@vite-hub/choices 0.5.0 → 0.5.1
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/cli.d.ts +1 -8
- package/dist/cli.js +4 -7
- package/dist/{diagnostics-BubnKF2J.js → diagnostics-D9hxehC1.js} +1 -2
- package/dist/index.d.ts +1 -5
- package/dist/index.js +4 -6
- package/dist/{selection-gateway-D2jci9t-.js → selection-gateway-BB8o3bIT.js} +1 -2
- package/dist/testing.d.ts +2 -3
- package/dist/testing.js +3 -4
- package/dist/{types-slPoBTpx.d.ts → types-DNHgwMWj.d.ts} +0 -2
- package/dist/vue.d.ts +1 -3
- package/dist/vue.js +1 -2
- package/package.json +8 -8
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Diagnostic } from "nostics";
|
|
2
|
-
//#region ../internal/src/host-credentials.d.ts
|
|
3
2
|
interface HostCliRunResult {
|
|
4
3
|
exitCode: number | null;
|
|
5
4
|
stdout: string;
|
|
@@ -11,8 +10,6 @@ type HostCliRun = (command: string, args: readonly string[], options: {
|
|
|
11
10
|
env: NodeJS.ProcessEnv;
|
|
12
11
|
signal?: AbortSignal;
|
|
13
12
|
}) => Promise<HostCliRunResult>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../internal/src/provision.d.ts
|
|
16
13
|
type ProvisionProvider = "cloudflare" | "vercel";
|
|
17
14
|
interface ProvisionLogger {
|
|
18
15
|
log: (message: string) => void;
|
|
@@ -64,8 +61,6 @@ interface ProvisionStep {
|
|
|
64
61
|
/** Describes the Provision State this step records. Runs without network access, also without credentials. */
|
|
65
62
|
recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
|
|
66
63
|
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../internal/src/cli.d.ts
|
|
69
64
|
interface ViteHubCliStreams {
|
|
70
65
|
stderr: {
|
|
71
66
|
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
@@ -126,8 +121,6 @@ interface ViteHubCliCommandNamespace {
|
|
|
126
121
|
name: string;
|
|
127
122
|
}
|
|
128
123
|
type StdoutWriteCallback = (error?: Error | null) => void;
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/cli.d.ts
|
|
131
124
|
interface FoundChoices {
|
|
132
125
|
export: string;
|
|
133
126
|
name: string | undefined;
|
|
@@ -144,4 +137,4 @@ export declare function listChoices(rootDir: string): Promise<ListedFile[]>;
|
|
|
144
137
|
* `run` calls the gateway of the definition, so it reads the same keys as the app, from the shell or the `.env` files.
|
|
145
138
|
*/
|
|
146
139
|
export declare function createChoicesCliNamespace(): ViteHubCliCommandNamespace;
|
|
147
|
-
|
|
140
|
+
export {};
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as choicesDiagnostics } from "./diagnostics-
|
|
1
|
+
import { t as choicesDiagnostics } from "./diagnostics-D9hxehC1.js";
|
|
2
2
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
3
3
|
import { relative, resolve } from "node:path";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
|
-
|
|
5
|
+
// ../internal/src/cli.ts
|
|
6
6
|
const stdoutRedirectQueueKey = Symbol.for("vite-hub.internal.stdout-redirect-queue");
|
|
7
7
|
const stdoutRedirectWriterKey = Symbol.for("vite-hub.internal.stdout-redirect-writer");
|
|
8
8
|
const stdoutRedirectSourceKey = Symbol.for("vite-hub.internal.stdout-redirect-source");
|
|
@@ -58,8 +58,7 @@ function getStableStdoutWrite() {
|
|
|
58
58
|
}
|
|
59
59
|
return stdoutRedirectGlobal[stdoutRedirectWriterKey] ?? current.bind(process.stdout);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
//#region ../internal/src/vite-stage.ts
|
|
61
|
+
// ../internal/src/vite-stage.ts
|
|
63
62
|
/**
|
|
64
63
|
* Vite's `loadEnv(mode, envDir, "")`: every `.env` value of the mode and the whole shell. With `DEBUG=vite:env`, Vite
|
|
65
64
|
* logs that result to stderr, secrets included. loadEnv is synchronous, so this drops only the writes of this call.
|
|
@@ -73,8 +72,7 @@ function loadAllEnv(loadEnv, mode, envDir) {
|
|
|
73
72
|
process.stderr.write = write;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
//#region src/cli.ts
|
|
75
|
+
// src/cli.ts
|
|
78
76
|
const listUsage = "vitehub choices list [--json]";
|
|
79
77
|
const runUsage = "vitehub choices run <file> <text> [--export <name>] [--context <json>] [--inspect]";
|
|
80
78
|
const sourceExtensions = /\.(?:[cm]?[jt]s)$/;
|
|
@@ -275,5 +273,4 @@ function createChoicesCliNamespace() {
|
|
|
275
273
|
name: "choices"
|
|
276
274
|
};
|
|
277
275
|
}
|
|
278
|
-
//#endregion
|
|
279
276
|
export { createChoicesCliNamespace, listChoices };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const choicesDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/choices/diagnostics",
|
|
@@ -42,5 +42,4 @@ const choicesDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
//#endregion
|
|
46
45
|
export { choicesDiagnostics as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { _ as MultipleSelection, a as Choices, c as ChoicesError, d as ChoicesRequest, f as ChoicesResult, g as GroupsContext, h as GroupValue, i as ChoiceValue, l as ChoicesLimits, m as ChoicesThresholds, n as ChoiceGroups, o as ChoicesArgs, p as ChoicesSelection, r as ChoiceOption, s as ChoicesDefinition, t as ChoiceGroup, u as ChoicesPlan, v as SingleSelection } from "./types-
|
|
2
|
-
//#region src/choices.d.ts
|
|
1
|
+
import { _ as MultipleSelection, a as Choices, c as ChoicesError, d as ChoicesRequest, f as ChoicesResult, g as GroupsContext, h as GroupValue, i as ChoiceValue, l as ChoicesLimits, m as ChoicesThresholds, n as ChoiceGroups, o as ChoicesArgs, p as ChoicesSelection, r as ChoiceOption, s as ChoicesDefinition, t as ChoiceGroup, u as ChoicesPlan, v as SingleSelection } from "./types-DNHgwMWj.js";
|
|
3
2
|
/**
|
|
4
3
|
* Declares the options that text can choose from, and how to ask a gateway about them.
|
|
5
4
|
* Nothing here knows your UI, your routes, or your store. Call `resolve()` wherever you run server code.
|
|
6
5
|
*/
|
|
7
6
|
export declare function defineChoices<const TGroups extends ChoiceGroups>(definition: ChoicesDefinition<TGroups>): Choices<TGroups>;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/options.d.ts
|
|
10
7
|
interface ToOptionsMap<TItem, TValue extends ChoiceValue> {
|
|
11
8
|
aliases?: (item: TItem) => readonly string[] | undefined;
|
|
12
9
|
description?: (item: TItem) => string | undefined;
|
|
@@ -15,5 +12,4 @@ interface ToOptionsMap<TItem, TValue extends ChoiceValue> {
|
|
|
15
12
|
}
|
|
16
13
|
/** Maps your own items to options. This is the bridge from your data to Choices. */
|
|
17
14
|
export declare function toOptions<TItem, TValue extends ChoiceValue>(items: readonly TItem[], map: ToOptionsMap<TItem, TValue>): ChoiceOption<TValue>[];
|
|
18
|
-
//#endregion
|
|
19
15
|
export type { ChoiceGroup, ChoiceGroups, ChoiceOption, ChoiceValue, Choices, ChoicesArgs, ChoicesDefinition, ChoicesError, ChoicesLimits, ChoicesPlan, ChoicesRequest, ChoicesResult, ChoicesSelection, ChoicesThresholds, GroupValue, GroupsContext, MultipleSelection, SingleSelection, ToOptionsMap };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as choicesDiagnostics } from "./diagnostics-
|
|
2
|
-
import { t as resolveSelection } from "./selection-gateway-
|
|
1
|
+
import { t as choicesDiagnostics } from "./diagnostics-D9hxehC1.js";
|
|
2
|
+
import { t as resolveSelection } from "./selection-gateway-BB8o3bIT.js";
|
|
3
3
|
import { ask, askWithModel } from "@vite-hub/gateways";
|
|
4
4
|
import { getPublicAiGatewayDiagnostic } from "@vite-hub/gateways/internal";
|
|
5
|
-
|
|
5
|
+
// src/choices.ts
|
|
6
6
|
const defaultLimits = {
|
|
7
7
|
groups: 40,
|
|
8
8
|
options: 100,
|
|
@@ -326,8 +326,7 @@ function defineChoices(definition) {
|
|
|
326
326
|
}
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
-
|
|
330
|
-
//#region src/options.ts
|
|
329
|
+
// src/options.ts
|
|
331
330
|
/** Maps your own items to options. This is the bridge from your data to Choices. */
|
|
332
331
|
function toOptions(items, map) {
|
|
333
332
|
return items.map((item) => {
|
|
@@ -341,5 +340,4 @@ function toOptions(items, map) {
|
|
|
341
340
|
};
|
|
342
341
|
});
|
|
343
342
|
}
|
|
344
|
-
//#endregion
|
|
345
343
|
export { defineChoices, toOptions };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/selection-gateway.ts
|
|
2
2
|
/** Internal protocol shared by the production and testing entries, even across package copies. */
|
|
3
3
|
const resolveSelection = Symbol.for("vitehub.choices.resolveSelection");
|
|
4
|
-
//#endregion
|
|
5
4
|
export { resolveSelection as t };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { g as GroupsContext, h as GroupValue, i as ChoiceValue, n as ChoiceGroups } from "./types-
|
|
1
|
+
import { g as GroupsContext, h as GroupValue, i as ChoiceValue, n as ChoiceGroups } from "./types-DNHgwMWj.js";
|
|
2
2
|
import { AiGatewayAsk } from "@vite-hub/gateways";
|
|
3
|
-
//#region src/testing.d.ts
|
|
4
3
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
4
|
/** Return it from `selectionGateway()` to say that the options cannot express the text. `resolve()` returns `DECISIONS_R0004`. */
|
|
6
5
|
export declare const unsupported: unique symbol;
|
|
@@ -44,4 +43,4 @@ export declare function selectionGateway<TGroups extends ChoiceGroups = ChoiceGr
|
|
|
44
43
|
export declare function wordGateway(): {
|
|
45
44
|
ask: AiGatewayAsk;
|
|
46
45
|
};
|
|
47
|
-
|
|
46
|
+
export {};
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as choicesDiagnostics } from "./diagnostics-
|
|
2
|
-
import { t as resolveSelection } from "./selection-gateway-
|
|
1
|
+
import { t as choicesDiagnostics } from "./diagnostics-D9hxehC1.js";
|
|
2
|
+
import { t as resolveSelection } from "./selection-gateway-BB8o3bIT.js";
|
|
3
3
|
import { answers } from "@vite-hub/gateways/testing";
|
|
4
|
-
|
|
4
|
+
// src/testing.ts
|
|
5
5
|
/** Return it from `selectionGateway()` to say that the options cannot express the text. `resolve()` returns `DECISIONS_R0004`. */
|
|
6
6
|
const unsupported = Symbol("unsupported");
|
|
7
7
|
function invalid(problem) {
|
|
@@ -122,5 +122,4 @@ function wordGateway() {
|
|
|
122
122
|
};
|
|
123
123
|
return { ask };
|
|
124
124
|
}
|
|
125
|
-
//#endregion
|
|
126
125
|
export { selectionGateway, unsupported, wordGateway };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AiGatewayAsk, AiGatewayAskOptions, AskModel } from "@vite-hub/gateways";
|
|
2
2
|
import { Diagnostic } from "nostics";
|
|
3
|
-
//#region src/types.d.ts
|
|
4
3
|
/** The value that you map back to your data. It must be unique within its group. */
|
|
5
4
|
type ChoiceValue = string | number;
|
|
6
5
|
/** One option of a group. `value` is yours, `label`, `aliases`, and `description` are what the model reads. */
|
|
@@ -144,5 +143,4 @@ interface Choices<TGroups extends ChoiceGroups> {
|
|
|
144
143
|
/** Asks the gateway which options the text names. It returns `[error, selection]` and never throws. */
|
|
145
144
|
resolve: (text: string, ...args: ChoicesArgs<GroupsContext<TGroups>>) => Promise<ChoicesResult<ChoicesSelection<TGroups>>>;
|
|
146
145
|
}
|
|
147
|
-
//#endregion
|
|
148
146
|
export { MultipleSelection as _, Choices as a, ChoicesError as c, ChoicesRequest as d, ChoicesResult as f, GroupsContext as g, GroupValue as h, ChoiceValue as i, ChoicesLimits as l, ChoicesThresholds as m, ChoiceGroups as n, ChoicesArgs as o, ChoicesSelection as p, ChoiceOption as r, ChoicesDefinition as s, ChoiceGroup as t, ChoicesPlan as u, SingleSelection as v };
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
|
-
//#region src/vue.d.ts
|
|
3
2
|
/** Any Choices object. Its `resolve()` parameters do not matter here. */
|
|
4
3
|
export interface ChoicesLike {
|
|
5
4
|
resolve: (text: never, ...args: never[]) => Promise<unknown>;
|
|
@@ -50,5 +49,4 @@ export interface UseChoicesResult<TSelection> {
|
|
|
50
49
|
* `import type`, so no server code reaches the browser.
|
|
51
50
|
*/
|
|
52
51
|
export declare function useChoices<TChoices extends ChoicesLike>(options: UseChoicesOptions<ChoicesSelectionOf<TChoices>>): UseChoicesResult<ChoicesSelectionOf<TChoices>>;
|
|
53
|
-
export declare function useChoices<TSelection>(options: UseChoicesOptions<TSelection>): UseChoicesResult<TSelection>;
|
|
54
|
-
//#endregion
|
|
52
|
+
export declare function useChoices<TSelection>(options: UseChoicesOptions<TSelection>): UseChoicesResult<TSelection>;
|
package/dist/vue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { onScopeDispose, readonly, ref, watch } from "vue";
|
|
2
|
-
|
|
2
|
+
// src/vue.ts
|
|
3
3
|
function toError(value) {
|
|
4
4
|
return value instanceof Error ? value : new Error(String(value));
|
|
5
5
|
}
|
|
@@ -75,5 +75,4 @@ function useChoices(options) {
|
|
|
75
75
|
text
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
//#endregion
|
|
79
78
|
export { useChoices };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/choices",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Turn text into choices over options that you declare: filters, search facets, command palettes, and builders on a TypeSafe Jev decision model.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -51,19 +51,19 @@
|
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vite-hub/gateways": "0.5.
|
|
54
|
+
"@vite-hub/gateways": "0.5.1",
|
|
55
55
|
"nostics": "1.4.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/node": "^24.19.
|
|
58
|
+
"@types/node": "^24.19.2",
|
|
59
59
|
"@vite-hub/internal": "0.0.1",
|
|
60
|
-
"ai": "7.0.
|
|
60
|
+
"ai": "7.0.179",
|
|
61
61
|
"publint": "^0.3.25",
|
|
62
62
|
"typescript": "^6.0.3",
|
|
63
|
-
"vite": "^8.
|
|
64
|
-
"vite-plus": "^
|
|
65
|
-
"vitest": "
|
|
66
|
-
"vue": "3.5.
|
|
63
|
+
"vite": "^8.3.8",
|
|
64
|
+
"vite-plus": "^1.7.0",
|
|
65
|
+
"vitest": "5.1.0",
|
|
66
|
+
"vue": "3.5.46"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"vite": ">=8.0.0",
|