@almadar/core 10.109.0 → 10.111.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.
- package/dist/builders.d.ts +5 -5
- package/dist/builders.js +1 -1
- package/dist/builders.js.map +1 -1
- package/dist/{bus-De_T27aq.d.ts → bus-DS-GzSrs.d.ts} +2 -2
- package/dist/{effect-Cv7k1MTO.d.ts → effect-BD47AL48.d.ts} +1 -1
- package/dist/{entityAccess-CH8vC2OG.d.ts → entityAccess-Dc6o3AYo.d.ts} +3 -3
- package/dist/{expression-C6Gs_c5b.d.ts → expression-Dz84kipC.d.ts} +20 -3
- package/dist/factory/index.d.ts +81 -7
- package/dist/factory/index.js +179 -7
- package/dist/factory/index.js.map +1 -1
- package/dist/factory-runtime/index.d.ts +5 -5
- package/dist/factory-runtime/index.js +1 -1
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/fixtures.d.ts +3 -3
- package/dist/fixtures.js +1 -1
- package/dist/fixtures.js.map +1 -1
- package/dist/{index-BzFToa4c.d.ts → index-DgD_3g5F.d.ts} +101 -10
- package/dist/index.d.ts +16 -16
- package/dist/index.js +235 -11
- package/dist/index.js.map +1 -1
- package/dist/mock/index.d.ts +20 -7
- package/dist/mock/index.js +26 -5
- package/dist/mock/index.js.map +1 -1
- package/dist/patterns/index.d.ts +3 -3
- package/dist/{schema-Chi9QIcZ.d.ts → schema-B3GE83sz.d.ts} +340 -340
- package/dist/state-machine/index.d.ts +1 -1
- package/dist/state-machine/index.js +32 -7
- package/dist/state-machine/index.js.map +1 -1
- package/dist/themes/index.d.ts +1 -1
- package/dist/{trait-A_OGE8xT.d.ts → trait-BNxIGRUF.d.ts} +2 -2
- package/dist/types/index.d.ts +8 -8
- package/dist/types/index.js +32 -2
- package/dist/types/index.js.map +1 -1
- package/dist/{types-DQoBssKq.d.ts → types-5IX1FGgd.d.ts} +2 -2
- package/package.json +1 -1
- package/dist/{domain-DYverojF.d.ts → domain-Bf6sf9NR.d.ts} +210 -210
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as FieldValue, S as ServerReportedEffect, N as NamespacedEffectName, g as EntityRow, d as OrbitalId, T as TraitId, b as EventId, h as PatternConfig, i as ResolvedPatternProps, A as AnyPatternConfig } from './effect-
|
|
1
|
+
import { F as FieldValue, S as ServerReportedEffect, N as NamespacedEffectName, g as EntityRow, d as OrbitalId, T as TraitId, b as EventId, h as PatternConfig, i as ResolvedPatternProps, A as AnyPatternConfig } from './effect-BD47AL48.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { a as EventPayloadValue, b as EventPayload } from './expression-
|
|
3
|
+
import { a as EventPayloadValue, b as EventPayload } from './expression-Dz84kipC.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Authenticated user context — what `@user.x` resolves against.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as SExpr, b as EventPayload, E as Expression } from './expression-
|
|
2
|
+
import { S as SExpr, b as EventPayload, E as Expression } from './expression-Dz84kipC.js';
|
|
3
3
|
import { J as JsonValue, R as RuntimeValue } from './json-D8gmyK3l.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as OrbitalEntity } from './effect-
|
|
2
|
-
import { O as OrbitalSchema, a as OrbitalDefinition } from './schema-
|
|
3
|
-
import { S as SExpr } from './expression-
|
|
1
|
+
import { O as OrbitalEntity } from './effect-BD47AL48.js';
|
|
2
|
+
import { O as OrbitalSchema, a as OrbitalDefinition } from './schema-B3GE83sz.js';
|
|
3
|
+
import { S as SExpr } from './expression-Dz84kipC.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Entity access policies — the declared `@read`/`@create`/`@update`/`@delete`
|
|
@@ -53,8 +53,10 @@ declare const SExprDataSchema: z.ZodType<SExpr>;
|
|
|
53
53
|
*/
|
|
54
54
|
declare const SExprAtomSchema: z.ZodType<SExprAtom>;
|
|
55
55
|
/**
|
|
56
|
-
* Recursive schema for S-expressions
|
|
57
|
-
*
|
|
56
|
+
* Recursive schema for S-expressions: an atom, or a call — an array whose first element is its
|
|
57
|
+
* string operator. A call's arguments are data (`SExprDataSchema`): an argument array without
|
|
58
|
+
* an operator head is a literal list, as both evaluators read it (an inlined config list in
|
|
59
|
+
* `["array/nth", [{…}, {…}], "@entity.i"]`).
|
|
58
60
|
*/
|
|
59
61
|
declare const SExprSchema: z.ZodType<SExpr>;
|
|
60
62
|
/**
|
|
@@ -182,6 +184,21 @@ declare function isValidBinding(binding: string): boolean;
|
|
|
182
184
|
* @returns The operator string or null if not a valid call
|
|
183
185
|
*/
|
|
184
186
|
declare function getOperator(expr: SExpr): string | null;
|
|
187
|
+
/** Where a node sits in its S-expression: argument indices of calls/arrays, keys of object literals. */
|
|
188
|
+
type SExprPath = ReadonlyArray<number | string>;
|
|
189
|
+
/**
|
|
190
|
+
* One step of a traced evaluation. `enter`/`exit` bracket a node's evaluation
|
|
191
|
+
* (`exit` carries its value or error); `iter` marks a node re-entered (a lambda
|
|
192
|
+
* body per item); `skip` marks an argument the operator never evaluated
|
|
193
|
+
* (short-circuited `and`/`or`, the untaken `if` branch).
|
|
194
|
+
*/
|
|
195
|
+
interface EvalStep {
|
|
196
|
+
kind: 'enter' | 'exit' | 'iter' | 'skip';
|
|
197
|
+
path: SExprPath;
|
|
198
|
+
value?: RuntimeValue;
|
|
199
|
+
error?: string;
|
|
200
|
+
}
|
|
201
|
+
type EvalTrace = EvalStep[];
|
|
185
202
|
/**
|
|
186
203
|
* Print an S-expression in `.lolo` surface form: calls as `(op args…)`,
|
|
187
204
|
* bindings bare, strings quoted, objects `{ k: v }`, literal arrays `[a b]`.
|
|
@@ -271,4 +288,4 @@ interface LogMeta {
|
|
|
271
288
|
*/
|
|
272
289
|
declare function isStaticallyFalse(expr: SExpr, resolve?: (binding: string) => SExprAtom | undefined): boolean;
|
|
273
290
|
|
|
274
|
-
export {
|
|
291
|
+
export { isSExprCall as A, isStaticallyFalse as B, CORE_BINDINGS as C, isValidBinding as D, type Expression as E, parseBinding as F, sexpr as G, walkSExpr as H, type LogMeta as L, type ParsedBinding as P, type SExpr as S, type EventPayloadValue as a, type EventPayload as b, type CoreBinding as c, type EvalContext as d, type EvalStep as e, type EvalTrace as f, EventPayloadSchema as g, EventPayloadValueSchema as h, type ExpressionInput as i, ExpressionSchema as j, type LogMetaValue as k, type SExprAtom as l, SExprAtomSchema as m, SExprDataSchema as n, type SExprInput as o, type SExprObject as p, type SExprPath as q, SExprSchema as r, collectBindings as s, formatSExpr as t, getArgs as u, getOperator as v, isBinding as w, isEventPayloadValue as x, isSExpr as y, isSExprAtom as z };
|
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { k as FactorySignatureCatalog, h as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, j as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, T as TraitOverlay, J as JsonSchema } from '../types-
|
|
2
|
-
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryExposure, g as FactoryPageSignature, i as FactoryProvenance, l as FactorySignatureEntityField, m as FactoryTraitSignature, n as JsonSchemaType, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, q as TraitOverlayEntry, r as TraitOverlayListener } from '../types-
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
|
|
1
|
+
import { k as FactorySignatureCatalog, h as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, j as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, T as TraitOverlay, J as JsonSchema } from '../types-5IX1FGgd.js';
|
|
2
|
+
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryExposure, g as FactoryPageSignature, i as FactoryProvenance, l as FactorySignatureEntityField, m as FactoryTraitSignature, n as JsonSchemaType, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, q as TraitOverlayEntry, r as TraitOverlayListener } from '../types-5IX1FGgd.js';
|
|
3
|
+
import { J as JsonValue } from '../json-D8gmyK3l.js';
|
|
4
|
+
import { a as EntityPersistence, E as EntityField } from '../effect-BD47AL48.js';
|
|
5
|
+
import { a as TraitReference } from '../trait-BNxIGRUF.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../expression-
|
|
7
|
+
import '../expression-Dz84kipC.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Rehydrate `overridableConfigKeys` from a catalog's `knobDefs` table,
|
|
@@ -22,6 +22,80 @@ import '../expression-C6Gs_c5b.js';
|
|
|
22
22
|
*/
|
|
23
23
|
declare function rehydrateKnobDefs(catalog: FactorySignatureCatalog): FactorySignatureCatalog;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Three-way merge of an orbital's factory params: the common ancestor (`base`), and each side's
|
|
27
|
+
* edit (`ours`, `theirs`). Objects merge key by key; a list whose items are objects carrying a
|
|
28
|
+
* string `id` (entity fields, trait children, nav items) merges item by item and keeps either
|
|
29
|
+
* side's reorder alongside the other's inserts; any other list is one value.
|
|
30
|
+
*
|
|
31
|
+
* Only a value both sides changed differently (`both-changed`) or an item/key one side removed
|
|
32
|
+
* while the other changed it (`delete-vs-edit`) is a conflict. A conflicted value keeps ours in
|
|
33
|
+
* `merged` until it is resolved.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
type ParamConflictKind = 'both-changed' | 'delete-vs-edit';
|
|
37
|
+
interface ParamConflict {
|
|
38
|
+
/** Keys and item ids from the params root to the conflicted value. */
|
|
39
|
+
path: string[];
|
|
40
|
+
kind: ParamConflictKind;
|
|
41
|
+
/** `null` stands for absent. */
|
|
42
|
+
base: JsonValue;
|
|
43
|
+
ours: JsonValue;
|
|
44
|
+
theirs: JsonValue;
|
|
45
|
+
}
|
|
46
|
+
interface ParamsMerge {
|
|
47
|
+
merged: JsonValue;
|
|
48
|
+
conflicts: ParamConflict[];
|
|
49
|
+
}
|
|
50
|
+
declare function mergeParams(base: JsonValue, ours: JsonValue, theirs: JsonValue): ParamsMerge;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The behavior-contract slice `orbital-lolo` reads at parse time (a behavior package's
|
|
54
|
+
* `loloContracts` sidecar): per behavior, each trait's `entityContract.requires` and overridable
|
|
55
|
+
* config-key types, its page names, orbital-level config and app-level config.
|
|
56
|
+
*
|
|
57
|
+
* Built from a package's own factory-signature catalog(s) and its own `.orb` documents. A behavior
|
|
58
|
+
* with no factory signature (a template, or a behavior a user published from the Studio) takes its
|
|
59
|
+
* slice from its `.orb` alone. Pure: the cascade (`@almadar-io/almadar-pattern-sync`) and the
|
|
60
|
+
* Studio's behavior packages read their files and call this, one copy of the rule.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/** One trait's parse-time-checkable contract. Mirrors `TraitContract` in `orbital-lolo/src/registry.rs`. */
|
|
64
|
+
interface LoloTraitContract {
|
|
65
|
+
/** Entity fields the trait reads (`@entity.<field>`); a rebind target must supply all of these. */
|
|
66
|
+
requires: string[];
|
|
67
|
+
/** Overridable config keys → their lolo type. */
|
|
68
|
+
config: Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
/** One orbital's parse-time-checkable contract. Mirrors `OrbitalContract` in `orbital-lolo/src/registry.rs`. */
|
|
71
|
+
interface LoloOrbitalContract {
|
|
72
|
+
config: Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
/** One behavior's slice. Mirrors `Behavior` in `orbital-lolo/src/registry.rs`. */
|
|
75
|
+
interface LoloBehaviorContract {
|
|
76
|
+
traits: Record<string, LoloTraitContract>;
|
|
77
|
+
pages: string[];
|
|
78
|
+
/** Orbital contracts, keyed by orbital name — the `Alias.orbitals.X` surface. */
|
|
79
|
+
orbitals: Record<string, LoloOrbitalContract>;
|
|
80
|
+
/** App-level (organism-wide) declared config keys → their lolo type. */
|
|
81
|
+
appConfig: Record<string, string>;
|
|
82
|
+
}
|
|
83
|
+
/** One behavior's `.orb` document, named as its registry file is (`<name>.orb`). */
|
|
84
|
+
interface NamedOrb {
|
|
85
|
+
name: string;
|
|
86
|
+
orb: JsonValue;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A declared config knob's lolo type: its explicit `type` when present, else inferred from its
|
|
90
|
+
* `default`'s JS runtime type.
|
|
91
|
+
*/
|
|
92
|
+
declare function inferConfigType(spec: JsonValue | undefined): string | undefined;
|
|
93
|
+
/** Recursively sort object keys so emitted JSON is byte-stable across runs. */
|
|
94
|
+
declare function sortKeysDeep(v: JsonValue): JsonValue;
|
|
95
|
+
declare function buildLoloBehaviorContracts(catalogs: readonly FactorySignatureCatalog[], orbs: readonly NamedOrb[]): Record<string, LoloBehaviorContract>;
|
|
96
|
+
/** The sidecar file's content: `{ behaviors }`, key-sorted. */
|
|
97
|
+
declare function serializeLoloBehaviorContracts(behaviors: Record<string, LoloBehaviorContract>): string;
|
|
98
|
+
|
|
25
99
|
/**
|
|
26
100
|
* Typed questionnaire surface — shapes the studio renders + answers.
|
|
27
101
|
*
|
|
@@ -440,4 +514,4 @@ declare function signatureToParamsSchema(signature: FactorySignature, options?:
|
|
|
440
514
|
*/
|
|
441
515
|
declare function assertNoUnsatisfiableEnum(node: JsonSchema, where: string, path?: string): void;
|
|
442
516
|
|
|
443
|
-
export { type CallSiteDiff, type DomainQuestion, type DomainQuestionAnswer, type DomainQuestionAnswers, type DomainQuestionInputType, type FactoryCallPlanMutation, type FactoryCallPlanMutationTemplate, type FactoryCallPlanState, FactoryCallSite, FactoryConfigParam, FactoryConfigTier, FactoryParamValue, FactorySignature, FactorySignatureCatalog, JsonSchema, type OrbitalCallInput, PresentationOverlay, RuleOverlay, RuleOverlayEntry, TraitOverlay, type TranslationBinding, type TranslationResult, type TranslationWarning, answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assertNoUnsatisfiableEnum, deriveInputType, diffFactoryCalls, generateQuestions, rehydrateKnobDefs, signatureToParamsSchema, translateOverlaysToParams };
|
|
517
|
+
export { type CallSiteDiff, type DomainQuestion, type DomainQuestionAnswer, type DomainQuestionAnswers, type DomainQuestionInputType, type FactoryCallPlanMutation, type FactoryCallPlanMutationTemplate, type FactoryCallPlanState, FactoryCallSite, FactoryConfigParam, FactoryConfigTier, FactoryParamValue, FactorySignature, FactorySignatureCatalog, JsonSchema, JsonValue, type LoloBehaviorContract, type LoloOrbitalContract, type LoloTraitContract, type NamedOrb, type OrbitalCallInput, type ParamConflict, type ParamConflictKind, type ParamsMerge, PresentationOverlay, RuleOverlay, RuleOverlayEntry, TraitOverlay, type TranslationBinding, type TranslationResult, type TranslationWarning, answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assertNoUnsatisfiableEnum, buildLoloBehaviorContracts, deriveInputType, diffFactoryCalls, generateQuestions, inferConfigType, mergeParams, rehydrateKnobDefs, serializeLoloBehaviorContracts, signatureToParamsSchema, sortKeysDeep, translateOverlaysToParams };
|
package/dist/factory/index.js
CHANGED
|
@@ -30,6 +30,181 @@ function rehydrateKnobDefs(catalog) {
|
|
|
30
30
|
}
|
|
31
31
|
return catalog;
|
|
32
32
|
}
|
|
33
|
+
var JsonValueSchema = z.lazy(
|
|
34
|
+
() => z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(JsonValueSchema), z.record(JsonValueSchema)])
|
|
35
|
+
);
|
|
36
|
+
function isJsonObject(value) {
|
|
37
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/factory/merge.ts
|
|
41
|
+
function canonical(v) {
|
|
42
|
+
if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
|
|
43
|
+
if (isJsonObject(v)) return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canonical(v[k] ?? null)}`).join(",")}}`;
|
|
44
|
+
return JSON.stringify(v);
|
|
45
|
+
}
|
|
46
|
+
var same = (a, b) => a === void 0 || b === void 0 ? a === b : canonical(a) === canonical(b);
|
|
47
|
+
function isIdList(v) {
|
|
48
|
+
return Array.isArray(v) && v.length > 0 && v.every((i) => isJsonObject(i) && typeof i["id"] === "string");
|
|
49
|
+
}
|
|
50
|
+
var idList = (v) => v === void 0 || Array.isArray(v) && v.length === 0 || isIdList(v);
|
|
51
|
+
function mergeParams(base, ours, theirs) {
|
|
52
|
+
const conflicts = [];
|
|
53
|
+
const merged = mergeValue([], base, ours, theirs, conflicts);
|
|
54
|
+
return { merged: merged === void 0 ? null : merged, conflicts };
|
|
55
|
+
}
|
|
56
|
+
function mergeValue(path, base, ours, theirs, conflicts) {
|
|
57
|
+
if (same(ours, theirs)) return ours;
|
|
58
|
+
if (same(base, ours)) return theirs;
|
|
59
|
+
if (same(base, theirs)) return ours;
|
|
60
|
+
if (ours !== void 0 && theirs !== void 0 && isJsonObject(ours) && isJsonObject(theirs) && (base === void 0 || isJsonObject(base))) {
|
|
61
|
+
return mergeObject(path, base, ours, theirs, conflicts);
|
|
62
|
+
}
|
|
63
|
+
if (ours !== void 0 && theirs !== void 0 && (isIdList(ours) || isIdList(theirs)) && idList(ours) && idList(theirs) && idList(base)) {
|
|
64
|
+
return mergeIdList(path, base ?? [], ours, theirs, conflicts);
|
|
65
|
+
}
|
|
66
|
+
conflicts.push({
|
|
67
|
+
path,
|
|
68
|
+
kind: ours === void 0 || theirs === void 0 ? "delete-vs-edit" : "both-changed",
|
|
69
|
+
base: base ?? null,
|
|
70
|
+
ours: ours ?? null,
|
|
71
|
+
theirs: theirs ?? null
|
|
72
|
+
});
|
|
73
|
+
return ours;
|
|
74
|
+
}
|
|
75
|
+
function mergeObject(path, base, ours, theirs, conflicts) {
|
|
76
|
+
const out = {};
|
|
77
|
+
const keys = [.../* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(ours), ...Object.keys(theirs)])];
|
|
78
|
+
for (const key of keys) {
|
|
79
|
+
const value = mergeValue([...path, key], base?.[key], ours[key], theirs[key], conflicts);
|
|
80
|
+
if (value !== void 0) out[key] = value;
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
var idsOf = (list) => list.map((i) => i.id);
|
|
85
|
+
function mergeIdList(path, base, ours, theirs, conflicts) {
|
|
86
|
+
const byId = (list) => new Map(list.map((i) => [i.id, i]));
|
|
87
|
+
const b = byId(base);
|
|
88
|
+
const o = byId(ours);
|
|
89
|
+
const t = byId(theirs);
|
|
90
|
+
const result = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const id of /* @__PURE__ */ new Set([...b.keys(), ...o.keys(), ...t.keys()])) {
|
|
92
|
+
const value = mergeValue([...path, id], b.get(id), o.get(id), t.get(id), conflicts);
|
|
93
|
+
if (value !== void 0) result.set(id, value);
|
|
94
|
+
}
|
|
95
|
+
const common = (list) => idsOf(list).filter((id) => b.has(id));
|
|
96
|
+
const reordered = (list) => canonical(common(list).filter((id) => o.has(id) && t.has(id))) !== canonical(idsOf(base).filter((id) => o.has(id) && t.has(id)));
|
|
97
|
+
const [primary, secondary] = reordered(ours) || !reordered(theirs) ? [ours, theirs] : [theirs, ours];
|
|
98
|
+
const order = idsOf(primary).filter((id) => result.has(id));
|
|
99
|
+
const secondaryIds = idsOf(secondary);
|
|
100
|
+
secondaryIds.forEach((id, index) => {
|
|
101
|
+
if (!result.has(id) || order.includes(id)) return;
|
|
102
|
+
const before = secondaryIds.slice(0, index).reverse().find((prev) => order.includes(prev));
|
|
103
|
+
order.splice(before === void 0 ? 0 : order.indexOf(before) + 1, 0, id);
|
|
104
|
+
});
|
|
105
|
+
for (const id of result.keys()) if (!order.includes(id)) order.push(id);
|
|
106
|
+
return order.map((id) => result.get(id) ?? null);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/factory/lolo-behavior-contracts.ts
|
|
110
|
+
var JS_TO_LOLO_TYPE = {
|
|
111
|
+
string: "string",
|
|
112
|
+
number: "number",
|
|
113
|
+
integer: "number",
|
|
114
|
+
boolean: "boolean",
|
|
115
|
+
array: "array",
|
|
116
|
+
object: "object"
|
|
117
|
+
};
|
|
118
|
+
function jsToLolo(t) {
|
|
119
|
+
return JS_TO_LOLO_TYPE[t ?? ""] ?? (t || "string");
|
|
120
|
+
}
|
|
121
|
+
function inferConfigType(spec) {
|
|
122
|
+
if (spec === void 0 || !isJsonObject(spec)) return void 0;
|
|
123
|
+
const explicit = spec["type"];
|
|
124
|
+
if (typeof explicit === "string" && explicit.length > 0) return explicit;
|
|
125
|
+
const d = spec["default"];
|
|
126
|
+
if (Array.isArray(d)) return "array";
|
|
127
|
+
if (d === null || d === void 0) return void 0;
|
|
128
|
+
return typeof d;
|
|
129
|
+
}
|
|
130
|
+
function sortKeysDeep(v) {
|
|
131
|
+
if (Array.isArray(v)) return v.map(sortKeysDeep);
|
|
132
|
+
if (isJsonObject(v)) {
|
|
133
|
+
const out = {};
|
|
134
|
+
for (const k of Object.keys(v).sort()) out[k] = sortKeysDeep(v[k] ?? null);
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
return v;
|
|
138
|
+
}
|
|
139
|
+
var objectsOf = (v) => Array.isArray(v) ? v.filter(isJsonObject) : [];
|
|
140
|
+
var objectOf = (v) => v !== void 0 && isJsonObject(v) ? v : {};
|
|
141
|
+
var stringsOf = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
142
|
+
function configTypes(config) {
|
|
143
|
+
const out = {};
|
|
144
|
+
for (const [key, spec] of Object.entries(objectOf(config))) out[key] = jsToLolo(inferConfigType(spec));
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
function buildLoloBehaviorContracts(catalogs, orbs) {
|
|
148
|
+
const behaviors = {};
|
|
149
|
+
const entryFor = (name) => behaviors[name] ?? (behaviors[name] = { traits: {}, pages: [], orbitals: {}, appConfig: {} });
|
|
150
|
+
for (const raw of catalogs) {
|
|
151
|
+
const catalog = rehydrateKnobDefs(raw);
|
|
152
|
+
for (const s of catalog.signatures) {
|
|
153
|
+
if (!s.organism) continue;
|
|
154
|
+
const entry = entryFor(s.organism);
|
|
155
|
+
for (const t of s.traits) {
|
|
156
|
+
if (t.name in entry.traits) continue;
|
|
157
|
+
const config = {};
|
|
158
|
+
for (const ck of t.overridableConfigKeys ?? []) {
|
|
159
|
+
if (ck?.key) config[ck.key] = jsToLolo(ck.type);
|
|
160
|
+
}
|
|
161
|
+
entry.traits[t.name] = { requires: [...t.entityContract?.requires ?? []], config };
|
|
162
|
+
}
|
|
163
|
+
for (const p of s.pages) {
|
|
164
|
+
if (p?.name && !entry.pages.includes(p.name)) entry.pages.push(p.name);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const entry of Object.values(behaviors)) entry.pages.sort();
|
|
169
|
+
for (const { name, orb } of orbs) {
|
|
170
|
+
if (behaviors[name]) continue;
|
|
171
|
+
const traits = {};
|
|
172
|
+
const pages = [];
|
|
173
|
+
for (const orbital of objectsOf(objectOf(orb)["orbitals"])) {
|
|
174
|
+
for (const t of objectsOf(orbital["traits"])) {
|
|
175
|
+
const traitName = t["name"];
|
|
176
|
+
if (typeof traitName !== "string") continue;
|
|
177
|
+
traits[traitName] = { requires: stringsOf(objectOf(t["entityContract"])["requires"]), config: configTypes(t["config"]) };
|
|
178
|
+
}
|
|
179
|
+
for (const p of objectsOf(orbital["pages"])) {
|
|
180
|
+
if (typeof p["name"] === "string" && p["name"]) pages.push(p["name"]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
behaviors[name] = { traits, pages, orbitals: {}, appConfig: {} };
|
|
184
|
+
}
|
|
185
|
+
for (const { name, orb } of orbs) {
|
|
186
|
+
const target = entryFor(name);
|
|
187
|
+
const doc = objectOf(orb);
|
|
188
|
+
Object.assign(target.appConfig, configTypes(doc["config"]));
|
|
189
|
+
for (const orbital of objectsOf(doc["orbitals"])) {
|
|
190
|
+
const orbitalName = orbital["name"];
|
|
191
|
+
if (typeof orbitalName !== "string" || !orbitalName) continue;
|
|
192
|
+
target.orbitals[orbitalName] = { config: configTypes(orbital["config"]) };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return behaviors;
|
|
196
|
+
}
|
|
197
|
+
function serializeLoloBehaviorContracts(behaviors) {
|
|
198
|
+
const doc = {};
|
|
199
|
+
for (const [name, b] of Object.entries(behaviors)) {
|
|
200
|
+
const traits = {};
|
|
201
|
+
for (const [t, c] of Object.entries(b.traits)) traits[t] = { requires: c.requires, config: c.config };
|
|
202
|
+
const orbitals = {};
|
|
203
|
+
for (const [o, c] of Object.entries(b.orbitals)) orbitals[o] = { config: c.config };
|
|
204
|
+
doc[name] = { traits, pages: b.pages, orbitals, appConfig: b.appConfig };
|
|
205
|
+
}
|
|
206
|
+
return JSON.stringify(sortKeysDeep({ behaviors: doc }));
|
|
207
|
+
}
|
|
33
208
|
|
|
34
209
|
// src/factory/questions/generate.ts
|
|
35
210
|
function generateQuestions(plan, catalog, ruleOverlay, _userPrompt) {
|
|
@@ -500,10 +675,10 @@ function applyEntityFields(binding, signature, params) {
|
|
|
500
675
|
params.entityFields = [...binding.entityFields];
|
|
501
676
|
return;
|
|
502
677
|
}
|
|
503
|
-
const
|
|
678
|
+
const canonical2 = new Set(signature.entities[0].fields.map((f) => f.name));
|
|
504
679
|
const extras = [];
|
|
505
680
|
for (const f of binding.entityFields) {
|
|
506
|
-
if (f.name &&
|
|
681
|
+
if (f.name && canonical2.has(f.name)) continue;
|
|
507
682
|
extras.push(f);
|
|
508
683
|
}
|
|
509
684
|
if (extras.length > 0) params.entityFields = extras;
|
|
@@ -53174,9 +53349,6 @@ var patterns_registry_default = {
|
|
|
53174
53349
|
}
|
|
53175
53350
|
}
|
|
53176
53351
|
}};
|
|
53177
|
-
var JsonValueSchema = z.lazy(
|
|
53178
|
-
() => z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(JsonValueSchema), z.record(JsonValueSchema)])
|
|
53179
|
-
);
|
|
53180
53352
|
|
|
53181
53353
|
// src/patterns/helpers/prompt-helpers.ts
|
|
53182
53354
|
function getAllPatternTypes() {
|
|
@@ -53585,7 +53757,7 @@ var SExprAtomSchema = z.union([
|
|
|
53585
53757
|
var SExprSchema = z.lazy(
|
|
53586
53758
|
() => z.union([
|
|
53587
53759
|
SExprAtomSchema,
|
|
53588
|
-
z.array(
|
|
53760
|
+
z.array(SExprDataSchema).min(1).refine(
|
|
53589
53761
|
(arr) => typeof arr[0] === "string",
|
|
53590
53762
|
{ message: "S-expression array must have a string operator as first element" }
|
|
53591
53763
|
)
|
|
@@ -54165,6 +54337,6 @@ var PAGE_OVERRIDE_SCHEMA = {
|
|
|
54165
54337
|
}
|
|
54166
54338
|
};
|
|
54167
54339
|
|
|
54168
|
-
export { answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assertNoUnsatisfiableEnum, deriveInputType, diffFactoryCalls, generateQuestions, rehydrateKnobDefs, signatureToParamsSchema, translateOverlaysToParams };
|
|
54340
|
+
export { answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assertNoUnsatisfiableEnum, buildLoloBehaviorContracts, deriveInputType, diffFactoryCalls, generateQuestions, inferConfigType, mergeParams, rehydrateKnobDefs, serializeLoloBehaviorContracts, signatureToParamsSchema, sortKeysDeep, translateOverlaysToParams };
|
|
54169
54341
|
//# sourceMappingURL=index.js.map
|
|
54170
54342
|
//# sourceMappingURL=index.js.map
|