Skip to content

Commit 2799b8b

Browse files
committed
Add schema package with initial configuration (#968)
Introduced a dedicated schema package featuring a live editor with real-time linting for schema definitions. The implementation includes a new grammar and parser for Yorkie schema definitions, enabling structured validation capabilities.
1 parent c45f63b commit 2799b8b

31 files changed

+8187
-4205
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ packages/sdk/lib
1111

1212
# examples
1313
examples/react-tldraw/src/tldraw.d.ts
14+
15+
# schema
16+
packages/schema/antlr

.github/workflows/ci.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,31 @@ jobs:
4141
if: steps.cache.outputs.cache-hit != 'true'
4242
run: pnpm install
4343

44-
- run: pnpm lint
45-
- run: pnpm sdk build
46-
- run: pnpm build:examples
47-
- run: docker compose -f docker/docker-compose-ci.yml up --build -d
48-
- run: pnpm sdk test:ci
44+
- name: Lint
45+
run: pnpm lint
4946

47+
- name: Build and Test SDK
48+
run: |
49+
pnpm sdk build
50+
docker compose -f docker/docker-compose-ci.yml up --build -d
51+
pnpm sdk test:ci
5052
- name: Upload coverage to Codecov
5153
uses: codecov/codecov-action@v5
5254
with:
5355
files: ./coverage/lcov.info
5456
env:
5557
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5658

59+
- name: Build Examples
60+
run: pnpm build:examples
61+
62+
- name: Build React
63+
run: pnpm react build
64+
65+
- name: Build and Test Schema
66+
run: |
67+
pnpm schema build
68+
pnpm schema test
69+
5770
- name: Run benchmark
5871
run: pnpm sdk test:bench

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ jobs:
5050
run: pnpm publish --filter=@yorkie-js/react --no-git-checks --provenance
5151
env:
5252
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
54+
- name: Schema Build
55+
run: pnpm schema build
56+
- name: Schema Publish
57+
run: pnpm publish --filter=@yorkie-js/schema --no-git-checks --provenance
58+
env:
59+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

examples/react-tldraw/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {

examples/vanilla-codemirror6/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
"vite": "^5.0.12"
1414
},
1515
"dependencies": {
16-
"@codemirror/commands": "6.1.2",
17-
"@codemirror/highlight": "^0.19.8",
18-
"@codemirror/lang-markdown": "^6.0.2",
19-
"@codemirror/language-data": "^6.1.0",
2016
"@codemirror/state": "^6.4.1",
21-
"@codemirror/view": "6.23.1",
2217
"codemirror": "^6.0.1",
2318
"@yorkie-js/sdk": "workspace:*"
2419
}

examples/vanilla-codemirror6/src/main.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/* eslint-disable jsdoc/require-jsdoc */
2-
import yorkie, { DocEventType } from '@yorkie-js/sdk';
32
import type { EditOpInfo, OperationInfo } from '@yorkie-js/sdk';
3+
import yorkie, { DocEventType } from '@yorkie-js/sdk';
44
import { basicSetup, EditorView } from 'codemirror';
5-
import { keymap } from '@codemirror/view';
6-
import {
7-
markdown,
8-
markdownKeymap,
9-
markdownLanguage,
10-
} from '@codemirror/lang-markdown';
115
import { Transaction, TransactionSpec } from '@codemirror/state';
126
import { network } from './network';
137
import { displayLog, displayPeers } from './utils';
@@ -144,12 +138,7 @@ async function main() {
144138
// 03-2. create codemirror instance
145139
const view = new EditorView({
146140
doc: '',
147-
extensions: [
148-
basicSetup,
149-
markdown({ base: markdownLanguage }),
150-
keymap.of(markdownKeymap),
151-
updateListener,
152-
],
141+
extensions: [basicSetup, updateListener],
153142
parent: editorParentElem,
154143
});
155144

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"sdk": "pnpm --filter=@yorkie-js/sdk",
99
"devtools": "pnpm --filter=@yorkie-js/devtools",
1010
"react": "pnpm --filter=@yorkie-js/react",
11+
"schema": "pnpm --filter=@yorkie-js/schema",
1112
"nextjs-scheduler": "pnpm --filter=nextjs-scheduler",
1213
"nextjs-todolist": "pnpm --filter=nextjs-todolist",
1314
"react-tldraw": "pnpm --filter=react-tldraw",

packages/react/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# lib
27+
lib

packages/schema/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Antlr
27+
*.antlr

packages/schema/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Yorkie Schema
2+
3+
Yorkie Schema is a library that provides a schema definition and validation for Yorkie documents.
4+
5+
## Contributing
6+
7+
See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
8+
9+
## Contributors ✨
10+
11+
Thanks goes to these incredible people:
12+
13+
<a href="https://github.com/yorkie-team/yorkie-js-sdk/graphs/contributors">
14+
<img src="https://contrib.rocks/image?repo=yorkie-team/yorkie-js-sdk" />
15+
</a>

0 commit comments

Comments
 (0)