Skip to content
Snippets Groups Projects
Commit 3e277ce1 authored by Behrisch, M. (Michael)'s avatar Behrisch, M. (Michael)
Browse files

fix(storybook): :ambulance: adds babel config for module resolution of util projects

The storyboard TS config was not having any babelrc information
required for the external module resolution (with a package.json)
parent 5704e9c8
No related branches found
No related tags found
2 merge requests!17fix(storybook): :ambulance: adds babel config for module resolution of util projects,!15May 2022 merge request
Showing
with 428 additions and 32 deletions
{ "extends": "../.babelrc" }
......@@ -28,4 +28,8 @@ module.exports = {
return config;
},
babel: async (options) => ({
...options,
// any extra options you want to set
}),
};
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"emitDecoratorMetadata": false,
"outDir": ""
},
"files": [
......@@ -14,6 +14,7 @@
"../**/*.spec.js",
"../**/*.spec.tsx",
"../**/*.spec.jsx"
],
"include": ["../src/**/*", "*.js"]
]
// ,
// "include": ["../src/**/*", "*.js"]
}
import { SchemaUtils } from '@graphpolaris/schema-utils';
import { SchemaFromBackend } from '@graphpolaris/models';
const twitterSchemaRaw: SchemaFromBackend = {
nodes: [
{
name: 'Me',
attributes: [
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
],
},
{
name: 'Link',
attributes: [
{
name: 'url',
type: 'string',
},
],
},
{
name: 'Source',
attributes: [
{
name: 'name',
type: 'string',
},
],
},
{
name: 'Hashtag',
attributes: [
{
name: 'name',
type: 'string',
},
],
},
{
name: 'User',
attributes: [
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'statuses',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
],
},
{
name: 'Tweet',
attributes: [
{
name: 'id',
type: 'int',
},
{
name: 'id_str',
type: 'string',
},
{
name: 'text',
type: 'string',
},
{
name: 'favorites',
type: 'int',
},
{
name: 'import_method',
type: 'string',
},
],
},
],
edges: [
{
name: 'USING',
collection: 'USING',
from: 'Tweet',
to: 'Source',
attributes: [],
},
{
name: 'SIMILAR_TO',
collection: 'SIMILAR_TO',
from: 'User',
to: 'User',
attributes: [
{
name: 'score',
type: 'float',
},
],
},
{
name: 'SIMILAR_TO',
collection: 'SIMILAR_TO',
from: 'User',
to: 'Me',
attributes: [
{
name: 'score',
type: 'float',
},
],
},
{
name: 'AMPLIFIES',
collection: 'AMPLIFIES',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'AMPLIFIES',
collection: 'AMPLIFIES',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'RT_MENTIONS',
collection: 'RT_MENTIONS',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'RT_MENTIONS',
collection: 'RT_MENTIONS',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'User',
to: 'Me',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'Me',
to: 'Me',
attributes: [],
},
{
name: 'INTERACTS_WITH',
collection: 'INTERACTS_WITH',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'INTERACTS_WITH',
collection: 'INTERACTS_WITH',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'RETWEETS',
collection: 'RETWEETS',
from: 'Tweet',
to: 'Tweet',
attributes: [],
},
{
name: 'REPLY_TO',
collection: 'REPLY_TO',
from: 'Tweet',
to: 'Tweet',
attributes: [],
},
{
name: 'CONTAINS',
collection: 'CONTAINS',
from: 'Tweet',
to: 'Link',
attributes: [],
},
{
name: 'MENTIONS',
collection: 'MENTIONS',
from: 'Tweet',
to: 'User',
attributes: [],
},
{
name: 'MENTIONS',
collection: 'MENTIONS',
from: 'Tweet',
to: 'Me',
attributes: [],
},
{
name: 'TAGS',
collection: 'TAGS',
from: 'Tweet',
to: 'Hashtag',
attributes: [],
},
{
name: 'POSTS',
collection: 'POSTS',
from: 'User',
to: 'Tweet',
attributes: [],
},
{
name: 'POSTS',
collection: 'POSTS',
from: 'Me',
to: 'Tweet',
attributes: [],
},
],
};
const twitterSchema =
SchemaUtils.ParseSchemaFromBackend(twitterSchemaRaw);
describe('import tests', () => {
it('should resolve all imports appropriately for _external_ libs @graphpolaris/schema-utils and @graphpolaris/model ', () => {
const graph = twitterSchema;
expect(graph);
});
});
\ No newline at end of file
......@@ -11,6 +11,17 @@ import React from 'react';
import { Provider } from 'react-redux';
import Schema from './schema';
import {
movieSchemaRaw,
northwindSchemaRaw,
simpleSchemaRaw,
twitterSchemaRaw,
movieSchema,
northWindSchema,
simpleSchema,
twitterSchema,
} from '@graphpolaris/shared/mock-data';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
......@@ -146,5 +157,47 @@ TestWithSchema.play = async () => {
console.info('dispatch dummy schema', schema.order);
dispatch(setSchema(schema.export()));
// handleSchemaLayout(schema);
};
export const TestWithMockNorthWindSchema = Template.bind({});
TestWithMockNorthWindSchema.play = async () => {
const dispatch = Mockstore.dispatch;
const schema = northWindSchema;
console.info('dispatch northWindSchema schema', schema.order);
dispatch(setSchema(schema.export()));
};
export const TestWithMockTwitterSchema = Template.bind({});
TestWithMockTwitterSchema.play = async () => {
const dispatch = Mockstore.dispatch;
const schema = twitterSchema;
console.info('dispatch TestWithMockTwitterSchema schema', schema.order);
dispatch(setSchema(schema.export()));
};
export const TestWithMockSimpleSchema = Template.bind({});
TestWithMockSimpleSchema.play = async () => {
const dispatch = Mockstore.dispatch;
const schema = simpleSchema;
console.info('dispatch simpleSchema schema', schema.order);
dispatch(setSchema(schema.export()));
};
export const TestWithMockMovieSchema = Template.bind({});
TestWithMockMovieSchema.play = async () => {
const dispatch = Mockstore.dispatch;
const schema = movieSchema;
console.info('dispatch movieSchema schema', schema.order);
dispatch(setSchema(schema.export()));
};
\ No newline at end of file
import Graph from 'graphology';
import { movieSchemaRaw, movieSchema } from './moviesSchemaRaw';
import { northWindSchema, northwindSchemaRaw } from './northwindSchemaRaw';
import { simpleSchema, simpleSchemaRaw } from './simpleRaw';
import { twitterSchema, twitterSchemaRaw } from './twitterSchemaRaw';
import { movieSchemaRaw, movieSchema } from '..';
import { northWindSchema, northwindSchemaRaw } from '..';
import { simpleSchema, simpleSchemaRaw } from '..';
import { twitterSchema, twitterSchemaRaw } from '..';
describe('MockData Tests', () => {
it('should have raw data available movie', () => {
......@@ -29,27 +29,35 @@ describe('MockData Tests', () => {
const graph = movieSchema;
expect(graph);
expect(graph.constructor.name.toLowerCase().indexOf('graph') != -1).toBeTruthy();
expect(
graph.constructor.name.toLowerCase().indexOf('graph') != -1
).toBeTruthy();
});
it('should have data available as graphology model northwind', () => {
const graph = northWindSchema;
expect(graph);
expect(graph.constructor.name.toLowerCase().indexOf('graph') != -1).toBeTruthy();
expect(
graph.constructor.name.toLowerCase().indexOf('graph') != -1
).toBeTruthy();
});
it('should have data available as graphology model simpleSchemaRaw', () => {
const graph = simpleSchema;
expect(graph);
expect(graph.constructor.name.toLowerCase().indexOf('graph') != -1).toBeTruthy();
expect(
graph.constructor.name.toLowerCase().indexOf('graph') != -1
).toBeTruthy();
});
it('should have data available as graphology model twitterSchemaRaw', () => {
const graph = twitterSchema;
expect(graph);
expect(graph.constructor.name.toLowerCase().indexOf('graph') != -1).toBeTruthy();
expect(
graph.constructor.name.toLowerCase().indexOf('graph') != -1
).toBeTruthy();
});
});
import { SchemaUtils } from '@graphpolaris/schema-utils';
import { SchemaFromBackend } from 'libs/shared/models/src';
import { SchemaFromBackend } from '@graphpolaris/models';
export const movieSchemaRaw = {
export const movieSchemaRaw: SchemaFromBackend = {
nodes: [
{
name: 'Movie',
......@@ -98,6 +98,5 @@ export const movieSchemaRaw = {
],
};
export const movieSchema = SchemaUtils.ParseSchemaFromBackend(
movieSchemaRaw as SchemaFromBackend
);
export const movieSchema = SchemaUtils.ParseSchemaFromBackend(movieSchemaRaw);
import { SchemaUtils } from '@graphpolaris/schema-utils';
import { SchemaFromBackend } from 'libs/shared/models/src';
import { SchemaFromBackend } from '@graphpolaris/models';
export const northwindSchemaRaw = {
export const northwindSchemaRaw: SchemaFromBackend = {
nodes: [
{
name: 'Order',
......@@ -286,6 +286,5 @@ export const northwindSchemaRaw = {
],
};
export const northWindSchema = SchemaUtils.ParseSchemaFromBackend(
northwindSchemaRaw as SchemaFromBackend
);
export const northWindSchema =
SchemaUtils.ParseSchemaFromBackend(northwindSchemaRaw);
import { SchemaUtils } from '@graphpolaris/schema-utils';
import { SchemaFromBackend } from '@graphpolaris/models';
export const simpleSchemaRaw = {
export const simpleSchemaRaw: SchemaFromBackend = {
nodes: [
{
name: 'Thijs',
......@@ -103,6 +103,4 @@ export const simpleSchemaRaw = {
],
};
export const simpleSchema = SchemaUtils.ParseSchemaFromBackend(
simpleSchemaRaw as SchemaFromBackend
);
export const simpleSchema = SchemaUtils.ParseSchemaFromBackend(simpleSchemaRaw);
import { SchemaUtils } from '@graphpolaris/schema-utils';
import { SchemaFromBackend } from 'libs/shared/models/src';
import { SchemaFromBackend } from '@graphpolaris/models';
export const twitterSchemaRaw = {
export const twitterSchemaRaw: SchemaFromBackend = {
nodes: [
{
name: 'Me',
......@@ -315,6 +315,5 @@ export const twitterSchemaRaw = {
],
};
export const twitterSchema = SchemaUtils.ParseSchemaFromBackend(
twitterSchemaRaw as SchemaFromBackend
);
export const twitterSchema =
SchemaUtils.ParseSchemaFromBackend(twitterSchemaRaw);
......@@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"module": "esnext",
"types": ["jest", "node"],
"composite": true
},
......
......@@ -20,6 +20,8 @@ export class SchemaUtils {
});
});
// The name of the edge will be name + from + to, since edge names are not unique
edges.forEach((edge: Edge) => {
const edgeID = [edge.name, '_', edge.from, edge.to].join(''); //ensure that all interpreted as string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment