Skip to content

Commit a1840db

Browse files
committed
feat(schemas): enhance schemas
1 parent ffd58dc commit a1840db

File tree

3 files changed

+82
-24
lines changed

3 files changed

+82
-24
lines changed

lib/schemas/ParcelMeta.ts

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,97 @@
11
import { $schema } from './utils.ts'
22

33
type ParcelFormat = {
4-
/**
5-
* Parcel format ID
6-
*/
4+
/**
5+
* Parcel format ID
6+
*/
77
id: string
8-
/**
9-
* Parcel format version
10-
*/
8+
/**
9+
* Parcel format version
10+
*/
1111
version: number
1212
}
1313

14-
type ModDependency = {
15-
id: string
16-
/** Minimum version (SemVer) */
17-
min?: string
18-
/** Maximum version (SemVer) */
19-
max?: string
20-
}
14+
type ModDependency =
15+
| '*'
16+
| {
17+
/**
18+
* Minimum version (SemVer)
19+
*/
20+
min?: string
21+
/**
22+
* Maximum version (SemVer)
23+
*/
24+
max?: string
25+
}
2126

27+
/**
28+
* The meta file of a Parcel
29+
*
30+
* This file should be in the root directory of a parcel
31+
*/
2232
export type ParcelMeta = $schema & {
23-
/** The format of parcel */
33+
/**
34+
* The format of parcel
35+
*/
2436
format: ParcelFormat
25-
/** Minecraft data version */
37+
/**
38+
* Minecraft data version
39+
*
40+
* Refer to [Minecraft WIKI - Data version: List of data versions](https://minecraft.wiki/w/Data_version#List_of_data_versions)
41+
*/
2642
dataVersion: number
27-
/** Size of parcel in X,Y,Z */
43+
/**
44+
* Size of parcel in `X`, `Y`, `Z`.
45+
*
46+
* Must be positive integers.
47+
*/
2848
size: [number, number, number]
49+
/**
50+
* Display name of the parcel
51+
*
52+
* It doesn't need to be unique. It's used for display purposes only.
53+
*/
2954
name?: string
55+
/**
56+
* Description of the parcel
57+
*/
3058
description?: string
31-
/** Tags for searching */
59+
/**
60+
* Tags for categorizing
61+
*/
3262
tags?: string[]
3363
/**
3464
* List of mods that are allowed to be used in the parcel
65+
*
66+
* - Key is the mod ID, usually in lowercase with underscore separator.
67+
* - Value is the mod dependency, `"*"` means any version
68+
*
69+
* ### Example
70+
*
71+
* ```json
72+
* {
73+
* "mod_1": "*"
74+
* "mod_2": { "min": "1.0.0", "max": "2.0.0" },
75+
* "mod_3": { "min": "1.0.0" },
76+
* "mod_4": { "max": "1.0.0" }
77+
* }
78+
* ```
3579
*/
36-
mods?: ModDependency[]
80+
mods?: Record<string, ModDependency>
3781
/**
3882
* Whether to include blocks
3983
*
40-
* @default true
84+
* Default is `true`
85+
*
86+
* If `false`, the parcel will not save or load blocks, and existing block data will be cleared when saving.
4187
*/
4288
includeBlock?: boolean
4389
/**
4490
* Whether to include entities
4591
*
46-
* @default false
92+
* Default is `true`
93+
*
94+
* If `false`, the parcel will not save or load entities, and existing entity data will be cleared when saving.
4795
*/
4896
includeEntity?: boolean
4997
}

lib/schemas/RepoMeta.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import { $schema } from './utils.ts'
33
type ParcelPath = string
44

55
/**
6-
* RepoMeta is the schema for the meta file of a Git Parcel repository.
6+
* The meta file of a Git Parcel repository.
77
*
8-
* It lists all parcels in the repository.
8+
* This file:
9+
*
10+
* - should be in the root directory of the repository.
11+
* - lists all the parcels in this repository.
912
*/
1013
export type RepoMeta = $schema & {
1114
/**

test/schema/ParcelMeta.test.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
{
2-
"$schema": "../../dist/schema/ParcelMeta.json",
2+
"$schema": "../../dist/schemas/ParcelMeta.json",
33
"format": {
44
"id": "parcel",
55
"version": 1
66
},
77
"dataVersion": 1536,
8-
"size": [4, 4, 4]
8+
"size": [4, 4, 4],
9+
"mods": {
10+
"mod_1": "*",
11+
"mod_2": { "min": "1.0.0", "max": "2.0.0" },
12+
"mod_3": { "min": "1.0.0" },
13+
"mod_4": { "max": "1.0.0" }
14+
},
15+
"includeBlock": true
916
}

0 commit comments

Comments
 (0)