nuabase 1.2.0 → 2.1.0

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,17 @@
1
+ import { Nua } from '../../nua';
2
+ export type TestMode = 'gateway' | 'direct';
3
+ /**
4
+ * Creates a Nua client for the specified test mode.
5
+ *
6
+ * Gateway mode: Requires api-server running on localhost:3030
7
+ * Direct mode: Requires one of GROQ_API_KEY, OPENROUTER_API_KEY, CEREBRAS_API_KEY, or GEMINI_API_KEY
8
+ *
9
+ * @param mode - 'gateway' or 'direct'
10
+ * @returns Configured Nua instance
11
+ */
12
+ export declare function createTestClient(mode: TestMode): Nua;
13
+ /**
14
+ * Returns the list of test modes to run based on environment.
15
+ * Respects SKIP_DIRECT_TESTS and SKIP_GATEWAY_TESTS env vars.
16
+ */
17
+ export declare function getTestModes(): TestMode[];
@@ -0,0 +1 @@
1
+ export { createTestClient, getTestModes, TestMode } from './client-factory';
@@ -0,0 +1,17 @@
1
+ import { CastArrayParams, CastResult, CastValueParams, LlmBackend } from './types';
2
+ import { LlmProviderId } from 'nua-llm-core';
3
+ export type DirectConfig = {
4
+ model: string;
5
+ providers: {
6
+ [key in LlmProviderId]?: {
7
+ apiKey: string;
8
+ };
9
+ };
10
+ };
11
+ export declare class DirectBackend implements LlmBackend {
12
+ private readonly client;
13
+ private readonly model;
14
+ constructor(config: DirectConfig);
15
+ castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
16
+ castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
17
+ }
@@ -0,0 +1,23 @@
1
+ import { CastArrayParams, CastResult, CastValueParams, LlmBackend, QueueResult } from './types';
2
+ type GatewayApiKeyConfig = {
3
+ apiKey?: string;
4
+ fetchToken?: never;
5
+ baseUrl?: string;
6
+ };
7
+ type GatewayTokenConfig = {
8
+ fetchToken: () => Promise<string>;
9
+ apiKey?: never;
10
+ baseUrl?: string;
11
+ };
12
+ export type GatewayConfig = GatewayApiKeyConfig | GatewayTokenConfig;
13
+ export declare class GatewayBackend implements LlmBackend {
14
+ private readonly baseUrl;
15
+ private readonly authManager;
16
+ constructor(config: GatewayConfig);
17
+ castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
18
+ castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
19
+ queueCastValue(params: CastValueParams): Promise<QueueResult>;
20
+ queueCastArray(params: CastArrayParams): Promise<QueueResult>;
21
+ private post;
22
+ }
23
+ export {};
@@ -0,0 +1,61 @@
1
+ export type CastValueParams = {
2
+ prompt: string;
3
+ data: unknown;
4
+ outputName: string;
5
+ outputSchema: object;
6
+ };
7
+ export type CastArrayParams = {
8
+ prompt: string;
9
+ data: unknown[];
10
+ primaryKey: string;
11
+ outputName: string;
12
+ outputSchema: object;
13
+ };
14
+ export type NormalizedUsage = {
15
+ promptTokens: number;
16
+ completionTokens: number;
17
+ totalTokens: number;
18
+ };
19
+ export type GatewayMeta = {
20
+ requestId: string;
21
+ cached: boolean;
22
+ llmUsage: NormalizedUsage;
23
+ cacheUsage: NormalizedUsage;
24
+ };
25
+ export type DirectMeta = unknown;
26
+ type CastResultSuccess<T> = {
27
+ success: true;
28
+ data: T;
29
+ usage: NormalizedUsage;
30
+ model: string;
31
+ latencyMs: number;
32
+ } & ({
33
+ source: 'gateway';
34
+ meta: GatewayMeta;
35
+ } | {
36
+ source: 'direct';
37
+ meta: DirectMeta;
38
+ });
39
+ type CastResultFailure = {
40
+ success: false;
41
+ error: string;
42
+ source: 'gateway' | 'direct';
43
+ latencyMs: number;
44
+ };
45
+ export type CastResult<T> = CastResultSuccess<T> | CastResultFailure;
46
+ export interface LlmBackend {
47
+ castValue<T>(params: CastValueParams): Promise<CastResult<T>>;
48
+ castArray<T>(params: CastArrayParams): Promise<CastResult<T[]>>;
49
+ queueCastValue?(params: CastValueParams): Promise<QueueResult>;
50
+ queueCastArray?(params: CastArrayParams): Promise<QueueResult>;
51
+ }
52
+ export type QueueResult = {
53
+ success: true;
54
+ jobId: string;
55
+ source: 'gateway' | 'direct';
56
+ } | {
57
+ success: false;
58
+ error: string;
59
+ source: 'gateway' | 'direct';
60
+ };
61
+ export {};
@@ -1,3 +1,6 @@
1
- export { type NuabaseConfig } from './lib/api-client';
2
- export { type NuabaseError } from './lib/error-response';
3
1
  export { Nua } from './nua';
2
+ export type { OutputDef, GetOptions, ListOptions, ListResultRow } from './nua';
3
+ export type { LlmBackend, CastResult, CastValueParams, CastArrayParams, NormalizedUsage, GatewayMeta, DirectMeta, QueueResult, } from './backend/types';
4
+ export type { GatewayConfig } from './backend/gateway';
5
+ export type { DirectConfig } from './backend/direct';
6
+ export { z } from 'zod';
@@ -1,3 +1,6 @@
1
- export { type NuabaseConfig } from './lib/api-client';
2
- export { type NuabaseError } from './lib/error-response';
3
1
  export { Nua } from './nua';
2
+ export type { OutputDef, GetOptions, ListOptions, ListResultRow } from './nua';
3
+ export type { LlmBackend, CastResult, CastValueParams, CastArrayParams, NormalizedUsage, GatewayMeta, DirectMeta, QueueResult, } from './backend/types';
4
+ export type { GatewayConfig } from './backend/gateway';
5
+ export type { DirectConfig } from './backend/direct';
6
+ export { z } from 'zod';
@@ -0,0 +1,12 @@
1
+ export type AuthConfig = {
2
+ apiKey?: string;
3
+ fetchToken?: () => Promise<string>;
4
+ };
5
+ export declare class AuthTokenManager {
6
+ private readonly apiKey?;
7
+ private readonly fetchToken?;
8
+ private apiToken?;
9
+ private pendingTokenPromise?;
10
+ constructor(config: AuthConfig);
11
+ getToken(): Promise<string>;
12
+ }
@@ -1,3 +1,34 @@
1
- export { Nua } from './nua/index';
2
- export { createArrayFn, validateArrayRequestParams } from './nua/index';
3
- export type { ArrayFn, ArrayFnDef } from './nua/index';
1
+ import { DirectConfig } from './backend/direct';
2
+ import { GatewayConfig } from './backend/gateway';
3
+ import { CastResult, QueueResult } from './backend/types';
4
+ import { z } from 'zod';
5
+ export type OutputDef<TSchema extends z.ZodTypeAny> = {
6
+ name: string;
7
+ schema: TSchema;
8
+ };
9
+ export type GetOptions<TSchema extends z.ZodTypeAny> = {
10
+ input?: unknown;
11
+ output: OutputDef<TSchema>;
12
+ };
13
+ export type ListOptions<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string> = {
14
+ input: TData[];
15
+ primaryKey: PrimaryKey;
16
+ output: OutputDef<TSchema>;
17
+ };
18
+ export type ListResultRow<TSchema extends z.ZodTypeAny, PrimaryKey extends string> = {
19
+ [K in PrimaryKey]: string | number;
20
+ } & {
21
+ [outputName: string]: z.infer<TSchema>;
22
+ };
23
+ export declare class Nua {
24
+ private readonly backend;
25
+ private constructor();
26
+ static gateway(config: GatewayConfig): Nua;
27
+ static direct(config: DirectConfig): Nua;
28
+ get(prompt: string): Promise<CastResult<string>>;
29
+ get<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<CastResult<z.infer<TSchema>>>;
30
+ list<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey>): Promise<CastResult<ListResultRow<TSchema, PrimaryKey>[]>>;
31
+ queueGet(prompt: string): Promise<QueueResult>;
32
+ queueGet<TSchema extends z.ZodTypeAny>(prompt: string, options: GetOptions<TSchema>): Promise<QueueResult>;
33
+ queueList<TSchema extends z.ZodTypeAny, TData extends Record<string, unknown>, PrimaryKey extends keyof TData & string>(prompt: string, options: ListOptions<TSchema, TData, PrimaryKey>): Promise<QueueResult>;
34
+ }
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "nuabase",
3
3
  "description": "Nuabase TypeScript client to create typed functions from LLM prompts",
4
- "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f",
5
- "version": "1.2.0",
4
+ "version": "2.1.0",
6
5
  "type": "module",
7
6
  "author": "Jasim A Basheer <jasim@nuabase.com>",
8
7
  "engines": {
@@ -17,12 +16,13 @@
17
16
  "license": "MIT",
18
17
  "repository": {
19
18
  "type": "git",
20
- "url": "git+https://github.com/nuabase/ts-sdk.git"
19
+ "url": "git+https://github.com/nuabase/nua-llm.git",
20
+ "directory": "nua-client"
21
21
  },
22
22
  "bugs": {
23
- "url": "https://github.com/nuabase/ts-sdk/issues"
23
+ "url": "https://github.com/nuabase/nua-llm/issues"
24
24
  },
25
- "homepage": "https://github.com/nuabase/ts-sdk#readme",
25
+ "homepage": "https://github.com/nuabase/nua-llm/tree/main/nua-client#readme",
26
26
  "main": "./dist/cjs/index.cjs",
27
27
  "types": "./dist/types/index.d.cts",
28
28
  "module": "./dist/esm/index.mjs",
@@ -38,23 +38,12 @@
38
38
  }
39
39
  }
40
40
  },
41
+ "dependencies": {
42
+ "ajv": "^8.17.1"
43
+ },
41
44
  "peerDependencies": {
42
45
  "zod": "^4.1.5"
43
46
  },
44
- "scripts": {
45
- "clean": "rimraf dist",
46
- "generate-dts": "tsx scripts/generate-dts",
47
- "build": "rollup -c rollup.config.js && npm run generate-dts",
48
- "pack:test": "tsx scripts/pack-test",
49
- "prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
50
- "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
51
- "typecheck": "tsc --noEmit",
52
- "lint": "eslint --cache .",
53
- "jest": "jest",
54
- "test": "npm run prettier:check && npm run typecheck && npm run lint && npm run jest && npm run build && npm run pack:test",
55
- "release": "npm test && tsx scripts/release",
56
- "knip": "knip"
57
- },
58
47
  "devDependencies": {
59
48
  "@eslint/js": "^9.35.0",
60
49
  "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
@@ -89,6 +78,21 @@
89
78
  "version-next": "^1.0.2",
90
79
  "yargs": "^18.0.0",
91
80
  "zod": "^4.1.5",
92
- "zx": "^8.8.1"
81
+ "zx": "^8.8.1",
82
+ "nua-llm-core": "1.0.0"
83
+ },
84
+ "scripts": {
85
+ "clean": "rimraf dist",
86
+ "generate-dts": "tsx scripts/generate-dts",
87
+ "build": "rollup -c rollup.config.js && pnpm run generate-dts",
88
+ "pack:test": "tsx scripts/pack-test",
89
+ "prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
90
+ "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
91
+ "typecheck": "tsc --noEmit",
92
+ "lint": "eslint --cache .",
93
+ "jest": "jest",
94
+ "test": "pnpm run prettier:check && pnpm run typecheck && pnpm run lint && pnpm run jest && pnpm run build && pnpm run pack:test",
95
+ "release": "pnpm test && tsx scripts/release",
96
+ "knip": "knip"
93
97
  }
94
- }
98
+ }
@@ -1,12 +0,0 @@
1
- import z from 'zod';
2
- export declare const processedSchema: z.ZodObject<{
3
- processed_id: z.ZodString;
4
- }, z.core.$strip>;
5
- export declare const sseResponseSchema: z.ZodObject<{
6
- isSuccess: z.ZodLiteral<true>;
7
- llmRequestId: z.ZodString;
8
- kind: z.ZodLiteral<"cast/value">;
9
- data: z.ZodUnknown;
10
- isCacheHit: z.ZodOptional<z.ZodBoolean>;
11
- }, z.core.$loose>;
12
- export declare const waitForSuccessfulSseMessage: (sseUrl: string, timeoutMs?: number) => Promise<Record<string, unknown>>;
@@ -1,19 +0,0 @@
1
- import { NuabaseError } from './error-response';
2
- type NuabaseApiKeyConfig = {
3
- apiKey?: string;
4
- fetchToken?: never;
5
- baseUrl?: string;
6
- };
7
- type NuabaseTokenConfig = {
8
- fetchToken: () => Promise<string>;
9
- apiKey?: never;
10
- baseUrl?: string;
11
- };
12
- export type NuabaseConfig = NuabaseApiKeyConfig | NuabaseTokenConfig;
13
- export declare class NuabaseAPIClient {
14
- private readonly baseUrl;
15
- private readonly authTokenManager;
16
- constructor(config?: NuabaseConfig);
17
- request(method: 'GET' | 'POST', urlPath: string, params?: object): Promise<NuabaseError | unknown>;
18
- }
19
- export {};
@@ -1,4 +0,0 @@
1
- import { NuabaseAPIClient } from '../../lib/api-client';
2
- import { ArrayFn, ArrayFnDef } from './types';
3
- import { z } from 'zod';
4
- export declare const createArrayFn: <OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(client: NuabaseAPIClient, inputFnDef: ArrayFnDef<OutputName, OutputZodSchema>) => ArrayFn<OutputZodSchema, OutputName>;
@@ -1 +0,0 @@
1
- export declare const validateArrayRequestParams: (data: unknown, primaryKeyName: unknown) => void;
@@ -1,19 +0,0 @@
1
- import { NormalizedUsage } from '../common/normalized-usage';
2
- import { z } from 'zod';
3
- export type UserDataPKValue = string | number;
4
- export type PrimaryKeyedInputRecord<PrimaryKeyName extends string> = Record<PrimaryKeyName, UserDataPKValue> & Record<string, unknown>;
5
- type ResponseRow<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = Pick<InputRecord, PrimaryKeyName> & Record<OutputName, z.infer<OutputZodSchema>>;
6
- type NuaApiResponseShape<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = {
7
- llmRequestId: string;
8
- kind: 'cast/array';
9
- data: Array<ResponseRow<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>>;
10
- cacheHits: number;
11
- rowsWithNoResults: UserDataPKValue[];
12
- isSuccess: true;
13
- isError?: false;
14
- usage: NormalizedUsage;
15
- };
16
- type NuaApiResponseCastArrayBuilder = <OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>>(primaryKeyName: PrimaryKeyName, outputKey: OutputName, outputSchema: OutputZodSchema) => z.ZodType<NuaApiResponseShape<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>>;
17
- export declare const zs_NuaApiResponse_CastArray: NuaApiResponseCastArrayBuilder;
18
- export type NuaApiResponse_CastArray<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = z.infer<ReturnType<typeof zs_NuaApiResponse_CastArray<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>>>;
19
- export {};
@@ -1,33 +0,0 @@
1
- import { NuabaseError } from '../../lib/error-response';
2
- import { NuaQueuedResponse } from '../common/queued-response';
3
- import type { NuaApiResponse_CastArray, PrimaryKeyedInputRecord } from './response-schema';
4
- import { z } from 'zod';
5
- export type ArrayFnDef<OutputName extends string, OutputZodSchema extends z.ZodTypeAny> = {
6
- prompt: string;
7
- output: {
8
- name: OutputName;
9
- schema: OutputZodSchema;
10
- };
11
- };
12
- export declare const validateArrayFnDef: <OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(fnDef: ArrayFnDef<OutputName, OutputZodSchema>) => ArrayFnDef<OutputName, OutputZodSchema>;
13
- type CastArraySuccessFromApi<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = NuaApiResponse_CastArray<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>;
14
- type CastArraySourceRowAugmentation<PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = {
15
- /**
16
- * SDK-added field containing the full input row for convenience; not returned by the API.
17
- */
18
- sourceRow: InputRecord;
19
- };
20
- type CastArraySuccessRowWithSource<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = CastArraySuccessFromApi<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>['data'][number] & CastArraySourceRowAugmentation<PrimaryKeyName, InputRecord>;
21
- export type CastArraySuccessWithSource<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = Omit<CastArraySuccessFromApi<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>, 'data'> & {
22
- /**
23
- * Each row mirrors the API payload and includes the SDK-provided `sourceRow`.
24
- */
25
- data: CastArraySuccessRowWithSource<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>[];
26
- };
27
- export type ArrayFnResult<OutputZodSchema extends z.ZodTypeAny, OutputName extends string, PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>> = NuabaseError | CastArraySuccessWithSource<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>;
28
- export type ArrayFnQueuedResult = NuabaseError | NuaQueuedResponse;
29
- export type ArrayFn<OutputZodSchema extends z.ZodTypeAny, OutputName extends string> = {
30
- <PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>>(data: InputRecord[], primaryKeyName: PrimaryKeyName): Promise<ArrayFnResult<OutputZodSchema, OutputName, PrimaryKeyName, InputRecord>>;
31
- queue: <PrimaryKeyName extends string, InputRecord extends PrimaryKeyedInputRecord<PrimaryKeyName>>(data: InputRecord[], primaryKeyName: PrimaryKeyName) => Promise<ArrayFnQueuedResult>;
32
- };
33
- export {};
@@ -1,4 +0,0 @@
1
- import { NuabaseAPIClient } from '../../lib/api-client';
2
- import { ValueFn, ValueFnDef } from './types';
3
- import { z } from 'zod';
4
- export declare const createValueFn: <OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(client: NuabaseAPIClient, inputFnDef: ValueFnDef<OutputName, OutputZodSchema>) => ValueFn<OutputZodSchema, OutputName>;
@@ -1,15 +0,0 @@
1
- import { NormalizedUsage } from '../common/normalized-usage';
2
- import { z } from 'zod';
3
- type NuaApiResponseShape<OutputZodSchema extends z.ZodTypeAny> = {
4
- llmRequestId: string;
5
- kind: 'cast/value';
6
- data: z.infer<OutputZodSchema>;
7
- isCacheHit: boolean;
8
- isSuccess: true;
9
- isError?: false;
10
- usage: NormalizedUsage;
11
- };
12
- type NuaApiResponseCastValueBuilder = <OutputZodSchema extends z.ZodTypeAny, OutputName extends string>(outputKey: OutputName, outputSchema: OutputZodSchema) => z.ZodType<NuaApiResponseShape<OutputZodSchema>>;
13
- export declare const zs_NuaApiResponse_CastValue: NuaApiResponseCastValueBuilder;
14
- export type NuaApiResponse_CastValue<OutputZodSchema extends z.ZodTypeAny, OutputName extends string> = z.infer<ReturnType<typeof zs_NuaApiResponse_CastValue<OutputZodSchema, OutputName>>>;
15
- export {};
@@ -1,18 +0,0 @@
1
- import { NuabaseError } from '../../lib/error-response';
2
- import { NuaQueuedResponse } from '../common/queued-response';
3
- import { NuaApiResponse_CastValue } from './response-schema';
4
- import { z } from 'zod';
5
- export type ValueFnDef<OutputName extends string, OutputZodSchema extends z.ZodTypeAny> = {
6
- prompt: string;
7
- output: {
8
- name: OutputName;
9
- schema: OutputZodSchema;
10
- };
11
- };
12
- export declare const validateValueFnDef: <OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(fnDef: ValueFnDef<OutputName, OutputZodSchema>) => ValueFnDef<OutputName, OutputZodSchema>;
13
- export type ValueFnResult<OutputZodSchema extends z.ZodTypeAny, OutputName extends string> = NuabaseError | NuaApiResponse_CastValue<OutputZodSchema, OutputName>;
14
- export type ValueFnQueuedResult = NuabaseError | NuaQueuedResponse;
15
- export type ValueFn<OutputZodSchema extends z.ZodTypeAny, OutputName extends string> = {
16
- (data: unknown): Promise<ValueFnResult<OutputZodSchema, OutputName>>;
17
- queue: (data: unknown) => Promise<ValueFnQueuedResult>;
18
- };
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- export type NormalizedUsage = {
3
- promptTokens: number;
4
- completionTokens: number;
5
- totalTokens: number;
6
- };
7
- export declare const zs_NormalizedUsage: z.ZodType<NormalizedUsage>;
@@ -1,6 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const zs_NuaQueuedResponse: z.ZodObject<{
3
- id: z.ZodString;
4
- sseUrl: z.ZodString;
5
- }, z.core.$strict>;
6
- export type NuaQueuedResponse = z.infer<typeof zs_NuaQueuedResponse>;
@@ -1,12 +0,0 @@
1
- import { NuabaseAPIClient, NuabaseConfig } from '../lib/api-client';
2
- import { ArrayFn, ArrayFnDef } from './cast_array/types';
3
- import { ValueFn, ValueFnDef } from './cast_value/types';
4
- import { GetRequestResult } from './get-request';
5
- import { z } from 'zod';
6
- export declare class Nua {
7
- apiClient: NuabaseAPIClient;
8
- constructor(config?: NuabaseConfig);
9
- createArrayFn<OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(fnDef: ArrayFnDef<OutputName, OutputZodSchema>): ArrayFn<OutputZodSchema, OutputName>;
10
- createFn<OutputName extends string, OutputZodSchema extends z.ZodTypeAny>(fnDef: ValueFnDef<OutputName, OutputZodSchema>): ValueFn<OutputZodSchema, OutputName>;
11
- getRequest(llmRequestId: string): Promise<GetRequestResult>;
12
- }
@@ -1,6 +0,0 @@
1
- import { NuabaseAPIClient } from '../../lib/api-client';
2
- import { NuabaseError } from '../../lib/error-response';
3
- import { ApiResponseLlmRequest, NuaInternalError } from './types';
4
- export type GetRequestResult = ApiResponseLlmRequest | NuaInternalError | NuabaseError;
5
- export declare function getRequest(client: NuabaseAPIClient, llmRequestId: string): Promise<GetRequestResult>;
6
- export type { ApiResponseLlmRequest, LlmRequestStatus, NuaInternalError, SseRequestStatus, WebhookRequestStatus, } from './types';
@@ -1,34 +0,0 @@
1
- export type LlmRequestType = string;
2
- export type LlmRequestStatus = 'pending' | 'processing' | 'success' | 'failed';
3
- export type SseRequestStatus = 'n/a' | 'pending' | 'sent' | 'failed';
4
- export type WebhookRequestStatus = 'n/a' | 'pending' | 'sent' | 'failed';
5
- export type NuaInternalError = {
6
- kind: 'internal-error';
7
- message: string;
8
- };
9
- export type ApiResponseLlmRequest = {
10
- id: string;
11
- requestType: LlmRequestType;
12
- llmStatus: LlmRequestStatus;
13
- sseStatus: SseRequestStatus;
14
- webhookStatus: WebhookRequestStatus;
15
- input: {
16
- prompt: string | null;
17
- data: string | null;
18
- primaryKey: string | null;
19
- };
20
- output: {
21
- name: string;
22
- schema: string;
23
- effectiveSchema: string;
24
- };
25
- result?: Record<string, unknown> | null;
26
- error: string | null;
27
- fullPrompt: string;
28
- model: string;
29
- provider: string;
30
- startedAt: Date | null;
31
- finishedAt: Date | null;
32
- createdAt: Date;
33
- updatedAt: Date;
34
- };
@@ -1,5 +0,0 @@
1
- export { Nua } from './core';
2
- export { createArrayFn } from './cast_array/factory';
3
- export { validateArrayRequestParams } from './cast_array/request-validation';
4
- export type { ArrayFn, ArrayFnDef } from './cast_array/types';
5
- export type { ApiResponseLlmRequest, GetRequestResult, LlmRequestStatus, NuaInternalError, SseRequestStatus, WebhookRequestStatus, } from './get-request';