@_linked/core 2.35.0 → 2.36.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/CHANGELOG.md +18 -0
- package/README.md +30 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/live/LiveQueryStore.js +2 -1
- package/lib/esm/live/LiveQueryStore.js.map +1 -1
- package/lib/esm/queries/FieldSet.d.ts +7 -0
- package/lib/esm/queries/FieldSet.js +25 -4
- package/lib/esm/queries/FieldSet.js.map +1 -1
- package/lib/esm/queries/MutationQuery.js +3 -2
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/queries/PropertyPath.js +2 -1
- package/lib/esm/queries/PropertyPath.js.map +1 -1
- package/lib/esm/queries/QueryBuilder.js +2 -1
- package/lib/esm/queries/QueryBuilder.js.map +1 -1
- package/lib/esm/queries/QueryContext.js +2 -0
- package/lib/esm/queries/QueryContext.js.map +1 -1
- package/lib/esm/queries/SelectQuery.js +6 -1
- package/lib/esm/queries/SelectQuery.js.map +1 -1
- package/lib/esm/queries/resolveShape.js +2 -1
- package/lib/esm/queries/resolveShape.js.map +1 -1
- package/lib/esm/shapes/validation.js +9 -4
- package/lib/esm/shapes/validation.js.map +1 -1
- package/lib/esm/utils/linkedError.d.ts +35 -0
- package/lib/esm/utils/linkedError.js +52 -0
- package/lib/esm/utils/linkedError.js.map +1 -0
- package/lib/esm/utils/sharedState.d.ts +25 -0
- package/lib/esm/utils/sharedState.js +34 -0
- package/lib/esm/utils/sharedState.js.map +1 -0
- package/lib/esm/utils/unresolvedShape.d.ts +44 -0
- package/lib/esm/utils/unresolvedShape.js +68 -0
- package/lib/esm/utils/unresolvedShape.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldSet.js","sourceRoot":"","sources":["../../../src/queries/FieldSet.ts"],"names":[],"mappings":"A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CAAC;QACD,iBAAiB;QACjB,IAAI,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,wBAAwB;QACxB,IAAI,gBAAgB,CAAC,aAAa,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;YAChE,qDAAqD;YACrD,MAAM,OAAO,GAAoB,EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;oBAC5D,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC;oBACtB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CAEF","sourcesContent":["import type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {getUniquePropertyShapes, getPropertyShape} from '../shapes/nodeShapeData.js';\nimport type {Shape, ShapeConstructor} from '../shapes/Shape.js';\nimport {PropertyPath, walkPropertyPath} from './PropertyPath.js';\nimport {\n captureCatalog,\n getActiveShapeCatalog,\n getAllNodeShapes,\n getAllShapeClasses,\n getNodeShape,\n getShapeClass,\n withShapeCatalog,\n getQueryShapeClass,\n} from '../utils/ShapeClass.js';\nimport type {ShapeCatalog} from '../utils/ShapeCatalog.js';\nimport type {WherePath} from './SelectQuery.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {encodeValueExpr, decodeValueExpr, type DslJsonValue} from './DslJsonExpression.js';\nimport {\n serializeWherePath,\n deserializeWherePath,\n type WherePathJSON,\n} from './QueryBuilderSerialization.js';\n\n// Duck-type helpers for runtime detection.\n// These check structural shape since the classes live in SelectQuery.ts (runtime circular dep).\n// QueryBuilderObject has .property (PropertyShapeData) and .subject (QueryBuilderObject).\n// SetSize has .subject and extends QueryPrimitive<number>.\ntype QueryBuilderObjectLike = {\n property?: PropertyShapeData;\n subject?: QueryBuilderObjectLike;\n wherePath?: unknown;\n};\nconst isQueryBuilderObject = (obj: any): obj is QueryBuilderObjectLike =>\n obj !== null &&\n typeof obj === 'object' &&\n 'property' in obj &&\n 'subject' in obj &&\n typeof obj.getPropertyPath === 'function';\n\nconst isSetSize = (obj: any): boolean =>\n obj !== null &&\n typeof obj === 'object' &&\n 'subject' in obj &&\n typeof obj.as === 'function' &&\n typeof obj.getPropertyPath === 'function' &&\n // SetSize has a 'countable' field (may be undefined) and 'label' field\n 'label' in obj;\n\n// BoundComponent: has .source (QueryBuilderObject) and .originalValue (component-like)\nconst isBoundComponent = (obj: any): boolean =>\n obj !== null &&\n typeof obj === 'object' &&\n 'source' in obj &&\n 'originalValue' in obj;\n\n/**\n * A single entry in a FieldSet: a property path with optional alias, scoped filter,\n * sub-selection, aggregation, and custom key.\n */\nexport type FieldSetEntry = {\n path: PropertyPath;\n alias?: string;\n scopedFilter?: WherePath;\n /** Index into path.segments indicating which segment the scopedFilter applies to.\n * Defaults to the last segment if not specified. */\n scopedFilterIndex?: number;\n /** Nested object selection — the user explicitly selected sub-fields (e.g. `p.friends.select(...)`) */\n subSelect?: FieldSet;\n aggregation?: 'count';\n customKey?: string;\n /** Component preload composition — the FieldSet comes from a linked component's own query,\n * merged in via `preloadFor()`. Distinct from subSelect which is a user-authored nested query. */\n preloadSubSelect?: FieldSet;\n /** Computed expression from proxy tracing (e.g. `p.age.times(12)`) */\n expressionNode?: ExpressionNode;\n /** Inner LIMIT for a nested select (e.g. `p.friends.select(...).limit(2)`).\n * Only supported when the outer query targets a single subject. */\n innerLimit?: number;\n /** Inner OFFSET for a nested select. */\n innerOffset?: number;\n /** Inner ORDER BY for a nested select — paths relative to the sub-select shape. */\n innerOrderBy?: FieldSetInnerOrderBy[];\n};\n\n/** A single inner ORDER BY clause for a nested select. */\nexport type FieldSetInnerOrderBy = {\n propertyShapeId: string;\n direction: 'ASC' | 'DESC';\n};\n\n/**\n * Input types accepted by FieldSet construction methods.\n *\n * - `string` — resolved via walkPropertyPath (dot-separated)\n * - `PropertyPath` — used directly\n * - `FieldSet` — merged in\n * - `Record<string, string[] | FieldSet>` — nested fields\n */\nexport type FieldSetInput =\n | string\n | PropertyPath\n | FieldSet\n | Record<string, string[] | FieldSet>;\n\n/** A computed projection field: `{ as?, value }` — a DSL-JSON expression, no path. */\nexport type FieldSetComputedJSON = {\n as?: string;\n value: DslJsonValue;\n customKey?: string;\n};\n\n/** Options for a relation projection (the object value under a relation key). */\nexport type FieldSetRelationOptionsJSON = {\n as?: string;\n /** Shape IRI for nested fields when it differs from the relation's declared value shape. */\n shape?: string;\n /** A scoped filter on the relation (`p.friends.where(...)`). */\n where?: WherePathJSON;\n /** Which path segment the scoped `where` applies to (defaults to the last). */\n whereIndex?: number;\n aggregation?: string;\n customKey?: string;\n /** Nested-select pagination (`p.friends.select(...).limit(5).offset(2).orderBy(...)`). */\n limit?: number;\n offset?: number;\n orderBy?: Array<{[path: string]: 'ASC' | 'DESC'}>;\n /** Sub-projection of the related shape. */\n fields?: FieldSetFieldJSON[];\n};\n\n/**\n * A relation-keyed field: a single-key object whose key is the relation path\n * (labels dotted, with inline `as(Shape)` casts) and whose value is either the\n * sub-fields array (`{ \"friends\": [\"name\"] }`) or an options object\n * (`{ \"friends\": { as, where, fields } }`). Also covers a leaf with options\n * (`{ \"name\": { \"as\": \"personName\" } }`). The related shape is inferred.\n */\nexport type FieldSetRelationJSON = {\n [path: string]: FieldSetFieldJSON[] | FieldSetRelationOptionsJSON;\n};\n\n/**\n * JSON representation of a FieldSet field entry — exactly three shapes:\n * - a **string** leaf path (`\"name\"`, `\"friends.friends.name\"`, `\"pets.as(Dog).level\"`)\n * - a **relation-keyed** object (`{ \"friends\": [...] | {options} }`)\n * - a **computed** object (`{ as?, value }`)\n */\nexport type FieldSetFieldJSON = string | FieldSetComputedJSON | FieldSetRelationJSON;\n\n/** JSON representation of a FieldSet (a shape + its top-level fields). */\nexport type FieldSetJSON = {\n shape: string;\n fields: FieldSetFieldJSON[];\n};\n\n/** Option keys reserved inside a relation options object (never a relation path). */\nconst RELATION_OPTION_KEYS = new Set([\n 'as',\n 'shape',\n 'where',\n 'whereIndex',\n 'aggregation',\n 'customKey',\n 'limit',\n 'offset',\n 'orderBy',\n 'fields',\n]);\n\n/**\n * An immutable, composable collection of property paths for a shape.\n *\n * FieldSet describes which properties to select, independent of\n * how the query is built. It integrates with QueryBuilder via\n * `.select(fieldSet)`.\n *\n * Every mutation method returns a new FieldSet — the original is never modified.\n */\nexport class FieldSet<R = any, Source = any> {\n readonly shape: NodeShapeData;\n readonly entries: readonly FieldSetEntry[];\n /** Phantom field — carries the callback response type for conditional type inference. */\n declare readonly __response: R;\n /** Phantom field — carries the source context (QueryShapeSet/QueryShape) for conditional type inference. */\n declare readonly __source: Source;\n\n /**\n * For sub-select FieldSets: the raw callback return value (proxy trace objects).\n * Stored so conditional types can extract the response type.\n */\n readonly traceResponse?: R;\n\n /**\n * For sub-select FieldSets: the parent property segments leading to this sub-select.\n */\n readonly parentSegments?: PropertyShapeData[];\n\n /**\n * For sub-select FieldSets: the shape class (ShapeType) of the sub-select's target.\n */\n readonly shapeType?: any;\n\n /**\n * For sub-select FieldSets: inline `.where()` filter found on the parent\n * traversal chain (e.g. `p.friends.where(...).select(...)`), plus the index\n * into `parentSegments` of the segment it scopes.\n */\n readonly parentWherePath?: WherePath;\n readonly parentWherePathIndex?: number;\n\n /**\n * For sub-select FieldSets: inner LIMIT/OFFSET/ORDER BY carried from\n * `.limit()`/`.offset()`/`.orderBy()` chained on the nested select.\n * These bound the related collection per parent (single-subject only).\n */\n readonly innerLimit?: number;\n readonly innerOffset?: number;\n readonly innerOrderBy?: FieldSetInnerOrderBy[];\n\n private readonly _catalog: ShapeCatalog | undefined;\n\n private constructor(\n shape: NodeShapeData,\n entries: FieldSetEntry[],\n catalog: ShapeCatalog | undefined = FieldSet.captureFor(shape),\n ) {\n this.shape = shape;\n this.entries = entries;\n this._catalog = catalog;\n }\n\n /** The catalog this FieldSet resolves shapes in (undefined = the global registry). */\n get catalog(): ShapeCatalog | undefined {\n return this._catalog;\n }\n\n /**\n * The catalog a FieldSet rooted at `shape` captures: the active one for an IRI or a\n * shape it holds, none for a shape it does not (an authored class built by code that\n * runs inside a project scope), else the catalog an adapter class came from.\n */\n private static captureFor(\n shape: ShapeConstructor<any> | NodeShapeData | string,\n ): ShapeCatalog | undefined {\n if (typeof shape === 'function') return captureCatalog(shape);\n const active = getActiveShapeCatalog();\n if (active === undefined || typeof shape === 'string') return active;\n return active.has(shape.id) ? active : undefined;\n }\n\n // ---------------------------------------------------------------------------\n // Static constructors\n // ---------------------------------------------------------------------------\n\n /**\n * Create a FieldSet for the given shape with the specified fields.\n *\n * Accepts a ShapeClass (e.g. Person), NodeShapeData, or shape IRI string.\n * Fields can be string paths, PropertyPath instances, nested objects,\n * or a callback receiving a proxy for dot-access.\n */\n static for<S extends Shape>(shape: ShapeConstructor<S>, fields: FieldSetInput[]): FieldSet<any>;\n static for<S extends Shape, R>(shape: ShapeConstructor<S>, fn: (p: any) => R): FieldSet<R>;\n static for(shape: NodeShapeData | string, fields: FieldSetInput[]): FieldSet<any>;\n static for(shape: NodeShapeData | string, fn: (p: any) => any): FieldSet<any>;\n static for(\n shape: ShapeConstructor<any> | NodeShapeData | string,\n fieldsOrFn: FieldSetInput[] | ((p: any) => any),\n ): FieldSet<any> {\n const catalog = FieldSet.captureFor(shape);\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => FieldSet.for(shape as string, fieldsOrFn as FieldSetInput[]));\n }\n const resolved = FieldSet.resolveShapeInput(shape);\n const resolvedShape = resolved.nodeShape;\n\n if (typeof fieldsOrFn === 'function') {\n if (!resolved.shapeClass) {\n throw new Error(\n `Cannot use callback form for shape '${resolved.nodeShape.id}': no ShapeConstructor registered. ` +\n `Use string field names instead, or pass the Shape class directly.`,\n );\n }\n const fields = FieldSet.traceFieldsWithProxy(resolved.nodeShape, resolved.shapeClass, fieldsOrFn);\n return new FieldSet(resolved.nodeShape, fields);\n }\n\n const entries = FieldSet.resolveInputs(resolvedShape, fieldsOrFn);\n return new FieldSet(resolvedShape, entries);\n }\n\n /**\n * Create a typed FieldSet for a sub-select. Traces the callback through the proxy,\n * stores parentSegments and traceResponse for runtime compatibility, and preserves\n * R and Source generics for conditional type inference.\n */\n static forSubSelect<R, Source>(\n shapeClass: any,\n fn: (p: any) => R,\n parentSegments: PropertyShapeData[],\n source?: QueryBuilderObjectLike,\n ): FieldSet<R, Source> {\n const nodeShape = shapeClass.shape || shapeClass;\n // Trace once: get both the raw response (for type carriers) and the entries\n const proxy = createProxiedPathBuilder(shapeClass);\n const traceResponse = fn(proxy as any);\n const entries = FieldSet.extractSubSelectEntries(nodeShape, traceResponse);\n const fs = new FieldSet(nodeShape, entries) as FieldSet<R, Source>;\n // Writable cast — these readonly fields are initialised once here at construction time\n const w = fs as {-readonly [K in 'traceResponse' | 'parentSegments' | 'shapeType' | 'parentWherePath' | 'parentWherePathIndex']: FieldSet<R, Source>[K]};\n w.traceResponse = traceResponse;\n w.parentSegments = parentSegments;\n w.shapeType = shapeClass;\n // Carry an inline `.where()` from the parent traversal chain (walked\n // leaf→root, same convention as convertTraceResult for plain paths).\n let current = source;\n let leafDistance = 0;\n while (current) {\n if (current.wherePath) {\n w.parentWherePath = current.wherePath as WherePath;\n w.parentWherePathIndex = parentSegments.length - 1 - leafDistance;\n break;\n }\n current = current.subject;\n leafDistance++;\n }\n return fs;\n }\n\n\n /**\n * Create a FieldSet containing all decorated properties of the shape.\n *\n * @param opts.depth Controls how deep to include nested shape properties:\n * - `depth=1` (default): this level only — properties of the root shape.\n * - `depth=0`: throws — use a node reference instead.\n * - `depth>1`: recursively includes nested shape properties up to the given depth.\n */\n static all<S extends Shape>(shape: ShapeConstructor<S>, opts?: {depth?: number}): FieldSet;\n static all(shape: NodeShapeData | string, opts?: {depth?: number}): FieldSet;\n static all(shape: ShapeConstructor<any> | NodeShapeData | string, opts?: {depth?: number}): FieldSet {\n const catalog = FieldSet.captureFor(shape);\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => FieldSet.all(shape as string, opts));\n }\n const depth = opts?.depth ?? 1;\n if (depth < 1) {\n throw new Error(\n 'FieldSet.all() requires depth >= 1. Use a node reference ({id}) for depth 0.',\n );\n }\n const resolved = FieldSet.resolveShapeInput(shape);\n // Seed visited with the root shape to prevent self-referencing cycles\n const visited = new Set<string>([resolved.nodeShape.id]);\n return FieldSet.allForShape(resolved.nodeShape, depth, visited);\n }\n\n /**\n * Recursive helper for all(). Tracks visited shape IDs to prevent infinite loops\n * from circular shape references.\n */\n private static allForShape(\n nodeShape: NodeShapeData,\n depth: number,\n visited: Set<string>,\n ): FieldSet {\n const propertyShapes = getUniquePropertyShapes(nodeShape);\n const entries: FieldSetEntry[] = [];\n\n for (const ps of propertyShapes) {\n const entry: FieldSetEntry = {path: new PropertyPath(nodeShape, [ps])};\n\n // If depth > 1, recurse into nested shapes\n if (depth > 1 && ps.valueShape) {\n const nestedShapeClass = getQueryShapeClass(ps.valueShape);\n if (nestedShapeClass?.shape && !visited.has(nestedShapeClass.shape.id)) {\n visited.add(nestedShapeClass.shape.id);\n const nestedFs = FieldSet.allForShape(nestedShapeClass.shape, depth - 1, visited);\n if (nestedFs.entries.length > 0) {\n entry.subSelect = nestedFs;\n }\n }\n }\n\n entries.push(entry);\n }\n\n return new FieldSet(nodeShape, entries);\n }\n\n /**\n * Merge multiple FieldSets into one, deduplicating by path equality.\n * All FieldSets must share the same root shape.\n */\n static merge(sets: FieldSet[]): FieldSet {\n if (sets.length === 0) {\n throw new Error('Cannot merge empty array of FieldSets');\n }\n const shape = sets[0].shape;\n for (const set of sets) {\n if (set.shape.id !== shape.id) {\n throw new Error(\n `Cannot merge FieldSets with different shapes: '${shape.label || shape.id}' and '${set.shape.label || set.shape.id}'`,\n );\n }\n }\n const merged: FieldSetEntry[] = [];\n const seen = new Set<string>();\n\n for (const set of sets) {\n for (const entry of set.entries) {\n // Include aggregation in the dedup key so that 'friends' and 'friends(count)' are distinct\n const key = entry.aggregation\n ? `${entry.path.toString()}:${entry.aggregation}`\n : entry.path.toString();\n if (!seen.has(key)) {\n seen.add(key);\n merged.push(entry);\n }\n }\n }\n\n return new FieldSet(shape, merged, sets[0]._catalog);\n }\n\n // ---------------------------------------------------------------------------\n // Composition methods — each returns a new FieldSet\n // ---------------------------------------------------------------------------\n\n /** Returns a new FieldSet with only the given fields. */\n select(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.select(fields));\n }\n const entries = FieldSet.resolveInputs(this.shape, fields);\n return new FieldSet(this.shape, entries, this._catalog);\n }\n\n /**\n * Clone this FieldSet, preserving the sub-select carrier fields\n * (traceResponse / parentSegments / shapeType / inner pagination) and\n * applying the supplied overrides. Used by `.limit()`/`.offset()`/`.orderBy()`.\n */\n private cloneWith(\n overrides: Partial<Pick<FieldSet, 'innerLimit' | 'innerOffset' | 'innerOrderBy'>>,\n ): this {\n const clone = new FieldSet(this.shape, this.entries as FieldSetEntry[], this._catalog) as this;\n // The sub-select carrier fields are declared `readonly` (normally set once at\n // construction via `forSubSelect`). Copy this FieldSet's identity onto the\n // clone through a mutable view, then layer the pagination overrides on top.\n Object.assign(clone as Record<string, unknown>, {\n traceResponse: this.traceResponse,\n parentSegments: this.parentSegments,\n shapeType: this.shapeType,\n parentWherePath: this.parentWherePath,\n parentWherePathIndex: this.parentWherePathIndex,\n innerLimit: this.innerLimit,\n innerOffset: this.innerOffset,\n innerOrderBy: this.innerOrderBy,\n ...overrides,\n });\n return clone;\n }\n\n /**\n * Bound a nested select's related collection to at most `lim` items per parent.\n * Only honoured when the outer query targets a single subject; otherwise the\n * pipeline throws (per-group pagination across multiple parents is unsupported).\n */\n limit(lim: number): this {\n return this.cloneWith({innerLimit: lim});\n }\n\n /** Skip the first `off` items of a nested select's related collection (single-subject only). */\n offset(off: number): this {\n return this.cloneWith({innerOffset: off});\n }\n\n /**\n * Order a nested select's related collection, producing a deterministic window\n * for inner LIMIT/OFFSET. Defaults to ascending.\n *\n * Accepts either a proxy callback — `.orderBy(f => f.name)` — consistent with\n * the rest of the DSL, or a property-name string (`.orderBy('name')`).\n */\n orderBy(\n paths: string | string[] | ((p: any) => unknown),\n direction: 'ASC' | 'DESC' = 'ASC',\n ): this {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.orderBy(paths, direction));\n }\n const orderBy: FieldSetInnerOrderBy[] =\n typeof paths === 'function'\n ? this.orderByFromProxy(paths, direction)\n : (Array.isArray(paths) ? paths : [paths]).map((label) => {\n const ps = walkPropertyPath(this.shape, label).terminal;\n if (!ps) {\n throw new Error(`orderBy: cannot resolve property '${label}' on shape '${this.shape.id}'`);\n }\n return {propertyShapeId: ps.id, direction};\n });\n return this.cloneWith({innerOrderBy: orderBy});\n }\n\n /** Resolve a proxy `orderBy` callback (e.g. `f => f.name` or `f => [f.a, f.b]`)\n * to inner order-by clauses by tracing the sub-select shape's property proxy. */\n private orderByFromProxy(\n fn: (p: any) => unknown,\n direction: 'ASC' | 'DESC',\n ): FieldSetInnerOrderBy[] {\n if (!this.shapeType) {\n throw new Error(\n 'orderBy(callback) is only available on a nested select(); pass a property-name string otherwise',\n );\n }\n const response = fn(createProxiedPathBuilder(this.shapeType));\n const results = Array.isArray(response) ? response : [response];\n return results.map((result) => {\n const segments = FieldSet.collectPropertySegments(result as QueryBuilderObjectLike);\n const terminal = segments[segments.length - 1];\n if (!terminal) {\n throw new Error('orderBy: callback did not resolve to a property of the sub-select shape');\n }\n return {propertyShapeId: terminal.id, direction};\n });\n }\n\n /** Returns a new FieldSet with additional entries. */\n add(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.add(fields));\n }\n const newEntries = FieldSet.resolveInputs(this.shape, fields);\n // Deduplicate\n const existing = new Set(this.entries.map((e) => e.path.toString()));\n const combined = [...this.entries];\n for (const entry of newEntries) {\n if (!existing.has(entry.path.toString())) {\n combined.push(entry);\n }\n }\n return new FieldSet(this.shape, combined, this._catalog);\n }\n\n /** Returns a new FieldSet without entries matching the given labels. */\n remove(labels: string[]): FieldSet {\n const labelSet = new Set(labels);\n const filtered = (this.entries as FieldSetEntry[]).filter(\n (e) => !labelSet.has(e.path.terminal?.label),\n );\n return new FieldSet(this.shape, filtered, this._catalog);\n }\n\n /** Synonym for replacing all entries — returns a new FieldSet with only the given fields. */\n set(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.set(fields));\n }\n const entries = FieldSet.resolveInputs(this.shape, fields);\n return new FieldSet(this.shape, entries, this._catalog);\n }\n\n /** Returns a new FieldSet keeping only entries matching the given labels. */\n pick(labels: string[]): FieldSet {\n const labelSet = new Set(labels);\n const filtered = (this.entries as FieldSetEntry[]).filter(\n (e) => labelSet.has(e.path.terminal?.label),\n );\n return new FieldSet(this.shape, filtered, this._catalog);\n }\n\n /** Returns all PropertyPaths in this FieldSet. */\n paths(): PropertyPath[] {\n return (this.entries as FieldSetEntry[]).map((e) => e.path);\n }\n\n /** Returns terminal property labels of all entries. */\n labels(): string[] {\n return (this.entries as FieldSetEntry[]).map((e) => e.path.terminal?.label).filter(Boolean) as string[];\n }\n\n // ---------------------------------------------------------------------------\n // Serialization\n // ---------------------------------------------------------------------------\n\n /**\n * Serialize this FieldSet to a plain JSON object.\n * Shape is identified by its IRI, paths by dot-separated labels.\n */\n toJSON(): FieldSetJSON {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.toJSON());\n }\n return {shape: this.shape.id, fields: this.toFieldsJSON()};\n }\n\n /** Serialize just the field entries (used for nested relation sub-fields). */\n private toFieldsJSON(): FieldSetFieldJSON[] {\n return (this.entries as FieldSetEntry[]).map((entry) =>\n this.serializeEntry(entry),\n );\n }\n\n private serializeEntry(entry: FieldSetEntry): FieldSetFieldJSON {\n // Computed projection — no path; carry the DSL-JSON value.\n if (entry.expressionNode) {\n const out: FieldSetComputedJSON = {\n value: encodeValueExpr(entry.expressionNode.ir, entry.expressionNode._refs),\n };\n if (entry.alias) out.as = entry.alias;\n if (entry.customKey) out.customKey = entry.customKey;\n return out;\n }\n const pathStr = FieldSet.pathToStringWithCasts(this.shape, entry.path.segments);\n const sub = entry.subSelect ?? entry.preloadSubSelect;\n const subFields = sub ? sub.toFieldsJSON() : undefined;\n const opts: FieldSetRelationOptionsJSON = {};\n const naturalSubShape = FieldSet.nestedShapeOf(entry.path);\n if (sub && sub.shape.id !== naturalSubShape?.id) opts.shape = sub.shape.id;\n if (entry.alias) opts.as = entry.alias;\n if (entry.aggregation) opts.aggregation = entry.aggregation;\n if (entry.customKey) opts.customKey = entry.customKey;\n if (entry.scopedFilter) {\n const idx = entry.scopedFilterIndex ?? entry.path.segments.length - 1;\n opts.where = serializeWherePath(entry.scopedFilter, this.scopedShapeAt(entry, idx));\n opts.whereIndex = idx;\n }\n // Nested-select pagination (G10) — was previously dropped on the wire.\n if (typeof entry.innerLimit === 'number') opts.limit = entry.innerLimit;\n if (typeof entry.innerOffset === 'number') opts.offset = entry.innerOffset;\n if (entry.innerOrderBy && entry.innerOrderBy.length > 0) {\n opts.orderBy = entry.innerOrderBy.map((o) => ({\n [FieldSet.labelOfId(o.propertyShapeId)]: o.direction,\n }));\n }\n const hasOpts = Object.keys(opts).length > 0;\n // Bare-string shorthand: a plain leaf/relation with no options or sub-fields.\n if (!subFields && !hasOpts) return pathStr;\n // Array shorthand: sub-fields only, no other options.\n if (subFields && !hasOpts) return {[pathStr]: subFields};\n // Full options object (optionally carrying `fields`).\n return {[pathStr]: {...opts, ...(subFields ? {fields: subFields} : {})}};\n }\n\n /** The shape a scoped filter at segment `idx` is evaluated against (the segment's value shape). */\n private scopedShapeAt(entry: FieldSetEntry, idx: number): NodeShapeData {\n const seg = entry.path.segments[idx] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})\n ?.valueShape?.id;\n return (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || this.shape;\n }\n\n /**\n * Reconstruct a FieldSet from a JSON object.\n * Resolves shape IRI via getShapeClass() and paths via walkPropertyPath().\n */\n static fromJSON(json: FieldSetJSON): FieldSet {\n return FieldSet.fromFields(FieldSet.resolveShape(json.shape), json.fields);\n }\n\n /** Build a FieldSet from a shape + relation-keyed field list (recursion entry). */\n private static fromFields(shape: NodeShapeData, fields: FieldSetFieldJSON[]): FieldSet {\n return new FieldSet(\n shape,\n fields.map((raw) => FieldSet.parseField(shape, raw)),\n );\n }\n\n /** Parse one field entry (string leaf / computed / relation-keyed) against `shape`. */\n private static parseField(shape: NodeShapeData, raw: FieldSetFieldJSON): FieldSetEntry {\n // Leaf path (may carry inline `as(Shape)` casts).\n if (typeof raw === 'string') {\n return {path: FieldSet.walkPathWithCasts(shape, raw)};\n }\n // Computed projection — carries `value`.\n if ('value' in raw && (raw as FieldSetComputedJSON).value !== undefined) {\n const computed = raw as FieldSetComputedJSON;\n const {ir, refs} = decodeValueExpr(computed.value, shape);\n const entry: FieldSetEntry = {\n path: new PropertyPath(shape, []),\n expressionNode: new ExpressionNode(ir, refs),\n };\n if (computed.as) entry.alias = computed.as;\n if (computed.customKey) entry.customKey = computed.customKey;\n return entry;\n }\n // Relation-keyed: the single non-option key is the relation path.\n const rel = raw as FieldSetRelationJSON;\n const pathKey = Object.keys(rel).find((k) => !RELATION_OPTION_KEYS.has(k));\n if (!pathKey) {\n throw new Error(`FieldSet field has no relation path: ${JSON.stringify(raw)}`);\n }\n const spec = rel[pathKey];\n const path = FieldSet.walkPathWithCasts(shape, pathKey);\n const entry: FieldSetEntry = {path};\n const subFields = Array.isArray(spec) ? spec : spec.fields;\n const opts = Array.isArray(spec) ? ({} as FieldSetRelationOptionsJSON) : spec;\n if (opts.as) entry.alias = opts.as;\n if (opts.customKey) entry.customKey = opts.customKey;\n if (opts.aggregation) entry.aggregation = opts.aggregation as 'count';\n if (opts.where) {\n const idx = opts.whereIndex ?? path.segments.length - 1;\n const seg = path.segments[idx] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})?.valueShape?.id;\n const scopedShape = (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || shape;\n entry.scopedFilter = deserializeWherePath(scopedShape, opts.where);\n entry.scopedFilterIndex = idx;\n }\n // Nested-select pagination (G10).\n if (typeof opts.limit === 'number') entry.innerLimit = opts.limit;\n if (typeof opts.offset === 'number') entry.innerOffset = opts.offset;\n if (opts.orderBy && opts.orderBy.length > 0) {\n const nested = FieldSet.nestedShapeOf(path) ?? shape;\n entry.innerOrderBy = opts.orderBy.map((e) => {\n const label = Object.keys(e)[0];\n const ps = getPropertyShape(nested, label);\n return {propertyShapeId: ps?.id ?? label, direction: Object.values(e)[0]};\n });\n }\n if (subFields) {\n const nested = opts.shape\n ? FieldSet.resolveShape(opts.shape)\n : FieldSet.nestedShapeOf(path) ?? shape;\n entry.subSelect = FieldSet.fromFields(nested, subFields);\n }\n return entry;\n }\n\n /** The shape reached at the end of a relation path (its terminal segment's value shape). */\n private static nestedShapeOf(path: PropertyPath): NodeShapeData | undefined {\n const seg = path.segments[path.segments.length - 1] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})?.valueShape?.id;\n return (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || undefined;\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Resolves any of the accepted shape input types to a NodeShapeData and optional ShapeClass.\n * Accepts: ShapeConstructor (class with .shape), NodeShapeData, or IRI string.\n */\n private static resolveShapeInput(shape: ShapeConstructor<any> | NodeShapeData | string): {nodeShape: NodeShapeData; shapeClass?: ShapeConstructor<any>} {\n // Inside a catalog the catalog's data is the authority for every IRI it holds, so an\n // authored class (or metadata) for one of them resolves to the catalog's shape — as\n // `resolveShape` does for the builders.\n const catalog = getActiveShapeCatalog();\n if (catalog !== undefined && typeof shape !== 'string') {\n const id = typeof shape === 'function' ? shape.shape?.id : shape?.id;\n const own = id ? catalog.get(id) : undefined;\n if (own) {\n const shapeClass = getQueryShapeClass(id!);\n return shapeClass ? {nodeShape: own, shapeClass} : {nodeShape: own};\n }\n }\n if (typeof shape === 'string') {\n const shapeClass = getQueryShapeClass(shape);\n if (shapeClass?.shape) {\n return {nodeShape: shapeClass.shape, shapeClass};\n }\n // No authored class: the metadata alone is enough here — the classless branch\n // below is already supported, it just was not reachable from an IRI.\n const nodeShape = getNodeShape(shape);\n if (!nodeShape) {\n throw new Error(`Cannot resolve shape for '${shape}'`);\n }\n return {nodeShape};\n }\n // ShapeConstructor: has a static .shape property that is a NodeShapeData\n if ('shape' in shape && typeof shape.shape === 'object' && shape.shape !== null && 'id' in shape.shape) {\n return {nodeShape: (shape as ShapeConstructor<any>).shape, shapeClass: shape as ShapeConstructor<any>};\n }\n // NodeShapeData: has .id directly — try to look up its ShapeConstructor for full proxy support\n const nodeShape = shape as NodeShapeData;\n const shapeClass = nodeShape.id ? getQueryShapeClass(nodeShape.id) : undefined;\n return shapeClass\n ? {nodeShape, shapeClass}\n : {nodeShape};\n }\n\n /** @deprecated Use resolveShapeInput instead. Kept for fromJSON which only passes NodeShapeData|string. */\n private static resolveShape(shape: NodeShapeData | string): NodeShapeData {\n return FieldSet.resolveShapeInput(shape).nodeShape;\n }\n\n private static resolveInputs(\n shape: NodeShapeData,\n inputs: FieldSetInput[],\n ): FieldSetEntry[] {\n const entries: FieldSetEntry[] = [];\n for (const input of inputs) {\n if (typeof input === 'string') {\n entries.push({path: walkPropertyPath(shape, input)});\n } else if (input instanceof PropertyPath) {\n entries.push({path: input});\n } else if (input instanceof FieldSet) {\n entries.push(...(input.entries as FieldSetEntry[]));\n } else if (typeof input === 'object') {\n // Nested object form: { friends: ['name', 'hobby'] }\n for (const [key, value] of Object.entries(input)) {\n const basePath = walkPropertyPath(shape, key);\n if (value instanceof FieldSet) {\n // Merge nested FieldSet entries under this path\n for (const entry of value.entries as FieldSetEntry[]) {\n const combined = new PropertyPath(shape, [\n ...basePath.segments,\n ...entry.path.segments,\n ]);\n entries.push({path: combined, alias: entry.alias, scopedFilter: entry.scopedFilter});\n }\n } else if (Array.isArray(value)) {\n // Resolve nested string fields\n const basePropertyShape = basePath.terminal;\n if (!basePropertyShape?.valueShape) {\n throw new Error(\n `Property '${key}' has no valueShape; cannot resolve nested fields`,\n );\n }\n const nestedShapeClass = getQueryShapeClass(basePropertyShape.valueShape);\n if (!nestedShapeClass || !nestedShapeClass.shape) {\n throw new Error(\n `Cannot resolve valueShape for property '${key}'`,\n );\n }\n for (const nestedField of value) {\n const nestedPath = walkPropertyPath(nestedShapeClass.shape, nestedField);\n const combined = new PropertyPath(shape, [\n ...basePath.segments,\n ...nestedPath.segments,\n ]);\n entries.push({path: combined});\n }\n }\n }\n }\n }\n return entries;\n }\n\n /**\n * Trace fields using the full ProxiedPathBuilder proxy (createProxiedPathBuilder).\n * Handles nested paths, where conditions, aggregations, and sub-selects.\n */\n private static traceFieldsWithProxy(\n nodeShape: NodeShapeData,\n shapeClass: ShapeConstructor<any>,\n fn: (p: any) => any,\n ): FieldSetEntry[] {\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = fn(proxy);\n\n // Normalize result: could be a single value, array, or custom object\n if (Array.isArray(result)) {\n return result.map((item) => FieldSet.convertTraceResult(nodeShape, item));\n }\n if (isQueryBuilderObject(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single FieldSet sub-select (e.g. p.friends.select(f => [f.name]))\n if (result instanceof FieldSet && result.parentSegments !== undefined) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single SetSize (e.g. p.friends.size())\n if (isSetSize(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single BoundComponent (e.g. p.bestFriend.preloadFor(comp))\n if (isBoundComponent(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single ExpressionNode (e.g. p.age.times(12))\n if (isExpressionNode(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n if (typeof result === 'object' && result !== null) {\n // Custom object form: {name: p.name, hobby: p.hobby}\n const entries: FieldSetEntry[] = [];\n for (const [key, value] of Object.entries(result)) {\n const entry = FieldSet.convertTraceResult(nodeShape, value);\n entry.customKey = key;\n entries.push(entry);\n }\n return entries;\n }\n return [];\n }\n\n /**\n * Convert a single proxy trace result (QueryBuilderObject, SetSize, or FieldSet sub-select)\n * into a FieldSetEntry.\n */\n private static convertTraceResult(rootShape: NodeShapeData, obj: any): FieldSetEntry {\n // SetSize → aggregation: 'count'\n if (isSetSize(obj)) {\n const segments = FieldSet.collectPropertySegments(obj.subject);\n return {\n path: new PropertyPath(rootShape, segments),\n aggregation: 'count',\n };\n }\n\n // FieldSet sub-select — use its entries directly (created by forSubSelect)\n if (obj instanceof FieldSet && obj.parentSegments !== undefined) {\n const subSelect = obj.entries.length > 0 ? obj : undefined;\n const entry: FieldSetEntry = {\n path: new PropertyPath(rootShape, obj.parentSegments),\n subSelect: subSelect as FieldSet | undefined,\n };\n // Carry an inline `.where()` from the parent traversal chain\n // (e.g. `p.friends.where(...).select(...)`).\n if (obj.parentWherePath) {\n entry.scopedFilter = obj.parentWherePath;\n entry.scopedFilterIndex = obj.parentWherePathIndex;\n }\n // Carry inner LIMIT/OFFSET/ORDER BY from `.limit()`/`.offset()`/`.orderBy()`.\n if (typeof obj.innerLimit === 'number') entry.innerLimit = obj.innerLimit;\n if (typeof obj.innerOffset === 'number') entry.innerOffset = obj.innerOffset;\n if (obj.innerOrderBy) entry.innerOrderBy = obj.innerOrderBy;\n return entry;\n }\n\n // BoundComponent → preload composition (e.g. p.bestFriend.preloadFor(component))\n // Extract the component's FieldSet and store it as preloadSubSelect.\n if (isBoundComponent(obj)) {\n const segments = FieldSet.collectPropertySegments(obj.source);\n const componentFieldSet = FieldSet.extractComponentFieldSet(obj.originalValue);\n return {\n path: new PropertyPath(rootShape, segments),\n preloadSubSelect: componentFieldSet,\n };\n }\n\n // ExpressionNode → computed expression (e.g. p.age.times(12))\n if (isExpressionNode(obj)) {\n return {\n path: new PropertyPath(rootShape, []),\n expressionNode: obj,\n };\n }\n\n // QueryBuilderObject → walk the chain to collect PropertyPath segments\n if (isQueryBuilderObject(obj)) {\n const segments = FieldSet.collectPropertySegments(obj);\n const entry: FieldSetEntry = {\n path: new PropertyPath(rootShape, segments),\n };\n // Walk from leaf to root to find wherePath on any object in the chain.\n // Track which segment it belongs to so desugarEntry attaches the filter correctly.\n let current: QueryBuilderObjectLike | undefined = obj;\n let leafDistance = 0;\n while (current) {\n if (current.wherePath) {\n entry.scopedFilter = current.wherePath as WherePath;\n entry.scopedFilterIndex = segments.length - 1 - leafDistance;\n break;\n }\n current = current.subject;\n leafDistance++;\n }\n return entry;\n }\n\n // Fallback: string label\n if (typeof obj === 'string') {\n return {path: walkPropertyPath(rootShape, obj)};\n }\n\n throw new Error(`Unknown trace result type: ${obj}`);\n }\n\n /**\n * Walk a QueryBuilderObject-like chain (via .subject) collecting PropertyShapeData segments\n * from leaf to root, then reverse to get root-to-leaf order.\n */\n static collectPropertySegments(obj: QueryBuilderObjectLike): PropertyShapeData[] {\n const segments: PropertyShapeData[] = [];\n let current: QueryBuilderObjectLike | undefined = obj;\n while (current) {\n if (current.property) {\n segments.unshift(current.property);\n }\n current = current.subject;\n }\n return segments;\n }\n\n // ---------------------------------------------------------------------------\n // Cast-aware path (de)serialization — carries `.as(Shape)` narrowing inline as\n // an `as(<ShapeLabel>)` path segment (documentation/dsl-json.md, backlog 002 G5).\n // ---------------------------------------------------------------------------\n\n private static shapeById(id: string): NodeShapeData | undefined {\n return getShapeClass(id)?.shape ?? getNodeShape(id);\n }\n\n private static shapeByLabel(label: string): NodeShapeData | undefined {\n // Inside a catalog every shape is data (core's built-ins aside), so scan its shapes;\n // the global registry keeps scanning authored classes.\n const matches = (shape?: NodeShapeData): shape is NodeShapeData =>\n !!shape && (shape.label === label || FieldSet.labelOfId(shape.id) === label);\n if (getActiveShapeCatalog() !== undefined) {\n for (const shape of getAllNodeShapes().values()) if (matches(shape)) return shape;\n return undefined;\n }\n for (const cls of getAllShapeClasses().values()) {\n const shape = (cls as unknown as {shape?: NodeShapeData}).shape;\n if (matches(shape)) return shape;\n }\n return undefined;\n }\n\n private static labelOfId(id: string): string {\n const i = id.lastIndexOf('/');\n return i >= 0 ? id.slice(i + 1) : id;\n }\n\n /**\n * Render a segment chain as a dotted label path, inserting `as(<ShapeLabel>)`\n * wherever a segment is not resolvable by label from the natural (walked) shape\n * — i.e. a `.as(Shape)` narrowing happened before it.\n */\n static pathToStringWithCasts(rootShape: NodeShapeData, segments: readonly PropertyShapeData[]): string {\n const parts: string[] = [];\n let current: NodeShapeData | undefined = rootShape;\n for (const seg of segments) {\n const label = FieldSet.labelOfId(seg.id);\n const natural = current ? getPropertyShape(current, label) : undefined;\n if (!natural || natural.id !== seg.id) {\n // A cast narrowed the context to the segment's owner shape.\n const ownerId = seg.id.slice(0, seg.id.lastIndexOf('/'));\n const owner = FieldSet.shapeById(ownerId);\n parts.push(`as(${owner?.label ?? FieldSet.labelOfId(ownerId)})`);\n current = owner ?? current;\n }\n parts.push(label);\n const vs = (seg as unknown as {valueShape?: {id: string}}).valueShape;\n current = vs ? FieldSet.shapeById(vs.id) ?? current : current;\n }\n return parts.join('.');\n }\n\n /** Inverse of {@link pathToStringWithCasts}: resolve a dotted path with `as(X)` casts. */\n static walkPathWithCasts(rootShape: NodeShapeData, path: string): PropertyPath {\n if (!path.includes('as(')) return walkPropertyPath(rootShape, path);\n const segments: PropertyShapeData[] = [];\n let current: NodeShapeData | undefined = rootShape;\n for (const token of path.split('.')) {\n const cast = /^as\\((.+)\\)$/.exec(token);\n if (cast) {\n current = FieldSet.shapeByLabel(cast[1]) ?? current;\n continue;\n }\n const ps = current ? getPropertyShape(current, token) : undefined;\n if (!ps) {\n throw new Error(\n `Property '${token}' not found on shape '${current?.label || current?.id}' while resolving path '${path}'`,\n );\n }\n segments.push(ps);\n const vs = (ps as unknown as {valueShape?: {id: string}}).valueShape;\n current = vs ? FieldSet.shapeById(vs.id) ?? current : current;\n }\n return new PropertyPath(rootShape, segments);\n }\n\n /**\n * Extract a FieldSet from a component-like object for preload composition.\n *\n * Supports multiple component interfaces:\n * - `.fields` as a FieldSet directly\n * - `.query` as a FieldSet, QueryBuilder (duck-typed via .fields()), or\n * Record<string, QueryBuilder> (e.g. `{person: PersonQuery}`)\n */\n static extractComponentFieldSet(component: any): FieldSet | undefined {\n // Prefer .fields if it's a FieldSet\n if (component.fields instanceof FieldSet) {\n return component.fields;\n }\n const query = component.query;\n if (query instanceof FieldSet) {\n return query;\n }\n // QueryBuilder duck-type — has .fields() method\n if (query && typeof query.fields === 'function') {\n return query.fields();\n }\n // Record form: { propName: QueryBuilder }\n if (typeof query === 'object') {\n for (const key in query) {\n const value = (query as Record<string, any>)[key];\n if (value && typeof value.fields === 'function') {\n return value.fields();\n }\n }\n }\n return undefined;\n }\n\n /**\n * Internal factory that bypasses the private constructor for use by static methods.\n */\n private static createInternal(shape: NodeShapeData, entries: FieldSetEntry[]): FieldSet {\n return new FieldSet(shape, entries);\n }\n\n /**\n * Create a FieldSet from raw entries. Used by QueryBuilder to merge preload entries.\n */\n static createFromEntries(shape: NodeShapeData, entries: FieldSetEntry[]): FieldSet {\n return new FieldSet(shape, entries);\n }\n\n /**\n * Extract FieldSetEntry[] from a sub-query's traceResponse.\n * Public alias for use by lightweight sub-select wrappers.\n */\n static extractSubSelectEntriesPublic(rootShape: NodeShapeData, traceResponse: any): FieldSetEntry[] {\n return FieldSet.extractSubSelectEntries(rootShape, traceResponse);\n }\n\n /**\n * Extract FieldSetEntry[] from a sub-select's traceResponse.\n * The traceResponse is the result of calling the sub-query callback with a proxy,\n * containing QueryBuilderObjects, arrays, custom objects, etc.\n */\n private static extractSubSelectEntries(rootShape: NodeShapeData, traceResponse: any): FieldSetEntry[] {\n if (Array.isArray(traceResponse)) {\n return traceResponse\n .filter((item) => item !== null && item !== undefined)\n .map((item) => FieldSet.convertTraceResult(rootShape, item));\n }\n if (isQueryBuilderObject(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single FieldSet sub-select — convert directly\n if (traceResponse instanceof FieldSet && traceResponse.parentSegments !== undefined) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single SetSize\n if (isSetSize(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single ExpressionNode\n if (isExpressionNode(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n if (typeof traceResponse === 'object' && traceResponse !== null) {\n // Custom object form: {name: p.name, hobby: p.hobby}\n const entries: FieldSetEntry[] = [];\n for (const [key, value] of Object.entries(traceResponse)) {\n if (value !== null && value !== undefined) {\n const entry = FieldSet.convertTraceResult(rootShape, value);\n entry.customKey = key;\n entries.push(entry);\n }\n }\n return entries;\n }\n return [];\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FieldSet.js","sourceRoot":"","sources":["../../../src/queries/FieldSet.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,CAAC,aAAa,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;YAChE,qDAAqD;YACrD,MAAM,OAAO,GAAoB,EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;oBAC5D,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC;oBACtB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CAEF","sourcesContent":["import type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {getUniquePropertyShapes, getPropertyShape} from '../shapes/nodeShapeData.js';\nimport type {Shape, ShapeConstructor} from '../shapes/Shape.js';\nimport {PropertyPath, walkPropertyPath} from './PropertyPath.js';\nimport {\n captureCatalog,\n getActiveShapeCatalog,\n getAllNodeShapes,\n getAllShapeClasses,\n getNodeShape,\n getShapeClass,\n withShapeCatalog,\n getQueryShapeClass,\n} from '../utils/ShapeClass.js';\nimport type {ShapeCatalog} from '../utils/ShapeCatalog.js';\nimport type {WherePath} from './SelectQuery.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {encodeValueExpr, decodeValueExpr, type DslJsonValue} from './DslJsonExpression.js';\nimport {\n serializeWherePath,\n deserializeWherePath,\n type WherePathJSON,\n} from './QueryBuilderSerialization.js';\nimport {topLevelDetails, unresolvedShapeError, unresolvedValueShapeError} from '../utils/unresolvedShape.js';\n\n// Duck-type helpers for runtime detection.\n// These check structural shape since the classes live in SelectQuery.ts (runtime circular dep).\n// QueryBuilderObject has .property (PropertyShapeData) and .subject (QueryBuilderObject).\n// SetSize has .subject and extends QueryPrimitive<number>.\ntype QueryBuilderObjectLike = {\n property?: PropertyShapeData;\n subject?: QueryBuilderObjectLike;\n wherePath?: unknown;\n};\nconst isQueryBuilderObject = (obj: any): obj is QueryBuilderObjectLike =>\n obj !== null &&\n typeof obj === 'object' &&\n 'property' in obj &&\n 'subject' in obj &&\n typeof obj.getPropertyPath === 'function';\n\nconst isSetSize = (obj: any): boolean =>\n obj !== null &&\n typeof obj === 'object' &&\n 'subject' in obj &&\n typeof obj.as === 'function' &&\n typeof obj.getPropertyPath === 'function' &&\n // SetSize has a 'countable' field (may be undefined) and 'label' field\n 'label' in obj;\n\n// BoundComponent: has .source (QueryBuilderObject) and .originalValue (component-like)\nconst isBoundComponent = (obj: any): boolean =>\n obj !== null &&\n typeof obj === 'object' &&\n 'source' in obj &&\n 'originalValue' in obj;\n\n/**\n * A single entry in a FieldSet: a property path with optional alias, scoped filter,\n * sub-selection, aggregation, and custom key.\n */\nexport type FieldSetEntry = {\n path: PropertyPath;\n alias?: string;\n scopedFilter?: WherePath;\n /** Index into path.segments indicating which segment the scopedFilter applies to.\n * Defaults to the last segment if not specified. */\n scopedFilterIndex?: number;\n /** Nested object selection — the user explicitly selected sub-fields (e.g. `p.friends.select(...)`) */\n subSelect?: FieldSet;\n aggregation?: 'count';\n customKey?: string;\n /** Component preload composition — the FieldSet comes from a linked component's own query,\n * merged in via `preloadFor()`. Distinct from subSelect which is a user-authored nested query. */\n preloadSubSelect?: FieldSet;\n /** Computed expression from proxy tracing (e.g. `p.age.times(12)`) */\n expressionNode?: ExpressionNode;\n /** Inner LIMIT for a nested select (e.g. `p.friends.select(...).limit(2)`).\n * Only supported when the outer query targets a single subject. */\n innerLimit?: number;\n /** Inner OFFSET for a nested select. */\n innerOffset?: number;\n /** Inner ORDER BY for a nested select — paths relative to the sub-select shape. */\n innerOrderBy?: FieldSetInnerOrderBy[];\n};\n\n/** A single inner ORDER BY clause for a nested select. */\nexport type FieldSetInnerOrderBy = {\n propertyShapeId: string;\n direction: 'ASC' | 'DESC';\n};\n\n/**\n * Input types accepted by FieldSet construction methods.\n *\n * - `string` — resolved via walkPropertyPath (dot-separated)\n * - `PropertyPath` — used directly\n * - `FieldSet` — merged in\n * - `Record<string, string[] | FieldSet>` — nested fields\n */\nexport type FieldSetInput =\n | string\n | PropertyPath\n | FieldSet\n | Record<string, string[] | FieldSet>;\n\n/** A computed projection field: `{ as?, value }` — a DSL-JSON expression, no path. */\nexport type FieldSetComputedJSON = {\n as?: string;\n value: DslJsonValue;\n customKey?: string;\n};\n\n/** Options for a relation projection (the object value under a relation key). */\nexport type FieldSetRelationOptionsJSON = {\n as?: string;\n /** Shape IRI for nested fields when it differs from the relation's declared value shape. */\n shape?: string;\n /** A scoped filter on the relation (`p.friends.where(...)`). */\n where?: WherePathJSON;\n /** Which path segment the scoped `where` applies to (defaults to the last). */\n whereIndex?: number;\n aggregation?: string;\n customKey?: string;\n /** Nested-select pagination (`p.friends.select(...).limit(5).offset(2).orderBy(...)`). */\n limit?: number;\n offset?: number;\n orderBy?: Array<{[path: string]: 'ASC' | 'DESC'}>;\n /** Sub-projection of the related shape. */\n fields?: FieldSetFieldJSON[];\n};\n\n/**\n * A relation-keyed field: a single-key object whose key is the relation path\n * (labels dotted, with inline `as(Shape)` casts) and whose value is either the\n * sub-fields array (`{ \"friends\": [\"name\"] }`) or an options object\n * (`{ \"friends\": { as, where, fields } }`). Also covers a leaf with options\n * (`{ \"name\": { \"as\": \"personName\" } }`). The related shape is inferred.\n */\nexport type FieldSetRelationJSON = {\n [path: string]: FieldSetFieldJSON[] | FieldSetRelationOptionsJSON;\n};\n\n/**\n * JSON representation of a FieldSet field entry — exactly three shapes:\n * - a **string** leaf path (`\"name\"`, `\"friends.friends.name\"`, `\"pets.as(Dog).level\"`)\n * - a **relation-keyed** object (`{ \"friends\": [...] | {options} }`)\n * - a **computed** object (`{ as?, value }`)\n */\nexport type FieldSetFieldJSON = string | FieldSetComputedJSON | FieldSetRelationJSON;\n\n/** JSON representation of a FieldSet (a shape + its top-level fields). */\nexport type FieldSetJSON = {\n shape: string;\n fields: FieldSetFieldJSON[];\n};\n\n/** Option keys reserved inside a relation options object (never a relation path). */\nconst RELATION_OPTION_KEYS = new Set([\n 'as',\n 'shape',\n 'where',\n 'whereIndex',\n 'aggregation',\n 'customKey',\n 'limit',\n 'offset',\n 'orderBy',\n 'fields',\n]);\n\n/**\n * An immutable, composable collection of property paths for a shape.\n *\n * FieldSet describes which properties to select, independent of\n * how the query is built. It integrates with QueryBuilder via\n * `.select(fieldSet)`.\n *\n * Every mutation method returns a new FieldSet — the original is never modified.\n */\nexport class FieldSet<R = any, Source = any> {\n readonly shape: NodeShapeData;\n readonly entries: readonly FieldSetEntry[];\n /** Phantom field — carries the callback response type for conditional type inference. */\n declare readonly __response: R;\n /** Phantom field — carries the source context (QueryShapeSet/QueryShape) for conditional type inference. */\n declare readonly __source: Source;\n\n /**\n * For sub-select FieldSets: the raw callback return value (proxy trace objects).\n * Stored so conditional types can extract the response type.\n */\n readonly traceResponse?: R;\n\n /**\n * For sub-select FieldSets: the parent property segments leading to this sub-select.\n */\n readonly parentSegments?: PropertyShapeData[];\n\n /**\n * For sub-select FieldSets: the shape class (ShapeType) of the sub-select's target.\n */\n readonly shapeType?: any;\n\n /**\n * For sub-select FieldSets: inline `.where()` filter found on the parent\n * traversal chain (e.g. `p.friends.where(...).select(...)`), plus the index\n * into `parentSegments` of the segment it scopes.\n */\n readonly parentWherePath?: WherePath;\n readonly parentWherePathIndex?: number;\n\n /**\n * For sub-select FieldSets: inner LIMIT/OFFSET/ORDER BY carried from\n * `.limit()`/`.offset()`/`.orderBy()` chained on the nested select.\n * These bound the related collection per parent (single-subject only).\n */\n readonly innerLimit?: number;\n readonly innerOffset?: number;\n readonly innerOrderBy?: FieldSetInnerOrderBy[];\n\n private readonly _catalog: ShapeCatalog | undefined;\n\n private constructor(\n shape: NodeShapeData,\n entries: FieldSetEntry[],\n catalog: ShapeCatalog | undefined = FieldSet.captureFor(shape),\n ) {\n this.shape = shape;\n this.entries = entries;\n this._catalog = catalog;\n }\n\n /** The catalog this FieldSet resolves shapes in (undefined = the global registry). */\n get catalog(): ShapeCatalog | undefined {\n return this._catalog;\n }\n\n /**\n * The catalog a FieldSet rooted at `shape` captures: the active one for an IRI or a\n * shape it holds, none for a shape it does not (an authored class built by code that\n * runs inside a project scope), else the catalog an adapter class came from.\n */\n private static captureFor(\n shape: ShapeConstructor<any> | NodeShapeData | string,\n ): ShapeCatalog | undefined {\n if (typeof shape === 'function') return captureCatalog(shape);\n const active = getActiveShapeCatalog();\n if (active === undefined || typeof shape === 'string') return active;\n return active.has(shape.id) ? active : undefined;\n }\n\n // ---------------------------------------------------------------------------\n // Static constructors\n // ---------------------------------------------------------------------------\n\n /**\n * Create a FieldSet for the given shape with the specified fields.\n *\n * Accepts a ShapeClass (e.g. Person), NodeShapeData, or shape IRI string.\n * Fields can be string paths, PropertyPath instances, nested objects,\n * or a callback receiving a proxy for dot-access.\n */\n static for<S extends Shape>(shape: ShapeConstructor<S>, fields: FieldSetInput[]): FieldSet<any>;\n static for<S extends Shape, R>(shape: ShapeConstructor<S>, fn: (p: any) => R): FieldSet<R>;\n static for(shape: NodeShapeData | string, fields: FieldSetInput[]): FieldSet<any>;\n static for(shape: NodeShapeData | string, fn: (p: any) => any): FieldSet<any>;\n static for(\n shape: ShapeConstructor<any> | NodeShapeData | string,\n fieldsOrFn: FieldSetInput[] | ((p: any) => any),\n ): FieldSet<any> {\n const catalog = FieldSet.captureFor(shape);\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => FieldSet.for(shape as string, fieldsOrFn as FieldSetInput[]));\n }\n const resolved = FieldSet.resolveShapeInput(shape);\n const resolvedShape = resolved.nodeShape;\n\n if (typeof fieldsOrFn === 'function') {\n if (!resolved.shapeClass) {\n throw new Error(\n `Cannot use callback form for shape '${resolved.nodeShape.id}': no ShapeConstructor registered. ` +\n `Use string field names instead, or pass the Shape class directly.`,\n );\n }\n const fields = FieldSet.traceFieldsWithProxy(resolved.nodeShape, resolved.shapeClass, fieldsOrFn);\n return new FieldSet(resolved.nodeShape, fields);\n }\n\n const entries = FieldSet.resolveInputs(resolvedShape, fieldsOrFn);\n return new FieldSet(resolvedShape, entries);\n }\n\n /**\n * Create a typed FieldSet for a sub-select. Traces the callback through the proxy,\n * stores parentSegments and traceResponse for runtime compatibility, and preserves\n * R and Source generics for conditional type inference.\n */\n static forSubSelect<R, Source>(\n shapeClass: any,\n fn: (p: any) => R,\n parentSegments: PropertyShapeData[],\n source?: QueryBuilderObjectLike,\n ): FieldSet<R, Source> {\n const nodeShape = shapeClass.shape || shapeClass;\n // Trace once: get both the raw response (for type carriers) and the entries\n const proxy = createProxiedPathBuilder(shapeClass);\n const traceResponse = fn(proxy as any);\n const entries = FieldSet.extractSubSelectEntries(nodeShape, traceResponse);\n const fs = new FieldSet(nodeShape, entries) as FieldSet<R, Source>;\n // Writable cast — these readonly fields are initialised once here at construction time\n const w = fs as {-readonly [K in 'traceResponse' | 'parentSegments' | 'shapeType' | 'parentWherePath' | 'parentWherePathIndex']: FieldSet<R, Source>[K]};\n w.traceResponse = traceResponse;\n w.parentSegments = parentSegments;\n w.shapeType = shapeClass;\n // Carry an inline `.where()` from the parent traversal chain (walked\n // leaf→root, same convention as convertTraceResult for plain paths).\n let current = source;\n let leafDistance = 0;\n while (current) {\n if (current.wherePath) {\n w.parentWherePath = current.wherePath as WherePath;\n w.parentWherePathIndex = parentSegments.length - 1 - leafDistance;\n break;\n }\n current = current.subject;\n leafDistance++;\n }\n return fs;\n }\n\n\n /**\n * Create a FieldSet containing all decorated properties of the shape.\n *\n * @param opts.depth Controls how deep to include nested shape properties:\n * - `depth=1` (default): this level only — properties of the root shape.\n * - `depth=0`: throws — use a node reference instead.\n * - `depth>1`: recursively includes nested shape properties up to the given depth.\n */\n static all<S extends Shape>(shape: ShapeConstructor<S>, opts?: {depth?: number}): FieldSet;\n static all(shape: NodeShapeData | string, opts?: {depth?: number}): FieldSet;\n static all(shape: ShapeConstructor<any> | NodeShapeData | string, opts?: {depth?: number}): FieldSet {\n const catalog = FieldSet.captureFor(shape);\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => FieldSet.all(shape as string, opts));\n }\n const depth = opts?.depth ?? 1;\n if (depth < 1) {\n throw new Error(\n 'FieldSet.all() requires depth >= 1. Use a node reference ({id}) for depth 0.',\n );\n }\n const resolved = FieldSet.resolveShapeInput(shape);\n // Seed visited with the root shape to prevent self-referencing cycles\n const visited = new Set<string>([resolved.nodeShape.id]);\n return FieldSet.allForShape(resolved.nodeShape, depth, visited);\n }\n\n /**\n * Recursive helper for all(). Tracks visited shape IDs to prevent infinite loops\n * from circular shape references.\n */\n private static allForShape(\n nodeShape: NodeShapeData,\n depth: number,\n visited: Set<string>,\n ): FieldSet {\n const propertyShapes = getUniquePropertyShapes(nodeShape);\n const entries: FieldSetEntry[] = [];\n\n for (const ps of propertyShapes) {\n const entry: FieldSetEntry = {path: new PropertyPath(nodeShape, [ps])};\n\n // If depth > 1, recurse into nested shapes\n if (depth > 1 && ps.valueShape) {\n const nestedShapeClass = getQueryShapeClass(ps.valueShape);\n if (nestedShapeClass?.shape && !visited.has(nestedShapeClass.shape.id)) {\n visited.add(nestedShapeClass.shape.id);\n const nestedFs = FieldSet.allForShape(nestedShapeClass.shape, depth - 1, visited);\n if (nestedFs.entries.length > 0) {\n entry.subSelect = nestedFs;\n }\n }\n }\n\n entries.push(entry);\n }\n\n return new FieldSet(nodeShape, entries);\n }\n\n /**\n * Merge multiple FieldSets into one, deduplicating by path equality.\n * All FieldSets must share the same root shape.\n */\n static merge(sets: FieldSet[]): FieldSet {\n if (sets.length === 0) {\n throw new Error('Cannot merge empty array of FieldSets');\n }\n const shape = sets[0].shape;\n for (const set of sets) {\n if (set.shape.id !== shape.id) {\n throw new Error(\n `Cannot merge FieldSets with different shapes: '${shape.label || shape.id}' and '${set.shape.label || set.shape.id}'`,\n );\n }\n }\n const merged: FieldSetEntry[] = [];\n const seen = new Set<string>();\n\n for (const set of sets) {\n for (const entry of set.entries) {\n // Include aggregation in the dedup key so that 'friends' and 'friends(count)' are distinct\n const key = entry.aggregation\n ? `${entry.path.toString()}:${entry.aggregation}`\n : entry.path.toString();\n if (!seen.has(key)) {\n seen.add(key);\n merged.push(entry);\n }\n }\n }\n\n return new FieldSet(shape, merged, sets[0]._catalog);\n }\n\n // ---------------------------------------------------------------------------\n // Composition methods — each returns a new FieldSet\n // ---------------------------------------------------------------------------\n\n /** Returns a new FieldSet with only the given fields. */\n select(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.select(fields));\n }\n const entries = FieldSet.resolveInputs(this.shape, fields);\n return new FieldSet(this.shape, entries, this._catalog);\n }\n\n /**\n * Clone this FieldSet, preserving the sub-select carrier fields\n * (traceResponse / parentSegments / shapeType / inner pagination) and\n * applying the supplied overrides. Used by `.limit()`/`.offset()`/`.orderBy()`.\n */\n private cloneWith(\n overrides: Partial<Pick<FieldSet, 'innerLimit' | 'innerOffset' | 'innerOrderBy'>>,\n ): this {\n const clone = new FieldSet(this.shape, this.entries as FieldSetEntry[], this._catalog) as this;\n // The sub-select carrier fields are declared `readonly` (normally set once at\n // construction via `forSubSelect`). Copy this FieldSet's identity onto the\n // clone through a mutable view, then layer the pagination overrides on top.\n Object.assign(clone as Record<string, unknown>, {\n traceResponse: this.traceResponse,\n parentSegments: this.parentSegments,\n shapeType: this.shapeType,\n parentWherePath: this.parentWherePath,\n parentWherePathIndex: this.parentWherePathIndex,\n innerLimit: this.innerLimit,\n innerOffset: this.innerOffset,\n innerOrderBy: this.innerOrderBy,\n ...overrides,\n });\n return clone;\n }\n\n /**\n * Bound a nested select's related collection to at most `lim` items per parent.\n * Only honoured when the outer query targets a single subject; otherwise the\n * pipeline throws (per-group pagination across multiple parents is unsupported).\n */\n limit(lim: number): this {\n return this.cloneWith({innerLimit: lim});\n }\n\n /** Skip the first `off` items of a nested select's related collection (single-subject only). */\n offset(off: number): this {\n return this.cloneWith({innerOffset: off});\n }\n\n /**\n * Order a nested select's related collection, producing a deterministic window\n * for inner LIMIT/OFFSET. Defaults to ascending.\n *\n * Accepts either a proxy callback — `.orderBy(f => f.name)` — consistent with\n * the rest of the DSL, or a property-name string (`.orderBy('name')`).\n */\n orderBy(\n paths: string | string[] | ((p: any) => unknown),\n direction: 'ASC' | 'DESC' = 'ASC',\n ): this {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.orderBy(paths, direction));\n }\n const orderBy: FieldSetInnerOrderBy[] =\n typeof paths === 'function'\n ? this.orderByFromProxy(paths, direction)\n : (Array.isArray(paths) ? paths : [paths]).map((label) => {\n const ps = walkPropertyPath(this.shape, label).terminal;\n if (!ps) {\n throw new Error(`orderBy: cannot resolve property '${label}' on shape '${this.shape.id}'`);\n }\n return {propertyShapeId: ps.id, direction};\n });\n return this.cloneWith({innerOrderBy: orderBy});\n }\n\n /** Resolve a proxy `orderBy` callback (e.g. `f => f.name` or `f => [f.a, f.b]`)\n * to inner order-by clauses by tracing the sub-select shape's property proxy. */\n private orderByFromProxy(\n fn: (p: any) => unknown,\n direction: 'ASC' | 'DESC',\n ): FieldSetInnerOrderBy[] {\n if (!this.shapeType) {\n throw new Error(\n 'orderBy(callback) is only available on a nested select(); pass a property-name string otherwise',\n );\n }\n const response = fn(createProxiedPathBuilder(this.shapeType));\n const results = Array.isArray(response) ? response : [response];\n return results.map((result) => {\n const segments = FieldSet.collectPropertySegments(result as QueryBuilderObjectLike);\n const terminal = segments[segments.length - 1];\n if (!terminal) {\n throw new Error('orderBy: callback did not resolve to a property of the sub-select shape');\n }\n return {propertyShapeId: terminal.id, direction};\n });\n }\n\n /** Returns a new FieldSet with additional entries. */\n add(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.add(fields));\n }\n const newEntries = FieldSet.resolveInputs(this.shape, fields);\n // Deduplicate\n const existing = new Set(this.entries.map((e) => e.path.toString()));\n const combined = [...this.entries];\n for (const entry of newEntries) {\n if (!existing.has(entry.path.toString())) {\n combined.push(entry);\n }\n }\n return new FieldSet(this.shape, combined, this._catalog);\n }\n\n /** Returns a new FieldSet without entries matching the given labels. */\n remove(labels: string[]): FieldSet {\n const labelSet = new Set(labels);\n const filtered = (this.entries as FieldSetEntry[]).filter(\n (e) => !labelSet.has(e.path.terminal?.label),\n );\n return new FieldSet(this.shape, filtered, this._catalog);\n }\n\n /** Synonym for replacing all entries — returns a new FieldSet with only the given fields. */\n set(fields: FieldSetInput[]): FieldSet {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.set(fields));\n }\n const entries = FieldSet.resolveInputs(this.shape, fields);\n return new FieldSet(this.shape, entries, this._catalog);\n }\n\n /** Returns a new FieldSet keeping only entries matching the given labels. */\n pick(labels: string[]): FieldSet {\n const labelSet = new Set(labels);\n const filtered = (this.entries as FieldSetEntry[]).filter(\n (e) => labelSet.has(e.path.terminal?.label),\n );\n return new FieldSet(this.shape, filtered, this._catalog);\n }\n\n /** Returns all PropertyPaths in this FieldSet. */\n paths(): PropertyPath[] {\n return (this.entries as FieldSetEntry[]).map((e) => e.path);\n }\n\n /** Returns terminal property labels of all entries. */\n labels(): string[] {\n return (this.entries as FieldSetEntry[]).map((e) => e.path.terminal?.label).filter(Boolean) as string[];\n }\n\n // ---------------------------------------------------------------------------\n // Serialization\n // ---------------------------------------------------------------------------\n\n /**\n * Serialize this FieldSet to a plain JSON object.\n * Shape is identified by its IRI, paths by dot-separated labels.\n */\n toJSON(): FieldSetJSON {\n const catalog = this._catalog;\n if (catalog !== getActiveShapeCatalog()) {\n return withShapeCatalog(catalog, () => this.toJSON());\n }\n return {shape: this.shape.id, fields: this.toFieldsJSON()};\n }\n\n /** Serialize just the field entries (used for nested relation sub-fields). */\n private toFieldsJSON(): FieldSetFieldJSON[] {\n return (this.entries as FieldSetEntry[]).map((entry) =>\n this.serializeEntry(entry),\n );\n }\n\n private serializeEntry(entry: FieldSetEntry): FieldSetFieldJSON {\n // Computed projection — no path; carry the DSL-JSON value.\n if (entry.expressionNode) {\n const out: FieldSetComputedJSON = {\n value: encodeValueExpr(entry.expressionNode.ir, entry.expressionNode._refs),\n };\n if (entry.alias) out.as = entry.alias;\n if (entry.customKey) out.customKey = entry.customKey;\n return out;\n }\n const pathStr = FieldSet.pathToStringWithCasts(this.shape, entry.path.segments);\n const sub = entry.subSelect ?? entry.preloadSubSelect;\n const subFields = sub ? sub.toFieldsJSON() : undefined;\n const opts: FieldSetRelationOptionsJSON = {};\n const naturalSubShape = FieldSet.nestedShapeOf(entry.path);\n if (sub && sub.shape.id !== naturalSubShape?.id) opts.shape = sub.shape.id;\n if (entry.alias) opts.as = entry.alias;\n if (entry.aggregation) opts.aggregation = entry.aggregation;\n if (entry.customKey) opts.customKey = entry.customKey;\n if (entry.scopedFilter) {\n const idx = entry.scopedFilterIndex ?? entry.path.segments.length - 1;\n opts.where = serializeWherePath(entry.scopedFilter, this.scopedShapeAt(entry, idx));\n opts.whereIndex = idx;\n }\n // Nested-select pagination (G10) — was previously dropped on the wire.\n if (typeof entry.innerLimit === 'number') opts.limit = entry.innerLimit;\n if (typeof entry.innerOffset === 'number') opts.offset = entry.innerOffset;\n if (entry.innerOrderBy && entry.innerOrderBy.length > 0) {\n opts.orderBy = entry.innerOrderBy.map((o) => ({\n [FieldSet.labelOfId(o.propertyShapeId)]: o.direction,\n }));\n }\n const hasOpts = Object.keys(opts).length > 0;\n // Bare-string shorthand: a plain leaf/relation with no options or sub-fields.\n if (!subFields && !hasOpts) return pathStr;\n // Array shorthand: sub-fields only, no other options.\n if (subFields && !hasOpts) return {[pathStr]: subFields};\n // Full options object (optionally carrying `fields`).\n return {[pathStr]: {...opts, ...(subFields ? {fields: subFields} : {})}};\n }\n\n /** The shape a scoped filter at segment `idx` is evaluated against (the segment's value shape). */\n private scopedShapeAt(entry: FieldSetEntry, idx: number): NodeShapeData {\n const seg = entry.path.segments[idx] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})\n ?.valueShape?.id;\n return (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || this.shape;\n }\n\n /**\n * Reconstruct a FieldSet from a JSON object.\n * Resolves shape IRI via getShapeClass() and paths via walkPropertyPath().\n */\n static fromJSON(json: FieldSetJSON): FieldSet {\n return FieldSet.fromFields(FieldSet.resolveShape(json.shape), json.fields);\n }\n\n /** Build a FieldSet from a shape + relation-keyed field list (recursion entry). */\n private static fromFields(shape: NodeShapeData, fields: FieldSetFieldJSON[]): FieldSet {\n return new FieldSet(\n shape,\n fields.map((raw) => FieldSet.parseField(shape, raw)),\n );\n }\n\n /** Parse one field entry (string leaf / computed / relation-keyed) against `shape`. */\n private static parseField(shape: NodeShapeData, raw: FieldSetFieldJSON): FieldSetEntry {\n // Leaf path (may carry inline `as(Shape)` casts).\n if (typeof raw === 'string') {\n return {path: FieldSet.walkPathWithCasts(shape, raw)};\n }\n // Computed projection — carries `value`.\n if ('value' in raw && (raw as FieldSetComputedJSON).value !== undefined) {\n const computed = raw as FieldSetComputedJSON;\n const {ir, refs} = decodeValueExpr(computed.value, shape);\n const entry: FieldSetEntry = {\n path: new PropertyPath(shape, []),\n expressionNode: new ExpressionNode(ir, refs),\n };\n if (computed.as) entry.alias = computed.as;\n if (computed.customKey) entry.customKey = computed.customKey;\n return entry;\n }\n // Relation-keyed: the single non-option key is the relation path.\n const rel = raw as FieldSetRelationJSON;\n const pathKey = Object.keys(rel).find((k) => !RELATION_OPTION_KEYS.has(k));\n if (!pathKey) {\n throw new Error(`FieldSet field has no relation path: ${JSON.stringify(raw)}`);\n }\n const spec = rel[pathKey];\n const path = FieldSet.walkPathWithCasts(shape, pathKey);\n const entry: FieldSetEntry = {path};\n const subFields = Array.isArray(spec) ? spec : spec.fields;\n const opts = Array.isArray(spec) ? ({} as FieldSetRelationOptionsJSON) : spec;\n if (opts.as) entry.alias = opts.as;\n if (opts.customKey) entry.customKey = opts.customKey;\n if (opts.aggregation) entry.aggregation = opts.aggregation as 'count';\n if (opts.where) {\n const idx = opts.whereIndex ?? path.segments.length - 1;\n const seg = path.segments[idx] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})?.valueShape?.id;\n const scopedShape = (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || shape;\n entry.scopedFilter = deserializeWherePath(scopedShape, opts.where);\n entry.scopedFilterIndex = idx;\n }\n // Nested-select pagination (G10).\n if (typeof opts.limit === 'number') entry.innerLimit = opts.limit;\n if (typeof opts.offset === 'number') entry.innerOffset = opts.offset;\n if (opts.orderBy && opts.orderBy.length > 0) {\n const nested = FieldSet.nestedShapeOf(path) ?? shape;\n entry.innerOrderBy = opts.orderBy.map((e) => {\n const label = Object.keys(e)[0];\n const ps = getPropertyShape(nested, label);\n return {propertyShapeId: ps?.id ?? label, direction: Object.values(e)[0]};\n });\n }\n if (subFields) {\n const nested = opts.shape\n ? FieldSet.resolveShape(opts.shape)\n : FieldSet.requireNestedShapeOf(path, shape);\n entry.subSelect = FieldSet.fromFields(nested, subFields);\n }\n return entry;\n }\n\n /**\n * The shape sub-fields of `path` are read against: its terminal segment's value shape, or\n * `shape` when that segment declares none. A declared value shape that does not resolve is\n * an error: reading the sub-fields against `shape` instead would resolve them on the wrong\n * shape (or fail with a message about the wrong property).\n */\n private static requireNestedShapeOf(path: PropertyPath, shape: NodeShapeData): NodeShapeData {\n const nested = FieldSet.nestedShapeOf(path);\n if (nested) return nested;\n const seg = path.segments[path.segments.length - 1] as PropertyShapeData | undefined;\n if (seg?.valueShape?.id) {\n const owner = path.segments.length > 1\n ? FieldSet.nestedShapeOf(new PropertyPath(path.rootShape, path.segments.slice(0, -1)))\n : path.rootShape;\n throw unresolvedValueShapeError(\n `Cannot resolve valueShape '${seg.valueShape.id}' for property '${seg.label}' in path '${path.toString()}'`,\n seg,\n owner,\n );\n }\n return shape;\n }\n\n /** The shape reached at the end of a relation path (its terminal segment's value shape). */\n private static nestedShapeOf(path: PropertyPath): NodeShapeData | undefined {\n const seg = path.segments[path.segments.length - 1] as PropertyShapeData | undefined;\n const valueShapeId = (seg as unknown as {valueShape?: {id: string}})?.valueShape?.id;\n return (valueShapeId && getQueryShapeClass(valueShapeId)?.shape) || undefined;\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Resolves any of the accepted shape input types to a NodeShapeData and optional ShapeClass.\n * Accepts: ShapeConstructor (class with .shape), NodeShapeData, or IRI string.\n */\n private static resolveShapeInput(shape: ShapeConstructor<any> | NodeShapeData | string): {nodeShape: NodeShapeData; shapeClass?: ShapeConstructor<any>} {\n // Inside a catalog the catalog's data is the authority for every IRI it holds, so an\n // authored class (or metadata) for one of them resolves to the catalog's shape — as\n // `resolveShape` does for the builders.\n const catalog = getActiveShapeCatalog();\n if (catalog !== undefined && typeof shape !== 'string') {\n const id = typeof shape === 'function' ? shape.shape?.id : shape?.id;\n const own = id ? catalog.get(id) : undefined;\n if (own) {\n const shapeClass = getQueryShapeClass(id!);\n return shapeClass ? {nodeShape: own, shapeClass} : {nodeShape: own};\n }\n }\n if (typeof shape === 'string') {\n const shapeClass = getQueryShapeClass(shape);\n if (shapeClass?.shape) {\n return {nodeShape: shapeClass.shape, shapeClass};\n }\n // No authored class: the metadata alone is enough here — the classless branch\n // below is already supported, it just was not reachable from an IRI.\n const nodeShape = getNodeShape(shape);\n if (!nodeShape) {\n throw unresolvedShapeError(`Cannot resolve shape for '${shape}'`, topLevelDetails(shape));\n }\n return {nodeShape};\n }\n // ShapeConstructor: has a static .shape property that is a NodeShapeData\n if ('shape' in shape && typeof shape.shape === 'object' && shape.shape !== null && 'id' in shape.shape) {\n return {nodeShape: (shape as ShapeConstructor<any>).shape, shapeClass: shape as ShapeConstructor<any>};\n }\n // NodeShapeData: has .id directly — try to look up its ShapeConstructor for full proxy support\n const nodeShape = shape as NodeShapeData;\n const shapeClass = nodeShape.id ? getQueryShapeClass(nodeShape.id) : undefined;\n return shapeClass\n ? {nodeShape, shapeClass}\n : {nodeShape};\n }\n\n /** @deprecated Use resolveShapeInput instead. Kept for fromJSON which only passes NodeShapeData|string. */\n private static resolveShape(shape: NodeShapeData | string): NodeShapeData {\n return FieldSet.resolveShapeInput(shape).nodeShape;\n }\n\n private static resolveInputs(\n shape: NodeShapeData,\n inputs: FieldSetInput[],\n ): FieldSetEntry[] {\n const entries: FieldSetEntry[] = [];\n for (const input of inputs) {\n if (typeof input === 'string') {\n entries.push({path: walkPropertyPath(shape, input)});\n } else if (input instanceof PropertyPath) {\n entries.push({path: input});\n } else if (input instanceof FieldSet) {\n entries.push(...(input.entries as FieldSetEntry[]));\n } else if (typeof input === 'object') {\n // Nested object form: { friends: ['name', 'hobby'] }\n for (const [key, value] of Object.entries(input)) {\n const basePath = walkPropertyPath(shape, key);\n if (value instanceof FieldSet) {\n // Merge nested FieldSet entries under this path\n for (const entry of value.entries as FieldSetEntry[]) {\n const combined = new PropertyPath(shape, [\n ...basePath.segments,\n ...entry.path.segments,\n ]);\n entries.push({path: combined, alias: entry.alias, scopedFilter: entry.scopedFilter});\n }\n } else if (Array.isArray(value)) {\n // Resolve nested string fields\n const basePropertyShape = basePath.terminal;\n if (!basePropertyShape?.valueShape) {\n throw new Error(\n `Property '${key}' has no valueShape; cannot resolve nested fields`,\n );\n }\n const nestedShapeClass = getQueryShapeClass(basePropertyShape.valueShape);\n if (!nestedShapeClass || !nestedShapeClass.shape) {\n throw unresolvedValueShapeError(\n `Cannot resolve valueShape '${basePropertyShape.valueShape.id}' for property '${key}'`,\n basePropertyShape,\n );\n }\n for (const nestedField of value) {\n const nestedPath = walkPropertyPath(nestedShapeClass.shape, nestedField);\n const combined = new PropertyPath(shape, [\n ...basePath.segments,\n ...nestedPath.segments,\n ]);\n entries.push({path: combined});\n }\n }\n }\n }\n }\n return entries;\n }\n\n /**\n * Trace fields using the full ProxiedPathBuilder proxy (createProxiedPathBuilder).\n * Handles nested paths, where conditions, aggregations, and sub-selects.\n */\n private static traceFieldsWithProxy(\n nodeShape: NodeShapeData,\n shapeClass: ShapeConstructor<any>,\n fn: (p: any) => any,\n ): FieldSetEntry[] {\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = fn(proxy);\n\n // Normalize result: could be a single value, array, or custom object\n if (Array.isArray(result)) {\n return result.map((item) => FieldSet.convertTraceResult(nodeShape, item));\n }\n if (isQueryBuilderObject(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single FieldSet sub-select (e.g. p.friends.select(f => [f.name]))\n if (result instanceof FieldSet && result.parentSegments !== undefined) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single SetSize (e.g. p.friends.size())\n if (isSetSize(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single BoundComponent (e.g. p.bestFriend.preloadFor(comp))\n if (isBoundComponent(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n // Single ExpressionNode (e.g. p.age.times(12))\n if (isExpressionNode(result)) {\n return [FieldSet.convertTraceResult(nodeShape, result)];\n }\n if (typeof result === 'object' && result !== null) {\n // Custom object form: {name: p.name, hobby: p.hobby}\n const entries: FieldSetEntry[] = [];\n for (const [key, value] of Object.entries(result)) {\n const entry = FieldSet.convertTraceResult(nodeShape, value);\n entry.customKey = key;\n entries.push(entry);\n }\n return entries;\n }\n return [];\n }\n\n /**\n * Convert a single proxy trace result (QueryBuilderObject, SetSize, or FieldSet sub-select)\n * into a FieldSetEntry.\n */\n private static convertTraceResult(rootShape: NodeShapeData, obj: any): FieldSetEntry {\n // SetSize → aggregation: 'count'\n if (isSetSize(obj)) {\n const segments = FieldSet.collectPropertySegments(obj.subject);\n return {\n path: new PropertyPath(rootShape, segments),\n aggregation: 'count',\n };\n }\n\n // FieldSet sub-select — use its entries directly (created by forSubSelect)\n if (obj instanceof FieldSet && obj.parentSegments !== undefined) {\n const subSelect = obj.entries.length > 0 ? obj : undefined;\n const entry: FieldSetEntry = {\n path: new PropertyPath(rootShape, obj.parentSegments),\n subSelect: subSelect as FieldSet | undefined,\n };\n // Carry an inline `.where()` from the parent traversal chain\n // (e.g. `p.friends.where(...).select(...)`).\n if (obj.parentWherePath) {\n entry.scopedFilter = obj.parentWherePath;\n entry.scopedFilterIndex = obj.parentWherePathIndex;\n }\n // Carry inner LIMIT/OFFSET/ORDER BY from `.limit()`/`.offset()`/`.orderBy()`.\n if (typeof obj.innerLimit === 'number') entry.innerLimit = obj.innerLimit;\n if (typeof obj.innerOffset === 'number') entry.innerOffset = obj.innerOffset;\n if (obj.innerOrderBy) entry.innerOrderBy = obj.innerOrderBy;\n return entry;\n }\n\n // BoundComponent → preload composition (e.g. p.bestFriend.preloadFor(component))\n // Extract the component's FieldSet and store it as preloadSubSelect.\n if (isBoundComponent(obj)) {\n const segments = FieldSet.collectPropertySegments(obj.source);\n const componentFieldSet = FieldSet.extractComponentFieldSet(obj.originalValue);\n return {\n path: new PropertyPath(rootShape, segments),\n preloadSubSelect: componentFieldSet,\n };\n }\n\n // ExpressionNode → computed expression (e.g. p.age.times(12))\n if (isExpressionNode(obj)) {\n return {\n path: new PropertyPath(rootShape, []),\n expressionNode: obj,\n };\n }\n\n // QueryBuilderObject → walk the chain to collect PropertyPath segments\n if (isQueryBuilderObject(obj)) {\n const segments = FieldSet.collectPropertySegments(obj);\n const entry: FieldSetEntry = {\n path: new PropertyPath(rootShape, segments),\n };\n // Walk from leaf to root to find wherePath on any object in the chain.\n // Track which segment it belongs to so desugarEntry attaches the filter correctly.\n let current: QueryBuilderObjectLike | undefined = obj;\n let leafDistance = 0;\n while (current) {\n if (current.wherePath) {\n entry.scopedFilter = current.wherePath as WherePath;\n entry.scopedFilterIndex = segments.length - 1 - leafDistance;\n break;\n }\n current = current.subject;\n leafDistance++;\n }\n return entry;\n }\n\n // Fallback: string label\n if (typeof obj === 'string') {\n return {path: walkPropertyPath(rootShape, obj)};\n }\n\n throw new Error(`Unknown trace result type: ${obj}`);\n }\n\n /**\n * Walk a QueryBuilderObject-like chain (via .subject) collecting PropertyShapeData segments\n * from leaf to root, then reverse to get root-to-leaf order.\n */\n static collectPropertySegments(obj: QueryBuilderObjectLike): PropertyShapeData[] {\n const segments: PropertyShapeData[] = [];\n let current: QueryBuilderObjectLike | undefined = obj;\n while (current) {\n if (current.property) {\n segments.unshift(current.property);\n }\n current = current.subject;\n }\n return segments;\n }\n\n // ---------------------------------------------------------------------------\n // Cast-aware path (de)serialization — carries `.as(Shape)` narrowing inline as\n // an `as(<ShapeLabel>)` path segment (documentation/dsl-json.md, backlog 002 G5).\n // ---------------------------------------------------------------------------\n\n private static shapeById(id: string): NodeShapeData | undefined {\n return getShapeClass(id)?.shape ?? getNodeShape(id);\n }\n\n private static shapeByLabel(label: string): NodeShapeData | undefined {\n // Inside a catalog every shape is data (core's built-ins aside), so scan its shapes;\n // the global registry keeps scanning authored classes.\n const matches = (shape?: NodeShapeData): shape is NodeShapeData =>\n !!shape && (shape.label === label || FieldSet.labelOfId(shape.id) === label);\n if (getActiveShapeCatalog() !== undefined) {\n for (const shape of getAllNodeShapes().values()) if (matches(shape)) return shape;\n return undefined;\n }\n for (const cls of getAllShapeClasses().values()) {\n const shape = (cls as unknown as {shape?: NodeShapeData}).shape;\n if (matches(shape)) return shape;\n }\n return undefined;\n }\n\n private static labelOfId(id: string): string {\n const i = id.lastIndexOf('/');\n return i >= 0 ? id.slice(i + 1) : id;\n }\n\n /**\n * Render a segment chain as a dotted label path, inserting `as(<ShapeLabel>)`\n * wherever a segment is not resolvable by label from the natural (walked) shape\n * — i.e. a `.as(Shape)` narrowing happened before it.\n */\n static pathToStringWithCasts(rootShape: NodeShapeData, segments: readonly PropertyShapeData[]): string {\n const parts: string[] = [];\n let current: NodeShapeData | undefined = rootShape;\n for (const seg of segments) {\n const label = FieldSet.labelOfId(seg.id);\n const natural = current ? getPropertyShape(current, label) : undefined;\n if (!natural || natural.id !== seg.id) {\n // A cast narrowed the context to the segment's owner shape.\n const ownerId = seg.id.slice(0, seg.id.lastIndexOf('/'));\n const owner = FieldSet.shapeById(ownerId);\n parts.push(`as(${owner?.label ?? FieldSet.labelOfId(ownerId)})`);\n current = owner ?? current;\n }\n parts.push(label);\n const vs = (seg as unknown as {valueShape?: {id: string}}).valueShape;\n current = vs ? FieldSet.shapeById(vs.id) ?? current : current;\n }\n return parts.join('.');\n }\n\n /** Inverse of {@link pathToStringWithCasts}: resolve a dotted path with `as(X)` casts. */\n static walkPathWithCasts(rootShape: NodeShapeData, path: string): PropertyPath {\n if (!path.includes('as(')) return walkPropertyPath(rootShape, path);\n const segments: PropertyShapeData[] = [];\n let current: NodeShapeData | undefined = rootShape;\n for (const token of path.split('.')) {\n const cast = /^as\\((.+)\\)$/.exec(token);\n if (cast) {\n current = FieldSet.shapeByLabel(cast[1]) ?? current;\n continue;\n }\n const ps = current ? getPropertyShape(current, token) : undefined;\n if (!ps) {\n throw new Error(\n `Property '${token}' not found on shape '${current?.label || current?.id}' while resolving path '${path}'`,\n );\n }\n segments.push(ps);\n const vs = (ps as unknown as {valueShape?: {id: string}}).valueShape;\n current = vs ? FieldSet.shapeById(vs.id) ?? current : current;\n }\n return new PropertyPath(rootShape, segments);\n }\n\n /**\n * Extract a FieldSet from a component-like object for preload composition.\n *\n * Supports multiple component interfaces:\n * - `.fields` as a FieldSet directly\n * - `.query` as a FieldSet, QueryBuilder (duck-typed via .fields()), or\n * Record<string, QueryBuilder> (e.g. `{person: PersonQuery}`)\n */\n static extractComponentFieldSet(component: any): FieldSet | undefined {\n // Prefer .fields if it's a FieldSet\n if (component.fields instanceof FieldSet) {\n return component.fields;\n }\n const query = component.query;\n if (query instanceof FieldSet) {\n return query;\n }\n // QueryBuilder duck-type — has .fields() method\n if (query && typeof query.fields === 'function') {\n return query.fields();\n }\n // Record form: { propName: QueryBuilder }\n if (typeof query === 'object') {\n for (const key in query) {\n const value = (query as Record<string, any>)[key];\n if (value && typeof value.fields === 'function') {\n return value.fields();\n }\n }\n }\n return undefined;\n }\n\n /**\n * Internal factory that bypasses the private constructor for use by static methods.\n */\n private static createInternal(shape: NodeShapeData, entries: FieldSetEntry[]): FieldSet {\n return new FieldSet(shape, entries);\n }\n\n /**\n * Create a FieldSet from raw entries. Used by QueryBuilder to merge preload entries.\n */\n static createFromEntries(shape: NodeShapeData, entries: FieldSetEntry[]): FieldSet {\n return new FieldSet(shape, entries);\n }\n\n /**\n * Extract FieldSetEntry[] from a sub-query's traceResponse.\n * Public alias for use by lightweight sub-select wrappers.\n */\n static extractSubSelectEntriesPublic(rootShape: NodeShapeData, traceResponse: any): FieldSetEntry[] {\n return FieldSet.extractSubSelectEntries(rootShape, traceResponse);\n }\n\n /**\n * Extract FieldSetEntry[] from a sub-select's traceResponse.\n * The traceResponse is the result of calling the sub-query callback with a proxy,\n * containing QueryBuilderObjects, arrays, custom objects, etc.\n */\n private static extractSubSelectEntries(rootShape: NodeShapeData, traceResponse: any): FieldSetEntry[] {\n if (Array.isArray(traceResponse)) {\n return traceResponse\n .filter((item) => item !== null && item !== undefined)\n .map((item) => FieldSet.convertTraceResult(rootShape, item));\n }\n if (isQueryBuilderObject(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single FieldSet sub-select — convert directly\n if (traceResponse instanceof FieldSet && traceResponse.parentSegments !== undefined) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single SetSize\n if (isSetSize(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n // Single ExpressionNode\n if (isExpressionNode(traceResponse)) {\n return [FieldSet.convertTraceResult(rootShape, traceResponse)];\n }\n if (typeof traceResponse === 'object' && traceResponse !== null) {\n // Custom object form: {name: p.name, hobby: p.hobby}\n const entries: FieldSetEntry[] = [];\n for (const [key, value] of Object.entries(traceResponse)) {\n if (value !== null && value !== undefined) {\n const entry = FieldSet.convertTraceResult(rootShape, value);\n entry.customKey = key;\n entries.push(entry);\n }\n }\n return entries;\n }\n return [];\n }\n\n}\n"]}
|
|
@@ -16,6 +16,7 @@ import { isExpressionNode } from '../expressions/ExpressionNode.js';
|
|
|
16
16
|
import { createProxiedPathBuilder } from './ProxiedPathBuilder.js';
|
|
17
17
|
import { asContextRef } from './QueryContext.js';
|
|
18
18
|
import { assertValid, undeclaredPropertyMessage, } from '../shapes/validation.js';
|
|
19
|
+
import { topLevelDetails, unresolvedShapeError, unresolvedValueShapeError } from '../utils/unresolvedShape.js';
|
|
19
20
|
export class MutationQueryFactory extends QueryFactory {
|
|
20
21
|
/**
|
|
21
22
|
* Normalize raw create/update data into a {@link NodeDescriptionValue} — the
|
|
@@ -50,7 +51,7 @@ export class MutationQueryFactory extends QueryFactory {
|
|
|
50
51
|
// fail here with "Shape class not found".
|
|
51
52
|
const shapeClass = shape.id ? resolveShapeConstructor(shape.id) : undefined;
|
|
52
53
|
if (!shapeClass) {
|
|
53
|
-
throw
|
|
54
|
+
throw unresolvedShapeError(`Shape class not found for ${shape.id || 'unknown'}`, topLevelDetails(shape.id || ''));
|
|
54
55
|
}
|
|
55
56
|
const proxy = createProxiedPathBuilder(shapeClass);
|
|
56
57
|
const result = obj(proxy);
|
|
@@ -215,7 +216,7 @@ export class MutationQueryFactory extends QueryFactory {
|
|
|
215
216
|
const shapeClass = resolveShapeConstructor(propShape.valueShape);
|
|
216
217
|
valueShape = (shapeClass === null || shapeClass === void 0 ? void 0 : shapeClass.shape) || null;
|
|
217
218
|
if (!valueShape) {
|
|
218
|
-
throw
|
|
219
|
+
throw unresolvedValueShapeError(`Shape class not found for ${propShape.valueShape.id}`, propShape);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
//pass the value shape of the property as the node shape of this value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationQuery.js","sourceRoot":"","sources":["../../../src/queries/MutationQuery.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAKL,YAAY,GAMb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAC,YAAY,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAC,gBAAgB,EAAiB,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAC,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,yBAAyB,GAE1B,MAAM,yBAAyB,CAAC;AAgBjC,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IACpD;;;;;;;;;OASG;IACH,QAAQ,CACN,KAAoB,EACpB,IAAa,EACb,UAA2B,EAAE;QAE7B,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,mFAAmF;IACnF,iBAAiB,CAAC,GAAsB;QACtC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAES,mBAAmB,CAC3B,GAAG,EACH,KAAoB,EACpB,EAAC,eAAe,GAAG,KAAK,EAAE,QAAQ,KAAqB,EAAE;QAEzD,IAAI,QAAQ,CAAC;QACb,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtE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ACN,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAES,4BAA4B,CACpC,CAAwB;QAExB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,EAAC,EAAE,EAAE,CAAC,EAAC,CAAC;QACjB,CAAC;aAAM,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,GAAiB;QAC9C,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC;IACtB,CAAC;CACF","sourcesContent":["import {\n type LiteralUpdateValue,\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n QueryFactory,\n type SetModification,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n type UpdateNodePropertyValue,\n type UpdatePartial,\n} from './QueryFactory.js';\nimport {getPropertyShapes} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {isSubShapeOf, resolveShapeConstructor} from '../utils/ShapeClass.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {asContextRef} from './QueryContext.js';\nimport {\n assertValid,\n undeclaredPropertyMessage,\n type ValidationMode,\n} from '../shapes/validation.js';\n\nexport type NodeId = {id: string} | string;\n\n/** Options for {@link MutationQueryFactory.describe}. */\nexport interface DescribeOptions {\n /** Create data may carry a top-level `id`; update data may not. */\n allowTopLevelId?: boolean;\n /**\n * Validate the data against the shape before normalizing, throwing a\n * `ShapeValidationError` with every violation. Omit to skip validation\n * (normalization-only, e.g. when the caller has already validated).\n */\n validate?: ValidationMode;\n}\n\nexport class MutationQueryFactory extends QueryFactory {\n /**\n * Normalize raw create/update data into a {@link NodeDescriptionValue} — the\n * IR-free step shared by `toJSON()` and `lower()`. Kept on this base (which\n * imports no IR) so the builders can normalize for serialization without\n * pulling the canonical-IR pipeline.\n *\n * This is also the single validation gate: pass `validate` and the resolved\n * data is checked against the shape first, so `toJSON()`, `lower()` and\n * `exec()` reject exactly the same input. See `shapes/validation`.\n */\n describe(\n shape: NodeShapeData,\n data: unknown,\n options: DescribeOptions = {},\n ): NodeDescriptionValue {\n return this.convertUpdateObject(data as any, shape, options);\n }\n\n /** Normalize delete ids (strings / `{id}`) to `NodeReferenceValue[]` (IR-free). */\n normalizeNodeRefs(ids: NodeId[] | NodeId): NodeReferenceValue[] {\n return this.convertNodeReferences(ids);\n }\n\n protected convertUpdateObject(\n obj,\n shape: NodeShapeData,\n {allowTopLevelId = false, validate}: DescribeOptions = {},\n ): NodeDescriptionValue {\n let resolved;\n if (typeof obj === 'object' && !(obj instanceof Date) && obj !== null) {\n if (!allowTopLevelId && 'id' in obj) {\n throw new Error(\n 'You cannot use id in the top level of an update object',\n );\n }\n resolved = obj;\n } else if (typeof obj === 'function') {\n // A shape authored in a project exists only as metadata, so it has no authored\n // class. `getOrCreateShapeAdapter` derives a constructor from that metadata --\n // which is the documented return leg of the shape round trip (see\n // registerRuntimeShape). Resolving with `getShapeClass` alone made every runtime shape\n // fail here with \"Shape class not found\".\n const shapeClass = shape.id ? resolveShapeConstructor(shape.id) : undefined;\n if (!shapeClass) {\n throw new Error(`Shape class not found for ${shape.id || 'unknown'}`);\n }\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = obj(proxy);\n if (typeof result !== 'object' || result === null) {\n throw new Error('Update function must return an object');\n }\n // Validate what the callback produced, not the callback itself.\n resolved = result;\n } else {\n throw new Error('Invalid update object');\n }\n if (validate) {\n assertValid(shape, resolved, {mode: validate});\n }\n return this.convertNodeDescription(resolved, shape);\n }\n\n protected isSetModification(obj, shape) {\n let hasAdd = obj.add;\n let hasRemove = obj.remove;\n let numKeysExpected = (hasAdd ? 1 : 0) + (hasRemove ? 1 : 0);\n let numKeys = Object.getOwnPropertyNames(obj).length;\n // A set modification is ONLY add/remove keys. Mixing them with other keys\n // (e.g. {add:[…], name:'x'}) must NOT be silently treated as a set mod —\n // that dropped the sibling fields. Require an exact key-count match for\n // both add and remove (mirrors isSetModificationValue).\n return (hasAdd || hasRemove) && numKeysExpected === numKeys;\n }\n\n protected convertSetModification(\n obj: SetModification<any>,\n shape: PropertyShapeData,\n ): SetModificationValue {\n if (!obj.add && !obj.remove) {\n throw new Error('Set modification should have either add or remove key');\n }\n const res: SetModificationValue = {};\n if (obj.add) {\n res.$add = this.convertSetAddValue(obj.add, shape);\n }\n if (obj.remove) {\n res.$remove = this.convertSetRemoveValue(obj.remove, shape);\n }\n return res;\n }\n\n protected convertSetRemoveValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): NodeReferenceValue[] {\n //the user can either pass an array of node references or a single node reference\n //either way we should return an array of node reference values\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertSingleRemoveValue(o, shape));\n } else {\n return [this.convertSingleRemoveValue(obj, shape)];\n }\n }\n\n protected convertSetAddValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): UpdatePartial[] {\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertUpdateValue(o, shape) as UpdatePartial);\n } else {\n return [this.convertUpdateValue(obj, shape) as UpdatePartial];\n }\n }\n\n protected convertSingleRemoveValue(\n value,\n shape: PropertyShapeData,\n ): NodeReferenceValue {\n const ctx = asContextRef(value);\n if (ctx) {\n return ctx as unknown as NodeReferenceValue;\n }\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n throw new Error(\n `Invalid value for ${shape.label}.$remove. Expected an object with an id as key: {id:string}`,\n );\n }\n }\n\n protected convertNodeDescription(\n inputObj: Record<string, unknown>,\n shape: NodeShapeData,\n ): NodeDescriptionValue {\n // Shallow-copy so we never mutate the caller's object\n const obj = {...inputObj};\n const props = getPropertyShapes(shape, true);\n const fields: UpdateNodePropertyValue[] = [];\n let id;\n if ('__id' in obj) {\n //if the object has a __id key, then we should use that in the result\n id = obj.__id.toString();\n //but we should not include it in the fields\n delete obj.__id;\n } else if ('id' in obj) {\n //if the object has an id key alongside other data properties,\n //treat it as a nested create with a predefined ID\n id = String(obj.id);\n delete obj.id;\n }\n for (var key in obj) {\n let propShape = props.find((p) => p.label === key);\n if (!propShape) {\n // Also reported as an `sh:ClosedConstraintComponent` violation when the\n // caller validates; kept here because normalization cannot build a field\n // without a property shape (`describe()` may run without validation).\n throw Error(undeclaredPropertyMessage(key, shape));\n } else {\n fields.push(this.createNodePropertyValue(obj[key], propShape));\n }\n }\n const res: NodeDescriptionValue = {\n fields,\n shape,\n };\n if (id) {\n res.__id = id;\n }\n\n return res;\n }\n\n protected createNodePropertyValue(\n value,\n propShape: PropertyShapeData,\n ): UpdateNodePropertyValue {\n return {\n prop: propShape,\n val: this.convertUpdateValue(value, propShape),\n } as UpdateNodePropertyValue;\n }\n\n protected convertUpdateValue(\n value,\n propShape?: PropertyShapeData,\n allowArrays: boolean = true,\n ): PropUpdateValue {\n // ExpressionNode → pass through as-is (will be converted to IRExpression by IRMutation)\n if (isExpressionNode(value)) {\n return value as unknown as PropUpdateValue;\n }\n\n // Query-context reference → preserve the live ref (do NOT collapse to {id},\n // which would read an unresolved `.id` as undefined). Handles both an unset\n // PendingQueryContext and a resolved context shape; both serialize as a {@ctx}\n // marker and are resolved — or throw — at lowering time.\n {\n const ctx = asContextRef(value);\n if (ctx) return ctx as unknown as PropUpdateValue;\n }\n\n //single value which will\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value as LiteralUpdateValue;\n }\n\n //if multiple items are given as value of this prop\n if (Array.isArray(value)) {\n if (!allowArrays) {\n throw new Error('Nested arrays are not allowed as values of keys');\n }\n //then convert each value, but disallow nested arrays moving forward\n return value.map((o) => {\n return this.convertUpdateValue(o, propShape, false);\n }) as SinglePropertyUpdateValue[];\n } else if (typeof value === 'undefined') {\n return value;\n } else if (value === null) {\n //unsetting a value with null is also possible. But we pass it as undefined in the query object\n return undefined;\n } else if (typeof value === 'object') {\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n let valueShape: NodeShapeData = null;\n if (propShape.valueShape) {\n const shapeClass = resolveShapeConstructor(propShape.valueShape);\n valueShape = shapeClass?.shape || null;\n if (!valueShape) {\n throw new Error(\n `Shape class not found for ${propShape.valueShape.id}`,\n );\n }\n }\n //pass the value shape of the property as the node shape of this value\n if (!propShape.valueShape) {\n //It's possible to define the shape of the value in the value itself for properties who do not define the shape in their objectProperty\n if (value.shape) {\n if (!value.shape.shape) {\n throw new Error(\n `The value of property \"shape\" is invalid and should be a class that extends Shape.`,\n );\n }\n valueShape = (value.shape as typeof Shape).shape;\n } else {\n //TODO: not sure if this should be an error. Does every @linkedObject need to define the shape of the values?\n // If not, then how do we continue? because currently we use the value shape to look up further property shapes\n throw new Error(\n `Cannot update properties with plain objects if the shape of the values is not known. Make sure get/set ${propShape.parentNodeShape.label}.${propShape.label} defines the 'shape' key in its @objectProperty decorator.`,\n );\n }\n }\n //never keep a shape key in the value object\n if (value.shape) {\n // A value may name its own concrete shape when that is the declared value\n // shape or a subclass of it (a Company under an Organization-typed property).\n const ownShape = (value.shape as typeof Shape).shape;\n if (ownShape && isSubShapeOf(ownShape, valueShape)) {\n valueShape = ownShape;\n } else if (!ownShape || ownShape.id !== valueShape.id) {\n throw new Error(\n `The 'shape' key of a value of ${propShape.label} must be its declared shape ${valueShape.label || valueShape.id} or a subclass of it, got ${ownShape?.label || ownShape?.id || 'an invalid shape'}.`,\n );\n }\n // Drop it from a copy, never from the caller's object: the same data\n // is lowered again after the mutation ran (LiveQueryStore derives the\n // mutation's effects from it), and without its `shape` key the value\n // can no longer be validated.\n const {shape: _shape, ...rest} = value;\n value = rest;\n }\n\n if (this.isSetModification(value, propShape)) {\n return this.convertSetModification(value, propShape);\n } else {\n return this.convertNodeDescription(value, valueShape);\n }\n }\n }\n throw new Error(`Unsupported update value type: ${typeof value}`);\n }\n\n protected isNodeReference(obj): obj is NodeReferenceValue {\n //check if obj is an object with only an id property\n //if additional data properties are present, it's a nested create with predefined ID\n return typeof obj === 'object' && obj !== null && 'id' in obj && Object.keys(obj).length === 1;\n }\n\n protected convertNodeReferences(\n input: NodeId[] | NodeId,\n ): NodeReferenceValue[] {\n if (Array.isArray(input)) {\n return input.map((o) => {\n return this.convertNodeReferenceOrString(o);\n });\n } else {\n return [this.convertNodeReferenceOrString(input)];\n }\n }\n\n protected convertNodeReferenceOrString(\n o: {id: string} | string,\n ): NodeReferenceValue {\n if (typeof o === 'string') {\n return {id: o};\n } else if (this.isNodeReference(o)) {\n return this.convertNodeReference(o);\n } else {\n throw new Error(`Invalid node reference: ${JSON.stringify(o)}`);\n }\n }\n\n protected convertNodeReference(obj: {id: string}): NodeReferenceValue {\n return {id: obj.id};\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MutationQuery.js","sourceRoot":"","sources":["../../../src/queries/MutationQuery.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAKL,YAAY,GAMb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAC,YAAY,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAC,gBAAgB,EAAiB,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAC,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,WAAW,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AoB,CAAC,GAAiB;QAC9C,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC;IACtB,CAAC;CACF","sourcesContent":["import {\n type LiteralUpdateValue,\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n QueryFactory,\n type SetModification,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n type UpdateNodePropertyValue,\n type UpdatePartial,\n} from './QueryFactory.js';\nimport {getPropertyShapes} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {isSubShapeOf, resolveShapeConstructor} from '../utils/ShapeClass.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {asContextRef} from './QueryContext.js';\nimport {\n assertValid,\n undeclaredPropertyMessage,\n type ValidationMode,\n} from '../shapes/validation.js';\nimport {topLevelDetails, unresolvedShapeError, unresolvedValueShapeError} from '../utils/unresolvedShape.js';\n\nexport type NodeId = {id: string} | string;\n\n/** Options for {@link MutationQueryFactory.describe}. */\nexport interface DescribeOptions {\n /** Create data may carry a top-level `id`; update data may not. */\n allowTopLevelId?: boolean;\n /**\n * Validate the data against the shape before normalizing, throwing a\n * `ShapeValidationError` with every violation. Omit to skip validation\n * (normalization-only, e.g. when the caller has already validated).\n */\n validate?: ValidationMode;\n}\n\nexport class MutationQueryFactory extends QueryFactory {\n /**\n * Normalize raw create/update data into a {@link NodeDescriptionValue} — the\n * IR-free step shared by `toJSON()` and `lower()`. Kept on this base (which\n * imports no IR) so the builders can normalize for serialization without\n * pulling the canonical-IR pipeline.\n *\n * This is also the single validation gate: pass `validate` and the resolved\n * data is checked against the shape first, so `toJSON()`, `lower()` and\n * `exec()` reject exactly the same input. See `shapes/validation`.\n */\n describe(\n shape: NodeShapeData,\n data: unknown,\n options: DescribeOptions = {},\n ): NodeDescriptionValue {\n return this.convertUpdateObject(data as any, shape, options);\n }\n\n /** Normalize delete ids (strings / `{id}`) to `NodeReferenceValue[]` (IR-free). */\n normalizeNodeRefs(ids: NodeId[] | NodeId): NodeReferenceValue[] {\n return this.convertNodeReferences(ids);\n }\n\n protected convertUpdateObject(\n obj,\n shape: NodeShapeData,\n {allowTopLevelId = false, validate}: DescribeOptions = {},\n ): NodeDescriptionValue {\n let resolved;\n if (typeof obj === 'object' && !(obj instanceof Date) && obj !== null) {\n if (!allowTopLevelId && 'id' in obj) {\n throw new Error(\n 'You cannot use id in the top level of an update object',\n );\n }\n resolved = obj;\n } else if (typeof obj === 'function') {\n // A shape authored in a project exists only as metadata, so it has no authored\n // class. `getOrCreateShapeAdapter` derives a constructor from that metadata --\n // which is the documented return leg of the shape round trip (see\n // registerRuntimeShape). Resolving with `getShapeClass` alone made every runtime shape\n // fail here with \"Shape class not found\".\n const shapeClass = shape.id ? resolveShapeConstructor(shape.id) : undefined;\n if (!shapeClass) {\n throw unresolvedShapeError(\n `Shape class not found for ${shape.id || 'unknown'}`,\n topLevelDetails(shape.id || ''),\n );\n }\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = obj(proxy);\n if (typeof result !== 'object' || result === null) {\n throw new Error('Update function must return an object');\n }\n // Validate what the callback produced, not the callback itself.\n resolved = result;\n } else {\n throw new Error('Invalid update object');\n }\n if (validate) {\n assertValid(shape, resolved, {mode: validate});\n }\n return this.convertNodeDescription(resolved, shape);\n }\n\n protected isSetModification(obj, shape) {\n let hasAdd = obj.add;\n let hasRemove = obj.remove;\n let numKeysExpected = (hasAdd ? 1 : 0) + (hasRemove ? 1 : 0);\n let numKeys = Object.getOwnPropertyNames(obj).length;\n // A set modification is ONLY add/remove keys. Mixing them with other keys\n // (e.g. {add:[…], name:'x'}) must NOT be silently treated as a set mod —\n // that dropped the sibling fields. Require an exact key-count match for\n // both add and remove (mirrors isSetModificationValue).\n return (hasAdd || hasRemove) && numKeysExpected === numKeys;\n }\n\n protected convertSetModification(\n obj: SetModification<any>,\n shape: PropertyShapeData,\n ): SetModificationValue {\n if (!obj.add && !obj.remove) {\n throw new Error('Set modification should have either add or remove key');\n }\n const res: SetModificationValue = {};\n if (obj.add) {\n res.$add = this.convertSetAddValue(obj.add, shape);\n }\n if (obj.remove) {\n res.$remove = this.convertSetRemoveValue(obj.remove, shape);\n }\n return res;\n }\n\n protected convertSetRemoveValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): NodeReferenceValue[] {\n //the user can either pass an array of node references or a single node reference\n //either way we should return an array of node reference values\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertSingleRemoveValue(o, shape));\n } else {\n return [this.convertSingleRemoveValue(obj, shape)];\n }\n }\n\n protected convertSetAddValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): UpdatePartial[] {\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertUpdateValue(o, shape) as UpdatePartial);\n } else {\n return [this.convertUpdateValue(obj, shape) as UpdatePartial];\n }\n }\n\n protected convertSingleRemoveValue(\n value,\n shape: PropertyShapeData,\n ): NodeReferenceValue {\n const ctx = asContextRef(value);\n if (ctx) {\n return ctx as unknown as NodeReferenceValue;\n }\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n throw new Error(\n `Invalid value for ${shape.label}.$remove. Expected an object with an id as key: {id:string}`,\n );\n }\n }\n\n protected convertNodeDescription(\n inputObj: Record<string, unknown>,\n shape: NodeShapeData,\n ): NodeDescriptionValue {\n // Shallow-copy so we never mutate the caller's object\n const obj = {...inputObj};\n const props = getPropertyShapes(shape, true);\n const fields: UpdateNodePropertyValue[] = [];\n let id;\n if ('__id' in obj) {\n //if the object has a __id key, then we should use that in the result\n id = obj.__id.toString();\n //but we should not include it in the fields\n delete obj.__id;\n } else if ('id' in obj) {\n //if the object has an id key alongside other data properties,\n //treat it as a nested create with a predefined ID\n id = String(obj.id);\n delete obj.id;\n }\n for (var key in obj) {\n let propShape = props.find((p) => p.label === key);\n if (!propShape) {\n // Also reported as an `sh:ClosedConstraintComponent` violation when the\n // caller validates; kept here because normalization cannot build a field\n // without a property shape (`describe()` may run without validation).\n throw Error(undeclaredPropertyMessage(key, shape));\n } else {\n fields.push(this.createNodePropertyValue(obj[key], propShape));\n }\n }\n const res: NodeDescriptionValue = {\n fields,\n shape,\n };\n if (id) {\n res.__id = id;\n }\n\n return res;\n }\n\n protected createNodePropertyValue(\n value,\n propShape: PropertyShapeData,\n ): UpdateNodePropertyValue {\n return {\n prop: propShape,\n val: this.convertUpdateValue(value, propShape),\n } as UpdateNodePropertyValue;\n }\n\n protected convertUpdateValue(\n value,\n propShape?: PropertyShapeData,\n allowArrays: boolean = true,\n ): PropUpdateValue {\n // ExpressionNode → pass through as-is (will be converted to IRExpression by IRMutation)\n if (isExpressionNode(value)) {\n return value as unknown as PropUpdateValue;\n }\n\n // Query-context reference → preserve the live ref (do NOT collapse to {id},\n // which would read an unresolved `.id` as undefined). Handles both an unset\n // PendingQueryContext and a resolved context shape; both serialize as a {@ctx}\n // marker and are resolved — or throw — at lowering time.\n {\n const ctx = asContextRef(value);\n if (ctx) return ctx as unknown as PropUpdateValue;\n }\n\n //single value which will\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value as LiteralUpdateValue;\n }\n\n //if multiple items are given as value of this prop\n if (Array.isArray(value)) {\n if (!allowArrays) {\n throw new Error('Nested arrays are not allowed as values of keys');\n }\n //then convert each value, but disallow nested arrays moving forward\n return value.map((o) => {\n return this.convertUpdateValue(o, propShape, false);\n }) as SinglePropertyUpdateValue[];\n } else if (typeof value === 'undefined') {\n return value;\n } else if (value === null) {\n //unsetting a value with null is also possible. But we pass it as undefined in the query object\n return undefined;\n } else if (typeof value === 'object') {\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n let valueShape: NodeShapeData = null;\n if (propShape.valueShape) {\n const shapeClass = resolveShapeConstructor(propShape.valueShape);\n valueShape = shapeClass?.shape || null;\n if (!valueShape) {\n throw unresolvedValueShapeError(\n `Shape class not found for ${propShape.valueShape.id}`,\n propShape,\n );\n }\n }\n //pass the value shape of the property as the node shape of this value\n if (!propShape.valueShape) {\n //It's possible to define the shape of the value in the value itself for properties who do not define the shape in their objectProperty\n if (value.shape) {\n if (!value.shape.shape) {\n throw new Error(\n `The value of property \"shape\" is invalid and should be a class that extends Shape.`,\n );\n }\n valueShape = (value.shape as typeof Shape).shape;\n } else {\n //TODO: not sure if this should be an error. Does every @linkedObject need to define the shape of the values?\n // If not, then how do we continue? because currently we use the value shape to look up further property shapes\n throw new Error(\n `Cannot update properties with plain objects if the shape of the values is not known. Make sure get/set ${propShape.parentNodeShape.label}.${propShape.label} defines the 'shape' key in its @objectProperty decorator.`,\n );\n }\n }\n //never keep a shape key in the value object\n if (value.shape) {\n // A value may name its own concrete shape when that is the declared value\n // shape or a subclass of it (a Company under an Organization-typed property).\n const ownShape = (value.shape as typeof Shape).shape;\n if (ownShape && isSubShapeOf(ownShape, valueShape)) {\n valueShape = ownShape;\n } else if (!ownShape || ownShape.id !== valueShape.id) {\n throw new Error(\n `The 'shape' key of a value of ${propShape.label} must be its declared shape ${valueShape.label || valueShape.id} or a subclass of it, got ${ownShape?.label || ownShape?.id || 'an invalid shape'}.`,\n );\n }\n // Drop it from a copy, never from the caller's object: the same data\n // is lowered again after the mutation ran (LiveQueryStore derives the\n // mutation's effects from it), and without its `shape` key the value\n // can no longer be validated.\n const {shape: _shape, ...rest} = value;\n value = rest;\n }\n\n if (this.isSetModification(value, propShape)) {\n return this.convertSetModification(value, propShape);\n } else {\n return this.convertNodeDescription(value, valueShape);\n }\n }\n }\n throw new Error(`Unsupported update value type: ${typeof value}`);\n }\n\n protected isNodeReference(obj): obj is NodeReferenceValue {\n //check if obj is an object with only an id property\n //if additional data properties are present, it's a nested create with predefined ID\n return typeof obj === 'object' && obj !== null && 'id' in obj && Object.keys(obj).length === 1;\n }\n\n protected convertNodeReferences(\n input: NodeId[] | NodeId,\n ): NodeReferenceValue[] {\n if (Array.isArray(input)) {\n return input.map((o) => {\n return this.convertNodeReferenceOrString(o);\n });\n } else {\n return [this.convertNodeReferenceOrString(input)];\n }\n }\n\n protected convertNodeReferenceOrString(\n o: {id: string} | string,\n ): NodeReferenceValue {\n if (typeof o === 'string') {\n return {id: o};\n } else if (this.isNodeReference(o)) {\n return this.convertNodeReference(o);\n } else {\n throw new Error(`Invalid node reference: ${JSON.stringify(o)}`);\n }\n }\n\n protected convertNodeReference(obj: {id: string}): NodeReferenceValue {\n return {id: obj.id};\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getPropertyShape } from '../shapes/nodeShapeData.js';
|
|
2
2
|
import { getQueryShapeClass } from '../utils/ShapeClass.js';
|
|
3
|
+
import { unresolvedValueShapeError } from '../utils/unresolvedShape.js';
|
|
3
4
|
/**
|
|
4
5
|
* A value object representing a sequence of property traversals from a root shape.
|
|
5
6
|
*
|
|
@@ -68,7 +69,7 @@ export function walkPropertyPath(shape, path) {
|
|
|
68
69
|
}
|
|
69
70
|
const shapeClass = getQueryShapeClass(propertyShape.valueShape);
|
|
70
71
|
if (!shapeClass || !shapeClass.shape) {
|
|
71
|
-
throw
|
|
72
|
+
throw unresolvedValueShapeError(`Cannot resolve valueShape '${propertyShape.valueShape.id}' for property '${label}' in path '${path}'`, propertyShape, currentShape);
|
|
72
73
|
}
|
|
73
74
|
currentShape = shapeClass.shape;
|
|
74
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyPath.js","sourceRoot":"","sources":["../../../src/queries/PropertyPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyPath.js","sourceRoot":"","sources":["../../../src/queries/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,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import type {PropertyShapeData, NodeShapeData} from '../shapes/SHACL.js';\nimport {getPropertyShape} from '../shapes/nodeShapeData.js';\nimport {getQueryShapeClass} from '../utils/ShapeClass.js';\nimport {unresolvedValueShapeError} from '../utils/unresolvedShape.js';\n\n/**\n * A value object representing a sequence of property traversals from a root shape.\n *\n * Each segment is a PropertyShapeData representing one hop in the traversal.\n * For example, `friends.name` on PersonShape produces a PropertyPath with\n * two segments: [friendsPropertyShape, namePropertyShape].\n *\n * This is used by FieldSet and QueryBuilder to describe which properties\n * to select/filter, independent of proxy tracing.\n */\nexport class PropertyPath {\n constructor(\n readonly rootShape: NodeShapeData,\n readonly segments: readonly PropertyShapeData[],\n ) {}\n\n /** Append a property traversal hop, returning a new PropertyPath. */\n prop(property: PropertyShapeData): PropertyPath {\n return new PropertyPath(this.rootShape, [...this.segments, property]);\n }\n\n /** The terminal (leaf) property of this path. */\n get terminal(): PropertyShapeData | undefined {\n return this.segments[this.segments.length - 1];\n }\n\n /** The depth (number of hops) of this path. */\n get depth(): number {\n return this.segments.length;\n }\n\n /** String representation using property labels joined by dots. */\n toString(): string {\n return this.segments.map((s) => s.label).join('.');\n }\n\n /** Two PropertyPaths are equal if they have the same root shape and same segment sequence. */\n equals(other: PropertyPath): boolean {\n if (this.rootShape.id !== other.rootShape.id) return false;\n if (this.segments.length !== other.segments.length) return false;\n return this.segments.every((s, i) => s.id === other.segments[i].id);\n }\n}\n\n/**\n * Resolve a dot-separated property path string into a PropertyPath.\n *\n * Walks the shape's property shapes by label, following valueShape references\n * to traverse into nested shapes.\n *\n * Example: `walkPropertyPath(PersonShape, 'friends.name')` resolves\n * [friendsPropertyShape, namePropertyShape].\n *\n * @throws If any segment cannot be resolved.\n */\nexport function walkPropertyPath(shape: NodeShapeData, path: string): PropertyPath {\n const labels = path.split('.');\n const segments: PropertyShapeData[] = [];\n let currentShape = shape;\n\n for (const label of labels) {\n const propertyShape = getPropertyShape(currentShape, label);\n if (!propertyShape) {\n throw new Error(\n `Property '${label}' not found on shape '${currentShape.label || currentShape.id}' while resolving path '${path}'`,\n );\n }\n segments.push(propertyShape);\n\n // If there are more segments to resolve, follow the valueShape\n if (segments.length < labels.length) {\n if (!propertyShape.valueShape) {\n throw new Error(\n `Property '${label}' on shape '${currentShape.label || currentShape.id}' has no valueShape; cannot traverse further in path '${path}'`,\n );\n }\n const shapeClass = getQueryShapeClass(propertyShape.valueShape);\n if (!shapeClass || !shapeClass.shape) {\n throw unresolvedValueShapeError(\n `Cannot resolve valueShape '${propertyShape.valueShape.id}' for property '${label}' in path '${path}'`,\n propertyShape,\n currentShape,\n );\n }\n currentShape = shapeClass.shape;\n }\n }\n\n return new PropertyPath(shape, segments);\n}\n"]}
|
|
@@ -22,6 +22,7 @@ import { createProxiedPathBuilder } from './ProxiedPathBuilder.js';
|
|
|
22
22
|
import { serializeWherePath, serializeSortByPath, serializeRawMinusEntry, deserializeWherePath, deserializeSortByPath, deserializeRawMinusEntry, } from './QueryBuilderSerialization.js';
|
|
23
23
|
import { requireLiveQueryStore } from '../live/registry.js';
|
|
24
24
|
import { captureCatalog, getActiveShapeCatalog, withShapeCatalog } from '../utils/ShapeClass.js';
|
|
25
|
+
import { isLinkedError } from '../utils/linkedError.js';
|
|
25
26
|
/**
|
|
26
27
|
* An immutable, fluent query builder for select queries.
|
|
27
28
|
*
|
|
@@ -715,7 +716,7 @@ export class SelectBuilder {
|
|
|
715
716
|
// UnresolvedContextError when the dataset lowers the query. For SELECT this
|
|
716
717
|
// means "not ready" — return null (a reactive layer re-runs once it lands),
|
|
717
718
|
// mirroring the pending-subject behavior. Mutations still throw.
|
|
718
|
-
if (swallowUnresolvedContext && err
|
|
719
|
+
if (swallowUnresolvedContext && isLinkedError(err, UnresolvedContextError)) {
|
|
719
720
|
return null;
|
|
720
721
|
}
|
|
721
722
|
// The message names the query, which is what a human needs. `cause` keeps
|