Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code, dependencies, and build #1526

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"mocha": true
},
"rules": {
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1, "ignoredNodes": ["PropertyDefinition"] }]
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1, "ignoredNodes": ["PropertyDefinition"] }],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off"
},
"overrides": [{
"files": ["*.test.ts"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set e2e environment variables
run: echo -e "\nVUE_APP_E2E=true\nVUE_APP_X_USER=john-doe\nVUE_APP_X_PERMISSION=pipelines:read,pipelines:write" >> .local.env
run: echo -e "\nVITE_E2E=true\nVITE_X_USER=john-doe\nVITE_X_PERMISSION=pipelines:read,pipelines:write" >> .local.env
- uses: ./.github/workflows/setup-env
- run: yarn seed-data

Expand Down
4 changes: 2 additions & 2 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env_file:
services:
core:
type: node:custom
command: mkdir -p /var/www/.npm-global/lib && npx nodemon -w packages -w apis --verbose --ext ts,ttl,js,trig --ignore **/*.test.ts --ignore **/*.spec-graphs.ts --exec node --inspect=0.0.0.0:45671 -r ts-node/register --inspect apis/core/index.ts
command: mkdir -p /var/www/.npm-global/lib && npx nodemon -w packages -w apis --verbose --ext ts,ttl,js,trig --ignore **/*.test.ts --ignore **/*.spec-graphs.ts --exec node --inspect=0.0.0.0:45671 --loader ts-node/esm --inspect apis/core/index.ts
ssl: true
overrides:
image: node:18
Expand All @@ -23,7 +23,7 @@ services:
- 45671
ui:
type: node:custom
command: (cd ui; yarn serve --public app.cube-creator.lndo.site --hostname 0.0.0.0 --port 80)
command: (cd ui; npm i; yarn serve --host 0.0.0.0 --port 80)
ssl: true
overrides:
image: node:18
Expand Down
8 changes: 4 additions & 4 deletions .local.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ AUTH_ISSUER=https://keycloak.zazukoians.org/realms/zazuko-dev
AUTH_CLIENT_ID=cube-creator
AUTH_ACCESS_REQUEST=https://sts001-r.bar.admin.ch/_pep/accessRequest?appl=BAR-Pipelines

# VUE_APP_ prefix to expose them to the ui/public/index.html template.
# VITE_ prefix to expose them to the ui/public/index.html template.
# Keep in sync with the variables above
VUE_APP_AUTH_ISSUER=https://keycloak.zazukoians.org/realms/zazuko-dev
VUE_APP_AUTH_CLIENT_ID=cube-creator
VUE_APP_API_CORE_BASE=https://cube-creator.lndo.site/
VITE_AUTH_ISSUER=https://keycloak.zazukoians.org/realms/zazuko-dev
VITE_AUTH_CLIENT_ID=cube-creator
VITE_API_CORE_BASE=https://cube-creator.lndo.site/

# S3 config
AWS_S3_ENDPOINT=https://s3.cube-creator.lndo.site
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ It is obtained from [keycloak](https://keycloak.zazukoians.org/admin/master/cons
Alternatively, you can bypass authentication altogether by setting the environment variables in `.env` similar to the following example:

```dotenv
VUE_APP_E2E=true
VUE_APP_X_USER=john-doe
VUE_APP_X_PERMISSION=pipelines:read,pipelines:write
VITE_E2E=true
VITE_X_USER=john-doe
VITE_X_PERMISSION=pipelines:read,pipelines:write
```

If you have already started the application, make sure to run `lando rebuild -y` to apply the changes.
Expand Down Expand Up @@ -94,9 +94,9 @@ We use Cypress to run UI e2e tests.

To simplify the tests, we circumvent authentication in the app. For that, the following variables need to be set in `.env` before running the UI:
```
VUE_APP_E2E=true
VUE_APP_X_USER=john-doe
VUE_APP_X_PERMISSION=pipelines:read,pipelines:write
VITE_E2E=true
VITE_X_USER=john-doe
VITE_X_PERMISSION=pipelines:read,pipelines:write
```

We need a running instance of the app to test. The easiest way is to start lando: `lando start`
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { turtle } from '@tpluscode/rdf-string'
import { dcat, hydra } from '@tpluscode/rdf-ns-builders'
import { cc } from '@cube-creator/core/namespace'
import env from '@cube-creator/core/env'
import env from '@cube-creator/core/env/node'

export const entrypoint = turtle`
<> {
Expand Down
14 changes: 7 additions & 7 deletions apis/core/bootstrap/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as core from '@cube-creator/core/bootstrap'
import env from '@cube-creator/core/env'
import { log } from '../lib/log'
import { cubeProjects } from './cube-projects'
import { entrypoint } from './entrypoint'
import { organizations } from './organizations'
import shapes from './shapes'
import { users } from './users'
import env from '@cube-creator/core/env/node'
import { log } from '../lib/log.js'
import { cubeProjects } from './cube-projects.js'
import { entrypoint } from './entrypoint.js'
import { organizations } from './organizations.js'
import shapes from './shapes/index.js'
import { users } from './users.js'

const resources = [cubeProjects, entrypoint, organizations, ...shapes, users]

Expand Down
4 changes: 2 additions & 2 deletions apis/core/bootstrap/lib/query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NamedNode } from '@rdfjs/types'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'
import { SparqlTemplateResult } from '@tpluscode/rdf-string'
import env from '@cube-creator/core/env'
import env from '@cube-creator/core/env/node'

export function lindasQuery(query: SparqlTemplateResult): NamedNode {
return $rdf.namedNode(`${env.PUBLIC_QUERY_ENDPOINT}?query=${encodeURIComponent(query.toString())}`)
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/shapes/column-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { supportedLanguages } from '@cube-creator/core/languages'
import { datatypes } from '@cube-creator/core/datatypes'
import { dash, hydra, rdfs, sh, csvw, xsd } from '@tpluscode/rdf-ns-builders'
import { turtle } from '@tpluscode/rdf-string'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'

const literalShapeId = shape('column-mapping/literal')
const referenceShapeId = shape('column-mapping/reference')
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/shapes/csv-source.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cc, shape } from '@cube-creator/core/namespace'
import { csvw, dash, hydra, rdf, rdfs, schema, sh, xsd } from '@tpluscode/rdf-ns-builders'
import { turtle } from '@tpluscode/rdf-string'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'

const shapeCreateId = shape('csv-source/create')
const shapeUpdateId = shape('csv-source/update')
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/shapes/cube-project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cc, sh1, shape, editor } from '@cube-creator/core/namespace'
import { dash, dcterms, hydra, rdf, rdfs, schema, sh } from '@tpluscode/rdf-ns-builders'
import { turtle } from '@tpluscode/rdf-string'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'

const cubeIdPattern = $rdf.literal('^[a-zA-Z0-9/\\-._,]+[^/]$')

Expand Down
6 changes: 3 additions & 3 deletions apis/core/bootstrap/shapes/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { shape, editor, lindasSchema } from '@cube-creator/core/namespace'
import { supportedLanguages } from '@cube-creator/core/languages'
import { hydra, rdfs, sh, dcat, dcterms, xsd, rdf, vcard, schema, _void, dash, skos } from '@tpluscode/rdf-ns-builders'
import { sparql, turtle } from '@tpluscode/rdf-string'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'
import { Draft } from '@cube-creator/model/Cube'
import env from '@cube-creator/core/env'
import { lindasQuery } from '../lib/query'
import env from '@cube-creator/core/env/node'
import { lindasQuery } from '../lib/query.js'

const shapeId = shape('dataset/edit-metadata')
const temporalFromTo = $rdf.namedNode(shapeId.value + '#temporalFromTo')
Expand Down
6 changes: 3 additions & 3 deletions apis/core/bootstrap/shapes/dimension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { cc, meta, shape, sh1, cube, md, relation, editor } from '@cube-creator/
import { supportedLanguages } from '@cube-creator/core/languages'
import { sparql, turtle } from '@tpluscode/rdf-string'
import { dash, hydra, prov, rdf, rdfs, schema, sh, qudt, time, xsd } from '@tpluscode/rdf-ns-builders'
import namespace from '@rdfjs/namespace'
import { lindasQueryTemplate } from '../lib/query'
import $rdf from '@zazuko/env'
import { lindasQueryTemplate } from '../lib/query.js'

const sou = namespace('http://qudt.org/vocab/sou/')
const sou = $rdf.namespace('http://qudt.org/vocab/sou/')

const unitsQuery = sparql`
CONSTRUCT
Expand Down
14 changes: 7 additions & 7 deletions apis/core/bootstrap/shapes/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CubeProjectShape } from './cube-project'
import { TableShape } from './table'
import { DatasetShape } from './dataset'
import { CSVSourceCreateShape, CSVSourceUpdateShape } from './csv-source'
import { JobUpdateShape, JobTriggerShape } from './jobs'
import { ColumnMappingShape } from './column-mapping'
import { DimensionMetadataShape, SharedDimensionMappingShape, SharedDimensionMappingImportShape } from './dimension'
import { CubeProjectShape } from './cube-project.js'
import { TableShape } from './table.js'
import { DatasetShape } from './dataset.js'
import { CSVSourceCreateShape, CSVSourceUpdateShape } from './csv-source.js'
import { JobUpdateShape, JobTriggerShape } from './jobs.js'
import { ColumnMappingShape } from './column-mapping.js'
import { DimensionMetadataShape, SharedDimensionMappingShape, SharedDimensionMappingImportShape } from './dimension.js'

export default [
CubeProjectShape,
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/shapes/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { turtle } from '@tpluscode/rdf-string'
import { shape } from '@cube-creator/core/namespaces/shapes'
import { dcterms, hydra, rdfs, schema, sh } from '@tpluscode/rdf-ns-builders'
import env from '@cube-creator/core/env'
import env from '@cube-creator/core/env/node'
import { cc } from '@cube-creator/core/namespace'

let jobTriggerProperties = turtle``
Expand Down
2 changes: 1 addition & 1 deletion apis/core/bootstrap/shapes/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ${shape('table/create')} {
${commonProperties}
${sh.property} [
${sh.name} "Columns to map" ;
${sh.descriptin} "These columns will be mapped in the new table with default parameters that you can change later.";
${sh.description} "These columns will be mapped in the new table with default parameters that you can change later.";
${sh.path} ${csvw.column} ;
${sh.class} ${csvw.Column} ;
${dash.hidden} ${true} ;
Expand Down
39 changes: 23 additions & 16 deletions apis/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@ import express from 'express'
import * as Sentry from '@sentry/node'
import * as Tracing from '@sentry/tracing'
import { hydraBox } from '@hydrofoil/labyrinth'
import { problemJson } from '@hydrofoil/labyrinth/errors'
import { problemJson } from '@hydrofoil/labyrinth/errors.js'
import { sharedDimensions } from '@cube-creator/shared-dimensions-api'
import { resource } from 'express-rdf-request'
import cors from 'cors'
import env from '@cube-creator/core/env'
import env from '@cube-creator/core/env/node'
import { errorMappers } from '@cube-creator/api-errors'
import { error, log } from './lib/log'
import authentication from './lib/auth'
import { bootstrap } from './bootstrap'
import { resourceStore } from './lib/middleware/resource'
import { expectsDisambiguate, preferHydraCollection } from './lib/middleware/operations'
import './lib/domain'
import upload from './lib/upload'
import Loader from './lib/Loader'
import * as s3 from './lib/storage/s3'
import { version } from './package.json'
import $rdf from '@cube-creator/env'
import Environment from '@zazuko/env/Environment.js'
import Fs from '@zazuko/rdf-utils-fs/Factory.js'
import asyncMiddleware from 'middleware-async'
import { error, log } from './lib/log.js'
import authentication from './lib/auth.js'
import { bootstrap } from './bootstrap/index.js'
import { resourceStore } from './lib/middleware/resource.js'
import { expectsDisambiguate, preferHydraCollection } from './lib/middleware/operations.js'
import upload from './lib/upload.js'
import Loader from './lib/Loader.js'
import * as s3 from './lib/storage/s3.js'
import pkg from './package.json' assert { type: 'json' }
import './lib/domain/index.js'

const __dirname = path.dirname(new URL(import.meta.url).pathname)

const apiPath = path.resolve(__dirname, 'hydra')
const codePath = path.resolve(__dirname, 'lib')
Expand All @@ -48,7 +54,7 @@ async function main() {
app.enable('trust proxy')

app.use((req, res, next) => {
res.setHeader('x-cube-creator', version)
res.setHeader('x-cube-creator', pkg.version)
next()
})

Expand Down Expand Up @@ -83,7 +89,8 @@ async function main() {
app.use('/upload', upload)

app.use(resourceStore)
app.use(await hydraBox({
app.use(asyncMiddleware(await hydraBox({
env: new Environment([Fs], { parent: $rdf }),
apiPath,
codePath,
baseUri,
Expand All @@ -100,12 +107,12 @@ async function main() {
expectsDisambiguate,
],
},
loader: new Loader({
loader: new Loader($rdf, {
endpointUrl,
user,
password,
}),
}))
})))

app.use(Sentry.Handlers.errorHandler())
app.use(problemJson({ errorMappers, captureNotFound: true }))
Expand Down
2 changes: 1 addition & 1 deletion apis/core/lib/ChangelogDataset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DatasetCore, Quad } from '@rdfjs/types'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env'

interface Changes {
added: DatasetCore
Expand Down
21 changes: 9 additions & 12 deletions apis/core/lib/Loader.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type { NamedNode } from '@rdfjs/types'
import { SparqlQueryLoader } from '@hydrofoil/labyrinth/lib/loader'
import { PropertyResource, Resource } from 'hydra-box'
import ParsingClient from 'sparql-http-client/ParsingClient'
import { SparqlQueryLoader } from '@hydrofoil/labyrinth/lib/loader.js'
import { PropertyResource, Resource } from '@kopflos-cms/core'
import ParsingClient from 'sparql-http-client/ParsingClient.js'
import { SELECT } from '@tpluscode/sparql-builder'
import $rdf from 'rdf-ext'
import TermSet from '@rdfjs/term-set'
import TermMap from '@rdfjs/term-map'
import $rdf from '@zazuko/env'
import { as, hydra } from '@tpluscode/rdf-ns-builders'
import { IN, VALUES } from '@tpluscode/sparql-builder/expressions'
import clownface from 'clownface'
import express from 'express'

interface CreateResourceGetters {
Expand All @@ -28,7 +25,7 @@ export default class Loader extends SparqlQueryLoader {

const client: ParsingClient = (this as any).__client
const createDatasetGetters: CreateResourceGetters = (this as any).__createDatasetGetters.bind(this)
const supportedProperties = clownface(req.hydra.api)
const supportedProperties = $rdf.clownface(req.hydra.api)
.any()
.has(hydra.supportedProperty)
.out(hydra.supportedProperty)
Expand All @@ -44,7 +41,7 @@ export default class Loader extends SparqlQueryLoader {

FILTER (?link NOT ${IN(...excludedProperties)})
}
`.execute(client.query)
`.execute(client)

const resources = links.reduce((set, { parent, link }) => {
if (parent.termType !== 'NamedNode' || link.termType !== 'NamedNode') {
Expand All @@ -56,14 +53,14 @@ export default class Loader extends SparqlQueryLoader {
property: link,
object: term,
prefetchDataset: $rdf.dataset(),
types: new TermSet(),
types: $rdf.termSet(),
...createDatasetGetters(parent),
}

resource.prefetchDataset.add($rdf.quad(parent, link, term))

return set.set(parent, resource)
}, new TermMap<NamedNode, PropertyResource>())
}, $rdf.termMap<NamedNode, PropertyResource>())

if (resources.size) {
const typesQuery = [...resources.keys()].reduce((query, graph) => {
Expand All @@ -75,7 +72,7 @@ export default class Loader extends SparqlQueryLoader {
}
`)

const types = await typesQuery.execute(client.query)
const types = await typesQuery.execute(client)
for (const { parent, type } of types) {
if (parent.termType !== 'NamedNode' || type.termType !== 'NamedNode') {
continue
Expand Down
Loading
Loading