@arisutalk/character-spec 0.0.7 → 0.0.8
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/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/v0/utils.js +10 -14
- package/dist/v0/utils.js.map +1 -1
- package/dist/v0.js +1 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n type Character as CharacterV0,\n CharacterSchema as CharacterV0Schema,\n} from \"@/types/v0/Character/Character\";\n\nexport const characterMap = {\n 0: CharacterV0Schema,\n} as const;\nexport type CharacterMap = {\n \"0\": CharacterV0;\n};\n\nexport default characterMap;\n"],"names":["characterMap","CharacterV0Schema"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n type Character as CharacterV0,\n CharacterSchema as CharacterV0Schema,\n} from \"@/types/v0/Character/Character\";\n\n/**\n * Version-schema pair of character specification\n */\nexport const characterMap = {\n 0: CharacterV0Schema,\n} as const;\n/**\n * Version-type pair of character specification\n */\nexport type CharacterMap = {\n \"0\": CharacterV0;\n};\n/**\n * Latest character specification\n */\nexport default characterMap[\"0\"];\n"],"names":["characterMap","CharacterV0Schema","index"],"mappings":";AAQO,MAAMA,IAAe;AAAA,EACxB,GAAGC;AACP,GAUAC,IAAeF,EAAa,CAAG;"}
|
package/dist/v0/utils.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
const
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
const i = e.url().meta({
|
|
3
3
|
description: "URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended."
|
|
4
|
-
}),
|
|
4
|
+
}), r = e.instanceof(Uint8Array).meta({
|
|
5
5
|
description: "The binary data of the file. Used for local assets.",
|
|
6
6
|
tsType: "Uint8Array"
|
|
7
|
-
}), s =
|
|
7
|
+
}), s = e.union([
|
|
8
8
|
// URL Asset
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
i,
|
|
10
|
+
r
|
|
11
11
|
]).meta({
|
|
12
12
|
description: `Represents a file, either as a URL or as binary data (Uint8Array).
|
|
13
13
|
@type {string | Uint8Array}
|
|
14
14
|
`
|
|
15
15
|
});
|
|
16
16
|
function c(n) {
|
|
17
|
-
return (
|
|
18
|
-
}
|
|
19
|
-
const m = t.int().min(1).meta({ description: "Positive integer (>= 1)" });
|
|
20
|
-
function p(n, e) {
|
|
21
|
-
return n.parse(e);
|
|
17
|
+
return (t) => new Set(t.map((a) => a[n])).size === t.length;
|
|
22
18
|
}
|
|
19
|
+
const m = e.int().min(1).meta({ description: "Positive integer (>= 1)" });
|
|
23
20
|
export {
|
|
24
21
|
s as FileSchema,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
p as apply,
|
|
22
|
+
i as ImageURLSchema,
|
|
23
|
+
r as Uint8ArraySchema,
|
|
28
24
|
m as positiveInteger,
|
|
29
25
|
c as unique
|
|
30
26
|
};
|
package/dist/v0/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/types/v0/utils.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * This type is used to represent the URL of an image.\n * It is used to validate the URL of an image.\n * This should only be used in exported character. When importing the character, it should be converted to `local:`.\n * If its protocol is `local:`, it means the image is stored in the browser, usually OpFS.\n * Otherwise, it should be a valid URL which can be fetched in browser.\n * Don't use `data:` URL for large images, as it can bloat the character spec size.\n *\n */\nexport const ImageURLSchema = z.url().meta({\n description:\n \"URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended.\",\n});\n\n/**\n * Binary data represented as Uint8Array.\n * Useful for local file assets.\n */\nexport const Uint8ArraySchema = z.instanceof(Uint8Array).meta({\n description: \"The binary data of the file. Used for local assets.\",\n tsType: \"Uint8Array\",\n});\n\n/**\n * Represents a file, either as a URL or as binary data (Uint8Array).\n * Used for file assets.\n */\nexport const FileSchema = z\n .union([\n // URL Asset\n ImageURLSchema,\n Uint8ArraySchema,\n ])\n .meta({\n description:\n \"Represents a file, either as a URL or as binary data (Uint8Array).\\n\" +\n \"@type {string | Uint8Array}\\n\",\n });\n/**\n * Custom validator to ensure all objects in the array have unique values for a specific key.\n * @param key The key to check for uniqueness. It should be a string key of the object.\n * @returns A predicate function for `z.refine`.\n * @example\n * ```ts\n * const schema = z.array(z.object({ name: z.string() })).refine(unique(\"name\"), { message: \"Not unique\" });\n * ```\n */\nexport function unique<\n const ARR extends {\n [key: string]: unknown;\n },\n>(key: keyof ARR) {\n return (i: ARR[]) => {\n return new Set(i.map((j) => j[key])).size === i.length;\n };\n}\n\n/**\n * Zod custom schema to ensure the value is a positive integer.\n */\nexport const positiveInteger = z\n .int()\n .min(1)\n .meta({ description: \"Positive integer (>= 1)\" });\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/types/v0/utils.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * This type is used to represent the URL of an image.\n * It is used to validate the URL of an image.\n * This should only be used in exported character. When importing the character, it should be converted to `local:`.\n * If its protocol is `local:`, it means the image is stored in the browser, usually OpFS.\n * Otherwise, it should be a valid URL which can be fetched in browser.\n * Don't use `data:` URL for large images, as it can bloat the character spec size.\n *\n */\nexport const ImageURLSchema = z.url().meta({\n description:\n \"URL of an image. `local:` for browser storage (OpFS), otherwise a fetchable URL. While it can be `data:` URL for base64 encoded images, it's not recommended.\",\n});\n\n/**\n * Binary data represented as Uint8Array.\n * Useful for local file assets.\n */\nexport const Uint8ArraySchema = z.instanceof(Uint8Array).meta({\n description: \"The binary data of the file. Used for local assets.\",\n tsType: \"Uint8Array\",\n});\n\n/**\n * Represents a file, either as a URL or as binary data (Uint8Array).\n * Used for file assets.\n */\nexport const FileSchema = z\n .union([\n // URL Asset\n ImageURLSchema,\n Uint8ArraySchema,\n ])\n .meta({\n description:\n \"Represents a file, either as a URL or as binary data (Uint8Array).\\n\" +\n \"@type {string | Uint8Array}\\n\",\n });\n/**\n * Custom validator to ensure all objects in the array have unique values for a specific key.\n * @param key The key to check for uniqueness. It should be a string key of the object.\n * @returns A predicate function for `z.refine`.\n * @example\n * ```ts\n * const schema = z.array(z.object({ name: z.string() })).refine(unique(\"name\"), { message: \"Not unique\" });\n * ```\n */\nexport function unique<\n const ARR extends {\n [key: string]: unknown;\n },\n>(key: keyof ARR) {\n return (i: ARR[]) => {\n return new Set(i.map((j) => j[key])).size === i.length;\n };\n}\n\n/**\n * Zod custom schema to ensure the value is a positive integer.\n */\nexport const positiveInteger = z\n .int()\n .min(1)\n .meta({ description: \"Positive integer (>= 1)\" });\n"],"names":["ImageURLSchema","z","Uint8ArraySchema","FileSchema","unique","key","i","j","positiveInteger"],"mappings":";AAWO,MAAMA,IAAiBC,EAAE,IAAA,EAAM,KAAK;AAAA,EACvC,aACI;AACR,CAAC,GAMYC,IAAmBD,EAAE,WAAW,UAAU,EAAE,KAAK;AAAA,EAC1D,aAAa;AAAA,EACb,QAAQ;AACZ,CAAC,GAMYE,IAAaF,EACrB,MAAM;AAAA;AAAA,EAEHD;AAAA,EACAE;AACJ,CAAC,EACA,KAAK;AAAA,EACF,aACI;AAAA;AAAA;AAER,CAAC;AAUE,SAASE,EAIdC,GAAgB;AACd,SAAO,CAACC,MACG,IAAI,IAAIA,EAAE,IAAI,CAACC,MAAMA,EAAEF,CAAG,CAAC,CAAC,EAAE,SAASC,EAAE;AAExD;AAKO,MAAME,IAAkBP,EAC1B,IAAA,EACA,IAAI,CAAC,EACL,KAAK,EAAE,aAAa,0BAAA,CAA2B;"}
|
package/dist/v0.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FileSchema as i, ImageURLSchema as m, Uint8ArraySchema as r,
|
|
1
|
+
import { FileSchema as i, ImageURLSchema as m, Uint8ArraySchema as r, positiveInteger as t, unique as c } from "./v0/utils.js";
|
|
2
2
|
export {
|
|
3
3
|
i as FileSchema,
|
|
4
4
|
m as ImageURLSchema,
|
|
5
5
|
r as Uint8ArraySchema,
|
|
6
|
-
p as apply,
|
|
7
6
|
t as positiveInteger,
|
|
8
7
|
c as unique
|
|
9
8
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arisutalk/character-spec",
|
|
3
3
|
"description": "Character specification, schema & migration for ArisuTalk",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "concertypin",
|
|
@@ -58,4 +58,4 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"packageManager": "pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706"
|
|
61
|
-
}
|
|
61
|
+
}
|