Skip to content

Commit

Permalink
Merge branch 'main' into 4.3.0-alpha.1-leftover-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 committed May 8, 2024
2 parents 5cb7a99 + 0d61573 commit ea6b67a
Show file tree
Hide file tree
Showing 76 changed files with 2,995 additions and 989 deletions.
690 changes: 394 additions & 296 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ wasmer-compiler-cranelift = { version = "=4.3.0-alpha.1", path = "lib/compiler-c
wasmer-compiler-singlepass = { version = "=4.3.0-alpha.1", path = "lib/compiler-singlepass", optional = true }
wasmer-compiler-llvm = { version = "=4.3.0-alpha.1", path = "lib/compiler-llvm", optional = true }
wasmer-emscripten = { version = "=4.3.0-alpha.1", path = "lib/emscripten", optional = true }
wasmer-wasix = { version = "0.18.4", path = "lib/wasix", optional = true }
wasmer-wasix = { path = "lib/wasix", optional = true }
wasmer-wast = { version = "=4.3.0-alpha.1", path = "tests/lib/wast", optional = true }
wasi-test-generator = { version = "=4.3.0-alpha.1", path = "tests/wasi-wast", optional = true }
wasmer-cache = { version = "=4.3.0-alpha.1", path = "lib/cache", optional = true }
wasmer-types = { version = "=4.3.0-alpha.1", path = "lib/types" }
wasmer-middlewares = { version = "=4.3.0-alpha.1", path = "lib/middlewares", optional = true }

# Third party dependencies
cfg-if = "1.0"
tokio = { version = "1", features = [
"rt",
Expand Down Expand Up @@ -87,9 +89,10 @@ version = "4.3.0-alpha.1"
[workspace.dependencies]
# Repo-local crates
wasmer-config = { path = "./lib/config" }
wasmer-wasix = { path = "./lib/wasix" }

# Wasmer-owned crates
webc = { version = "6.0.0-alpha3", default-features = false, features = ["package"] }
webc = { version = "6.0.0-alpha8", default-features = false, features = ["package"] }
edge-schema = { version = "=0.1.0" }
shared-buffer = "0.1.4"

Expand Down
98 changes: 68 additions & 30 deletions lib/backend-api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ type Package implements Likeable & Node & PackageOwner {
"""List of app templates for this package"""
appTemplates(offset: Int, before: String, after: String, first: Int, last: Int): AppTemplateConnection!
packagewebcSet(offset: Int, before: String, after: String, first: Int, last: Int): PackageWebcConnection!
versions: [PackageVersion]!
versions: [PackageVersion]
collectionSet: [Collection!]!
categories(offset: Int, before: String, after: String, first: Int, last: Int): CategoryConnection!
keywords(offset: Int, before: String, after: String, first: Int, last: Int): PackageKeywordConnection!
Expand Down Expand Up @@ -504,7 +504,7 @@ scalar JSONString
type WebcImage implements Node {
"""The ID of the object"""
id: ID!
version: RegistryWebcImageVersionChoices!
version: WebcVersion

""""""
fileSize: BigInt!
Expand All @@ -518,11 +518,8 @@ type WebcImage implements Node {
webcUrl: String!
}

enum RegistryWebcImageVersionChoices {
"""v2"""
enum WebcVersion {
V2

"""v3"""
V3
}

Expand Down Expand Up @@ -645,7 +642,9 @@ type DeployAppVersion implements Node {
last: Int
): LogConnection!
usageMetrics(forRange: MetricRange!, variant: MetricType!): [UsageMetric]!
sourcePackageVersion: PackageVersion!
sourcePackageVersion: PackageVersion
sourcePackageRelease: PackageWebc
sourcePackage: Package!
aggregateMetrics: AggregateMetrics!
volumes: [AppVersionVolume]
favicon: URL
Expand Down Expand Up @@ -806,6 +805,24 @@ enum LogStream {
RUNTIME
}

type PackageWebc implements Node & PackageReleaseInterface & PackageInstance {
"""The ID of the object"""
id: ID!
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!
}

type AppVersionVolume {
name: String!
mountPaths: [AppVersionVolumeMountPath]!
Expand Down Expand Up @@ -1052,11 +1069,6 @@ type PackageDistribution {
webcVersion: WebcVersion
}

enum WebcVersion {
V2
V3
}

type PackageVersionFilesystem {
wasm: String!
host: String!
Expand Down Expand Up @@ -1235,24 +1247,6 @@ type PackageWebcEdge {
cursor: String!
}

type PackageWebc implements Node & PackageReleaseInterface & PackageInstance {
"""The ID of the object"""
id: ID!
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!
}

type Collection {
slug: String!
displayName: String!
Expand Down Expand Up @@ -2834,6 +2828,8 @@ type Mutation {
mfa2EmailGetToken(input: MFAGenerateEmailOTPInput!): MFAEmailGenerationResponse
publishPublicKey(input: PublishPublicKeyInput!): PublishPublicKeyPayload
publishPackage(input: PublishPackageInput!): PublishPackagePayload
pushPackageRelease(input: PushPackageReleaseInput!): PushPackageReleasePayload
tagPackageRelease(input: TagPackageReleaseInput!): TagPackageReleasePayload
updatePackage(input: UpdatePackageInput!): UpdatePackagePayload
likePackage(input: LikePackageInput!): LikePackagePayload
unlikePackage(input: UnlikePackageInput!): UnlikePackagePayload
Expand Down Expand Up @@ -3586,6 +3582,48 @@ enum UploadFormat {
webcv3
}

type PushPackageReleasePayload {
success: Boolean!
packageWebc: PackageWebc
clientMutationId: String
}

input PushPackageReleaseInput {
namespace: String!
signedUrl: String!
name: String

"""Whether the package is private"""
private: Boolean = false
clientMutationId: String
}

type TagPackageReleasePayload {
success: Boolean!
packageVersion: PackageVersion
clientMutationId: String
}

input TagPackageReleaseInput {
packageReleaseId: ID!
name: String!
version: String!
manifest: String!
namespace: String
description: String
license: String
licenseFile: String
readme: String
repository: String
homepage: String
signature: InputSignature

"""The package icon"""
icon: String
private: Boolean = false
clientMutationId: String
}

type UpdatePackagePayload {
package: Package!
clientMutationId: String
Expand Down
83 changes: 81 additions & 2 deletions lib/backend-api/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use crate::{
types::{
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
DeployAppVersionConnection, DnsDomain, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
GetDeployAppVersionsVars, GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection,
PublishDeployAppVars, UpsertDomainFromZoneFileVars,
GetDeployAppVersionsVars, GetNamespaceAppsVars, GetSignedUrlForPackageUploadVariables, Log,
LogStream, PackageVersionConnection, PublishDeployAppVars, PushPackageReleasePayload,
SignedUrl, TagPackageReleasePayload, UpsertDomainFromZoneFileVars,
},
GraphQLApiFailure, WasmerClient,
};
Expand Down Expand Up @@ -54,6 +55,84 @@ pub async fn fetch_webc_package(
webc::compat::Container::from_bytes(data).context("failed to parse webc package")
}

/// Get a signed URL to upload packages.
pub async fn get_signed_url_for_package_upload(
client: &WasmerClient,
expires_after_seconds: Option<i32>,
filename: Option<&str>,
name: Option<&str>,
version: Option<&str>,
) -> Result<Option<SignedUrl>, anyhow::Error> {
client
.run_graphql(types::GetSignedUrlForPackageUpload::build(
GetSignedUrlForPackageUploadVariables {
expires_after_seconds,
filename,
name,
version,
},
))
.await
.map(|r| r.get_signed_url_for_package_upload)
}
/// Push a package to the registry.
pub async fn push_package_release(
client: &WasmerClient,
name: Option<&str>,
namespace: &str,
signed_url: &str,
private: Option<bool>,
) -> Result<Option<PushPackageReleasePayload>, anyhow::Error> {
client
.run_graphql_strict(types::PushPackageRelease::build(
types::PushPackageReleaseVariables {
name,
namespace,
private,
signed_url,
},
))
.await
.map(|r| r.push_package_release)
}

#[allow(clippy::too_many_arguments)]
pub async fn tag_package_release(
client: &WasmerClient,
description: Option<&str>,
homepage: Option<&str>,
license: Option<&str>,
license_file: Option<&str>,
manifest: &str,
name: &str,
namespace: Option<&str>,
package_release_id: &cynic::Id,
private: Option<bool>,
readme: Option<&str>,
repository: Option<&str>,
version: &str,
) -> Result<Option<TagPackageReleasePayload>, anyhow::Error> {
client
.run_graphql_strict(types::TagPackageRelease::build(
types::TagPackageReleaseVariables {
description,
homepage,
license,
license_file,
manifest,
name,
namespace,
package_release_id,
private,
readme,
repository,
version,
},
))
.await
.map(|r| r.tag_package_release)
}

/// Get the currently logged in used, together with all accessible namespaces.
///
/// You can optionally filter the namespaces by the user role.
Expand Down
Loading

0 comments on commit ea6b67a

Please sign in to comment.