@atscript/typescript 0.2.9 → 0.2.10

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_plugin = require('./plugin-e4R5zAfw.cjs');
3
- const require_user_text = require('./user-text-C9ov-aSv.cjs');
2
+ const require_plugin = require('./plugin-BNbjc9-d.cjs');
3
+ const require_user_text = require('./user-text-BrP_qD3T.cjs');
4
4
 
5
5
  exports.JS_COMPILED_FORMAT = require_plugin.JS_COMPILED_FORMAT;
6
6
  exports.JS_INTERPRETED_FORMAT = require_plugin.JS_INTERPRETED_FORMAT;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,40 @@
1
1
  import { TAtscriptPlugin, AtscriptDoc } from '@atscript/core';
2
2
 
3
+ /**
4
+ * What a strict tool / structured-output schema of an LLM provider accepts (the `strict` option
5
+ * of {@link buildJsonSchema}): the schema is built closed (`additionalProperties: false` on every
6
+ * object), then rewritten to the profile. Constraints the profile drops are not enforced by the
7
+ * provider: validate the model's output with the atscript validator.
8
+ */
9
+ interface TStrictProfile {
10
+ /** The provider's name, in the errors of a shape it can't take. */
11
+ name: string;
12
+ /**
13
+ * The keywords the provider accepts (an allow-list): `true`, or a check of the keyword's value
14
+ * (`false`: the keyword is dropped there). Every other keyword is dropped.
15
+ */
16
+ keywords: Readonly<Record<string, true | ((value: unknown) => boolean)>>;
17
+ /**
18
+ * Every property in `required`, the optional ones nullable: the model sends `null` for an
19
+ * optional field it leaves out. The validator rejects `null` on an optional `@meta.required`
20
+ * field: drop those values first (see `dropOptionalNulls`).
21
+ */
22
+ requireAll: boolean;
23
+ /**
24
+ * Rewrites the `allOf` the schema builder writes: a `$ref` with notes beside it (a field's
25
+ * title, description, key counts) → the referenced schema inlined with them; several patterns
26
+ * → the first one (the rest dropped) when `allOf` itself is not allowed. Any other `allOf`
27
+ * the profile does not allow throws.
28
+ */
29
+ collapseAllOf: boolean;
30
+ /** Appends each dropped constraint to the schema's `description`, in plain words. */
31
+ describeDropped: boolean;
32
+ /** Recursive types (a `$defs` entry that refers to itself); `false`: throws. */
33
+ allowRecursion: boolean;
34
+ /** The root must be an object schema; else throws. */
35
+ objectRoot: boolean;
36
+ }
37
+
3
38
  /** Options of {@link buildJsonSchema} (and of the `jsonSchemaOptions` plugin option). */
4
39
  interface TJsonSchemaOptions {
5
40
  /**
@@ -18,6 +53,14 @@ interface TJsonSchemaOptions {
18
53
  * `anyOf` of `const` schemas. *(default: `true`)*
19
54
  */
20
55
  enums?: boolean;
56
+ /**
57
+ * Targets a strict LLM tool / structured-output schema: `OPENAI_STRICT`, `ANTHROPIC_STRICT` or
58
+ * a profile of your own (see {@link TStrictProfile}). The schema is built `closed`, then keeps
59
+ * only the keywords the profile allows (the dropped constraints described in `description`);
60
+ * a shape the profile can't take throws. The provider does not enforce what was dropped:
61
+ * validate the model's output with the type's validator. Runtime only (not a plugin option).
62
+ */
63
+ strict?: TStrictProfile;
21
64
  }
22
65
 
23
66
  interface TTsPluginOptions {
@@ -38,7 +81,7 @@ interface TTsPluginOptions {
38
81
  * `title` from `@meta.description` / `@meta.label`, default `true`), `enums` (a union of
39
82
  * literals as `enum`, default `true`).
40
83
  */
41
- jsonSchemaOptions?: TJsonSchemaOptions;
84
+ jsonSchemaOptions?: Omit<TJsonSchemaOptions, 'strict'>;
42
85
  /**
43
86
  * Example data support:
44
87
  * - `false` — No support. `toExampleData` is not rendered. *(default)*
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as withLoadCheck, i as importCycle, n as JS_INTERPRETED_FORMAT, r as tsPlugin, t as JS_COMPILED_FORMAT } from "./plugin-0ZgIMt1Y.mjs";
2
- import { X as invalidateCompiledValidators } from "./user-text-fz-TpY_H.mjs";
1
+ import { a as withLoadCheck, i as importCycle, n as JS_INTERPRETED_FORMAT, r as tsPlugin, t as JS_COMPILED_FORMAT } from "./plugin-CnraKYN3.mjs";
2
+ import { X as invalidateCompiledValidators } from "./user-text-DS0lorlV.mjs";
3
3
 
4
4
  export { JS_COMPILED_FORMAT, JS_INTERPRETED_FORMAT, tsPlugin as default, tsPlugin, importCycle, invalidateCompiledValidators, withLoadCheck };
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_user_text = require('./user-text-C9ov-aSv.cjs');
28
+ const require_user_text = require('./user-text-BrP_qD3T.cjs');
29
29
  let path = require("path");
30
30
  path = __toESM(path);
31
31
  let _atscript_core = require("@atscript/core");
@@ -1,4 +1,4 @@
1
- import { n as CORE_USER_TEXT, o as uniqueName, v as stageEnds } from "./user-text-fz-TpY_H.mjs";
1
+ import { n as CORE_USER_TEXT, o as uniqueName, v as stageEnds } from "./user-text-DS0lorlV.mjs";
2
2
  import path from "path";
3
3
  import { ANNOTATE_RESET, DEFAULT_FORMAT, MERGE_TOO_COMPLEX, NAV_PROP_ANNOTATIONS, SemanticGroup, andExprs, annotatedValueKinds, componentOf, components, defPosition, documentsEpoch, entryParts, flatDefinitions, forEachAnnotationSpec, getRelPath, hasMutatingAnnotates, hasNavPropAnnotation, isAnnotate, isArray, isAsView, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isInterface, isNull, isPhantomNode, isPrimitive, isQueryLogical, isRef, isStructure, isTuple, moduleId, pastViews, resolveAtscriptFromPath, unshell, userTextFields, withoutAsExtension } from "@atscript/core";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";