@m1212e/rumble 0.12.19 → 0.12.20
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/out/index.cjs +24 -23
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +9 -3
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +9 -3
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +25 -24
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.cjs
CHANGED
|
@@ -57,13 +57,14 @@ function generateClient({ apiUrl, rumbleImportPath, useExternalUrqlClient, avail
|
|
|
57
57
|
imports.push(`import { nativeDateExchange } from '${rumbleImportPath}';`);
|
|
58
58
|
imports.push(`import { makeLiveQuery, makeMutation, makeSubscription, makeQuery } from '${rumbleImportPath}';`);
|
|
59
59
|
code += `
|
|
60
|
+
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
export const schema = ${schema ? (0, devalue.uneval)((0, __urql_introspection.minifyIntrospectionQuery)((0, __urql_introspection.getIntrospectedSchema)(schema))) : "undefined"};
|
|
63
|
+
|
|
60
64
|
export const defaultOptions: ConstructorParameters<Client>[0] = {
|
|
61
65
|
url: "${apiUrl ?? "PLEASE PROVIDE A URL WHEN GENERATING OR IMPORT AN EXTERNAL URQL CLIENT"}",
|
|
62
66
|
fetchSubscriptions: true,
|
|
63
|
-
exchanges: [cacheExchange({
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
schema: ${schema ? (0, devalue.uneval)((0, __urql_introspection.minifyIntrospectionQuery)((0, __urql_introspection.getIntrospectedSchema)(schema))) : "undefined"}
|
|
66
|
-
}), nativeDateExchange, fetchExchange],
|
|
67
|
+
exchanges: [cacheExchange({ schema }), nativeDateExchange, fetchExchange],
|
|
67
68
|
fetchOptions: {
|
|
68
69
|
credentials: "include",
|
|
69
70
|
},
|
|
@@ -208,8 +209,8 @@ function makeStringLiteralUnionFromEnum(enumType) {
|
|
|
208
209
|
|
|
209
210
|
//#endregion
|
|
210
211
|
//#region lib/client/generate/generate.ts
|
|
211
|
-
async function generateFromSchema({ outputPath, schema, rumbleImportPath = "@m1212e/rumble", apiUrl, useExternalUrqlClient = false }) {
|
|
212
|
-
try {
|
|
212
|
+
async function generateFromSchema({ outputPath, schema, rumbleImportPath = "@m1212e/rumble", apiUrl, useExternalUrqlClient = false, removeExisting = true }) {
|
|
213
|
+
if (removeExisting) try {
|
|
213
214
|
await (0, node_fs_promises.access)(outputPath);
|
|
214
215
|
await (0, node_fs_promises.rm)(outputPath, {
|
|
215
216
|
recursive: true,
|
|
@@ -251,21 +252,23 @@ function makeGraphQLQuery({ queryName, input, client, enableSubscription = false
|
|
|
251
252
|
const otwQueryName = `${(0, es_toolkit.capitalize)(queryName)}Query`;
|
|
252
253
|
const argsString = stringifyArgumentObjectToGraphqlList(input?.[argsKey] ?? {});
|
|
253
254
|
const operationString = (operationVerb) => `${operationVerb} ${otwQueryName} { ${queryName}${argsString} ${input ? `{ ${stringifySelection(input)} }` : ""}}`;
|
|
254
|
-
|
|
255
|
-
const
|
|
255
|
+
const awaitedReturnValueReference = {};
|
|
256
|
+
const source = (0, wonka.pipe)((0, wonka.merge)([client.query(operationString("query"), {}), enableSubscription ? client.subscription(operationString("subscription"), {}) : wonka.empty]), wonka.share, (0, wonka.map)((v) => {
|
|
256
257
|
const data = v.data?.[queryName];
|
|
257
258
|
if (!data && v.error) throw v.error;
|
|
258
259
|
return data;
|
|
259
260
|
}), (0, wonka.onPush)((data) => {
|
|
260
|
-
if (
|
|
261
|
-
})
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
261
|
+
if (typeof data === "object" && data !== null) Object.assign(awaitedReturnValueReference, data);
|
|
262
|
+
}));
|
|
263
|
+
const observable = (0, wonka.toObservable)(source);
|
|
264
|
+
const promise = (0, wonka.toPromise)((0, wonka.pipe)(source, (0, wonka.take)(1), (0, wonka.map)((data) => {
|
|
265
|
+
if (typeof data === "object" && data !== null) {
|
|
266
|
+
Object.assign(awaitedReturnValueReference, data);
|
|
267
|
+
Object.assign(awaitedReturnValueReference, observable);
|
|
268
|
+
return awaitedReturnValueReference;
|
|
269
|
+
}
|
|
270
|
+
return data;
|
|
271
|
+
})));
|
|
269
272
|
Object.assign(promise, observable);
|
|
270
273
|
return promise;
|
|
271
274
|
}
|
|
@@ -278,10 +281,7 @@ function makeGraphQLMutation({ mutationName, input, client }) {
|
|
|
278
281
|
return data;
|
|
279
282
|
}));
|
|
280
283
|
const observable = (0, wonka.toObservable)(response);
|
|
281
|
-
const promise = (0, wonka.toPromise)(
|
|
282
|
-
Object.assign(res, observable);
|
|
283
|
-
return res;
|
|
284
|
-
});
|
|
284
|
+
const promise = (0, wonka.toPromise)((0, wonka.pipe)(response, (0, wonka.take)(1)));
|
|
285
285
|
Object.assign(promise, observable);
|
|
286
286
|
return promise;
|
|
287
287
|
}
|
|
@@ -1136,14 +1136,15 @@ const createWhereArgImplementer = ({ db, schemaBuilder, enumImplementer }) => {
|
|
|
1136
1136
|
//#region lib/client/client.ts
|
|
1137
1137
|
const clientCreatorImplementer = ({ builtSchema }) => {
|
|
1138
1138
|
if (process.env.NODE_ENV !== "development") console.warn("Running rumble client generation in non development mode. Are you sure this is correct?");
|
|
1139
|
-
const clientCreator = async ({ apiUrl, outputPath, rumbleImportPath, useExternalUrqlClient }) => {
|
|
1139
|
+
const clientCreator = async ({ apiUrl, outputPath, rumbleImportPath, useExternalUrqlClient, removeExisting }) => {
|
|
1140
1140
|
if (process.env.NODE_ENV !== "development") console.warn("Running rumble client generation in non development mode. Are you sure this is correct?");
|
|
1141
1141
|
await generateFromSchema({
|
|
1142
1142
|
schema: builtSchema(),
|
|
1143
1143
|
outputPath,
|
|
1144
1144
|
rumbleImportPath,
|
|
1145
1145
|
apiUrl,
|
|
1146
|
-
useExternalUrqlClient
|
|
1146
|
+
useExternalUrqlClient,
|
|
1147
|
+
removeExisting
|
|
1147
1148
|
});
|
|
1148
1149
|
};
|
|
1149
1150
|
return clientCreator;
|