diff --git a/cli/lib/commands/publish.ts b/cli/lib/commands/publish.ts index e8d4a8292..55786fe4f 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, profile } = await getJob(jobUri, Hydra) if (options.to === 'filesystem' && !variable.has('targetFile')) { variable.set('targetFile', tempy.file()) @@ -43,6 +43,7 @@ export default runner.create({ variable.set('metadata', $rdf.dataset()) // this should be possible as relative path in pipeline ttl but does not work variable.set('shapesPath', path.resolve(__dirname, '../../shapes.ttl')) + variable.set('profile', profile) if (cubeCreatorVersion) { variable.set('cubeCreatorVersion', cubeCreatorVersion) @@ -77,6 +78,7 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{ namespace: string cubeIdentifier: string cubeCreatorVersion: string | undefined | null + profile: string }> { const jobResource = await Hydra.loadResource(jobUri) const cubeCreatorVersion = jobResource.response?.xhr.headers.get('x-cube-creator') @@ -85,6 +87,22 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{ throw new Error(`Did not find representation of job ${jobUri}. Server responded ${jobResource.response?.xhr.status}`) } + const getProfile = () => { + // 'https://cube.link/v0.2.1/shape/standalone-constraint-constraint' + // 'https://cube.link/latest/shape/standalone-constraint-constraint' + // 'https://cube.link/latest/shape/profile-opendataswiss' + // 'https://cube.link/latest/shape/profile-visualize' + const publishedTo = jobResource.representation?.root?.publishedTo?.value + if (publishedTo === 'https://ld.admin.ch/application/opendataswiss') { + return 'https://cube.link/latest/shape/profile-opendataswiss' + } + if (publishedTo === 'https://ld.admin.ch/application/visualize') { + return 'https://cube.link/latest/shape/profile-visualize' + } + + return 'https://cube.link/v0.2.1/shape/standalone-constraint-constraint' + } + const projectResource = await Hydra.loadResource(job.project) const project = projectResource.representation?.root if (!project) { @@ -105,5 +123,6 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{ namespace: datasetResource.representation?.root?.hasPart[0].id.value, cubeIdentifier, cubeCreatorVersion, + profile: getProfile(), } } diff --git a/cli/lib/variables.ts b/cli/lib/variables.ts index e72a51abe..3ce0cd921 100644 --- a/cli/lib/variables.ts +++ b/cli/lib/variables.ts @@ -19,6 +19,7 @@ declare module 'barnard59-core' { 'publish-job': PublishJob 'unlist-job': UnlistJob 'target-graph': string + profile: string targetFile: string revision: number namespace: string diff --git a/cli/pipelines/publish.ttl b/cli/pipelines/publish.ttl index 647252043..f44baa96b 100644 --- a/cli/pipelines/publish.ttl +++ b/cli/pipelines/publish.ttl @@ -152,14 +152,8 @@ a code:EcmaScriptModule ; code:link ] ; - code:arguments - ( - 'https://cube.link/v0.2.1/shape/standalone-constraint-constraint' - # 'https://cube.link/latest/shape/standalone-constraint-constraint' - # 'https://cube.link/latest/shape/profile-opendataswiss' - # 'https://cube.link/latest/shape/profile-visualize' - ) - . + code:arguments ( 'profile'^^:VariableName ) +. <#imports> a :Step ; code:implementedBy