Skip to content

Commit

Permalink
Do not curie self/incoming/outgoing links (#4191)
Browse files Browse the repository at this point in the history
* Do not curie self/incoming/outgoing links

---------

Co-authored-by: Simon Dumas <simon.dumas@epfl.ch>
  • Loading branch information
imsdu and Simon Dumas authored Aug 23, 2023
1 parent 0c5760b commit 0c245f0
Show file tree
Hide file tree
Showing 130 changed files with 1,013 additions and 1,390 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ object ProjectsModule extends ModuleDef {
Task.pure(FetchContext(organizations, projects, quotas))
}

make[ProjectContextCache].fromEffect { (fetchContext: FetchContext[ContextRejection]) =>
ProjectContextCache(fetchContext)
}

make[ProjectDeletionCoordinator].fromEffect {
(
projects: Projects,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.wiring

import cats.effect.{Clock, Sync}
import ch.epfl.bluebrain.nexus.delta.sdk.ResourceShifts
import ch.epfl.bluebrain.nexus.delta.sdk.projects.ProjectContextCache
import ch.epfl.bluebrain.nexus.delta.sdk.stream.GraphResourceStream
import ch.epfl.bluebrain.nexus.delta.sourcing.config.{ProjectionConfig, QueryConfig}
import ch.epfl.bluebrain.nexus.delta.sourcing.projections.{ProjectionErrors, Projections}
Expand All @@ -20,12 +19,11 @@ object StreamModule extends ModuleDef {

make[GraphResourceStream].from {
(
contextCache: ProjectContextCache,
qc: QueryConfig,
xas: Transactors,
shifts: ResourceShifts
) =>
GraphResourceStream(contextCache.fetchContext, qc, xas, shifts)
GraphResourceStream(qc, xas, shifts)
}

many[PipeDef].add(DiscardMetadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"_createdAt": "1970-01-01T00:00:00Z",
"_createdBy": "http://localhost/v1/anonymous",
"_deprecated": false,
"_incoming": "http://localhost/v1/resources/org/proj1/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fschemas%2Funconstrained.json/success/incoming",
"_outgoing": "http://localhost/v1/resources/org/proj1/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fschemas%2Funconstrained.json/success/outgoing",
"_incoming": "http://localhost/v1/resources/org/proj1/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2Fsuccess/incoming",
"_outgoing": "http://localhost/v1/resources/org/proj1/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2Fsuccess/outgoing",
"_project": "http://localhost/v1/projects/org/proj1",
"_rev": 1,
"_schemaProject": "http://localhost/v1/projects/org/proj1",
"_self": "http://localhost/v1/resources/org/proj1/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fschemas%2Funconstrained.json/success",
"_self": "http://localhost/v1/resources/org/proj1/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2Fsuccess",
"_updatedAt": "1970-01-01T00:00:00Z",
"_updatedBy": "http://localhost/v1/anonymous"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"_createdAt" : "1970-01-01T00:00:00Z",
"_createdBy" : "{{createdBy}}",
"_deprecated" : {{deprecated}},
"_incoming" : "http://localhost/v1/resolvers/{{project}}/{{label}}/incoming",
"_outgoing" : "http://localhost/v1/resolvers/{{project}}/{{label}}/outgoing",
"_incoming" : "{{self}}/incoming",
"_outgoing" : "{{self}}/outgoing",
"_project" : "http://localhost/v1/projects/{{project}}",
"_rev" : {{rev}},
"_self" : "http://localhost/v1/resolvers/{{project}}/{{label}}",
"_self" : "{{self}}",
"_updatedAt" : "1970-01-01T00:00:00Z",
"_updatedBy" : "{{updatedBy}}"
}
6 changes: 3 additions & 3 deletions delta/app/src/test/resources/resolvers/resource-resolved.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"_createdAt": "1970-01-01T00:00:00Z",
"_createdBy": "http://localhost/v1/anonymous",
"_deprecated": false,
"_incoming": "http://localhost/v1/resources/org/project/_/resource/incoming",
"_outgoing": "http://localhost/v1/resources/org/project/_/resource/outgoing",
"_incoming": "{{self}}/incoming",
"_outgoing": "{{self}}/outgoing",
"_project": "http://localhost/v1/projects/org/project",
"_schemaProject": "http://localhost/v1/projects/org/project",
"_rev": 1,
"_self": "http://localhost/v1/resources/org/project/_/resource",
"_self": "{{self}}",
"_updatedAt": "1970-01-01T00:00:00Z",
"_updatedBy": "http://localhost/v1/anonymous",
"bool": false,
Expand Down
6 changes: 3 additions & 3 deletions delta/app/src/test/resources/resolvers/schema-resolved.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"_createdAt": "1970-01-01T00:00:00Z",
"_createdBy": "http://localhost/v1/anonymous",
"_deprecated": false,
"_incoming": "http://localhost/v1/schemas/org/project/schemaId/incoming",
"_outgoing": "http://localhost/v1/schemas/org/project/schemaId/outgoing",
"_incoming": "{{self}}/incoming",
"_outgoing": "{{self}}/outgoing",
"_project": "http://localhost/v1/projects/org/project",
"_rev": 1,
"_self": "http://localhost/v1/schemas/org/project/schemaId",
"_self": "{{self}}",
"_updatedAt": "1970-01-01T00:00:00Z",
"_updatedBy": "http://localhost/v1/anonymous",
"shapes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"_createdAt" : "1970-01-01T00:00:00Z",
"_createdBy" : "{{createdBy}}",
"_deprecated" : {{deprecated}},
"_incoming" : "http://localhost/v1/resources/{{project}}/{{schemaLabel}}/{{label}}/incoming",
"_outgoing" : "http://localhost/v1/resources/{{project}}/{{schemaLabel}}/{{label}}/outgoing",
"_incoming" : "{{self}}/incoming",
"_outgoing" : "{{self}}/outgoing",
"_project" : "http://localhost/v1/projects/{{project}}",
"_rev" : {{rev}},
"_schemaProject" : "http://localhost/v1/projects/{{project}}",
"_self" : "http://localhost/v1/resources/{{project}}/{{schemaLabel}}/{{label}}",
"_self" : "{{self}}",
"_updatedAt" : "1970-01-01T00:00:00Z",
"_updatedBy" : "{{updatedBy}}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"_createdAt" : "1970-01-01T00:00:00Z",
"_createdBy" : "http://localhost/v1/realms/wonderland/users/alice",
"_deprecated" : false,
"_incoming" : "http://localhost/v1/schemas/myorg/myproject/myid2/incoming",
"_outgoing" : "http://localhost/v1/schemas/myorg/myproject/myid2/outgoing",
"_incoming" : "{{self}}/incoming",
"_outgoing" : "{{self}}/outgoing",
"_project" : "http://localhost/v1/projects/myorg/myproject",
"_rev" : 1,
"_self" : "http://localhost/v1/schemas/myorg/myproject/myid2",
"_self" : "{{self}}",
"_updatedAt" : "1970-01-01T00:00:00Z",
"_updatedBy" : "http://localhost/v1/realms/wonderland/users/alice",
"shapes" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"_createdAt" : "1970-01-01T00:00:00Z",
"_createdBy" : "{{createdBy}}",
"_deprecated" : {{deprecated}},
"_incoming" : "http://localhost/v1/schemas/{{project}}/{{label}}/incoming",
"_outgoing" : "http://localhost/v1/schemas/{{project}}/{{label}}/outgoing",
"_incoming" : "{{self}}/incoming",
"_outgoing" : "{{self}}/outgoing",
"_project" : "http://localhost/v1/projects/{{project}}",
"_rev" : {{rev}},
"_self" : "http://localhost/v1/schemas/{{project}}/{{label}}",
"_self" : "{{self}}",
"_updatedAt" : "1970-01-01T00:00:00Z",
"_updatedBy" : "{{updatedBy}}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"_createdAt": "1970-01-01T00:00:00Z",
"_createdBy": "http://localhost/v1/anonymous",
"_deprecated": true,
"_incoming": "http://localhost/v1/schemas/myorg/myproject/myid/incoming",
"_outgoing": "http://localhost/v1/schemas/myorg/myproject/myid/outgoing",
"_incoming": "{{self}}/incoming",
"_outgoing": "{{self}}/outgoing",
"_project": "http://localhost/v1/projects/myorg/myproject",
"_rev": 6,
"_self": "http://localhost/v1/schemas/myorg/myproject/myid",
"_self": "{{self}}",
"_updatedAt": "1970-01-01T00:00:00Z",
"_updatedBy": "http://localhost/v1/anonymous",
"shapes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import akka.http.scaladsl.server.Route
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{UUIDF, UrlUtils}
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.{contexts, nxv, schema, schemas}
import ch.epfl.bluebrain.nexus.delta.sdk.{Defaults, IndexingAction}
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
Expand All @@ -16,17 +15,18 @@ import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdContent
import ch.epfl.bluebrain.nexus.delta.sdk.model.ResourceUris
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContextDummy
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ApiMappings
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers._
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.ResolverRejection.ProjectContextRejection
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.ResolverType.{CrossProject, InProject}
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.{ResolverRejection, ResolverType, ResourceResolutionReport}
import ch.epfl.bluebrain.nexus.delta.sdk.resources.Resources
import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.Resource
import ch.epfl.bluebrain.nexus.delta.sdk.schemas.model.Schema
import ch.epfl.bluebrain.nexus.delta.sdk.utils.BaseRouteSpec
import ch.epfl.bluebrain.nexus.delta.sdk.{Defaults, IndexingAction}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authenticated, Group, Subject}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef.{Latest, Revision}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef, ResourceRef}
Expand All @@ -45,13 +45,12 @@ class ResolversRoutesSpec extends BaseRouteSpec {
private val asAlice = addCredentials(OAuth2BearerToken(alice.subject))
private val asBob = addCredentials(OAuth2BearerToken(bob.subject))

private val org = Label.unsafe("org")
private val defaultApiMappings = Resources.mappings
private val am = ApiMappings("nxv" -> nxv.base, "Person" -> schema.Person, "resolver" -> schemas.resolvers)
private val projBase = nxv.base
private val project =
private val org = Label.unsafe("org")
private val am = ApiMappings("nxv" -> nxv.base, "Person" -> schema.Person, "resolver" -> schemas.resolvers)
private val projBase = nxv.base
private val project =
ProjectGen.project("org", "project", uuid = uuid, orgUuid = uuid, base = projBase, mappings = am)
private val project2 =
private val project2 =
ProjectGen.project("org", "project2", uuid = uuid, orgUuid = uuid, base = projBase, mappings = am)

private val identities = IdentitiesDummy(
Expand All @@ -67,7 +66,7 @@ class ResolversRoutesSpec extends BaseRouteSpec {
private val resourceId = nxv + "resource"
private val resource =
ResourceGen.resource(resourceId, project.ref, jsonContentOf("resources/resource.json", "id" -> resourceId))
private val resourceFR = ResourceGen.resourceFor(resource, types = Set(nxv + "Custom"), am = defaultApiMappings)
private val resourceFR = ResourceGen.resourceFor(resource, types = Set(nxv + "Custom"))

private val schemaId = nxv + "schemaId"
private val schemaResource = SchemaGen.schema(
Expand Down Expand Up @@ -724,13 +723,23 @@ class ResolversRoutesSpec extends BaseRouteSpec {
val idSchemaEncoded = UrlUtils.encode(schemaId.toString)
val unknownResourceEncoded = UrlUtils.encode((nxv + "xxx").toString)

val resourceResolved = jsonContentOf(
"resolvers/resource-resolved.json",
"self" -> ResourceUris.resource(project.ref, project.ref, resourceId).accessUri
)

val schemaResolved = jsonContentOf(
"resolvers/schema-resolved.json",
"self" -> ResourceUris.schema(project.ref, schemaId).accessUri
)

"resolve the resources/schemas" should {
"succeed as a resource for the given id" in {
// First we resolve with a in-project resolver, the second one with a cross-project resolver
forAll(List(project, project2)) { p =>
Get(s"/v1/resolvers/${p.ref}/_/$idResourceEncoded") ~> asAlice ~> routes ~> check {
response.status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("resolvers/resource-resolved.json")
response.asJson shouldEqual resourceResolved
}
}
}
Expand All @@ -747,7 +756,7 @@ class ResolversRoutesSpec extends BaseRouteSpec {
case (p, resolver) =>
Get(s"/v1/resolvers/${p.ref}/$resolver/$idResourceEncoded") ~> asAlice ~> routes ~> check {
response.status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("resolvers/resource-resolved.json")
response.asJson shouldEqual resourceResolved
}
}
}
Expand All @@ -766,7 +775,7 @@ class ResolversRoutesSpec extends BaseRouteSpec {
forAll(List(project, project2)) { p =>
Get(s"/v1/resolvers/${p.ref}/_/$idSchemaEncoded?rev=5") ~> asAlice ~> routes ~> check {
response.status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("resolvers/schema-resolved.json")
response.asJson shouldEqual schemaResolved
}
}
}
Expand All @@ -783,7 +792,7 @@ class ResolversRoutesSpec extends BaseRouteSpec {
case (p, resolver) =>
Get(s"/v1/resolvers/${p.ref}/$resolver/$idSchemaEncoded?rev=5") ~> asAlice ~> routes ~> check {
response.status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("resolvers/schema-resolved.json")
response.asJson shouldEqual schemaResolved
}
}
}
Expand Down Expand Up @@ -849,6 +858,6 @@ class ResolversRoutesSpec extends BaseRouteSpec {
"createdBy" -> createdBy.asIri,
"updatedBy" -> updatedBy.asIri,
"type" -> resolverType,
"label" -> lastSegment(id)
"self" -> ResourceUris.resolver(projectRef, id).accessUri
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.generators.{ProjectGen, ResourceResolut
import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
import ch.epfl.bluebrain.nexus.delta.sdk.model.ResourceUris
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{events, resources}
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContextDummy
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ApiMappings
Expand Down Expand Up @@ -71,7 +72,11 @@ class ResourcesRoutesSpec extends BaseRouteSpec {
private val payloadWithBlankId = jsonContentOf("resources/resource.json", "id" -> "")
private val payloadWithUnderscoreFields =
jsonContentOf("resources/resource-with-underscore-fields.json", "id" -> myId5)
private val payloadWithMetadata = jsonContentOf("resources/resource-with-metadata.json", "id" -> myId)
private val payloadWithMetadata = jsonContentOf(
"resources/resource-with-metadata.json",
"id" -> myId,
"self" -> ResourceUris.resource(projectRef, projectRef, myId).accessUri
)

private val aclCheck = AclSimpleCheck().accepted

Expand Down Expand Up @@ -568,7 +573,7 @@ class ResourcesRoutesSpec extends BaseRouteSpec {
}

def resourceMetadata(
ref: ProjectRef,
project: ProjectRef,
id: Iri,
schema: Iri,
tpe: String,
Expand All @@ -579,16 +584,15 @@ class ResourcesRoutesSpec extends BaseRouteSpec {
): Json =
jsonContentOf(
"resources/resource-route-metadata-response.json",
"project" -> ref,
"id" -> id,
"rev" -> rev,
"type" -> tpe,
"deprecated" -> deprecated,
"createdBy" -> createdBy.asIri,
"updatedBy" -> updatedBy.asIri,
"schema" -> schema,
"label" -> lastSegment(id),
"schemaLabel" -> (if (schema == schemas.resources) "_" else lastSegment(schema))
"project" -> project,
"id" -> id,
"rev" -> rev,
"type" -> tpe,
"deprecated" -> deprecated,
"createdBy" -> createdBy.asIri,
"updatedBy" -> updatedBy.asIri,
"schema" -> schema,
"self" -> ResourceUris.resource(project, project, id).accessUri
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.generators.ProjectGen
import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
import ch.epfl.bluebrain.nexus.delta.sdk.model.ResourceUris
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{events, resources, schemas}
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContextDummy
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ApiMappings
Expand Down Expand Up @@ -264,7 +265,11 @@ class SchemasRoutesSpec extends BaseRouteSpec {
forAll(endpoints) { endpoint =>
Get(endpoint) ~> routes ~> check {
status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("schemas/schema-updated-response.json", "id" -> "nxv:myid")
response.asJson shouldEqual jsonContentOf(
"schemas/schema-updated-response.json",
"id" -> "nxv:myid",
"self" -> ResourceUris.schema(projectRef, myId).accessUri
)
}
}
}
Expand All @@ -285,7 +290,11 @@ class SchemasRoutesSpec extends BaseRouteSpec {
forAll(List("rev=1", "tag=mytag")) { param =>
Get(s"$endpoint?$param") ~> routes ~> check {
status shouldEqual StatusCodes.OK
response.asJson shouldEqual jsonContentOf("schemas/schema-created-response.json", "id" -> "nxv:myid2")
response.asJson shouldEqual jsonContentOf(
"schemas/schema-created-response.json",
"id" -> "nxv:myid2",
"self" -> ResourceUris.schema(projectRef, myId2).accessUri
)
}
}
}
Expand Down Expand Up @@ -388,7 +397,7 @@ class SchemasRoutesSpec extends BaseRouteSpec {
}

private def schemaMetadata(
ref: ProjectRef,
project: ProjectRef,
id: Iri,
rev: Int = 1,
deprecated: Boolean = false,
Expand All @@ -397,12 +406,12 @@ class SchemasRoutesSpec extends BaseRouteSpec {
): Json =
jsonContentOf(
"schemas/schema-route-metadata-response.json",
"project" -> ref,
"project" -> project,
"id" -> id,
"rev" -> rev,
"deprecated" -> deprecated,
"createdBy" -> createdBy.asIri,
"updatedBy" -> updatedBy.asIri,
"label" -> lastSegment(id)
"self" -> ResourceUris.schema(project, id).accessUri
)
}
Loading

0 comments on commit 0c245f0

Please sign in to comment.