@soda-gql/core 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapter.d.cts +2 -2
- package/dist/adapter.d.ts +2 -2
- package/dist/{index-Bdt5dpFG.d.cts → index-B1n1hHta.d.ts} +170 -10
- package/dist/{index-D1T79XaT.d.ts.map → index-B1n1hHta.d.ts.map} +1 -1
- package/dist/{index-DJ-yqsXz.d.ts → index-DGLs-yOJ.d.ts} +17 -6
- package/dist/{index-DJ-yqsXz.d.ts.map → index-DGLs-yOJ.d.ts.map} +1 -1
- package/dist/{index-D1T79XaT.d.ts → index-Dz6_Wnn2.d.cts} +170 -10
- package/dist/{index-Bdt5dpFG.d.cts.map → index-Dz6_Wnn2.d.cts.map} +1 -1
- package/dist/{index-CRWc3q9X.d.cts → index-iYNGR-zb.d.cts} +17 -6
- package/dist/{index-CRWc3q9X.d.cts.map → index-iYNGR-zb.d.cts.map} +1 -1
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +40 -16
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.cts.map +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/{schema-builder-DfdeJY7k.d.cts → schema-builder-CyOSWGkc.d.cts} +2 -2
- package/dist/{schema-builder-DfdeJY7k.d.cts.map → schema-builder-CyOSWGkc.d.cts.map} +1 -1
- package/dist/{schema-builder-DTinHI5s.d.ts → schema-builder-DVZMBaAM.d.ts} +2 -2
- package/dist/{schema-builder-DTinHI5s.d.ts.map → schema-builder-DVZMBaAM.d.ts.map} +1 -1
- package/package.json +14 -14
package/dist/index.cjs
CHANGED
|
@@ -2488,7 +2488,7 @@ const getVarRefValue = (varRef) => {
|
|
|
2488
2488
|
const SelectableProxyInnerRegistry = /* @__PURE__ */ new WeakMap();
|
|
2489
2489
|
const getSelectableProxyInner = (proxy) => {
|
|
2490
2490
|
const inner = SelectableProxyInnerRegistry.get(proxy);
|
|
2491
|
-
if (!inner) throw new Error(
|
|
2491
|
+
if (!inner) throw new Error("$var selector must return the proxy itself or a field navigated from it (e.g. (p) => p or (p) => p.user.id); it returned a value that is not a selector proxy");
|
|
2492
2492
|
return inner;
|
|
2493
2493
|
};
|
|
2494
2494
|
const createSelectableProxy = (current) => {
|
|
@@ -2503,7 +2503,7 @@ const createSelectableProxy = (current) => {
|
|
|
2503
2503
|
varInner: {
|
|
2504
2504
|
type: "virtual",
|
|
2505
2505
|
varName: current.varInner.name,
|
|
2506
|
-
varSegments:
|
|
2506
|
+
varSegments: current.segments
|
|
2507
2507
|
},
|
|
2508
2508
|
segments: nextSegments
|
|
2509
2509
|
});
|
|
@@ -3508,22 +3508,29 @@ const generateInputType = (schema, variableDefinitions, formatters) => {
|
|
|
3508
3508
|
* Generate TypeScript type for a single input field from its parsed specifier.
|
|
3509
3509
|
* Used by generateInputTypeFromSpecifiers.
|
|
3510
3510
|
*/
|
|
3511
|
-
const
|
|
3512
|
-
let baseType;
|
|
3511
|
+
const resolveInputBaseTypeFromSpecifier = (schema, specifier, options) => {
|
|
3513
3512
|
const { formatters } = options;
|
|
3514
3513
|
switch (specifier.kind) {
|
|
3515
|
-
case "scalar":
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
baseType = getEnumType(schema, specifier.name);
|
|
3520
|
-
break;
|
|
3521
|
-
case "input":
|
|
3522
|
-
baseType = formatters?.inputObject?.(specifier.name) ?? generateInputObjectType(schema, specifier.name, options);
|
|
3523
|
-
break;
|
|
3524
|
-
default: baseType = "unknown";
|
|
3514
|
+
case "scalar": return formatters?.scalarInput?.(specifier.name) ?? getScalarInputType(schema, specifier.name);
|
|
3515
|
+
case "enum": return getEnumType(schema, specifier.name);
|
|
3516
|
+
case "input": return formatters?.inputObject?.(specifier.name) ?? generateInputObjectType(schema, specifier.name, options);
|
|
3517
|
+
default: return "unknown";
|
|
3525
3518
|
}
|
|
3526
|
-
|
|
3519
|
+
};
|
|
3520
|
+
const generateInputFieldTypeFromSpecifier = (schema, specifier, options) => {
|
|
3521
|
+
return applyTypeModifier(resolveInputBaseTypeFromSpecifier(schema, specifier, options), specifier.modifier);
|
|
3522
|
+
};
|
|
3523
|
+
/**
|
|
3524
|
+
* Wraps a base type in array brackets for each list level in the modifier. Only the
|
|
3525
|
+
* list dimensions are applied here; nullability is layered on by the caller. Matches
|
|
3526
|
+
* the operation-side `graphqlTypeToTypeScript`, which also drops inner-list-element
|
|
3527
|
+
* nullability (a shared limitation of the generated `input` type).
|
|
3528
|
+
*/
|
|
3529
|
+
const applyListModifier = (baseType, modifier) => {
|
|
3530
|
+
const listDepth = modifier.split("[]").length - 1;
|
|
3531
|
+
let result = baseType;
|
|
3532
|
+
for (let i = 0; i < listDepth; i++) result = `(${result})[]`;
|
|
3533
|
+
return result;
|
|
3527
3534
|
};
|
|
3528
3535
|
/**
|
|
3529
3536
|
* Generate a TypeScript type string for input variables from InputTypeSpecifiers.
|
|
@@ -3568,6 +3575,23 @@ const generateInputTypeFromVarDefs = (schema, varDefs, options = {}) => {
|
|
|
3568
3575
|
return `readonly ${name}${!isOuterRequired || hasDefault ? "?" : ""}: ${baseType}`;
|
|
3569
3576
|
}).join("; ")} }`;
|
|
3570
3577
|
};
|
|
3578
|
+
/**
|
|
3579
|
+
* Generate the per-variable payload type map for a fragment's variables.
|
|
3580
|
+
*
|
|
3581
|
+
* Mirrors the operation-side `varTypes` map: the key is always present (`$.<name>` is
|
|
3582
|
+
* always a ref) while the value keeps the variable's outer nullability — an optional
|
|
3583
|
+
* or nullable variable reads as `| null | undefined`, so downstream consumers see the
|
|
3584
|
+
* value that actually arrives at spread time. Backs the VarRef payload types consumed
|
|
3585
|
+
* by `$`/`$var` in metadata builders.
|
|
3586
|
+
*/
|
|
3587
|
+
const generateVarTypesFromVarDefs = (schema, varDefs, options = {}) => {
|
|
3588
|
+
const entries = Object.entries(varDefs);
|
|
3589
|
+
if (entries.length === 0) return "{}";
|
|
3590
|
+
return `{ ${entries.map(([name, varSpec]) => {
|
|
3591
|
+
const listType = applyListModifier(resolveInputBaseTypeFromSpecifier(schema, varSpec, options), varSpec.modifier);
|
|
3592
|
+
return `readonly ${name}: ${varSpec.modifier.endsWith("!") ? listType : `(${listType} | null | undefined)`}`;
|
|
3593
|
+
}).join("; ")} }`;
|
|
3594
|
+
};
|
|
3571
3595
|
|
|
3572
3596
|
//#endregion
|
|
3573
3597
|
exports.Fragment = Fragment;
|
|
@@ -3617,6 +3641,7 @@ exports.generateInputObjectType = generateInputObjectType;
|
|
|
3617
3641
|
exports.generateInputType = generateInputType;
|
|
3618
3642
|
exports.generateInputTypeFromSpecifiers = generateInputTypeFromSpecifiers;
|
|
3619
3643
|
exports.generateInputTypeFromVarDefs = generateInputTypeFromVarDefs;
|
|
3644
|
+
exports.generateVarTypesFromVarDefs = generateVarTypesFromVarDefs;
|
|
3620
3645
|
exports.getArgumentType = getArgumentType;
|
|
3621
3646
|
exports.getCurrentFieldPath = getCurrentFieldPath;
|
|
3622
3647
|
exports.getEnumType = getEnumType;
|