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

TS: Resolve all circular dependencies and run madge as part of CI checks #128

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/pond/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"clean": "rimraf ./lib ./coverage",
"build": "tsc -p ./tsconfig.prod.json",
"build:watch": "npm run build -- --watch --pretty",
"build:prod": "npm run clean && npm run lint && npm run test:ci && npm run build && npm run api:accept",
"build:prod": "npm run clean && npm run lint && npm run test:ci && npm run build && npm run api:accept && npm run madge",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"format:configs": "prettier --write .prettierrc.json jest.config.js .vscode/settings.json tsconfig.prod.json tsconfig.json .eslintrc.json",
Expand Down
2 changes: 1 addition & 1 deletion js/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"clean": "rimraf ./lib ./coverage",
"build": "tsc -p ./tsconfig.prod.json",
"build:watch": "npm run build -- --watch --pretty",
"build:prod": "npm run clean && npm run lint && npm run test:ci && npm run build && npm run api:accept",
"build:prod": "npm run clean && npm run lint && npm run test:ci && npm run build && npm run api:accept && npm run madge",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint -- --fix",
"format:configs": "prettier --write .prettierrc.json jest.config.js .vscode/settings.json tsconfig.prod.json tsconfig.json .eslintrc.json",
Expand Down
4 changes: 2 additions & 2 deletions js/sdk/src/actyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2021 Actyx AG
*/
import { EventFns, TestEventFns } from './event-fns'
import { EventFnsFromEventStoreV2, EventStoreV2 } from './internal_common'
import { EventFnsFromEventStoreV2, EventStores } from './internal_common'
import { log } from './internal_common/log'
import { SnapshotStore } from './snapshotStore'
import { ActyxOpts, ActyxTestOpts, AppId, AppManifest, NodeId } from './types'
Expand Down Expand Up @@ -102,7 +102,7 @@ export const Actyx = {
* @public
*/
test: (opts: ActyxTestOpts = {}): TestActyx => {
const store = EventStoreV2.test(opts.nodeId)
const store = EventStores.test(opts.nodeId)
const snaps = SnapshotStore.inMem()
const nodeId = opts.nodeId || NodeId.of('TESTNODEID')

Expand Down
6 changes: 3 additions & 3 deletions js/sdk/src/internal_common/event-fns-impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* Copyright (C) 2021 Actyx AG
*/
import { chunksOf } from 'fp-ts/lib/Array'
import { Subject } from '../../node_modules/rxjs'
import {
ActyxEvent,
allEvents,
Expand All @@ -16,9 +15,10 @@ import {
NodeId,
Where,
} from '..'
import { Subject } from '../../node_modules/rxjs'
import { SnapshotStore } from '../snapshotStore'
import { EventFnsFromEventStoreV2 } from './event-fns-impl'
import { EventStore } from './eventStore'
import { testEventStore } from './testEventStore'
import { emitter, mkTimeline } from './testHelper'
import { Event, Events } from './types'

Expand Down Expand Up @@ -141,7 +141,7 @@ const setup = () => {
const srcC = emitter('C')
const tl = mkTimeline(srcC(5), srcB(6), srcA(7), srcA(8), srcB(9), srcC(10))

const store = EventStore.test()
const store = testEventStore()
const fns = EventFnsFromEventStoreV2(NodeId.of('noop'), store, SnapshotStore.noop)

return { store, fns, tl }
Expand Down
20 changes: 0 additions & 20 deletions js/sdk/src/internal_common/eventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
import { Observable } from '../../node_modules/rxjs'
import { EventsSortOrder, NodeId, OffsetMap, Where } from '../types'
import { mockEventStore } from './mockEventStore'
import { testEventStore, TestEventStore } from './testEventStore'
import { Event, Events, OffsetsResponse, UnstoredEvents } from './types'

/**
Expand Down Expand Up @@ -76,21 +74,3 @@ export type EventStore = {
readonly subscribe: DoSubscribe
readonly persistEvents: DoPersistEvents
}

const noopEventStore: EventStore = {
subscribe: () => Observable.empty(),
query: () => Observable.empty(),
queryUnchecked: () => Observable.empty(),
offsets: () => Promise.resolve({ present: {}, toReplicate: {} }),
persistEvents: () => Observable.empty(),
}

export const EventStore: {
noop: EventStore
mock: () => EventStore
test: (nodeId?: NodeId, eventChunkSize?: number) => TestEventStore
} = {
noop: noopEventStore,
mock: mockEventStore,
test: testEventStore,
}
19 changes: 19 additions & 0 deletions js/sdk/src/internal_common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@
export { EventFnsFromEventStoreV2 } from './event-fns-impl'
export { EventStore as EventStoreV2 } from './eventStore'
export * from './types'

import { Observable } from '../../node_modules/rxjs'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why node_modules need to be specified? Couldn't it be imported from 'rxjs'.
Why do we reexport it anyway, because of node_modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The RXjs import style is due to some Grafana issue (I just took it over from other files)
See 073f280

Copy link
Member

Choose a reason for hiding this comment

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

Importing from 'rxjs' is resolved very differently from importing a file path — we depend on version 5 but the former actually gave us version 6 in some contexts. So I learnt that “private” dependencies actually need to be resolved by file path in order to really keep them private.

import { EventStore } from './eventStore'
import { mockEventStore } from './mockEventStore'
import { testEventStore } from './testEventStore'

const noopEventStore: EventStore = {
subscribe: () => Observable.empty(),
query: () => Observable.empty(),
queryUnchecked: () => Observable.empty(),
offsets: () => Promise.resolve({ present: {}, toReplicate: {} }),
persistEvents: () => Observable.empty(),
}

export const EventStores = {
noop: noopEventStore,
mock: mockEventStore,
test: testEventStore,
}
182 changes: 0 additions & 182 deletions js/sdk/src/snapshotStore/inMemSnapshotStore.ts

This file was deleted.