@arisutalk/character-spec 0.0.5 → 0.0.7

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.
@@ -126,7 +126,7 @@ export type Character = {
126
126
  /** The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored. */
127
127
  mem?: number | undefined;
128
128
  /** The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. It is used per call, not a total limit. Default is 3 seconds. */
129
- timout: number;
129
+ timeout: number;
130
130
  };
131
131
  /** Replace hooks for the script. */
132
132
  replaceHooks: {
@@ -12,7 +12,7 @@ export type ScriptSetting = {
12
12
  /** The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored. */
13
13
  mem?: number | undefined;
14
14
  /** The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. It is used per call, not a total limit. Default is 3 seconds. */
15
- timout: number;
15
+ timeout: number;
16
16
  };
17
17
  /** Replace hooks for the script. */
18
18
  replaceHooks: {
@@ -6,7 +6,7 @@ const n = e.object({
6
6
  mem: t.optional().meta({
7
7
  description: "The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored."
8
8
  }),
9
- timout: t.default(3).meta({
9
+ timeout: t.default(3).meta({
10
10
  description: "The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. It is used per call, not a total limit. Default is 3 seconds."
11
11
  })
12
12
  }).prefault({}).meta({
@@ -1 +1 @@
1
- {"version":3,"file":"Executable.js","sources":["../../../src/types/v0/Executables/Executable.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ReplaceHookSchema } from \"@/types/v0/Executables/ReplaceHook\";\nimport { positiveInteger } from \"@/types/v0/utils\";\n\n/**\n * This is the script for character. It includes hook, script settings, something else.\n */\nexport const ScriptSettingSchema = z\n .object({\n runtimeSetting: z\n .object({\n mem: positiveInteger.optional().meta({\n description:\n \"The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored.\",\n }),\n timout: positiveInteger.default(3).meta({\n description:\n \"The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. \" +\n \"It is used per call, not a total limit. Default is 3 seconds.\",\n }),\n })\n .prefault({})\n .meta({\n description:\n \"Runtime settings for the script. Controls runtime environment. All values capped at user's configuration.\",\n }),\n replaceHooks: ReplaceHookSchema.meta({\n description: \"Replace hooks for the script.\",\n }),\n })\n .prefault({})\n .meta({\n description:\n \"Script settings for character. Includes hooks and script settings.\",\n });\n"],"names":["ScriptSettingSchema","z","positiveInteger","ReplaceHookSchema"],"mappings":";;;AAOO,MAAMA,IAAsBC,EAC9B,OAAO;AAAA,EACJ,gBAAgBA,EACX,OAAO;AAAA,IACJ,KAAKC,EAAgB,SAAA,EAAW,KAAK;AAAA,MACjC,aACI;AAAA,IAAA,CACP;AAAA,IACD,QAAQA,EAAgB,QAAQ,CAAC,EAAE,KAAK;AAAA,MACpC,aACI;AAAA,IAAA,CAEP;AAAA,EAAA,CACJ,EACA,SAAS,EAAE,EACX,KAAK;AAAA,IACF,aACI;AAAA,EAAA,CACP;AAAA,EACL,cAAcC,EAAkB,KAAK;AAAA,IACjC,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,SAAS,EAAE,EACX,KAAK;AAAA,EACF,aACI;AACR,CAAC;"}
1
+ {"version":3,"file":"Executable.js","sources":["../../../src/types/v0/Executables/Executable.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ReplaceHookSchema } from \"@/types/v0/Executables/ReplaceHook\";\nimport { positiveInteger } from \"@/types/v0/utils\";\n\n/**\n * This is the script for character. It includes hook, script settings, something else.\n */\nexport const ScriptSettingSchema = z\n .object({\n runtimeSetting: z\n .object({\n mem: positiveInteger.optional().meta({\n description:\n \"The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored.\",\n }),\n timeout: positiveInteger.default(3).meta({\n description:\n \"The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. \" +\n \"It is used per call, not a total limit. Default is 3 seconds.\",\n }),\n })\n .prefault({})\n .meta({\n description:\n \"Runtime settings for the script. Controls runtime environment. All values capped at user's configuration.\",\n }),\n replaceHooks: ReplaceHookSchema.meta({\n description: \"Replace hooks for the script.\",\n }),\n })\n .prefault({})\n .meta({\n description:\n \"Script settings for character. Includes hooks and script settings.\",\n });\n"],"names":["ScriptSettingSchema","z","positiveInteger","ReplaceHookSchema"],"mappings":";;;AAOO,MAAMA,IAAsBC,EAC9B,OAAO;AAAA,EACJ,gBAAgBA,EACX,OAAO;AAAA,IACJ,KAAKC,EAAgB,SAAA,EAAW,KAAK;AAAA,MACjC,aACI;AAAA,IAAA,CACP;AAAA,IACD,SAASA,EAAgB,QAAQ,CAAC,EAAE,KAAK;AAAA,MACrC,aACI;AAAA,IAAA,CAEP;AAAA,EAAA,CACJ,EACA,SAAS,EAAE,EACX,KAAK;AAAA,IACF,aACI;AAAA,EAAA,CACP;AAAA,EACL,cAAcC,EAAkB,KAAK;AAAA,IACjC,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,SAAS,EAAE,EACX,KAAK;AAAA,EACF,aACI;AACR,CAAC;"}
package/dist/v0/utils.js CHANGED
@@ -1,26 +1,30 @@
1
- import { z as e } from "zod";
2
- const i = e.url().meta({
1
+ import { z as t } from "zod";
2
+ const a = t.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
- }), r = e.instanceof(Uint8Array).meta({
4
+ }), i = t.instanceof(Uint8Array).meta({
5
5
  description: "The binary data of the file. Used for local assets.",
6
6
  tsType: "Uint8Array"
7
- }), s = e.union([
7
+ }), s = t.union([
8
8
  // URL Asset
9
- i,
10
- r
9
+ a,
10
+ i
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 (t) => new Set(t.map((a) => a[n])).size === t.length;
17
+ return (e) => new Set(e.map((r) => r[n])).size === e.length;
18
+ }
19
+ const m = t.int().min(1).meta({ description: "Positive integer (>= 1)" });
20
+ function p(n, e) {
21
+ return n.parse(e);
18
22
  }
19
- const m = e.int().min(1).meta({ description: "Positive integer (>= 1)" });
20
23
  export {
21
24
  s as FileSchema,
22
- i as ImageURLSchema,
23
- r as Uint8ArraySchema,
25
+ a as ImageURLSchema,
26
+ i as Uint8ArraySchema,
27
+ p as apply,
24
28
  m as positiveInteger,
25
29
  c as unique
26
30
  };
@@ -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"],"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;"}
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\n/**\n * Applies the given Zod schema to the provided data and returns the parsed output.\n * @param schema The Zod schema to apply.\n * @param data The data to be validated and parsed. Don't need to pass optional fields.\n * @returns The parsed output of the schema.\n */\nexport function apply<T extends z.ZodType>(\n schema: T,\n data: z.input<T>,\n): z.output<T> {\n return schema.parse(data);\n}\n"],"names":["ImageURLSchema","z","Uint8ArraySchema","FileSchema","unique","key","i","j","positiveInteger","apply","schema","data"],"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;AAQ7C,SAASQ,EACZC,GACAC,GACW;AACX,SAAOD,EAAO,MAAMC,CAAI;AAC5B;"}
package/dist/v0.js CHANGED
@@ -1,8 +1,9 @@
1
- import { FileSchema as i, ImageURLSchema as m, Uint8ArraySchema as r, positiveInteger as t, unique as c } from "./v0/utils.js";
1
+ import { FileSchema as i, ImageURLSchema as m, Uint8ArraySchema as r, apply as p, 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,
6
7
  t as positiveInteger,
7
8
  c as unique
8
9
  };
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.5",
4
+ "version": "0.0.7",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "concertypin",