@ariestools/sdk
Advanced tools
@@ -132,3 +132,3 @@ // src/asObject.ts | ||
| zodToFactory | ||
| } from "../../zod/neutral/index.mjs"; | ||
| } from "@ariestools/zod"; | ||
| import * as z from "zod/mini"; | ||
@@ -135,0 +135,0 @@ var JsonArrayZod = z.array(z.lazy(() => JsonValueZod)); |
@@ -242,3 +242,3 @@ var __defProp = Object.defineProperty; | ||
| zodToFactory | ||
| } from "../../zod/neutral/index.mjs"; | ||
| } from "@ariestools/zod"; | ||
| import * as z from "zod/mini"; | ||
@@ -245,0 +245,0 @@ var JsonArrayZod = z.array(z.lazy(() => JsonValueZod)); |
@@ -17,3 +17,3 @@ import * as z from 'zod/mini'; | ||
| <T>(value: T): T | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T; | ||
| }; | ||
@@ -23,3 +23,3 @@ /** Parses a value into a JsonValue, throwing if it does not conform. */ | ||
| <T>(value: T): T | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T; | ||
| }; | ||
@@ -31,3 +31,3 @@ /** Type guard that checks if a value is a valid JSON array. */ | ||
| <T>(value: T): (T & unknown[]) | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T & unknown[]; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T & unknown[]; | ||
| }; | ||
@@ -37,3 +37,3 @@ /** Parses a value into a JsonArray, throwing if it does not conform. */ | ||
| <T>(value: T): (T & unknown[]) | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T & unknown[]; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T & unknown[]; | ||
| }; | ||
@@ -45,3 +45,3 @@ /** Type guard that checks if a value is a valid JSON object. */ | ||
| <T>(value: T): (T & Record<string, unknown>) | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T & Record<string, unknown>; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T & Record<string, unknown>; | ||
| }; | ||
@@ -51,4 +51,4 @@ /** Parses a value into a JsonObject, throwing if it does not conform. */ | ||
| <T>(value: T): (T & Record<string, unknown>) | undefined; | ||
| <T>(value: T, assert: import("../../zod/neutral/index.ts").ZodFactoryConfig): T & Record<string, unknown>; | ||
| <T>(value: T, assert: import("@ariestools/zod").ZodFactoryConfig): T & Record<string, unknown>; | ||
| }; | ||
| export {}; |
@@ -32,2 +32,1 @@ export * from '../_pkg/api/neutral/index.ts' | ||
| export * from '../_pkg/url/browser/index-browser.ts' | ||
| export * from '../_pkg/zod/neutral/index.ts' |
@@ -32,2 +32,1 @@ export * from '../_pkg/api/neutral/index.mjs' | ||
| export * from '../_pkg/url/browser/index-browser.mjs' | ||
| export * from '../_pkg/zod/neutral/index.mjs' |
@@ -18,2 +18,1 @@ export type * from '../_pkg/api/neutral/model.ts' | ||
| export type * from '../_pkg/typeof/neutral/model.ts' | ||
| export type * from '../_pkg/zod/neutral/model.ts' |
@@ -18,2 +18,1 @@ export * from '../_pkg/api/neutral/model.mjs' | ||
| export * from '../_pkg/typeof/neutral/model.mjs' | ||
| export * from '../_pkg/zod/neutral/model.mjs' |
@@ -32,2 +32,1 @@ export * from '../_pkg/api/neutral/index.ts' | ||
| export * from '../_pkg/url/node/index-node.ts' | ||
| export * from '../_pkg/zod/neutral/index.ts' |
@@ -32,2 +32,1 @@ export * from '../_pkg/api/neutral/index.mjs' | ||
| export * from '../_pkg/url/node/index-node.mjs' | ||
| export * from '../_pkg/zod/neutral/index.mjs' |
+37
-43
| { | ||
| "name": "@ariestools/sdk", | ||
| "version": "7.0.6", | ||
| "version": "7.0.7", | ||
| "description": "All-in-one umbrella for the Aries Tools TypeScript/JavaScript utility libraries", | ||
@@ -260,10 +260,2 @@ "keywords": [ | ||
| }, | ||
| "./zod": { | ||
| "types": "./dist/neutral/zod.d.ts", | ||
| "default": "./dist/neutral/zod.mjs" | ||
| }, | ||
| "./zod/model": { | ||
| "types": "./dist/neutral/zod.model.d.ts", | ||
| "default": "./dist/neutral/zod.model.mjs" | ||
| }, | ||
| "./package.json": "./package.json" | ||
@@ -278,7 +270,10 @@ }, | ||
| ], | ||
| "dependencies": { | ||
| "@ariestools/zod": "~7.0.7" | ||
| }, | ||
| "devDependencies": { | ||
| "@opentelemetry/api": "~1.9.1", | ||
| "@opentelemetry/sdk-trace-base": "~2.9.0", | ||
| "@xylabs/toolchain": "~8.6.0", | ||
| "@xylabs/tsconfig": "~8.6.0", | ||
| "@xylabs/toolchain": "~8.6.2", | ||
| "@xylabs/tsconfig": "~8.6.2", | ||
| "async-mutex": "~0.5.0", | ||
@@ -292,34 +287,33 @@ "browserslist": "~4.28.4", | ||
| "zod": "~4.4.3", | ||
| "@internal/api": "~7.0.6", | ||
| "@internal/arraybuffer": "~7.0.6", | ||
| "@internal/decimal-precision": "~7.0.6", | ||
| "@internal/delay": "~7.0.6", | ||
| "@internal/array": "~7.0.6", | ||
| "@internal/creatable": "~7.0.6", | ||
| "@internal/enum": "~7.0.6", | ||
| "@internal/error": "~7.0.6", | ||
| "@internal/ellipsize": "~7.0.6", | ||
| "@internal/exists": "~7.0.6", | ||
| "@internal/base": "~7.0.6", | ||
| "@internal/fetch": "~7.0.6", | ||
| "@internal/forget": "~7.0.6", | ||
| "@internal/function-name": "~7.0.6", | ||
| "@internal/events": "~7.0.6", | ||
| "@internal/assert": "~7.0.6", | ||
| "@internal/hex": "~7.0.6", | ||
| "@internal/logger": "~7.0.6", | ||
| "@internal/object": "~7.0.6", | ||
| "@internal/profile": "~7.0.6", | ||
| "@internal/promise": "~7.0.6", | ||
| "@internal/platform": "~7.0.6", | ||
| "@internal/static-implements": "~7.0.6", | ||
| "@internal/retry": "~7.0.6", | ||
| "@internal/set": "~7.0.6", | ||
| "@internal/storage": "~7.0.6", | ||
| "@internal/telemetry-exporter": "~7.0.6", | ||
| "@internal/telemetry": "~7.0.6", | ||
| "@internal/zod": "~7.0.6", | ||
| "@internal/url": "~7.0.6", | ||
| "@internal/typeof": "~7.0.6", | ||
| "@internal/timer": "~7.0.6" | ||
| "@internal/array": "~7.0.7", | ||
| "@internal/api": "~7.0.7", | ||
| "@internal/arraybuffer": "~7.0.7", | ||
| "@internal/assert": "~7.0.7", | ||
| "@internal/creatable": "~7.0.7", | ||
| "@internal/decimal-precision": "~7.0.7", | ||
| "@internal/delay": "~7.0.7", | ||
| "@internal/base": "~7.0.7", | ||
| "@internal/ellipsize": "~7.0.7", | ||
| "@internal/enum": "~7.0.7", | ||
| "@internal/error": "~7.0.7", | ||
| "@internal/events": "~7.0.7", | ||
| "@internal/exists": "~7.0.7", | ||
| "@internal/fetch": "~7.0.7", | ||
| "@internal/forget": "~7.0.7", | ||
| "@internal/function-name": "~7.0.7", | ||
| "@internal/logger": "~7.0.7", | ||
| "@internal/hex": "~7.0.7", | ||
| "@internal/object": "~7.0.7", | ||
| "@internal/retry": "~7.0.7", | ||
| "@internal/promise": "~7.0.7", | ||
| "@internal/profile": "~7.0.7", | ||
| "@internal/platform": "~7.0.7", | ||
| "@internal/static-implements": "~7.0.7", | ||
| "@internal/set": "~7.0.7", | ||
| "@internal/storage": "~7.0.7", | ||
| "@internal/telemetry": "~7.0.7", | ||
| "@internal/timer": "~7.0.7", | ||
| "@internal/telemetry-exporter": "~7.0.7", | ||
| "@internal/url": "~7.0.7", | ||
| "@internal/typeof": "~7.0.7" | ||
| }, | ||
@@ -326,0 +320,0 @@ "peerDependencies": { |
| import type { AssertConfig } from '../../error/neutral/index.ts'; | ||
| /** Configuration object for zod factory functions, providing a name for error messages. */ | ||
| export interface ZodFactoryConfigObject { | ||
| name: string; | ||
| } | ||
| /** Configuration for zod factory assertion behavior, either an AssertConfig or a named config object. */ | ||
| export type ZodFactoryConfig = AssertConfig | ZodFactoryConfigObject; |
| export * from './Config.ts'; | ||
| export * from './zodAllFactory.ts'; | ||
| export * from './zodAsAsyncFactory.ts'; | ||
| export * from './zodAsFactory.ts'; | ||
| export * from './zodIsFactory.ts'; | ||
| export * from './zodToAsyncFactory.ts'; | ||
| export * from './zodToFactory.ts'; |
| // src/zodAsFactory.ts | ||
| import { assertError } from "../../error/neutral/index.mjs"; | ||
| import * as z from "zod/v4/core"; | ||
| var formatZodValue = (value) => { | ||
| const json = JSON.stringify(value); | ||
| return json ?? String(value); | ||
| }; | ||
| function zodAsFactory(zod, name) { | ||
| function asFunc(value, assert) { | ||
| const result = z.safeParse(zod, value); | ||
| if (result.success) { | ||
| return value; | ||
| } | ||
| if (assert !== void 0) { | ||
| let assertConfig; | ||
| switch (typeof assert) { | ||
| case "string": { | ||
| assertConfig = `[${name}][${formatZodValue(value)}] ${assert}`; | ||
| break; | ||
| } | ||
| case "object": { | ||
| assertConfig = `[${name}][${assert.name}][${formatZodValue(value)}] ${result.error.message}`; | ||
| break; | ||
| } | ||
| case "boolean": { | ||
| assertConfig = `[${name}][${formatZodValue(value)}] ${result.error.message}`; | ||
| break; | ||
| } | ||
| case "function": { | ||
| assertConfig = assert(value, result.error.message); | ||
| break; | ||
| } | ||
| } | ||
| return assertError(value, assertConfig, result.error.message); | ||
| } | ||
| } | ||
| return asFunc; | ||
| } | ||
| // src/zodIsFactory.ts | ||
| import * as z2 from "zod/v4/core"; | ||
| function zodIsFactory(zod) { | ||
| return (value) => z2.safeParse(zod, value).success; | ||
| } | ||
| // src/zodToFactory.ts | ||
| import { isDefined } from "../../typeof/neutral/index.mjs"; | ||
| function zodToFactory(zod, name) { | ||
| const as = zodAsFactory(zod, name); | ||
| function toFunc(value, assert) { | ||
| if (isDefined(assert)) { | ||
| return as(value, assert); | ||
| } | ||
| return as(value); | ||
| } | ||
| return toFunc; | ||
| } | ||
| // src/zodAllFactory.ts | ||
| function zodAllFactory(zod, name) { | ||
| return { | ||
| [`is${name}`]: zodIsFactory(zod), | ||
| [`as${name}`]: zodAsFactory(zod, `as${name}`), | ||
| [`to${name}`]: zodToFactory(zod, `to${name}`) | ||
| }; | ||
| } | ||
| // src/zodAsAsyncFactory.ts | ||
| import { assertError as assertError2 } from "../../error/neutral/index.mjs"; | ||
| import * as z3 from "zod/v4/core"; | ||
| var formatZodValue2 = (value) => { | ||
| const json = JSON.stringify(value); | ||
| return json ?? String(value); | ||
| }; | ||
| function zodAsAsyncFactory(zod, name) { | ||
| async function asFunc(value, assert) { | ||
| const result = await z3.safeParseAsync(zod, value); | ||
| if (result.success) { | ||
| return value; | ||
| } | ||
| if (assert !== void 0) { | ||
| let assertConfig; | ||
| switch (typeof assert) { | ||
| case "string": { | ||
| assertConfig = `[${name}][${formatZodValue2(value)}] ${assert}`; | ||
| break; | ||
| } | ||
| case "object": { | ||
| assertConfig = `[${name}][${assert.name}][${formatZodValue2(value)}] ${result.error.message}`; | ||
| break; | ||
| } | ||
| case "boolean": { | ||
| assertConfig = `[${name}][${formatZodValue2(value)}] ${result.error.message}`; | ||
| break; | ||
| } | ||
| case "function": { | ||
| assertConfig = assert(value, result.error.message); | ||
| break; | ||
| } | ||
| } | ||
| return assertError2(value, assertConfig, result.error.message); | ||
| } | ||
| } | ||
| return asFunc; | ||
| } | ||
| // src/zodToAsyncFactory.ts | ||
| import { isDefined as isDefined2 } from "../../typeof/neutral/index.mjs"; | ||
| function zodToAsyncFactory(zod, name) { | ||
| const as = zodAsAsyncFactory(zod, name); | ||
| async function toFunc(value, assert) { | ||
| if (isDefined2(assert)) { | ||
| return await as(value, assert); | ||
| } | ||
| return await as(value); | ||
| } | ||
| return toFunc; | ||
| } | ||
| export { | ||
| zodAllFactory, | ||
| zodAsAsyncFactory, | ||
| zodAsFactory, | ||
| zodIsFactory, | ||
| zodToAsyncFactory, | ||
| zodToFactory | ||
| }; |
| export type * from './Config.ts'; |
| import type * as z from 'zod/v4/core'; | ||
| import { zodAsFactory } from './zodAsFactory.ts'; | ||
| import { zodIsFactory } from './zodIsFactory.ts'; | ||
| import { zodToFactory } from './zodToFactory.ts'; | ||
| /** @alpha */ | ||
| export type AllZodFactories<TType, TName extends string> = Record<`is${TName}`, ReturnType<typeof zodIsFactory<TType>>> & Record<`as${TName}`, ReturnType<typeof zodAsFactory<TType>>> & Record<`to${TName}`, ReturnType<typeof zodToFactory<TType>>>; | ||
| /** | ||
| * Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema. | ||
| * @alpha | ||
| * @param zod - The zod schema to validate against | ||
| * @param name - The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`) | ||
| * @returns An object containing `is<Name>`, `as<Name>`, and `to<Name>` functions | ||
| */ | ||
| export declare function zodAllFactory<T, TName extends string>(zod: z.$ZodType<T>, name: TName): { | ||
| [x: string]: { | ||
| <T_1>(value: T_1): (T_1 & T) | undefined; | ||
| <T_1>(value: T_1, assert: import("./Config.ts").ZodFactoryConfig): T_1 & T; | ||
| }; | ||
| }; |
| import * as z from 'zod/v4/core'; | ||
| import type { ZodFactoryConfig } from './Config.ts'; | ||
| /** | ||
| * Creates an async function that validates a value against a zod schema and returns it with a narrowed type. | ||
| * Uses `safeParseAsync` for schemas with async refinements. When called without an assert config, returns undefined on failure. | ||
| * @param zod - The zod schema to validate against | ||
| * @param name - A name used in error messages for identification | ||
| * @returns An async function that validates and narrows the type of a value | ||
| */ | ||
| export declare function zodAsAsyncFactory<TZod>(zod: z.$ZodType<TZod>, name: string): { | ||
| <T>(value: T): Promise<(T & TZod) | undefined>; | ||
| <T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>; | ||
| }; |
| import * as z from 'zod/v4/core'; | ||
| import type { ZodFactoryConfig } from './Config.ts'; | ||
| /** | ||
| * Creates a function that validates a value against a zod schema and returns it with a narrowed type. | ||
| * When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure. | ||
| * @param zod - The zod schema to validate against | ||
| * @param name - A name used in error messages for identification | ||
| * @returns A function that validates and narrows the type of a value | ||
| */ | ||
| export declare function zodAsFactory<TZod>(zod: z.$ZodType<TZod>, name: string): { | ||
| <T>(value: T): (T & TZod) | undefined; | ||
| <T>(value: T, assert: ZodFactoryConfig): (T & TZod); | ||
| }; |
| import * as z from 'zod/v4/core'; | ||
| /** | ||
| * Creates a type guard function that checks if a value matches a zod schema. | ||
| * @param zod - The zod schema to validate against | ||
| * @returns A type guard function that returns true if the value passes validation | ||
| */ | ||
| export declare function zodIsFactory<TZod>(zod: z.$ZodType<TZod>): <T>(value: T) => value is T & TZod; |
| import type * as z from 'zod/v4/core'; | ||
| import type { ZodFactoryConfig } from './Config.ts'; | ||
| /** | ||
| * Creates an async function that converts a value to the zod schema type, delegating to `zodAsAsyncFactory` internally. | ||
| * Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure. | ||
| * @param zod - The zod schema to validate against | ||
| * @param name - A name used in error messages for identification | ||
| * @returns An async function that validates and converts a value to the schema type | ||
| */ | ||
| export declare function zodToAsyncFactory<TZod>(zod: z.$ZodType<TZod>, name: string): { | ||
| <T>(value: T): Promise<(T & TZod) | undefined>; | ||
| <T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>; | ||
| }; |
| import type * as z from 'zod/v4/core'; | ||
| import type { ZodFactoryConfig } from './Config.ts'; | ||
| /** | ||
| * Creates a function that converts a value to the zod schema type, delegating to `zodAsFactory` internally. | ||
| * Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure. | ||
| * @param zod - The zod schema to validate against | ||
| * @param name - A name used in error messages for identification | ||
| * @returns A function that validates and converts a value to the schema type | ||
| */ | ||
| export declare function zodToFactory<TZod>(zod: z.$ZodType<TZod>, name: string): { | ||
| <T>(value: T): (T & TZod) | undefined; | ||
| <T>(value: T, assert: ZodFactoryConfig): (T & TZod); | ||
| }; |
| export * from '../_pkg/zod/neutral/index.ts' |
| export * from '../_pkg/zod/neutral/index.mjs' |
| export type * from '../_pkg/zod/neutral/model.ts' |
| export * from '../_pkg/zod/neutral/model.mjs' |
43
-2.27%302972
-2.96%5
25%393
-3.68%6990
-3.11%+ Added
+ Added
+ Added