@memizy/oqse 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +58 -0
- package/SPECIFICATION.md +2444 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +845 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/manifest.d.ts +429 -0
- package/dist/src/manifestValidation.d.ts +167 -0
- package/dist/src/manifestValidation.test.d.ts +1 -0
- package/dist/src/oqse.d.ts +1121 -0
- package/dist/src/oqseValidation.d.ts +6120 -0
- package/dist/src/oqseValidation.test.d.ts +1 -0
- package/dist/src/progress.d.ts +42 -0
- package/dist/src/progressValidation.d.ts +9 -0
- package/dist/src/progressValidation.test.d.ts +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/package.json +40 -0
- package/schemas/README.md +1 -0
- package/schemas/oqse-manifest-v0.1.json +256 -0
- package/schemas/oqse-v0.1.json +7573 -0
- package/schemas/oqsep-v0.1.json +172 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { FeatureProfile } from './oqse';
|
|
2
|
+
export type { FeatureProfile } from './oqse';
|
|
3
|
+
/**
|
|
4
|
+
* Official actions from the OQSE Action Registry (Section 2.1.3).
|
|
5
|
+
*
|
|
6
|
+
* - `render` - Player/learning mode: displays items interactively.
|
|
7
|
+
* - `edit` - Authoring mode: creates/modifies item content.
|
|
8
|
+
* - `validate` - Verification mode: checks structural/logical correctness.
|
|
9
|
+
* - `import` - Data ingestion: parses OQSE data into an internal system.
|
|
10
|
+
* - `export` - Data generation: serializes internal data into OQSE format.
|
|
11
|
+
*/
|
|
12
|
+
export type OfficialAction = 'render' | 'edit' | 'validate' | 'import' | 'export';
|
|
13
|
+
/**
|
|
14
|
+
* Custom action using the required `x-` prefix (e.g., `"x-preview"`, `"x-sync"`).
|
|
15
|
+
* Host environments that do not recognize a custom action MUST ignore it.
|
|
16
|
+
*/
|
|
17
|
+
export type CustomAction = `x-${string}`;
|
|
18
|
+
/**
|
|
19
|
+
* Any action value: official from the Action Registry or a custom `x-` prefixed action.
|
|
20
|
+
*/
|
|
21
|
+
export type OQSEAction = OfficialAction | CustomAction;
|
|
22
|
+
/**
|
|
23
|
+
* Primary experience type of an application.
|
|
24
|
+
*
|
|
25
|
+
* - `"game"` - Entertainment-first; gameplay mechanics take priority.
|
|
26
|
+
* - `"fun"` - Balanced blend of interactivity and learning.
|
|
27
|
+
* - `"drill"` - Maximally focused, distraction-free repetition.
|
|
28
|
+
*
|
|
29
|
+
* If absent, no assumption is made.
|
|
30
|
+
*/
|
|
31
|
+
export type OQSEStudyMode = 'game' | 'fun' | 'drill';
|
|
32
|
+
/**
|
|
33
|
+
* Ratio of quiz items relative to non-question game elements.
|
|
34
|
+
*
|
|
35
|
+
* - `"low"` - Questions appear rarely; gameplay dominates.
|
|
36
|
+
* - `"medium"` - Questions and gameplay are roughly balanced.
|
|
37
|
+
* - `"high"` - Nearly every interaction is a question.
|
|
38
|
+
*
|
|
39
|
+
* If `studyMode` is `"drill"`, hosts SHOULD treat this as `"high"` regardless.
|
|
40
|
+
* If absent, no assumption is made.
|
|
41
|
+
*/
|
|
42
|
+
export type OQSEQuestionDensity = 'low' | 'medium' | 'high';
|
|
43
|
+
/**
|
|
44
|
+
* All officially recognized feature keys from the OQSE Feature Registry (Section 2.2).
|
|
45
|
+
*
|
|
46
|
+
* Features are declared in `capabilities.features` (Manifest) and in
|
|
47
|
+
* `meta.requirements.features` (Study Set) to signal support/requirement.
|
|
48
|
+
*
|
|
49
|
+
* Dependency notes:
|
|
50
|
+
* - `syntax-highlighting`, `mermaid`, `smiles`, `abc-notation`, `html-safe`
|
|
51
|
+
* are only meaningful when `markdown` is also declared.
|
|
52
|
+
* - `latexPackages` (in FeatureProfile) is only meaningful when `math` is declared.
|
|
53
|
+
*/
|
|
54
|
+
export type OfficialFeatureKey = 'markdown' | 'html-safe' | 'math' | 'ruby-annotations' | 'rtl' | 'syntax-highlighting' | 'mermaid' | 'smiles' | 'abc-notation' | 'text-to-speech' | 'voice-input' | 'handwriting-recognition';
|
|
55
|
+
/**
|
|
56
|
+
* A custom feature using the required `x-` prefix (e.g., `"x-memizy-3d-voxel"`).
|
|
57
|
+
* MUST NOT collide with current or future official registry entries.
|
|
58
|
+
* SHOULD be documented in the manifest's own `appSpecific` field.
|
|
59
|
+
*/
|
|
60
|
+
export type CustomFeatureKey = `x-${string}`;
|
|
61
|
+
/**
|
|
62
|
+
* Any feature flag: official from the registry or a custom `x-` prefixed value.
|
|
63
|
+
*/
|
|
64
|
+
export type FeatureFlag = OfficialFeatureKey | CustomFeatureKey;
|
|
65
|
+
/**
|
|
66
|
+
* Official item-level property keys from the OQSE itemProperties registry (Section 2.2).
|
|
67
|
+
*
|
|
68
|
+
* Declared in `capabilities.itemProperties` (app support) and
|
|
69
|
+
* `meta.requirements.itemProperties` (set requirement).
|
|
70
|
+
*/
|
|
71
|
+
export type OfficialItemProperty = 'hints' | 'explanation' | 'incorrectFeedback' | 'sources' | 'relatedItems' | 'dependencyItems' | 'timeLimit' | 'lang' | 'topic' | 'pedagogy';
|
|
72
|
+
/**
|
|
73
|
+
* A custom item property using the `x-` prefix.
|
|
74
|
+
*/
|
|
75
|
+
export type CustomItemProperty = `x-${string}`;
|
|
76
|
+
/**
|
|
77
|
+
* Any item property key: official or custom.
|
|
78
|
+
*/
|
|
79
|
+
export type ItemPropertyKey = OfficialItemProperty | CustomItemProperty;
|
|
80
|
+
/**
|
|
81
|
+
* Official set-level (meta) property keys from the OQSE metaProperties registry (Section 2.2).
|
|
82
|
+
*
|
|
83
|
+
* Declared in `capabilities.metaProperties` (app support) and
|
|
84
|
+
* `meta.requirements.metaProperties` (set requirement).
|
|
85
|
+
*/
|
|
86
|
+
export type OfficialMetaProperty = 'description' | 'thumbnail' | 'subject' | 'language' | 'author' | 'contributors' | 'license' | 'ageRestriction' | 'tags' | 'tagDefinitions' | 'sourceMaterials' | 'estimatedTime' | 'prerequisites' | 'translations' | 'relatedSets';
|
|
87
|
+
/**
|
|
88
|
+
* A custom meta property using the `x-` prefix.
|
|
89
|
+
*/
|
|
90
|
+
export type CustomMetaProperty = `x-${string}`;
|
|
91
|
+
/**
|
|
92
|
+
* Any meta property key: official or custom.
|
|
93
|
+
*/
|
|
94
|
+
export type MetaPropertyKey = OfficialMetaProperty | CustomMetaProperty;
|
|
95
|
+
/**
|
|
96
|
+
* A typed "explicit list" array - lists concrete accepted values.
|
|
97
|
+
* Used for MIME type arrays in ManifestAssets and for item `types`.
|
|
98
|
+
*/
|
|
99
|
+
export type ExplicitArray<T extends string> = T[];
|
|
100
|
+
/**
|
|
101
|
+
* A "wildcard" array - the single-element tuple `["*"]` meaning "all accepted."
|
|
102
|
+
*/
|
|
103
|
+
export type WildcardArray = ['*'];
|
|
104
|
+
/**
|
|
105
|
+
* The full wildcard-or-explicit-or-null semantic for `types` and `assets` values:
|
|
106
|
+
*
|
|
107
|
+
* | Value | Meaning |
|
|
108
|
+
* |------------------|--------------------------------------|
|
|
109
|
+
* | `["*"]` | All accepted (any type/MIME). |
|
|
110
|
+
* | `["a/b", ...]` | Only the listed values are supported.|
|
|
111
|
+
* | `null` | Not supported; hosts MUST NOT pass. |
|
|
112
|
+
* | `[]` / absent | Equivalent to `null` (not supported).|
|
|
113
|
+
*
|
|
114
|
+
* Parsers MUST treat `[]` identically to `null`.
|
|
115
|
+
*/
|
|
116
|
+
export type WildcardOrExplicit<T extends string> = WildcardArray | ExplicitArray<T> | null;
|
|
117
|
+
/**
|
|
118
|
+
* Common image MIME types recognized by OQSE.
|
|
119
|
+
* Applications MAY support additional types; these are well-known values.
|
|
120
|
+
*/
|
|
121
|
+
export type ImageMimeType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/svg+xml' | 'image/avif' | 'image/bmp' | `image/${string}`;
|
|
122
|
+
/**
|
|
123
|
+
* Common audio MIME types recognized by OQSE.
|
|
124
|
+
*/
|
|
125
|
+
export type AudioMimeType = 'audio/mpeg' | 'audio/ogg' | 'audio/wav' | 'audio/aac' | 'audio/flac' | 'audio/mp4' | `audio/${string}`;
|
|
126
|
+
/**
|
|
127
|
+
* Common video MIME types recognized by OQSE.
|
|
128
|
+
*/
|
|
129
|
+
export type VideoMimeType = 'video/mp4' | 'video/webm' | 'video/ogg' | 'video/quicktime' | `video/${string}`;
|
|
130
|
+
/**
|
|
131
|
+
* 3D model MIME types recognized by OQSE.
|
|
132
|
+
* glTF format (`.glb` / `.gltf`) is RECOMMENDED as the universal baseline.
|
|
133
|
+
*/
|
|
134
|
+
export type ModelMimeType = 'model/gltf-binary' | 'model/gltf+json' | 'model/obj' | 'model/fbx' | `model/${string}`;
|
|
135
|
+
/**
|
|
136
|
+
* Asset support map for the four supported asset categories.
|
|
137
|
+
*
|
|
138
|
+
* Per each category:
|
|
139
|
+
* - `["*"]` - Accepts any MIME type in this category.
|
|
140
|
+
* - `["image/png", ...]` - Only the listed MIME types.
|
|
141
|
+
* - `null` or absent - Category not supported.
|
|
142
|
+
* - `[]` - Equivalent to `null` (not supported); SHOULD NOT be emitted.
|
|
143
|
+
*
|
|
144
|
+
* If the entire `assets` object is omitted, the application declares no media support.
|
|
145
|
+
*/
|
|
146
|
+
export interface ManifestAssets {
|
|
147
|
+
/** Image asset support */
|
|
148
|
+
image?: WildcardOrExplicit<ImageMimeType>;
|
|
149
|
+
/** Audio asset support */
|
|
150
|
+
audio?: WildcardOrExplicit<AudioMimeType>;
|
|
151
|
+
/** Video asset support */
|
|
152
|
+
video?: WildcardOrExplicit<VideoMimeType>;
|
|
153
|
+
/** 3D model asset support. glTF (`model/gltf-binary`) is RECOMMENDED. */
|
|
154
|
+
model?: WildcardOrExplicit<ModelMimeType>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The `capabilities` object in the Application Manifest.
|
|
158
|
+
*
|
|
159
|
+
* Extends FeatureProfile by adding `actions`, `types`, and `assets`.
|
|
160
|
+
* Declares everything the application can do, what types it handles,
|
|
161
|
+
* what media formats it accepts, and which OQSE features it supports.
|
|
162
|
+
*
|
|
163
|
+
* @see /SPECIFICATION.md#212-capabilities-object-extends-featureprofile
|
|
164
|
+
*/
|
|
165
|
+
export interface ManifestCapabilities extends FeatureProfile {
|
|
166
|
+
/**
|
|
167
|
+
* Actions the application can perform (REQUIRED, >=1 value).
|
|
168
|
+
* MUST contain at least one value from the Action Registry.
|
|
169
|
+
* Custom actions MUST use the `x-` prefix.
|
|
170
|
+
*
|
|
171
|
+
* @example `["render", "edit"]`
|
|
172
|
+
*/
|
|
173
|
+
actions: OQSEAction[];
|
|
174
|
+
/**
|
|
175
|
+
* OQSE item types the application supports.
|
|
176
|
+
*
|
|
177
|
+
* - Required (at least one type or `["*"]`) when `actions` includes `render` or `edit`.
|
|
178
|
+
* - MAY be omitted for `validate`, `import`, or `export`-only applications.
|
|
179
|
+
* - `["*"]` - supports all item types.
|
|
180
|
+
* - `[]` / `null` - equivalent; treated as "no types declared".
|
|
181
|
+
* - Custom types MUST use the `x-` prefix.
|
|
182
|
+
*
|
|
183
|
+
* @example `["flashcard", "mcq-single", "*"]`
|
|
184
|
+
*/
|
|
185
|
+
types?: WildcardOrExplicit<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Media asset support map.
|
|
188
|
+
* If omitted entirely, the application declares no media support.
|
|
189
|
+
*
|
|
190
|
+
* @see ManifestAssets
|
|
191
|
+
*/
|
|
192
|
+
assets?: ManifestAssets;
|
|
193
|
+
/**
|
|
194
|
+
* Array of supported feature flags.
|
|
195
|
+
* Values MUST come from the Official Feature Registry or use the `x-` prefix.
|
|
196
|
+
*
|
|
197
|
+
* @see OfficialFeatureKey
|
|
198
|
+
* @see FeatureFlag
|
|
199
|
+
*/
|
|
200
|
+
features?: FeatureFlag[];
|
|
201
|
+
/**
|
|
202
|
+
* Array of supported LaTeX packages.
|
|
203
|
+
* Only meaningful when `features` includes `"math"`.
|
|
204
|
+
*
|
|
205
|
+
* @example `["mhchem", "amsmath"]`
|
|
206
|
+
*/
|
|
207
|
+
latexPackages?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Item-level properties the application supports.
|
|
210
|
+
*
|
|
211
|
+
* @see OfficialItemProperty
|
|
212
|
+
* @see ItemPropertyKey
|
|
213
|
+
*/
|
|
214
|
+
itemProperties?: ItemPropertyKey[];
|
|
215
|
+
/**
|
|
216
|
+
* Set-level metadata properties the application supports.
|
|
217
|
+
*
|
|
218
|
+
* @see OfficialMetaProperty
|
|
219
|
+
* @see MetaPropertyKey
|
|
220
|
+
*/
|
|
221
|
+
metaProperties?: MetaPropertyKey[];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* OQSE Application Manifest (Section 2.1).
|
|
225
|
+
*
|
|
226
|
+
* Every application, micro-frontend, or plugin that interacts with OQSE data
|
|
227
|
+
* MUST declare its capabilities using this structure.
|
|
228
|
+
*
|
|
229
|
+
* **Delivery options:**
|
|
230
|
+
* - HTML application: `<script type="application/oqse-manifest+json">` tag.
|
|
231
|
+
* - Non-HTML application: static `oqse-manifest.json` at the deployment root.
|
|
232
|
+
* - HTTP discovery: `Link: <manifest.json>; rel="oqse-manifest"` header.
|
|
233
|
+
*
|
|
234
|
+
* @see /SPECIFICATION.md#21-the-application-manifest
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```json
|
|
238
|
+
* {
|
|
239
|
+
* "$schema": "https://memizy.com/schemas/oqse-manifest/v0.1.json",
|
|
240
|
+
* "version": "0.1",
|
|
241
|
+
* "pluginVersion": "2.1.0",
|
|
242
|
+
* "id": "https://memizy.com/universal-player",
|
|
243
|
+
* "appName": "Memizy Universal Player",
|
|
244
|
+
* "capabilities": {
|
|
245
|
+
* "actions": ["render"],
|
|
246
|
+
* "types": ["flashcard", "mcq-single"],
|
|
247
|
+
* "features": ["math", "markdown"]
|
|
248
|
+
* }
|
|
249
|
+
* }
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export interface OQSEManifest {
|
|
253
|
+
/**
|
|
254
|
+
* URL reference to the JSON Schema for automatic validation.
|
|
255
|
+
* Recommended but not required.
|
|
256
|
+
* @example `"https://memizy.com/schemas/oqse-manifest/v0.1.json"`
|
|
257
|
+
*/
|
|
258
|
+
$schema?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Version of the Application Manifest format (REQUIRED).
|
|
261
|
+
* MUST follow `"MAJOR.MINOR"` format. The current version is `"0.1"`.
|
|
262
|
+
* Malformed values MUST cause the host to reject this manifest.
|
|
263
|
+
*
|
|
264
|
+
* @example `"0.1"`
|
|
265
|
+
*/
|
|
266
|
+
version: string;
|
|
267
|
+
/**
|
|
268
|
+
* Version of the application/plugin itself using SemVer.
|
|
269
|
+
* Independent of the manifest format version.
|
|
270
|
+
*
|
|
271
|
+
* @example `"2.1.0"`
|
|
272
|
+
*/
|
|
273
|
+
pluginVersion?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Minimum OQSE spec version this application requires.
|
|
276
|
+
* MUST follow `"MAJOR.MINOR"` format. Version comparison is numeric field-by-field.
|
|
277
|
+
* If malformed, treat as absent and SHOULD warn.
|
|
278
|
+
* MUST be \u2264 `maxOqseVersion` when both are declared.
|
|
279
|
+
*
|
|
280
|
+
* @example `"0.1"`
|
|
281
|
+
*/
|
|
282
|
+
minOqseVersion?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Maximum OQSE spec version this application is compatible with.
|
|
285
|
+
* MUST follow `"MAJOR.MINOR"` format. If absent, no upper bound is assumed.
|
|
286
|
+
* If malformed, treat as absent and SHOULD warn.
|
|
287
|
+
*
|
|
288
|
+
* @example `"1.99"`
|
|
289
|
+
*/
|
|
290
|
+
maxOqseVersion?: string;
|
|
291
|
+
/**
|
|
292
|
+
* Unique identifier for this application (REQUIRED).
|
|
293
|
+
* MUST be either:
|
|
294
|
+
* - A controlled URL (preferred): `"https://memizy.com/player"`
|
|
295
|
+
* - A URN-format UUID: `"urn:uuid:019aa600-abc1-7234-b678-c0ffee000001"`
|
|
296
|
+
*/
|
|
297
|
+
id: string;
|
|
298
|
+
/**
|
|
299
|
+
* Human-readable name of the application (REQUIRED).
|
|
300
|
+
* MUST be non-empty. Plain Text.
|
|
301
|
+
*
|
|
302
|
+
* @example `"Memizy Universal Player"`
|
|
303
|
+
*/
|
|
304
|
+
appName: string;
|
|
305
|
+
/**
|
|
306
|
+
* Human-readable description of what the application does.
|
|
307
|
+
* Displayed in host environments and plugin catalogs.
|
|
308
|
+
* **Plain Text** - no Markdown or HTML.
|
|
309
|
+
*/
|
|
310
|
+
description?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Name of the author or organization.
|
|
313
|
+
* **Plain Text.**
|
|
314
|
+
*
|
|
315
|
+
* @example `"Memizy Team"`
|
|
316
|
+
*/
|
|
317
|
+
author?: string;
|
|
318
|
+
/**
|
|
319
|
+
* URL of the author or organization.
|
|
320
|
+
* MUST be an absolute URL.
|
|
321
|
+
*
|
|
322
|
+
* @example `"https://memizy.com"`
|
|
323
|
+
*/
|
|
324
|
+
authorUrl?: string;
|
|
325
|
+
/**
|
|
326
|
+
* BCP 47 locale codes for the application's supported UI languages.
|
|
327
|
+
* If absent or `[]`, the host SHOULD assume the application supports English.
|
|
328
|
+
*
|
|
329
|
+
* @example `["en", "cs"]`
|
|
330
|
+
*/
|
|
331
|
+
locales?: string[];
|
|
332
|
+
/**
|
|
333
|
+
* Plain-text keywords for filtering and discovery in host environments/catalogs.
|
|
334
|
+
* Uses the same convention as `meta.tags` in study sets.
|
|
335
|
+
*
|
|
336
|
+
* @example `["flashcards", "spaced-repetition", "chess"]`
|
|
337
|
+
*/
|
|
338
|
+
tags?: string[];
|
|
339
|
+
/**
|
|
340
|
+
* A single emoji used as the application's visual identity in catalogs.
|
|
341
|
+
* SHOULD be a single visually-rendered emoji glyph.
|
|
342
|
+
* Multi-codepoint emoji (flags, family sequences) are acceptable.
|
|
343
|
+
* If a future `iconUrl` field is also declared, hosts SHOULD prefer that.
|
|
344
|
+
*
|
|
345
|
+
* @example `"\uD83E\uDDE0"` (brain), `"\uD83D\uDE80"` (rocket), `"\uD83C\uDFAE"` (game controller)
|
|
346
|
+
*/
|
|
347
|
+
emoji?: string;
|
|
348
|
+
/**
|
|
349
|
+
* Primary experience type of the application.
|
|
350
|
+
* MUST be one of `"game"`, `"fun"`, or `"drill"`.
|
|
351
|
+
* If absent, no assumption is made.
|
|
352
|
+
*/
|
|
353
|
+
studyMode?: OQSEStudyMode;
|
|
354
|
+
/**
|
|
355
|
+
* Ratio of quiz questions relative to other game elements.
|
|
356
|
+
* MUST be one of `"low"`, `"medium"`, or `"high"`.
|
|
357
|
+
* If `studyMode` is `"drill"`, hosts SHOULD treat this as `"high"`.
|
|
358
|
+
* If absent, no assumption is made.
|
|
359
|
+
*/
|
|
360
|
+
questionDensity?: OQSEQuestionDensity;
|
|
361
|
+
/**
|
|
362
|
+
* Object for application-specific metadata not covered by standard fields.
|
|
363
|
+
* Applications declaring custom `x-` features SHOULD document their semantics here.
|
|
364
|
+
* Other applications MUST ignore this object.
|
|
365
|
+
*/
|
|
366
|
+
appSpecific?: Record<string, unknown>;
|
|
367
|
+
/**
|
|
368
|
+
* Capabilities of this application (REQUIRED).
|
|
369
|
+
* Extends FeatureProfile with `actions`, `types`, and `assets`.
|
|
370
|
+
*
|
|
371
|
+
* @see ManifestCapabilities
|
|
372
|
+
*/
|
|
373
|
+
capabilities: ManifestCapabilities;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Validates that a version string follows the `"MAJOR.MINOR"` format
|
|
377
|
+
* required by both `manifest.version` and `minOqseVersion`/`maxOqseVersion`.
|
|
378
|
+
*
|
|
379
|
+
* @param version - The version string to validate.
|
|
380
|
+
* @returns `true` if valid (e.g., `"0.1"`, `"2.10"`), `false` otherwise.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* isValidManifestVersion("0.1") // true
|
|
384
|
+
* isValidManifestVersion("2.10") // true
|
|
385
|
+
* isValidManifestVersion("1.0.0") // false (SemVer, not allowed here)
|
|
386
|
+
* isValidManifestVersion("v0.1") // false
|
|
387
|
+
*/
|
|
388
|
+
export declare function isValidManifestVersion(version: string): boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Validates that a SemVer string follows the `"MAJOR.MINOR.PATCH"` format
|
|
391
|
+
* required by `manifest.pluginVersion`.
|
|
392
|
+
*
|
|
393
|
+
* @param version - The SemVer string to validate.
|
|
394
|
+
* @returns `true` if valid (e.g., `"2.1.0"`, `"1.0.0-rc.1"`), `false` otherwise.
|
|
395
|
+
*/
|
|
396
|
+
export declare function isValidSemVer(version: string): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Numerically compares two `"MAJOR.MINOR"` version strings.
|
|
399
|
+
*
|
|
400
|
+
* @returns
|
|
401
|
+
* - Negative number if `a < b`
|
|
402
|
+
* - `0` if `a === b`
|
|
403
|
+
* - Positive number if `a > b`
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* compareManifestVersions("0.1", "1.10") // negative (0.1 < 1.10)
|
|
407
|
+
* compareManifestVersions("2.0", "1.99") // positive (2.0 > 1.99)
|
|
408
|
+
*/
|
|
409
|
+
export declare function compareManifestVersions(a: string, b: string): number;
|
|
410
|
+
/**
|
|
411
|
+
* Type guard: checks whether a value is a valid `OQSEManifest` at runtime.
|
|
412
|
+
*
|
|
413
|
+
* Performs only structural validation (presence of required fields and correct types).
|
|
414
|
+
* For full spec-compliant validation including enum values and version format,
|
|
415
|
+
* use the Zod schema in `src/app/schemas/`.
|
|
416
|
+
*
|
|
417
|
+
* @param value - Unknown parsed JSON value.
|
|
418
|
+
* @returns `true` if the value has the required shape of an `OQSEManifest`.
|
|
419
|
+
*/
|
|
420
|
+
export declare function isOQSEManifest(value: unknown): value is OQSEManifest;
|
|
421
|
+
/**
|
|
422
|
+
* Checks whether an OQSE file's version is within the application's
|
|
423
|
+
* declared min/max OQSE version range.
|
|
424
|
+
*
|
|
425
|
+
* @param fileVersion - The `version` field of the OQSE study set file (e.g., `"0.1"`).
|
|
426
|
+
* @param manifest - The Application Manifest to check against.
|
|
427
|
+
* @returns `true` if the file is compatible, `false` if the host MUST NOT load it.
|
|
428
|
+
*/
|
|
429
|
+
export declare function isVersionCompatible(fileVersion: string, manifest: OQSEManifest): boolean;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OQSEManifest } from './manifest';
|
|
3
|
+
/**
|
|
4
|
+
* A valid OQSE action: one of the five official actions, or a vendor-specific
|
|
5
|
+
* action prefixed with `x-` (e.g. `x-acme-grade`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const OQSEActionSchema: z.ZodString;
|
|
8
|
+
/** Recommended study modality for a set of items. */
|
|
9
|
+
export declare const OQSEStudyModeSchema: z.ZodEnum<{
|
|
10
|
+
game: "game";
|
|
11
|
+
fun: "fun";
|
|
12
|
+
drill: "drill";
|
|
13
|
+
}>;
|
|
14
|
+
/** Recommended question density per session. */
|
|
15
|
+
export declare const OQSEQuestionDensitySchema: z.ZodEnum<{
|
|
16
|
+
low: "low";
|
|
17
|
+
medium: "medium";
|
|
18
|
+
high: "high";
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* A feature flag: one of the official keys or a vendor-specific key prefixed
|
|
22
|
+
* with `x-` (e.g. `x-acme-chemistry`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const FeatureFlagSchema: z.ZodString;
|
|
25
|
+
/** Official item-level extension property keys (or vendor-prefixed). */
|
|
26
|
+
export declare const ItemPropertyKeySchema: z.ZodString;
|
|
27
|
+
/** Official meta-level extension property keys (or vendor-prefixed). */
|
|
28
|
+
export declare const MetaPropertyKeySchema: z.ZodString;
|
|
29
|
+
/** Any valid image MIME type. */
|
|
30
|
+
export declare const ImageMimeTypeSchema: z.ZodString;
|
|
31
|
+
/** Any valid audio MIME type. */
|
|
32
|
+
export declare const AudioMimeTypeSchema: z.ZodString;
|
|
33
|
+
/** Any valid video MIME type. */
|
|
34
|
+
export declare const VideoMimeTypeSchema: z.ZodString;
|
|
35
|
+
/** Any valid 3D model MIME type. */
|
|
36
|
+
export declare const ModelMimeTypeSchema: z.ZodString;
|
|
37
|
+
/**
|
|
38
|
+
* Declares which media asset MIME types an application can handle.
|
|
39
|
+
* `null` means the category is not supported; `['*']` means all MIME types
|
|
40
|
+
* within that category are accepted; an array lists explicit MIME types.
|
|
41
|
+
*/
|
|
42
|
+
export declare const ManifestAssetsSchema: z.ZodObject<{
|
|
43
|
+
image: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
44
|
+
audio: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
45
|
+
video: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
46
|
+
model: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
/**
|
|
49
|
+
* Full capability declaration of an OQSE-compatible application.
|
|
50
|
+
* Extends FeatureProfile with application-level capability fields.
|
|
51
|
+
*/
|
|
52
|
+
export declare const ManifestCapabilitiesSchema: z.ZodObject<{
|
|
53
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
latexPackages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
itemProperties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
metaProperties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
actions: z.ZodArray<z.ZodString>;
|
|
58
|
+
types: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
59
|
+
assets: z.ZodOptional<z.ZodObject<{
|
|
60
|
+
image: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
61
|
+
audio: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
62
|
+
video: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
63
|
+
model: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Full OQSE Application Manifest schema (T�2.1.1).
|
|
68
|
+
*
|
|
69
|
+
* Validated constraints beyond syntax:
|
|
70
|
+
* - `minOqseVersion` �� `maxOqseVersion` when both are present
|
|
71
|
+
* - `version` adheres to MAJOR.MINOR format
|
|
72
|
+
* - `capabilities.actions` is non-empty (enforced by inner schema)
|
|
73
|
+
*/
|
|
74
|
+
export declare const OQSEManifestSchema: z.ZodObject<{
|
|
75
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
appName: z.ZodString;
|
|
78
|
+
version: z.ZodString;
|
|
79
|
+
pluginVersion: z.ZodOptional<z.ZodString>;
|
|
80
|
+
minOqseVersion: z.ZodOptional<z.ZodString>;
|
|
81
|
+
maxOqseVersion: z.ZodOptional<z.ZodString>;
|
|
82
|
+
capabilities: z.ZodObject<{
|
|
83
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
latexPackages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
+
itemProperties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
metaProperties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
actions: z.ZodArray<z.ZodString>;
|
|
88
|
+
types: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
89
|
+
assets: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
image: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
91
|
+
audio: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
92
|
+
video: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
93
|
+
model: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"*">], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
author: z.ZodOptional<z.ZodString>;
|
|
97
|
+
authorUrl: z.ZodOptional<z.ZodString>;
|
|
98
|
+
locales: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
description: z.ZodOptional<z.ZodString>;
|
|
100
|
+
emoji: z.ZodOptional<z.ZodString>;
|
|
101
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
102
|
+
studyMode: z.ZodOptional<z.ZodEnum<{
|
|
103
|
+
game: "game";
|
|
104
|
+
fun: "fun";
|
|
105
|
+
drill: "drill";
|
|
106
|
+
}>>;
|
|
107
|
+
questionDensity: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
low: "low";
|
|
109
|
+
medium: "medium";
|
|
110
|
+
high: "high";
|
|
111
|
+
}>>;
|
|
112
|
+
appSpecific: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
/**
|
|
115
|
+
* Validates an unknown value against `OQSEManifestSchema`.
|
|
116
|
+
*
|
|
117
|
+
* @param data - The value to validate (typically parsed JSON).
|
|
118
|
+
* @returns The validated `OQSEManifest` object.
|
|
119
|
+
* @throws {z.ZodError} when validation fails.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const manifest = validateManifest(JSON.parse(rawJson));
|
|
124
|
+
* manifest.capabilities.actions; // string[]
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function validateManifest(data: unknown): OQSEManifest;
|
|
128
|
+
/**
|
|
129
|
+
* Safely validates an unknown value without throwing.
|
|
130
|
+
*
|
|
131
|
+
* @param data - The value to validate.
|
|
132
|
+
* @returns A Zod `SafeParseReturnType` with `success` flag and either `data` or `error`.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const result = safeValidateManifest(raw);
|
|
137
|
+
* if (result.success) {
|
|
138
|
+
* console.log(result.data.id);
|
|
139
|
+
* } else {
|
|
140
|
+
* console.error(formatManifestErrors(result.error));
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function safeValidateManifest(data: unknown): ReturnType<typeof OQSEManifestSchema.safeParse>;
|
|
145
|
+
/**
|
|
146
|
+
* Formats a `ZodError` from manifest validation into a human-readable string.
|
|
147
|
+
*
|
|
148
|
+
* @param error - A `ZodError` returned by `safeValidateManifest`.
|
|
149
|
+
* @returns A newline-separated string listing each validation issue with its path.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* console.error(formatManifestErrors(result.error));
|
|
154
|
+
* // ��� "id: ID mus+� b+�t ve tvaru reverse-domain..."
|
|
155
|
+
* // ��� "capabilities.actions: Aplikace mus+� podporovat alespo+� jednu akci"
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function formatManifestErrors(error: z.ZodError): string;
|
|
159
|
+
/**
|
|
160
|
+
* Checks whether a plain object looks like an OQSE Manifest (duck-typing).
|
|
161
|
+
*
|
|
162
|
+
* This is a fast pre-check ��� use `validateManifest` for full validation.
|
|
163
|
+
*
|
|
164
|
+
* @param data - Any value.
|
|
165
|
+
* @returns `true` if `data` has the minimum required shape.
|
|
166
|
+
*/
|
|
167
|
+
export declare function isValidOQSEManifest(data: unknown): data is OQSEManifest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|