diff --git a/lib/backend-api/schema.graphql b/lib/backend-api/schema.graphql index 6b6ee380633..1ca851e4a04 100644 --- a/lib/backend-api/schema.graphql +++ b/lib/backend-api/schema.graphql @@ -447,7 +447,6 @@ type PackageVersion implements Node & PackageReleaseInterface & PackageInstance totalDownloads: Int! bindingsState: RegistryPackageVersionBindingsStateChoices! nativeExecutablesState: RegistryPackageVersionNativeExecutablesStateChoices! - deployappversionSet(offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection! packagewebcSet(offset: Int, before: String, after: String, first: Int, last: Int): PackageWebcConnection! lastversionPackage(offset: Int, before: String, after: String, first: Int, last: Int): PackageConnection! commands: [Command!]! @@ -455,6 +454,7 @@ type PackageVersion implements Node & PackageReleaseInterface & PackageInstance bindingsgeneratorSet(offset: Int, before: String, after: String, first: Int, last: Int): BindingsGeneratorConnection! javascriptlanguagebindingSet(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionNPMBindingConnection! pythonlanguagebindingSet(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionPythonBindingConnection! + deployappversionSet(offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection! piritaManifest: JSONString piritaOffsets: JSONString piritaVolumes: JSONString @@ -583,498 +583,528 @@ enum RegistryPackageVersionNativeExecutablesStateChoices { GENERATED_AND_PRESENT } -type DeployAppVersionConnection { +type PackageWebcConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [DeployAppVersionEdge]! + edges: [PackageWebcEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `DeployAppVersion` and its cursor.""" -type DeployAppVersionEdge { +"""A Relay edge containing a `PackageWebc` and its cursor.""" +type PackageWebcEdge { """The item at the end of the edge""" - node: DeployAppVersion + node: PackageWebc """A cursor for use in pagination""" cursor: String! } -type DeployAppVersion implements Node { +type PackageWebc implements Node & PackageReleaseInterface & PackageInstance { """The ID of the object""" id: ID! - app: DeployApp! - yamlConfig: String! - userYamlConfig: String! - clientName: String! - signature: String - description: String - publishedBy: User! createdAt: DateTime! updatedAt: DateTime! - configWebc: String @deprecated(reason: "webc support has been deprecated for apps") - config: String! @deprecated(reason: "Please use jsonConfig instead") - jsonConfig: String! - url: String! - permalink: String! - urls: [String]! - version: String! - isActive: Boolean! - manifest: String! - logs( - """ - Get logs starting from this timestamp. Takes EPOCH timestamp in seconds. - """ - startingFrom: Float - - """Get logs starting from this timestamp. Takes ISO timestamp.""" - startingFromISO: DateTime - - """Fetch logs until this timestamp. Takes EPOCH timestamp in seconds.""" - until: Float - - """List of streams to fetch logs from. e.g. stdout, stderr.""" - streams: [LogStream] + package: Package! + webc: WebcImage + piritaManifest: JSONString + piritaOffsets: JSONString + piritaVolumes: JSONString + isArchived: Boolean! + clientName: String + publishedBy: User! + webcV3: WebcImage + tag: String! + webcUrl: String! +} - """List of instance ids to fetch logs from.""" - instanceIds: [String] - before: String - after: String - first: Int - last: Int - ): LogConnection! - usageMetrics(forRange: MetricRange!, variant: MetricType!): [UsageMetric]! - sourcePackageVersion: PackageVersion - sourcePackageRelease: PackageWebc - sourcePackage: Package! - aggregateMetrics: AggregateMetrics! - volumes: [AppVersionVolume] - favicon: URL - screenshot: URL +type Command { + command: String! + packageVersion: PackageVersion! + module: PackageVersionModule! } -type DeployApp implements Node & Owner { - """The ID of the object""" - id: ID! - createdBy: User! - createdAt: DateTime! - updatedAt: DateTime! - activeVersion: DeployAppVersion! - globalName: String! - globalId: ID! - url: String! - adminUrl: String! - permalink: String! - urls: [String]! - description: String +type PackageVersionModule { name: String! - owner: Owner! - versions(sortBy: DeployAppVersionsSortBy, createdAfter: DateTime, offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection! - aggregateMetrics: AggregateMetrics! - aliases(offset: Int, before: String, after: String, first: Int, last: Int): AppAliasConnection! - usageMetrics(forRange: MetricRange!, variant: MetricType!): [UsageMetric]! - deleted: Boolean! - favicon: URL - screenshot: URL + source: String! + abi: String + publicUrl: String! + atom: PiritaFilesystemFile! + rangeHeader: String! } -enum DeployAppVersionsSortBy { - NEWEST - OLDEST +type PiritaFilesystemFile { + name(display: PiritaFilesystemNameDisplay): String! + size: Int! + offset: Int! } -type AggregateMetrics { - cpuTime: String! - memoryTime: String! - ingress: String! - egress: String! - noRequests: String! - noFailedRequests: String! - monthlyCost: String! +enum PiritaFilesystemNameDisplay { + RELATIVE + ABSOLUTE } -type AppAliasConnection { +type NativeExecutableConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [AppAliasEdge]! + edges: [NativeExecutableEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `AppAlias` and its cursor.""" -type AppAliasEdge { +"""A Relay edge containing a `NativeExecutable` and its cursor.""" +type NativeExecutableEdge { """The item at the end of the edge""" - node: AppAlias + node: NativeExecutable """A cursor for use in pagination""" cursor: String! } -type AppAlias implements Node { - name: String! - app: DeployApp! - isDefault: Boolean! - hostname: String! - text: String! - kind: DeployAppAliasKindChoices! - +type NativeExecutable implements Node { """The ID of the object""" id: ID! - url: String! + module: String! @deprecated(reason: "Use filename instead") + filename: String! + filesize: Int! + targetTriple: String! + downloadUrl: String! } -enum DeployAppAliasKindChoices { - """Deployment""" - DEPLOYMENT - - """Domain""" - DOMAIN -} +type BindingsGeneratorConnection { + """Pagination data for this connection.""" + pageInfo: PageInfo! -type UsageMetric { - variant: MetricType! - value: Float! - unit: MetricUnit! - timestamp: DateTime! -} + """Contains the nodes in this connection.""" + edges: [BindingsGeneratorEdge]! -enum MetricType { - cpu_time - memory_time - network_egress - network_ingress - no_of_requests - no_of_failed_requests - cost + """Total number of items in the connection.""" + totalCount: Int } -"""Units for metrics""" -enum MetricUnit { - """represents the unit of "seconds".""" - SEC - - """represents the unit of "milliseconds".""" - MS - - """represents the unit of "kilobytes".""" - KB - - """represents the unit of "kilobytes per second".""" - KBS - - """represents the unit of "number of requests".""" - NO_REQUESTS +"""A Relay edge containing a `BindingsGenerator` and its cursor.""" +type BindingsGeneratorEdge { + """The item at the end of the edge""" + node: BindingsGenerator - """represents the unit of "cost" in USD.""" - DOLLARS + """A cursor for use in pagination""" + cursor: String! } -enum MetricRange { - LAST_24_HOURS - LAST_30_DAYS - LAST_1_HOUR +type BindingsGenerator implements Node { + """The ID of the object""" + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + packageVersion: PackageVersion! + active: Boolean! + commandName: String! + registryJavascriptlanguagebindings(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionNPMBindingConnection! + registryPythonlanguagebindings(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionPythonBindingConnection! } -""" -The `URL` scalar type represents a URL as text, represented as UTF-8 -character sequences. -""" -scalar URL - -type LogConnection { +type PackageVersionNPMBindingConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [LogEdge]! + edges: [PackageVersionNPMBindingEdge]! + + """Total number of items in the connection.""" + totalCount: Int } -"""A Relay edge containing a `Log` and its cursor.""" -type LogEdge { +"""A Relay edge containing a `PackageVersionNPMBinding` and its cursor.""" +type PackageVersionNPMBindingEdge { """The item at the end of the edge""" - node: Log + node: PackageVersionNPMBinding """A cursor for use in pagination""" cursor: String! } -enum LogStream { - STDOUT - STDERR - RUNTIME -} - -type PackageWebc implements Node & PackageReleaseInterface & PackageInstance { +type PackageVersionNPMBinding implements PackageVersionLanguageBinding & Node { """The ID of the object""" id: ID! + language: ProgrammingLanguage! + + """The URL of the generated artifacts on Wasmer CDN.""" + url: String! + + """When the binding was generated""" createdAt: DateTime! - updatedAt: DateTime! - package: Package! - webc: WebcImage - piritaManifest: JSONString - piritaOffsets: JSONString - piritaVolumes: JSONString - isArchived: Boolean! - clientName: String - publishedBy: User! - webcV3: WebcImage - tag: String! - webcUrl: String! + + """Package version used to generate this binding""" + generator: BindingsGenerator! + name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + + """Name of package source""" + packageName: String! + + """Name of the package to import""" + importablePackageName: String! + + """Code snippet example to use the package""" + codeSnippetExample: String! + module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + npmDefaultInstallPackageName(url: String): String! @deprecated(reason: "Please use packageName instead") } -type AppVersionVolume { - name: String! - mountPaths: [AppVersionVolumeMountPath]! - size: Int - usedSize: Int +interface PackageVersionLanguageBinding { + id: ID! + language: ProgrammingLanguage! + + """The URL of the generated artifacts on Wasmer CDN.""" + url: String! + + """When the binding was generated""" + createdAt: DateTime! + + """Package version used to generate this binding""" + generator: BindingsGenerator! + name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + + """Name of package source""" + packageName: String! + + """Name of the package to import""" + importablePackageName: String! + + """Code snippet example to use the package""" + codeSnippetExample: String! + module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") } -type AppVersionVolumeMountPath { - path: String! - subpath: String! +enum ProgrammingLanguage { + PYTHON + JAVASCRIPT } -type PackageWebcConnection { +type PackageVersionPythonBindingConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [PackageWebcEdge]! + edges: [PackageVersionPythonBindingEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `PackageWebc` and its cursor.""" -type PackageWebcEdge { +""" +A Relay edge containing a `PackageVersionPythonBinding` and its cursor. +""" +type PackageVersionPythonBindingEdge { """The item at the end of the edge""" - node: PackageWebc + node: PackageVersionPythonBinding """A cursor for use in pagination""" cursor: String! } -type Command { - command: String! - packageVersion: PackageVersion! - module: PackageVersionModule! -} +type PackageVersionPythonBinding implements PackageVersionLanguageBinding & Node { + """The ID of the object""" + id: ID! + language: ProgrammingLanguage! -type PackageVersionModule { - name: String! - source: String! - abi: String - publicUrl: String! - atom: PiritaFilesystemFile! - rangeHeader: String! -} + """The URL of the generated artifacts on Wasmer CDN.""" + url: String! -type PiritaFilesystemFile { - name(display: PiritaFilesystemNameDisplay): String! - size: Int! - offset: Int! -} + """When the binding was generated""" + createdAt: DateTime! -enum PiritaFilesystemNameDisplay { - RELATIVE - ABSOLUTE + """Package version used to generate this binding""" + generator: BindingsGenerator! + name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + + """Name of package source""" + packageName: String! + + """Name of the package to import""" + importablePackageName: String! + + """Code snippet example to use the package""" + codeSnippetExample: String! + module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + pythonDefaultInstallPackageName(url: String): String! } -type NativeExecutableConnection { +type DeployAppVersionConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [NativeExecutableEdge]! + edges: [DeployAppVersionEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `NativeExecutable` and its cursor.""" -type NativeExecutableEdge { +"""A Relay edge containing a `DeployAppVersion` and its cursor.""" +type DeployAppVersionEdge { """The item at the end of the edge""" - node: NativeExecutable + node: DeployAppVersion """A cursor for use in pagination""" cursor: String! } -type NativeExecutable implements Node { - """The ID of the object""" - id: ID! - module: String! @deprecated(reason: "Use filename instead") - filename: String! - filesize: Int! - targetTriple: String! - downloadUrl: String! +type DeployAppVersion implements Node { + """The ID of the object""" + id: ID! + app: DeployApp! + yamlConfig: String! + userYamlConfig: String! + clientName: String! + signature: String + description: String + publishedBy: User! + createdAt: DateTime! + updatedAt: DateTime! + configWebc: String @deprecated(reason: "webc support has been deprecated for apps") + config: String! @deprecated(reason: "Please use jsonConfig instead") + jsonConfig: String! + url: String! + permalink: String! + urls: [String]! + version: String! + isActive: Boolean! + manifest: String! + logs( + """ + Get logs starting from this timestamp. Takes EPOCH timestamp in seconds. + """ + startingFrom: Float + + """Get logs starting from this timestamp. Takes ISO timestamp.""" + startingFromISO: DateTime + + """Fetch logs until this timestamp. Takes EPOCH timestamp in seconds.""" + until: Float + + """List of streams to fetch logs from. e.g. stdout, stderr.""" + streams: [LogStream] + + """List of instance ids to fetch logs from.""" + instanceIds: [String] + before: String + after: String + first: Int + last: Int + ): LogConnection! + usageMetrics(forRange: MetricRange!, variant: MetricType!): [UsageMetric]! + sourcePackageVersion: PackageVersion + sourcePackageRelease: PackageWebc + sourcePackage: Package! + aggregateMetrics: AggregateMetrics! + volumes: [AppVersionVolume] + favicon: URL + screenshot: URL +} + +type DeployApp implements Node & Owner { + """The ID of the object""" + id: ID! + createdBy: User! + createdAt: DateTime! + updatedAt: DateTime! + activeVersion: DeployAppVersion! + globalName: String! + globalId: ID! + url: String! + adminUrl: String! + permalink: String! + urls: [String]! + description: String + name: String! + owner: Owner! + versions(sortBy: DeployAppVersionsSortBy, createdAfter: DateTime, offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection! + aggregateMetrics: AggregateMetrics! + aliases(offset: Int, before: String, after: String, first: Int, last: Int): AppAliasConnection! + secrets(offset: Int, before: String, after: String, first: Int, last: Int): SecretConnection! + usageMetrics(forRange: MetricRange!, variant: MetricType!): [UsageMetric]! + deleted: Boolean! + favicon: URL + screenshot: URL +} + +enum DeployAppVersionsSortBy { + NEWEST + OLDEST +} + +type AggregateMetrics { + cpuTime: String! + memoryTime: String! + ingress: String! + egress: String! + noRequests: String! + noFailedRequests: String! + monthlyCost: String! } -type BindingsGeneratorConnection { +type AppAliasConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [BindingsGeneratorEdge]! + edges: [AppAliasEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `BindingsGenerator` and its cursor.""" -type BindingsGeneratorEdge { +"""A Relay edge containing a `AppAlias` and its cursor.""" +type AppAliasEdge { """The item at the end of the edge""" - node: BindingsGenerator + node: AppAlias """A cursor for use in pagination""" cursor: String! } -type BindingsGenerator implements Node { +type AppAlias implements Node { + name: String! + app: DeployApp! + isDefault: Boolean! + hostname: String! + text: String! + kind: DeployAppAliasKindChoices! + """The ID of the object""" id: ID! - createdAt: DateTime! - updatedAt: DateTime! - packageVersion: PackageVersion! - active: Boolean! - commandName: String! - registryJavascriptlanguagebindings(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionNPMBindingConnection! - registryPythonlanguagebindings(offset: Int, before: String, after: String, first: Int, last: Int): PackageVersionPythonBindingConnection! + url: String! } -type PackageVersionNPMBindingConnection { +enum DeployAppAliasKindChoices { + """Deployment""" + DEPLOYMENT + + """Domain""" + DOMAIN +} + +type SecretConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [PackageVersionNPMBindingEdge]! + edges: [SecretEdge]! """Total number of items in the connection.""" totalCount: Int } -"""A Relay edge containing a `PackageVersionNPMBinding` and its cursor.""" -type PackageVersionNPMBindingEdge { +"""A Relay edge containing a `Secret` and its cursor.""" +type SecretEdge { """The item at the end of the edge""" - node: PackageVersionNPMBinding + node: Secret """A cursor for use in pagination""" cursor: String! } -type PackageVersionNPMBinding implements PackageVersionLanguageBinding & Node { - """The ID of the object""" - id: ID! - language: ProgrammingLanguage! - - """The URL of the generated artifacts on Wasmer CDN.""" - url: String! - - """When the binding was generated""" +type Secret implements Node { createdAt: DateTime! + updatedAt: DateTime! + name: String! - """Package version used to generate this binding""" - generator: BindingsGenerator! - name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - - """Name of package source""" - packageName: String! - - """Name of the package to import""" - importablePackageName: String! + """The ID of the object""" + id: ID! +} - """Code snippet example to use the package""" - codeSnippetExample: String! - module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - npmDefaultInstallPackageName(url: String): String! @deprecated(reason: "Please use packageName instead") +type UsageMetric { + variant: MetricType! + value: Float! + unit: MetricUnit! + timestamp: DateTime! } -interface PackageVersionLanguageBinding { - id: ID! - language: ProgrammingLanguage! +enum MetricType { + cpu_time + memory_time + network_egress + network_ingress + no_of_requests + no_of_failed_requests + cost +} - """The URL of the generated artifacts on Wasmer CDN.""" - url: String! +"""Units for metrics""" +enum MetricUnit { + """represents the unit of "seconds".""" + SEC - """When the binding was generated""" - createdAt: DateTime! + """represents the unit of "milliseconds".""" + MS - """Package version used to generate this binding""" - generator: BindingsGenerator! - name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + """represents the unit of "kilobytes".""" + KB - """Name of package source""" - packageName: String! + """represents the unit of "kilobytes per second".""" + KBS - """Name of the package to import""" - importablePackageName: String! + """represents the unit of "number of requests".""" + NO_REQUESTS - """Code snippet example to use the package""" - codeSnippetExample: String! - module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") + """represents the unit of "cost" in USD.""" + DOLLARS } -enum ProgrammingLanguage { - PYTHON - JAVASCRIPT +enum MetricRange { + LAST_24_HOURS + LAST_30_DAYS + LAST_1_HOUR } -type PackageVersionPythonBindingConnection { +""" +The `URL` scalar type represents a URL as text, represented as UTF-8 +character sequences. +""" +scalar URL + +type LogConnection { """Pagination data for this connection.""" pageInfo: PageInfo! """Contains the nodes in this connection.""" - edges: [PackageVersionPythonBindingEdge]! - - """Total number of items in the connection.""" - totalCount: Int + edges: [LogEdge]! } -""" -A Relay edge containing a `PackageVersionPythonBinding` and its cursor. -""" -type PackageVersionPythonBindingEdge { +"""A Relay edge containing a `Log` and its cursor.""" +type LogEdge { """The item at the end of the edge""" - node: PackageVersionPythonBinding + node: Log """A cursor for use in pagination""" cursor: String! } -type PackageVersionPythonBinding implements PackageVersionLanguageBinding & Node { - """The ID of the object""" - id: ID! - language: ProgrammingLanguage! - - """The URL of the generated artifacts on Wasmer CDN.""" - url: String! - - """When the binding was generated""" - createdAt: DateTime! - - """Package version used to generate this binding""" - generator: BindingsGenerator! - name: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - kind: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - - """Name of package source""" - packageName: String! +enum LogStream { + STDOUT + STDERR + RUNTIME +} - """Name of the package to import""" - importablePackageName: String! +type AppVersionVolume { + name: String! + mountPaths: [AppVersionVolumeMountPath]! + size: Int + usedSize: Int +} - """Code snippet example to use the package""" - codeSnippetExample: String! - module: String! @deprecated(reason: "Do not use this field, since bindings for all modules are generated at once now.") - pythonDefaultInstallPackageName(url: String): String! +type AppVersionVolumeMountPath { + path: String! + subpath: String! } type PackageDistribution { @@ -2267,6 +2297,7 @@ input WorkloadRunnerWasmSourceV1 { type Query { latestTOS: TermsOfService! + getAppRegions(offset: Int, before: String, after: String, first: Int, last: Int): AppRegionConnection! getDeployAppVersion(name: String!, owner: String, version: String): DeployAppVersion getAllDomains(namespace: String, offset: Int, before: String, after: String, first: Int, last: Int): DNSDomainConnection! getAllDNSRecords(sortBy: DNSRecordsSortBy, updatedAfter: DateTime, before: String, after: String, first: Int, last: Int): DNSRecordConnection! @@ -2360,6 +2391,35 @@ type TermsOfService implements Node { viewerHasAccepted: Boolean! } +type AppRegionConnection { + """Pagination data for this connection.""" + pageInfo: PageInfo! + + """Contains the nodes in this connection.""" + edges: [AppRegionEdge]! + + """Total number of items in the connection.""" + totalCount: Int +} + +"""A Relay edge containing a `AppRegion` and its cursor.""" +type AppRegionEdge { + """The item at the end of the edge""" + node: AppRegion + + """A cursor for use in pagination""" + cursor: String! +} + +type AppRegion implements Node { + name: String! + country: String! + city: String! + + """The ID of the object""" + id: ID! +} + type DNSRecordConnection { """Pagination data for this connection.""" pageInfo: PageInfo! @@ -2431,35 +2491,6 @@ enum AppTemplatesSortBy { POPULAR } -type SecretConnection { - """Pagination data for this connection.""" - pageInfo: PageInfo! - - """Contains the nodes in this connection.""" - edges: [SecretEdge]! - - """Total number of items in the connection.""" - totalCount: Int -} - -"""A Relay edge containing a `Secret` and its cursor.""" -type SecretEdge { - """The item at the end of the edge""" - node: Secret - - """A cursor for use in pagination""" - cursor: String! -} - -type Secret implements Node { - createdAt: DateTime! - updatedAt: DateTime! - name: String! - - """The ID of the object""" - id: ID! -} - type SecretLogConnection { """Pagination data for this connection.""" pageInfo: PageInfo! @@ -3396,6 +3427,9 @@ input SecretInput { """Delete secret with given ID""" type DeleteAppSecretPayload { success: Boolean! + + """ID of the deleted secret.""" + id: ID! clientMutationId: String } diff --git a/lib/backend-api/src/query.rs b/lib/backend-api/src/query.rs index 0fae804ef5f..db0aaccfa16 100644 --- a/lib/backend-api/src/query.rs +++ b/lib/backend-api/src/query.rs @@ -129,6 +129,57 @@ pub async fn get_all_app_secrets_filtered( Ok(all_secrets) } +/// Load all available regions. +/// +/// Will paginate through all versions and return them in a single list. +pub async fn get_all_app_regions(client: &WasmerClient) -> Result, anyhow::Error> { + let mut vars = GetAllAppRegionsVariables { + after: None, + before: None, + first: None, + last: None, + offset: None, + }; + + let mut all_regions = Vec::::new(); + + loop { + let page = get_regions(client, vars.clone()).await?; + if page.edges.is_empty() { + break; + } + + for edge in page.edges { + let edge = match edge { + Some(edge) => edge, + None => continue, + }; + let version = match edge.node { + Some(item) => item, + None => continue, + }; + + all_regions.push(version); + + // Update pagination. + vars.after = Some(edge.cursor); + } + } + + Ok(all_regions) +} + +/// Retrieve regions. +pub async fn get_regions( + client: &WasmerClient, + vars: GetAllAppRegionsVariables, +) -> Result { + let res = client + .run_graphql_strict(types::GetAllAppRegions::build(vars)) + .await?; + Ok(res.get_app_regions) +} + /// Load all secrets of an app. /// /// Will paginate through all versions and return them in a single list. diff --git a/lib/backend-api/src/types.rs b/lib/backend-api/src/types.rs index ddfebc0259e..124c3899394 100644 --- a/lib/backend-api/src/types.rs +++ b/lib/backend-api/src/types.rs @@ -1311,6 +1311,43 @@ mod queries { pub updated_at: DateTime, } + #[derive(cynic::QueryVariables, Debug, Clone)] + pub struct GetAllAppRegionsVariables { + pub after: Option, + pub before: Option, + pub first: Option, + pub last: Option, + pub offset: Option, + } + + #[derive(cynic::QueryFragment, Debug)] + #[cynic(graphql_type = "Query", variables = "GetAllAppRegionsVariables")] + pub struct GetAllAppRegions { + #[arguments(after: $after, offset: $offset, before: $before, first: $first, last: $last)] + pub get_app_regions: AppRegionConnection, + } + + #[derive(cynic::QueryFragment, Debug)] + pub struct AppRegionConnection { + pub edges: Vec>, + pub page_info: PageInfo, + pub total_count: Option, + } + + #[derive(cynic::QueryFragment, Debug)] + pub struct AppRegionEdge { + pub cursor: String, + pub node: Option, + } + + #[derive(cynic::QueryFragment, Debug, Serialize)] + pub struct AppRegion { + pub city: String, + pub country: String, + pub id: cynic::Id, + pub name: String, + } + #[derive(cynic::QueryFragment, Debug, Clone, Serialize)] #[cynic(graphql_type = "TXTRecord")] pub struct TxtRecord { diff --git a/lib/cli/src/commands/app/mod.rs b/lib/cli/src/commands/app/mod.rs index 3da02d42eb8..cc3ad250055 100644 --- a/lib/cli/src/commands/app/mod.rs +++ b/lib/cli/src/commands/app/mod.rs @@ -8,6 +8,7 @@ pub mod info; pub mod list; pub mod logs; pub mod purge_cache; +pub mod regions; pub mod secrets; pub mod version; @@ -30,6 +31,8 @@ pub enum CmdApp { Version(version::CmdAppVersion), #[clap(subcommand, alias = "secrets")] Secret(secrets::CmdAppSecrets), + #[clap(subcommand, alias = "regions")] + Region(regions::CmdAppRegions), } #[async_trait::async_trait] @@ -57,6 +60,7 @@ impl AsyncCliCommand for CmdApp { Self::Deploy(cmd) => cmd.run_async().await, Self::PurgeCache(cmd) => cmd.run_async().await, Self::Secret(cmd) => cmd.run_async().await, + Self::Region(cmd) => cmd.run_async().await, } } } diff --git a/lib/cli/src/commands/app/regions/list.rs b/lib/cli/src/commands/app/regions/list.rs new file mode 100644 index 00000000000..ca9e8ac2f68 --- /dev/null +++ b/lib/cli/src/commands/app/regions/list.rs @@ -0,0 +1,42 @@ +use crate::{ + commands::AsyncCliCommand, + opts::{ApiOpts, ListFormatOpts, WasmerEnv}, +}; +use is_terminal::IsTerminal; + +/// List available Edge regions. +#[derive(clap::Parser, Debug)] +pub struct CmdAppRegionsList { + /* --- Common flags --- */ + #[clap(flatten)] + #[allow(missing_docs)] + pub api: ApiOpts, + + #[clap(flatten)] + pub env: WasmerEnv, + + /// Don't print any message. + #[clap(long)] + pub quiet: bool, + + /// Do not prompt for user input. + #[clap(long, default_value_t = !std::io::stdin().is_terminal())] + pub non_interactive: bool, + + #[clap(flatten)] + pub fmt: ListFormatOpts, +} + +#[async_trait::async_trait] +impl AsyncCliCommand for CmdAppRegionsList { + type Output = (); + + async fn run_async(self) -> Result { + let client = self.api.client()?; + let regions = wasmer_api::query::get_all_app_regions(&client).await?; + + println!("{}", self.fmt.format.render(regions.as_slice())); + + Ok(()) + } +} diff --git a/lib/cli/src/commands/app/regions/mod.rs b/lib/cli/src/commands/app/regions/mod.rs new file mode 100644 index 00000000000..c196f8b6bce --- /dev/null +++ b/lib/cli/src/commands/app/regions/mod.rs @@ -0,0 +1,24 @@ +use crate::commands::AsyncCliCommand; + +pub mod list; +mod utils; + +/// Informations about available Edge regioins. +#[derive(Debug, clap::Parser)] +pub enum CmdAppRegions { + List(list::CmdAppRegionsList), +} + +#[async_trait::async_trait] +impl AsyncCliCommand for CmdAppRegions { + type Output = (); + + async fn run_async(self) -> Result { + match self { + Self::List(c) => { + c.run_async().await?; + Ok(()) + } + } + } +} diff --git a/lib/cli/src/commands/app/regions/utils/mod.rs b/lib/cli/src/commands/app/regions/utils/mod.rs new file mode 100644 index 00000000000..14f3a4214d5 --- /dev/null +++ b/lib/cli/src/commands/app/regions/utils/mod.rs @@ -0,0 +1 @@ +pub(crate) mod render; diff --git a/lib/cli/src/commands/app/regions/utils/render.rs b/lib/cli/src/commands/app/regions/utils/render.rs new file mode 100644 index 00000000000..bb03497fc40 --- /dev/null +++ b/lib/cli/src/commands/app/regions/utils/render.rs @@ -0,0 +1,55 @@ +use crate::utils::render::CliRender; +use comfy_table::{Cell, Table}; +use wasmer_api::types::AppRegion; + +impl CliRender for AppRegion { + fn render_item_table(&self) -> String { + let mut table = Table::new(); + let AppRegion { + name, + city, + country, + .. + }: &AppRegion = self; + + table.load_preset(comfy_table::presets::NOTHING); + table.set_content_arrangement(comfy_table::ContentArrangement::Dynamic); + + table.add_rows([ + vec![ + Cell::new("Name".to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new("City".to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new("Country code".to_string()).add_attribute(comfy_table::Attribute::Bold), + ], + vec![ + Cell::new(name.to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new(city.to_string()), + Cell::new(country.to_string()), + ], + ]); + table.to_string() + } + + fn render_list_table(items: &[Self]) -> String { + if items.is_empty() { + return String::new(); + } + let mut table = Table::new(); + table.load_preset(comfy_table::presets::NOTHING); + //table.set_content_arrangement(comfy_table::ContentArrangement::Dynamic); + + table.set_header(vec![ + Cell::new("Name".to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new("City".to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new("Country code".to_string()).add_attribute(comfy_table::Attribute::Bold), + ]); + table.add_rows(items.iter().map(|s| { + vec![ + Cell::new(s.name.to_string()).add_attribute(comfy_table::Attribute::Bold), + Cell::new(s.city.to_string()), + Cell::new(s.country.to_string()), + ] + })); + table.to_string() + } +}