@ethisyscore/core-utils 1.148.0 → 1.149.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.
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ // src/wire/enum.ts
4
+ var NUMERIC_KEY = /^-?\d+$/;
5
+ var lookups = /* @__PURE__ */ new WeakMap();
6
+ function lookupFor(members) {
7
+ const cached = lookups.get(members);
8
+ if (cached) {
9
+ return cached;
10
+ }
11
+ const byOrdinal = /* @__PURE__ */ new Map();
12
+ const byLowerName = /* @__PURE__ */ new Map();
13
+ for (const [name, ordinal] of Object.entries(members)) {
14
+ if (NUMERIC_KEY.test(name) || typeof ordinal !== "number") {
15
+ continue;
16
+ }
17
+ byOrdinal.set(ordinal, name);
18
+ byLowerName.set(name.toLowerCase(), name);
19
+ }
20
+ const lookup = { byOrdinal, byLowerName };
21
+ lookups.set(members, lookup);
22
+ return lookup;
23
+ }
24
+ function decodeWireEnumName(members, value) {
25
+ const lookup = lookupFor(members);
26
+ if (typeof value === "number") {
27
+ return lookup.byOrdinal.get(value);
28
+ }
29
+ if (typeof value === "string") {
30
+ return lookup.byLowerName.get(value.toLowerCase());
31
+ }
32
+ return void 0;
33
+ }
34
+ function decodeWireEnum(members, value) {
35
+ const name = decodeWireEnumName(members, value);
36
+ if (name === void 0) {
37
+ return void 0;
38
+ }
39
+ const ordinal = members[name];
40
+ return isWireEnumValue(members, ordinal) ? ordinal : void 0;
41
+ }
42
+ function isWireEnumValue(_members, value) {
43
+ return typeof value === "number";
44
+ }
45
+
46
+ exports.decodeWireEnum = decodeWireEnum;
47
+ exports.decodeWireEnumName = decodeWireEnumName;
48
+ //# sourceMappingURL=chunk-3ZLUSRKU.cjs.map
49
+ //# sourceMappingURL=chunk-3ZLUSRKU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wire/enum.ts"],"names":[],"mappings":";;;AAqBA,IAAM,WAAA,GAAc,SAAA;AAEp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O,kBAAA,CAAmB,OAAA,EAAS,KAAK,CAAA;AAC9C,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,GAAmB,QAAQ,IAAI,CAAA;AACrC,EAAA,OAAO,eAAA,CAAgB,OAAA,EAAS,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AACvD;AAEA,SAAS,eAAA,CAA2C,UAAa,KAAA,EAA2C;AAC1G,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA;AAC1B","file":"chunk-3ZLUSRKU.cjs","sourcesContent":["/**\n * The members of a C# enum as the UI mirrors them: member name to ordinal. A `const` object\n * (`{ Hidden: 0, Shown: 2 } as const`) and a TypeScript numeric `enum` both fit.\n */\nexport type WireEnumMembers = Readonly<Record<string, string | number>>;\n\n/**\n * The ordinal values of `T`. For a TypeScript numeric enum this is the enum type itself.\n */\nexport type WireEnumValue<T extends WireEnumMembers> = Extract<T[keyof T], number>;\n\n/**\n * The member names of `T`.\n */\nexport type WireEnumName<T extends WireEnumMembers> = Extract<keyof T, string>;\n\ninterface WireEnumLookup {\n readonly byOrdinal: ReadonlyMap<number, string>;\n readonly byLowerName: ReadonlyMap<string, string>;\n}\n\nconst NUMERIC_KEY = /^-?\\d+$/;\n\nconst lookups = new WeakMap<WireEnumMembers, WireEnumLookup>();\n\nfunction lookupFor(members: WireEnumMembers): WireEnumLookup {\n const cached = lookups.get(members);\n if (cached) {\n return cached;\n }\n\n const byOrdinal = new Map<number, string>();\n const byLowerName = new Map<string, string>();\n for (const [name, ordinal] of Object.entries(members)) {\n // A TypeScript numeric enum also maps each ordinal back to its name under a numeric key.\n if (NUMERIC_KEY.test(name) || typeof ordinal !== \"number\") {\n continue;\n }\n\n byOrdinal.set(ordinal, name);\n byLowerName.set(name.toLowerCase(), name);\n }\n\n const lookup = { byOrdinal, byLowerName };\n lookups.set(members, lookup);\n return lookup;\n}\n\n/**\n * Decodes an enum value from an MCP tool response to its canonical member name.\n *\n * @remarks\n * Plugin tool responses carry an enum either as its ordinal (the SDK's current output) or as\n * its C# member name (the platform's target form, ethisyscore-protocol#248). A number matches\n * when it is one of the members' ordinals; a string matches a member name in any casing.\n * Anything else, including a numeric string such as `\"2\"`, returns `undefined`, so the caller\n * chooses the fallback.\n *\n * @param members - The C# enum's members as `{ Name: ordinal }`.\n * @param value - The raw wire value.\n * @returns The canonical member name, or `undefined` when nothing matches.\n */\nexport function decodeWireEnumName<const T extends WireEnumMembers>(\n members: T,\n value: unknown,\n): WireEnumName<T> | undefined {\n const lookup = lookupFor(members);\n if (typeof value === \"number\") {\n return lookup.byOrdinal.get(value) as WireEnumName<T> | undefined;\n }\n\n if (typeof value === \"string\") {\n return lookup.byLowerName.get(value.toLowerCase()) as WireEnumName<T> | undefined;\n }\n\n return undefined;\n}\n\n/**\n * Decodes an enum value from an MCP tool response to its ordinal.\n *\n * @remarks\n * Accepts the same forms as {@link decodeWireEnumName}.\n *\n * @param members - The C# enum's members as `{ Name: ordinal }`.\n * @param value - The raw wire value.\n * @returns The member's ordinal, or `undefined` when nothing matches.\n */\nexport function decodeWireEnum<const T extends WireEnumMembers>(\n members: T,\n value: unknown,\n): WireEnumValue<T> | undefined {\n const name = decodeWireEnumName(members, value);\n if (name === undefined) {\n return undefined;\n }\n\n const ordinal: unknown = members[name];\n return isWireEnumValue(members, ordinal) ? ordinal : undefined;\n}\n\nfunction isWireEnumValue<T extends WireEnumMembers>(_members: T, value: unknown): value is WireEnumValue<T> {\n return typeof value === \"number\";\n}\n"]}
@@ -0,0 +1,46 @@
1
+ // src/wire/enum.ts
2
+ var NUMERIC_KEY = /^-?\d+$/;
3
+ var lookups = /* @__PURE__ */ new WeakMap();
4
+ function lookupFor(members) {
5
+ const cached = lookups.get(members);
6
+ if (cached) {
7
+ return cached;
8
+ }
9
+ const byOrdinal = /* @__PURE__ */ new Map();
10
+ const byLowerName = /* @__PURE__ */ new Map();
11
+ for (const [name, ordinal] of Object.entries(members)) {
12
+ if (NUMERIC_KEY.test(name) || typeof ordinal !== "number") {
13
+ continue;
14
+ }
15
+ byOrdinal.set(ordinal, name);
16
+ byLowerName.set(name.toLowerCase(), name);
17
+ }
18
+ const lookup = { byOrdinal, byLowerName };
19
+ lookups.set(members, lookup);
20
+ return lookup;
21
+ }
22
+ function decodeWireEnumName(members, value) {
23
+ const lookup = lookupFor(members);
24
+ if (typeof value === "number") {
25
+ return lookup.byOrdinal.get(value);
26
+ }
27
+ if (typeof value === "string") {
28
+ return lookup.byLowerName.get(value.toLowerCase());
29
+ }
30
+ return void 0;
31
+ }
32
+ function decodeWireEnum(members, value) {
33
+ const name = decodeWireEnumName(members, value);
34
+ if (name === void 0) {
35
+ return void 0;
36
+ }
37
+ const ordinal = members[name];
38
+ return isWireEnumValue(members, ordinal) ? ordinal : void 0;
39
+ }
40
+ function isWireEnumValue(_members, value) {
41
+ return typeof value === "number";
42
+ }
43
+
44
+ export { decodeWireEnum, decodeWireEnumName };
45
+ //# sourceMappingURL=chunk-VJKGDUZ2.js.map
46
+ //# sourceMappingURL=chunk-VJKGDUZ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wire/enum.ts"],"names":[],"mappings":";AAqBA,IAAM,WAAA,GAAc,SAAA;AAEpB,IAAM,OAAA,uBAAc,OAAA,EAAyC;AAE7D,SAAS,UAAU,OAAA,EAA0C;AAC3D,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA;AAClC,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAoB;AAC1C,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAoB;AAC5C,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,OAAO,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAErD,IAAA,IAAI,YAAY,IAAA,CAAK,IAAI,CAAA,IA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 2 } as const`) and a TypeScript numeric `enum` both fit.\n */\nexport type WireEnumMembers = Readonly<Record<string, string | number>>;\n\n/**\n * The ordinal values of `T`. For a TypeScript numeric enum this is the enum type itself.\n */\nexport type WireEnumValue<T extends WireEnumMembers> = Extract<T[keyof T], number>;\n\n/**\n * The member names of `T`.\n */\nexport type WireEnumName<T extends WireEnumMembers> = Extract<keyof T, string>;\n\ninterface WireEnumLookup {\n readonly byOrdinal: ReadonlyMap<number, string>;\n readonly byLowerName: ReadonlyMap<string, string>;\n}\n\nconst NUMERIC_KEY = /^-?\\d+$/;\n\nconst lookups = new WeakMap<WireEnumMembers, WireEnumLookup>();\n\nfunction lookupFor(members: WireEnumMembers): WireEnumLookup {\n const cached = lookups.get(members);\n if (cached) {\n return cached;\n }\n\n const byOrdinal = new Map<number, string>();\n const byLowerName = new Map<string, string>();\n for (const [name, ordinal] of Object.entries(members)) {\n // A TypeScript numeric enum also maps each ordinal back to its name under a numeric key.\n if (NUMERIC_KEY.test(name) || typeof ordinal !== \"number\") {\n continue;\n }\n\n byOrdinal.set(ordinal, name);\n byLowerName.set(name.toLowerCase(), name);\n }\n\n const lookup = { byOrdinal, byLowerName };\n lookups.set(members, lookup);\n return lookup;\n}\n\n/**\n * Decodes an enum value from an MCP tool response to its canonical member name.\n *\n * @remarks\n * Plugin tool responses carry an enum either as its ordinal (the SDK's current output) or as\n * its C# member name (the platform's target form, ethisyscore-protocol#248). A number matches\n * when it is one of the members' ordinals; a string matches a member name in any casing.\n * Anything else, including a numeric string such as `\"2\"`, returns `undefined`, so the caller\n * chooses the fallback.\n *\n * @param members - The C# enum's members as `{ Name: ordinal }`.\n * @param value - The raw wire value.\n * @returns The canonical member name, or `undefined` when nothing matches.\n */\nexport function decodeWireEnumName<const T extends WireEnumMembers>(\n members: T,\n value: unknown,\n): WireEnumName<T> | undefined {\n const lookup = lookupFor(members);\n if (typeof value === \"number\") {\n return lookup.byOrdinal.get(value) as WireEnumName<T> | undefined;\n }\n\n if (typeof value === \"string\") {\n return lookup.byLowerName.get(value.toLowerCase()) as WireEnumName<T> | undefined;\n }\n\n return undefined;\n}\n\n/**\n * Decodes an enum value from an MCP tool response to its ordinal.\n *\n * @remarks\n * Accepts the same forms as {@link decodeWireEnumName}.\n *\n * @param members - The C# enum's members as `{ Name: ordinal }`.\n * @param value - The raw wire value.\n * @returns The member's ordinal, or `undefined` when nothing matches.\n */\nexport function decodeWireEnum<const T extends WireEnumMembers>(\n members: T,\n value: unknown,\n): WireEnumValue<T> | undefined {\n const name = decodeWireEnumName(members, value);\n if (name === undefined) {\n return undefined;\n }\n\n const ordinal: unknown = members[name];\n return isWireEnumValue(members, ordinal) ? ordinal : undefined;\n}\n\nfunction isWireEnumValue<T extends WireEnumMembers>(_members: T, value: unknown): value is WireEnumValue<T> {\n return typeof value === \"number\";\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunk3ZLUSRKU_cjs = require('./chunk-3ZLUSRKU.cjs');
3
4
  var chunkLT7I4JVK_cjs = require('./chunk-LT7I4JVK.cjs');
4
5
  var chunkYNBKRMK3_cjs = require('./chunk-YNBKRMK3.cjs');
5
6
  var chunkP5FSVRZO_cjs = require('./chunk-P5FSVRZO.cjs');
@@ -9,6 +10,14 @@ var chunkRLPXYKSM_cjs = require('./chunk-RLPXYKSM.cjs');
9
10
 
10
11
 
11
12
 
13
+ Object.defineProperty(exports, "decodeWireEnum", {
14
+ enumerable: true,
15
+ get: function () { return chunk3ZLUSRKU_cjs.decodeWireEnum; }
16
+ });
17
+ Object.defineProperty(exports, "decodeWireEnumName", {
18
+ enumerable: true,
19
+ get: function () { return chunk3ZLUSRKU_cjs.decodeWireEnumName; }
20
+ });
12
21
  Object.defineProperty(exports, "computeDateRange", {
13
22
  enumerable: true,
14
23
  get: function () { return chunkLT7I4JVK_cjs.computeDateRange; }
package/dist/index.d.cts CHANGED
@@ -3,3 +3,4 @@ export { JsonPatch, JsonPatchOperation, PatchOperation, applyJsonPatch, deepClon
3
3
  export { ListEnvelope, unwrapList } from './list/index.cjs';
4
4
  export { FormatCompactMoneyOptions, FormatMoneyOptions, MONEY_FALLBACK_CURRENCY, MONEY_FALLBACK_LOCALE, OrgReportingCurrency, formatCompactMoney, formatMoney, getCurrencySymbol, getOrgReportingCurrency, parseMoney, resolveOrgReportingCurrencyCode, setOrgReportingCurrency } from './money/index.cjs';
5
5
  export { NUMBER_FALLBACK_LOCALE, formatNumber, formatPercent } from './number/index.cjs';
6
+ export { WireEnumMembers, WireEnumName, WireEnumValue, decodeWireEnum, decodeWireEnumName } from './wire/index.cjs';
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { JsonPatch, JsonPatchOperation, PatchOperation, applyJsonPatch, deepClon
3
3
  export { ListEnvelope, unwrapList } from './list/index.js';
4
4
  export { FormatCompactMoneyOptions, FormatMoneyOptions, MONEY_FALLBACK_CURRENCY, MONEY_FALLBACK_LOCALE, OrgReportingCurrency, formatCompactMoney, formatMoney, getCurrencySymbol, getOrgReportingCurrency, parseMoney, resolveOrgReportingCurrencyCode, setOrgReportingCurrency } from './money/index.js';
5
5
  export { NUMBER_FALLBACK_LOCALE, formatNumber, formatPercent } from './number/index.js';
6
+ export { WireEnumMembers, WireEnumName, WireEnumValue, decodeWireEnum, decodeWireEnumName } from './wire/index.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { decodeWireEnum, decodeWireEnumName } from './chunk-VJKGDUZ2.js';
1
2
  export { computeDateRange, currentMonthRangeUtc, dateOnlyToIsoUtc, ensureUtcIso, formatDuration, getCurrentOffsetMinutes, getDateRange, hoursToMilliseconds, isoUtcToLocalDateTimeInput, localDateTimeInputToIsoUtc, millisecondsToHours, nowLocalDateTimeInputValue, timespanToMilliseconds, toHHmm, toHHmmss } from './chunk-GAZLFZEL.js';
2
3
  export { AUDIT_DATE_FORMAT, DATE_FORMAT, DAY_DATE_FORMAT, DAY_MONTH_FORMAT, DAY_MONTH_YEAR_FORMAT, DISPLAY_DATETIME_SLASH_FORMAT, DISPLAY_DATE_FORMAT, DISPLAY_DATE_SLASH_FORMAT, DISPLAY_SHORT_DATE_FORMAT, EM_DASH, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, SHORT_DATETIME_FORMAT, TIME_FORMAT, addDaysToIsoDate, addYearsToIsoDate, daysBetweenIso, formatCompactDateTime, formatDate, formatDateSafe, formatDateWithOrdinal, formatMonthDay, formatShortDate, formatSlashDate, formatTimeAgo, getMonthEndIso, getMonthStartIso, getTodayIsoDate, isDateOnlyString, parseIsoDateLocal, relativeTimePhrase, startOfMonthOffset, toDateOnlyString, toIsoDate, validateDateFormat, validateTimeFormat } from './chunk-TN6DXBVD.js';
3
4
  export { applyJsonPatch, deepClone, generateJsonPatch, hasPatches, isNullOrEmpty } from './chunk-OEDAX6WN.js';
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunk3ZLUSRKU_cjs = require('../chunk-3ZLUSRKU.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "decodeWireEnum", {
8
+ enumerable: true,
9
+ get: function () { return chunk3ZLUSRKU_cjs.decodeWireEnum; }
10
+ });
11
+ Object.defineProperty(exports, "decodeWireEnumName", {
12
+ enumerable: true,
13
+ get: function () { return chunk3ZLUSRKU_cjs.decodeWireEnumName; }
14
+ });
15
+ //# sourceMappingURL=index.cjs.map
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The members of a C# enum as the UI mirrors them: member name to ordinal. A `const` object
3
+ * (`{ Hidden: 0, Shown: 2 } as const`) and a TypeScript numeric `enum` both fit.
4
+ */
5
+ type WireEnumMembers = Readonly<Record<string, string | number>>;
6
+ /**
7
+ * The ordinal values of `T`. For a TypeScript numeric enum this is the enum type itself.
8
+ */
9
+ type WireEnumValue<T extends WireEnumMembers> = Extract<T[keyof T], number>;
10
+ /**
11
+ * The member names of `T`.
12
+ */
13
+ type WireEnumName<T extends WireEnumMembers> = Extract<keyof T, string>;
14
+ /**
15
+ * Decodes an enum value from an MCP tool response to its canonical member name.
16
+ *
17
+ * @remarks
18
+ * Plugin tool responses carry an enum either as its ordinal (the SDK's current output) or as
19
+ * its C# member name (the platform's target form, ethisyscore-protocol#248). A number matches
20
+ * when it is one of the members' ordinals; a string matches a member name in any casing.
21
+ * Anything else, including a numeric string such as `"2"`, returns `undefined`, so the caller
22
+ * chooses the fallback.
23
+ *
24
+ * @param members - The C# enum's members as `{ Name: ordinal }`.
25
+ * @param value - The raw wire value.
26
+ * @returns The canonical member name, or `undefined` when nothing matches.
27
+ */
28
+ declare function decodeWireEnumName<const T extends WireEnumMembers>(members: T, value: unknown): WireEnumName<T> | undefined;
29
+ /**
30
+ * Decodes an enum value from an MCP tool response to its ordinal.
31
+ *
32
+ * @remarks
33
+ * Accepts the same forms as {@link decodeWireEnumName}.
34
+ *
35
+ * @param members - The C# enum's members as `{ Name: ordinal }`.
36
+ * @param value - The raw wire value.
37
+ * @returns The member's ordinal, or `undefined` when nothing matches.
38
+ */
39
+ declare function decodeWireEnum<const T extends WireEnumMembers>(members: T, value: unknown): WireEnumValue<T> | undefined;
40
+
41
+ export { type WireEnumMembers, type WireEnumName, type WireEnumValue, decodeWireEnum, decodeWireEnumName };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The members of a C# enum as the UI mirrors them: member name to ordinal. A `const` object
3
+ * (`{ Hidden: 0, Shown: 2 } as const`) and a TypeScript numeric `enum` both fit.
4
+ */
5
+ type WireEnumMembers = Readonly<Record<string, string | number>>;
6
+ /**
7
+ * The ordinal values of `T`. For a TypeScript numeric enum this is the enum type itself.
8
+ */
9
+ type WireEnumValue<T extends WireEnumMembers> = Extract<T[keyof T], number>;
10
+ /**
11
+ * The member names of `T`.
12
+ */
13
+ type WireEnumName<T extends WireEnumMembers> = Extract<keyof T, string>;
14
+ /**
15
+ * Decodes an enum value from an MCP tool response to its canonical member name.
16
+ *
17
+ * @remarks
18
+ * Plugin tool responses carry an enum either as its ordinal (the SDK's current output) or as
19
+ * its C# member name (the platform's target form, ethisyscore-protocol#248). A number matches
20
+ * when it is one of the members' ordinals; a string matches a member name in any casing.
21
+ * Anything else, including a numeric string such as `"2"`, returns `undefined`, so the caller
22
+ * chooses the fallback.
23
+ *
24
+ * @param members - The C# enum's members as `{ Name: ordinal }`.
25
+ * @param value - The raw wire value.
26
+ * @returns The canonical member name, or `undefined` when nothing matches.
27
+ */
28
+ declare function decodeWireEnumName<const T extends WireEnumMembers>(members: T, value: unknown): WireEnumName<T> | undefined;
29
+ /**
30
+ * Decodes an enum value from an MCP tool response to its ordinal.
31
+ *
32
+ * @remarks
33
+ * Accepts the same forms as {@link decodeWireEnumName}.
34
+ *
35
+ * @param members - The C# enum's members as `{ Name: ordinal }`.
36
+ * @param value - The raw wire value.
37
+ * @returns The member's ordinal, or `undefined` when nothing matches.
38
+ */
39
+ declare function decodeWireEnum<const T extends WireEnumMembers>(members: T, value: unknown): WireEnumValue<T> | undefined;
40
+
41
+ export { type WireEnumMembers, type WireEnumName, type WireEnumValue, decodeWireEnum, decodeWireEnumName };
@@ -0,0 +1,3 @@
1
+ export { decodeWireEnum, decodeWireEnumName } from '../chunk-VJKGDUZ2.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethisyscore/core-utils",
3
- "version": "1.148.0",
3
+ "version": "1.149.1",
4
4
  "description": "Framework-agnostic utilities shared by the EthisysCore monolith and plugins: date/time/duration helpers (over date-fns), RFC 6902 JSON Patch generate/apply (over mutative), and list-response envelope normalisation. Pure TypeScript; no React or MUI. The dayjs-backed picker helper lives behind the ./date/dayjs sub-path so the core entry stays dayjs-free.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -46,6 +46,11 @@
46
46
  "types": "./dist/number/index.d.ts",
47
47
  "import": "./dist/number/index.js",
48
48
  "require": "./dist/number/index.cjs"
49
+ },
50
+ "./wire": {
51
+ "types": "./dist/wire/index.d.ts",
52
+ "import": "./dist/wire/index.js",
53
+ "require": "./dist/wire/index.cjs"
49
54
  }
50
55
  },
51
56
  "files": [