Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
426de4e
[VET-5931] Upgrade Stardog.js to node 22
SpiralP Aug 21, 2025
6fcb8b6
bump node version to 22 in .nvmrc and package.json
SpiralP Aug 21, 2025
1409ace
convert to yarn.lock
SpiralP Aug 21, 2025
3cea131
remove fetch.js
SpiralP Aug 22, 2025
44c83cb
remove fetch polyfill
SpiralP Aug 22, 2025
7203206
cleanup scripts
SpiralP Aug 22, 2025
59150c3
remove husky and lint-staged
SpiralP Aug 22, 2025
34aea36
upgrade prettier and eslint; configure them
SpiralP Aug 21, 2025
44a0ee1
`yarn format`
SpiralP Aug 22, 2025
4836b7c
`npx prettier --write .`
SpiralP Aug 22, 2025
3922e4f
remove querystring, use URLSearchParams
SpiralP Aug 22, 2025
802d767
prettier: avoid using parens
SpiralP Aug 22, 2025
e539306
`yarn format`
SpiralP Aug 22, 2025
7870bd3
`npx prettier --write .`
SpiralP Aug 22, 2025
fcc7ee5
update circleci config
SpiralP Aug 12, 2025
624392e
eslint fixes
SpiralP Aug 22, 2025
9450b59
convert to use URLSearchParams
SpiralP Aug 22, 2025
a392b0f
remove old node-fetch FormData code
SpiralP Aug 22, 2025
7b51de4
upgrade jest to ^28
SpiralP Aug 22, 2025
6c1891b
fix tests
SpiralP Aug 22, 2025
8ca9215
fix file/blob usage
SpiralP Aug 22, 2025
4a2b36f
duplicate jest config for cluster tests
SpiralP Aug 23, 2025
677fc75
fix missing yarn dep warnings
SpiralP Aug 23, 2025
3d673d4
upgrade rollbar
SpiralP Aug 23, 2025
58e4b52
ci: wait for stardog server to be ready before testing
SpiralP Aug 25, 2025
edb7157
package.json: set `main` and `browser` fields
SpiralP Aug 25, 2025
e418c0b
`npm pkg fix`
SpiralP Aug 25, 2025
fce89bf
use encodeURIComponent for url params since URLSearchParams gives + f…
SpiralP Aug 25, 2025
8c049ed
revert some style changes
SpiralP Aug 26, 2025
bcde36a
rename to encodeQueryString
SpiralP Aug 29, 2025
3ebdad0
missed a encodeURIComponent
SpiralP Aug 29, 2025
0a293cc
fix test
SpiralP Aug 29, 2025
3b0a89e
remove todo
SpiralP Aug 29, 2025
4582434
run format, docs
anneeb Aug 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 38 additions & 61 deletions .circleci/config.yml
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to update github settings for pr blocking these 2 tasks, and remove required build

image

Original file line number Diff line number Diff line change
@@ -1,65 +1,42 @@
# This config is based partially on one that was auto-generated by CircleCI
# from our 1.0 config. Some stuff may be superfluous.
version: 2
version: 2.1

references:
working_directory: &working_directory ~/stardog-union/stardog.js
orbs:
node: circleci/node@7

jobs:
build:
working_directory: *working_directory
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
executors:
machine:
machine:
docker_layer_caching: true
steps:
- checkout
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
# These steps could be consolidated, but I left them separate since that was what was generated.
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- run:
working_directory: *working_directory
command: echo $LICENSE | base64 --decode > ./stardog-license-key.bin
- run:
working_directory: *working_directory
command: docker login -u $ARTIFACTORY_USERNAME -p $ARTIFACTORY_PASSWORD stardog-eps-docker.jfrog.io
- run:
working_directory: *working_directory
command: docker build -t this/here/starduck ./
- run:
working_directory: *working_directory
command: docker run --name stargoose -p 127.0.0.1:5820:5820 -d -it this/here/starduck
# Dependencies
# Restore the dependency cache
- restore_cache:
keys:
# This branch if available
- v1-dep-{{ .Branch }}-{{ checksum "package-lock.json" }}
# Default branch if not
- v1-dep-master-{{ checksum "package-lock.json" }}
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
- v1-dep-{{ checksum "package-lock.json" }}
- run: if [ -z "${NODE_ENV:-}" ]; then export NODE_ENV=test; fi
- run: npm install
# Save dependency cache
- save_cache:
key: v1-dep-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
# Test
# This would typically be a build job when using workflows, possibly combined with build
- run: docker ps -a
- run: docker logs stargoose
- run: npm test
# Teardown
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# Save test results
- store_test_results:
path: /tmp/circleci-test-results
# Save artifacts
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results
image: ubuntu-2204:current

workflows:
build_and_test:
jobs:
- node/test:
name: Test with Node.js 22
executor: machine
pkg-manager: yarn
setup:
- node/install:
install-yarn: true
node-version: '22'
- run:
name: Build and run docker container
command: |
echo "$LICENSE" | base64 --decode > ./stardog-license-key.bin
docker login -u "$ARTIFACTORY_USERNAME" -p "$ARTIFACTORY_PASSWORD" stardog-eps-docker.jfrog.io
docker build -t this/here/starduck ./
docker run --name stargoose -p 127.0.0.1:5820:5820 -d -it this/here/starduck
post_install_steps:
- run:
name: Wait for Stardog server to be ready
command: yarn run wait-for-server
- node/run:
name: Build with Node.js 22
executor: machine
pkg-manager: yarn
yarn-run: build
setup:
- node/install:
install-yarn: true
node-version: '22'
33 changes: 16 additions & 17 deletions .circleci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,70 @@ services:
stardog1:
command: ["--port", "5821", "--home", "/var/opt/stardog"]
depends_on:
- zoo1
- zoo1
environment:
STARDOG_SERVER_JAVA_ARGS: -Xms2g -Xmx2g -XX:MaxDirectMemorySize=1g
THIS_HOST: stardog1
THIS_PORT: 5821
ZK_HOST_PORT: zoo1:2181
image: stardog/stardog:latest
ports:
- 5821:5821
- 5821:5821
restart: always
privileged: true
volumes:
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ./cluster.properties:/var/opt/stardog/stardog.properties
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ./cluster.properties:/var/opt/stardog/stardog.properties
stardog2:
command: ["--port", "5822", "--home", "/var/opt/stardog"]
depends_on:
- zoo1
- zoo1
environment:
STARDOG_SERVER_JAVA_ARGS: -Xms2g -Xmx2g -XX:MaxDirectMemorySize=1g
THIS_HOST: stardog2
THIS_PORT: 5822
ZK_HOST_PORT: zoo1:2181
image: stardog/stardog:latest
ports:
- 5822:5822
- 5822:5822
restart: always
privileged: true
volumes:
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ./cluster.properties:/var/opt/stardog/stardog.properties
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ./cluster.properties:/var/opt/stardog/stardog.properties
stardog3:
image: stardog/stardog:latest
ports:
- 5820:5820
- 5820:5820
restart: always
privileged: true
volumes:
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ../test/fixtures/:/var/opt/stardog/test/fixtures/
- ./token.properties:/var/opt/stardog/stardog.properties
- ./jwt.yaml:/var/opt/stardog/jwt.yaml
- ../stardog-license-key.bin:/var/opt/stardog/stardog-license-key.bin
- ../test/fixtures/:/var/opt/stardog/test/fixtures/
- ./token.properties:/var/opt/stardog/stardog.properties
- ./jwt.yaml:/var/opt/stardog/jwt.yaml
zoo1:
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888
image: zookeeper:3.4.14
ports:
- 2181
- 2181
restart: always

test-unit:
image: circleci/node:carbon-stretch
image: node:22
command: npm test
working_dir: /app
volumes:
- ../:/app/
environment:
- HOST=stardog3
- CIRCLECI=true
depends_on:
- stardog3

test-cluster:
image: circleci/node:carbon-stretch
image: node:22
command: npm test:cluster
working_dir: /app
environment:
Expand Down
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** @type {import('eslint').Linter.BaseConfig} */
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 'latest',
},
plugins: ['prettier'],
extends: [
'airbnb-base',
'prettier',
'plugin:jest/recommended',
'@blueprintjs/eslint-config',
'plugin:prettier/recommended',
],
rules: {
curly: ['warn', 'all'],
'header/header': 'off',
'import/no-mutable-exports': 'off',
'import/order': 'off',
'import/prefer-default-export': 'off',
'jest/expect-expect': ['warn', { assertFunctionNames: ['expect*'] }],
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'no-console': 'warn',
'no-return-await': 'off',
'no-underscore-dangle': 'off',
'object-curly-spacing': 'error',
'prettier/prettier': 'warn',
radix: 'off',
'sort-imports': 'off',

// TODO remove these:
'no-unused-vars': 'off',
'prefer-object-spread': 'warn',
},
};
28 changes: 0 additions & 28 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/carbon
22
5 changes: 5 additions & 0 deletions jest.config.cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('jest').Config} */
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
testRegex: 'test/cluster/.+\\.spec\\.js$',
};
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/** @type {import('jest').Config} */
module.exports = {
setupTestFrameworkScriptFile: './jest.setup.js',
setupFilesAfterEnv: ['./jest.setup.js'],
// don't include subdirs, so we ignore test/cluster/*
testRegex: 'test/[^/]+\\.spec\\.js$',
};
1 change: 0 additions & 1 deletion lib/Connection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { Headers, Request } = require('./fetch');
const base64 = require('isomorphic-base64');

class Connection {
Expand Down
2 changes: 0 additions & 2 deletions lib/catalog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { fetch } = require('./fetch');

const { httpBody } = require('./response-transforms');

const status = conn => {
Expand Down
1 change: 0 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { fetch } = require('./fetch');
const { httpBody } = require('./response-transforms');

const info = conn => {
Expand Down
23 changes: 13 additions & 10 deletions lib/dataSources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { fetch } = require('./fetch');
const qs = require('querystring');

const { httpBody } = require('./response-transforms');
const { encodeURIComponentsWithQuestionMark } = require('./utils');

const list = conn => {
const headers = conn.headers();
Expand Down Expand Up @@ -59,13 +57,18 @@ const update = (conn, name, options, requestOptions = {}) => {

const remove = (conn, name, params = {}) => {
const headers = conn.headers();
const queryParams = Object.keys(params).length
? `?${qs.stringify(params)}`
: '';
return fetch(conn.request('admin', 'data_sources', `${name}${queryParams}`), {
method: 'DELETE',
headers,
}).then(httpBody);

return fetch(
conn.request(
'admin',
'data_sources',
`${name}${encodeURIComponentsWithQuestionMark(params)}`
),
{
method: 'DELETE',
headers,
}
).then(httpBody);
};

const share = (conn, name) => {
Expand Down
13 changes: 1 addition & 12 deletions lib/db/docs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const FormData = require('form-data');
const { fetch } = require('../fetch');

const { httpBody } = require('../response-transforms');

const size = (conn, database, params = {}) => {
Expand All @@ -23,15 +20,7 @@ const clear = (conn, database, params = {}) => {
const add = (conn, database, fileName, fileContents, params = {}) => {
const headers = conn.headers();
const formData = new FormData();
formData.append('upload', Buffer.from(fileContents), {
filename: fileName,
});
// Copy over formData headers, since node-fetch 2+ apparently doesn't do this
// automatically. See: https://github.com/bitinn/node-fetch/issues/368
const formDataHeaders = formData.getHeaders();
Object.keys(formDataHeaders).forEach(key => {
headers.set(key, formDataHeaders[key]);
});
formData.append('upload', new Blob([fileContents]), fileName);
return fetch(conn.request(database, 'docs'), {
method: 'POST',
body: formData,
Expand Down
Loading