Skip to content

Commit b102a71

Browse files
authored
Created registry and inventory models (#4)
Registry models represent resources of the registry (Modrinth), e.g. packages, versions, etc. Inventory models represent local resources, e.g. the config, manifest, installed packages, etc.
2 parents a0de1e6 + e664864 commit b102a71

17 files changed

Lines changed: 1046 additions & 2 deletions

dub.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"authors": [
3-
"Kai"
3+
"Kai",
4+
"Zefir Kirilov"
45
],
5-
"copyright": "Copyright © 2025, Kai",
6+
"copyright": "Copyright © 2025 Kai, Zefir Kirilov",
67
"description": "Modpm client-side library",
78
"license": "GPL-3.0-only",
89
"name": "libmodpm",

schemas/config.schema.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-06/schema#",
3+
"title": "Modpm Config",
4+
"description": "Represents the package manager configuration for a given scope.",
5+
"type": "object",
6+
"properties": {
7+
"configVersion": {
8+
"const": 0,
9+
"description": "Configuration schema version."
10+
},
11+
"type": {
12+
"enum": ["mod", "plugin", "resourcepack", "shader", "datapack"],
13+
"description": "Type of packages managed in this scope."
14+
},
15+
"environment": {
16+
"enum": ["client", "server"],
17+
"description": "Type of environment of this scope."
18+
},
19+
"loader": {
20+
"enum": [
21+
"babric",
22+
"bta-babric",
23+
"bukkit",
24+
"bungeecord",
25+
"canvas",
26+
"datapack",
27+
"fabric",
28+
"folia",
29+
"forge",
30+
"iris",
31+
"java-agent",
32+
"legacy-fabric",
33+
"liteloader",
34+
"minecraft",
35+
"modloader",
36+
"neoforge",
37+
"nilloader",
38+
"optifine",
39+
"ornite",
40+
"paper",
41+
"purpur",
42+
"quilt",
43+
"rift",
44+
"spigot",
45+
"sponge",
46+
"vanilla",
47+
"velocity",
48+
"waterfall"
49+
],
50+
"description": "Package loader used in this scope."
51+
},
52+
"gameVersion": {
53+
"type": "string",
54+
"description": "Game version supported by the loader in this scope."
55+
}
56+
},
57+
"required": ["configVersion", "type", "environment", "loader", "gameVersion"],
58+
"additionalProperties": false
59+
}

schemas/manifest.schema.json

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-06/schema#",
3+
"title": "Modpm Manifest",
4+
"description": "Represents the manifest of installed packages in a given scope.",
5+
"type": "object",
6+
"properties": {
7+
"manifestVersion": {
8+
"const": 0,
9+
"description": "Manifest schema version."
10+
},
11+
"packages": {
12+
"type": "array",
13+
"description": "Installed packages.",
14+
"items": {
15+
"$ref": "#/definitions/InstalledPackage"
16+
}
17+
}
18+
},
19+
"required": ["manifestVersion", "packages"],
20+
"additionalProperties": false,
21+
"definitions": {
22+
"Dependency": {
23+
"type": "object",
24+
"description": "Represents a dependency of a specific package version. If version is specified, the dependency is on that specific version of the package only.",
25+
"properties": {
26+
"type": {
27+
"enum": ["required", "optional", "embedded", "incompatible"],
28+
"description": "Type of the dependency."
29+
},
30+
"package": {
31+
"type": "string",
32+
"description": "ID of the dependency package."
33+
},
34+
"version": {
35+
"type": "string",
36+
"description": "ID of the dependency version."
37+
}
38+
},
39+
"required": ["type", "package"],
40+
"additionalProperties": false
41+
},
42+
"File": {
43+
"type": "object",
44+
"description": "Represents a downloadable file associated with a specific version of a package.",
45+
"properties": {
46+
"hash": {
47+
"type": "string",
48+
"pattern": "^[\\da-f]{128}$",
49+
"description": "SHA-512 hash of the file."
50+
},
51+
"url": {
52+
"type": "string",
53+
"description": "Direct download URL."
54+
},
55+
"name": {
56+
"type": "string",
57+
"description": "Name of the file."
58+
},
59+
"size": {
60+
"type": "number",
61+
"description": "Size of the file in bytes."
62+
}
63+
},
64+
"required": ["hash", "url", "name", "size"],
65+
"additionalProperties": false
66+
},
67+
"Version": {
68+
"type": "object",
69+
"description": "Represents a specific version of a package that can be installed.",
70+
"properties": {
71+
"id": {
72+
"type": "string",
73+
"description": "Unique ID of the version."
74+
},
75+
"number": {
76+
"type": "string",
77+
"description": "Version number.",
78+
"examples": ["1.0.0"]
79+
},
80+
"dependencies": {
81+
"type": "array",
82+
"description": "Dependencies required by this version.",
83+
"items": {
84+
"$ref": "#/definitions/Dependency"
85+
}
86+
},
87+
"file": {
88+
"$ref": "#/definitions/File"
89+
}
90+
},
91+
"required": ["id", "number", "dependencies", "file"],
92+
"additionalProperties": false
93+
},
94+
"InstalledPackage": {
95+
"type": "object",
96+
"description": "Represents an installed package.",
97+
"properties": {
98+
"id": {
99+
"type": "string",
100+
"description": "Unique ID of the package."
101+
},
102+
"slug": {
103+
"type": "string",
104+
"description": "Slug of the package."
105+
},
106+
"name": {
107+
"type": "string",
108+
"description": "Name of the package."
109+
},
110+
"path": {
111+
"type": "string",
112+
"description": "Path where the package is installed."
113+
},
114+
"reason": {
115+
"enum": ["user", "dependency"],
116+
"description": "Reason why this package was installed."
117+
},
118+
"version": {
119+
"$ref": "#/definitions/Version"
120+
}
121+
},
122+
"required": ["id", "slug", "name", "path", "reason", "version"],
123+
"additionalProperties": false
124+
}
125+
}
126+
}

0 commit comments

Comments
 (0)