Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Refactored into Monorepo (#2)
Browse files Browse the repository at this point in the history
* Refactored into Monorepo

* Fixed tests

* Refactoring types module to not be compiled and pure types

* Removed log file

* Removed dots from package exports

* Tweak workflow

* Tweak workflow

* Tweak workflow

* Fixed type tests

* Fixed missing module

* Failing tests - annotation normalization problems, added context

* Added some more context

* Added workflow step

* Publish config

* Lerna version

* Lerna version

* Visibility

* v0.1.0

* Revert v1.0.0

* v0.1.0

* Added relase to github

* Made sure pre-release is before tests

* ping

* ping

* Debug

* Debug

* Debug

* Debug

* Debug

* Debug

* debug

* debug

* First test

* Test fix

* Restore full workflow

* Adding some extra context

* Adding some extra context (1)

* Update main.workflow

* Update main.workflow

* Workflow

* Planning for react module

* Further planning of React package

* First react example prototype

* Remove deploy pull request

* Fixed import

* Plan for selectors
  • Loading branch information
stephenwf authored Mar 4, 2019
1 parent 7b32425 commit 7b6f381
Show file tree
Hide file tree
Showing 155 changed files with 15,092 additions and 1,362 deletions.
22 changes: 20 additions & 2 deletions .github/main.workflow
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
workflow "Hyperion" {
workflow "Build and test" {
on = "push"
resolves = ["Yarn tests"]
resolves = ["Yarn tests", "Typescript types tests"]
}

action "Yarn install" {
uses = "docker://node:8"
args = "yarn install"
}

action "Yarn build" {
uses = "docker://node:8"
args = "yarn build"
needs = ["Yarn install"]
}

action "Yarn tests" {
uses = "docker://node:8"
args = "yarn test"
needs = ["Yarn build"]
}

action "Typescript types tests" {
uses = "docker://node:8"
args = "yarn test-types"
needs = ["Yarn install"]
}

action "Deploy package to NPM" {
uses = "stephenwf/module-release-action@master"
secrets = ["NPM_AUTH"]
needs = ["Yarn install"]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
node_modules
dist
coverage
.cache
yarn-error.log
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspaces-experimental true
2 changes: 1 addition & 1 deletion __tests__/process/fixtures/0001.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Manifest } from '../../../src';
import json from './0001.json';
import {Manifest} from "@hyperion-framework/types";

describe('process/fixtures/0001', () => {
test('fixture is correctly typed', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/types/resources/annotation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Annotation } from '../../../src/types/resources/annotation';
import {Annotation} from "@hyperion-framework/types";

describe('types/resources/annotations', () => {
test('it passes fixtures from W3C', () => {
Expand Down
6 changes: 2 additions & 4 deletions __tests__/types/resources/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Manifest } from '../../../src';

import {ContentResource, Manifest} from '../../../packages/types';
import ghentManifest from '../../../fixtures/2-to-3-converter/manifests/ghent-university-manifest.json';
import blManifest from '../../../fixtures/2-to-3-converter/manifests/british-library-manifest.json';
import princetonManifest from '../../../fixtures/2-to-3-converter/manifests/princeton-manifest.json';
import ncsuManifest from '../../../fixtures/2-to-3-converter/manifests/ncsu-libraries-manifest.json';
import nlwNewspaper from '../../../fixtures/2-to-3-converter/manifests/nlw-newspaper-manifest.json';
import nlwManuscript from '../../../fixtures/2-to-3-converter/manifests/nlw-manuscript-manifest.json';
import { ContentResource } from '../../../src/types/resources/contentResource';
import { matchAnnotationBody } from '../../../src/pattern-matching/annotation';
import {matchAnnotationBody} from "@hyperion-framework/pattern-matching/src/annotation-body";

describe('types/manifest', () => {
describe('Manifests converted from Presentation 2', () => {
Expand Down
136 changes: 136 additions & 0 deletions __tests__/utility/__snapshots__/iiif-normalize-test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`utility/normalize it can normalize a simple manifest 1`] = `
Object {
"Annotation": Object {
"https://example.org/iiif/book1/annotation/p0001-image": Object {
"body": Array [
Object {
"format": "image/png",
"height": 1800,
"id": "http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png",
"type": "Image",
"width": 1200,
},
],
"id": "https://example.org/iiif/book1/annotation/p0001-image",
"motivation": Array [
"painting",
],
"target": "https://example.org/iiif/book1/canvas/p1",
"type": "Annotation",
},
},
"AnnotationCollection": Object {},
"AnnotationPage": Object {
"https://example.org/iiif/book1/page/p1/1": Object {
"behaviour": Array [],
"homepage": null,
"id": "https://example.org/iiif/book1/page/p1/1",
"items": Array [
Object {
"id": "https://example.org/iiif/book1/annotation/p0001-image",
"type": "Annotation",
},
],
"label": null,
"logo": Array [],
"metadata": Array [],
"motivation": null,
"rendering": Array [],
"requiredStatement": null,
"rights": null,
"seeAlso": Array [],
"service": Array [],
"summary": null,
"thumbnail": Array [],
"type": "AnnotationPage",
},
},
"Canvas": Object {
"https://example.org/iiif/book1/canvas/p1": Object {
"annotations": Array [],
"behaviour": Array [],
"duration": 0,
"height": 1800,
"homepage": null,
"id": "https://example.org/iiif/book1/canvas/p1",
"items": Array [
Object {
"id": "https://example.org/iiif/book1/page/p1/1",
"type": "AnnotationPage",
},
],
"label": null,
"logo": Array [],
"metadata": Array [],
"motivation": null,
"navDate": null,
"partOf": Array [],
"posterCanvas": null,
"rendering": Array [],
"requiredStatement": null,
"rights": null,
"seeAlso": Array [],
"service": Array [],
"summary": null,
"thumbnail": Array [],
"type": "Canvas",
"width": 1200,
},
},
"Collection": Object {},
"ContentResource": Object {
"http://myhomepage.com": Object {
"id": "http://myhomepage.com",
"type": "ContentResource",
},
},
"Manifest": Object {
"https://example.org/iiif/book1/manifest": Object {
"@context": Array [
"http://www.w3.org/ns/anno.jsonld",
"http://iiif.io/api/presentation/{{ page.major }}/context.json",
],
"annotations": Array [],
"behaviour": Array [],
"homepage": Object {
"id": "http://myhomepage.com",
"type": "ContentResource",
},
"id": "https://example.org/iiif/book1/manifest",
"items": Array [
Object {
"id": "https://example.org/iiif/book1/canvas/p1",
"type": "Canvas",
},
],
"label": Object {
"en": Array [
"Image 1",
],
},
"logo": Array [],
"metadata": Array [],
"motivation": null,
"navDate": null,
"partOf": Array [],
"posterCanvas": null,
"rendering": Array [],
"requiredStatement": null,
"rights": null,
"seeAlso": Array [],
"service": Array [],
"start": null,
"structures": Array [],
"summary": null,
"thumbnail": Array [],
"type": "Manifest",
"viewingDirection": "left-to-right",
},
},
"Range": Object {},
"Selector": Object {},
"Service": Object {},
}
`;
67 changes: 5 additions & 62 deletions __tests__/utility/iiif-normalize-test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { normalize } from '../../src/utility/iiif-normalize';
import { Manifest } from '../../src';
import { Manifest } from '@hyperion-framework/types';
import { normalize } from '@hyperion-framework/vault/src/processing/normalize';

describe('utility/normalize', () => {
const manifest = (): Manifest => ({
'@context': ['http://www.w3.org/ns/anno.jsonld', 'http://iiif.io/api/presentation/{{ page.major }}/context.json'],
id: 'https://example.org/iiif/book1/manifest',
type: 'Manifest',
label: { en: ['Image 1'] },
homepage: 'http://myhomepage.com',
items: [
{
id: 'https://example.org/iiif/book1/canvas/p1',
Expand Down Expand Up @@ -41,68 +42,10 @@ describe('utility/normalize', () => {
test('it can normalize a simple manifest', () => {
const result = normalize(manifest());

expect(result.entities).toEqual({
Annotation: {
'https://example.org/iiif/book1/annotation/p0001-image': {
body: {
id: 'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png',
type: 'ContentResource',
},
id: 'https://example.org/iiif/book1/annotation/p0001-image',
motivation: 'painting',
target: { id: 'https://example.org/iiif/book1/canvas/p1', type: 'ContentResource' },
type: 'Annotation',
},
},
AnnotationCollection: {},
AnnotationPage: {
'https://example.org/iiif/book1/page/p1/1': {
id: 'https://example.org/iiif/book1/page/p1/1',
items: [{ id: 'https://example.org/iiif/book1/annotation/p0001-image', type: 'Annotation' }],
type: 'AnnotationPage',
},
},
Canvas: {
'https://example.org/iiif/book1/canvas/p1': {
height: 1800,
id: 'https://example.org/iiif/book1/canvas/p1',
items: [{ id: 'https://example.org/iiif/book1/page/p1/1', type: 'AnnotationPage' }],
type: 'Canvas',
width: 1200,
},
},
Collection: {},
ContentResource: {
'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png': {
format: 'image/png',
height: 1800,
id: 'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png',
type: 'Image',
width: 1200,
},
'https://example.org/iiif/book1/canvas/p1': {
id: 'https://example.org/iiif/book1/canvas/p1',
type: 'ContentResource',
},
},
Manifest: {
'https://example.org/iiif/book1/manifest': {
'@context': [
'http://www.w3.org/ns/anno.jsonld',
'http://iiif.io/api/presentation/{{ page.major }}/context.json',
],
id: 'https://example.org/iiif/book1/manifest',
items: [{ id: 'https://example.org/iiif/book1/canvas/p1', type: 'Canvas' }],
label: { en: ['Image 1'] },
type: 'Manifest',
},
},
Range: {},
Service: {},
});
expect(result.entities).toMatchSnapshot();

expect(result.mapping).toEqual({
'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png': 'ContentResource',
'http://myhomepage.com': 'ContentResource',
'https://example.org/iiif/book1/annotation/p0001-image': 'Annotation',
'https://example.org/iiif/book1/canvas/p1': 'Canvas',
'https://example.org/iiif/book1/manifest': 'Manifest',
Expand Down
23 changes: 9 additions & 14 deletions __tests__/utility/iiif-traverse-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Traverse } from '../../src/utility/iiif-traverse';
import { Manifest } from '../../src';
import { Canvas } from '../../src/types/resources/canvas';
import { Canvas, Manifest } from '@hyperion-framework/types';
import { Traverse } from '@hyperion-framework/vault/src/processing/traverse';

describe('utility/iiif-traverse', () => {
const manifest = (): Manifest => ({
Expand Down Expand Up @@ -107,7 +106,13 @@ describe('utility/iiif-traverse', () => {
expect(store).toEqual({
Annotation: {
'https://example.org/iiif/book1/annotation/p0001-image': {
body: { id: 'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png', type: 'Image' },
body: {
format: 'image/png',
height: 1800,
id: 'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png',
type: 'Image',
width: 1200,
},
id: 'https://example.org/iiif/book1/annotation/p0001-image',
motivation: 'painting',
target: 'https://example.org/iiif/book1/canvas/p1',
Expand All @@ -130,15 +135,6 @@ describe('utility/iiif-traverse', () => {
width: 1200,
},
},
Image: {
'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png': {
format: 'image/png',
height: 1800,
id: 'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png',
type: 'Image',
width: 1200,
},
},
Manifest: {
'https://example.org/iiif/book1/manifest': {
'@context': [
Expand Down Expand Up @@ -169,7 +165,6 @@ describe('utility/iiif-traverse', () => {
traversal.traverseManifest(manifest());

expect(ids).toEqual([
'http://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png',
'https://example.org/iiif/book1/annotation/p0001-image',
'https://example.org/iiif/book1/page/p1/1',
'https://example.org/iiif/book1/canvas/p1',
Expand Down
18 changes: 18 additions & 0 deletions examples/react-context-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "react-context-example",
"private": true,
"version": "0.1.0",
"dependencies": {
"@hyperion-framework/vault": "^0.1.0",
"@hyperion-framework/react-vault": "^0.1.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
},
"scripts": {
"start": "fesk-start",
"build": "fesk-build"
},
"devDependencies": {
"@fesk/scripts": "^1.1.8"
}
}
34 changes: 34 additions & 0 deletions examples/react-context-example/src/components/App/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { useExternalManifest, ManifestProvider, useManifest } from '@hyperion-framework/react-vault';
import { manifestContext, createSelector } from '@hyperion-framework/vault';

const manifestLabelSelector = createSelector({
context: [manifestContext],
selector: ((state, ctx) => {
return ctx.manifest.label.en.join('');
})
});

function ManifestLabel() {
const label = useManifest(manifestLabelSelector);

return <div>{label}</div>
}

function App() {
const { isLoaded, id } = useExternalManifest('https://adam-digirati.github.io/balenciaga1-behaviors.json');

if (!isLoaded) {
return <div>Loading...</div>
}

return (
<ManifestProvider id={id}>
Hello react.
<ManifestLabel/>
</ManifestProvider>
);

}

export default App;
Loading

0 comments on commit 7b6f381

Please sign in to comment.