@soda-gql/colocation-tools 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["projector: (result: AnySlicedExecutionResult) => TProjected","paths","type: \"success\" | \"error\" | \"empty\"","data: TData","extensions?: unknown","error: NormalizedError","generateErrorMapEntries","createErrorMaps","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","accessDataByPathSegments","current: unknown","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","current: unknown"],"sources":["../src/projection.ts","../src/create-projection.ts","../src/utils/map-values.ts","../src/projection-path-graph.ts","../src/sliced-execution-result.ts","../src/parse-direct-result.ts","../src/parse-execution-result.ts"],"sourcesContent":["import type { AnySlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n/** Shape of a single selection slice projection. */\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Projection regardless of projected type\nexport type AnyProjection = Projection<any>;\n\ndeclare const __PROJECTION_BRAND__: unique symbol;\n/**\n * Nominal type representing any slice selection regardless of schema specifics.\n * Encodes how individual slices map a concrete field path to a projection\n * function. Multiple selections allow slices to expose several derived values.\n */\nexport class Projection<TProjected> {\n declare readonly [__PROJECTION_BRAND__]: void;\n\n declare readonly $infer: { readonly output: TProjected };\n\n constructor(\n paths: Tuple<string>,\n public readonly projector: (result: AnySlicedExecutionResult) => TProjected,\n ) {\n this.paths = paths.map((path) => createProjectionPath(path));\n\n Object.defineProperty(this, \"$infer\", {\n get() {\n throw new Error(\"This property is only for type meta. Do not access this property directly.\");\n },\n });\n }\n\n public readonly paths: ProjectionPath[];\n}\n\nexport type ProjectionPath = {\n full: string;\n segments: Tuple<string>;\n};\n\nfunction createProjectionPath(path: string): ProjectionPath {\n const segments = path.split(\".\");\n if (path === \"$\" || segments.length <= 1) {\n throw new Error(\"Field path must not be only $ or empty\");\n }\n\n return {\n full: path,\n segments: segments.slice(1) as Tuple<string>,\n };\n}\n\nexport type InferExecutionResultProjection<TProjection extends AnyProjection> = ReturnType<TProjection[\"projector\"]>;\n","import type { AnyFields, Fragment, GqlElementAttachment } from \"@soda-gql/core\";\nimport { Projection } from \"./projection\";\nimport type { SlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { AvailableFieldPathOf } from \"./types/field-path\";\nimport type { InferPathsOutput } from \"./types/output-path\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Fragment regardless of type parameters\ntype AnyFragment = Fragment<string, any, any, any>;\n\n/** Get TFields from Fragment via spread's return type. */\ntype FragmentFields<TFragment extends AnyFragment> = ReturnType<TFragment[\"spread\"]>;\n\n/**\n * Options for creating a projection from a Fragment.\n */\nexport type CreateProjectionOptions<\n TFields extends AnyFields,\n TOutput extends object,\n TPaths extends Tuple<AvailableFieldPathOf<TFields>>,\n TProjected,\n> = {\n /**\n * Field paths to extract from the execution result.\n * Each path starts with \"$.\" and follows the field selection structure.\n * Paths are type-checked against the Fragment's field structure.\n *\n * @example\n * ```typescript\n * paths: [\"$.user.id\", \"$.user.name\"]\n * ```\n */\n paths: TPaths;\n\n /**\n * Handler function to transform the sliced execution result.\n * Receives a SlicedExecutionResult with types inferred from the specified paths.\n * Handles all cases: success, error, and empty.\n *\n * @example\n * ```typescript\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple of types from paths\n * return { error: null, data: { id, name } };\n * }\n * ```\n */\n handle: (result: SlicedExecutionResult<InferPathsOutput<TOutput, TPaths>>) => TProjected;\n};\n\n/**\n * Creates a type-safe projection from a Fragment.\n *\n * The projection extracts and transforms data from GraphQL execution results,\n * with full type inference from the Fragment's field structure and output type.\n *\n * - Paths are validated against Fragment's TFields via `ReturnType<Fragment[\"spread\"]>`\n * - Handler receives types inferred from the specified paths\n *\n * @param _fragment - The Fragment to infer types from (used for type inference only)\n * @param options - Projection options including paths and handle function\n * @returns A Projection that can be used with createExecutionResultParser\n *\n * @example\n * ```typescript\n * const userFragment = gql(({ fragment }) =>\n * fragment.Query({\n * variables: { ... },\n * fields: ({ f, $ }) => ({\n * ...f.user({ id: $.userId })(({ f }) => ({ ...f.id(), ...f.name() })),\n * }),\n * })\n * );\n *\n * const userProjection = createProjection(userFragment, {\n * paths: [\"$.user.id\", \"$.user.name\"],\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple: [string, string]\n * return { error: null, data: { id, name } };\n * },\n * });\n * ```\n */\nexport const createProjection = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<TFragment>>>,\n TProjected,\n>(\n _fragment: TFragment,\n options: CreateProjectionOptions<FragmentFields<TFragment>, TFragment[\"$infer\"][\"output\"], TPaths, TProjected>,\n): Projection<TProjected> => {\n return new Projection(options.paths, options.handle);\n};\n\n/**\n * Creates a projection attachment for use with Fragment.attach().\n *\n * @example\n * ```typescript\n * const fragment = gql(({ fragment }) =>\n * fragment.Query({\n * fields: ({ f }) => ({ ...f.user()(({ f }) => ({ ...f.id() })) }),\n * })\n * ).attach(createProjectionAttachment({\n * paths: [\"$.user.id\"],\n * handle: (result) => result.isSuccess() ? result.unwrap()[0] : null,\n * }));\n * ```\n */\nexport const createProjectionAttachment = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<NoInfer<TFragment>>>>,\n TProjected,\n>(\n options: CreateProjectionOptions<\n FragmentFields<NoInfer<TFragment>>,\n NoInfer<TFragment>[\"$infer\"][\"output\"],\n TPaths,\n TProjected\n >,\n): GqlElementAttachment<TFragment, \"projection\", Projection<TProjected>> => {\n return {\n name: \"projection\",\n createValue: (fragment) => createProjection(fragment, options),\n };\n};\n","type ArgEntries<T extends object> = { [K in keyof T]-?: [value: T[K], key: K] }[keyof T];\ntype Entries<T extends object> = { [K in keyof T]: [key: K, value: T[K]] }[keyof T];\n\nexport function mapValues<TObject extends object, TMappedValue>(\n obj: TObject,\n fn: (...args: ArgEntries<TObject>) => TMappedValue,\n): {\n [K in keyof TObject]: TMappedValue;\n} {\n return Object.fromEntries((Object.entries(obj) as Entries<TObject>[]).map(([key, value]) => [key, fn(value, key)])) as {\n [K in keyof TObject]: TMappedValue;\n };\n}\n","import type { AnyProjection } from \"./projection\";\nimport { mapValues } from \"./utils/map-values\";\n\n/**\n * Node in the projection path graph tree.\n * Used for mapping GraphQL errors and data to their corresponding slices.\n */\nexport type ProjectionPathGraphNode = {\n readonly matches: { label: string; path: string; exact: boolean }[];\n readonly children: { readonly [segment: string]: ProjectionPathGraphNode };\n};\n\n/**\n * Payload from a slice that contains projection.\n */\nexport type AnySlicePayload = {\n readonly projection: AnyProjection;\n};\n\nexport type AnySlicePayloads = Record<string, AnySlicePayload>;\n\ntype ExecutionResultProjectionPathGraphIntermediate = {\n [segment: string]: { label: string; raw: string; segments: string[] }[];\n};\n\nexport function createPathGraph(paths: ExecutionResultProjectionPathGraphIntermediate[string]): ProjectionPathGraphNode {\n const intermediate = paths.reduce(\n (acc: ExecutionResultProjectionPathGraphIntermediate, { label, raw, segments: [segment, ...segments] }) => {\n if (segment) {\n (acc[segment] || (acc[segment] = [])).push({ label, raw, segments });\n }\n return acc;\n },\n {},\n );\n\n return {\n matches: paths.map(({ label, raw, segments }) => ({ label, path: raw, exact: segments.length === 0 })),\n children: mapValues(intermediate, (paths) => createPathGraph(paths)),\n } satisfies ProjectionPathGraphNode;\n}\n\n/**\n * Creates a projection path graph from slice entries with field prefixing.\n * Each slice's paths are prefixed with the slice label for disambiguation.\n */\nexport function createPathGraphFromSliceEntries(fragments: AnySlicePayloads) {\n const paths = Object.entries(fragments).flatMap(([label, slice]) =>\n Array.from(\n new Map(\n slice.projection.paths.map(({ full: raw, segments }) => {\n const [first, ...rest] = segments;\n return [raw, { label, raw, segments: [`${label}_${first}`, ...rest] }];\n }),\n ).values(),\n ),\n );\n\n return createPathGraph(paths);\n}\n","/** Result-like wrapper types returned from slice projections. */\n\nimport type { NormalizedError } from \"./types\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any SlicedExecutionResult regardless of data type\nexport type AnySlicedExecutionResult = SlicedExecutionResult<any>;\n\n/**\n * Internal discriminated union describing the Result-like wrapper exposed to\n * slice selection callbacks.\n */\nexport type AnySlicedExecutionResultRecord = {\n [path: string]: AnySlicedExecutionResult;\n};\n\nexport type SafeUnwrapResult<TTransformed, TError> =\n | {\n data?: never;\n error?: never;\n }\n | {\n data: TTransformed;\n error?: never;\n }\n | {\n data?: never;\n error: TError;\n };\n\n/** Utility signature returned by the safe unwrap helper. */\ntype SlicedExecutionResultCommon<TData, TError> = {\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed): SafeUnwrapResult<TTransformed, TError>;\n};\n\n/** Public union used by selection callbacks to inspect data, empty, or error states. */\nexport type SlicedExecutionResult<TData> =\n | SlicedExecutionResultEmpty<TData>\n | SlicedExecutionResultSuccess<TData>\n | SlicedExecutionResultError<TData>;\n\n/** Runtime guard interface shared by all slice result variants. */\nclass SlicedExecutionResultGuards<TData> {\n isSuccess(): this is SlicedExecutionResultSuccess<TData> {\n return this.type === \"success\";\n }\n isError(): this is SlicedExecutionResultError<TData> {\n return this.type === \"error\";\n }\n isEmpty(): this is SlicedExecutionResultEmpty<TData> {\n return this.type === \"empty\";\n }\n\n constructor(private readonly type: \"success\" | \"error\" | \"empty\") {}\n}\n\n/** Variant representing an empty payload (no data, no error). */\nexport class SlicedExecutionResultEmpty<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor() {\n super(\"empty\");\n }\n\n unwrap(): null {\n return null;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: undefined,\n };\n }\n}\n\n/** Variant representing a successful payload. */\nexport class SlicedExecutionResultSuccess<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly data: TData,\n public readonly extensions?: unknown,\n ) {\n super(\"success\");\n }\n\n unwrap(): TData {\n return this.data;\n }\n\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed) {\n return {\n data: transform(this.data),\n error: undefined,\n };\n }\n}\n\n/** Variant representing an error payload. */\nexport class SlicedExecutionResultError<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly error: NormalizedError,\n public readonly extensions?: unknown,\n ) {\n super(\"error\");\n }\n\n unwrap(): never {\n throw this.error;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: this.error,\n };\n }\n}\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { AnyProjection, Projection } from \"./projection\";\nimport { createPathGraph, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\nconst DIRECT_LABEL = \"__direct__\";\n\n/**\n * Creates a projection path graph from a single projection without label prefixing.\n * Unlike createPathGraphFromSliceEntries, this does not prefix segments with labels.\n */\nfunction createPathGraphFromProjection(projection: AnyProjection): ProjectionPathGraphNode {\n const paths = projection.paths.map(({ full: raw, segments }) => ({\n label: DIRECT_LABEL,\n raw,\n segments: [...segments],\n }));\n return createPathGraph(paths);\n}\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (let i = 0; i <= errorPath.length; i++) {\n const segment = errorPath[i];\n\n if (segment == null || typeof segment === \"number\") {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates a direct execution result parser for single fragment operations.\n * Unlike createExecutionResultParser, this does not apply label prefixing\n * and returns the projected value directly.\n *\n * Use this for operations that use a single fragment spread without $colocate:\n *\n * @example\n * ```typescript\n * const parser = createDirectParser(productFragment);\n *\n * const result = parser({\n * type: \"graphql\",\n * body: { data: { createProduct: { id: \"123\" } }, errors: undefined },\n * });\n * // result is the projected type directly\n * ```\n */\nexport const createDirectParser = <TProjected>(fragmentWithProjection: { readonly projection: Projection<TProjected> }) => {\n const { projection } = fragmentWithProjection;\n const projectionPathGraph = createPathGraphFromProjection(projection);\n\n return (result: NormalizedExecutionResult<object, object>): TProjected => {\n if (result.type === \"non-graphql-error\") {\n return projection.projector(new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }));\n }\n\n if (result.type === \"empty\") {\n return projection.projector(new SlicedExecutionResultEmpty());\n }\n\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => errorMaps[DIRECT_LABEL]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }));\n }\n\n const dataResults = projection.paths.map(({ segments }) =>\n result.body.data ? accessDataByPathSegments(result.body.data, segments) : { error: new Error(\"No data\") },\n );\n\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }));\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return projection.projector(new SlicedExecutionResultSuccess(dataList));\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n};\n","import type { GraphQLFormattedError } from \"graphql\";\nimport { type AnySlicePayloads, createPathGraphFromSliceEntries, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\n// Internal function to build path graph from slices\nconst createPathGraphFromSlices = createPathGraphFromSliceEntries;\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (\n let i = 0;\n // i <= errorPath.length to handle the case where the error path is empty\n i <= errorPath.length;\n i++\n ) {\n const segment = errorPath[i];\n\n if (\n // the end of the path\n segment == null ||\n // FieldPath does not support index access. We treat it as the end of the path.\n typeof segment === \"number\"\n ) {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates an execution result parser for composed operations.\n * The parser maps GraphQL errors and data to their corresponding slices\n * based on the projection path graph.\n *\n * @param slices - Object mapping labels to projections\n * @returns A parser function that takes a NormalizedExecutionResult and returns parsed slices\n *\n * @example\n * ```typescript\n * const parser = createExecutionResultParser({\n * userCard: userCardProjection,\n * posts: postsProjection,\n * });\n *\n * const results = parser({\n * type: \"graphql\",\n * body: { data, errors },\n * });\n * ```\n */\nexport const createExecutionResultParser = <TSlices extends AnySlicePayloads>(slices: TSlices) => {\n // Build path graph from slices\n const projectionPathGraph = createPathGraphFromSlices(slices);\n const fragments = slices;\n const prepare = (result: NormalizedExecutionResult<object, object>) => {\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n\n return { ...result, errorMaps };\n }\n\n if (result.type === \"non-graphql-error\") {\n return { ...result, error: new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }) };\n }\n\n if (result.type === \"empty\") {\n return { ...result, error: new SlicedExecutionResultEmpty() };\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n\n return (result: NormalizedExecutionResult<object, object>) => {\n const prepared = prepare(result);\n\n const entries = Object.entries(fragments).map(([label, fragment]) => {\n const { projection } = fragment;\n\n if (prepared.type === \"graphql\") {\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }))];\n }\n\n // Apply label prefix to first segment for data access (matching $colocate prefix pattern)\n const dataResults = projection.paths.map(({ segments }) => {\n const [first, ...rest] = segments;\n const prefixedSegments = [`${label}_${first}`, ...rest];\n return prepared.body.data\n ? accessDataByPathSegments(prepared.body.data, prefixedSegments)\n : { error: new Error(\"No data\") };\n });\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }))];\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];\n }\n\n if (prepared.type === \"non-graphql-error\") {\n return [label, projection.projector(prepared.error)];\n }\n\n if (prepared.type === \"empty\") {\n return [label, projection.projector(prepared.error)];\n }\n\n throw new Error(\"Invalid result type\", { cause: prepared satisfies never });\n });\n\n return Object.fromEntries(entries);\n };\n};\n"],"mappings":";;;;;;;AAaA,IAAa,aAAb,MAAoC;CAKlC,YACE,OACA,AAAgBA,WAChB;EADgB;AAEhB,OAAK,QAAQ,MAAM,KAAK,SAAS,qBAAqB,KAAK,CAAC;AAE5D,SAAO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AAG,EAAE,CAAE;AACzE,YAAO,CAAC,OAAO,WAAW,UAAU,IAAI,2BAA2B;MAAE,MAAM;MAAe;MAAQ,CAAC,CAAC,CAAC;;IAGvG,MAAM,WAAW,YAAY,KAAK,EAAE,WAAW,KAAK;AACpD,WAAO,CAAC,OAAO,WAAW,UAAU,IAAI,6BAA6B,SAAS,CAAC,CAAC;;AAGlF,OAAI,SAAS,SAAS,oBACpB,QAAO,CAAC,OAAO,WAAW,UAAU,SAAS,MAAM,CAAC;AAGtD,OAAI,SAAS,SAAS,QACpB,QAAO,CAAC,OAAO,WAAW,UAAU,SAAS,MAAM,CAAC;AAGtD,SAAM,IAAI,MAAM,uBAAuB,EAAE,OAAO,UAA0B,CAAC;IAC3E;AAEF,SAAO,OAAO,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["projector: (result: AnySlicedExecutionResult) => TProjected","paths","type: \"success\" | \"error\" | \"empty\"","data: TData","extensions?: unknown","error: NormalizedError","generateErrorMapEntries","createErrorMaps","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","accessDataByPathSegments","current: unknown","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","current: unknown"],"sources":["../src/projection.ts","../src/create-projection.ts","../src/utils/map-values.ts","../src/projection-path-graph.ts","../src/sliced-execution-result.ts","../src/parse-direct-result.ts","../src/parse-execution-result.ts"],"sourcesContent":["import type { AnySlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n/** Shape of a single selection slice projection. */\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Projection regardless of projected type\nexport type AnyProjection = Projection<any>;\n\ndeclare const __PROJECTION_BRAND__: unique symbol;\n/**\n * Nominal type representing any slice selection regardless of schema specifics.\n * Encodes how individual slices map a concrete field path to a projection\n * function. Multiple selections allow slices to expose several derived values.\n */\nexport class Projection<TProjected> {\n declare readonly [__PROJECTION_BRAND__]: void;\n\n declare readonly $infer: { readonly output: TProjected };\n\n constructor(\n paths: Tuple<string>,\n public readonly projector: (result: AnySlicedExecutionResult) => TProjected,\n ) {\n this.paths = paths.map((path) => createProjectionPath(path));\n\n Object.defineProperty(this, \"$infer\", {\n get() {\n throw new Error(\"This property is only for type meta. Do not access this property directly.\");\n },\n });\n }\n\n public readonly paths: ProjectionPath[];\n}\n\nexport type ProjectionPath = {\n full: string;\n segments: Tuple<string>;\n};\n\nfunction createProjectionPath(path: string): ProjectionPath {\n const segments = path.split(\".\");\n if (path === \"$\" || segments.length <= 1) {\n throw new Error(\"Field path must not be only $ or empty\");\n }\n\n return {\n full: path,\n segments: segments.slice(1) as Tuple<string>,\n };\n}\n\nexport type InferExecutionResultProjection<TProjection extends AnyProjection> = ReturnType<TProjection[\"projector\"]>;\n","import type { AnyFields, Fragment, GqlElementAttachment } from \"@soda-gql/core\";\nimport { Projection } from \"./projection\";\nimport type { SlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { AvailableFieldPathOf } from \"./types/field-path\";\nimport type { InferPathsOutput } from \"./types/output-path\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Fragment regardless of type parameters\ntype AnyFragment = Fragment<string, any, any, any>;\n\n/** Get TFields from Fragment via spread's return type. */\ntype FragmentFields<TFragment extends AnyFragment> = ReturnType<TFragment[\"spread\"]>;\n\n/**\n * Options for creating a projection from a Fragment.\n */\nexport type CreateProjectionOptions<\n TFields extends AnyFields,\n TOutput extends object,\n TPaths extends Tuple<AvailableFieldPathOf<TFields>>,\n TProjected,\n> = {\n /**\n * Field paths to extract from the execution result.\n * Each path starts with \"$.\" and follows the field selection structure.\n * Paths are type-checked against the Fragment's field structure.\n *\n * @example\n * ```typescript\n * paths: [\"$.user.id\", \"$.user.name\"]\n * ```\n */\n paths: TPaths;\n\n /**\n * Handler function to transform the sliced execution result.\n * Receives a SlicedExecutionResult with types inferred from the specified paths.\n * Handles all cases: success, error, and empty.\n *\n * @example\n * ```typescript\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple of types from paths\n * return { error: null, data: { id, name } };\n * }\n * ```\n */\n handle: (result: SlicedExecutionResult<InferPathsOutput<TOutput, TPaths>>) => TProjected;\n};\n\n/**\n * Creates a type-safe projection from a Fragment.\n *\n * The projection extracts and transforms data from GraphQL execution results,\n * with full type inference from the Fragment's field structure and output type.\n *\n * - Paths are validated against Fragment's TFields via `ReturnType<Fragment[\"spread\"]>`\n * - Handler receives types inferred from the specified paths\n *\n * @param _fragment - The Fragment to infer types from (used for type inference only)\n * @param options - Projection options including paths and handle function\n * @returns A Projection that can be used with createExecutionResultParser\n *\n * @example\n * ```typescript\n * const userFragment = gql(({ fragment }) =>\n * fragment.Query({\n * variables: { ... },\n * fields: ({ f, $ }) => ({\n * ...f.user({ id: $.userId })(({ f }) => ({ ...f.id(), ...f.name() })),\n * }),\n * })\n * );\n *\n * const userProjection = createProjection(userFragment, {\n * paths: [\"$.user.id\", \"$.user.name\"],\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple: [string, string]\n * return { error: null, data: { id, name } };\n * },\n * });\n * ```\n */\nexport const createProjection = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<TFragment>>>,\n TProjected,\n>(\n _fragment: TFragment,\n options: CreateProjectionOptions<FragmentFields<TFragment>, TFragment[\"$infer\"][\"output\"], TPaths, TProjected>,\n): Projection<TProjected> => {\n return new Projection(options.paths, options.handle);\n};\n\n/**\n * Creates a projection attachment for use with Fragment.attach().\n *\n * @example\n * ```typescript\n * const fragment = gql(({ fragment }) =>\n * fragment.Query({\n * fields: ({ f }) => ({ ...f.user()(({ f }) => ({ ...f.id() })) }),\n * })\n * ).attach(createProjectionAttachment({\n * paths: [\"$.user.id\"],\n * handle: (result) => result.isSuccess() ? result.unwrap()[0] : null,\n * }));\n * ```\n */\nexport const createProjectionAttachment = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<NoInfer<TFragment>>>>,\n TProjected,\n>(\n options: CreateProjectionOptions<\n FragmentFields<NoInfer<TFragment>>,\n NoInfer<TFragment>[\"$infer\"][\"output\"],\n TPaths,\n TProjected\n >,\n): GqlElementAttachment<TFragment, \"projection\", Projection<TProjected>> => {\n return {\n name: \"projection\",\n createValue: (fragment) => createProjection(fragment, options),\n };\n};\n","type ArgEntries<T extends object> = { [K in keyof T]-?: [value: T[K], key: K] }[keyof T];\ntype Entries<T extends object> = { [K in keyof T]: [key: K, value: T[K]] }[keyof T];\n\nexport function mapValues<TObject extends object, TMappedValue>(\n obj: TObject,\n fn: (...args: ArgEntries<TObject>) => TMappedValue,\n): {\n [K in keyof TObject]: TMappedValue;\n} {\n return Object.fromEntries((Object.entries(obj) as Entries<TObject>[]).map(([key, value]) => [key, fn(value, key)])) as {\n [K in keyof TObject]: TMappedValue;\n };\n}\n","import type { AnyProjection } from \"./projection\";\nimport { mapValues } from \"./utils/map-values\";\n\n/**\n * Node in the projection path graph tree.\n * Used for mapping GraphQL errors and data to their corresponding slices.\n */\nexport type ProjectionPathGraphNode = {\n readonly matches: { label: string; path: string; exact: boolean }[];\n readonly children: { readonly [segment: string]: ProjectionPathGraphNode };\n};\n\n/**\n * Payload from a slice that contains projection.\n */\nexport type AnySlicePayload = {\n readonly projection: AnyProjection;\n};\n\nexport type AnySlicePayloads = Record<string, AnySlicePayload>;\n\ntype ExecutionResultProjectionPathGraphIntermediate = {\n [segment: string]: { label: string; raw: string; segments: string[] }[];\n};\n\nexport function createPathGraph(paths: ExecutionResultProjectionPathGraphIntermediate[string]): ProjectionPathGraphNode {\n const intermediate = paths.reduce(\n (acc: ExecutionResultProjectionPathGraphIntermediate, { label, raw, segments: [segment, ...segments] }) => {\n if (segment) {\n (acc[segment] || (acc[segment] = [])).push({ label, raw, segments });\n }\n return acc;\n },\n {},\n );\n\n return {\n matches: paths.map(({ label, raw, segments }) => ({ label, path: raw, exact: segments.length === 0 })),\n children: mapValues(intermediate, (paths) => createPathGraph(paths)),\n } satisfies ProjectionPathGraphNode;\n}\n\n/**\n * Creates a projection path graph from slice entries with field prefixing.\n * Each slice's paths are prefixed with the slice label for disambiguation.\n */\nexport function createPathGraphFromSliceEntries(fragments: AnySlicePayloads) {\n const paths = Object.entries(fragments).flatMap(([label, slice]) =>\n Array.from(\n new Map(\n slice.projection.paths.map(({ full: raw, segments }) => {\n const [first, ...rest] = segments;\n return [raw, { label, raw, segments: [`${label}_${first}`, ...rest] }];\n }),\n ).values(),\n ),\n );\n\n return createPathGraph(paths);\n}\n","/** Result-like wrapper types returned from slice projections. */\n\nimport type { NormalizedError } from \"./types\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any SlicedExecutionResult regardless of data type\nexport type AnySlicedExecutionResult = SlicedExecutionResult<any>;\n\n/**\n * Internal discriminated union describing the Result-like wrapper exposed to\n * slice selection callbacks.\n */\nexport type AnySlicedExecutionResultRecord = {\n [path: string]: AnySlicedExecutionResult;\n};\n\nexport type SafeUnwrapResult<TTransformed, TError> =\n | {\n data?: never;\n error?: never;\n }\n | {\n data: TTransformed;\n error?: never;\n }\n | {\n data?: never;\n error: TError;\n };\n\n/** Utility signature returned by the safe unwrap helper. */\ntype SlicedExecutionResultCommon<TData, TError> = {\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed): SafeUnwrapResult<TTransformed, TError>;\n};\n\n/** Public union used by selection callbacks to inspect data, empty, or error states. */\nexport type SlicedExecutionResult<TData> =\n | SlicedExecutionResultEmpty<TData>\n | SlicedExecutionResultSuccess<TData>\n | SlicedExecutionResultError<TData>;\n\n/** Runtime guard interface shared by all slice result variants. */\nclass SlicedExecutionResultGuards<TData> {\n isSuccess(): this is SlicedExecutionResultSuccess<TData> {\n return this.type === \"success\";\n }\n isError(): this is SlicedExecutionResultError<TData> {\n return this.type === \"error\";\n }\n isEmpty(): this is SlicedExecutionResultEmpty<TData> {\n return this.type === \"empty\";\n }\n\n constructor(private readonly type: \"success\" | \"error\" | \"empty\") {}\n}\n\n/** Variant representing an empty payload (no data, no error). */\nexport class SlicedExecutionResultEmpty<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor() {\n super(\"empty\");\n }\n\n unwrap(): null {\n return null;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: undefined,\n };\n }\n}\n\n/** Variant representing a successful payload. */\nexport class SlicedExecutionResultSuccess<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly data: TData,\n public readonly extensions?: unknown,\n ) {\n super(\"success\");\n }\n\n unwrap(): TData {\n return this.data;\n }\n\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed) {\n return {\n data: transform(this.data),\n error: undefined,\n };\n }\n}\n\n/** Variant representing an error payload. */\nexport class SlicedExecutionResultError<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly error: NormalizedError,\n public readonly extensions?: unknown,\n ) {\n super(\"error\");\n }\n\n unwrap(): never {\n throw this.error;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: this.error,\n };\n }\n}\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { AnyProjection, Projection } from \"./projection\";\nimport { createPathGraph, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\nconst DIRECT_LABEL = \"__direct__\";\n\n/**\n * Creates a projection path graph from a single projection without label prefixing.\n * Unlike createPathGraphFromSliceEntries, this does not prefix segments with labels.\n */\nfunction createPathGraphFromProjection(projection: AnyProjection): ProjectionPathGraphNode {\n const paths = projection.paths.map(({ full: raw, segments }) => ({\n label: DIRECT_LABEL,\n raw,\n segments: [...segments],\n }));\n return createPathGraph(paths);\n}\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (let i = 0; i <= errorPath.length; i++) {\n const segment = errorPath[i];\n\n if (segment == null || typeof segment === \"number\") {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates a direct execution result parser for single fragment operations.\n * Unlike createExecutionResultParser, this does not apply label prefixing\n * and returns the projected value directly.\n *\n * Use this for operations that use a single fragment spread without $colocate:\n *\n * @example\n * ```typescript\n * const parser = createDirectParser(productFragment);\n *\n * const result = parser({\n * type: \"graphql\",\n * body: { data: { createProduct: { id: \"123\" } }, errors: undefined },\n * });\n * // result is the projected type directly\n * ```\n */\nexport const createDirectParser = <TProjected>(fragmentWithProjection: { readonly projection: Projection<TProjected> }) => {\n const { projection } = fragmentWithProjection;\n const projectionPathGraph = createPathGraphFromProjection(projection);\n\n return (result: NormalizedExecutionResult<object, object>): TProjected => {\n if (result.type === \"non-graphql-error\") {\n return projection.projector(new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }));\n }\n\n if (result.type === \"empty\") {\n return projection.projector(new SlicedExecutionResultEmpty());\n }\n\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => errorMaps[DIRECT_LABEL]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }));\n }\n\n const dataResults = projection.paths.map(({ segments }) =>\n result.body.data ? accessDataByPathSegments(result.body.data, segments) : { error: new Error(\"No data\") },\n );\n\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }));\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return projection.projector(new SlicedExecutionResultSuccess(dataList));\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n};\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { InferExecutionResultProjection } from \"./projection\";\nimport { type AnySlicePayloads, createPathGraphFromSliceEntries, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\n/** Inferred result type for parsed slices */\ntype ParsedSlices<TSlices extends AnySlicePayloads> = {\n [K in keyof TSlices]: InferExecutionResultProjection<TSlices[K][\"projection\"]>;\n};\n\n// Internal function to build path graph from slices\nconst createPathGraphFromSlices = createPathGraphFromSliceEntries;\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (\n let i = 0;\n // i <= errorPath.length to handle the case where the error path is empty\n i <= errorPath.length;\n i++\n ) {\n const segment = errorPath[i];\n\n if (\n // the end of the path\n segment == null ||\n // FieldPath does not support index access. We treat it as the end of the path.\n typeof segment === \"number\"\n ) {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates an execution result parser for composed operations.\n * The parser maps GraphQL errors and data to their corresponding slices\n * based on the projection path graph.\n *\n * @param slices - Object mapping labels to projections\n * @returns A parser function that takes a NormalizedExecutionResult and returns parsed slices\n *\n * @example\n * ```typescript\n * const parser = createExecutionResultParser({\n * userCard: userCardProjection,\n * posts: postsProjection,\n * });\n *\n * const results = parser({\n * type: \"graphql\",\n * body: { data, errors },\n * });\n * ```\n */\nexport const createExecutionResultParser = <TSlices extends AnySlicePayloads>(\n slices: TSlices,\n): ((result: NormalizedExecutionResult<object, object>) => ParsedSlices<TSlices>) => {\n // Build path graph from slices\n const projectionPathGraph = createPathGraphFromSlices(slices);\n const fragments = slices;\n const prepare = (result: NormalizedExecutionResult<object, object>) => {\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n\n return { ...result, errorMaps };\n }\n\n if (result.type === \"non-graphql-error\") {\n return { ...result, error: new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }) };\n }\n\n if (result.type === \"empty\") {\n return { ...result, error: new SlicedExecutionResultEmpty() };\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n\n return (result: NormalizedExecutionResult<object, object>) => {\n const prepared = prepare(result);\n\n const entries = Object.entries(fragments).map(([label, fragment]) => {\n const { projection } = fragment;\n\n if (prepared.type === \"graphql\") {\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }))];\n }\n\n // Apply label prefix to first segment for data access (matching $colocate prefix pattern)\n const dataResults = projection.paths.map(({ segments }) => {\n const [first, ...rest] = segments;\n const prefixedSegments = [`${label}_${first}`, ...rest];\n return prepared.body.data\n ? accessDataByPathSegments(prepared.body.data, prefixedSegments)\n : { error: new Error(\"No data\") };\n });\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }))];\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];\n }\n\n if (prepared.type === \"non-graphql-error\") {\n return [label, projection.projector(prepared.error)];\n }\n\n if (prepared.type === \"empty\") {\n return [label, projection.projector(prepared.error)];\n }\n\n throw new Error(\"Invalid result type\", { cause: prepared satisfies never });\n });\n\n return Object.fromEntries(entries);\n };\n};\n"],"mappings":";;;;;;;AAaA,IAAa,aAAb,MAAoC;CAKlC,YACE,OACA,AAAgBA,WAChB;EADgB;AAEhB,OAAK,QAAQ,MAAM,KAAK,SAAS,qBAAqB,KAAK,CAAC;AAE5D,SAAO,eAAe,MAAM,UAAU,EACpC,MAAM;AACJ,SAAM,IAAI,MAAM,6EAA6E;KAEhG,CAAC;;CAGJ,AAAgB;;AAQlB,SAAS,qBAAqB,MAA8B;CAC1D,MAAM,WAAW,KAAK,MAAM,IAAI;AAChC,KAAI,SAAS,OAAO,SAAS,UAAU,EACrC,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO;EACL,MAAM;EACN,UAAU,SAAS,MAAM,EAAE;EAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuCH,MAAa,oBAKX,WACA,YAC2B;AAC3B,QAAO,IAAI,WAAW,QAAQ,OAAO,QAAQ,OAAO;;;;;;;;;;;;;;;;;AAkBtD,MAAa,8BAKX,YAM0E;AAC1E,QAAO;EACL,MAAM;EACN,cAAc,aAAa,iBAAiB,UAAU,QAAQ;EAC/D;;;;;AC7HH,SAAgB,UACd,KACA,IAGA;AACA,QAAO,OAAO,YAAa,OAAO,QAAQ,IAAI,CAAwB,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC;;;;;ACgBrH,SAAgB,gBAAgB,OAAwF;CACtH,MAAM,eAAe,MAAM,QACxB,KAAqD,EAAE,OAAO,KAAK,UAAU,CAAC,SAAS,GAAG,gBAAgB;AACzG,MAAI,QACF,EAAC,IAAI,aAAa,IA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IvH,MAAM,cAAc,WAAW,MAAM,KAAK,EAAE,eAAe;KACzD,MAAM,CAAC,OAAO,GAAG,QAAQ;KACzB,MAAM,mBAAmB,CAAC,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK;AACvD,YAAO,SAAS,KAAK,OACjB,yBAAyB,SAAS,KAAK,MAAM,iBAAiB,GAC9D,EAAE,uBAAO,IAAI,MAAM,UAAU,EAAE;MACnC;AACF,QAAI,YAAY,MAAM,EAAE,YAAY,MAAM,EAAE;KAC1C,MAAM,SAAS,YAAY,SAAS,EAAE,YAAa,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAE;AACzE,YAAO,CAAC,OAAO,WAAW,UAAU,IAAI,2BAA2B;MAAE,MAAM;MAAe;MAAQ,CAAC,CAAC,CAAC;;IAGvG,MAAM,WAAW,YAAY,KAAK,EAAE,WAAW,KAAK;AACpD,WAAO,CAAC,OAAO,WAAW,UAAU,IAAI,6BAA6B,SAAS,CAAC,CAAC;;AAGlF,OAAI,SAAS,SAAS,oBACpB,QAAO,CAAC,OAAO,WAAW,UAAU,SAAS,MAAM,CAAC;AAGtD,OAAI,SAAS,SAAS,QACpB,QAAO,CAAC,OAAO,WAAW,UAAU,SAAS,MAAM,CAAC;AAGtD,SAAM,IAAI,MAAM,uBAAuB,EAAE,OAAO,UAA0B,CAAC;IAC3E;AAEF,SAAO,OAAO,YAAY,QAAQ"}
|
package/dist/index.d.cts
CHANGED
|
@@ -322,6 +322,8 @@ type AnySlicePayloads = Record<string, AnySlicePayload>;
|
|
|
322
322
|
declare function createPathGraphFromSliceEntries(fragments: AnySlicePayloads): ProjectionPathGraphNode;
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region packages/colocation-tools/src/parse-execution-result.d.ts
|
|
325
|
+
/** Inferred result type for parsed slices */
|
|
326
|
+
type ParsedSlices<TSlices extends AnySlicePayloads> = { [K in keyof TSlices]: InferExecutionResultProjection<TSlices[K]["projection"]> };
|
|
325
327
|
/**
|
|
326
328
|
* Creates an execution result parser for composed operations.
|
|
327
329
|
* The parser maps GraphQL errors and data to their corresponding slices
|
|
@@ -343,7 +345,7 @@ declare function createPathGraphFromSliceEntries(fragments: AnySlicePayloads): P
|
|
|
343
345
|
* });
|
|
344
346
|
* ```
|
|
345
347
|
*/
|
|
346
|
-
declare const createExecutionResultParser: <TSlices extends AnySlicePayloads>(slices: TSlices) => (result: NormalizedExecutionResult<object, object>) =>
|
|
348
|
+
declare const createExecutionResultParser: <TSlices extends AnySlicePayloads>(slices: TSlices) => ((result: NormalizedExecutionResult<object, object>) => ParsedSlices<TSlices>);
|
|
347
349
|
//#endregion
|
|
348
350
|
export { type AnyFieldPath, type AnyOutputPath, type AnyProjection, type AnySlicePayload, type AnySlicePayloads, type AnySlicedExecutionResult, type AnySlicedExecutionResultRecord, type AvailableFieldPathOf, type CreateProjectionOptions, type EmptyResult, type GraphqlExecutionResult, type InferByOutputPath, type InferExecutionResultProjection, type InferPathsOutput, type NonGraphqlError, type NonGraphqlErrorResult, type NormalizedError, type NormalizedExecutionResult, Projection, type ProjectionPath, type ProjectionPathGraphNode, type SafeUnwrapResult, type SlicedExecutionResult, SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess, createDirectParser, createExecutionResultParser, createPathGraphFromSliceEntries, createProjection, createProjectionAttachment };
|
|
349
351
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/sliced-execution-result.ts","../src/utils/type-utils.ts","../src/projection.ts","../src/types/field-path.ts","../src/types/output-path.ts","../src/create-projection.ts","../src/parse-direct-result.ts","../src/projection-path-graph.ts","../src/parse-execution-result.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAMA;AAMY,KANA,eAAA,GAMA,OAAyB;;;;;AAGjC,KAHQ,yBAGR,CAAA,KAAA,EAAA,WAAA,CAAA,GAFA,WAEA,GADA,sBACA,C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AA,MAAA;IAAO,IAAA,EAAA,MAAA;IAA9B,KAAA,EAAA,OAAA;EACA,CAAA,EAAA;EAAqB,SAAA,QAAA,EAAA;IAEb,UAAW,OAAA,EAAA,MAAA,CAAA,EQR4B,uBRQ5B;EAIX,CAAA;CAEqB;;;;AAGrB,KQXA,eAAA,GRWqB;EAQrB,SAAA,UAAe,EQlBJ,aRkBI;CAGb;AAID,KQtBD,gBAAA,GAAmB,MRsBlB,CAAA,MAAA,EQtBiC,eRsBjC,CAAA;ACdP;;;;AAI+F,iBOerF,+BAAA,CPfqF,SAAA,EOe1C,gBPf0C,CAAA,EOe1B,uBPf0B
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/sliced-execution-result.ts","../src/utils/type-utils.ts","../src/projection.ts","../src/types/field-path.ts","../src/types/output-path.ts","../src/create-projection.ts","../src/parse-direct-result.ts","../src/projection-path-graph.ts","../src/parse-execution-result.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAMA;AAMY,KANA,eAAA,GAMA,OAAyB;;;;;AAGjC,KAHQ,yBAGR,CAAA,KAAA,EAAA,WAAA,CAAA,GAFA,WAEA,GADA,sBACA,CADuB,KACvB,EAD8B,WAC9B,CAAA,GAAA,qBAAA;AAAqB,KAEb,WAAA,GAFa;EAEb,IAAA,EAAA,OAAA;AAIZ,CAAA;AAEiC,KAFrB,sBAEqB,CAAA,KAAA,EAAA,WAAA,CAAA,GAAA;EAAO,IAAA,EAAA,SAAA;EAAhC,IAAA,EAAA,wBAAA,CAAyB,KAAzB,EAAgC,WAAhC,CAAA;CAAwB;AAGpB,KAAA,qBAAA,GAAqB;EAQrB,IAAA,EAAA,mBAAe;EAGb,KAAA,EATL,eASK;CAID;;;;KAPD,eAAA;;EC7BA,MAAA,EDgCE,qBChCsB,EAAA;AAMpC,CAAA,GAAY;EAIA,IAAA,EAAA,mBAAgB;EAevB,KAAA,EDWQ,eCXR;CACwC,GAAA;EAAU,IAAA,EAAA,aAAA;E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CSJ0B,CTI1B,CAAA,CAAA,YAAA,CAAA,CAAA,EACjC;;;;;;AAIJ;AAIA;;;;;AAKA;AAQA;;;;;;;;AC7BA;AAMY,cQ2FC,2BR3F6B,EACxB,CAAA,gBQ0F0C,gBR1FlB,CAAA,CAAA,MAAA,EQ2FhC,OR3FgC,EAAA,GAAA,CAAA,CAAA,MAAA,EQ4F7B,yBR5F6B,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,GQ4FiB,YR5FjB,CQ4F8B,OR5F9B,CAAA,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -322,6 +322,8 @@ type AnySlicePayloads = Record<string, AnySlicePayload>;
|
|
|
322
322
|
declare function createPathGraphFromSliceEntries(fragments: AnySlicePayloads): ProjectionPathGraphNode;
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region packages/colocation-tools/src/parse-execution-result.d.ts
|
|
325
|
+
/** Inferred result type for parsed slices */
|
|
326
|
+
type ParsedSlices<TSlices extends AnySlicePayloads> = { [K in keyof TSlices]: InferExecutionResultProjection<TSlices[K]["projection"]> };
|
|
325
327
|
/**
|
|
326
328
|
* Creates an execution result parser for composed operations.
|
|
327
329
|
* The parser maps GraphQL errors and data to their corresponding slices
|
|
@@ -343,7 +345,7 @@ declare function createPathGraphFromSliceEntries(fragments: AnySlicePayloads): P
|
|
|
343
345
|
* });
|
|
344
346
|
* ```
|
|
345
347
|
*/
|
|
346
|
-
declare const createExecutionResultParser: <TSlices extends AnySlicePayloads>(slices: TSlices) => (result: NormalizedExecutionResult<object, object>) =>
|
|
348
|
+
declare const createExecutionResultParser: <TSlices extends AnySlicePayloads>(slices: TSlices) => ((result: NormalizedExecutionResult<object, object>) => ParsedSlices<TSlices>);
|
|
347
349
|
//#endregion
|
|
348
350
|
export { type AnyFieldPath, type AnyOutputPath, type AnyProjection, type AnySlicePayload, type AnySlicePayloads, type AnySlicedExecutionResult, type AnySlicedExecutionResultRecord, type AvailableFieldPathOf, type CreateProjectionOptions, type EmptyResult, type GraphqlExecutionResult, type InferByOutputPath, type InferExecutionResultProjection, type InferPathsOutput, type NonGraphqlError, type NonGraphqlErrorResult, type NormalizedError, type NormalizedExecutionResult, Projection, type ProjectionPath, type ProjectionPathGraphNode, type SafeUnwrapResult, type SlicedExecutionResult, SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess, createDirectParser, createExecutionResultParser, createPathGraphFromSliceEntries, createProjection, createProjectionAttachment };
|
|
349
351
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/sliced-execution-result.ts","../src/utils/type-utils.ts","../src/projection.ts","../src/types/field-path.ts","../src/types/output-path.ts","../src/create-projection.ts","../src/parse-direct-result.ts","../src/projection-path-graph.ts","../src/parse-execution-result.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAMA;AAMY,KANA,eAAA,GAMA,OAAyB;;;;;AAGjC,KAHQ,yBAGR,CAAA,KAAA,EAAA,WAAA,CAAA,GAFA,WAEA,GADA,sBACA,CADuB,KACvB,EAD8B,WAC9B,CAAA,GAAA,qBAAA;AAAqB,KAEb,WAAA,GAFa;EAEb,IAAA,EAAA,OAAA;AAIZ,CAAA;AAEiC,KAFrB,sBAEqB,CAAA,KAAA,EAAA,WAAA,CAAA,GAAA;EAAO,IAAA,EAAA,SAAA;EAAhC,IAAA,EAAA,wBAAA,CAAyB,KAAzB,EAAgC,WAAhC,CAAA;CAAwB;AAGpB,KAAA,qBAAA,GAAqB;EAQrB,IAAA,EAAA,mBAAe;EAGb,KAAA,EATL,eASK;CAID;;;;KAPD,eAAA;;EC7BA,MAAA,EDgCE,qBChCsB,EAAA;AAMpC,CAAA,GAAY;EAIA,IAAA,EAAA,mBAAgB;EAevB,KAAA,EDWQ,eCXR;CACwC,GAAA;EAAU,IAAA,EAAA,aAAA;EAAgC,MAAA,EDczE,KCdyE,EAAA;C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HtGlD,CAAA,CAAA,CAAA,CAAA,EAAA,UAAA,CAAA,CAAA,OAAA,EGyGZ,uBHzGY,CG0GnB,cH1GmB,CG0GJ,OH1GI,CG0GI,SH1GJ,CAAA,CAAA,EG2GnB,OH3GmB,CG2GX,SH3GW,CAAA,CAAA,QAAA,CAAA,CAAA,QAAA,CAAA,EG4GnB,MH5GmB,EG6GnB,UH7GmB,CAAA,EAAA,GG+GpB,oBH/GoB,CG+GC,SH/GD,EAAA,YAAA,EG+G0B,UH/G1B,CG+GqC,UH/GrC,CAAA,CAAA;;;;;AHPvB;AAMA;;;;;;;AAKA;AAIA;;;;;AAKA;AAQA;AAGc,cO2DD,kBP3DC,EAAA,CAAA,UAAA,CAAA,CAAA,sBAAA,EAAA;EAID,SAAA,UAAA,EOuDiF,UPvDjF,COuD4F,UPvD5F,CAAA;CAIC,EAAA,GAAA,CAAA,MAAA,EOuDI,yBPvDJ,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,GOuDgD,UPvDhD;;;;;;AAvCd;AAMY,KQLA,uBAAA,GRKyB;EACjC,SAAA,OAAA,EAAA;IACuB,KAAA,EAAA,MAAA;IAAO,IAAA,EAAA,MAAA;IAA9B,KAAA,EAAA,OAAA;EACA,CAAA,EAAA;EAAqB,SAAA,QAAA,EAAA;IAEb,UAAW,OAAA,EAAA,MAAA,CAAA,EQR4B,uBRQ5B;EAIX,CAAA;CAEqB;;;;AAGrB,KQXA,eAAA,GRWqB;EAQrB,SAAA,UAAe,EQlBJ,aRkBI;CAGb;AAID,KQtBD,gBAAA,GAAmB,MRsBlB,CAAA,MAAA,EQtBiC,eRsBjC,CAAA;ACdP;;;;AAI+F,iBOerF,+BAAA,CPfqF,SAAA,EOe1C,gBPf0C,CAAA,EOe1B,uBPf0B
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/sliced-execution-result.ts","../src/utils/type-utils.ts","../src/projection.ts","../src/types/field-path.ts","../src/types/output-path.ts","../src/create-projection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,COuD4F,UPvD5F,CAAA;CAIC,EAAA,GAAA,CAAA,MAAA,EOuDI,yBPvDJ,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,GOuDgD,UPvDhD;;;;;;AAvCd;AAMY,KQLA,uBAAA,GRKyB;EACjC,SAAA,OAAA,EAAA;IACuB,KAAA,EAAA,MAAA;IAAO,IAAA,EAAA,MAAA;IAA9B,KAAA,EAAA,OAAA;EACA,CAAA,EAAA;EAAqB,SAAA,QAAA,EAAA;IAEb,UAAW,OAAA,EAAA,MAAA,CAAA,EQR4B,uBRQ5B;EAIX,CAAA;CAEqB;;;;AAGrB,KQXA,eAAA,GRWqB;EAQrB,SAAA,UAAe,EQlBJ,aRkBI;CAGb;AAID,KQtBD,gBAAA,GAAmB,MRsBlB,CAAA,MAAA,EQtBiC,eRsBjC,CAAA;ACdP;;;;AAI+F,iBOerF,+BAAA,CPfqF,SAAA,EOe1C,gBPf0C,CAAA,EOe1B,uBPf0B;;;;ADzBrG,KSCK,YTDO,CAAA,gBSCsB,gBTDP,CAAA,GAAA,QAMf,MSJE,OTIF,GSJY,8BTIa,CSJkB,OTIlB,CSJ0B,CTI1B,CAAA,CAAA,YAAA,CAAA,CAAA,EACjC;;;;;;AAIJ;AAIA;;;;;AAKA;AAQA;;;;;;;;AC7BA;AAMY,cQ2FC,2BR3F6B,EACxB,CAAA,gBQ0F0C,gBR1FlB,CAAA,CAAA,MAAA,EQ2FhC,OR3FgC,EAAA,GAAA,CAAA,CAAA,MAAA,EQ4F7B,yBR5F6B,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,GQ4FiB,YR5FjB,CQ4F8B,OR5F9B,CAAA,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["projector: (result: AnySlicedExecutionResult) => TProjected","paths","type: \"success\" | \"error\" | \"empty\"","data: TData","extensions?: unknown","error: NormalizedError","generateErrorMapEntries","createErrorMaps","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","accessDataByPathSegments","current: unknown","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","current: unknown"],"sources":["../src/projection.ts","../src/create-projection.ts","../src/utils/map-values.ts","../src/projection-path-graph.ts","../src/sliced-execution-result.ts","../src/parse-direct-result.ts","../src/parse-execution-result.ts"],"sourcesContent":["import type { AnySlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n/** Shape of a single selection slice projection. */\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Projection regardless of projected type\nexport type AnyProjection = Projection<any>;\n\ndeclare const __PROJECTION_BRAND__: unique symbol;\n/**\n * Nominal type representing any slice selection regardless of schema specifics.\n * Encodes how individual slices map a concrete field path to a projection\n * function. Multiple selections allow slices to expose several derived values.\n */\nexport class Projection<TProjected> {\n declare readonly [__PROJECTION_BRAND__]: void;\n\n declare readonly $infer: { readonly output: TProjected };\n\n constructor(\n paths: Tuple<string>,\n public readonly projector: (result: AnySlicedExecutionResult) => TProjected,\n ) {\n this.paths = paths.map((path) => createProjectionPath(path));\n\n Object.defineProperty(this, \"$infer\", {\n get() {\n throw new Error(\"This property is only for type meta. Do not access this property directly.\");\n },\n });\n }\n\n public readonly paths: ProjectionPath[];\n}\n\nexport type ProjectionPath = {\n full: string;\n segments: Tuple<string>;\n};\n\nfunction createProjectionPath(path: string): ProjectionPath {\n const segments = path.split(\".\");\n if (path === \"$\" || segments.length <= 1) {\n throw new Error(\"Field path must not be only $ or empty\");\n }\n\n return {\n full: path,\n segments: segments.slice(1) as Tuple<string>,\n };\n}\n\nexport type InferExecutionResultProjection<TProjection extends AnyProjection> = ReturnType<TProjection[\"projector\"]>;\n","import type { AnyFields, Fragment, GqlElementAttachment } from \"@soda-gql/core\";\nimport { Projection } from \"./projection\";\nimport type { SlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { AvailableFieldPathOf } from \"./types/field-path\";\nimport type { InferPathsOutput } from \"./types/output-path\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Fragment regardless of type parameters\ntype AnyFragment = Fragment<string, any, any, any>;\n\n/** Get TFields from Fragment via spread's return type. */\ntype FragmentFields<TFragment extends AnyFragment> = ReturnType<TFragment[\"spread\"]>;\n\n/**\n * Options for creating a projection from a Fragment.\n */\nexport type CreateProjectionOptions<\n TFields extends AnyFields,\n TOutput extends object,\n TPaths extends Tuple<AvailableFieldPathOf<TFields>>,\n TProjected,\n> = {\n /**\n * Field paths to extract from the execution result.\n * Each path starts with \"$.\" and follows the field selection structure.\n * Paths are type-checked against the Fragment's field structure.\n *\n * @example\n * ```typescript\n * paths: [\"$.user.id\", \"$.user.name\"]\n * ```\n */\n paths: TPaths;\n\n /**\n * Handler function to transform the sliced execution result.\n * Receives a SlicedExecutionResult with types inferred from the specified paths.\n * Handles all cases: success, error, and empty.\n *\n * @example\n * ```typescript\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple of types from paths\n * return { error: null, data: { id, name } };\n * }\n * ```\n */\n handle: (result: SlicedExecutionResult<InferPathsOutput<TOutput, TPaths>>) => TProjected;\n};\n\n/**\n * Creates a type-safe projection from a Fragment.\n *\n * The projection extracts and transforms data from GraphQL execution results,\n * with full type inference from the Fragment's field structure and output type.\n *\n * - Paths are validated against Fragment's TFields via `ReturnType<Fragment[\"spread\"]>`\n * - Handler receives types inferred from the specified paths\n *\n * @param _fragment - The Fragment to infer types from (used for type inference only)\n * @param options - Projection options including paths and handle function\n * @returns A Projection that can be used with createExecutionResultParser\n *\n * @example\n * ```typescript\n * const userFragment = gql(({ fragment }) =>\n * fragment.Query({\n * variables: { ... },\n * fields: ({ f, $ }) => ({\n * ...f.user({ id: $.userId })(({ f }) => ({ ...f.id(), ...f.name() })),\n * }),\n * })\n * );\n *\n * const userProjection = createProjection(userFragment, {\n * paths: [\"$.user.id\", \"$.user.name\"],\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple: [string, string]\n * return { error: null, data: { id, name } };\n * },\n * });\n * ```\n */\nexport const createProjection = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<TFragment>>>,\n TProjected,\n>(\n _fragment: TFragment,\n options: CreateProjectionOptions<FragmentFields<TFragment>, TFragment[\"$infer\"][\"output\"], TPaths, TProjected>,\n): Projection<TProjected> => {\n return new Projection(options.paths, options.handle);\n};\n\n/**\n * Creates a projection attachment for use with Fragment.attach().\n *\n * @example\n * ```typescript\n * const fragment = gql(({ fragment }) =>\n * fragment.Query({\n * fields: ({ f }) => ({ ...f.user()(({ f }) => ({ ...f.id() })) }),\n * })\n * ).attach(createProjectionAttachment({\n * paths: [\"$.user.id\"],\n * handle: (result) => result.isSuccess() ? result.unwrap()[0] : null,\n * }));\n * ```\n */\nexport const createProjectionAttachment = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<NoInfer<TFragment>>>>,\n TProjected,\n>(\n options: CreateProjectionOptions<\n FragmentFields<NoInfer<TFragment>>,\n NoInfer<TFragment>[\"$infer\"][\"output\"],\n TPaths,\n TProjected\n >,\n): GqlElementAttachment<TFragment, \"projection\", Projection<TProjected>> => {\n return {\n name: \"projection\",\n createValue: (fragment) => createProjection(fragment, options),\n };\n};\n","type ArgEntries<T extends object> = { [K in keyof T]-?: [value: T[K], key: K] }[keyof T];\ntype Entries<T extends object> = { [K in keyof T]: [key: K, value: T[K]] }[keyof T];\n\nexport function mapValues<TObject extends object, TMappedValue>(\n obj: TObject,\n fn: (...args: ArgEntries<TObject>) => TMappedValue,\n): {\n [K in keyof TObject]: TMappedValue;\n} {\n return Object.fromEntries((Object.entries(obj) as Entries<TObject>[]).map(([key, value]) => [key, fn(value, key)])) as {\n [K in keyof TObject]: TMappedValue;\n };\n}\n","import type { AnyProjection } from \"./projection\";\nimport { mapValues } from \"./utils/map-values\";\n\n/**\n * Node in the projection path graph tree.\n * Used for mapping GraphQL errors and data to their corresponding slices.\n */\nexport type ProjectionPathGraphNode = {\n readonly matches: { label: string; path: string; exact: boolean }[];\n readonly children: { readonly [segment: string]: ProjectionPathGraphNode };\n};\n\n/**\n * Payload from a slice that contains projection.\n */\nexport type AnySlicePayload = {\n readonly projection: AnyProjection;\n};\n\nexport type AnySlicePayloads = Record<string, AnySlicePayload>;\n\ntype ExecutionResultProjectionPathGraphIntermediate = {\n [segment: string]: { label: string; raw: string; segments: string[] }[];\n};\n\nexport function createPathGraph(paths: ExecutionResultProjectionPathGraphIntermediate[string]): ProjectionPathGraphNode {\n const intermediate = paths.reduce(\n (acc: ExecutionResultProjectionPathGraphIntermediate, { label, raw, segments: [segment, ...segments] }) => {\n if (segment) {\n (acc[segment] || (acc[segment] = [])).push({ label, raw, segments });\n }\n return acc;\n },\n {},\n );\n\n return {\n matches: paths.map(({ label, raw, segments }) => ({ label, path: raw, exact: segments.length === 0 })),\n children: mapValues(intermediate, (paths) => createPathGraph(paths)),\n } satisfies ProjectionPathGraphNode;\n}\n\n/**\n * Creates a projection path graph from slice entries with field prefixing.\n * Each slice's paths are prefixed with the slice label for disambiguation.\n */\nexport function createPathGraphFromSliceEntries(fragments: AnySlicePayloads) {\n const paths = Object.entries(fragments).flatMap(([label, slice]) =>\n Array.from(\n new Map(\n slice.projection.paths.map(({ full: raw, segments }) => {\n const [first, ...rest] = segments;\n return [raw, { label, raw, segments: [`${label}_${first}`, ...rest] }];\n }),\n ).values(),\n ),\n );\n\n return createPathGraph(paths);\n}\n","/** Result-like wrapper types returned from slice projections. */\n\nimport type { NormalizedError } from \"./types\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any SlicedExecutionResult regardless of data type\nexport type AnySlicedExecutionResult = SlicedExecutionResult<any>;\n\n/**\n * Internal discriminated union describing the Result-like wrapper exposed to\n * slice selection callbacks.\n */\nexport type AnySlicedExecutionResultRecord = {\n [path: string]: AnySlicedExecutionResult;\n};\n\nexport type SafeUnwrapResult<TTransformed, TError> =\n | {\n data?: never;\n error?: never;\n }\n | {\n data: TTransformed;\n error?: never;\n }\n | {\n data?: never;\n error: TError;\n };\n\n/** Utility signature returned by the safe unwrap helper. */\ntype SlicedExecutionResultCommon<TData, TError> = {\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed): SafeUnwrapResult<TTransformed, TError>;\n};\n\n/** Public union used by selection callbacks to inspect data, empty, or error states. */\nexport type SlicedExecutionResult<TData> =\n | SlicedExecutionResultEmpty<TData>\n | SlicedExecutionResultSuccess<TData>\n | SlicedExecutionResultError<TData>;\n\n/** Runtime guard interface shared by all slice result variants. */\nclass SlicedExecutionResultGuards<TData> {\n isSuccess(): this is SlicedExecutionResultSuccess<TData> {\n return this.type === \"success\";\n }\n isError(): this is SlicedExecutionResultError<TData> {\n return this.type === \"error\";\n }\n isEmpty(): this is SlicedExecutionResultEmpty<TData> {\n return this.type === \"empty\";\n }\n\n constructor(private readonly type: \"success\" | \"error\" | \"empty\") {}\n}\n\n/** Variant representing an empty payload (no data, no error). */\nexport class SlicedExecutionResultEmpty<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor() {\n super(\"empty\");\n }\n\n unwrap(): null {\n return null;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: undefined,\n };\n }\n}\n\n/** Variant representing a successful payload. */\nexport class SlicedExecutionResultSuccess<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly data: TData,\n public readonly extensions?: unknown,\n ) {\n super(\"success\");\n }\n\n unwrap(): TData {\n return this.data;\n }\n\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed) {\n return {\n data: transform(this.data),\n error: undefined,\n };\n }\n}\n\n/** Variant representing an error payload. */\nexport class SlicedExecutionResultError<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly error: NormalizedError,\n public readonly extensions?: unknown,\n ) {\n super(\"error\");\n }\n\n unwrap(): never {\n throw this.error;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: this.error,\n };\n }\n}\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { AnyProjection, Projection } from \"./projection\";\nimport { createPathGraph, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\nconst DIRECT_LABEL = \"__direct__\";\n\n/**\n * Creates a projection path graph from a single projection without label prefixing.\n * Unlike createPathGraphFromSliceEntries, this does not prefix segments with labels.\n */\nfunction createPathGraphFromProjection(projection: AnyProjection): ProjectionPathGraphNode {\n const paths = projection.paths.map(({ full: raw, segments }) => ({\n label: DIRECT_LABEL,\n raw,\n segments: [...segments],\n }));\n return createPathGraph(paths);\n}\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (let i = 0; i <= errorPath.length; i++) {\n const segment = errorPath[i];\n\n if (segment == null || typeof segment === \"number\") {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates a direct execution result parser for single fragment operations.\n * Unlike createExecutionResultParser, this does not apply label prefixing\n * and returns the projected value directly.\n *\n * Use this for operations that use a single fragment spread without $colocate:\n *\n * @example\n * ```typescript\n * const parser = createDirectParser(productFragment);\n *\n * const result = parser({\n * type: \"graphql\",\n * body: { data: { createProduct: { id: \"123\" } }, errors: undefined },\n * });\n * // result is the projected type directly\n * ```\n */\nexport const createDirectParser = <TProjected>(fragmentWithProjection: { readonly projection: Projection<TProjected> }) => {\n const { projection } = fragmentWithProjection;\n const projectionPathGraph = createPathGraphFromProjection(projection);\n\n return (result: NormalizedExecutionResult<object, object>): TProjected => {\n if (result.type === \"non-graphql-error\") {\n return projection.projector(new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }));\n }\n\n if (result.type === \"empty\") {\n return projection.projector(new SlicedExecutionResultEmpty());\n }\n\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => errorMaps[DIRECT_LABEL]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }));\n }\n\n const dataResults = projection.paths.map(({ segments }) =>\n result.body.data ? accessDataByPathSegments(result.body.data, segments) : { error: new Error(\"No data\") },\n );\n\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }));\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return projection.projector(new SlicedExecutionResultSuccess(dataList));\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n};\n","import type { GraphQLFormattedError } from \"graphql\";\nimport { type AnySlicePayloads, createPathGraphFromSliceEntries, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\n// Internal function to build path graph from slices\nconst createPathGraphFromSlices = createPathGraphFromSliceEntries;\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (\n let i = 0;\n // i <= errorPath.length to handle the case where the error path is empty\n i <= errorPath.length;\n i++\n ) {\n const segment = errorPath[i];\n\n if (\n // the end of the path\n segment == null ||\n // FieldPath does not support index access. We treat it as the end of the path.\n typeof segment === \"number\"\n ) {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates an execution result parser for composed operations.\n * The parser maps GraphQL errors and data to their corresponding slices\n * based on the projection path graph.\n *\n * @param slices - Object mapping labels to projections\n * @returns A parser function that takes a NormalizedExecutionResult and returns parsed slices\n *\n * @example\n * ```typescript\n * const parser = createExecutionResultParser({\n * userCard: userCardProjection,\n * posts: postsProjection,\n * });\n *\n * const results = parser({\n * type: \"graphql\",\n * body: { data, errors },\n * });\n * ```\n */\nexport const createExecutionResultParser = <TSlices extends AnySlicePayloads>(slices: TSlices) => {\n // Build path graph from slices\n const projectionPathGraph = createPathGraphFromSlices(slices);\n const fragments = slices;\n const prepare = (result: NormalizedExecutionResult<object, object>) => {\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n\n return { ...result, errorMaps };\n }\n\n if (result.type === \"non-graphql-error\") {\n return { ...result, error: new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }) };\n }\n\n if (result.type === \"empty\") {\n return { ...result, error: new SlicedExecutionResultEmpty() };\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n\n return (result: NormalizedExecutionResult<object, object>) => {\n const prepared = prepare(result);\n\n const entries = Object.entries(fragments).map(([label, fragment]) => {\n const { projection } = fragment;\n\n if (prepared.type === \"graphql\") {\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }))];\n }\n\n // Apply label prefix to first segment for data access (matching $colocate prefix pattern)\n const dataResults = projection.paths.map(({ segments }) => {\n const [first, ...rest] = segments;\n const prefixedSegments = [`${label}_${first}`, ...rest];\n return prepared.body.data\n ? accessDataByPathSegments(prepared.body.data, prefixedSegments)\n : { error: new Error(\"No data\") };\n });\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }))];\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];\n }\n\n if (prepared.type === \"non-graphql-error\") {\n return [label, projection.projector(prepared.error)];\n }\n\n if (prepared.type === \"empty\") {\n return [label, projection.projector(prepared.error)];\n }\n\n throw new Error(\"Invalid result type\", { cause: prepared satisfies never });\n });\n\n return Object.fromEntries(entries);\n };\n};\n"],"mappings":";;;;;;AAaA,IAAa,aAAb,MAAoC;CAKlC,YACE,OACA,AAAgBA,WAChB;EADgB;AAEhB,OAAK,QAAQ,MAAM,KAAK,SAAS,qBAAqB,KAAK,CAAC;AAE5D,SAAO,eAAe,MAAM,UAAU,EACpC,MAAM;AACJ,SAAM,IAAI,MAAM,6EAA6E;KAEhG,CAAC;;CAGJ,AAAgB;;AAQlB,SAAS,qBAAqB,MAA8B;CAC1D,MAAM,WAAW,KAAK,MAAM,IAAI;AAChC,KAAI,SAAS,OAAO,SAAS,UAAU,EACrC,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO;EACL,MAAM;EACN,UAAU,SAAS,MAAM,EAAE;EAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuCH,MAAa,oBAKX,WACA,YAC2B;AAC3B,QAAO,IAAI,WAAW,QAAQ,OAAO,QAAQ,OAAO;;;;;;;;;;;;;;;;;AAkBtD,MAAa,8BAKX,YAM0E;A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OAAO,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["projector: (result: AnySlicedExecutionResult) => TProjected","paths","type: \"success\" | \"error\" | \"empty\"","data: TData","extensions?: unknown","error: NormalizedError","generateErrorMapEntries","createErrorMaps","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","accessDataByPathSegments","current: unknown","errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } }","current: unknown"],"sources":["../src/projection.ts","../src/create-projection.ts","../src/utils/map-values.ts","../src/projection-path-graph.ts","../src/sliced-execution-result.ts","../src/parse-direct-result.ts","../src/parse-execution-result.ts"],"sourcesContent":["import type { AnySlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n/** Shape of a single selection slice projection. */\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Projection regardless of projected type\nexport type AnyProjection = Projection<any>;\n\ndeclare const __PROJECTION_BRAND__: unique symbol;\n/**\n * Nominal type representing any slice selection regardless of schema specifics.\n * Encodes how individual slices map a concrete field path to a projection\n * function. Multiple selections allow slices to expose several derived values.\n */\nexport class Projection<TProjected> {\n declare readonly [__PROJECTION_BRAND__]: void;\n\n declare readonly $infer: { readonly output: TProjected };\n\n constructor(\n paths: Tuple<string>,\n public readonly projector: (result: AnySlicedExecutionResult) => TProjected,\n ) {\n this.paths = paths.map((path) => createProjectionPath(path));\n\n Object.defineProperty(this, \"$infer\", {\n get() {\n throw new Error(\"This property is only for type meta. Do not access this property directly.\");\n },\n });\n }\n\n public readonly paths: ProjectionPath[];\n}\n\nexport type ProjectionPath = {\n full: string;\n segments: Tuple<string>;\n};\n\nfunction createProjectionPath(path: string): ProjectionPath {\n const segments = path.split(\".\");\n if (path === \"$\" || segments.length <= 1) {\n throw new Error(\"Field path must not be only $ or empty\");\n }\n\n return {\n full: path,\n segments: segments.slice(1) as Tuple<string>,\n };\n}\n\nexport type InferExecutionResultProjection<TProjection extends AnyProjection> = ReturnType<TProjection[\"projector\"]>;\n","import type { AnyFields, Fragment, GqlElementAttachment } from \"@soda-gql/core\";\nimport { Projection } from \"./projection\";\nimport type { SlicedExecutionResult } from \"./sliced-execution-result\";\nimport type { AvailableFieldPathOf } from \"./types/field-path\";\nimport type { InferPathsOutput } from \"./types/output-path\";\nimport type { Tuple } from \"./utils/type-utils\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any Fragment regardless of type parameters\ntype AnyFragment = Fragment<string, any, any, any>;\n\n/** Get TFields from Fragment via spread's return type. */\ntype FragmentFields<TFragment extends AnyFragment> = ReturnType<TFragment[\"spread\"]>;\n\n/**\n * Options for creating a projection from a Fragment.\n */\nexport type CreateProjectionOptions<\n TFields extends AnyFields,\n TOutput extends object,\n TPaths extends Tuple<AvailableFieldPathOf<TFields>>,\n TProjected,\n> = {\n /**\n * Field paths to extract from the execution result.\n * Each path starts with \"$.\" and follows the field selection structure.\n * Paths are type-checked against the Fragment's field structure.\n *\n * @example\n * ```typescript\n * paths: [\"$.user.id\", \"$.user.name\"]\n * ```\n */\n paths: TPaths;\n\n /**\n * Handler function to transform the sliced execution result.\n * Receives a SlicedExecutionResult with types inferred from the specified paths.\n * Handles all cases: success, error, and empty.\n *\n * @example\n * ```typescript\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple of types from paths\n * return { error: null, data: { id, name } };\n * }\n * ```\n */\n handle: (result: SlicedExecutionResult<InferPathsOutput<TOutput, TPaths>>) => TProjected;\n};\n\n/**\n * Creates a type-safe projection from a Fragment.\n *\n * The projection extracts and transforms data from GraphQL execution results,\n * with full type inference from the Fragment's field structure and output type.\n *\n * - Paths are validated against Fragment's TFields via `ReturnType<Fragment[\"spread\"]>`\n * - Handler receives types inferred from the specified paths\n *\n * @param _fragment - The Fragment to infer types from (used for type inference only)\n * @param options - Projection options including paths and handle function\n * @returns A Projection that can be used with createExecutionResultParser\n *\n * @example\n * ```typescript\n * const userFragment = gql(({ fragment }) =>\n * fragment.Query({\n * variables: { ... },\n * fields: ({ f, $ }) => ({\n * ...f.user({ id: $.userId })(({ f }) => ({ ...f.id(), ...f.name() })),\n * }),\n * })\n * );\n *\n * const userProjection = createProjection(userFragment, {\n * paths: [\"$.user.id\", \"$.user.name\"],\n * handle: (result) => {\n * if (result.isError()) return { error: result.error, data: null };\n * if (result.isEmpty()) return { error: null, data: null };\n * const [id, name] = result.unwrap(); // tuple: [string, string]\n * return { error: null, data: { id, name } };\n * },\n * });\n * ```\n */\nexport const createProjection = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<TFragment>>>,\n TProjected,\n>(\n _fragment: TFragment,\n options: CreateProjectionOptions<FragmentFields<TFragment>, TFragment[\"$infer\"][\"output\"], TPaths, TProjected>,\n): Projection<TProjected> => {\n return new Projection(options.paths, options.handle);\n};\n\n/**\n * Creates a projection attachment for use with Fragment.attach().\n *\n * @example\n * ```typescript\n * const fragment = gql(({ fragment }) =>\n * fragment.Query({\n * fields: ({ f }) => ({ ...f.user()(({ f }) => ({ ...f.id() })) }),\n * })\n * ).attach(createProjectionAttachment({\n * paths: [\"$.user.id\"],\n * handle: (result) => result.isSuccess() ? result.unwrap()[0] : null,\n * }));\n * ```\n */\nexport const createProjectionAttachment = <\n TFragment extends AnyFragment,\n const TPaths extends Tuple<AvailableFieldPathOf<FragmentFields<NoInfer<TFragment>>>>,\n TProjected,\n>(\n options: CreateProjectionOptions<\n FragmentFields<NoInfer<TFragment>>,\n NoInfer<TFragment>[\"$infer\"][\"output\"],\n TPaths,\n TProjected\n >,\n): GqlElementAttachment<TFragment, \"projection\", Projection<TProjected>> => {\n return {\n name: \"projection\",\n createValue: (fragment) => createProjection(fragment, options),\n };\n};\n","type ArgEntries<T extends object> = { [K in keyof T]-?: [value: T[K], key: K] }[keyof T];\ntype Entries<T extends object> = { [K in keyof T]: [key: K, value: T[K]] }[keyof T];\n\nexport function mapValues<TObject extends object, TMappedValue>(\n obj: TObject,\n fn: (...args: ArgEntries<TObject>) => TMappedValue,\n): {\n [K in keyof TObject]: TMappedValue;\n} {\n return Object.fromEntries((Object.entries(obj) as Entries<TObject>[]).map(([key, value]) => [key, fn(value, key)])) as {\n [K in keyof TObject]: TMappedValue;\n };\n}\n","import type { AnyProjection } from \"./projection\";\nimport { mapValues } from \"./utils/map-values\";\n\n/**\n * Node in the projection path graph tree.\n * Used for mapping GraphQL errors and data to their corresponding slices.\n */\nexport type ProjectionPathGraphNode = {\n readonly matches: { label: string; path: string; exact: boolean }[];\n readonly children: { readonly [segment: string]: ProjectionPathGraphNode };\n};\n\n/**\n * Payload from a slice that contains projection.\n */\nexport type AnySlicePayload = {\n readonly projection: AnyProjection;\n};\n\nexport type AnySlicePayloads = Record<string, AnySlicePayload>;\n\ntype ExecutionResultProjectionPathGraphIntermediate = {\n [segment: string]: { label: string; raw: string; segments: string[] }[];\n};\n\nexport function createPathGraph(paths: ExecutionResultProjectionPathGraphIntermediate[string]): ProjectionPathGraphNode {\n const intermediate = paths.reduce(\n (acc: ExecutionResultProjectionPathGraphIntermediate, { label, raw, segments: [segment, ...segments] }) => {\n if (segment) {\n (acc[segment] || (acc[segment] = [])).push({ label, raw, segments });\n }\n return acc;\n },\n {},\n );\n\n return {\n matches: paths.map(({ label, raw, segments }) => ({ label, path: raw, exact: segments.length === 0 })),\n children: mapValues(intermediate, (paths) => createPathGraph(paths)),\n } satisfies ProjectionPathGraphNode;\n}\n\n/**\n * Creates a projection path graph from slice entries with field prefixing.\n * Each slice's paths are prefixed with the slice label for disambiguation.\n */\nexport function createPathGraphFromSliceEntries(fragments: AnySlicePayloads) {\n const paths = Object.entries(fragments).flatMap(([label, slice]) =>\n Array.from(\n new Map(\n slice.projection.paths.map(({ full: raw, segments }) => {\n const [first, ...rest] = segments;\n return [raw, { label, raw, segments: [`${label}_${first}`, ...rest] }];\n }),\n ).values(),\n ),\n );\n\n return createPathGraph(paths);\n}\n","/** Result-like wrapper types returned from slice projections. */\n\nimport type { NormalizedError } from \"./types\";\n\n// biome-ignore lint/suspicious/noExplicitAny: Type alias for any SlicedExecutionResult regardless of data type\nexport type AnySlicedExecutionResult = SlicedExecutionResult<any>;\n\n/**\n * Internal discriminated union describing the Result-like wrapper exposed to\n * slice selection callbacks.\n */\nexport type AnySlicedExecutionResultRecord = {\n [path: string]: AnySlicedExecutionResult;\n};\n\nexport type SafeUnwrapResult<TTransformed, TError> =\n | {\n data?: never;\n error?: never;\n }\n | {\n data: TTransformed;\n error?: never;\n }\n | {\n data?: never;\n error: TError;\n };\n\n/** Utility signature returned by the safe unwrap helper. */\ntype SlicedExecutionResultCommon<TData, TError> = {\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed): SafeUnwrapResult<TTransformed, TError>;\n};\n\n/** Public union used by selection callbacks to inspect data, empty, or error states. */\nexport type SlicedExecutionResult<TData> =\n | SlicedExecutionResultEmpty<TData>\n | SlicedExecutionResultSuccess<TData>\n | SlicedExecutionResultError<TData>;\n\n/** Runtime guard interface shared by all slice result variants. */\nclass SlicedExecutionResultGuards<TData> {\n isSuccess(): this is SlicedExecutionResultSuccess<TData> {\n return this.type === \"success\";\n }\n isError(): this is SlicedExecutionResultError<TData> {\n return this.type === \"error\";\n }\n isEmpty(): this is SlicedExecutionResultEmpty<TData> {\n return this.type === \"empty\";\n }\n\n constructor(private readonly type: \"success\" | \"error\" | \"empty\") {}\n}\n\n/** Variant representing an empty payload (no data, no error). */\nexport class SlicedExecutionResultEmpty<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor() {\n super(\"empty\");\n }\n\n unwrap(): null {\n return null;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: undefined,\n };\n }\n}\n\n/** Variant representing a successful payload. */\nexport class SlicedExecutionResultSuccess<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly data: TData,\n public readonly extensions?: unknown,\n ) {\n super(\"success\");\n }\n\n unwrap(): TData {\n return this.data;\n }\n\n safeUnwrap<TTransformed>(transform: (data: TData) => TTransformed) {\n return {\n data: transform(this.data),\n error: undefined,\n };\n }\n}\n\n/** Variant representing an error payload. */\nexport class SlicedExecutionResultError<TData>\n extends SlicedExecutionResultGuards<TData>\n implements SlicedExecutionResultCommon<TData, NormalizedError>\n{\n constructor(\n public readonly error: NormalizedError,\n public readonly extensions?: unknown,\n ) {\n super(\"error\");\n }\n\n unwrap(): never {\n throw this.error;\n }\n\n safeUnwrap() {\n return {\n data: undefined,\n error: this.error,\n };\n }\n}\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { AnyProjection, Projection } from \"./projection\";\nimport { createPathGraph, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\nconst DIRECT_LABEL = \"__direct__\";\n\n/**\n * Creates a projection path graph from a single projection without label prefixing.\n * Unlike createPathGraphFromSliceEntries, this does not prefix segments with labels.\n */\nfunction createPathGraphFromProjection(projection: AnyProjection): ProjectionPathGraphNode {\n const paths = projection.paths.map(({ full: raw, segments }) => ({\n label: DIRECT_LABEL,\n raw,\n segments: [...segments],\n }));\n return createPathGraph(paths);\n}\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (let i = 0; i <= errorPath.length; i++) {\n const segment = errorPath[i];\n\n if (segment == null || typeof segment === \"number\") {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates a direct execution result parser for single fragment operations.\n * Unlike createExecutionResultParser, this does not apply label prefixing\n * and returns the projected value directly.\n *\n * Use this for operations that use a single fragment spread without $colocate:\n *\n * @example\n * ```typescript\n * const parser = createDirectParser(productFragment);\n *\n * const result = parser({\n * type: \"graphql\",\n * body: { data: { createProduct: { id: \"123\" } }, errors: undefined },\n * });\n * // result is the projected type directly\n * ```\n */\nexport const createDirectParser = <TProjected>(fragmentWithProjection: { readonly projection: Projection<TProjected> }) => {\n const { projection } = fragmentWithProjection;\n const projectionPathGraph = createPathGraphFromProjection(projection);\n\n return (result: NormalizedExecutionResult<object, object>): TProjected => {\n if (result.type === \"non-graphql-error\") {\n return projection.projector(new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }));\n }\n\n if (result.type === \"empty\") {\n return projection.projector(new SlicedExecutionResultEmpty());\n }\n\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => errorMaps[DIRECT_LABEL]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }));\n }\n\n const dataResults = projection.paths.map(({ segments }) =>\n result.body.data ? accessDataByPathSegments(result.body.data, segments) : { error: new Error(\"No data\") },\n );\n\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }));\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return projection.projector(new SlicedExecutionResultSuccess(dataList));\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n};\n","import type { GraphQLFormattedError } from \"graphql\";\nimport type { InferExecutionResultProjection } from \"./projection\";\nimport { type AnySlicePayloads, createPathGraphFromSliceEntries, type ProjectionPathGraphNode } from \"./projection-path-graph\";\nimport { SlicedExecutionResultEmpty, SlicedExecutionResultError, SlicedExecutionResultSuccess } from \"./sliced-execution-result\";\nimport type { NormalizedExecutionResult } from \"./types\";\n\n/** Inferred result type for parsed slices */\ntype ParsedSlices<TSlices extends AnySlicePayloads> = {\n [K in keyof TSlices]: InferExecutionResultProjection<TSlices[K][\"projection\"]>;\n};\n\n// Internal function to build path graph from slices\nconst createPathGraphFromSlices = createPathGraphFromSliceEntries;\n\nfunction* generateErrorMapEntries(errors: readonly GraphQLFormattedError[], projectionPathGraph: ProjectionPathGraphNode) {\n for (const error of errors) {\n const errorPath = error.path ?? [];\n let stack = projectionPathGraph;\n\n for (\n let i = 0;\n // i <= errorPath.length to handle the case where the error path is empty\n i <= errorPath.length;\n i++\n ) {\n const segment = errorPath[i];\n\n if (\n // the end of the path\n segment == null ||\n // FieldPath does not support index access. We treat it as the end of the path.\n typeof segment === \"number\"\n ) {\n yield* stack.matches.map(({ label, path }) => ({ label, path, error }));\n break;\n }\n\n yield* stack.matches.filter(({ exact }) => exact).map(({ label, path }) => ({ label, path, error }));\n\n const next = stack.children[segment];\n if (!next) {\n break;\n }\n\n stack = next;\n }\n }\n}\n\nconst createErrorMaps = (errors: readonly GraphQLFormattedError[] | undefined, projectionPathGraph: ProjectionPathGraphNode) => {\n const errorMaps: { [label: string]: { [path: string]: { error: GraphQLFormattedError }[] } } = {};\n for (const { label, path, error } of generateErrorMapEntries(errors ?? [], projectionPathGraph)) {\n const mapPerLabel = errorMaps[label] || (errorMaps[label] = {});\n const mapPerPath = mapPerLabel[path] || (mapPerLabel[path] = []);\n mapPerPath.push({ error });\n }\n return errorMaps;\n};\n\nconst accessDataByPathSegments = (data: object, pathSegments: string[]) => {\n let current: unknown = data;\n\n for (const segment of pathSegments) {\n if (current == null) {\n return { error: new Error(\"No data\") };\n }\n\n if (typeof current !== \"object\") {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n if (Array.isArray(current)) {\n return { error: new Error(\"Incorrect data type\") };\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return { data: current };\n};\n\n/**\n * Creates an execution result parser for composed operations.\n * The parser maps GraphQL errors and data to their corresponding slices\n * based on the projection path graph.\n *\n * @param slices - Object mapping labels to projections\n * @returns A parser function that takes a NormalizedExecutionResult and returns parsed slices\n *\n * @example\n * ```typescript\n * const parser = createExecutionResultParser({\n * userCard: userCardProjection,\n * posts: postsProjection,\n * });\n *\n * const results = parser({\n * type: \"graphql\",\n * body: { data, errors },\n * });\n * ```\n */\nexport const createExecutionResultParser = <TSlices extends AnySlicePayloads>(\n slices: TSlices,\n): ((result: NormalizedExecutionResult<object, object>) => ParsedSlices<TSlices>) => {\n // Build path graph from slices\n const projectionPathGraph = createPathGraphFromSlices(slices);\n const fragments = slices;\n const prepare = (result: NormalizedExecutionResult<object, object>) => {\n if (result.type === \"graphql\") {\n const errorMaps = createErrorMaps(result.body.errors, projectionPathGraph);\n\n return { ...result, errorMaps };\n }\n\n if (result.type === \"non-graphql-error\") {\n return { ...result, error: new SlicedExecutionResultError({ type: \"non-graphql-error\", error: result.error }) };\n }\n\n if (result.type === \"empty\") {\n return { ...result, error: new SlicedExecutionResultEmpty() };\n }\n\n throw new Error(\"Invalid result type\", { cause: result satisfies never });\n };\n\n return (result: NormalizedExecutionResult<object, object>) => {\n const prepared = prepare(result);\n\n const entries = Object.entries(fragments).map(([label, fragment]) => {\n const { projection } = fragment;\n\n if (prepared.type === \"graphql\") {\n const matchedErrors = projection.paths.flatMap(({ full: raw }) => prepared.errorMaps[label]?.[raw] ?? []);\n const uniqueErrors = Array.from(new Set(matchedErrors.map(({ error }) => error)).values());\n\n if (uniqueErrors.length > 0) {\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"graphql-error\", errors: uniqueErrors }))];\n }\n\n // Apply label prefix to first segment for data access (matching $colocate prefix pattern)\n const dataResults = projection.paths.map(({ segments }) => {\n const [first, ...rest] = segments;\n const prefixedSegments = [`${label}_${first}`, ...rest];\n return prepared.body.data\n ? accessDataByPathSegments(prepared.body.data, prefixedSegments)\n : { error: new Error(\"No data\") };\n });\n if (dataResults.some(({ error }) => error)) {\n const errors = dataResults.flatMap(({ error }) => (error ? [error] : []));\n return [label, projection.projector(new SlicedExecutionResultError({ type: \"parse-error\", errors }))];\n }\n\n const dataList = dataResults.map(({ data }) => data);\n return [label, projection.projector(new SlicedExecutionResultSuccess(dataList))];\n }\n\n if (prepared.type === \"non-graphql-error\") {\n return [label, projection.projector(prepared.error)];\n }\n\n if (prepared.type === \"empty\") {\n return [label, projection.projector(prepared.error)];\n }\n\n throw new Error(\"Invalid result type\", { cause: prepared satisfies never });\n });\n\n return Object.fromEntries(entries);\n };\n};\n"],"mappings":";;;;;;AAaA,IAAa,aAAb,MAAoC;CAKlC,YACE,OACA,AAAgBA,WAChB;EADgB;AAEhB,OAAK,QAAQ,MAAM,KAAK,SAAS,qBAAqB,KAAK,CAAC;AAE5D,SAAO,eAAe,MAAM,UAAU,EACpC,MAAM;AACJ,SAAM,IAAI,MAAM,6EAA6E;KAEhG,CAAC;;CAGJ,AAAgB;;AA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