@bessemer/cornerstone 0.5.45 → 0.5.46

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,12 @@
1
+ import Zod, { ZodType } from 'zod';
2
+ import { NominalType } from '@bessemer/cornerstone/types';
3
+ export type AspectRatio = NominalType<string, 'AspectRatio'>;
4
+ export declare const buildSchema: (fieldName?: string) => ZodType<AspectRatio>;
5
+ export declare const AspectRatioSchema: Zod.ZodType<AspectRatio, Zod.ZodTypeDef, AspectRatio>;
6
+ export declare const of: (aspectRatio: string) => AspectRatio;
7
+ export declare const fromString: (aspectRatio: string) => AspectRatio;
8
+ export declare const fromDimensions: (width: number, height: number) => AspectRatio;
9
+ export declare const numericValue: (aspectRatio: AspectRatio) => number;
10
+ export declare const calculateHeight: (width: number, aspectRatio: AspectRatio) => number;
11
+ export declare const calculateWidth: (height: number, aspectRatio: AspectRatio) => number;
12
+ //# sourceMappingURL=aspect-ratio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aspect-ratio.d.ts","sourceRoot":"","sources":["../src/aspect-ratio.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAE5D,eAAO,MAAM,WAAW,GAAI,YAAW,MAAuB,KAAG,OAAO,CAAC,WAAW,CAMnF,CAAA;AAED,eAAO,MAAM,iBAAiB,uDAAgB,CAAA;AAE9C,eAAO,MAAM,EAAE,GAAI,aAAa,MAAM,KAAG,WAExC,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,aAAa,MAAM,KAAG,WAEhD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,WAK9D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,aAAa,WAAW,KAAG,MAGvD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,aAAa,WAAW,KAAG,MAGzE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,aAAa,WAAW,KAAG,MAGzE,CAAA"}
@@ -0,0 +1,44 @@
1
+ // src/aspect-ratio.ts
2
+ import Zod from "zod";
3
+ import { greatestCommonFactor } from "@bessemer/cornerstone/math";
4
+ var buildSchema = (fieldName = "Aspect Ratio") => {
5
+ return Zod.string({
6
+ required_error: `${fieldName} is required`
7
+ }).trim().regex(/^[1-9]\d*:[1-9]\d*$/, `${fieldName} must be in the format 'width:height' (e.g., '16:9', '4:3')`);
8
+ };
9
+ var AspectRatioSchema = buildSchema();
10
+ var of = (aspectRatio) => {
11
+ return aspectRatio;
12
+ };
13
+ var fromString = (aspectRatio) => {
14
+ return AspectRatioSchema.parse(aspectRatio);
15
+ };
16
+ var fromDimensions = (width, height) => {
17
+ const factor = greatestCommonFactor(width, height);
18
+ const ratioWidth = width / factor;
19
+ const ratioHeight = height / factor;
20
+ return `${ratioWidth}:${ratioHeight}`;
21
+ };
22
+ var numericValue = (aspectRatio) => {
23
+ const [width, height] = aspectRatio.split(":").map(Number);
24
+ return width / height;
25
+ };
26
+ var calculateHeight = (width, aspectRatio) => {
27
+ const ratio = numericValue(aspectRatio);
28
+ return width / ratio;
29
+ };
30
+ var calculateWidth = (height, aspectRatio) => {
31
+ const ratio = numericValue(aspectRatio);
32
+ return height * ratio;
33
+ };
34
+ export {
35
+ AspectRatioSchema,
36
+ buildSchema,
37
+ calculateHeight,
38
+ calculateWidth,
39
+ fromDimensions,
40
+ fromString,
41
+ numericValue,
42
+ of
43
+ };
44
+ //# sourceMappingURL=aspect-ratio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/aspect-ratio.ts"],"sourcesContent":["import Zod, { ZodType } from 'zod'\nimport { greatestCommonFactor } from '@bessemer/cornerstone/math'\nimport { NominalType } from '@bessemer/cornerstone/types'\n\nexport type AspectRatio = NominalType<string, 'AspectRatio'>\n\nexport const buildSchema = (fieldName: string = 'Aspect Ratio'): ZodType<AspectRatio> => {\n return Zod.string({\n required_error: `${fieldName} is required`,\n })\n .trim()\n .regex(/^[1-9]\\d*:[1-9]\\d*$/, `${fieldName} must be in the format 'width:height' (e.g., '16:9', '4:3')`)\n}\n\nexport const AspectRatioSchema = buildSchema()\n\nexport const of = (aspectRatio: string): AspectRatio => {\n return aspectRatio\n}\n\nexport const fromString = (aspectRatio: string): AspectRatio => {\n return AspectRatioSchema.parse(aspectRatio)\n}\n\nexport const fromDimensions = (width: number, height: number): AspectRatio => {\n const factor = greatestCommonFactor(width, height)\n const ratioWidth = width / factor\n const ratioHeight = height / factor\n return `${ratioWidth}:${ratioHeight}`\n}\n\nexport const numericValue = (aspectRatio: AspectRatio): number => {\n const [width, height] = aspectRatio.split(':').map(Number)\n return width! / height!\n}\n\nexport const calculateHeight = (width: number, aspectRatio: AspectRatio): number => {\n const ratio = numericValue(aspectRatio)\n return width / ratio\n}\n\nexport const calculateWidth = (height: number, aspectRatio: AspectRatio): number => {\n const ratio = numericValue(aspectRatio)\n return height * ratio\n}\n"],"mappings":";AAAA,OAAO,SAAsB;AAC7B,SAAS,4BAA4B;AAK9B,IAAM,cAAc,CAAC,YAAoB,mBAAyC;AACvF,SAAO,IAAI,OAAO;AAAA,IAChB,gBAAgB,GAAG,SAAS;AAAA,EAC9B,CAAC,EACE,KAAK,EACL,MAAM,uBAAuB,GAAG,SAAS,6DAA6D;AAC3G;AAEO,IAAM,oBAAoB,YAAY;AAEtC,IAAM,KAAK,CAAC,gBAAqC;AACtD,SAAO;AACT;AAEO,IAAM,aAAa,CAAC,gBAAqC;AAC9D,SAAO,kBAAkB,MAAM,WAAW;AAC5C;AAEO,IAAM,iBAAiB,CAAC,OAAe,WAAgC;AAC5E,QAAM,SAAS,qBAAqB,OAAO,MAAM;AACjD,QAAM,aAAa,QAAQ;AAC3B,QAAM,cAAc,SAAS;AAC7B,SAAO,GAAG,UAAU,IAAI,WAAW;AACrC;AAEO,IAAM,eAAe,CAAC,gBAAqC;AAChE,QAAM,CAAC,OAAO,MAAM,IAAI,YAAY,MAAM,GAAG,EAAE,IAAI,MAAM;AACzD,SAAO,QAAS;AAClB;AAEO,IAAM,kBAAkB,CAAC,OAAe,gBAAqC;AAClF,QAAM,QAAQ,aAAa,WAAW;AACtC,SAAO,QAAQ;AACjB;AAEO,IAAM,iBAAiB,CAAC,QAAgB,gBAAqC;AAClF,QAAM,QAAQ,aAAa,WAAW;AACtC,SAAO,SAAS;AAClB;","names":[]}
package/dist/cache.d.ts CHANGED
@@ -6,7 +6,7 @@ import { NominalType } from '@bessemer/cornerstone/types';
6
6
  import { Entry } from '@bessemer/cornerstone/entry';
7
7
  import { GlobPattern } from '@bessemer/cornerstone/glob';
8
8
  import { Arrayable } from 'type-fest';
9
- import { ZodType } from 'zod/v4';
9
+ import { ZodType } from 'zod';
10
10
  export type CacheProps = {
11
11
  maxSize: number | null;
12
12
  timeToLive: Duration;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAE9I,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM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AAU,GAAI,CAAC,EAAE,eAAe,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,UAAU,KAAG,UAAU,CAAC,CAAC,CAwB3F,CAAA;CACF;AAED,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG;IAClE,KAAK,EAAE,yBAAyB,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,eAAe,CAAA;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;CAClD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;AACxE,MAAM,MAAM,0BAA0B,GAAG,YAAY,GAAG;IACtD,IAAI,EAAE,iBAAiB,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,GAAG;IAC3D,KAAK,EAAE,yBAAyB,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,WAAW,SAAS,0BAA0B,IAAI;IAClF,IAAI,EAAE,iBAAiB,CAAA;IACvB,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,CAAA;CAC5E,CAAA"}
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cache.ts"],"sourcesContent":["import { AbstractLocalKeyValueStore, AbstractRemoteKeyValueStore, LocalKeyValueStore, RemoteKeyValueStore } from '@bessemer/cornerstone/store'\nimport { Arrays, Dates, Durations, Objects, Strings, Zod } from '@bessemer/cornerstone'\nimport { Duration } from '@bessemer/cornerstone/duration'\nimport { ResourceKey, ResourceNamespace } from '@bessemer/cornerstone/resource'\nimport { AbstractApplicationContext } from '@bessemer/cornerstone/context'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { GlobPattern } from '@bessemer/cornerstone/glob'\nimport { Arrayable } from 'type-fest'\nimport { ZodType } from 'zod/v4'\n\n// JOHN should this even be in cornerstone? especially consider the config types down at the bottom\n\nexport type CacheProps = {\n maxSize: number | null\n timeToLive: Duration\n timeToStale: Duration | null\n}\n\nexport type CacheOptions = Partial<CacheProps>\n\nexport namespace CacheProps {\n const DefaultCacheProps = {\n maxSize: 50000,\n timeToLive: Durations.OneDay,\n timeToStale: Durations.OneHour,\n }\n\n export const buildCacheProps = (options?: CacheOptions): CacheProps => {\n options = options ?? {}\n\n const props = Objects.deepMerge(DefaultCacheProps, options)\n\n if (props.maxSize === null && props.timeToLive === null) {\n throw new Error('Invalid cache configuration, both maxSize and timeToLive are null')\n }\n\n return props\n }\n}\n\nexport namespace CacheKey {\n // We use a hardcoded UUID to represent a unique token value that serves as a flag to disable caching\n const DisableCacheToken = 'f6822c1a-d527-4c65-b9dd-ddc24620b684'\n\n export const disableCaching = (): ResourceNamespace => {\n return DisableCacheToken\n }\n\n export const isDisabled = (key: ResourceNamespace): boolean => {\n return Strings.contains(key, DisableCacheToken)\n }\n}\n\nexport type CacheSector = {\n globs: Array<GlobPattern>\n}\n\nexport namespace CacheSector {\n export const of = (globs: Arrayable<GlobPattern>) => {\n return { globs: Arrays.toArray(globs) }\n }\n\n export const namespace = (namespace: ResourceNamespace, sector: CacheSector): CacheSector => {\n return { globs: ResourceKey.namespaceAll(namespace, sector.globs) }\n }\n}\n\nexport type CacheName = NominalType<string, 'CacheName'>\nexport const CacheNameSchema: ZodType<CacheName> = Zod.string()\n\nexport interface AbstractCache<T> {\n name: CacheName\n}\n\nexport interface Cache<T> extends AbstractCache<T> {\n fetchValue(namespace: ResourceNamespace, key: ResourceKey, fetch: () => Promise<T>): Promise<T>\n\n fetchValues(\n namespace: ResourceNamespace,\n keys: Array<ResourceKey>,\n fetch: (keys: Array<ResourceKey>) => Promise<Array<Entry<T>>>\n ): Promise<Array<Entry<T>>>\n\n writeValue(namespace: ResourceNamespace, key: ResourceKey, value: T | undefined): Promise<void>\n\n writeValues(namespace: ResourceNamespace, entries: Array<Entry<T | undefined>>): Promise<void>\n\n evictAll(sector: CacheSector): Promise<void>\n}\n\nexport interface CacheProvider<T> extends RemoteKeyValueStore<CacheEntry<T>> {\n type: CacheProviderType\n\n evictAll(sector: CacheSector): Promise<void>\n}\n\nexport abstract class AbstractCacheProvider<T> extends AbstractRemoteKeyValueStore<CacheEntry<T>> implements CacheProvider<T> {\n abstract type: CacheProviderType\n\n abstract evictAll(sector: CacheSector): Promise<void>\n}\n\nexport interface LocalCache<T> extends AbstractCache<T> {\n getValue(namespace: ResourceNamespace, key: ResourceKey, fetch: () => T): T\n\n getValues(namespace: ResourceNamespace, keys: Array<ResourceKey>, fetch: (keys: Array<ResourceKey>) => Array<Entry<T>>): Array<Entry<T>>\n\n setValue(namespace: ResourceNamespace, key: ResourceKey, value: T | undefined): void\n\n setValues(namespace: ResourceNamespace, entries: Array<Entry<T | undefined>>): void\n\n removeAll(sector: CacheSector): void\n}\n\nexport interface LocalCacheProvider<T> extends LocalKeyValueStore<CacheEntry<T>>, CacheProvider<T> {\n removeAll(sector: CacheSector): void\n}\n\nexport abstract class AbstractLocalCacheProvider<T> extends AbstractLocalKeyValueStore<CacheEntry<T>> implements LocalCacheProvider<T> {\n abstract type: CacheProviderType\n\n abstract removeAll(sector: CacheSector): void\n\n async evictAll(sector: CacheSector): Promise<void> {\n this.removeAll(sector)\n }\n}\n\nexport type CacheEntry<T> = {\n value: T\n liveTimestamp: Date | null\n staleTimestamp: Date | null\n}\n\nexport namespace CacheEntry {\n export const isActive = <T>(entry: CacheEntry<T>): boolean => {\n if (isDead(entry) || isStale(entry)) {\n return false\n }\n\n return true\n }\n\n export const isDead = <T>(entry: CacheEntry<T> | undefined): boolean => {\n if (Objects.isNil(entry)) {\n return true\n }\n\n if (Objects.isNil(entry.liveTimestamp)) {\n return false\n }\n\n return Dates.isBefore(entry.liveTimestamp, Dates.now())\n }\n\n export const isAlive = <T>(entry: CacheEntry<T> | undefined): boolean => !isDead(entry)\n\n export const isStale = <T>(entry: CacheEntry<T>): boolean => {\n if (Objects.isNil(entry.staleTimestamp)) {\n return false\n }\n\n return Dates.isBefore(entry.staleTimestamp, Dates.now())\n }\n\n export const of = <T>(value: T) => {\n const entry: CacheEntry<T> = {\n value,\n liveTimestamp: null,\n staleTimestamp: null,\n }\n\n return entry\n }\n\n // JOHN do we want to enforce some kind of minimum liveness threshold?\n export const applyProps = <T>(originalEntry: CacheEntry<T>, props: CacheProps): CacheEntry<T> => {\n let liveTimestamp: Date | null = originalEntry.liveTimestamp\n if (!Objects.isNil(props.timeToLive)) {\n const limit = Dates.addMilliseconds(Dates.now(), Durations.inMilliseconds(props.timeToLive))\n if (Dates.isBefore(limit, liveTimestamp ?? limit)) {\n liveTimestamp = limit\n }\n }\n\n let staleTimestamp: Date | null = originalEntry.staleTimestamp\n if (!Objects.isNil(props.timeToStale)) {\n const limit = Dates.addMilliseconds(Dates.now(), Durations.inMilliseconds(props.timeToStale))\n if (Dates.isBefore(limit, staleTimestamp ?? limit)) {\n staleTimestamp = limit\n }\n }\n\n const limitedEntry: CacheEntry<T> = {\n value: originalEntry.value,\n liveTimestamp,\n staleTimestamp,\n }\n\n return limitedEntry\n }\n}\n\nexport type CacheConfigurationOptions = CacheConfigurationSection & {\n local: CacheConfigurationSection\n}\n\nexport type CacheConfigurationSection = {\n defaults: CacheDefinition\n\n /**\n * These options map from cache name key to configuration. They are a way for the tenant to override the configurations\n * for specific caches from the cache configuration here.\n */\n caches?: Record<string, Partial<CacheDefinition>>\n}\n\nexport type CacheDefinition = {\n options?: CacheOptions\n providers: Array<CacheProviderConfiguration>\n}\n\nexport type CacheProviderType = NominalType<string, 'CacheProviderType'>\nexport type CacheProviderConfiguration = CacheOptions & {\n type: CacheProviderType\n}\n\nexport type CacheConfiguration = CacheConfigurationSection & {\n local: CacheConfigurationSection\n}\n\nexport type CacheProviderRegistry<ContextType extends AbstractApplicationContext> = {\n type: CacheProviderType\n construct: <T>(props: CacheProps, context: ContextType) => CacheProvider<T>\n}\n"],"mappings":";AAAA,SAAS,4BAA4B,mCAA4E;AACjH,SAAS,QAAQ,OAAO,WAAW,SAAS,SAAS,WAAW;AAEhE,SAAS,mBAAsC;AAkBxC,IAAU;AAAA,CAAV,CAAUA,gBAAV;AACL,QAAM,oBAAoB;AAAA,IACxB,SAAS;AAAA,IACT,YAAY,UAAU;AAAA,IACtB,aAAa,UAAU;AAAA,EACzB;AAEO,EAAMA,YAAA,kBAAkB,CAAC,YAAuC;AACrE,cAAU,WAAW,CAAC;AAEtB,UAAM,QAAQ,QAAQ,UAAU,mBAAmB,OAAO;AAE1D,QAAI,MAAM,YAAY,QAAQ,MAAM,eAAe,MAAM;AACvD,YAAM,IAAI,MAAM,mEAAmE;AAAA,IACrF;AAEA,WAAO;AAAA,EACT;AAAA,GAjBe;AAoBV,IAAU;AAAA,CAAV,CAAUC,cAAV;AAEL,QAAM,oBAAoB;AAEnB,EAAMA,UAAA,iBAAiB,MAAyB;AACrD,WAAO;AAAA,EACT;AAEO,EAAMA,UAAA,aAAa,CAAC,QAAoC;AAC7D,WAAO,QAAQ,SAAS,KAAK,iBAAiB;AAAA,EAChD;AAAA,GAVe;AAiBV,IAAU;AAAA,CAAV,CAAUC,iBAAV;AACE,EAAMA,aAAA,KAAK,CAAC,UAAkC;AACnD,WAAO,EAAE,OAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,EACxC;AAEO,EAAMA,aAAA,YAAY,CAACC,YAA8B,WAAqC;AAC3F,WAAO,EAAE,OAAO,YAAY,aAAaA,YAAW,OAAO,KAAK,EAAE;AAAA,EACpE;AAAA,GAPe;AAWV,IAAM,kBAAsC,IAAI,OAAO;AA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AAAA,IACF;AAEA,QAAI,iBAA8B,cAAc;AAChD,QAAI,CAAC,QAAQ,MAAM,MAAM,WAAW,GAAG;AACrC,YAAM,QAAQ,MAAM,gBAAgB,MAAM,IAAI,GAAG,UAAU,eAAe,MAAM,WAAW,CAAC;AAC5F,UAAI,MAAM,SAAS,OAAO,kBAAkB,KAAK,GAAG;AAClD,yBAAiB;AAAA,MACnB;AAAA,IACF;AAEA,UAAM,eAA8B;AAAA,MAClC,OAAO,cAAc;AAAA,MACrB;AAAA,MACA;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,GAlEe;","names":["CacheProps","CacheKey","CacheSector","namespace","CacheEntry"]}
1
+ {"version":3,"sources":["../src/cache.ts"],"sourcesContent":["import { AbstractLocalKeyValueStore, AbstractRemoteKeyValueStore, LocalKeyValueStore, RemoteKeyValueStore } from '@bessemer/cornerstone/store'\nimport { Arrays, Dates, Durations, Objects, Strings, Zod } from '@bessemer/cornerstone'\nimport { Duration } from '@bessemer/cornerstone/duration'\nimport { ResourceKey, ResourceNamespace } from '@bessemer/cornerstone/resource'\nimport { AbstractApplicationContext } from '@bessemer/cornerstone/context'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { GlobPattern } from '@bessemer/cornerstone/glob'\nimport { Arrayable } from 'type-fest'\nimport { ZodType } from 'zod'\n\n// JOHN should this even be in cornerstone? especially consider the config types down at the bottom\n\nexport type CacheProps = {\n maxSize: number | null\n timeToLive: Duration\n timeToStale: Duration | null\n}\n\nexport type CacheOptions = Partial<CacheProps>\n\nexport namespace CacheProps {\n const DefaultCacheProps = {\n maxSize: 50000,\n timeToLive: Durations.OneDay,\n timeToStale: Durations.OneHour,\n }\n\n export const buildCacheProps = (options?: CacheOptions): CacheProps => {\n options = options ?? {}\n\n const props = Objects.deepMerge(DefaultCacheProps, options)\n\n if (props.maxSize === null && props.timeToLive === null) {\n throw new Error('Invalid cache configuration, both maxSize and timeToLive are null')\n }\n\n return props\n }\n}\n\nexport namespace CacheKey {\n // We use a hardcoded UUID to represent a unique token value that serves as a flag to disable caching\n const DisableCacheToken = 'f6822c1a-d527-4c65-b9dd-ddc24620b684'\n\n export const disableCaching = (): ResourceNamespace => {\n return DisableCacheToken\n }\n\n export const isDisabled = (key: ResourceNamespace): boolean => {\n return Strings.contains(key, DisableCacheToken)\n }\n}\n\nexport type CacheSector = {\n globs: Array<GlobPattern>\n}\n\nexport namespace CacheSector {\n export const of = (globs: Arrayable<GlobPattern>) => {\n return { globs: Arrays.toArray(globs) }\n }\n\n export const namespace = (namespace: ResourceNamespace, sector: CacheSector): CacheSector => {\n return { globs: ResourceKey.namespaceAll(namespace, sector.globs) }\n }\n}\n\nexport type CacheName = NominalType<string, 'CacheName'>\nexport const CacheNameSchema: ZodType<CacheName> = Zod.string()\n\nexport interface AbstractCache<T> {\n name: CacheName\n}\n\nexport interface Cache<T> extends AbstractCache<T> {\n fetchValue(namespace: ResourceNamespace, key: ResourceKey, fetch: () => Promise<T>): Promise<T>\n\n fetchValues(\n namespace: ResourceNamespace,\n keys: Array<ResourceKey>,\n fetch: (keys: Array<ResourceKey>) => Promise<Array<Entry<T>>>\n ): Promise<Array<Entry<T>>>\n\n writeValue(namespace: ResourceNamespace, key: ResourceKey, value: T | undefined): Promise<void>\n\n writeValues(namespace: ResourceNamespace, entries: Array<Entry<T | undefined>>): Promise<void>\n\n evictAll(sector: CacheSector): Promise<void>\n}\n\nexport interface CacheProvider<T> extends RemoteKeyValueStore<CacheEntry<T>> {\n type: CacheProviderType\n\n evictAll(sector: CacheSector): Promise<void>\n}\n\nexport abstract class AbstractCacheProvider<T> extends AbstractRemoteKeyValueStore<CacheEntry<T>> implements CacheProvider<T> {\n abstract type: CacheProviderType\n\n abstract evictAll(sector: CacheSector): Promise<void>\n}\n\nexport interface LocalCache<T> extends AbstractCache<T> {\n getValue(namespace: ResourceNamespace, key: ResourceKey, fetch: () => T): T\n\n getValues(namespace: ResourceNamespace, keys: Array<ResourceKey>, fetch: (keys: Array<ResourceKey>) => Array<Entry<T>>): Array<Entry<T>>\n\n setValue(namespace: ResourceNamespace, key: ResourceKey, value: T | undefined): void\n\n setValues(namespace: ResourceNamespace, entries: Array<Entry<T | undefined>>): void\n\n removeAll(sector: CacheSector): void\n}\n\nexport interface LocalCacheProvider<T> extends LocalKeyValueStore<CacheEntry<T>>, CacheProvider<T> {\n removeAll(sector: CacheSector): void\n}\n\nexport abstract class AbstractLocalCacheProvider<T> extends AbstractLocalKeyValueStore<CacheEntry<T>> implements LocalCacheProvider<T> {\n abstract type: CacheProviderType\n\n abstract removeAll(sector: CacheSector): void\n\n async evictAll(sector: CacheSector): Promise<void> {\n this.removeAll(sector)\n }\n}\n\nexport type CacheEntry<T> = {\n value: T\n liveTimestamp: Date | null\n staleTimestamp: Date | null\n}\n\nexport namespace CacheEntry {\n export const isActive = <T>(entry: CacheEntry<T>): boolean => {\n if (isDead(entry) || isStale(entry)) {\n return false\n }\n\n return true\n }\n\n export const isDead = <T>(entry: CacheEntry<T> | undefined): boolean => {\n if (Objects.isNil(entry)) {\n return true\n }\n\n if (Objects.isNil(entry.liveTimestamp)) {\n return false\n }\n\n return Dates.isBefore(entry.liveTimestamp, Dates.now())\n }\n\n export const isAlive = <T>(entry: CacheEntry<T> | undefined): boolean => !isDead(entry)\n\n export const isStale = <T>(entry: CacheEntry<T>): boolean => {\n if (Objects.isNil(entry.staleTimestamp)) {\n return false\n }\n\n return Dates.isBefore(entry.staleTimestamp, Dates.now())\n }\n\n export const of = <T>(value: T) => {\n const entry: CacheEntry<T> = {\n value,\n liveTimestamp: null,\n staleTimestamp: null,\n }\n\n return entry\n }\n\n // JOHN do we want to enforce some kind of minimum liveness threshold?\n export const applyProps = <T>(originalEntry: CacheEntry<T>, props: CacheProps): CacheEntry<T> => {\n let liveTimestamp: Date | null = originalEntry.liveTimestamp\n if (!Objects.isNil(props.timeToLive)) {\n const limit = Dates.addMilliseconds(Dates.now(), Durations.inMilliseconds(props.timeToLive))\n if (Dates.isBefore(limit, liveTimestamp ?? limit)) {\n liveTimestamp = limit\n }\n }\n\n let staleTimestamp: Date | null = originalEntry.staleTimestamp\n if (!Objects.isNil(props.timeToStale)) {\n const limit = Dates.addMilliseconds(Dates.now(), Durations.inMilliseconds(props.timeToStale))\n if (Dates.isBefore(limit, staleTimestamp ?? limit)) {\n staleTimestamp = limit\n }\n }\n\n const limitedEntry: CacheEntry<T> = {\n value: originalEntry.value,\n liveTimestamp,\n staleTimestamp,\n }\n\n return limitedEntry\n }\n}\n\nexport type CacheConfigurationOptions = CacheConfigurationSection & {\n local: CacheConfigurationSection\n}\n\nexport type CacheConfigurationSection = {\n defaults: CacheDefinition\n\n /**\n * These options map from cache name key to configuration. They are a way for the tenant to override the configurations\n * for specific caches from the cache configuration here.\n */\n caches?: Record<string, Partial<CacheDefinition>>\n}\n\nexport type CacheDefinition = {\n options?: CacheOptions\n providers: Array<CacheProviderConfiguration>\n}\n\nexport type CacheProviderType = NominalType<string, 'CacheProviderType'>\nexport type CacheProviderConfiguration = CacheOptions & {\n type: CacheProviderType\n}\n\nexport type CacheConfiguration = CacheConfigurationSection & {\n local: CacheConfigurationSection\n}\n\nexport type CacheProviderRegistry<ContextType extends AbstractApplicationContext> = {\n type: CacheProviderType\n construct: <T>(props: CacheProps, context: ContextType) => CacheProvider<T>\n}\n"],"mappings":";AAAA,SAAS,4BAA4B,mCAA4E;AACjH,SAAS,QAAQ,OAAO,WAAW,SAAS,SAAS,WAAW;AAEhE,SAAS,mBAAsC;AAkBxC,IAAU;AAAA,CAAV,CAAUA,gBAAV;AACL,QAAM,oBAAoB;AAAA,IACxB,SAAS;AAAA,IACT,YAAY,UAAU;AAAA,IACtB,aAAa,UAAU;AAAA,EACzB;AAEO,EAAMA,YAAA,kBAAkB,CAAC,YAAuC;AACrE,cAAU,WAAW,CAAC;AAEtB,UAAM,QAAQ,QAAQ,UAAU,mBAAmB,OAAO;AAE1D,QAAI,MAAM,YAAY,QAAQ,M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KAACA,YAAA,QAAO,KAAK;AAE/E,EAAMA,YAAA,UAAU,CAAI,UAAkC;AAC3D,QAAI,QAAQ,MAAM,MAAM,cAAc,GAAG;AACvC,aAAO;AAAA,IACT;AAEA,WAAO,MAAM,SAAS,MAAM,gBAAgB,MAAM,IAAI,CAAC;AAAA,EACzD;AAEO,EAAMA,YAAA,KAAK,CAAI,UAAa;AACjC,UAAM,QAAuB;AAAA,MAC3B;AAAA,MACA,eAAe;AAAA,MACf,gBAAgB;AAAA,IAClB;AAEA,WAAO;AAAA,EACT;AAGO,EAAMA,YAAA,aAAa,CAAI,eAA8B,UAAqC;AAC/F,QAAI,gBAA6B,cAAc;AAC/C,QAAI,CAAC,QAAQ,MAAM,MAAM,UAAU,GAAG;AACpC,YAAM,QAAQ,MAAM,gBAAgB,MAAM,IAAI,GAAG,UAAU,eAAe,MAAM,UAAU,CAAC;AAC3F,UAAI,MAAM,SAAS,OAAO,iBAAiB,KAAK,GAAG;AACjD,wBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,QAAI,iBAA8B,cAAc;AAChD,QAAI,CAAC,QAAQ,MAAM,MAAM,WAAW,GAAG;AACrC,YAAM,QAAQ,MAAM,gBAAgB,MAAM,IAAI,GAAG,UAAU,eAAe,MAAM,WAAW,CAAC;AAC5F,UAAI,MAAM,SAAS,OAAO,kBAAkB,KAAK,GAAG;AAClD,yBAAiB;AAAA,MACnB;AAAA,IACF;AAEA,UAAM,eAA8B;AAAA,MAClC,OAAO,cAAc;AAAA,MACrB;AAAA,MACA;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,GAlEe;","names":["CacheProps","CacheKey","CacheSector","namespace","CacheEntry"]}
package/dist/content.d.ts CHANGED
@@ -3,7 +3,7 @@ import { NominalType } from '@bessemer/cornerstone/types';
3
3
  import { AbstractApplicationContext } from '@bessemer/cornerstone/context';
4
4
  import { RichTextJson } from '@bessemer/cornerstone/rich-text';
5
5
  import { Tag } from '@bessemer/cornerstone/tag';
6
- import { ZodType } from 'zod/v4';
6
+ import { ZodType } from 'zod';
7
7
  export type ContentSector = NominalType<string, 'ContentSector'>;
8
8
  export declare const ContentSectorSchema: ZodType<ContentSector>;
9
9
  export type ContentKey = NominalType<string, 'ContentKey'>;
@@ -12,12 +12,22 @@ export type ContentType<Data = unknown> = NominalType<string, ['ContentType', Da
12
12
  export declare const ContentTypeSchema: ZodType<ContentType>;
13
13
  export type ContentReference = Reference<'Content'>;
14
14
  type ContentDataType<Type> = Type extends ContentType<infer Data> ? Data : never;
15
- export declare const ContentDataSchema: import("zod/v4").ZodObject<{
16
- key: ZodType<ContentKey, unknown>;
17
- type: ZodType<ContentType<unknown>, unknown>;
18
- data: import("zod/v4").ZodUnknown;
19
- sector: import("zod/v4").ZodNullable<ZodType<ContentSector, unknown>>;
20
- }, import("zod/v4/core").$strip>;
15
+ export declare const ContentDataSchema: import("zod").ZodObject<{
16
+ key: ZodType<ContentKey, import("zod").ZodTypeDef, ContentKey>;
17
+ type: ZodType<ContentType<unknown>, import("zod").ZodTypeDef, ContentType<unknown>>;
18
+ data: import("zod").ZodUnknown;
19
+ sector: import("zod").ZodNullable<ZodType<ContentSector, import("zod").ZodTypeDef, ContentSector>>;
20
+ }, "strip", import("zod").ZodTypeAny, {
21
+ key: string & import("@bessemer/cornerstone/types").NominalTyping<"ContentKey">;
22
+ type: string & import("@bessemer/cornerstone/types").NominalTyping<["ContentType", unknown]>;
23
+ sector: ContentSector | null;
24
+ data?: unknown;
25
+ }, {
26
+ key: string & import("@bessemer/cornerstone/types").NominalTyping<"ContentKey">;
27
+ type: string & import("@bessemer/cornerstone/types").NominalTyping<["ContentType", unknown]>;
28
+ sector: ContentSector | null;
29
+ data?: unknown;
30
+ }>;
21
31
  export type ContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = Referencable<ContentReference> & {
22
32
  key: ContentKey;
23
33
  type: Type;
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],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SAAS,KAAK,CAAC,iBAAiB,CAAC,EACjC,cAAc,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,KACzD,eAAe,CAAC,kBAAkB,CA2BpC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/content.ts"],"sourcesContent":["import { Referencable, Reference, ReferenceType } from '@bessemer/cornerstone/reference'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { AbstractApplicationContext } from '@bessemer/cornerstone/context'\nimport { Arrays, Objects, References, Tags, Ulids, Zod } from '@bessemer/cornerstone'\nimport { RichTextJson } from '@bessemer/cornerstone/rich-text'\nimport { Tag } from '@bessemer/cornerstone/tag'\nimport { ZodType } from 'zod/v4'\n\nexport type ContentSector = NominalType<string, 'ContentSector'>\nexport const ContentSectorSchema: ZodType<ContentSector> = Zod.string()\n\nexport type ContentKey = NominalType<string, 'ContentKey'>\nexport const ContentKeySchema: ZodType<ContentKey> = Zod.string()\n\nexport type ContentType<Data = unknown> = NominalType<string, ['ContentType', Data]>\nexport const ContentTypeSchema: ZodType<ContentType> = Zod.string()\n\nexport type ContentReference = Reference<'Content'>\n\ntype ContentDataType<Type> = Type extends ContentType<infer Data> ? Data : never\n\nexport const ContentDataSchema = Zod.object({\n key: ContentKeySchema,\n type: ContentTypeSchema,\n data: Zod.unknown(),\n sector: ContentSectorSchema.nullable(),\n})\n\nexport type ContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = Referencable<ContentReference> & {\n key: ContentKey\n type: Type\n data: Data\n sector: ContentSector | null\n}\n\nexport type ContentTypeConstructor<Content extends ContentData> = Content['type']\n\nexport type ContentDisplayType = NominalType<string, 'ContentDisplayType'>\n\nexport namespace ContentDisplayTypes {\n export const Default: ContentDisplayType = 'Default'\n export const Label: ContentDisplayType = 'Label'\n export const Desktop: ContentDisplayType = 'Desktop'\n export const Mobile: ContentDisplayType = 'Mobile'\n export const Modal: ContentDisplayType = 'Modal'\n export const Tooltip: ContentDisplayType = 'Tooltip'\n}\n\nexport const TextContentType: ContentType<RichTextJson> = 'Text'\nexport type TextContent = ContentData<typeof TextContentType>\n\nexport interface ContentProvider<ContextType extends AbstractApplicationContext = AbstractApplicationContext> {\n fetchContentByIds: (references: Array<ReferenceType<ContentReference>>, context: ContextType) => Promise<Array<ContentData>>\n\n fetchContentByKeys: (keys: Array<ContentKey>, tags: Array<Tag>, context: ContextType) => Promise<Array<ContentData>>\n\n fetchContentBySectors: (sectors: Array<ContentSector>, tags: Array<Tag>, context: ContextType) => Promise<Array<ContentData>>\n}\n\nexport type ContentNormalizer<\n ApplicationContext extends AbstractApplicationContext = AbstractApplicationContext,\n Type extends ContentData = ContentData\n> = {\n type: Type['type']\n normalize: (data: Array<ContentData>, context: ApplicationContext) => Promise<Array<Type>>\n}\n\n// TODO might be more efficient to put the normalizers in a map at some point\nexport const normalizeContent = async <ApplicationContext extends AbstractApplicationContext>(\n content: Array<ContentData>,\n normalizers: Array<ContentNormalizer<ApplicationContext>>,\n context: ApplicationContext\n): Promise<Array<ContentData>> => {\n const groupedContent = Arrays.groupBy(content, (it) => it.type)\n const normalizedGroupedContent = Object.entries(groupedContent).map(async ([type, values]) => {\n const normalizer = normalizers.find((it) => it.type === type)\n if (Objects.isNil(normalizer)) {\n return values\n }\n\n return await normalizer.normalize(values, context)\n })\n\n const normalizedContent = (await Promise.all(normalizedGroupedContent)).flatMap((it) => it)\n return normalizedContent\n}\n\nexport type StaticContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = ContentData<Type, Data> & {\n tags: Array<Tag>\n}\n\nexport const staticData = <Type extends ContentType = ContentType, Data = ContentDataType<Type>>(\n key: ContentKey,\n type: Type,\n data: Data,\n options?: { tags?: Array<Tag>; sector?: ContentSector }\n): StaticContentData<Type, Data> => {\n return {\n reference: References.reference(Ulids.generateString(), 'Content'),\n key,\n type,\n data,\n tags: options?.tags ?? [],\n sector: options?.sector ?? null,\n }\n}\n\nexport const staticProvider = <ApplicationContext extends AbstractApplicationContext>(\n content: Array<StaticContentData>,\n normalizers?: Array<ContentNormalizer<ApplicationContext>>\n): ContentProvider<ApplicationContext> => {\n return {\n async fetchContentByIds(references: Array<ReferenceType<ContentReference>>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Arrays.contains(references, it.reference))\n return normalizeContent(matchingContent, normalizers ?? [], context)\n },\n async fetchContentByKeys(keys: Array<ContentKey>, tags: Array<Tag>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Arrays.contains(keys, it.key))\n\n const resolvedContent = Object.values(Arrays.groupBy(matchingContent, (it) => it.key)).map((it) => {\n const resolvedContent = Tags.resolveBy(it, (it) => it.tags ?? [], tags)\n return Arrays.first(resolvedContent)!\n })\n\n return normalizeContent(resolvedContent, normalizers ?? [], context)\n },\n async fetchContentBySectors(sectors: Array<ContentSector>, tags: Array<Tag>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Objects.isPresent(it.sector)).filter((it) => Arrays.contains(sectors, it.sector!))\n\n const resolvedContent = Object.values(Arrays.groupBy(matchingContent, (it) => it.key)).map((it) => {\n const resolvedContent = Tags.resolveBy(it, (it) => it.tags ?? [], tags)\n return Arrays.first(resolvedContent)!\n })\n\n return normalizeContent(resolvedContent, normalizers ?? [], context)\n },\n }\n}\n"],"mappings":";AAGA,SAAS,QAAQ,SAAS,YAAY,MAAM,OAAO,WAAW;AAMvD,IAAM,sBAA8C,IAAI,OAAO;AAG/D,IAAM,mBAAwC,IAAI,OAAO;AAGzD,IAAM,oBAA0C,IAAI,OAAO;AAM3D,IAAM,oBAAoB,IAAI,OAAO;AAAA,EAC1C,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM,IAAI,QAAQ;AAAA,EAClB,QAAQ,oBAAoB,SAAS;AACvC,CAAC;AAaM,IAAU;AAAA,CAAV,CAAUA,yBAAV;AACE,EAAMA,qBAAA,UAA8B;AACpC,EAAMA,qBAAA,QAA4B;AAClC,EAAMA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AO,OAAO,QAAQ,iBAAiB,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO;AACjG,cAAMC,mBAAkB,KAAK,UAAU,IAAI,CAACC,QAAOA,IAAG,QAAQ,CAAC,GAAG,IAAI;AACtE,eAAO,OAAO,MAAMD,gBAAe;AAAA,MACrC,CAAC;AAED,aAAO,iBAAiB,iBAAiB,eAAe,CAAC,GAAG,OAAO;AAAA,IACrE;AAAA,IACA,MAAM,sBAAsB,SAA+B,MAAkB,SAA0D;AACrI,YAAM,kBAAkB,QAAQ,OAAO,CAAC,OAAO,QAAQ,UAAU,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,OAAO,SAAS,SAAS,GAAG,MAAO,CAAC;AAEhI,YAAM,kBAAkB,OAAO,OAAO,OAAO,QAAQ,iBAAiB,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO;AACjG,cAAMA,mBAAkB,KAAK,UAAU,IAAI,CAACC,QAAOA,IAAG,QAAQ,CAAC,GAAG,IAAI;AACtE,eAAO,OAAO,MAAMD,gBAAe;AAAA,MACrC,CAAC;AAED,aAAO,iBAAiB,iBAAiB,eAAe,CAAC,GAAG,OAAO;AAAA,IACrE;AAAA,EACF;AACF;","names":["ContentDisplayTypes","resolvedContent","it"]}
1
+ {"version":3,"sources":["../src/content.ts"],"sourcesContent":["import { Referencable, Reference, ReferenceType } from '@bessemer/cornerstone/reference'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { AbstractApplicationContext } from '@bessemer/cornerstone/context'\nimport { Arrays, Objects, References, Tags, Ulids, Zod } from '@bessemer/cornerstone'\nimport { RichTextJson } from '@bessemer/cornerstone/rich-text'\nimport { Tag } from '@bessemer/cornerstone/tag'\nimport { ZodType } from 'zod'\n\nexport type ContentSector = NominalType<string, 'ContentSector'>\nexport const ContentSectorSchema: ZodType<ContentSector> = Zod.string()\n\nexport type ContentKey = NominalType<string, 'ContentKey'>\nexport const ContentKeySchema: ZodType<ContentKey> = Zod.string()\n\nexport type ContentType<Data = unknown> = NominalType<string, ['ContentType', Data]>\nexport const ContentTypeSchema: ZodType<ContentType> = Zod.string()\n\nexport type ContentReference = Reference<'Content'>\n\ntype ContentDataType<Type> = Type extends ContentType<infer Data> ? Data : never\n\nexport const ContentDataSchema = Zod.object({\n key: ContentKeySchema,\n type: ContentTypeSchema,\n data: Zod.unknown(),\n sector: ContentSectorSchema.nullable(),\n})\n\nexport type ContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = Referencable<ContentReference> & {\n key: ContentKey\n type: Type\n data: Data\n sector: ContentSector | null\n}\n\nexport type ContentTypeConstructor<Content extends ContentData> = Content['type']\n\nexport type ContentDisplayType = NominalType<string, 'ContentDisplayType'>\n\nexport namespace ContentDisplayTypes {\n export const Default: ContentDisplayType = 'Default'\n export const Label: ContentDisplayType = 'Label'\n export const Desktop: ContentDisplayType = 'Desktop'\n export const Mobile: ContentDisplayType = 'Mobile'\n export const Modal: ContentDisplayType = 'Modal'\n export const Tooltip: ContentDisplayType = 'Tooltip'\n}\n\nexport const TextContentType: ContentType<RichTextJson> = 'Text'\nexport type TextContent = ContentData<typeof TextContentType>\n\nexport interface ContentProvider<ContextType extends AbstractApplicationContext = AbstractApplicationContext> {\n fetchContentByIds: (references: Array<ReferenceType<ContentReference>>, context: ContextType) => Promise<Array<ContentData>>\n\n fetchContentByKeys: (keys: Array<ContentKey>, tags: Array<Tag>, context: ContextType) => Promise<Array<ContentData>>\n\n fetchContentBySectors: (sectors: Array<ContentSector>, tags: Array<Tag>, context: ContextType) => Promise<Array<ContentData>>\n}\n\nexport type ContentNormalizer<\n ApplicationContext extends AbstractApplicationContext = AbstractApplicationContext,\n Type extends ContentData = ContentData\n> = {\n type: Type['type']\n normalize: (data: Array<ContentData>, context: ApplicationContext) => Promise<Array<Type>>\n}\n\n// TODO might be more efficient to put the normalizers in a map at some point\nexport const normalizeContent = async <ApplicationContext extends AbstractApplicationContext>(\n content: Array<ContentData>,\n normalizers: Array<ContentNormalizer<ApplicationContext>>,\n context: ApplicationContext\n): Promise<Array<ContentData>> => {\n const groupedContent = Arrays.groupBy(content, (it) => it.type)\n const normalizedGroupedContent = Object.entries(groupedContent).map(async ([type, values]) => {\n const normalizer = normalizers.find((it) => it.type === type)\n if (Objects.isNil(normalizer)) {\n return values\n }\n\n return await normalizer.normalize(values, context)\n })\n\n const normalizedContent = (await Promise.all(normalizedGroupedContent)).flatMap((it) => it)\n return normalizedContent\n}\n\nexport type StaticContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = ContentData<Type, Data> & {\n tags: Array<Tag>\n}\n\nexport const staticData = <Type extends ContentType = ContentType, Data = ContentDataType<Type>>(\n key: ContentKey,\n type: Type,\n data: Data,\n options?: { tags?: Array<Tag>; sector?: ContentSector }\n): StaticContentData<Type, Data> => {\n return {\n reference: References.reference(Ulids.generateString(), 'Content'),\n key,\n type,\n data,\n tags: options?.tags ?? [],\n sector: options?.sector ?? null,\n }\n}\n\nexport const staticProvider = <ApplicationContext extends AbstractApplicationContext>(\n content: Array<StaticContentData>,\n normalizers?: Array<ContentNormalizer<ApplicationContext>>\n): ContentProvider<ApplicationContext> => {\n return {\n async fetchContentByIds(references: Array<ReferenceType<ContentReference>>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Arrays.contains(references, it.reference))\n return normalizeContent(matchingContent, normalizers ?? [], context)\n },\n async fetchContentByKeys(keys: Array<ContentKey>, tags: Array<Tag>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Arrays.contains(keys, it.key))\n\n const resolvedContent = Object.values(Arrays.groupBy(matchingContent, (it) => it.key)).map((it) => {\n const resolvedContent = Tags.resolveBy(it, (it) => it.tags ?? [], tags)\n return Arrays.first(resolvedContent)!\n })\n\n return normalizeContent(resolvedContent, normalizers ?? [], context)\n },\n async fetchContentBySectors(sectors: Array<ContentSector>, tags: Array<Tag>, context: ApplicationContext): Promise<Array<ContentData>> {\n const matchingContent = content.filter((it) => Objects.isPresent(it.sector)).filter((it) => Arrays.contains(sectors, it.sector!))\n\n const resolvedContent = Object.values(Arrays.groupBy(matchingContent, (it) => it.key)).map((it) => {\n const resolvedContent = Tags.resolveBy(it, (it) => it.tags ?? [], tags)\n return Arrays.first(resolvedContent)!\n })\n\n return normalizeContent(resolvedContent, normalizers ?? [], context)\n },\n }\n}\n"],"mappings":";AAGA,SAAS,QAAQ,SAAS,YAAY,MAAM,OAAO,WAAW;AAMvD,IAAM,sBAA8C,IAAI,OAAO;AAG/D,IAAM,mBAAwC,IAAI,OAAO;AAGzD,IAAM,oBAA0C,IAAI,OAAO;AAM3D,IAAM,oBAAoB,IAAI,OAAO;AAAA,EAC1C,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM,IAAI,QAAQ;AAAA,EAClB,QAAQ,oBAAoB,SAAS;AACvC,CAAC;AAaM,IAAU;AAAA,CAAV,CAAUA,yBAAV;AACE,EAAMA,qBAAA,UAA8B;AACpC,EAAMA,qBAAA,QAA4B;AAClC,EAAMA,qBAAA,UAA8B;AACpC,EAAMA,qBAAA,SAA6B;AACnC,EAAMA,qBAAA,QAA4B;AAClC,EAAMA,qBAAA,UAA8B;AAAA,GAN5B;AASV,IAAM,kBAA6C;AAoBnD,IAAM,mBAAmB,OAC9B,SACA,aACA,YACgC;AAChC,QAAM,iBAAiB,OAAO,QAAQ,SAAS,CAAC,OAAO,GAAG,IAAI;AAC9D,QAAM,2BAA2B,OAAO,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,MAAM,MAAM,MAAM;AAC5F,UAAM,aAAa,YAAY,KAAK,CAAC,OAAO,GAAG,SAAS,IAAI;AAC5D,QAAI,QAAQ,MAAM,UAAU,GAAG;AAC7B,aAAO;AAAA,IACT;AAEA,WAAO,MAAM,WAAW,UAAU,QAAQ,OAAO;AAAA,EACnD,CAAC;AAED,QAAM,qBAAqB,MAAM,QAAQ,IAAI,wBAAwB,GAAG,QAA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OAAO;AACjG,cAAMA,mBAAkB,KAAK,UAAU,IAAI,CAACC,QAAOA,IAAG,QAAQ,CAAC,GAAG,IAAI;AACtE,eAAO,OAAO,MAAMD,gBAAe;AAAA,MACrC,CAAC;AAED,aAAO,iBAAiB,iBAAiB,eAAe,CAAC,GAAG,OAAO;AAAA,IACrE;AAAA,EACF;AACF;","names":["ContentDisplayTypes","resolvedContent","it"]}
package/dist/date.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore } from 'date-fns';
2
2
  import { Duration } from '@bessemer/cornerstone/duration';
3
+ import Zod from 'zod';
4
+ export declare const buildSchema: (fieldName: string) => Zod.ZodEffects<Zod.ZodUnion<[Zod.ZodString, Zod.ZodDate]>, Date, string | Date>;
3
5
  export declare const isDate: (value?: any) => value is Date;
4
6
  export declare const now: () => Date;
5
7
  export declare const of: (dateString: string) => Date;
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,eAAe,IAAI,gBAAgB,EAAE,OAAO,IAAI,QAAQ,EAAE,QAAQ,IAAI,SAAS,EAAY,MAAM,UAAU,CAAA;AAE3I,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAGzD,eAAO,MAAM,MAAM,gCAAU,CAAA;AAE7B,eAAO,MAAM,GAAG,QAAO,IAEtB,CAAA;AAED,eAAO,MAAM,EAAE,GAAI,YAAY,MAAM,KAAG,IAEvC,CAAA;AAED,eAAO,MAAM,eAAe,yBAAmB,CAAA;AAC/C,eAAO,MAAM,QAAQ,kBAAY,CAAA;AACjC,eAAO,MAAM,QAAQ,kBAAY,CAAA;AACjC,eAAO,MAAM,OAAO,iBAAW,CAAA;AAE/B,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,EAAE,UAAU,QAAQ,KAAG,IAAiE,CAAA"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,eAAe,IAAI,gBAAgB,EAAE,OAAO,IAAI,QAAQ,EAAE,QAAQ,IAAI,SAAS,EAAY,MAAM,UAAU,CAAA;AAE3I,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAEzD,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,eAAO,MAAM,WAAW,GAAI,WAAW,MAAM,oFAqB5C,CAAA;AAED,eAAO,MAAM,MAAM,gCAAU,CAAA;AAE7B,eAAO,MAAM,GAAG,QAAO,IAEtB,CAAA;AAED,eAAO,MAAM,EAAE,GAAI,YAAY,MAAM,KAAG,IAEvC,CAAA;AAED,eAAO,MAAM,eAAe,yBAAmB,CAAA;AAC/C,eAAO,MAAM,QAAQ,kBAAY,CAAA;AACjC,eAAO,MAAM,QAAQ,kBAAY,CAAA;AACjC,eAAO,MAAM,OAAO,iBAAW,CAAA;AAE/B,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,EAAE,UAAU,QAAQ,KAAG,IAAiE,CAAA"}
package/dist/date.js CHANGED
@@ -2,6 +2,26 @@
2
2
  import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore, parseISO } from "date-fns";
3
3
  import { isDate as _isDate } from "lodash-es";
4
4
  import { Durations } from "@bessemer/cornerstone";
5
+ import Zod from "zod";
6
+ var buildSchema = (fieldName) => {
7
+ return Zod.union([
8
+ Zod.string({
9
+ required_error: `${fieldName} is required`
10
+ }).trim().regex(
11
+ /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/,
12
+ `${fieldName} is an invalid Date. Use YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.sssZ`
13
+ ),
14
+ Zod.date({
15
+ required_error: `${fieldName} is required`
16
+ })
17
+ ]).transform((isoString) => {
18
+ const date = new Date(isoString);
19
+ if (isNaN(date.getTime())) {
20
+ throw new Error("Invalid date");
21
+ }
22
+ return date;
23
+ });
24
+ };
5
25
  var isDate = _isDate;
6
26
  var now = () => {
7
27
  return /* @__PURE__ */ new Date();
@@ -18,6 +38,7 @@ export {
18
38
  addDuration,
19
39
  addHours,
20
40
  addMilliseconds,
41
+ buildSchema,
21
42
  isAfter,
22
43
  isBefore,
23
44
  isDate,
package/dist/date.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/date.ts"],"sourcesContent":["import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore, parseISO } from 'date-fns'\nimport { isDate as _isDate } from 'lodash-es'\nimport { Duration } from '@bessemer/cornerstone/duration'\nimport { Durations } from '@bessemer/cornerstone'\n\nexport const isDate = _isDate\n\nexport const now = (): Date => {\n return new Date()\n}\n\nexport const of = (dateString: string): Date => {\n return parseISO(dateString)\n}\n\nexport const addMilliseconds = _addMilliseconds\nexport const addHours = _addHours\nexport const isBefore = _isBefore\nexport const isAfter = _isAfter\n\nexport const addDuration = (date: Date, duration: Duration): Date => addMilliseconds(date, Durations.inMilliseconds(duration))\n"],"mappings":";AAAA,SAAS,YAAY,WAAW,mBAAmB,kBAAkB,WAAW,UAAU,YAAY,WAAW,gBAAgB;AACjI,SAAS,UAAU,eAAe;AAElC,SAAS,iBAAiB;AAEnB,IAAM,SAAS;AAEf,IAAM,MAAM,MAAY;AAC7B,SAAO,oBAAI,KAAK;AAClB;AAEO,IAAM,KAAK,CAAC,eAA6B;AAC9C,SAAO,SAAS,UAAU;AAC5B;AAEO,IAAM,kBAAkB;AACxB,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,UAAU;AAEhB,IAAM,cAAc,CAAC,MAAY,aAA6B,gBAAgB,MAAM,UAAU,eAAe,QAAQ,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/date.ts"],"sourcesContent":["import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore, parseISO } from 'date-fns'\nimport { isDate as _isDate } from 'lodash-es'\nimport { Duration } from '@bessemer/cornerstone/duration'\nimport { Durations } from '@bessemer/cornerstone'\nimport Zod from 'zod'\n\nexport const buildSchema = (fieldName: string) => {\n return Zod.union([\n Zod.string({\n required_error: `${fieldName} is required`,\n })\n .trim()\n .regex(\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/,\n `${fieldName} is an invalid Date. Use YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.sssZ`\n ),\n Zod.date({\n required_error: `${fieldName} is required`,\n }),\n ]).transform((isoString) => {\n const date = new Date(isoString)\n // Additional check to ensure the parsed date is valid\n if (isNaN(date.getTime())) {\n throw new Error('Invalid date')\n }\n return date\n })\n}\n\nexport const isDate = _isDate\n\nexport const now = (): Date => {\n return new Date()\n}\n\nexport const of = (dateString: string): Date => {\n return parseISO(dateString)\n}\n\nexport const addMilliseconds = _addMilliseconds\nexport const addHours = _addHours\nexport const isBefore = _isBefore\nexport const isAfter = _isAfter\n\nexport const addDuration = (date: Date, duration: Duration): Date => addMilliseconds(date, Durations.inMilliseconds(duration))\n"],"mappings":";AAAA,SAAS,YAAY,WAAW,mBAAmB,kBAAkB,WAAW,UAAU,YAAY,WAAW,gBAAgB;AACjI,SAAS,UAAU,eAAe;AAElC,SAAS,iBAAiB;AAC1B,OAAO,SAAS;AAET,IAAM,cAAc,CAAC,cAAsB;AAChD,SAAO,IAAI,MAAM;AAAA,IACf,IAAI,OAAO;AAAA,MACT,gBAAgB,GAAG,SAAS;AAAA,IAC9B,CAAC,EACE,KAAK,EACL;AAAA,MACC;AAAA,MACA,GAAG,SAAS;AAAA,IACd;AAAA,IACF,IAAI,KAAK;AAAA,MACP,gBAAgB,GAAG,SAAS;AAAA,IAC9B,CAAC;AAAA,EACH,CAAC,EAAE,UAAU,CAAC,cAAc;AAC1B,UAAM,OAAO,IAAI,KAAK,SAAS;AAE/B,QAAI,MAAM,KAAK,QAAQ,CAAC,GAAG;AACzB,YAAM,IAAI,MAAM,cAAc;AAAA,IAChC;AACA,WAAO;AAAA,EACT,CAAC;AACH;AAEO,IAAM,SAAS;AAEf,IAAM,MAAM,MAAY;AAC7B,SAAO,oBAAI,KAAK;AAClB;AAEO,IAAM,KAAK,CAAC,eAA6B;AAC9C,SAAO,SAAS,UAAU;AAC5B;AAEO,IAAM,kBAAkB;AACxB,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,UAAU;AAEhB,IAAM,cAAc,CAAC,MAAY,aAA6B,gBAAgB,MAAM,UAAU,eAAe,QAAQ,CAAC;","names":[]}
@@ -1,15 +1,23 @@
1
1
  import { NominalType, Throwable } from '@bessemer/cornerstone/types';
2
2
  import { RecordAttribute } from '@bessemer/cornerstone/object';
3
- import Zod, { ZodType } from 'zod/v4';
3
+ import Zod, { ZodType } from 'zod';
4
4
  export type ErrorCode = NominalType<string, 'ErrorCode'>;
5
5
  export declare const ErrorCodeSchema: ZodType<ErrorCode>;
6
6
  export type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>;
7
- export declare const ErrorAttributeSchema: ZodType<ErrorAttribute, string>;
7
+ export declare const ErrorAttributeSchema: ZodType<ErrorAttribute>;
8
8
  declare const baseErrorEventSchema: Zod.ZodObject<{
9
- code: Zod.ZodType<ErrorCode, unknown>;
9
+ code: Zod.ZodType<ErrorCode, Zod.ZodTypeDef, ErrorCode>;
10
10
  message: Zod.ZodString;
11
- attributes: Zod.ZodRecord<Zod.ZodType<ErrorAttribute<unknown>, string>, Zod.ZodUnknown>;
12
- }, Zod.core.$strip>;
11
+ attributes: Zod.ZodRecord<Zod.ZodType<ErrorAttribute<unknown>, Zod.ZodTypeDef, ErrorAttribute<unknown>>, Zod.ZodUnknown>;
12
+ }, "strip", Zod.ZodTypeAny, {
13
+ code: string & import("@bessemer/cornerstone/types").NominalTyping<"ErrorCode">;
14
+ message: string;
15
+ attributes: Record<ErrorAttribute<unknown>, unknown>;
16
+ }, {
17
+ code: string & import("@bessemer/cornerstone/types").NominalTyping<"ErrorCode">;
18
+ message: string;
19
+ attributes: Record<ErrorAttribute<unknown>, unknown>;
20
+ }>;
13
21
  export type ErrorEvent = Zod.infer<typeof baseErrorEventSchema> & {
14
22
  causes: Array<ErrorEvent>;
15
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"error-event.d.ts","sourceRoot":"","sources":["../src/error-event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAOrC,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AACxD,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,SAAS,CAAgB,CAAA;AAE/D,MAAM,MAAM,cAAc,CAAC,IAAI,GAAG,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;AACpF,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,CAAgB,CAAA;AAEjF,QAAA,MAAM,oBAAoB;;;;mBAIxB,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,GAAG;IAChE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAC1B,CAAA;AAOD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CA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,CAAA;AAEH,eAAO,MAAM,UAAU,GAAI,UAAU,OAAO,CAAC,iBAAiB,CAAC,eAO5D,CAAA"}
@@ -1,6 +1,6 @@
1
1
  // src/error-event.ts
2
2
  import { Arrays, Errors, Objects } from "@bessemer/cornerstone";
3
- import Zod from "zod/v4";
3
+ import Zod from "zod";
4
4
  var ErrorCodeSchema = Zod.string();
5
5
  var ErrorAttributeSchema = Zod.string();
6
6
  var baseErrorEventSchema = Zod.object({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/error-event.ts"],"sourcesContent":["import { Arrays, Errors, Objects } from '@bessemer/cornerstone'\nimport { NominalType, Throwable } from '@bessemer/cornerstone/types'\nimport { RecordAttribute } from '@bessemer/cornerstone/object'\nimport Zod, { ZodType } from 'zod/v4'\n\n/*\n Represents a structured error event. The code can be mapped to a unique type of error while the\n message and attributes can provide contextual information about the error. Finally,\n an ErrorEvent could have multiple causes which get aggregated into a single parent error.\n */\nexport type ErrorCode = NominalType<string, 'ErrorCode'>\nexport const ErrorCodeSchema: ZodType<ErrorCode> = Zod.string()\n\nexport type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>\nexport const ErrorAttributeSchema: ZodType<ErrorAttribute, string> = Zod.string()\n\nconst baseErrorEventSchema = Zod.object({\n code: ErrorCodeSchema,\n message: Zod.string(),\n attributes: Zod.record(ErrorAttributeSchema, Zod.unknown()),\n})\n\nexport type ErrorEvent = Zod.infer<typeof baseErrorEventSchema> & {\n causes: Array<ErrorEvent>\n}\n\nconst ErrorEventSchema: ZodType<ErrorEvent> = baseErrorEventSchema.extend({\n causes: Zod.lazy(() => Zod.array(ErrorEventSchema)),\n})\n\n// Builder object that allows for 'partial' representation of ErrorEvents\nexport type ErrorEventBuilder = {\n code: ErrorCode\n message?: string | null\n attributes?: Record<ErrorAttribute, unknown>\n causes?: Array<ErrorEvent>\n}\n\n// An exception type that contains an ErrorEvent\nexport class ErrorEventException extends Error {\n readonly errorEvent: ErrorEvent\n\n constructor(errorEvent: ErrorEvent, cause?: unknown) {\n super(errorEvent.message ?? '', { cause })\n this.name = this.constructor.name\n this.errorEvent = errorEvent\n }\n}\n\nexport const isErrorEvent = (throwable: Throwable): throwable is ErrorEvent => {\n if (!Objects.isObject(throwable)) {\n return false\n }\n\n return 'code' in throwable && 'message' in throwable && 'attributes' in throwable && 'causes' in throwable\n}\n\nexport const isErrorEventException = (throwable: Throwable): throwable is ErrorEventException => {\n return throwable instanceof ErrorEventException\n}\n\nexport const of = (builder: ErrorEventBuilder): ErrorEvent => {\n const code = builder.code\n\n return {\n code,\n message: builder.message ?? code,\n attributes: builder.attributes ?? {},\n causes: builder.causes ?? [],\n }\n}\n\nexport const from = (throwable: Throwable): ErrorEvent => {\n if (isErrorEvent(throwable)) {\n return throwable\n }\n\n if (!Errors.isError(throwable)) {\n return unhandled()\n }\n\n const errorEventException = Errors.findInCausalChain(throwable, isErrorEventException) as ErrorEventException | undefined\n if (Objects.isNil(errorEventException)) {\n return unhandled()\n }\n\n return errorEventException.errorEvent\n}\n\nexport const findByCodeInCausalChain = (error: ErrorEvent, code: string): ErrorEvent | undefined => {\n return findInCausalChain(error, (it) => it.code === code)\n}\n\n/*\n Traverses the causal chain of the ErrorEvent, searching for a predicate that matches (including matching on the parent error event)\n This is useful if you want to find whether or not a given error was caused by a specific failure. The search executes depth-first and\n will return te first matching instance that satisfies the predicate, or undefined otherwise\n */\nexport const findInCausalChain = (error: ErrorEvent, predicate: (error: ErrorEvent) => boolean): ErrorEvent | undefined => {\n if (predicate(error)) {\n return error\n }\n\n return Arrays.first(error.causes.map((it) => findInCausalChain(it, predicate)).filter(Objects.isPresent))\n}\n\nexport const aggregate = (builder: ErrorEventBuilder, causes: Array<ErrorEvent>): ErrorEvent | undefined => {\n if (causes.length === 0) {\n return undefined\n }\n\n return of({ ...builder, causes })\n}\n\nexport const UnhandledErrorCode: ErrorCode = 'error-event.unhandled'\nexport const NotFoundErrorCode: ErrorCode = 'error-event.not-found'\nexport const UnauthorizedErrorCode: ErrorCode = 'error-event.unauthorized'\nexport const BadRequestErrorCode: ErrorCode = 'error-event.bad-request'\n\nexport const RequestCorrelationIdAttribute: ErrorAttribute<string> = 'requestCorrelationId'\nexport const HttpStatusCodeAttribute: ErrorAttribute<number> = 'httpStatusCode'\n\nexport const unhandled = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: UnhandledErrorCode,\n message: 'An Unhandled Error has occurred.',\n attributes: { [HttpStatusCodeAttribute]: 500 },\n })\n )\n\nexport const notFound = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: NotFoundErrorCode,\n message: 'The requested Resource could not be found.',\n attributes: { [HttpStatusCodeAttribute]: 404 },\n })\n )\n\nexport const unauthorized = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: UnauthorizedErrorCode,\n message: 'The requested Resource requires authentication.',\n attributes: { [HttpStatusCodeAttribute]: 401 },\n })\n )\n\nexport const badRequest = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: BadRequestErrorCode,\n message: 'The request is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400 },\n })\n )\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,eAAe;AAGxC,OAAO,SAAsB;AAQtB,IAAM,kBAAsC,IAAI,OAAO;AAGvD,IAAM,uBAAwD,IAAI,OAAO;AAEhF,IAAM,uBAAuB,IAAI,OAAO;AAAA,EACtC,MAAM;AAAA,EACN,SAAS,IAAI,OAAO;AAAA,EACpB,YAAY,IAAI,OAAO,sBAAsB,IAAI,QAAQ,CAAC;AAC5D,CAAC;AAMD,IAAM,mBAAwC,qBAAqB,OAAO;AAAA,EACxE,QAAQ,IAAI,KAAK,MAAM,IAAI,MAAM,gBAAgB,CAAC;AACpD,CAAC;AAWM,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EAET,YAAY,YAAw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AO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,EAAE,GAAG,SAAS,OAAO,CAAC;AAClC;AAEO,IAAM,qBAAgC;AACtC,IAAM,oBAA+B;AACrC,IAAM,wBAAmC;AACzC,IAAM,sBAAiC;AAEvC,IAAM,gCAAwD;AAC9D,IAAM,0BAAkD;AAExD,IAAM,YAAY,CAAC,YACxB;AAAA,EACE,QAAQ,UAAU,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;AAEK,IAAM,WAAW,CAAC,YACvB;AAAA,EACE,QAAQ,UAAU,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;AAEK,IAAM,eAAe,CAAC,YAC3B;AAAA,EACE,QAAQ,UAAU,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;AAEK,IAAM,aAAa,CAAC,YACzB;AAAA,EACE,QAAQ,UAAU,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/error-event.ts"],"sourcesContent":["import { Arrays, Errors, Objects } from '@bessemer/cornerstone'\nimport { NominalType, Throwable } from '@bessemer/cornerstone/types'\nimport { RecordAttribute } from '@bessemer/cornerstone/object'\nimport Zod, { ZodType } from 'zod'\n\n/*\n Represents a structured error event. The code can be mapped to a unique type of error while the\n message and attributes can provide contextual information about the error. Finally,\n an ErrorEvent could have multiple causes which get aggregated into a single parent error.\n */\nexport type ErrorCode = NominalType<string, 'ErrorCode'>\nexport const ErrorCodeSchema: ZodType<ErrorCode> = Zod.string()\n\nexport type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>\nexport const ErrorAttributeSchema: ZodType<ErrorAttribute> = Zod.string()\n\nconst baseErrorEventSchema = Zod.object({\n code: ErrorCodeSchema,\n message: Zod.string(),\n attributes: Zod.record(ErrorAttributeSchema, Zod.unknown()),\n})\n\nexport type ErrorEvent = Zod.infer<typeof baseErrorEventSchema> & {\n causes: Array<ErrorEvent>\n}\n\nconst ErrorEventSchema: ZodType<ErrorEvent> = baseErrorEventSchema.extend({\n causes: Zod.lazy(() => Zod.array(ErrorEventSchema)),\n})\n\n// Builder object that allows for 'partial' representation of ErrorEvents\nexport type ErrorEventBuilder = {\n code: ErrorCode\n message?: string | null\n attributes?: Record<ErrorAttribute, unknown>\n causes?: Array<ErrorEvent>\n}\n\n// An exception type that contains an ErrorEvent\nexport class ErrorEventException extends Error {\n readonly errorEvent: ErrorEvent\n\n constructor(errorEvent: ErrorEvent, cause?: unknown) {\n super(errorEvent.message ?? '', { cause })\n this.name = this.constructor.name\n this.errorEvent = errorEvent\n }\n}\n\nexport const isErrorEvent = (throwable: Throwable): throwable is ErrorEvent => {\n if (!Objects.isObject(throwable)) {\n return false\n }\n\n return 'code' in throwable && 'message' in throwable && 'attributes' in throwable && 'causes' in throwable\n}\n\nexport const isErrorEventException = (throwable: Throwable): throwable is ErrorEventException => {\n return throwable instanceof ErrorEventException\n}\n\nexport const of = (builder: ErrorEventBuilder): ErrorEvent => {\n const code = builder.code\n\n return {\n code,\n message: builder.message ?? code,\n attributes: builder.attributes ?? {},\n causes: builder.causes ?? [],\n }\n}\n\nexport const from = (throwable: Throwable): ErrorEvent => {\n if (isErrorEvent(throwable)) {\n return throwable\n }\n\n if (!Errors.isError(throwable)) {\n return unhandled()\n }\n\n const errorEventException = Errors.findInCausalChain(throwable, isErrorEventException) as ErrorEventException | undefined\n if (Objects.isNil(errorEventException)) {\n return unhandled()\n }\n\n return errorEventException.errorEvent\n}\n\nexport const findByCodeInCausalChain = (error: ErrorEvent, code: string): ErrorEvent | undefined => {\n return findInCausalChain(error, (it) => it.code === code)\n}\n\n/*\n Traverses the causal chain of the ErrorEvent, searching for a predicate that matches (including matching on the parent error event)\n This is useful if you want to find whether or not a given error was caused by a specific failure. The search executes depth-first and\n will return te first matching instance that satisfies the predicate, or undefined otherwise\n */\nexport const findInCausalChain = (error: ErrorEvent, predicate: (error: ErrorEvent) => boolean): ErrorEvent | undefined => {\n if (predicate(error)) {\n return error\n }\n\n return Arrays.first(error.causes.map((it) => findInCausalChain(it, predicate)).filter(Objects.isPresent))\n}\n\nexport const aggregate = (builder: ErrorEventBuilder, causes: Array<ErrorEvent>): ErrorEvent | undefined => {\n if (causes.length === 0) {\n return undefined\n }\n\n return of({ ...builder, causes })\n}\n\nexport const UnhandledErrorCode: ErrorCode = 'error-event.unhandled'\nexport const NotFoundErrorCode: ErrorCode = 'error-event.not-found'\nexport const UnauthorizedErrorCode: ErrorCode = 'error-event.unauthorized'\nexport const BadRequestErrorCode: ErrorCode = 'error-event.bad-request'\n\nexport const RequestCorrelationIdAttribute: ErrorAttribute<string> = 'requestCorrelationId'\nexport const HttpStatusCodeAttribute: ErrorAttribute<number> = 'httpStatusCode'\n\nexport const unhandled = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: UnhandledErrorCode,\n message: 'An Unhandled Error has occurred.',\n attributes: { [HttpStatusCodeAttribute]: 500 },\n })\n )\n\nexport const notFound = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: NotFoundErrorCode,\n message: 'The requested Resource could not be found.',\n attributes: { [HttpStatusCodeAttribute]: 404 },\n })\n )\n\nexport const unauthorized = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: UnauthorizedErrorCode,\n message: 'The requested Resource requires authentication.',\n attributes: { [HttpStatusCodeAttribute]: 401 },\n })\n )\n\nexport const badRequest = (builder?: Partial<ErrorEventBuilder>) =>\n of(\n Objects.deepMerge(builder, {\n code: BadRequestErrorCode,\n message: 'The request is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400 },\n })\n )\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,eAAe;AAGxC,OAAO,SAAsB;AAQtB,IAAM,kBAAsC,IAAI,OAAO;AAGvD,IAAM,uBAAgD,IAAI,OAAO;AAExE,IAAM,uBAAuB,IAAI,OAAO;AAAA,EACtC,MAAM;AAAA,EACN,SAAS,IAAI,OAAO;AAAA,EACpB,YAAY,IAAI,OAAO,sBAAsB,IAAI,QAAQ,CAAC;AAC5D,CAAC;AAMD,IAAM,mBAAwC,qBAAqB,OAAO;AAAA,EACxE,QAAQ,IAAI,KAAK,MAAM,IAAI,MAAM,gBAAgB,CAAC;AACpD,CAAC;AAWM,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EAET,YAAY,YAAwB,OAAiB;AACnD,UAAM,WAAW,WAAW,IAAI,EAAE,MAAM,CAAC;AACzC,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,aAAa;AAAA,EACpB;AACF;AAEO,IAAM,eAAe,CAAC,cAAkD;AAC7E,MAAI,CAAC,QAAQ,SAAS,SAAS,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,SAAO,UAAU,aAAa,aAAa,aAAa,gBAAgB,aAAa,YAAY;AACnG;AAEO,IAAM,wBAAwB,CAAC,cAA2D;AAC/F,SAAO,qBAAqB;AAC9B;AAEO,IAAM,KAAK,CAAC,YAA2C;AAC5D,QAAM,OAAO,QAAQ;AAErB,SAAO;AAAA,IACL;AAAA,IACA,SAAS,QAAQ,WAAW;AAAA,IAC5B,YAAY,QAAQ,cAAc,CAAC;AAAA,IACnC,QAAQ,QAAQ,UAAU,CAAC;AAAA,EAC7B;AACF;AAEO,IAAM,OAAO,CAAC,cAAqC;AACxD,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO;AAAA,EACT;A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IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;AAEK,IAAM,aAAa,CAAC,YACzB;AAAA,EACE,QAAQ,UAAU,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,EAC/C,CAAC;AACH;","names":[]}
package/dist/glob.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NominalType } from '@bessemer/cornerstone/types';
2
- import { ZodType } from 'zod/v4';
2
+ import { ZodType } from 'zod';
3
3
  export type GlobPattern = NominalType<string, 'GlobPattern'>;
4
4
  export declare const GlobPatternSchema: ZodType<GlobPattern>;
5
5
  export declare const schema: () => ZodType<GlobPattern>;
@@ -1 +1 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGhC,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAC5D,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,WAAW,CAAY,CAAA;AAE/D,eAAO,MAAM,MAAM,QAAO,OAAO,CAAC,WAAW,CAE5C,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,SAAS,WAAW,KAAG,OAEzD,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,UAAU,KAAK,CAAC,WAAW,CAAC,KAAG,OAEpE,CAAA"}
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAG7B,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAC5D,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,WAAW,CAAY,CAAA;AAE/D,eAAO,MAAM,MAAM,QAAO,OAAO,CAAC,WAAW,CAE5C,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,SAAS,WAAW,KAAG,OAEzD,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,UAAU,KAAK,CAAC,WAAW,CAAC,KAAG,OAEpE,CAAA"}
package/dist/glob.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/glob.ts"],"sourcesContent":["import { minimatch } from 'minimatch'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { ZodType } from 'zod/v4'\nimport { string } from '@bessemer/cornerstone/zod'\n\nexport type GlobPattern = NominalType<string, 'GlobPattern'>\nexport const GlobPatternSchema: ZodType<GlobPattern> = string()\n\nexport const schema = (): ZodType<GlobPattern> => {\n return string()\n}\n\nexport const match = (str: string, pattern: GlobPattern): boolean => {\n return minimatch(str, pattern)\n}\n\nexport const anyMatch = (str: string, patterns: Array<GlobPattern>): boolean => {\n return patterns.some((it) => match(str, it))\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAG1B,SAAS,cAAc;AAGhB,IAAM,oBAA0C,OAAO;AAEvD,IAAM,SAAS,MAA4B;AAChD,SAAO,OAAO;AAChB;AAEO,IAAM,QAAQ,CAAC,KAAa,YAAkC;AACnE,SAAO,UAAU,KAAK,OAAO;AAC/B;AAEO,IAAM,WAAW,CAAC,KAAa,aAA0C;AAC9E,SAAO,SAAS,KAAK,CAAC,OAAO,MAAM,KAAK,EAAE,CAAC;AAC7C;","names":[]}
1
+ {"version":3,"sources":["../src/glob.ts"],"sourcesContent":["import { minimatch } from 'minimatch'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { ZodType } from 'zod'\nimport { string } from '@bessemer/cornerstone/zod'\n\nexport type GlobPattern = NominalType<string, 'GlobPattern'>\nexport const GlobPatternSchema: ZodType<GlobPattern> = string()\n\nexport const schema = (): ZodType<GlobPattern> => {\n return string()\n}\n\nexport const match = (str: string, pattern: GlobPattern): boolean => {\n return minimatch(str, pattern)\n}\n\nexport const anyMatch = (str: string, patterns: Array<GlobPattern>): boolean => {\n return patterns.some((it) => match(str, it))\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAG1B,SAAS,cAAc;AAGhB,IAAM,oBAA0C,OAAO;AAEvD,IAAM,SAAS,MAA4B;AAChD,SAAO,OAAO;AAChB;AAEO,IAAM,QAAQ,CAAC,KAAa,YAAkC;AACnE,SAAO,UAAU,KAAK,OAAO;AAC/B;AAEO,IAAM,WAAW,CAAC,KAAa,aAA0C;AAC9E,SAAO,SAAS,KAAK,CAAC,OAAO,MAAM,KAAK,EAAE,CAAC;AAC7C;","names":[]}
@@ -1,4 +1,4 @@
1
1
  import { Zod } from '@bessemer/cornerstone';
2
- export declare const HexCodeSchema: import("zod/v4/core").$ZodBranded<import("zod/v4").ZodString, "HexCode">;
2
+ export declare const HexCodeSchema: import("zod").ZodBranded<import("zod").ZodString, "HexCode">;
3
3
  export type HexCode = Zod.infer<typeof HexCodeSchema>;
4
4
  //# sourceMappingURL=hex-code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hex-code.d.ts","sourceRoot":"","sources":["../src/hex-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAE3C,eAAO,MAAM,aAAa,0EAA2G,CAAA;AACrI,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
1
+ {"version":3,"file":"hex-code.d.ts","sourceRoot":"","sources":["../src/hex-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAE3C,eAAO,MAAM,aAAa,8DAA2G,CAAA;AACrI,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -39,5 +39,6 @@ import * as Retry from '@bessemer/cornerstone/retry';
39
39
  import * as Stores from '@bessemer/cornerstone/store';
40
40
  import * as Misc from '@bessemer/cornerstone/misc';
41
41
  import * as Json from '@bessemer/cornerstone/json';
42
- export { Objects, Functions, Arrays, Strings, Async, Maths, Sets, Dates, Comparators, Equalitors, Durations, Uris, Urls, Loggers, Errors, ErrorEvents, Preconditions, Uuids, Ulids, Entries, Hashes, Crypto, Globs, Ranges, Zod, Tags, Promises, References, Signatures, Eithers, Results, Lazy, Patches, Content, Combinables, Properties, RichTexts, Retry, Stores, Misc, Json, };
42
+ import * as AspectRatios from '@bessemer/cornerstone/aspect-ratio';
43
+ export { Objects, Functions, Arrays, Strings, Async, Maths, Sets, Dates, Comparators, Equalitors, Durations, Uris, Urls, Loggers, Errors, ErrorEvents, Preconditions, Uuids, Ulids, Entries, Hashes, Crypto, Globs, Ranges, Zod, Tags, Promises, References, Signatures, Eithers, Results, Lazy, Patches, Content, Combinables, Properties, RichTexts, Retry, Stores, Misc, Json, AspectRatios, };
43
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,SAAS,MAAM,gCAAgC,CAAA;AAC3D,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAA;AACrD,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,KAAK,MAAM,6BAA6B,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAA;AACnD,OAAO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AAM,6BAA6B,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAA;AAClD,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAA;AAClD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAElE,OAAO,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,MAAM,EACN,WAAW,EACX,aAAa,EACb,KAAK,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,OAAO,EACP,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,GACb,CAAA"}
package/dist/index.js CHANGED
@@ -40,8 +40,10 @@ import * as Retry from "@bessemer/cornerstone/retry";
40
40
  import * as Stores from "@bessemer/cornerstone/store";
41
41
  import * as Misc from "@bessemer/cornerstone/misc";
42
42
  import * as Json from "@bessemer/cornerstone/json";
43
+ import * as AspectRatios from "@bessemer/cornerstone/aspect-ratio";
43
44
  export {
44
45
  Arrays,
46
+ AspectRatios,
45
47
  Async,
46
48
  Combinables,
47
49
  Comparators,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as Objects from '@bessemer/cornerstone/object'\nimport * as Functions from '@bessemer/cornerstone/function'\nimport * as Arrays from '@bessemer/cornerstone/array'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Async from '@bessemer/cornerstone/async'\nimport * as Maths from '@bessemer/cornerstone/math'\nimport * as Sets from '@bessemer/cornerstone/set'\nimport * as Dates from '@bessemer/cornerstone/date'\nimport * as Comparators from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Durations from '@bessemer/cornerstone/duration'\nimport * as Uris from '@bessemer/cornerstone/uri'\nimport * as Urls from '@bessemer/cornerstone/url'\nimport * as Loggers from '@bessemer/cornerstone/logger'\nimport * as Errors from '@bessemer/cornerstone/error'\nimport * as ErrorEvents from '@bessemer/cornerstone/error-event'\nimport * as Preconditions from '@bessemer/cornerstone/precondition'\nimport * as Uuids from '@bessemer/cornerstone/uuid'\nimport * as Ulids from '@bessemer/cornerstone/ulid'\nimport * as Entries from '@bessemer/cornerstone/entry'\nimport * as Hashes from '@bessemer/cornerstone/hash'\nimport * as Crypto from '@bessemer/cornerstone/crypto'\nimport * as Globs from '@bessemer/cornerstone/glob'\nimport * as Ranges from '@bessemer/cornerstone/range'\n\nimport * as Zod from '@bessemer/cornerstone/zod'\nimport * as Tags from '@bessemer/cornerstone/tag'\nimport * as Promises from '@bessemer/cornerstone/promise'\nimport * as References from '@bessemer/cornerstone/reference'\nimport * as Signatures from '@bessemer/cornerstone/signature'\nimport * as Eithers from '@bessemer/cornerstone/either'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as Lazy from '@bessemer/cornerstone/lazy'\nimport * as Patches from '@bessemer/cornerstone/patch'\nimport * as Content from '@bessemer/cornerstone/content'\nimport * as Combinables from '@bessemer/cornerstone/combinable'\nimport * as Properties from '@bessemer/cornerstone/property'\nimport * as RichTexts from '@bessemer/cornerstone/rich-text'\nimport * as Retry from '@bessemer/cornerstone/retry'\nimport * as Stores from '@bessemer/cornerstone/store'\nimport * as Misc from '@bessemer/cornerstone/misc'\nimport * as Json from '@bessemer/cornerstone/json'\n\nexport {\n Objects,\n Functions,\n Arrays,\n Strings,\n Async,\n Maths,\n Sets,\n Dates,\n Comparators,\n Equalitors,\n Durations,\n Uris,\n Urls,\n Loggers,\n Errors,\n ErrorEvents,\n Preconditions,\n Uuids,\n Ulids,\n Entries,\n Hashes,\n Crypto,\n Globs,\n Ranges,\n Zod,\n Tags,\n Promises,\n References,\n Signatures,\n Eithers,\n Results,\n Lazy,\n Patches,\n Content,\n Combinables,\n Properties,\n RichTexts,\n Retry,\n Stores,\n Misc,\n Json,\n}\n"],"mappings":";AAAA,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,YAAY,UAAU;AACtB,YAAY,WAAW;AACvB,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,eAAe;AAC3B,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,YAAY;AACxB,YAAY,WAAW;AACvB,YAAY,YAAY;AAExB,YAAY,SAAS;AACrB,YAAY,UAAU;AACtB,YAAY,cAAc;AAC1B,YAAY,gBAAgB;AAC5B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,UAAU;AACtB,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,eAAe;AAC3B,YAAY,WAAW;AACvB,YAAY,YAAY;AACxB,YAAY,UAAU;AACtB,YAAY,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as Objects from '@bessemer/cornerstone/object'\nimport * as Functions from '@bessemer/cornerstone/function'\nimport * as Arrays from '@bessemer/cornerstone/array'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Async from '@bessemer/cornerstone/async'\nimport * as Maths from '@bessemer/cornerstone/math'\nimport * as Sets from '@bessemer/cornerstone/set'\nimport * as Dates from '@bessemer/cornerstone/date'\nimport * as Comparators from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Durations from '@bessemer/cornerstone/duration'\nimport * as Uris from '@bessemer/cornerstone/uri'\nimport * as Urls from '@bessemer/cornerstone/url'\nimport * as Loggers from '@bessemer/cornerstone/logger'\nimport * as Errors from '@bessemer/cornerstone/error'\nimport * as ErrorEvents from '@bessemer/cornerstone/error-event'\nimport * as Preconditions from '@bessemer/cornerstone/precondition'\nimport * as Uuids from '@bessemer/cornerstone/uuid'\nimport * as Ulids from '@bessemer/cornerstone/ulid'\nimport * as Entries from '@bessemer/cornerstone/entry'\nimport * as Hashes from '@bessemer/cornerstone/hash'\nimport * as Crypto from '@bessemer/cornerstone/crypto'\nimport * as Globs from '@bessemer/cornerstone/glob'\nimport * as Ranges from '@bessemer/cornerstone/range'\n\nimport * as Zod from '@bessemer/cornerstone/zod'\nimport * as Tags from '@bessemer/cornerstone/tag'\nimport * as Promises from '@bessemer/cornerstone/promise'\nimport * as References from '@bessemer/cornerstone/reference'\nimport * as Signatures from '@bessemer/cornerstone/signature'\nimport * as Eithers from '@bessemer/cornerstone/either'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as Lazy from '@bessemer/cornerstone/lazy'\nimport * as Patches from '@bessemer/cornerstone/patch'\nimport * as Content from '@bessemer/cornerstone/content'\nimport * as Combinables from '@bessemer/cornerstone/combinable'\nimport * as Properties from '@bessemer/cornerstone/property'\nimport * as RichTexts from '@bessemer/cornerstone/rich-text'\nimport * as Retry from '@bessemer/cornerstone/retry'\nimport * as Stores from '@bessemer/cornerstone/store'\nimport * as Misc from '@bessemer/cornerstone/misc'\nimport * as Json from '@bessemer/cornerstone/json'\nimport * as AspectRatios from '@bessemer/cornerstone/aspect-ratio'\n\nexport {\n Objects,\n Functions,\n Arrays,\n Strings,\n Async,\n Maths,\n Sets,\n Dates,\n Comparators,\n Equalitors,\n Durations,\n Uris,\n Urls,\n Loggers,\n Errors,\n ErrorEvents,\n Preconditions,\n Uuids,\n Ulids,\n Entries,\n Hashes,\n Crypto,\n Globs,\n Ranges,\n Zod,\n Tags,\n Promises,\n References,\n Signatures,\n Eithers,\n Results,\n Lazy,\n Patches,\n Content,\n Combinables,\n Properties,\n RichTexts,\n Retry,\n Stores,\n Misc,\n Json,\n AspectRatios,\n}\n"],"mappings":";AAAA,YAAY,aAAa;AACzB,YAAY,eAAe;AAC3B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,YAAY,UAAU;AACtB,YAAY,WAAW;AACvB,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,eAAe;AAC3B,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,YAAY;AACxB,YAAY,WAAW;AACvB,YAAY,YAAY;AAExB,YAAY,SAAS;AACrB,YAAY,UAAU;AACtB,YAAY,cAAc;AAC1B,YAAY,gBAAgB;AAC5B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,UAAU;AACtB,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,gBAAgB;AAC5B,YAAY,eAAe;AAC3B,YAAY,WAAW;AACvB,YAAY,YAAY;AACxB,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,kBAAkB;","names":[]}
package/dist/math.d.ts CHANGED
@@ -19,4 +19,5 @@ export declare const roundUp: (value: number, scale: number) => number;
19
19
  */
20
20
  export declare const roundHalfEven: (value: number, scale: number) => number;
21
21
  export declare const random: (min: number, max: number) => number;
22
+ export declare const greatestCommonFactor: (first: number, second: number) => number;
22
23
  //# sourceMappingURL=math.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,MAEnD,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,MAErD,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,YAAgB,CAAA;AAEhD,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,EAAE,OAAO;IACT,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,cAAc,YAAY,KAAG,MAWhF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MAG3D,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,WAGrD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,WAGnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MA0E5D,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAEjD,CAAA"}
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,MAKnD,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,MAErD,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,YAAgB,CAAA;AAEhD,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,EAAE,OAAO;IACT,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,cAAc,YAAY,KAAG,MAWhF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MAG3D,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,WAGrD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,WAGnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MA0E5D,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAEjD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAEpE,CAAA"}
package/dist/math.js CHANGED
@@ -1,6 +1,9 @@
1
1
  // src/math.ts
2
2
  import { isNumber as _isNumber } from "lodash-es";
3
3
  var isNumber = (value) => {
4
+ if (isNaN(value)) {
5
+ return false;
6
+ }
4
7
  return _isNumber(value);
5
8
  };
6
9
  var isPositive = (value) => {
@@ -108,8 +111,12 @@ var roundHalfEven = (value, scale) => {
108
111
  var random = (min, max) => {
109
112
  return Math.random() * (max - min) + min;
110
113
  };
114
+ var greatestCommonFactor = (first, second) => {
115
+ return second === 0 ? first : greatestCommonFactor(second, first % second);
116
+ };
111
117
  export {
112
118
  RoundingMode,
119
+ greatestCommonFactor,
113
120
  isEven,
114
121
  isNumber,
115
122
  isPositive,
package/dist/math.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/math.ts"],"sourcesContent":["import { isNumber as _isNumber } from 'lodash-es'\n\nexport const isNumber = (value?: unknown): value is number => {\n return _isNumber(value)\n}\n\nexport const isPositive = (value?: unknown): value is number => {\n return isNumber(value) && value > 0\n}\n\nexport const isEven = (d: number) => d % 2 === 0\n\nexport enum RoundingMode {\n Nearest = 'Nearest',\n Down = 'Down',\n Up = 'Up',\n HalfEven = 'HalfEven',\n}\n\nexport const round = (value: number, scale: number, roundingMode: RoundingMode): number => {\n switch (roundingMode) {\n case RoundingMode.Nearest:\n return roundNearest(value, scale)\n case RoundingMode.Down:\n return roundDown(value, scale)\n case RoundingMode.Up:\n return roundUp(value, scale)\n case RoundingMode.HalfEven:\n return roundHalfEven(value, scale)\n }\n}\n\nexport const roundNearest = (value: number, scale: number): number => {\n const factor = Math.pow(10, scale)\n return Math.round((value + Number.EPSILON) * factor) / factor\n}\n\nexport const roundDown = (value: number, scale: number) => {\n const factor = Math.pow(10, scale)\n return Math.floor((value + +Number.EPSILON) * factor) / factor\n}\n\nexport const roundUp = (value: number, scale: number) => {\n const factor = Math.pow(10, scale)\n return Math.ceil((value + +Number.EPSILON) * factor) / factor\n}\n\n/**\n * Round Half-Even (Banker's Rounding) Utility\n * https://en.wikipedia.org/wiki/Rounding#Round_half_to_even\n *\n * Mostly copied from this Github: https://github.com/schowdhuri/round-half-even\n */\nexport const roundHalfEven = (value: number, scale: number): number => {\n if (value < 0) {\n return -roundHalfEven(-value, scale)\n }\n if (scale === 0) {\n return roundHalfEven(value / 10, 1) * 10\n }\n\n const MAX_DECIMALS_ALLOWED = 20\n if (scale > MAX_DECIMALS_ALLOWED) {\n throw new Error(`Cannot handle more than ${MAX_DECIMALS_ALLOWED} decimals`)\n }\n\n // convert to string; remove trailing 0s\n const isExponentialForm = value.toString().includes('e') || value.toString().includes('E')\n const strNum = (isExponentialForm ? value.toFixed(MAX_DECIMALS_ALLOWED).toString() : value.toString()).replace(/0+$/, '')\n const decimalIndex = strNum.indexOf('.')\n if (decimalIndex < 0) {\n // no fractional part\n return value\n }\n let intPart: string = strNum.slice(0, decimalIndex)\n if (intPart.length == 0) {\n intPart = '0'\n }\n let fractPart = strNum.slice(decimalIndex + 1) // extract fractional part\n if (fractPart.length < scale) {\n return value\n }\n const followingDig = parseInt(fractPart[scale]!, 10)\n if (followingDig < 5) {\n // rounding not required\n const newFractPart = fractPart.slice(0, scale)\n return parseFloat(`${intPart}.${newFractPart}`)\n }\n if (followingDig === 5) {\n const newFractPart = fractPart.slice(0, scale + 1)\n if (parseInt(fractPart.slice(scale + 1), 10) > 0) {\n fractPart = `${newFractPart}9`\n } else {\n fractPart = newFractPart\n }\n }\n\n let nextDig = parseInt(fractPart[fractPart.length - 1]!, 10)\n let carriedOver = 0\n for (let ptr = fractPart.length - 1; ptr >= scale; ptr--) {\n let dig = parseInt(fractPart[ptr - 1]!, 10) + carriedOver\n if (nextDig > 5 || (nextDig == 5 && !isEven(dig))) {\n ++dig\n }\n if (dig > 9) {\n dig -= 10\n carriedOver = 1\n } else {\n carriedOver = 0\n }\n nextDig = dig\n }\n\n let newFractPart = ''\n for (let ptr = scale - 2; ptr >= 0; ptr--) {\n let d = parseInt(fractPart[ptr]!, 10) + carriedOver\n if (d > 9) {\n d -= 10\n carriedOver = 1\n } else {\n carriedOver = 0\n }\n newFractPart = `${d}${newFractPart}`\n }\n\n const resolvedIntPart = parseInt(intPart, 10) + carriedOver\n return parseFloat(`${resolvedIntPart}.${newFractPart}${nextDig}`)\n}\n\nexport const random = (min: number, max: number): number => {\n return Math.random() * (max - min) + min\n}\n"],"mappings":";AAAA,SAAS,YAAY,iBAAiB;AAE/B,IAAM,WAAW,CAAC,UAAqC;AAC5D,SAAO,UAAU,KAAK;AACxB;AAEO,IAAM,aAAa,CAAC,UAAqC;AAC9D,SAAO,SAAS,KAAK,KAAK,QAAQ;AACpC;AAEO,IAAM,SAAS,CAAC,MAAc,IAAI,MAAM;AAExC,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,QAAK;AACL,EAAAA,cAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAM,QAAQ,C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B;AACA,mBAAe,GAAG,CAAC,GAAG,YAAY;AAAA,EACpC;AAEA,QAAM,kBAAkB,SAAS,SAAS,EAAE,IAAI;AAChD,SAAO,WAAW,GAAG,eAAe,IAAI,YAAY,GAAG,OAAO,EAAE;AAClE;AAEO,IAAM,SAAS,CAAC,KAAa,QAAwB;AAC1D,SAAO,KAAK,OAAO,KAAK,MAAM,OAAO;AACvC;","names":["RoundingMode","newFractPart"]}
1
+ {"version":3,"sources":["../src/math.ts"],"sourcesContent":["import { isNumber as _isNumber } from 'lodash-es'\n\nexport const isNumber = (value?: unknown): value is number => {\n if (isNaN(value as any)) {\n return false\n }\n return _isNumber(value)\n}\n\nexport const isPositive = (value?: unknown): value is number => {\n return isNumber(value) && value > 0\n}\n\nexport const isEven = (d: number) => d % 2 === 0\n\nexport enum RoundingMode {\n Nearest = 'Nearest',\n Down = 'Down',\n Up = 'Up',\n HalfEven = 'HalfEven',\n}\n\nexport const round = (value: number, scale: number, roundingMode: RoundingMode): number => {\n switch (roundingMode) {\n case RoundingMode.Nearest:\n return roundNearest(value, scale)\n case RoundingMode.Down:\n return roundDown(value, scale)\n case RoundingMode.Up:\n return roundUp(value, scale)\n case RoundingMode.HalfEven:\n return roundHalfEven(value, scale)\n }\n}\n\nexport const roundNearest = (value: number, scale: number): number => {\n const factor = Math.pow(10, scale)\n return Math.round((value + Number.EPSILON) * factor) / factor\n}\n\nexport const roundDown = (value: number, scale: number) => {\n const factor = Math.pow(10, scale)\n return Math.floor((value + +Number.EPSILON) * factor) / factor\n}\n\nexport const roundUp = (value: number, scale: number) => {\n const factor = Math.pow(10, scale)\n return Math.ceil((value + +Number.EPSILON) * factor) / factor\n}\n\n/**\n * Round Half-Even (Banker's Rounding) Utility\n * https://en.wikipedia.org/wiki/Rounding#Round_half_to_even\n *\n * Mostly copied from this Github: https://github.com/schowdhuri/round-half-even\n */\nexport const roundHalfEven = (value: number, scale: number): number => {\n if (value < 0) {\n return -roundHalfEven(-value, scale)\n }\n if (scale === 0) {\n return roundHalfEven(value / 10, 1) * 10\n }\n\n const MAX_DECIMALS_ALLOWED = 20\n if (scale > MAX_DECIMALS_ALLOWED) {\n throw new Error(`Cannot handle more than ${MAX_DECIMALS_ALLOWED} decimals`)\n }\n\n // convert to string; remove trailing 0s\n const isExponentialForm = value.toString().includes('e') || value.toString().includes('E')\n const strNum = (isExponentialForm ? value.toFixed(MAX_DECIMALS_ALLOWED).toString() : value.toString()).replace(/0+$/, '')\n const decimalIndex = strNum.indexOf('.')\n if (decimalIndex < 0) {\n // no fractional part\n return value\n }\n let intPart: string = strNum.slice(0, decimalIndex)\n if (intPart.length == 0) {\n intPart = '0'\n }\n let fractPart = strNum.slice(decimalIndex + 1) // extract fractional part\n if (fractPart.length < scale) {\n return value\n }\n const followingDig = parseInt(fractPart[scale]!, 10)\n if (followingDig < 5) {\n // rounding not required\n const newFractPart = fractPart.slice(0, scale)\n return parseFloat(`${intPart}.${newFractPart}`)\n }\n if (followingDig === 5) {\n const newFractPart = fractPart.slice(0, scale + 1)\n if (parseInt(fractPart.slice(scale + 1), 10) > 0) {\n fractPart = `${newFractPart}9`\n } else {\n fractPart = newFractPart\n }\n }\n\n let nextDig = parseInt(fractPart[fractPart.length - 1]!, 10)\n let carriedOver = 0\n for (let ptr = fractPart.length - 1; ptr >= scale; ptr--) {\n let dig = parseInt(fractPart[ptr - 1]!, 10) + carriedOver\n if (nextDig > 5 || (nextDig == 5 && !isEven(dig))) {\n ++dig\n }\n if (dig > 9) {\n dig -= 10\n carriedOver = 1\n } else {\n carriedOver = 0\n }\n nextDig = dig\n }\n\n let newFractPart = ''\n for (let ptr = scale - 2; ptr >= 0; ptr--) {\n let d = parseInt(fractPart[ptr]!, 10) + carriedOver\n if (d > 9) {\n d -= 10\n carriedOver = 1\n } else {\n carriedOver = 0\n }\n newFractPart = `${d}${newFractPart}`\n }\n\n const resolvedIntPart = parseInt(intPart, 10) + carriedOver\n return parseFloat(`${resolvedIntPart}.${newFractPart}${nextDig}`)\n}\n\nexport const random = (min: number, max: number): number => {\n return Math.random() * (max - min) + min\n}\n\nexport const greatestCommonFactor = (first: number, second: number): number => {\n return second === 0 ? first : greatestCommonFactor(second, first % second)\n}\n"],"mappings":";AAAA,SAAS,YAAY,iBAAiB;AAE/B,IAAM,WAAW,CAAC,UAAqC;AAC5D,MAAI,MAAM,KAAY,GAAG;AACvB,WAAO;AAAA,EACT;AACA,SAAO,UAAU,KAAK;AACxB;AAEO,IAAM,aAAa,CAAC,UAAqC;AAC9D,SAAO,SAAS,KAAK,KAAK,QAAQ;AACpC;AAEO,IAAM,SAAS,CAAC,MAAc,IAAI,MAAM;AAExC,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,QAAK;AACL,EAAAA,cAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAM,QAAQ,CAAC,OAAe,OAAe,iBAAuC;AACzF,UAAQ,cAAc;AAAA,IACpB,KAAK;AACH,aAAO,aAAa,OAAO,KAAK;AAAA,IAClC,KAAK;AACH,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B,KAAK;AACH,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC7B,KAAK;AACH,aAAO,cAAc,OAAO,KAAK;AAAA,EACrC;AACF;AAEO,IAAM,eAAe,CAAC,OAAe,UAA0B;AACpE,QAAM,SAAS,KAAK,IAAI,IAAI,KAAK;AACjC,SAAO,KAAK,OAAO,QAAQ,OAAO,WAAW,MAAM,IAAI;AACzD;AAEO,IAAM,YAAY,CAAC,OAAe,UAAkB;AACzD,QAAM,SAAS,KAAK,IAAI,IAAI,KAAK;AACjC,SAAO,KAAK,OAAO,QAAQ,CAAC,OAAO,WAAW,MAAM,IAAI;AAC1D;AAEO,IAAM,UAAU,CAAC,OAAe,UAAkB;AACvD,QAAM,SAAS,KAAK,IAAI,IAAI,KAAK;AACjC,SAAO,KAAK,MAAM,QAAQ,CAAC,OAAO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,UAAU,SAAS,CAAC,GAAI,EAAE;AAC3D,MAAI,cAAc;AAClB,WAAS,MAAM,UAAU,SAAS,GAAG,OAAO,OAAO,OAAO;AACxD,QAAI,MAAM,SAAS,UAAU,MAAM,CAAC,GAAI,EAAE,IAAI;AAC9C,QAAI,UAAU,KAAM,WAAW,KAAK,CAAC,OAAO,GAAG,GAAI;AACjD,QAAE;AAAA,IACJ;AACA,QAAI,MAAM,GAAG;AACX,aAAO;AACP,oBAAc;AAAA,IAChB,OAAO;AACL,oBAAc;AAAA,IAChB;AACA,cAAU;AAAA,EACZ;AAEA,MAAI,eAAe;AACnB,WAAS,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO;AACzC,QAAI,IAAI,SAAS,UAAU,GAAG,GAAI,EAAE,IAAI;AACxC,QAAI,IAAI,GAAG;AACT,WAAK;AACL,oBAAc;AAAA,IAChB,OAAO;AACL,oBAAc;AAAA,IAChB;AACA,mBAAe,GAAG,CAAC,GAAG,YAAY;AAAA,EACpC;AAEA,QAAM,kBAAkB,SAAS,SAAS,EAAE,IAAI;AAChD,SAAO,WAAW,GAAG,eAAe,IAAI,YAAY,GAAG,OAAO,EAAE;AAClE;AAEO,IAAM,SAAS,CAAC,KAAa,QAAwB;AAC1D,SAAO,KAAK,OAAO,KAAK,MAAM,OAAO;AACvC;AAEO,IAAM,uBAAuB,CAAC,OAAe,WAA2B;AAC7E,SAAO,WAAW,IAAI,QAAQ,qBAAqB,QAAQ,QAAQ,MAAM;AAC3E;","names":["RoundingMode","newFractPart"]}
package/dist/range.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ZodType } from 'zod/v4';
1
+ import { ZodType } from 'zod';
2
2
  import { TaggedType } from '@bessemer/cornerstone/types';
3
- export declare const boundsSchema: <T extends ZodType>(type: T) => import("zod/v4/core").$ZodBranded<import("zod/v4").ZodTuple<[import("zod/v4").ZodNullable<T>, import("zod/v4").ZodNullable<T>], null>, "Bounds">;
3
+ export declare const boundsSchema: <T extends ZodType>(type: T) => import("zod").ZodBranded<import("zod").ZodTuple<[import("zod").ZodNullable<T>, import("zod").ZodNullable<T>], null>, "Bounds">;
4
4
  export type Bounds<T> = TaggedType<[T | null, T | null], 'Bounds'>;
5
5
  export declare const bounds: <T>(bounds: [lower: T | null, upper?: T | null]) => Bounds<T>;
6
6
  //# sourceMappingURL=range.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,qJAEtD,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;AAElE,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAG,MAAM,CAAC,CAAC,CAM/E,CAAA"}
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,mIAEtD,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;AAElE,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAG,MAAM,CAAC,CAAC,CAM/E,CAAA"}
package/dist/range.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/range.ts"],"sourcesContent":["import { Objects, Zod } from '@bessemer/cornerstone'\nimport { ZodType } from 'zod/v4'\nimport { TaggedType } from '@bessemer/cornerstone/types'\n\nexport const boundsSchema = <T extends ZodType>(type: T) => {\n return Zod.tuple([type.nullable(), type.nullable()]).brand('Bounds')\n}\n\nexport type Bounds<T> = TaggedType<[T | null, T | null], 'Bounds'>\n\nexport const bounds = <T>(bounds: [lower: T | null, upper?: T | null]): Bounds<T> => {\n if (Objects.isUndefined(bounds[1])) {\n return [bounds[0], null] as Bounds<T>\n }\n\n return bounds as Bounds<T>\n}\n"],"mappings":";AAAA,SAAS,SAAS,WAAW;AAItB,IAAM,eAAe,CAAoB,SAAY;AAC1D,SAAO,IAAI,MAAM,CAAC,KAAK,SAAS,GAAG,KAAK,SAAS,CAAC,CAAC,EAAE,MAAM,QAAQ;AACrE;AAIO,IAAM,SAAS,CAAIA,YAA2D;AACnF,MAAI,QAAQ,YAAYA,QAAO,CAAC,CAAC,GAAG;AAClC,WAAO,CAACA,QAAO,CAAC,GAAG,IAAI;AAAA,EACzB;AAEA,SAAOA;AACT;","names":["bounds"]}
1
+ {"version":3,"sources":["../src/range.ts"],"sourcesContent":["import { Objects, Zod } from '@bessemer/cornerstone'\nimport { ZodType } from 'zod'\nimport { TaggedType } from '@bessemer/cornerstone/types'\n\nexport const boundsSchema = <T extends ZodType>(type: T) => {\n return Zod.tuple([type.nullable(), type.nullable()]).brand('Bounds')\n}\n\nexport type Bounds<T> = TaggedType<[T | null, T | null], 'Bounds'>\n\nexport const bounds = <T>(bounds: [lower: T | null, upper?: T | null]): Bounds<T> => {\n if(Objects.isUndefined(bounds[1])) {\n return [bounds[0], null] as Bounds<T>\n }\n\n return bounds as Bounds<T>\n}"],"mappings":";AAAA,SAAS,SAAS,WAAW;AAItB,IAAM,eAAe,CAAoB,SAAY;AAC1D,SAAO,IAAI,MAAM,CAAC,KAAK,SAAS,GAAG,KAAK,SAAS,CAAC,CAAC,EAAE,MAAM,QAAQ;AACrE;AAIO,IAAM,SAAS,CAAIA,YAA2D;AACnF,MAAG,QAAQ,YAAYA,QAAO,CAAC,CAAC,GAAG;AACjC,WAAO,CAACA,QAAO,CAAC,GAAG,IAAI;AAAA,EACzB;AAEA,SAAOA;AACT;","names":["bounds"]}
@@ -1,5 +1,5 @@
1
1
  import { NominalType } from '@bessemer/cornerstone/types';
2
- import { ZodType } from 'zod/v4';
2
+ import { ZodType } from 'zod';
3
3
  export type ResourceKey = string;
4
4
  export type ResourceNamespace = NominalType<string, 'ResourceNamespace'>;
5
5
  export declare const ResourceNamespaceSchema: ZodType<ResourceNamespace>;
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;AACxE,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,iBAAiB,CAAgB,CAAA;AAE/E,yBAAiB,WAAW,CAAC;IAGpB,MAAM,SAAS,GAAI,WAAW,iBAAiB,EAAE,KAAK,WAAW,KAAG,WAE1E,CAAA;IAEM,MAAM,YAAY,GAAI,WAAW,iBAAiB,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,KAAG,KAAK,CAAC,WAAW,CAEtG,CAAA;IAEM,MAAM,cAAc,GAAI,WAAW,iBAAiB,EAAE,KAAK,WAAW,KAAG,WAE/E,CAAA;IAEM,MAAM,iBAAiB,GAAI,WAAW,iBAAiB,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,KAAG,KAAK,CAAC,WAAW,CAE3G,CAAA;IAEM,MAAM,eAAe,GAAI,GAAG,YAAY,KAAK,CAAC,iBAAiB,CAAC,KAAG,iBAEzE,CAAA;CACF"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAE7B,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;AACxE,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,iBAAiB,CAAgB,CAAA;AAE/E,yBAAiB,WAAW,CAAC;IAGpB,MAAM,SAAS,GAAI,WAAW,iBAAiB,EAAE,KAAK,WAAW,KAAG,WAE1E,CAAA;IAEM,MAAM,YAAY,GAAI,WAAW,iBAAiB,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,KAAG,KAAK,CAAC,WAAW,CAEtG,CAAA;IAEM,MAAM,cAAc,GAAI,WAAW,iBAAiB,EAAE,KAAK,WAAW,KAAG,WAE/E,CAAA;IAEM,MAAM,iBAAiB,GAAI,WAAW,iBAAiB,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,KAAG,KAAK,CAAC,WAAW,CAE3G,CAAA;IAEM,MAAM,eAAe,GAAI,GAAG,YAAY,KAAK,CAAC,iBAAiB,CAAC,KAAG,iBAEzE,CAAA;CACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resource.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport { Strings, Zod } from '@bessemer/cornerstone'\nimport { ZodType } from 'zod/v4'\n\nexport type ResourceKey = string\n\nexport type ResourceNamespace = NominalType<string, 'ResourceNamespace'>\nexport const ResourceNamespaceSchema: ZodType<ResourceNamespace> = Zod.string()\n\nexport namespace ResourceKey {\n const ResourceNamespaceSeparator = '/'\n\n export const namespace = (namespace: ResourceNamespace, key: ResourceKey): ResourceKey => {\n return `${namespace}${ResourceNamespaceSeparator}${key}`\n }\n\n export const namespaceAll = (namespace: ResourceNamespace, keys: Array<ResourceKey>): Array<ResourceKey> => {\n return keys.map((it) => ResourceKey.namespace(namespace, it))\n }\n\n export const stripNamespace = (namespace: ResourceNamespace, key: ResourceKey): ResourceKey => {\n return Strings.removeStart(key, `${namespace}${ResourceNamespaceSeparator}`)\n }\n\n export const stripNamespaceAll = (namespace: ResourceNamespace, keys: Array<ResourceKey>): Array<ResourceKey> => {\n return keys.map((it) => ResourceKey.stripNamespace(namespace, it))\n }\n\n export const extendNamespace = (...namespaces: Array<ResourceNamespace>): ResourceNamespace => {\n return namespaces.join(ResourceNamespaceSeparator)\n }\n}\n"],"mappings":";AACA,SAAS,SAAS,WAAW;AAMtB,IAAM,0BAAsD,IAAI,OAAO;AAEvE,IAAU;AAAA,CAAV,CAAUA,iBAAV;AACL,QAAM,6BAA6B;AAE5B,EAAMA,aAAA,YAAY,CAACC,YAA8B,QAAkC;AACxF,WAAO,GAAGA,UAAS,GAAG,0BAA0B,GAAG,GAAG;AAAA,EACxD;AAEO,EAAMD,aAAA,eAAe,CAACC,YAA8B,SAAiD;AAC1G,WAAO,KAAK,IAAI,CAAC,OAAOD,aAAY,UAAUC,YAAW,EAAE,CAAC;AAAA,EAC9D;AAEO,EAAMD,aAAA,iBAAiB,CAACC,YAA8B,QAAkC;AAC7F,WAAO,QAAQ,YAAY,KAAK,GAAGA,UAAS,GAAG,0BAA0B,EAAE;AAAA,EAC7E;AAEO,EAAMD,aAAA,oBAAoB,CAACC,YAA8B,SAAiD;AAC/G,WAAO,KAAK,IAAI,CAAC,OAAOD,aAAY,eAAeC,YAAW,EAAE,CAAC;AAAA,EACnE;AAEO,EAAMD,aAAA,kBAAkB,IAAI,eAA4D;AAC7F,WAAO,WAAW,KAAK,0BAA0B;AAAA,EACnD;AAAA,GArBe;","names":["ResourceKey","namespace"]}
1
+ {"version":3,"sources":["../src/resource.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport { Strings, Zod } from '@bessemer/cornerstone'\nimport { ZodType } from 'zod'\n\nexport type ResourceKey = string\n\nexport type ResourceNamespace = NominalType<string, 'ResourceNamespace'>\nexport const ResourceNamespaceSchema: ZodType<ResourceNamespace> = Zod.string()\n\nexport namespace ResourceKey {\n const ResourceNamespaceSeparator = '/'\n\n export const namespace = (namespace: ResourceNamespace, key: ResourceKey): ResourceKey => {\n return `${namespace}${ResourceNamespaceSeparator}${key}`\n }\n\n export const namespaceAll = (namespace: ResourceNamespace, keys: Array<ResourceKey>): Array<ResourceKey> => {\n return keys.map((it) => ResourceKey.namespace(namespace, it))\n }\n\n export const stripNamespace = (namespace: ResourceNamespace, key: ResourceKey): ResourceKey => {\n return Strings.removeStart(key, `${namespace}${ResourceNamespaceSeparator}`)\n }\n\n export const stripNamespaceAll = (namespace: ResourceNamespace, keys: Array<ResourceKey>): Array<ResourceKey> => {\n return keys.map((it) => ResourceKey.stripNamespace(namespace, it))\n }\n\n export const extendNamespace = (...namespaces: Array<ResourceNamespace>): ResourceNamespace => {\n return namespaces.join(ResourceNamespaceSeparator)\n }\n}\n"],"mappings":";AACA,SAAS,SAAS,WAAW;AAMtB,IAAM,0BAAsD,IAAI,OAAO;AAEvE,IAAU;AAAA,CAAV,CAAUA,iBAAV;AACL,QAAM,6BAA6B;AAE5B,EAAMA,aAAA,YAAY,CAACC,YAA8B,QAAkC;AACxF,WAAO,GAAGA,UAAS,GAAG,0BAA0B,GAAG,GAAG;AAAA,EACxD;AAEO,EAAMD,aAAA,eAAe,CAACC,YAA8B,SAAiD;AAC1G,WAAO,KAAK,IAAI,CAAC,OAAOD,aAAY,UAAUC,YAAW,EAAE,CAAC;AAAA,EAC9D;AAEO,EAAMD,aAAA,iBAAiB,CAACC,YAA8B,QAAkC;AAC7F,WAAO,QAAQ,YAAY,KAAK,GAAGA,UAAS,GAAG,0BAA0B,EAAE;AAAA,EAC7E;AAEO,EAAMD,aAAA,oBAAoB,CAACC,YAA8B,SAAiD;AAC/G,WAAO,KAAK,IAAI,CAAC,OAAOD,aAAY,eAAeC,YAAW,EAAE,CAAC;AAAA,EACnE;AAEO,EAAMD,aAAA,kBAAkB,IAAI,eAA4D;AAC7F,WAAO,WAAW,KAAK,0BAA0B;AAAA,EACnD;AAAA,GArBe;","names":["ResourceKey","namespace"]}
package/dist/zod.d.ts CHANGED
@@ -1,24 +1,32 @@
1
- import Zod, { ZodType } from 'zod/v4';
1
+ import Zod, { ZodType } from 'zod';
2
2
  import { ResourceKey } from '@bessemer/cornerstone/resource';
3
3
  import { Entry } from '@bessemer/cornerstone/entry';
4
4
  import { Result } from '@bessemer/cornerstone/result';
5
- export type infer<T extends ZodType<any, any>> = Zod.infer<T>;
6
- export type input<T extends ZodType<any, any>> = Zod.input<T>;
7
- export type output<T extends ZodType<any, any>> = Zod.output<T>;
8
- export declare const object: typeof Zod.object;
9
- export declare const string: typeof Zod.string;
10
- export declare const union: typeof Zod.union;
11
- export declare const array: typeof Zod.array;
12
- export declare const unknown: typeof Zod.unknown;
13
- export declare const nullType: typeof Zod.null;
14
- export declare const undefined: typeof Zod.undefined;
15
- export declare const date: typeof Zod.date;
16
- export declare const boolean: typeof Zod.boolean;
17
- export declare const number: typeof Zod.number;
18
- export declare const tuple: typeof Zod.tuple;
19
- export declare const record: typeof Zod.record;
20
- export declare const lazy: typeof Zod.lazy;
21
- export declare const arrayable: <T>(type: ZodType<T>) => Zod.ZodUnion<readonly [Zod.ZodType<T, unknown>, Zod.ZodArray<Zod.ZodType<T, unknown>>]>;
5
+ export type infer<T extends ZodType<any, any, any>> = Zod.infer<T>;
6
+ export type input<T extends ZodType<any, any, any>> = Zod.input<T>;
7
+ export type output<T extends ZodType<any, any, any>> = Zod.output<T>;
8
+ export declare const object: <T extends Zod.ZodRawShape>(shape: T, params?: Zod.RawCreateParams) => Zod.ZodObject<T, "strip", Zod.ZodTypeAny, Zod.objectOutputType<T, Zod.ZodTypeAny, "strip">, Zod.objectInputType<T, Zod.ZodTypeAny, "strip">>;
9
+ export declare const string: (params?: Zod.RawCreateParams & {
10
+ coerce?: true;
11
+ }) => Zod.ZodString;
12
+ export declare const union: <T extends readonly [Zod.ZodTypeAny, Zod.ZodTypeAny, ...Zod.ZodTypeAny[]]>(types: T, params?: Zod.RawCreateParams) => Zod.ZodUnion<T>;
13
+ export declare const array: <T extends Zod.ZodTypeAny>(schema: T, params?: Zod.RawCreateParams) => Zod.ZodArray<T>;
14
+ export declare const unknown: (params?: Zod.RawCreateParams) => Zod.ZodUnknown;
15
+ export declare const nullType: (params?: Zod.RawCreateParams) => Zod.ZodNull;
16
+ export declare const undefined: (params?: Zod.RawCreateParams) => Zod.ZodUndefined;
17
+ export declare const date: (params?: Zod.RawCreateParams & {
18
+ coerce?: boolean;
19
+ }) => Zod.ZodDate;
20
+ export declare const boolean: (params?: Zod.RawCreateParams & {
21
+ coerce?: boolean;
22
+ }) => Zod.ZodBoolean;
23
+ export declare const number: (params?: Zod.RawCreateParams & {
24
+ coerce?: boolean;
25
+ }) => Zod.ZodNumber;
26
+ export declare const tuple: <T extends [] | [Zod.ZodTypeAny, ...Zod.ZodTypeAny[]]>(schemas: T, params?: Zod.RawCreateParams) => Zod.ZodTuple<T, null>;
27
+ export declare const record: typeof Zod.ZodRecord.create;
28
+ export declare const lazy: <T extends Zod.ZodTypeAny>(getter: () => T, params?: Zod.RawCreateParams) => Zod.ZodLazy<T>;
29
+ export declare const arrayable: <T>(type: ZodType<T>) => Zod.ZodUnion<[Zod.ZodType<T, Zod.ZodTypeDef, T>, Zod.ZodArray<Zod.ZodType<T, Zod.ZodTypeDef, T>, "many">]>;
22
30
  export declare const key: () => ZodType<ResourceKey>;
23
31
  export declare const entry: <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>) => ZodType<Entry<Value, Key>>;
24
32
  export declare const parse: <T extends ZodType>(type: T, data: unknown) => Result<Zod.infer<T>>;
package/dist/zod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AAEnD,OAAO,EAA4B,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAExF,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC7D,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC7D,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAC/D,eAAO,MAAM,MAAM,mBAAa,CAAA;AAChC,eAAO,MAAM,MAAM,mBAAa,CAAA;AAChC,eAAO,MAAM,KAAK,kBAAY,CAAA;AAC9B,eAAO,MAAM,KAAK,kBAAY,CAAA;AAC9B,eAAO,MAAM,OAAO,oBAAc,CAAA;AAClC,eAAO,MAAM,QAAQ,iBAAW,CAAA;AAChC,eAAO,MAAM,SAAS,sBAAgB,CAAA;AACtC,eAAO,MAAM,IAAI,iBAAW,CAAA;AAC5B,eAAO,MAAM,OAAO,oBAAc,CAAA;AAClC,eAAO,MAAM,MAAM,mBAAa,CAAA;AAChC,eAAO,MAAM,KAAK,kBAAY,CAAA;AAC9B,eAAO,MAAM,MAAM,mBAA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O,CAAC,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAE/G,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,OAAO,KAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAOpF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,OAAO,KAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAEnF,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAOvF,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,KAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAEtF,CAAA"}
package/dist/zod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/zod.ts
2
- import Zod from "zod/v4";
2
+ import Zod from "zod";
3
3
  import { parse as jsonParse } from "@bessemer/cornerstone/json";
4
4
  import { failure, getValueOrThrow, success } from "@bessemer/cornerstone/result";
5
5
  var object = Zod.object;
package/dist/zod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/zod.ts"],"sourcesContent":["import Zod, { ZodType } from 'zod/v4'\nimport { ResourceKey } from '@bessemer/cornerstone/resource'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { parse as jsonParse } from '@bessemer/cornerstone/json'\nimport { failure, getValueOrThrow, Result, success } from '@bessemer/cornerstone/result'\n\nexport type infer<T extends ZodType<any, any>> = Zod.infer<T>\nexport type input<T extends ZodType<any, any>> = Zod.input<T>\nexport type output<T extends ZodType<any, any>> = Zod.output<T>\nexport const object = Zod.object\nexport const string = Zod.string\nexport const union = Zod.union\nexport const array = Zod.array\nexport const unknown = Zod.unknown\nexport const nullType = Zod.null\nexport const undefined = Zod.undefined\nexport const date = Zod.date\nexport const boolean = Zod.boolean\nexport const number = Zod.number\nexport const tuple = Zod.tuple\nexport const record = Zod.record\nexport const lazy = Zod.lazy\n\nexport const arrayable = <T>(type: ZodType<T>) => {\n return union([type, array(type)])\n}\n\nexport const key = (): ZodType<ResourceKey> => {\n return string()\n}\n\nexport const entry = <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>): ZodType<Entry<Value, Key>> => {\n return tuple([key ?? string(), value]) as ZodType<Entry<Value, Key>>\n}\n\nexport const parse = <T extends ZodType>(type: T, data: unknown): Result<Zod.infer<T>> => {\n const result = type.safeParse(data)\n if (result.success) {\n return success(result.data)\n } else {\n return failure(result.error)\n }\n}\n\nexport const parseOrThrow = <T extends ZodType>(type: T, data: unknown): Zod.infer<T> => {\n return getValueOrThrow(parse(type, data))\n}\n\nexport const parseJson = <T extends ZodType>(type: T, data: string): Result<Zod.infer<T>> => {\n const result = jsonParse(data)\n if (!result.isSuccess) {\n return result\n }\n\n return parse(type, result.value)\n}\n\nexport const parseJsonOrThrow = <T extends ZodType>(type: T, data: string): Zod.infer<T> => {\n return parseJson(type, data)\n}\n"],"mappings":";AAAA,OAAO,SAAsB;AAG7B,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,iBAAyB,eAAe;AAKnD,IAAM,SAAS,IAAI;AACnB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAClB,IAAM,QAAQ,IAAI;AAClB,IAAM,UAAU,IAAI;AACpB,IAAM,WAAW,IAAI;AACrB,IAAM,YAAY,IAAI;AACtB,IAAM,OAAO,IAAI;AACjB,IAAM,UAAU,IAAI;AACpB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAClB,IAAM,SAAS,IAAI;AACnB,IAAM,OAAO,IAAI;AAEjB,IAAM,YAAY,CAAI,SAAqB;AAChD,SAAO,MAAM,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC;AAClC;AAEO,IAAM,MAAM,MAA4B;AAC7C,SAAO,OAAO;AAChB;AAEO,IAAM,QAAQ,CAAsB,OAAuBA,SAAmD;AACnH,SAAO,MAAM,CAACA,QAAO,OAAO,GAAG,KAAK,CAAC;AACvC;AAEO,IAAM,QAAQ,CAAoB,MAAS,SAAwC;AACxF,QAAM,SAAS,KAAK,UAAU,IAAI;AAClC,MAAI,OAAO,SAAS;AAClB,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B,OAAO;AACL,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAEO,IAAM,eAAe,CAAoB,MAAS,SAAgC;AACvF,SAAO,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAC1C;AAEO,IAAM,YAAY,CAAoB,MAAS,SAAuC;AAC3F,QAAM,SAAS,UAAU,IAAI;AAC7B,MAAI,CAAC,OAAO,WAAW;AACrB,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,MAAM,OAAO,KAAK;AACjC;AAEO,IAAM,mBAAmB,CAAoB,MAAS,SAA+B;AAC1F,SAAO,UAAU,MAAM,IAAI;AAC7B;","names":["key"]}
1
+ {"version":3,"sources":["../src/zod.ts"],"sourcesContent":["import Zod, { ZodType } from 'zod'\nimport { ResourceKey } from '@bessemer/cornerstone/resource'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { parse as jsonParse } from '@bessemer/cornerstone/json'\nimport { failure, getValueOrThrow, Result, success } from '@bessemer/cornerstone/result'\n\nexport type infer<T extends ZodType<any, any, any>> = Zod.infer<T>\nexport type input<T extends ZodType<any, any, any>> = Zod.input<T>\nexport type output<T extends ZodType<any, any, any>> = Zod.output<T>\nexport const object = Zod.object\nexport const string = Zod.string\nexport const union = Zod.union\nexport const array = Zod.array\nexport const unknown = Zod.unknown\nexport const nullType = Zod.null\nexport const undefined = Zod.undefined\nexport const date = Zod.date\nexport const boolean = Zod.boolean\nexport const number = Zod.number\nexport const tuple = Zod.tuple\nexport const record = Zod.record\nexport const lazy = Zod.lazy\n\nexport const arrayable = <T>(type: ZodType<T>) => {\n return union([type, array(type)])\n}\n\nexport const key = (): ZodType<ResourceKey> => {\n return string()\n}\n\nexport const entry = <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>): ZodType<Entry<Value, Key>> => {\n return tuple([key ?? string(), value]) as ZodType<Entry<Value, Key>>\n}\n\nexport const parse = <T extends ZodType>(type: T, data: unknown): Result<Zod.infer<T>> => {\n const result = type.safeParse(data)\n if (result.success) {\n return success(result.data)\n } else {\n return failure(result.error)\n }\n}\n\nexport const parseOrThrow = <T extends ZodType>(type: T, data: unknown): Zod.infer<T> => {\n return getValueOrThrow(parse(type, data))\n}\n\nexport const parseJson = <T extends ZodType>(type: T, data: string): Result<Zod.infer<T>> => {\n const result = jsonParse(data)\n if (!result.isSuccess) {\n return result\n }\n\n return parse(type, result.value)\n}\n\nexport const parseJsonOrThrow = <T extends ZodType>(type: T, data: string): Zod.infer<T> => {\n return parseJson(type, data)\n}\n"],"mappings":";AAAA,OAAO,SAAsB;AAG7B,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,iBAAyB,eAAe;AAKnD,IAAM,SAAS,IAAI;AACnB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAClB,IAAM,QAAQ,IAAI;AAClB,IAAM,UAAU,IAAI;AACpB,IAAM,WAAW,IAAI;AACrB,IAAM,YAAY,IAAI;AACtB,IAAM,OAAO,IAAI;AACjB,IAAM,UAAU,IAAI;AACpB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAClB,IAAM,SAAS,IAAI;AACnB,IAAM,OAAO,IAAI;AAEjB,IAAM,YAAY,CAAI,SAAqB;AAChD,SAAO,MAAM,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC;AAClC;AAEO,IAAM,MAAM,MAA4B;AAC7C,SAAO,OAAO;AAChB;AAEO,IAAM,QAAQ,CAAsB,OAAuBA,SAAmD;AACnH,SAAO,MAAM,CAACA,QAAO,OAAO,GAAG,KAAK,CAAC;AACvC;AAEO,IAAM,QAAQ,CAAoB,MAAS,SAAwC;AACxF,QAAM,SAAS,KAAK,UAAU,IAAI;AAClC,MAAI,OAAO,SAAS;AAClB,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B,OAAO;AACL,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAEO,IAAM,eAAe,CAAoB,MAAS,SAAgC;AACvF,SAAO,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAC1C;AAEO,IAAM,YAAY,CAAoB,MAAS,SAAuC;AAC3F,QAAM,SAAS,UAAU,IAAI;AAC7B,MAAI,CAAC,OAAO,WAAW;AACrB,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,MAAM,OAAO,KAAK;AACjC;AAEO,IAAM,mBAAmB,CAAoB,MAAS,SAA+B;AAC1F,SAAO,UAAU,MAAM,IAAI;AAC7B;","names":["key"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bessemer/cornerstone",
3
3
  "type": "module",
4
- "version": "0.5.45",
4
+ "version": "0.5.46",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "sideEffects": false,