@tstdl/base 0.92.27 → 0.92.29

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/ai/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { LiteralUnion } from 'type-fest';
2
2
  import type { ObjectSchema, SchemaOutput, SchemaTestable } from '../schema/index.js';
3
- import type { Record, TypedOmit, UndefinableJsonObject } from '../types.js';
3
+ import type { Record, UndefinableJsonObject } from '../types.js';
4
4
  import type { ResolvedValueOrProvider, ValueOrAsyncProvider } from '../utils/value-or-provider.js';
5
5
  export type FileInput = {
6
6
  path: string;
@@ -84,6 +84,5 @@ export type GenerationResult = {
84
84
  usage: GenerationUsage;
85
85
  };
86
86
  export declare function defineFunctions<T extends SchemaFunctionDeclarations>(declarations: T): T;
87
- export declare function defineFunction<P extends Record, T extends TypedOmit<SchemaFunctionDeclarationWithHandler<P>, 'parameters'>>(declaration: T & Pick<SchemaFunctionDeclarationWithHandler<P>, 'parameters'>): T;
88
- export declare function defineFunction<T extends SchemaFunctionDeclarationWithoutHandler>(declaration: T): T;
87
+ export declare function defineFunction<P extends Record, T extends SchemaFunctionDeclaration<P>>(declaration: T & Pick<SchemaFunctionDeclaration<P>, 'parameters'>): T;
89
88
  export declare function isSchemaFunctionDeclarationWithHandler(declaration: SchemaFunctionDeclaration): declaration is SchemaFunctionDeclarationWithHandler;
@@ -0,0 +1,8 @@
1
+ import type { Tagged } from 'type-fest';
2
+ import type { EnumerationObject } from '../types.js';
3
+ export type EnumType<T extends EnumerationObject> = T[keyof T];
4
+ export declare function defineEnum<const Name extends string, const T extends EnumerationObject>(name: Name, enumObject: T): {
5
+ [P in keyof T]: Tagged<T[P], Name>;
6
+ };
7
+ export declare function tryGetEnumName(enumeration: EnumerationObject): string | undefined;
8
+ export declare function getEnumName(enumeration: EnumerationObject): string;
@@ -0,0 +1,16 @@
1
+ import { isUndefined } from '../utils/type-guards.js';
2
+ const registry = new WeakMap();
3
+ export function defineEnum(name, enumObject) {
4
+ registry.set(enumObject, name);
5
+ return enumObject;
6
+ }
7
+ export function tryGetEnumName(enumeration) {
8
+ return registry.get(enumeration);
9
+ }
10
+ export function getEnumName(enumeration) {
11
+ const name = tryGetEnumName(enumeration);
12
+ if (isUndefined(name)) {
13
+ throw new Error('Unknown enumeration');
14
+ }
15
+ return name;
16
+ }
@@ -0,0 +1 @@
1
+ export * from './enumeration.js';
@@ -0,0 +1 @@
1
+ export * from './enumeration.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.27",
3
+ "version": "0.92.29",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -47,6 +47,7 @@
47
47
  "./distributed-loop": "./distributed-loop/index.js",
48
48
  "./dom": "./dom/index.js",
49
49
  "./document-management": "./document-management/index.js",
50
+ "./enumeration": "./enumeration/index.js",
50
51
  "./enumerable": "./enumerable/index.js",
51
52
  "./errors": "./errors/index.js",
52
53
  "./file": "./file/index.js",