diff --git a/cli/lib/commands/publish.ts b/cli/lib/commands/publish.ts index e8d4a8292..79c8216d1 100644 --- a/cli/lib/commands/publish.ts +++ b/cli/lib/commands/publish.ts @@ -29,7 +29,7 @@ export default runner.create({ 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()) @@ -59,6 +59,7 @@ export default runner.create({ 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) { @@ -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(jobUri) const cubeCreatorVersion = jobResource.response?.xhr.headers.get('x-cube-creator') @@ -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, } } diff --git a/cli/lib/publish/hiddenCube.ts b/cli/lib/publish/hiddenCube.ts new file mode 100644 index 000000000..96f77013b --- /dev/null +++ b/cli/lib/publish/hiddenCube.ts @@ -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) { + 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() + }) +} diff --git a/cli/lib/variables.ts b/cli/lib/variables.ts index e72a51abe..cde95a76b 100644 --- a/cli/lib/variables.ts +++ b/cli/lib/variables.ts @@ -39,5 +39,6 @@ declare module 'barnard59-core' { originalValueQuads: DatasetExt cubeCreatorVersion: string cliVersion: string + isHiddenCube: boolean } } diff --git a/cli/pipelines/publish.ttl b/cli/pipelines/publish.ttl index 22d39e94e..1f2160029 100644 --- a/cli/pipelines/publish.ttl +++ b/cli/pipelines/publish.ttl @@ -49,6 +49,7 @@ :steps [ :stepList ( <#loadCube> <#countInputQuads> <#injectCubeRevision> + <#injectIsHiddenCube> <#injectObservedBy> <#injectSoftwareVersions> ) ] @@ -245,6 +246,11 @@ _:get a code:EcmaScript ] ; code:arguments ( "jobUri"^^:VariableName ) . +<#injectIsHiddenCube> + a :Step ; + code:implementedBy [ code:link ; + a code:EcmaScript ] . + <#injectSoftwareVersions> a :Step ; code:implementedBy [ code:link ;