Skip to content

Commit a66f5b0

Browse files
committed
updz
1 parent 17d6cfe commit a66f5b0

File tree

14 files changed

+22200
-15590
lines changed

14 files changed

+22200
-15590
lines changed

.changeset/pre.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"dirty-books-pump",
1313
"early-pots-build",
1414
"eighty-grapes-sit",
15-
"sixty-turtles-roll"
15+
"quick-ways-sit",
16+
"sixty-turtles-roll",
17+
"smooth-garlics-wink"
1618
]
1719
}

.changeset/quick-ways-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"basehub": patch
3+
---
4+
5+
fixe

.changeset/smooth-garlics-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"basehub": patch
3+
---
4+
5+
fixes

packages/basehub/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# basehub
22

3+
## 9.0.0-schemaless.6
4+
5+
### Patch Changes
6+
7+
- fixes
8+
9+
## 9.0.0-schemaless.5
10+
11+
### Patch Changes
12+
13+
- fixe
14+
315
## 9.0.0-schemaless.4
416

517
### Patch Changes

packages/basehub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "basehub",
33
"description": "A very fast Headless CMS.",
44
"author": "JB <[email protected]>",
5-
"version": "9.0.0-schemaless.4",
5+
"version": "9.0.0-schemaless.6",
66
"license": "MIT",
77
"repository": "basehub-ai/basehub",
88
"bugs": "https://github.com/basehub-ai/basehub/issues",

packages/basehub/src/bin/tasks/clientTasks.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { RenderContext } from "./render/common/RenderContext.js";
99
import { renderRequestTypes } from "./render/requestTypes/renderRequestTypes.js";
1010
import { renderResponseTypes } from "./render/responseTypes/renderResponseTypes.js";
1111
import { renderSchema } from "./render/schema/renderSchema.js";
12-
import { renderModuleAugmentation } from "./render/responseTypes/renderModuleAugmentation.js";
12+
import {
13+
renderModuleAugmentation,
14+
enhanceMutationGenqlSelection,
15+
} from "./render/responseTypes/renderModuleAugmentation.js";
1316
// import { renderTypeGuards } from "./render/typeGuards/renderTypeGuards.js";
1417

1518
export type OutputContextRef = {
@@ -64,7 +67,9 @@ export const clientTasks = (
6467
await writeFileToPath(
6568
[output],
6669
"// @ts-nocheck\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n\n" +
67-
renderCtx.toCode("typescript")
70+
enhanceMutationGenqlSelection(
71+
await renderCtx.toCode("typescript")
72+
)
6873
);
6974
},
7075
},

packages/basehub/src/bin/tasks/render/requestTypes/objectType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export const objectType = (
8282
}
8383

8484
fieldStrings.push("__typename?: boolean | number");
85-
fieldStrings.push("__scalar?: boolean | number");
8685

8786
// add indentation
8887
fieldStrings = fieldStrings.map((x) =>

packages/basehub/src/bin/tasks/render/responseTypes/renderModuleAugmentation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ declare module "${ctx.config?.packageName || "basehub"}" {
2828
export interface Scalars extends _Scalars {}
2929
}
3030
31+
import type { Transaction } from 'basehub/api-transaction'
32+
3133
interface _Query extends Query {}
3234
interface _QueryGenqlSelection extends QueryGenqlSelection {}
3335
interface _Mutation extends Mutation {}
@@ -36,3 +38,13 @@ interface _FragmentsMap extends FragmentsMap {}
3638
interface _Scalars extends Scalars {}`
3739
);
3840
};
41+
42+
export const enhanceMutationGenqlSelection = (schemaFileContents: string) => {
43+
// edit `MutationGenqlSelection` to receive the Transaction directly instead of a string
44+
return schemaFileContents.replace(
45+
` /** Transaction data. */
46+
data: Scalars["String"];`,
47+
` /** Transaction data. */
48+
data: Transaction | Scalars["String"];`
49+
);
50+
};

packages/basehub/src/genql/runtime/_generate-graphql-operation.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,34 @@ const parseRequest = (
3838
return parseRequest(fields, ctx, path, options);
3939
}
4040

41+
const argsThatShouldNotBeEnums = [
42+
// image processing args
43+
"format",
44+
"anim",
45+
"background",
46+
"border",
47+
"compression",
48+
"fit",
49+
"gamma",
50+
"gravity",
51+
"metadata",
52+
"rotate",
53+
"sharpen",
54+
"trim",
55+
];
56+
4157
const argStrings = argNames.map((argName) => {
4258
let value = args[argName];
4359
if (typeof value === "object") {
4460
// stringify the object
4561
value = JSON.stringify(value);
4662
// strip quotes except for string values
4763
value = value.replace(/"([^"]+)":/g, "$1:");
64+
} else if (
65+
typeof value === "string" &&
66+
argsThatShouldNotBeEnums.includes(argName)
67+
) {
68+
value = JSON.stringify(value);
4869
}
4970

5071
return `${argName}:${value}`;

packages/basehub/src/react/pump/server-pump.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
generateQueryOp,
77
type QueryGenqlSelection,
88
type QueryResult,
9+
type Options,
910
} from "../../index.js";
1011
import { getStuffFromEnv } from "../../bin/util/get-stuff-from-env.js";
1112
import { replaceSystemAliases } from "../../genql/runtime/_aliasing.js";
@@ -46,7 +47,12 @@ export type PumpProps<
4647
) => React.ReactNode | Promise<React.ReactNode>;
4748
queries: [...Queries]; // Tuple type for better type inference
4849
bind?: Bind;
49-
} & Parameters<typeof basehub>[0];
50+
} & Omit<Options, "ref"> & {
51+
/**
52+
* same as "ref", but to avoid React complaining about the "ref" prop
53+
*/
54+
_ref?: Options["ref"];
55+
};
5056

5157
// Utility type to infer result types from an array of queries
5258
export type QueryResults<Queries extends Array<PumpQuery>> = {
@@ -60,8 +66,10 @@ export const Pump = async <
6066
children,
6167
queries,
6268
bind,
63-
...basehubProps
69+
_ref,
70+
..._basehubProps
6471
}: PumpProps<Queries, Bind>): Promise<JSX.Element> => {
72+
const basehubProps = { ..._basehubProps, ref: _ref };
6573
// passed to the client to toast
6674
const errors: Array<ResponseCache["errors"]> = [];
6775
const responseHashes: Array<ResponseCache["responseHash"]> = [];

0 commit comments

Comments
 (0)