Skip to content

Commit

Permalink
Merge pull request #118 from solid-contrib/bookmarks/create-bookmark
Browse files Browse the repository at this point in the history
Bookmarks/create bookmark
  • Loading branch information
angelo-v authored Jun 12, 2024
2 parents 5fd5421 + f12a8e9 commit 6c37ea1
Show file tree
Hide file tree
Showing 36 changed files with 1,012 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/bookmarks-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ run-name: ${{ github.actor }} is running jest
on:
push:
paths:
- bookmarks/**
- bookmarks/soukai/**
- bookmarks/vanilla/**
- .github/workflows/bookmarks-ci.yml
jobs:
test-bookmarks-vanilla:
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/bookmarks-rdflib-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Bookmarks rdflib CI/CD

on:
push:
paths:
- bookmarks/rdflib/**
- .github/workflows/bookmarks-rdflib-ci-cd.yml

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./bookmarks/rdflib/
strategy:
matrix:
node-version: [ 20 ]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm test
- run: npm run test:e2e
- name: Save e2e test data
uses: actions/upload-artifact@v4
with:
name: e2e-test-data
path: |
bookmarks/rdflib/src/e2e-tests/.test-data/
retention-days: 1
- name: Save build
uses: actions/upload-artifact@v4
with:
name: build
path: |
bookmarks/rdflib/dist/
bookmarks/rdflib/README.md
bookmarks/rdflib/package.json
retention-days: 1

npm-publish:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
outputs:
prereleaseVersion: ${{ steps.prerelease.outputs.version }}
steps:
- uses: actions/download-artifact@v4
with:
name: build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: rlespinasse/github-slug-action@v4.4.1
- name: prerelease version
run: |
echo "::set-output name=version::$(npm version prerelease --preid ${GITHUB_SHA_SHORT} --no-git-tag-version)"
id: prerelease
- run: echo prerelease version is ${{ steps.prerelease.outputs.version }}
- uses: JS-DevTools/npm-publish@v3
name: Publish @solid-data-modules/bookmarks-rdflib
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.GITHUB_REF_SLUG }}
access: public

npm-release-latest:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: JS-DevTools/npm-publish@v3
name: Release @solid-data-modules/bookmarks-rdflib
with:
token: ${{ secrets.NPM_TOKEN }}
tag: latest
access: public
11 changes: 11 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ jobs:
working-directory: ./bookmarks/soukai
run: npm run build:doc

######################
###################### bookmarks/rdflib module

- name: Install bookmarks/rdflib dev dependencies
working-directory: ./bookmarks/rdflib
run: npm ci --only=dev

- name: Build bookmarks/rdflib doc
working-directory: ./bookmarks/rdflib
run: npm run build:doc

######################

- name: Upload pages
Expand Down
12 changes: 10 additions & 2 deletions bookmarks/dev-server/initial-data/alice/.acl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
a acl:Authorization;
acl:agent <http://localhost:3000/alice/profile/card#me>;
# Optional owner email, to be used for account recovery:

# Set the access to the root storage folder itself
acl:accessTo <./>;
# All resources will inherit this authorization, by default
acl:default <./>;
# The owner has all of the access modes allowed
acl:mode
acl:Read, acl:Write, acl:Control.
acl:Read, acl:Write, acl:Control.

# read / write access for public for testing without auth
<#ReadWrite>
a acl:Authorization;
acl:accessTo <./>;
acl:agentClass foaf:Agent;
acl:default <./>;
acl:mode acl:Read, acl:Write.
Empty file.
4 changes: 4 additions & 0 deletions bookmarks/rdflib/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"proseWrap": "always",
"printWidth": 80
}
11 changes: 11 additions & 0 deletions bookmarks/rdflib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this module will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.0

### Added

- [createBookmark](https://solid-contrib.github.io/data-modules/bookmarks-rdflib-api/interfaces/BookmarksModule.html#createBookmark)
7 changes: 6 additions & 1 deletion bookmarks/rdflib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const updater = new UpdateManager(store);
const module: BookmarksModule = new BookmarksModuleRdfLib({store, fetcher, updater});

// 3️⃣ use the module to interact with bookmarks
const uri = await bookmarks.createBookmark({
storageUrl: "http://localhost:3000/alice/public/bookmarks",
title: "My favorite website",
url: "https://favorite.example"
})

```

Expand All @@ -64,7 +69,7 @@ After that you can run an example script like this:

```shell
npm run build
node ./examples/create-bookmark.mjs
node ./examples/create-bookmark-within-container.mjs
```

### Available features
Expand Down
15 changes: 15 additions & 0 deletions bookmarks/rdflib/examples/create-bookmark-within-container.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import BookmarksModule from '../dist/index.js';
import {Fetcher, graph, UpdateManager} from "rdflib";

const store = graph()
const fetcher = new Fetcher(store)
const updater = new UpdateManager(store)
const bookmarks = new BookmarksModule({store, fetcher, updater})

const uri = await bookmarks.createBookmark({
storageUrl: "http://localhost:3000/alice/bookmarks/",
title: "My favorite website",
url: "https://favorite.example"
})

console.log("new bookmark: " + uri)
15 changes: 15 additions & 0 deletions bookmarks/rdflib/examples/create-bookmark-within-document.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import BookmarksModule from '../dist/index.js';
import {Fetcher, graph, UpdateManager} from "rdflib";

const store = graph()
const fetcher = new Fetcher(store)
const updater = new UpdateManager(store)
const bookmarks = new BookmarksModule({store, fetcher, updater})

const uri = await bookmarks.createBookmark({
storageUrl: "http://localhost:3000/alice/public/bookmarks",
title: "My favorite website",
url: "https://favorite.example"
})

console.log("new bookmark: " + uri)
26 changes: 26 additions & 0 deletions bookmarks/rdflib/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: "src",
testPathIgnorePatterns: [".*\\.e2e\\.spec\\.ts"],
detectOpenHandles: true,
forceExit: true,
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.ts$": [
"ts-jest",
{
useESM: true,
},
],
},
};

export default config;
28 changes: 28 additions & 0 deletions bookmarks/rdflib/jest.e2e.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: "src/e2e-tests",
testTimeout: 60000,
detectOpenHandles: true,
globalSetup: "<rootDir>/globalSetup.ts",
globalTeardown: "<rootDir>/globalTeardown.ts",
forceExit: true,
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.ts$": [
"ts-jest",
{
useESM: true,
},
],
},
};

export default config;
48 changes: 48 additions & 0 deletions bookmarks/rdflib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions bookmarks/rdflib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"scripts": {
"clean": "rm -rf dist/",
"build": "npm run clean && tsc",
"build:doc": "typedoc src/index.ts --out ../../gh-pages/bookmarks-rdflib --tsconfig ./tsconfig.json",
"build:doc": "typedoc src/index.ts --out ../../gh-pages/bookmarks-rdflib-api --tsconfig ./tsconfig.json",
"serve:doc": "serve ../../gh-pages",
"test": "jest",
"lint": "eslint ./src/**",
"test:e2e": "jest --config jest.e2e.config.ts",
"lint": "eslint ./src/** ./examples/**",
"pod": "community-solid-server --config ../dev-server/config/config-mashlib.json --seedConfig ../dev-server/seed.json --rootFilePath ../dev-server/data",
"pod:init": "cp -r ../dev-server/initial-data/* ../dev-server/data/",
"pod:clean": "rm -rf ../dev-server/data"
Expand Down Expand Up @@ -44,15 +45,21 @@
"devDependencies": {
"@solid/community-server": "^7.0.5",
"@types/jest": "^29.5.12",
"@types/jest-when": "^3.5.5",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"eslint": "^8.57.0",
"eslint-plugin-require-extensions": "^0.1.3",
"jest": "^29.7.0",
"jest-when": "^3.6.0",
"mashlib": "^1.8.11",
"prettier": "^3.3.1",
"serve": "^14.2.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
},
"dependencies": {
"short-unique-id": "^5.2.0"
}
}
Loading

0 comments on commit 6c37ea1

Please sign in to comment.