瀏覽代碼

Split packages

Use monorepo structure for app, core, and plugin projects.
feature/transactions
TheoryOfNekomata 4 年之前
父節點
當前提交
f765207a20
共有 63 個檔案被更改,包括 135 行新增44 行删除
  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 查看文件

@@ -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 查看文件


.sequelizerc → packages/app/.sequelizerc 查看文件


README.md → packages/app/README.md 查看文件


config/config.js → packages/app/config/config.js 查看文件


migrate.ts → packages/app/migrate.ts 查看文件


next-env.d.ts → packages/app/next-env.d.ts 查看文件


next.config.js → packages/app/next.config.js 查看文件


package.json → packages/app/package.json 查看文件

@@ -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 查看文件


public/vercel.svg → packages/app/public/vercel.svg 查看文件


src/assets/global.css → packages/app/src/assets/global.css 查看文件


src/assets/mobiledoc.css → packages/app/src/assets/mobiledoc.css 查看文件


src/assets/theme.css → packages/app/src/assets/theme.css 查看文件


src/components/Editor/Editor.tsx → packages/app/src/components/Editor/Editor.tsx 查看文件


src/components/Icon/Icon.tsx → packages/app/src/components/Icon/Icon.tsx 查看文件


src/components/Navbar/Navbar.tsx → packages/app/src/components/Navbar/Navbar.tsx 查看文件


src/components/PrimaryNavItem/PrimaryNavItem.tsx → packages/app/src/components/PrimaryNavItem/PrimaryNavItem.tsx 查看文件


src/components/SecondaryNavItem/SecondaryNavItem.tsx → packages/app/src/components/SecondaryNavItem/SecondaryNavItem.tsx 查看文件


src/controllers/Folder.ts → packages/app/src/controllers/Folder.ts 查看文件


src/controllers/Note.ts → packages/app/src/controllers/Note.ts 查看文件


src/models.ts → packages/app/src/models.ts 查看文件


src/models/Folder.ts → packages/app/src/models/Folder.ts 查看文件


src/models/Note.ts → packages/app/src/models/Note.ts 查看文件


src/models/Operation.ts → packages/app/src/models/Operation.ts 查看文件


src/models/Tag.ts → packages/app/src/models/Tag.ts 查看文件


src/models/Transaction.ts → packages/app/src/models/Transaction.ts 查看文件


src/pages/_app.tsx → packages/app/src/pages/_app.tsx 查看文件


src/pages/_document.tsx → packages/app/src/pages/_document.tsx 查看文件


src/pages/api/folders.ts → packages/app/src/pages/api/folders.ts 查看文件


src/pages/api/folders/[id].ts → packages/app/src/pages/api/folders/[id].ts 查看文件


src/pages/api/notes.ts → packages/app/src/pages/api/notes.ts 查看文件


src/pages/api/notes/[id].ts → packages/app/src/pages/api/notes/[id].ts 查看文件


src/pages/notes.tsx → packages/app/src/pages/notes.tsx 查看文件


src/pages/notes/[id].tsx → packages/app/src/pages/notes/[id].tsx 查看文件


src/seeds.ts → packages/app/src/seeds.ts 查看文件


src/services/LocalStorage.ts → packages/app/src/services/LocalStorage.ts 查看文件


src/services/Operation.ts → packages/app/src/services/Operation.ts 查看文件


src/services/Storage.ts → packages/app/src/services/Storage.ts 查看文件


src/services/entities/Folder.ts → packages/app/src/services/entities/Folder.ts 查看文件


src/services/entities/Note.ts → packages/app/src/services/entities/Note.ts 查看文件


src/utilities/ColumnTypes.ts → packages/app/src/utilities/ColumnTypes.ts 查看文件


src/utilities/Date.ts → packages/app/src/utilities/Date.ts 查看文件


src/utilities/Id.ts → packages/app/src/utilities/Id.ts 查看文件


src/utilities/ORM.ts → packages/app/src/utilities/ORM.ts 查看文件


src/utilities/Response.ts → packages/app/src/utilities/Response.ts 查看文件


src/utilities/Serialization.ts → packages/app/src/utilities/Serialization.ts 查看文件


tsconfig.json → packages/app/tsconfig.json 查看文件


yarn.lock → packages/app/yarn.lock 查看文件


zeichen.config.ts → packages/app/zeichen.config.ts 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件


src/plugins/local-storage/Storage.ts → packages/plugin-local-storage/Storage.ts 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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')
}

Loading…
取消
儲存