@bessemer/cornerstone 0.5.43 → 0.5.44
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.
- package/dist/cache.d.ts +1 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/content.d.ts +7 -17
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js.map +1 -1
- package/dist/error-event.d.ts +5 -13
- package/dist/error-event.d.ts.map +1 -1
- package/dist/error-event.js +1 -1
- package/dist/error-event.js.map +1 -1
- package/dist/glob.d.ts +1 -1
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js.map +1 -1
- package/dist/hex-code.d.ts +1 -1
- package/dist/hex-code.d.ts.map +1 -1
- package/dist/range.d.ts +2 -2
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js.map +1 -1
- package/dist/resource.d.ts +1 -1
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js.map +1 -1
- package/dist/zod.d.ts +18 -26
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +1 -1
- package/dist/zod.js.map +1 -1
- package/package.json +2 -2
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';
|
9
|
+
import { ZodType } from 'zod/v4';
|
10
10
|
export type CacheProps = {
|
11
11
|
maxSize: number | null;
|
12
12
|
timeToLive: Duration;
|
package/dist/cache.d.ts.map
CHANGED
@@ -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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ache.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,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,KAA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Q,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"]}
|
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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}
|
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';
|
6
|
+
import { ZodType } from 'zod/v4';
|
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,22 +12,12 @@ 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").ZodObject<{
|
16
|
-
key: ZodType<ContentKey,
|
17
|
-
type: ZodType<ContentType<unknown>,
|
18
|
-
data: import("zod").ZodUnknown;
|
19
|
-
sector: import("zod").ZodNullable<ZodType<ContentSector,
|
20
|
-
},
|
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
|
-
}>;
|
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>;
|
31
21
|
export type ContentData<Type extends ContentType = ContentType, Data = ContentDataType<Type>> = Referencable<ContentReference> & {
|
32
22
|
key: ContentKey;
|
33
23
|
type: Type;
|
package/dist/content.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAChE,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAgB,CAAA;AAEvE,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,YAAY,C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B,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW,EAAE,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;IAC9H,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,IAAI,SAAS,WAAW,GAAG,WAAW,EAAE,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,EAC7F,KAAK,UAAU,EACf,MAAM,IAAI,EACV,MAAM,IAAI,EACV,UAAU;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,aAAa,CAAA;CAAE,KACtD,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAS9B,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,kBAAkB,SAAS,0BAA0B,EAClF,SAAS,KAAK,CAAC,iBAAiB,CAAC,EACjC,cAAc,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,KACzD,eAAe,CAAC,kBAAkB,CA2BpC,CAAA"}
|
package/dist/content.js.map
CHANGED
@@ -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'\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,QAAQ,CAAC,OAAO,EAAE;AAC1F,SAAO;AACT;AAMO,I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AACC,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/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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O,SAAS,MAAM,GAAG,GAAG,CAAC;AAE5E,YAAM,kBAAkB,OAAO,OAAO,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"]}
|
package/dist/error-event.d.ts
CHANGED
@@ -1,23 +1,15 @@
|
|
1
1
|
import { NominalType, Throwable } from '@bessemer/cornerstone/types';
|
2
2
|
import { RecordAttribute } from '@bessemer/cornerstone/object';
|
3
|
-
import Zod, { ZodType } from 'zod';
|
3
|
+
import Zod, { ZodType } from 'zod/v4';
|
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>;
|
7
|
+
export declare const ErrorAttributeSchema: ZodType<ErrorAttribute, string>;
|
8
8
|
declare const baseErrorEventSchema: Zod.ZodObject<{
|
9
|
-
code: Zod.ZodType<ErrorCode,
|
9
|
+
code: Zod.ZodType<ErrorCode, unknown>;
|
10
10
|
message: Zod.ZodString;
|
11
|
-
attributes: Zod.ZodRecord<Zod.ZodType<ErrorAttribute<unknown>,
|
12
|
-
},
|
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
|
-
}>;
|
11
|
+
attributes: Zod.ZodRecord<Zod.ZodType<ErrorAttribute<unknown>, string>, Zod.ZodUnknown>;
|
12
|
+
}, Zod.core.$strip>;
|
21
13
|
export type ErrorEvent = Zod.infer<typeof baseErrorEventSchema> & {
|
22
14
|
causes: Array<ErrorEvent>;
|
23
15
|
};
|
@@ -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,
|
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,EA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AM,MAAM,KAAG,UAAU,GAAG,SAEtF,CAAA;AAOD,eAAO,MAAM,iBAAiB,GAAI,OAAO,UAAU,EAAE,WAAW,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,KAAG,UAAU,GAAG,SAM7G,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,SAAS,iBAAiB,EAAE,QAAQ,KAAK,CAAC,UAAU,CAAC,KAAG,UAAU,GAAG,SAM9F,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,SAAmC,CAAA;AACpE,eAAO,MAAM,iBAAiB,EAAE,SAAmC,CAAA;AACnE,eAAO,MAAM,qBAAqB,EAAE,SAAsC,CAAA;AAC1E,eAAO,MAAM,mBAAmB,EAAE,SAAqC,CAAA;AAEvE,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,MAAM,CAA0B,CAAA;AAC3F,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,MAAM,CAAoB,CAAA;AAE/E,eAAO,MAAM,SAAS,GAAI,UAAU,OAAO,CAAC,iBAAiB,CAAC,eAO3D,CAAA;AAEH,eAAO,MAAM,QAAQ,GAAI,UAAU,OAAO,CAAC,iBAAiB,CAAC,eAO1D,CAAA;AAEH,eAAO,MAAM,YAAY,GAAI,UAAU,OAAO,CAAC,iBAAiB,CAAC,eAO9D,CAAA;AAEH,eAAO,MAAM,UAAU,GAAI,UAAU,OAAO,CAAC,iBAAiB,CAAC,eAO5D,CAAA"}
|
package/dist/error-event.js
CHANGED
package/dist/error-event.js.map
CHANGED
@@ -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'\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,
|
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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1G,MAAI,OAAO,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":[]}
|
package/dist/glob.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { NominalType } from '@bessemer/cornerstone/types';
|
2
|
-
import { ZodType } from 'zod';
|
2
|
+
import { ZodType } from 'zod/v4';
|
3
3
|
export type GlobPattern = NominalType<string, 'GlobPattern'>;
|
4
4
|
export declare const GlobPatternSchema: ZodType<GlobPattern>;
|
5
5
|
export declare const schema: () => ZodType<GlobPattern>;
|
package/dist/glob.d.ts.map
CHANGED
@@ -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,
|
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"}
|
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'\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/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":[]}
|
package/dist/hex-code.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { Zod } from '@bessemer/cornerstone';
|
2
|
-
export declare const HexCodeSchema: import("zod")
|
2
|
+
export declare const HexCodeSchema: import("zod/v4/core").$ZodBranded<import("zod/v4").ZodString, "HexCode">;
|
3
3
|
export type HexCode = Zod.infer<typeof HexCodeSchema>;
|
4
4
|
//# sourceMappingURL=hex-code.d.ts.map
|
package/dist/hex-code.d.ts.map
CHANGED
@@ -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,
|
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"}
|
package/dist/range.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ZodType } from 'zod';
|
1
|
+
import { ZodType } from 'zod/v4';
|
2
2
|
import { TaggedType } from '@bessemer/cornerstone/types';
|
3
|
-
export declare const boundsSchema: <T extends ZodType>(type: T) => import("zod")
|
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">;
|
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
|
package/dist/range.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
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"}
|
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'\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,
|
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"]}
|
package/dist/resource.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { NominalType } from '@bessemer/cornerstone/types';
|
2
|
-
import { ZodType } from 'zod';
|
2
|
+
import { ZodType } from 'zod/v4';
|
3
3
|
export type ResourceKey = string;
|
4
4
|
export type ResourceNamespace = NominalType<string, 'ResourceNamespace'>;
|
5
5
|
export declare const ResourceNamespaceSchema: ZodType<ResourceNamespace>;
|
package/dist/resource.d.ts.map
CHANGED
@@ -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,
|
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"}
|
package/dist/resource.js.map
CHANGED
@@ -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'\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/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"]}
|
package/dist/zod.d.ts
CHANGED
@@ -1,32 +1,24 @@
|
|
1
|
-
import Zod, { ZodType } from 'zod';
|
1
|
+
import Zod, { ZodType } from 'zod/v4';
|
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
|
6
|
-
export type input<T extends ZodType<any, any
|
7
|
-
export type output<T extends ZodType<any, any
|
8
|
-
export declare const object:
|
9
|
-
export declare const string:
|
10
|
-
|
11
|
-
|
12
|
-
export declare const
|
13
|
-
export declare const
|
14
|
-
export declare const
|
15
|
-
export declare const
|
16
|
-
export declare const
|
17
|
-
export declare const
|
18
|
-
|
19
|
-
|
20
|
-
export declare const
|
21
|
-
|
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">]>;
|
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>>]>;
|
30
22
|
export declare const key: () => ZodType<ResourceKey>;
|
31
23
|
export declare const entry: <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>) => ZodType<Entry<Value, Key>>;
|
32
24
|
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,
|
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;AAC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,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
package/dist/zod.js.map
CHANGED
@@ -1 +1 @@
|
|
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
|
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"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bessemer/cornerstone",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.5.
|
4
|
+
"version": "0.5.44",
|
5
5
|
"module": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
7
7
|
"sideEffects": false,
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"pino": "9.6.0",
|
31
31
|
"type-fest": "4.32.0",
|
32
32
|
"ulid": "2.3.0",
|
33
|
-
"zod": "3.
|
33
|
+
"zod": "3.25.6"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
36
|
"pino-pretty": "13.0.0"
|