Skip to content

Commit

Permalink
feat: hidden-graph
Browse files Browse the repository at this point in the history
add flag to the published cubes metadata (cc:isHiddenCube)
  • Loading branch information
mchlrch committed Mar 7, 2024
1 parent dcf7065 commit aa004c0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/lib/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default runner.create<PublishRunOptions>({
const { publishStore, job: jobUri } = options
const Hydra = variable.get('apiClient')

const { job, namespace, cubeIdentifier, cubeCreatorVersion } = await getJob(jobUri, Hydra)
const { job, namespace, cubeIdentifier, cubeCreatorVersion, isHiddenCube } = await getJob(jobUri, Hydra)

if (options.to === 'filesystem' && !variable.has('targetFile')) {
variable.set('targetFile', tempy.file())
Expand Down Expand Up @@ -59,6 +59,7 @@ export default runner.create<PublishRunOptions>({
variable.set('revision', job.revision)
variable.set('namespace', namespace)
variable.set('cubeIdentifier', cubeIdentifier)
variable.set('isHiddenCube', isHiddenCube)
logger.info(`Publishing cube <${cubeIdentifier}>`)
},
async after(options, variables) {
Expand All @@ -77,6 +78,7 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{
namespace: string
cubeIdentifier: string
cubeCreatorVersion: string | undefined | null
isHiddenCube: boolean
}> {
const jobResource = await Hydra.loadResource<PublishJob>(jobUri)
const cubeCreatorVersion = jobResource.response?.xhr.headers.get('x-cube-creator')
Expand Down Expand Up @@ -105,5 +107,6 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{
namespace: datasetResource.representation?.root?.hasPart[0].id.value,
cubeIdentifier,
cubeCreatorVersion,
isHiddenCube: project.isHiddenCube,
}
}
25 changes: 25 additions & 0 deletions cli/lib/publish/hiddenCube.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Context } from 'barnard59-core/lib/Pipeline'
import $rdf from 'rdf-ext'
import through2 from 'through2'
import clownface from 'clownface'
import { cc } from '@cube-creator/core/namespace'

export function inject(this: Pick<Context, 'variables'>) {
const isHiddenCube = this.variables.get('isHiddenCube')
const cubeNamespace = this.variables.get('namespace')
const revision = this.variables.get('revision')

const cubeId = $rdf.namedNode(`${cubeNamespace}/${revision}`)

const dataset = $rdf.dataset()
clownface({ dataset })
.node(cubeId)
.addOut(cc.isHiddenCube, !!isHiddenCube)

return through2.obj(
(chunk, enc, cb) => cb(null, chunk),
function (done) {
dataset.forEach(this.push.bind(this))
done()
})
}
1 change: 1 addition & 0 deletions cli/lib/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ declare module 'barnard59-core' {
originalValueQuads: DatasetExt
cubeCreatorVersion: string
cliVersion: string
isHiddenCube: boolean
}
}
6 changes: 6 additions & 0 deletions cli/pipelines/publish.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
:steps [ :stepList ( <#loadCube>
<#countInputQuads>
<#injectCubeRevision>
<#injectIsHiddenCube>
<#injectObservedBy>
<#injectSoftwareVersions>
) ]
Expand Down Expand Up @@ -245,6 +246,11 @@ _:get
a code:EcmaScript ] ;
code:arguments ( "jobUri"^^:VariableName ) .

<#injectIsHiddenCube>
a :Step ;
code:implementedBy [ code:link <file:../lib/publish/hiddenCube#inject> ;
a code:EcmaScript ] .

<#injectSoftwareVersions>
a :Step ;
code:implementedBy [ code:link <file:../lib/publish/versions#inject> ;
Expand Down

0 comments on commit aa004c0

Please sign in to comment.