@systemfsoftware/hex-schema 1.5.0 → 1.6.1

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.
@@ -1,6 +1,6 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
- export declare const ColonHex: Schema.brand<Schema.transform<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.SchemaClass<string, string, never>>, Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "HexString">>, "ColonHex">;
3
+ export declare const ColonHex: Schema.brand<Schema.transform<Schema.transform<Schema.filter<typeof Schema.String>, Schema.SchemaClass<string, string, never>>, Schema.brand<Schema.transform<Schema.SchemaClass<string, string, never>, Schema.refine<string, typeof Schema.String>>, "HexString">>, "ColonHex">;
4
4
 
5
5
  export declare type ColonHex = Schema.Schema.Type<typeof ColonHex>;
6
6
 
@@ -15,17 +15,17 @@ export declare type ColonHex = Schema.Schema.Type<typeof ColonHex>;
15
15
  */
16
16
  export declare const HexBytes: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
17
17
 
18
- export declare const HexString: Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "HexString">;
18
+ export declare const HexString: Schema.brand<Schema.transform<Schema.SchemaClass<string, string, never>, Schema.refine<string, typeof Schema.String>>, "HexString">;
19
19
 
20
20
  export declare type HexString = Schema.Schema.Type<typeof HexString>;
21
21
 
22
- export declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
22
+ export declare const PrefixedHex: Schema.brand<Schema.transform<Schema.TemplateLiteral<`0x${string}`>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
23
23
 
24
24
  export declare type PrefixedHex = Schema.Schema.Type<typeof PrefixedHex>;
25
25
 
26
26
  export declare const StrictHex: Schema.refine<string, typeof Schema.String>;
27
27
 
28
- export declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
28
+ export declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.brand<Schema.transform<Schema.TemplateLiteral<`0x${string}`>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
29
29
 
30
30
  export declare type Uint8ArrayFromPrefixedHex = Schema.Schema.Type<typeof Uint8ArrayFromPrefixedHex>;
31
31
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  //#region src/colon-hex.schema.d.ts
3
- declare const ColonHex: Schema.brand<Schema.transform<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.SchemaClass<string, string, never>>, Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "HexString">>, "ColonHex">;
3
+ declare const ColonHex: Schema.brand<Schema.transform<Schema.transform<Schema.filter<typeof Schema.String>, Schema.SchemaClass<string, string, never>>, Schema.brand<Schema.transform<Schema.SchemaClass<string, string, never>, Schema.refine<string, typeof Schema.String>>, "HexString">>, "ColonHex">;
4
4
  type ColonHex = Schema.Schema.Type<typeof ColonHex>;
5
5
  //#endregion
6
6
  //#region src/hex-bytes.schema.d.ts
@@ -16,18 +16,18 @@ type ColonHex = Schema.Schema.Type<typeof ColonHex>;
16
16
  declare const HexBytes: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
17
17
  //#endregion
18
18
  //#region src/hex-string.schema.d.ts
19
- declare const HexString: Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "HexString">;
19
+ declare const HexString: Schema.brand<Schema.transform<Schema.SchemaClass<string, string, never>, Schema.refine<string, typeof Schema.String>>, "HexString">;
20
20
  type HexString = Schema.Schema.Type<typeof HexString>;
21
21
  //#endregion
22
22
  //#region src/prefixed-hex.schema.d.ts
23
- declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
23
+ declare const PrefixedHex: Schema.brand<Schema.transform<Schema.TemplateLiteral<`0x${string}`>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
24
24
  type PrefixedHex = Schema.Schema.Type<typeof PrefixedHex>;
25
25
  //#endregion
26
26
  //#region src/strict-hex.schema.d.ts
27
27
  declare const StrictHex: Schema.refine<string, typeof Schema.String>;
28
28
  //#endregion
29
29
  //#region src/uint8array-from-prefixed-hex.schema.d.ts
30
- declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
30
+ declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.brand<Schema.transform<Schema.TemplateLiteral<`0x${string}`>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
31
31
  type Uint8ArrayFromPrefixedHex = Schema.Schema.Type<typeof Uint8ArrayFromPrefixedHex>;
32
32
  //#endregion
33
33
  export { ColonHex, HexBytes, HexString, PrefixedHex, StrictHex, Uint8ArrayFromPrefixedHex };
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
- import { Encoding, Schema, pipe } from "effect";
1
+ import { Schema, pipe } from "effect";
2
2
  //#region src/strict-hex.schema.ts
3
3
  const StrictHex = Schema.String.pipe(Schema.pattern(/^[0-9a-f]*$/), Schema.annotations({
4
- arbitrary: () => (fc) => fc.hexaString(),
5
4
  identifier: "StrictHex",
6
5
  description: "A lowercase hexadecimal string with no prefix",
7
6
  title: "Strict Hex String"
@@ -9,8 +8,7 @@ const StrictHex = Schema.String.pipe(Schema.pattern(/^[0-9a-f]*$/), Schema.annot
9
8
  //#endregion
10
9
  //#region src/hex-string.schema.ts
11
10
  const toStrictHex = (hex) => (hex.startsWith("0x") ? hex.slice(2) : hex).toLowerCase();
12
- const HexString = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^(0x)?[0-9a-fA-F]*$/), Schema.annotations({
13
- arbitrary: () => (fc) => fc.stringMatching(/^(0x)?[0-9a-fA-F]*$/),
11
+ const HexString = pipe(Schema.transform(Schema.String.pipe(Schema.annotations({
14
12
  identifier: "HexStringInput",
15
13
  description: "A hex string, optionally prefixed with 0x (empty string allowed)"
16
14
  })), StrictHex, {
@@ -24,8 +22,7 @@ const HexString = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^(0x)
24
22
  //#endregion
25
23
  //#region src/colon-hex.schema.ts
26
24
  const hexToColon = (hex) => (hex.match(/.{1,2}/g) ?? []).map((byte) => byte.toUpperCase()).join(":");
27
- const ColonHex = pipe(Schema.compose(Schema.transform(Schema.String.pipe(Schema.pattern(/^([0-9A-Fa-f]{1,2}(:[0-9A-Fa-f]{1,2})*)?$/), Schema.annotations({ arbitrary: () => (fc) => fc.hexaString().map(hexToColon) })), Schema.encodedSchema(HexString), {
28
- strict: true,
25
+ const ColonHex = pipe(Schema.compose(Schema.transform(Schema.String.pipe(Schema.pattern(/^([0-9A-Fa-f]{1,2}(:[0-9A-Fa-f]{1,2})*)?$/)), Schema.encodedSchema(HexString), {
29
26
  decode: (colon) => colon.replaceAll(":", ""),
30
27
  encode: hexToColon
31
28
  }), HexString), Schema.annotations({
@@ -51,8 +48,7 @@ const HexBytes = Schema.Uint8ArrayFromHex.pipe(Schema.annotations({
51
48
  }));
52
49
  //#endregion
53
50
  //#region src/prefixed-hex.schema.ts
54
- const PrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.String).pipe(Schema.pattern(/^0x[0-9a-f]*$/), Schema.annotations({ arbitrary: () => (fc) => fc.hexaString().map((hex) => `0x${hex}`) })), StrictHex, {
55
- strict: true,
51
+ const PrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.String), StrictHex, {
56
52
  decode: (fromA) => fromA.slice(2),
57
53
  encode: (toI) => `0x${toI}`
58
54
  }), Schema.annotations({
@@ -62,11 +58,7 @@ const PrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.St
62
58
  }), Schema.brand("PrefixedHex"));
63
59
  //#endregion
64
60
  //#region src/uint8array-from-prefixed-hex.schema.ts
65
- const Uint8ArrayFromPrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.String).pipe(Schema.pattern(/^0x(?:[0-9a-f]{2})*$/), Schema.annotations({ arbitrary: () => (fc) => fc.uint8Array().map((bytes) => `0x${Encoding.encodeHex(bytes)}`) })), HexBytes, {
66
- strict: true,
67
- decode: (prefixed) => prefixed.slice(2),
68
- encode: (hex) => `0x${hex}`
69
- }), Schema.annotations({
61
+ const Uint8ArrayFromPrefixedHex = pipe(Schema.compose(PrefixedHex, HexBytes), Schema.annotations({
70
62
  identifier: "Uint8ArrayFromPrefixedHex",
71
63
  description: "Uint8Array encoded as a 0x-prefixed hex string",
72
64
  title: "Uint8Array from Prefixed Hex"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/hex-schema",
3
3
  "license": "MIT",
4
- "version": "1.5.0",
4
+ "version": "1.6.1",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -43,14 +43,14 @@
43
43
  "rimraf": "^6.1.3",
44
44
  "tsdown": "^0.22.9",
45
45
  "vitest": "^4",
46
- "@systemfsoftware/arethetypeswrong-cli": "^1.0.7",
47
- "@systemfsoftware/effect-schema-vite": "^1.4.0",
46
+ "@systemfsoftware/arethetypeswrong-cli": "^1.1.1",
47
+ "@systemfsoftware/effect-schema-law": "^0.6.1",
48
+ "@systemfsoftware/effect-schema-vite": "^1.5.1",
49
+ "@systemfsoftware/stryker-js-typescript-checker": "^1.2.1",
48
50
  "@systemfsoftware/oxlint-config": "^0.1.0",
49
- "@systemfsoftware/stryker-js-core": "^1.1.6",
50
- "@systemfsoftware/effect-schema-law": "^0.5.0",
51
- "@systemfsoftware/tsconfig": "^1.2.6",
52
- "@systemfsoftware/stryker-js-typescript-checker": "^1.1.6",
53
- "@systemfsoftware/stryker-plugins": "^0.7.0",
51
+ "@systemfsoftware/stryker-js-core": "^1.2.1",
52
+ "@systemfsoftware/stryker-plugins": "^0.10.0",
53
+ "@systemfsoftware/tsconfig": "^1.3.0",
54
54
  "@systemfsoftware/vitest-config": "^0.1.0"
55
55
  },
56
56
  "peerDependencies": {
@@ -68,7 +68,7 @@
68
68
  "api:update": "api-extractor run --local",
69
69
  "lint": "oxlint . ${AGENT:+--format=unix --quiet}",
70
70
  "attw": "attw --pack .",
71
- "mutation": "stryker run --incremental",
71
+ "mutation": "stryker run",
72
72
  "mutation:full": "stryker run"
73
73
  }
74
74
  }