Pārlūkot izejas kodu

Split packages

Use monorepo structure for app, core, and plugin projects.
feature/transactions
TheoryOfNekomata pirms 4 gadiem
vecāks
revīzija
f765207a20
63 mainītis faili ar 135 papildinājumiem un 44 dzēšanām
  1. +6
    -6
      .gitignore
  2. +0
    -0
      packages/app/.babelrc
  3. +0
    -0
      packages/app/.sequelizerc
  4. +0
    -0
      packages/app/README.md
  5. +0
    -0
      packages/app/config/config.js
  6. +0
    -0
      packages/app/migrate.ts
  7. +0
    -0
      packages/app/next-env.d.ts
  8. +0
    -0
      packages/app/next.config.js
  9. +1
    -1
      packages/app/package.json
  10. +0
    -0
      packages/app/public/favicon.ico
  11. +0
    -0
      packages/app/public/vercel.svg
  12. +0
    -0
      packages/app/src/assets/global.css
  13. +0
    -0
      packages/app/src/assets/mobiledoc.css
  14. +0
    -0
      packages/app/src/assets/theme.css
  15. +0
    -0
      packages/app/src/components/Editor/Editor.tsx
  16. +0
    -0
      packages/app/src/components/Icon/Icon.tsx
  17. +0
    -0
      packages/app/src/components/Navbar/Navbar.tsx
  18. +0
    -0
      packages/app/src/components/PrimaryNavItem/PrimaryNavItem.tsx
  19. +0
    -0
      packages/app/src/components/SecondaryNavItem/SecondaryNavItem.tsx
  20. +0
    -0
      packages/app/src/controllers/Folder.ts
  21. +0
    -0
      packages/app/src/controllers/Note.ts
  22. +0
    -0
      packages/app/src/models.ts
  23. +0
    -0
      packages/app/src/models/Folder.ts
  24. +0
    -0
      packages/app/src/models/Note.ts
  25. +0
    -0
      packages/app/src/models/Operation.ts
  26. +0
    -0
      packages/app/src/models/Tag.ts
  27. +0
    -0
      packages/app/src/models/Transaction.ts
  28. +0
    -0
      packages/app/src/pages/_app.tsx
  29. +0
    -0
      packages/app/src/pages/_document.tsx
  30. +0
    -0
      packages/app/src/pages/api/folders.ts
  31. +0
    -0
      packages/app/src/pages/api/folders/[id].ts
  32. +0
    -0
      packages/app/src/pages/api/notes.ts
  33. +0
    -0
      packages/app/src/pages/api/notes/[id].ts
  34. +0
    -0
      packages/app/src/pages/notes.tsx
  35. +0
    -0
      packages/app/src/pages/notes/[id].tsx
  36. +0
    -0
      packages/app/src/seeds.ts
  37. +0
    -0
      packages/app/src/services/LocalStorage.ts
  38. +0
    -0
      packages/app/src/services/Operation.ts
  39. +0
    -0
      packages/app/src/services/Storage.ts
  40. +0
    -0
      packages/app/src/services/entities/Folder.ts
  41. +0
    -0
      packages/app/src/services/entities/Note.ts
  42. +0
    -0
      packages/app/src/utilities/ColumnTypes.ts
  43. +0
    -0
      packages/app/src/utilities/Date.ts
  44. +0
    -0
      packages/app/src/utilities/Id.ts
  45. +0
    -0
      packages/app/src/utilities/ORM.ts
  46. +0
    -0
      packages/app/src/utilities/Response.ts
  47. +0
    -0
      packages/app/src/utilities/Serialization.ts
  48. +0
    -0
      packages/app/tsconfig.json
  49. +0
    -0
      packages/app/yarn.lock
  50. +2
    -2
      packages/app/zeichen.config.ts
  51. +5
    -0
      packages/core/plugin.ts
  52. +1
    -1
      packages/core/storage.ts
  53. +0
    -0
      packages/plugin-local-storage/Engine.ts
  54. +5
    -5
      packages/plugin-local-storage/Storage.ts
  55. +13
    -0
      packages/plugin-local-storage/index.ts
  56. +12
    -0
      packages/plugin-local-storage/package.json
  57. +35
    -0
      packages/plugin-local-storage/tsconfig.json
  58. +1
    -1
      packages/plugin-remote-storage/Engine.ts
  59. +3
    -3
      packages/plugin-remote-storage/Storage.ts
  60. +4
    -7
      packages/plugin-remote-storage/index.ts
  61. +12
    -0
      packages/plugin-remote-storage/package.json
  62. +35
    -0
      packages/plugin-remote-storage/tsconfig.json
  63. +0
    -18
      src/plugins/local-storage/index.ts

+ 6
- 6
.gitignore Parādīt failu

@@ -1,19 +1,19 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
node_modules/
.pnp/
.pnp.js

# testing
/coverage
coverage/

# next.js
/.next/
/out/
.next/
out/

# production
/build
build/

# misc
.DS_Store


.babelrc → packages/app/.babelrc Parādīt failu


.sequelizerc → packages/app/.sequelizerc Parādīt failu


README.md → packages/app/README.md Parādīt failu


config/config.js → packages/app/config/config.js Parādīt failu


migrate.ts → packages/app/migrate.ts Parādīt failu


next-env.d.ts → packages/app/next-env.d.ts Parādīt failu


next.config.js → packages/app/next.config.js Parādīt failu


package.json → packages/app/package.json Parādīt failu

@@ -1,5 +1,5 @@
{
"name": "note.modal.sh",
"name": "zeichen-app",
"version": "0.1.0",
"private": true,
"scripts": {

public/favicon.ico → packages/app/public/favicon.ico Parādīt failu


public/vercel.svg → packages/app/public/vercel.svg Parādīt failu


src/assets/global.css → packages/app/src/assets/global.css Parādīt failu


src/assets/mobiledoc.css → packages/app/src/assets/mobiledoc.css Parādīt failu


src/assets/theme.css → packages/app/src/assets/theme.css Parādīt failu


src/components/Editor/Editor.tsx → packages/app/src/components/Editor/Editor.tsx Parādīt failu


src/components/Icon/Icon.tsx → packages/app/src/components/Icon/Icon.tsx Parādīt failu


src/components/Navbar/Navbar.tsx → packages/app/src/components/Navbar/Navbar.tsx Parādīt failu


src/components/PrimaryNavItem/PrimaryNavItem.tsx → packages/app/src/components/PrimaryNavItem/PrimaryNavItem.tsx Parādīt failu


src/components/SecondaryNavItem/SecondaryNavItem.tsx → packages/app/src/components/SecondaryNavItem/SecondaryNavItem.tsx Parādīt failu


src/controllers/Folder.ts → packages/app/src/controllers/Folder.ts Parādīt failu


src/controllers/Note.ts → packages/app/src/controllers/Note.ts Parādīt failu


src/models.ts → packages/app/src/models.ts Parādīt failu


src/models/Folder.ts → packages/app/src/models/Folder.ts Parādīt failu


src/models/Note.ts → packages/app/src/models/Note.ts Parādīt failu


src/models/Operation.ts → packages/app/src/models/Operation.ts Parādīt failu


src/models/Tag.ts → packages/app/src/models/Tag.ts Parādīt failu


src/models/Transaction.ts → packages/app/src/models/Transaction.ts Parādīt failu


src/pages/_app.tsx → packages/app/src/pages/_app.tsx Parādīt failu


src/pages/_document.tsx → packages/app/src/pages/_document.tsx Parādīt failu


src/pages/api/folders.ts → packages/app/src/pages/api/folders.ts Parādīt failu


src/pages/api/folders/[id].ts → packages/app/src/pages/api/folders/[id].ts Parādīt failu


src/pages/api/notes.ts → packages/app/src/pages/api/notes.ts Parādīt failu


src/pages/api/notes/[id].ts → packages/app/src/pages/api/notes/[id].ts Parādīt failu


src/pages/notes.tsx → packages/app/src/pages/notes.tsx Parādīt failu


src/pages/notes/[id].tsx → packages/app/src/pages/notes/[id].tsx Parādīt failu


src/seeds.ts → packages/app/src/seeds.ts Parādīt failu


src/services/LocalStorage.ts → packages/app/src/services/LocalStorage.ts Parādīt failu


src/services/Operation.ts → packages/app/src/services/Operation.ts Parādīt failu


src/services/Storage.ts → packages/app/src/services/Storage.ts Parādīt failu


src/services/entities/Folder.ts → packages/app/src/services/entities/Folder.ts Parādīt failu


src/services/entities/Note.ts → packages/app/src/services/entities/Note.ts Parādīt failu


src/utilities/ColumnTypes.ts → packages/app/src/utilities/ColumnTypes.ts Parādīt failu


src/utilities/Date.ts → packages/app/src/utilities/Date.ts Parādīt failu


src/utilities/Id.ts → packages/app/src/utilities/Id.ts Parādīt failu


src/utilities/ORM.ts → packages/app/src/utilities/ORM.ts Parādīt failu


src/utilities/Response.ts → packages/app/src/utilities/Response.ts Parādīt failu


src/utilities/Serialization.ts → packages/app/src/utilities/Serialization.ts Parādīt failu


tsconfig.json → packages/app/tsconfig.json Parādīt failu


yarn.lock → packages/app/yarn.lock Parādīt failu


zeichen.config.ts → packages/app/zeichen.config.ts Parādīt failu

@@ -1,5 +1,5 @@
import LocalStorage from './src/plugins/local-storage'
import RemoteStorage from './src/plugins/remote-storage'
import LocalStorage from '../plugin-local-storage'
import RemoteStorage from '../plugin-remote-storage'

export default {
plugins: [

+ 5
- 0
packages/core/plugin.ts Parādīt failu

@@ -0,0 +1,5 @@
export type State = {
currentUserId: string,
}

export type Plugin<T = {}> = (config: T) => (state: State) => void

src/services/storages/Storage.ts → packages/core/storage.ts Parādīt failu

@@ -4,7 +4,7 @@ export default interface Storage<T> {
deleteItem(item: T): Promise<boolean>
}

export interface StorageMeta<T> {
export interface Collection<T> {
items: T[],
lastModifiedBy: string,
lastModifiedAt: Date,

src/plugins/local-storage/Engine.ts → packages/plugin-local-storage/Engine.ts Parādīt failu


src/plugins/local-storage/Storage.ts → packages/plugin-local-storage/Storage.ts Parādīt failu

@@ -1,15 +1,15 @@
import Storage, { StorageMeta, OutOfSyncError } from '../../services/storages/Storage'
import Storage, { Collection, OutOfSyncError } from '../core/storage'
import Engine from './Engine'

export default class LocalStorage<T> implements Storage<T> {
private readonly engine: Engine<StorageMeta<T>>
private readonly engine: Engine<Collection<T>>

constructor(
private readonly ownerId: string,
private readonly storageId: string,
private readonly getItemId = item => item['id'],
) {
this.engine = new Engine<StorageMeta<T>>(window.localStorage)
this.engine = new Engine<Collection<T>>(window.localStorage)
}

private getMeta() {
@@ -31,7 +31,7 @@ export default class LocalStorage<T> implements Storage<T> {
async saveItem(newItem: T) {
const oldMeta = this.getMeta()
const isExistingItem = oldMeta.items.some(this.existenceCheck(newItem))
const newMeta: StorageMeta<T> = {
const newMeta: Collection<T> = {
items: isExistingItem
? oldMeta.items.map(oldItem => this.existenceCheck(newItem)(oldItem) ? newItem : oldItem)
: [...oldMeta.items, newItem],
@@ -44,7 +44,7 @@ export default class LocalStorage<T> implements Storage<T> {
async deleteItem(newItem: T) {
const oldMeta = this.getMeta()
const newItems = oldMeta.items.filter(oldItem => !this.existenceCheck(newItem)(oldItem))
const newMeta: StorageMeta<T> = {
const newMeta: Collection<T> = {
items: newItems,
lastModifiedBy: this.ownerId,
lastModifiedAt: new Date(),

+ 13
- 0
packages/plugin-local-storage/index.ts Parādīt failu

@@ -0,0 +1,13 @@
import { Plugin } from '../core/plugin'
import Storage from './Storage'

type PluginConfig = {}

const LocalStoragePlugin: Plugin<PluginConfig> = config => ({
currentUserId,
}) => {
new Storage(currentUserId, 'notes')
new Storage(currentUserId, 'folders')
}

export default LocalStoragePlugin

+ 12
- 0
packages/plugin-local-storage/package.json Parādīt failu

@@ -0,0 +1,12 @@
{
"name": "zeichen-plugin-local-storage",
"author": "TheoryOfNekomata <allan.crisostomo@outlook.com>",
"version": "0.1.0",
"description": "Save and load notes using the browser's local storage.",
"keywords": [
"zeichen",
"plugin",
"storage",
"local"
]
}

+ 35
- 0
packages/plugin-local-storage/tsconfig.json Parādīt failu

@@ -0,0 +1,35 @@
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"declaration": true,
"declarationDir": "./dist",
"sourceMap": true,
"strict": false
},
"exclude": [
"node_modules",
"**/*.test.ts",
"**/*.test.tsx"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}

src/plugins/remote-storage/Engine.ts → packages/plugin-remote-storage/Engine.ts Parādīt failu

@@ -1,4 +1,4 @@
import { Deserializer, Serializer } from '../../services/storages/Storage'
import { Deserializer, Serializer } from '../core/storage'

const CREATED = 201
const NO_CONTENT = 204

src/plugins/remote-storage/Storage.ts → packages/plugin-remote-storage/Storage.ts Parādīt failu

@@ -1,8 +1,8 @@
import Storage, { StorageMeta } from '../../services/storages/Storage'
import Storage, { Collection } from '../core/storage'
import Engine from './Engine'

export default class RemoteStorage<T> implements Storage<T> {
private readonly engine: Engine<T, StorageMeta<T>>
private readonly engine: Engine<T, Collection<T>>

constructor(
private ownerId: string,
@@ -17,7 +17,7 @@ export default class RemoteStorage<T> implements Storage<T> {
}

async queryItems() {
const response = await this.engine.getCollection(this.collectionId) as StorageMeta<T>;
const response = await this.engine.getCollection(this.collectionId) as Collection<T>;
return response.items;
}


src/plugins/remote-storage/index.ts → packages/plugin-remote-storage/index.ts Parādīt failu

@@ -1,18 +1,15 @@
import { Plugin } from '../core/plugin'
import Storage from './Storage'

type PluginConfig = {
baseUrl: string,
}

type State = {
currentUserId: string,
}

type Plugin = (config: PluginConfig) => (state: State) => void

const RemoteStoragePlugin: Plugin = config => ({
const RemoteStoragePlugin: Plugin<PluginConfig> = config => ({
currentUserId,
}) => {
new Storage(currentUserId, config.baseUrl, 'notes')
new Storage(currentUserId, config.baseUrl, 'folders')
}

export default RemoteStoragePlugin

+ 12
- 0
packages/plugin-remote-storage/package.json Parādīt failu

@@ -0,0 +1,12 @@
{
"name": "zeichen-plugin-remote-storage",
"author": "TheoryOfNekomata <allan.crisostomo@outlook.com>",
"version": "0.1.0",
"description": "Save and load notes using an external API.",
"keywords": [
"zeichen",
"plugin",
"storage",
"API"
]
}

+ 35
- 0
packages/plugin-remote-storage/tsconfig.json Parādīt failu

@@ -0,0 +1,35 @@
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"declaration": true,
"declarationDir": "./dist",
"sourceMap": true,
"strict": false
},
"exclude": [
"node_modules",
"**/*.test.ts",
"**/*.test.tsx"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}

+ 0
- 18
src/plugins/local-storage/index.ts Parādīt failu

@@ -1,18 +0,0 @@
import Storage from './Storage'

type PluginConfig = {

}

type State = {
currentUserId: string,
}

type Plugin = (config: PluginConfig) => (state: State) => void

const LocalStoragePlugin: Plugin = config => ({
currentUserId,
}) => {
new Storage(currentUserId, 'notes')
new Storage(currentUserId, 'folders')
}

Notiek ielāde…
Atcelt
Saglabāt