@vvedantb/server 0.5.0 → 0.6.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/CHANGELOG.md +18 -0
- package/README.md +7 -4
- package/dist/artifacts/debounce.d.ts +16 -0
- package/dist/artifacts/debounce.js +49 -0
- package/dist/artifacts/document.d.ts +26 -0
- package/dist/artifacts/document.js +61 -0
- package/dist/artifacts/index.d.ts +8 -0
- package/dist/artifacts/index.js +8 -0
- package/dist/artifacts/limits.d.ts +21 -0
- package/dist/artifacts/limits.js +23 -0
- package/dist/artifacts/protocol.d.ts +45 -0
- package/dist/artifacts/protocol.js +243 -0
- package/dist/artifacts/schemas.d.ts +80 -0
- package/dist/artifacts/schemas.js +103 -0
- package/dist/artifacts/stateOps.d.ts +39 -0
- package/dist/artifacts/stateOps.js +92 -0
- package/dist/artifacts/storageShim.d.ts +9 -0
- package/dist/artifacts/storageShim.js +32 -0
- package/dist/artifacts/templates.d.ts +33 -0
- package/dist/artifacts/templates.js +496 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/docs/artifacts.md +116 -0
- package/package.json +3 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { ArtifactTemplateName, Flashcard, QuizQuestion } from "./templates.js";
|
|
3
|
+
/** What the artifact is, for filters and icons. */
|
|
4
|
+
export declare const ARTIFACT_TYPES: readonly ["document", "report", "slides", "infographic", "mindmap", "quiz", "flashcards", "diagram", "code"];
|
|
5
|
+
export type ArtifactType = (typeof ARTIFACT_TYPES)[number];
|
|
6
|
+
/** How the body renders. `json` is only for typed bodies (`ARTIFACT_JSON_TYPES`). */
|
|
7
|
+
export declare const ARTIFACT_FORMATS: readonly ["html", "markdown", "svg", "code", "json"];
|
|
8
|
+
export type ArtifactFormat = (typeof ARTIFACT_FORMATS)[number];
|
|
9
|
+
/** Types with a typed JSON body, and the body schema versions each accepts. */
|
|
10
|
+
export declare const ARTIFACT_JSON_TYPES: {
|
|
11
|
+
readonly quiz: readonly [1];
|
|
12
|
+
readonly flashcards: readonly [1];
|
|
13
|
+
};
|
|
14
|
+
export declare const ARTIFACT_TITLE_MAX_CHARS = 200;
|
|
15
|
+
export declare const ARTIFACT_DESCRIPTION_MAX_CHARS = 280;
|
|
16
|
+
/** Which state keys an artifact uses, and the built-in template that renders it. */
|
|
17
|
+
export type ArtifactStateSpec = {
|
|
18
|
+
stateVersion: number;
|
|
19
|
+
keys: string[];
|
|
20
|
+
template?: ArtifactTemplateName;
|
|
21
|
+
};
|
|
22
|
+
export type QuizBodyV1 = {
|
|
23
|
+
title: string;
|
|
24
|
+
questions: QuizQuestion[];
|
|
25
|
+
};
|
|
26
|
+
export type FlashcardsBodyV1 = {
|
|
27
|
+
title: string;
|
|
28
|
+
cards: Flashcard[];
|
|
29
|
+
};
|
|
30
|
+
/** Who wrote the artifact: a free client name, and its id in that client when it was imported. */
|
|
31
|
+
export type ArtifactOrigin = {
|
|
32
|
+
client: string;
|
|
33
|
+
externalId?: string;
|
|
34
|
+
};
|
|
35
|
+
/** A list row: metadata only, never the body. Ids are strings so any store and any client can use it. */
|
|
36
|
+
export type ArtifactListRow = {
|
|
37
|
+
id: string;
|
|
38
|
+
title: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
type: ArtifactType;
|
|
41
|
+
format: ArtifactFormat;
|
|
42
|
+
language?: string;
|
|
43
|
+
schemaVersion: number;
|
|
44
|
+
stateSpec?: ArtifactStateSpec;
|
|
45
|
+
currentVersion: number;
|
|
46
|
+
/** Body size in bytes. */
|
|
47
|
+
size: number;
|
|
48
|
+
origin: ArtifactOrigin;
|
|
49
|
+
createdAt: number;
|
|
50
|
+
updatedAt: number;
|
|
51
|
+
teamId?: string;
|
|
52
|
+
};
|
|
53
|
+
/** A detail row: the list row plus the body of the version read. */
|
|
54
|
+
export type ArtifactDetailRow = ArtifactListRow & {
|
|
55
|
+
body: string;
|
|
56
|
+
};
|
|
57
|
+
export type ArtifactBodyValidation = {
|
|
58
|
+
ok: true;
|
|
59
|
+
json?: QuizBodyV1 | FlashcardsBodyV1;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
error: string;
|
|
63
|
+
};
|
|
64
|
+
export type ArtifactSchemas = {
|
|
65
|
+
artifactType: z.ZodType<ArtifactType>;
|
|
66
|
+
artifactFormat: z.ZodType<ArtifactFormat>;
|
|
67
|
+
stateSpec: z.ZodType<ArtifactStateSpec>;
|
|
68
|
+
quizBodyV1: z.ZodType<QuizBodyV1>;
|
|
69
|
+
flashcardsBodyV1: z.ZodType<FlashcardsBodyV1>;
|
|
70
|
+
listRow: z.ZodType<ArtifactListRow>;
|
|
71
|
+
detailRow: z.ZodType<ArtifactDetailRow>;
|
|
72
|
+
/**
|
|
73
|
+
* Checks a body before it is saved: at most `ARTIFACT_BODY_MAX_CHARS`, and
|
|
74
|
+
* for `json` a known type and schema version (default 1) whose parsed body
|
|
75
|
+
* matches the typed schema. Returns the parsed JSON body when there is one.
|
|
76
|
+
*/
|
|
77
|
+
validateArtifactBody(type: ArtifactType, format: ArtifactFormat, body: string, schemaVersion?: number): ArtifactBodyValidation;
|
|
78
|
+
};
|
|
79
|
+
/** The artifact schemas, built with the app's `z`. */
|
|
80
|
+
export declare function createArtifactSchemas(zod: typeof z): ArtifactSchemas;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ARTIFACT_BODY_MAX_CHARS, ARTIFACT_STATE_MAX_KEY_LENGTH, ARTIFACT_STATE_MAX_KEYS } from "./limits.js";
|
|
2
|
+
/** What the artifact is, for filters and icons. */
|
|
3
|
+
export const ARTIFACT_TYPES = [
|
|
4
|
+
"document",
|
|
5
|
+
"report",
|
|
6
|
+
"slides",
|
|
7
|
+
"infographic",
|
|
8
|
+
"mindmap",
|
|
9
|
+
"quiz",
|
|
10
|
+
"flashcards",
|
|
11
|
+
"diagram",
|
|
12
|
+
"code",
|
|
13
|
+
];
|
|
14
|
+
/** How the body renders. `json` is only for typed bodies (`ARTIFACT_JSON_TYPES`). */
|
|
15
|
+
export const ARTIFACT_FORMATS = ["html", "markdown", "svg", "code", "json"];
|
|
16
|
+
/** Types with a typed JSON body, and the body schema versions each accepts. */
|
|
17
|
+
export const ARTIFACT_JSON_TYPES = { quiz: [1], flashcards: [1] };
|
|
18
|
+
export const ARTIFACT_TITLE_MAX_CHARS = 200;
|
|
19
|
+
export const ARTIFACT_DESCRIPTION_MAX_CHARS = 280;
|
|
20
|
+
function isJsonType(type) {
|
|
21
|
+
return Object.hasOwn(ARTIFACT_JSON_TYPES, type);
|
|
22
|
+
}
|
|
23
|
+
function parseJson(body) {
|
|
24
|
+
try {
|
|
25
|
+
const value = JSON.parse(body);
|
|
26
|
+
return { ok: true, value };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return { ok: false };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** The artifact schemas, built with the app's `z`. */
|
|
33
|
+
export function createArtifactSchemas(zod) {
|
|
34
|
+
const text = zod.string().trim().min(1);
|
|
35
|
+
const artifactType = zod.enum(ARTIFACT_TYPES);
|
|
36
|
+
const artifactFormat = zod.enum(ARTIFACT_FORMATS);
|
|
37
|
+
const stateSpec = zod.object({
|
|
38
|
+
stateVersion: zod.number().int().min(1),
|
|
39
|
+
keys: zod.array(zod.string().min(1).max(ARTIFACT_STATE_MAX_KEY_LENGTH)).max(ARTIFACT_STATE_MAX_KEYS),
|
|
40
|
+
template: zod.enum(["quiz", "flashcards"]).optional(),
|
|
41
|
+
});
|
|
42
|
+
const quizBodyV1 = zod.object({
|
|
43
|
+
title: text,
|
|
44
|
+
questions: zod
|
|
45
|
+
.array(zod
|
|
46
|
+
.object({
|
|
47
|
+
id: text,
|
|
48
|
+
prompt: text,
|
|
49
|
+
options: zod.array(text).min(2).max(5),
|
|
50
|
+
correctIndex: zod.number().int().min(0),
|
|
51
|
+
})
|
|
52
|
+
.refine((question) => question.correctIndex < question.options.length, {
|
|
53
|
+
message: "correctIndex must point at an option",
|
|
54
|
+
path: ["correctIndex"],
|
|
55
|
+
}))
|
|
56
|
+
.min(1),
|
|
57
|
+
});
|
|
58
|
+
const flashcardsBodyV1 = zod.object({
|
|
59
|
+
title: text,
|
|
60
|
+
cards: zod.array(zod.object({ id: text, front: text, back: text })).min(1),
|
|
61
|
+
});
|
|
62
|
+
const listRowShape = {
|
|
63
|
+
id: zod.string(),
|
|
64
|
+
title: zod.string().min(1).max(ARTIFACT_TITLE_MAX_CHARS),
|
|
65
|
+
description: zod.string().max(ARTIFACT_DESCRIPTION_MAX_CHARS).optional(),
|
|
66
|
+
type: artifactType,
|
|
67
|
+
format: artifactFormat,
|
|
68
|
+
language: zod.string().optional(),
|
|
69
|
+
schemaVersion: zod.number().int().min(1),
|
|
70
|
+
stateSpec: stateSpec.optional(),
|
|
71
|
+
currentVersion: zod.number().int().min(1),
|
|
72
|
+
size: zod.number().int().min(0),
|
|
73
|
+
origin: zod.object({ client: zod.string().min(1), externalId: zod.string().optional() }),
|
|
74
|
+
createdAt: zod.number(),
|
|
75
|
+
updatedAt: zod.number(),
|
|
76
|
+
teamId: zod.string().optional(),
|
|
77
|
+
};
|
|
78
|
+
const listRow = zod.object(listRowShape);
|
|
79
|
+
const detailRow = zod.object({ ...listRowShape, body: zod.string().max(ARTIFACT_BODY_MAX_CHARS) });
|
|
80
|
+
function validateArtifactBody(type, format, body, schemaVersion = 1) {
|
|
81
|
+
if (body.length > ARTIFACT_BODY_MAX_CHARS) {
|
|
82
|
+
return { ok: false, error: `Artifact body exceeds ${ARTIFACT_BODY_MAX_CHARS.toLocaleString("en-GB")} characters.` };
|
|
83
|
+
}
|
|
84
|
+
if (format !== "json")
|
|
85
|
+
return { ok: true };
|
|
86
|
+
if (!isJsonType(type))
|
|
87
|
+
return { ok: false, error: `A ${type} artifact cannot have a json body.` };
|
|
88
|
+
const versions = ARTIFACT_JSON_TYPES[type];
|
|
89
|
+
if (!versions.includes(schemaVersion)) {
|
|
90
|
+
return { ok: false, error: `Unknown ${type} body schema version ${String(schemaVersion)}.` };
|
|
91
|
+
}
|
|
92
|
+
const parsed = parseJson(body);
|
|
93
|
+
if (!parsed.ok)
|
|
94
|
+
return { ok: false, error: "Artifact body is not valid JSON." };
|
|
95
|
+
const result = type === "quiz" ? quizBodyV1.safeParse(parsed.value) : flashcardsBodyV1.safeParse(parsed.value);
|
|
96
|
+
if (!result.success) {
|
|
97
|
+
const issues = result.error.issues.map((issue) => `${issue.message} at ${issue.path.join(".") || "body"}`);
|
|
98
|
+
return { ok: false, error: `Invalid ${type} body: ${issues.join("; ")}` };
|
|
99
|
+
}
|
|
100
|
+
return { ok: true, json: result.data };
|
|
101
|
+
}
|
|
102
|
+
return { artifactType, artifactFormat, stateSpec, quizBodyV1, flashcardsBodyV1, listRow, detailRow, validateArtifactBody };
|
|
103
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Per user, per artifact state: string keys to string values (the guest JSON-encodes values). */
|
|
2
|
+
export type ArtifactStateMap = Record<string, string>;
|
|
3
|
+
export type ArtifactStateOp = {
|
|
4
|
+
op: "get";
|
|
5
|
+
key: string;
|
|
6
|
+
} | {
|
|
7
|
+
op: "set";
|
|
8
|
+
key: string;
|
|
9
|
+
value: string;
|
|
10
|
+
} | {
|
|
11
|
+
op: "getAll";
|
|
12
|
+
} | {
|
|
13
|
+
op: "remove";
|
|
14
|
+
key: string;
|
|
15
|
+
} | {
|
|
16
|
+
op: "reset";
|
|
17
|
+
};
|
|
18
|
+
export type ArtifactStateOpResult = {
|
|
19
|
+
data: ArtifactStateMap;
|
|
20
|
+
value: string | ArtifactStateMap | null;
|
|
21
|
+
error?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ArtifactStatePatch = {
|
|
24
|
+
sets?: ArtifactStateMap;
|
|
25
|
+
removes?: string[];
|
|
26
|
+
reset?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** The first limit `data` breaks (keys, key length, value size, total size), or `undefined`. */
|
|
29
|
+
export declare function validateArtifactStateMap(data: ArtifactStateMap): string | undefined;
|
|
30
|
+
/** Apply one guest op. On an error, `data` is `current` unchanged. */
|
|
31
|
+
export declare function applyArtifactStateOp(current: ArtifactStateMap, message: ArtifactStateOp): ArtifactStateOpResult;
|
|
32
|
+
/** Apply a batched write (reset, then sets, then removes) all or nothing. */
|
|
33
|
+
export declare function applyArtifactStatePatch(current: ArtifactStateMap, patch: ArtifactStatePatch): ArtifactStateOpResult;
|
|
34
|
+
/** The op in a guest `artifact:state` message, or `undefined` when it is malformed. */
|
|
35
|
+
export declare function parseArtifactStateOp(data: {
|
|
36
|
+
op?: string;
|
|
37
|
+
key?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
}): ArtifactStateOp | undefined;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ARTIFACT_STATE_MAX_KEY_LENGTH, ARTIFACT_STATE_MAX_KEYS, ARTIFACT_STATE_MAX_TOTAL_BYTES, ARTIFACT_STATE_MAX_VALUE_BYTES, utf8ByteLength, } from "./limits.js";
|
|
2
|
+
function requireKey(key) {
|
|
3
|
+
const trimmed = key.trim();
|
|
4
|
+
if (trimmed.length === 0)
|
|
5
|
+
return "State key is required.";
|
|
6
|
+
if (trimmed.length > ARTIFACT_STATE_MAX_KEY_LENGTH)
|
|
7
|
+
return "State key is too long.";
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
/** The first limit `data` breaks (keys, key length, value size, total size), or `undefined`. */
|
|
11
|
+
export function validateArtifactStateMap(data) {
|
|
12
|
+
const keys = Object.keys(data);
|
|
13
|
+
if (keys.length > ARTIFACT_STATE_MAX_KEYS) {
|
|
14
|
+
return `State can have at most ${String(ARTIFACT_STATE_MAX_KEYS)} keys.`;
|
|
15
|
+
}
|
|
16
|
+
let total = 0;
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
const keyError = requireKey(key);
|
|
19
|
+
if (keyError)
|
|
20
|
+
return keyError;
|
|
21
|
+
const value = data[key];
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
continue;
|
|
24
|
+
const size = utf8ByteLength(value);
|
|
25
|
+
if (size > ARTIFACT_STATE_MAX_VALUE_BYTES)
|
|
26
|
+
return `State value for "${key}" exceeds 16 KiB.`;
|
|
27
|
+
total += utf8ByteLength(key) + size;
|
|
28
|
+
}
|
|
29
|
+
if (total > ARTIFACT_STATE_MAX_TOTAL_BYTES)
|
|
30
|
+
return "State exceeds 64 KiB.";
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Apply one guest op. On an error, `data` is `current` unchanged. */
|
|
34
|
+
export function applyArtifactStateOp(current, message) {
|
|
35
|
+
if (message.op === "getAll")
|
|
36
|
+
return { data: current, value: { ...current } };
|
|
37
|
+
if (message.op === "reset")
|
|
38
|
+
return { data: {}, value: null };
|
|
39
|
+
const keyError = requireKey(message.key);
|
|
40
|
+
if (keyError)
|
|
41
|
+
return { data: current, value: null, error: keyError };
|
|
42
|
+
const key = message.key.trim();
|
|
43
|
+
if (message.op === "get") {
|
|
44
|
+
const value = current[key];
|
|
45
|
+
return { data: current, value: value === undefined ? null : value };
|
|
46
|
+
}
|
|
47
|
+
if (message.op === "remove") {
|
|
48
|
+
const next = { ...current };
|
|
49
|
+
delete next[key];
|
|
50
|
+
return { data: next, value: null };
|
|
51
|
+
}
|
|
52
|
+
const next = { ...current, [key]: message.value };
|
|
53
|
+
const quotaError = validateArtifactStateMap(next);
|
|
54
|
+
if (quotaError)
|
|
55
|
+
return { data: current, value: null, error: quotaError };
|
|
56
|
+
return { data: next, value: null };
|
|
57
|
+
}
|
|
58
|
+
/** Apply a batched write (reset, then sets, then removes) all or nothing. */
|
|
59
|
+
export function applyArtifactStatePatch(current, patch) {
|
|
60
|
+
let data = patch.reset ? {} : { ...current };
|
|
61
|
+
for (const [key, value] of Object.entries(patch.sets ?? {})) {
|
|
62
|
+
const result = applyArtifactStateOp(data, { op: "set", key, value });
|
|
63
|
+
if (result.error)
|
|
64
|
+
return { ...result, data: current };
|
|
65
|
+
data = result.data;
|
|
66
|
+
}
|
|
67
|
+
for (const key of patch.removes ?? []) {
|
|
68
|
+
const result = applyArtifactStateOp(data, { op: "remove", key });
|
|
69
|
+
if (result.error)
|
|
70
|
+
return { ...result, data: current };
|
|
71
|
+
data = result.data;
|
|
72
|
+
}
|
|
73
|
+
const quotaError = validateArtifactStateMap(data);
|
|
74
|
+
if (quotaError)
|
|
75
|
+
return { data: current, value: null, error: quotaError };
|
|
76
|
+
return { data, value: null };
|
|
77
|
+
}
|
|
78
|
+
/** The op in a guest `artifact:state` message, or `undefined` when it is malformed. */
|
|
79
|
+
export function parseArtifactStateOp(data) {
|
|
80
|
+
if (data.op === "getAll")
|
|
81
|
+
return { op: "getAll" };
|
|
82
|
+
if (data.op === "reset")
|
|
83
|
+
return { op: "reset" };
|
|
84
|
+
if (data.op === "get" && typeof data.key === "string")
|
|
85
|
+
return { op: "get", key: data.key };
|
|
86
|
+
if (data.op === "remove" && typeof data.key === "string")
|
|
87
|
+
return { op: "remove", key: data.key };
|
|
88
|
+
if (data.op === "set" && typeof data.key === "string" && typeof data.value === "string") {
|
|
89
|
+
return { op: "set", key: data.key, value: data.value };
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArtifactStateMap } from "./stateOps.js";
|
|
2
|
+
export declare const ARTIFACT_LOCAL_STORAGE_PREFIX = "ls:";
|
|
3
|
+
export declare const ARTIFACT_SESSION_STORAGE_PREFIX = "ss:";
|
|
4
|
+
export declare function prefixedStorageKey(prefix: string, key: string): string;
|
|
5
|
+
export declare function unprefixStorageKey(prefix: string, prefixed: string): string | undefined;
|
|
6
|
+
/** The keys under `prefix`, with the prefix removed. */
|
|
7
|
+
export declare function storageView(data: ArtifactStateMap, prefix: string): ArtifactStateMap;
|
|
8
|
+
/** `data` without the keys under `prefix`. */
|
|
9
|
+
export declare function clearPrefixedKeys(data: ArtifactStateMap, prefix: string): ArtifactStateMap;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The guest's localStorage and sessionStorage shims keep their keys in the
|
|
2
|
+
// artifact state under these prefixes, beside the `artifactState` keys.
|
|
3
|
+
export const ARTIFACT_LOCAL_STORAGE_PREFIX = "ls:";
|
|
4
|
+
export const ARTIFACT_SESSION_STORAGE_PREFIX = "ss:";
|
|
5
|
+
export function prefixedStorageKey(prefix, key) {
|
|
6
|
+
return `${prefix}${key}`;
|
|
7
|
+
}
|
|
8
|
+
export function unprefixStorageKey(prefix, prefixed) {
|
|
9
|
+
if (!prefixed.startsWith(prefix))
|
|
10
|
+
return undefined;
|
|
11
|
+
return prefixed.slice(prefix.length);
|
|
12
|
+
}
|
|
13
|
+
/** The keys under `prefix`, with the prefix removed. */
|
|
14
|
+
export function storageView(data, prefix) {
|
|
15
|
+
const view = {};
|
|
16
|
+
for (const [key, value] of Object.entries(data)) {
|
|
17
|
+
const rest = unprefixStorageKey(prefix, key);
|
|
18
|
+
if (rest === undefined || rest.length === 0)
|
|
19
|
+
continue;
|
|
20
|
+
view[rest] = value;
|
|
21
|
+
}
|
|
22
|
+
return view;
|
|
23
|
+
}
|
|
24
|
+
/** `data` without the keys under `prefix`. */
|
|
25
|
+
export function clearPrefixedKeys(data, prefix) {
|
|
26
|
+
const next = {};
|
|
27
|
+
for (const [key, value] of Object.entries(data)) {
|
|
28
|
+
if (!key.startsWith(prefix))
|
|
29
|
+
next[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return next;
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type Flashcard = {
|
|
2
|
+
id: string;
|
|
3
|
+
front: string;
|
|
4
|
+
back: string;
|
|
5
|
+
};
|
|
6
|
+
export type QuizQuestion = {
|
|
7
|
+
id: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
options: string[];
|
|
10
|
+
correctIndex: number;
|
|
11
|
+
};
|
|
12
|
+
export type ArtifactTemplateName = "quiz" | "flashcards";
|
|
13
|
+
export declare function parseFlashcardsTemplate(raw: string): {
|
|
14
|
+
title?: string;
|
|
15
|
+
cards: Flashcard[];
|
|
16
|
+
} | undefined;
|
|
17
|
+
export declare function parseQuizTemplate(raw: string): {
|
|
18
|
+
title?: string;
|
|
19
|
+
questions: QuizQuestion[];
|
|
20
|
+
} | undefined;
|
|
21
|
+
export declare function htmlFromArtifactTemplate(args: {
|
|
22
|
+
title: string;
|
|
23
|
+
content: string;
|
|
24
|
+
template?: ArtifactTemplateName;
|
|
25
|
+
}): string | undefined;
|
|
26
|
+
export declare function buildFlashcardsHtml(args: {
|
|
27
|
+
title: string;
|
|
28
|
+
cards: Flashcard[];
|
|
29
|
+
}): string;
|
|
30
|
+
export declare function buildQuizHtml(args: {
|
|
31
|
+
title: string;
|
|
32
|
+
questions: QuizQuestion[];
|
|
33
|
+
}): string;
|