@m1212e/rumble 0.11.4 → 0.11.6
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 +13 -1
- package/index.cjs +19 -65
- package/index.cjs.map +1 -1
- package/index.d.cts +0 -14
- package/index.d.ts +0 -14
- package/index.js +19 -65
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -270,4 +270,16 @@ users.subscribe((s) => s?.at(0));
|
|
|
270
270
|
|
|
271
271
|
// you can directly access the values of an awaited result
|
|
272
272
|
console.log(users.firstName)
|
|
273
|
-
```
|
|
273
|
+
```
|
|
274
|
+
### Alternative
|
|
275
|
+
As an alternative to use the client generator with a fully instanciated rumble instance, you can also import the `generateFromSchema` function from rumble and pass it a standard `GraphQLSchema` object to generate the client:
|
|
276
|
+
```ts
|
|
277
|
+
import { generateFromSchema } from "@m1212e/rumble";
|
|
278
|
+
|
|
279
|
+
await generateFromSchema({
|
|
280
|
+
// a schema object: https://github.com/graphql/graphql-js/blob/60ae6c48b9c78332bf3d6036e7d931a3617d0674/src/type/schema.ts#L130
|
|
281
|
+
schema: yourGraphQLSchemaObject
|
|
282
|
+
outputPath: "./generated";
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
This might become handy in separate code bases for api and client.
|
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var promises=require('fs/promises'),path=require('path'),esToolkit=require('es-toolkit'),wonka=require('wonka'),graphqlArmor=require('@escape.tech/graphql-armor'),pluginDisableIntrospection=require('@graphql-yoga/plugin-disable-introspection'),graphqlYoga=require('graphql-yoga'),sofaApi=require('sofa-api'),drizzleOrm=require('drizzle-orm'),casing=require('drizzle-orm/casing'),pgCore=require('drizzle-orm/pg-core'),pluralize=require('pluralize'),mysqlCore=require('drizzle-orm/mysql-core'),sqliteCore=require('drizzle-orm/sqlite-core'),
|
|
1
|
+
'use strict';var promises=require('fs/promises'),path=require('path'),graphql=require('graphql'),esToolkit=require('es-toolkit'),wonka=require('wonka'),graphqlArmor=require('@escape.tech/graphql-armor'),pluginDisableIntrospection=require('@graphql-yoga/plugin-disable-introspection'),graphqlYoga=require('graphql-yoga'),sofaApi=require('sofa-api'),drizzleOrm=require('drizzle-orm'),casing=require('drizzle-orm/casing'),pgCore=require('drizzle-orm/pg-core'),pluralize=require('pluralize'),mysqlCore=require('drizzle-orm/mysql-core'),sqliteCore=require('drizzle-orm/sqlite-core'),Jt=require('@pothos/core'),tn=require('@pothos/plugin-drizzle'),nn=require('@pothos/plugin-smart-subscriptions'),graphqlScalars=require('graphql-scalars');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Jt__default=/*#__PURE__*/_interopDefault(Jt);var tn__default=/*#__PURE__*/_interopDefault(tn);var nn__default=/*#__PURE__*/_interopDefault(nn);function ye({apiUrl:e,rumbleImportPath:n,useExternalUrqlClient:r,availableSubscriptions:i}){let o=[],t="";return typeof r=="string"?o.push(`import { urqlClient } from "${r}";`):(o.push("import { Client, fetchExchange } from '@urql/core';"),o.push("import { cacheExchange } from '@urql/exchange-graphcache';")),o.push(`import { makeLiveQuery, makeMutation, makeSubscription, makeQuery } from '${n}';`),r||(t+=`
|
|
2
2
|
const urqlClient = new Client({
|
|
3
3
|
url: "${e??"PLEASE PROVIDE A URL WHEN GENERATING OR IMPORT AN EXTERNAL URQL CLIENT"}",
|
|
4
4
|
fetchSubscriptions: true,
|
|
@@ -8,7 +8,7 @@ const urqlClient = new Client({
|
|
|
8
8
|
},
|
|
9
9
|
requestPolicy: "cache-and-network",
|
|
10
10
|
});
|
|
11
|
-
`),
|
|
11
|
+
`),t+=`
|
|
12
12
|
export const client = {
|
|
13
13
|
/**
|
|
14
14
|
* A query and subscription combination. First queries and if exists, also subscribes to a subscription of the same name.
|
|
@@ -18,7 +18,7 @@ export const client = {
|
|
|
18
18
|
*/
|
|
19
19
|
liveQuery: makeLiveQuery<Query>({
|
|
20
20
|
urqlClient,
|
|
21
|
-
availableSubscriptions: new Set([${
|
|
21
|
+
availableSubscriptions: new Set([${i.values().toArray().map(l=>`"${l}"`).join(", ")}]),
|
|
22
22
|
}),
|
|
23
23
|
/**
|
|
24
24
|
* A mutation that can be used to e.g. create, update or delete data.
|
|
@@ -38,74 +38,28 @@ export const client = {
|
|
|
38
38
|
query: makeQuery<Query>({
|
|
39
39
|
urqlClient,
|
|
40
40
|
}),
|
|
41
|
-
}`,{imports:o,code:
|
|
42
|
-
|
|
43
|
-
`)}function Ht(e){let t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}var L=class e extends Error{constructor(t,...n){var r,o,i;let{nodes:s,source:l,positions:u,path:p,originalError:a,extensions:m}=Ht(n);super(t),this.name="GraphQLError",this.path=p??void 0,this.originalError=a??void 0,this.nodes=it(Array.isArray(s)?s:s?[s]:void 0);let c=it((r=this.nodes)===null||r===void 0?void 0:r.map(h=>h.loc).filter(h=>h!=null));this.source=l??(c==null||(o=c[0])===null||o===void 0?void 0:o.source),this.positions=u??c?.map(h=>h.start),this.locations=u&&l?u.map(h=>re(l,h)):c?.map(h=>re(h.source,h.start));let x=ce(a?.extensions)?a?.extensions:void 0;this.extensions=(i=m??x)!==null&&i!==void 0?i:Object.create(null),Object.defineProperties(this,{message:{writable:true,enumerable:true},name:{enumerable:false},nodes:{enumerable:false},source:{enumerable:false},positions:{enumerable:false},originalError:{enumerable:false}}),a!=null&&a.stack?Object.defineProperty(this,"stack",{value:a.stack,writable:true,configurable:true}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:true,configurable:true});}get[Symbol.toStringTag](){return "GraphQLError"}toString(){let t=this.message;if(this.nodes)for(let n of this.nodes)n.loc&&(t+=`
|
|
44
|
-
|
|
45
|
-
`+rt(n.loc));else if(this.source&&this.locations)for(let n of this.locations)t+=`
|
|
46
|
-
|
|
47
|
-
`+Re(this.source,n);return t}toJSON(){let t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}};function it(e){return e===void 0||e.length===0?void 0:e}var ve={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Xt=new Set(Object.keys(ve));function Oe(e){let t=e?.kind;return typeof t=="string"&&Xt.has(t)}var ot;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription";})(ot||(ot={}));var B;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";})(B||(B={}));function Le(e){return e===9||e===32}function Zt(e){return e>=48&&e<=57}function st(e){return e>=97&&e<=122||e>=65&&e<=90}function at(e){return st(e)||e===95}function lt(e){return st(e)||Zt(e)||e===95}function ut(e,t){let n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),o=r.length===1,i=r.length>1&&r.slice(1).every(x=>x.length===0||Le(x.charCodeAt(0))),s=n.endsWith('\\"""'),l=e.endsWith('"')&&!s,u=e.endsWith("\\"),p=l||u,a=(!o||e.length>70||p||i||s),m="",c=o&&Le(e.charCodeAt(0));return (a&&!c||i)&&(m+=`
|
|
48
|
-
`),m+=n,(a||p)&&(m+=`
|
|
49
|
-
`),'"""'+m+'"""'}function P(e){return me(e,[])}function me(e,t){switch(typeof e){case "string":return JSON.stringify(e);case "function":return e.name?`[function ${e.name}]`:"[function]";case "object":return en(e,t);default:return String(e)}}function en(e,t){if(e===null)return "null";if(t.includes(e))return "[Circular]";let n=[...t,e];if(tn(e)){let r=e.toJSON();if(r!==e)return typeof r=="string"?r:me(r,n)}else if(Array.isArray(e))return rn(e,n);return nn(e,n)}function tn(e){return typeof e.toJSON=="function"}function nn(e,t){let n=Object.entries(e);return n.length===0?"{}":t.length>2?"["+on(e)+"]":"{ "+n.map(([o,i])=>o+": "+me(i,t)).join(", ")+" }"}function rn(e,t){if(e.length===0)return "[]";if(t.length>2)return "[Array]";let n=Math.min(10,e.length),r=e.length-n,o=[];for(let i=0;i<n;++i)o.push(me(e[i],t));return r===1?o.push("... 1 more item"):r>1&&o.push(`... ${r} more items`),"["+o.join(", ")+"]"}function on(e){let t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){let n=e.constructor.name;if(typeof n=="string"&&n!=="")return n}return t}var sn=globalThis.process&&process.env.NODE_ENV==="production",z=sn?function(t,n){return t instanceof n}:function(t,n){if(t instanceof n)return true;if(typeof t=="object"&&t!==null){var r;let o=n.prototype[Symbol.toStringTag],i=Symbol.toStringTag in t?t[Symbol.toStringTag]:(r=t.constructor)===null||r===void 0?void 0:r.name;if(o===i){let s=P(t);throw new Error(`Cannot use ${o} "${s}" from another module or realm.
|
|
50
|
-
|
|
51
|
-
Ensure that there is only one instance of "graphql" in the node_modules
|
|
52
|
-
directory. If different versions of "graphql" are the dependencies of other
|
|
53
|
-
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
54
|
-
|
|
55
|
-
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
56
|
-
|
|
57
|
-
Duplicate "graphql" modules cannot be used at the same time since different
|
|
58
|
-
versions may have different capabilities and behavior. The data from one
|
|
59
|
-
version used in the function from another could produce confusing and
|
|
60
|
-
spurious results.`)}}return false};function pt(e,t){let[n,r]=t?[e,t]:[void 0,e],o=" Did you mean ";n&&(o+=n+" ");let i=r.map(u=>`"${u}"`);switch(i.length){case 0:return "";case 1:return o+i[0]+"?";case 2:return o+i[0]+" or "+i[1]+"?"}let s=i.slice(0,5),l=s.pop();return o+s.join(", ")+", or "+l+"?"}function Be(e){return e}function ct(e,t){let n=Object.create(null);for(let r of e)n[t(r)]=r;return n}function ie(e,t,n){let r=Object.create(null);for(let o of e)r[t(o)]=n(o);return r}function oe(e,t){let n=Object.create(null);for(let r of Object.keys(e))n[r]=t(e[r],r);return n}function mt(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let o=e.charCodeAt(n),i=t.charCodeAt(r);if(fe(o)&&fe(i)){let s=0;do++n,s=s*10+o-we,o=e.charCodeAt(n);while(fe(o)&&s>0);let l=0;do++r,l=l*10+i-we,i=t.charCodeAt(r);while(fe(i)&&l>0);if(s<l)return -1;if(s>l)return 1}else {if(o<i)return -1;if(o>i)return 1;++n,++r;}}return e.length-t.length}var we=48,an=57;function fe(e){return !isNaN(e)&&we<=e&&e<=an}function dt(e,t){let n=Object.create(null),r=new Pe(e),o=Math.floor(e.length*.4)+1;for(let i of t){let s=r.measure(i,o);s!==void 0&&(n[i]=s);}return Object.keys(n).sort((i,s)=>{let l=n[i]-n[s];return l!==0?l:mt(i,s)})}var Pe=class{constructor(t){this._input=t,this._inputLowerCase=t.toLowerCase(),this._inputArray=ft(this._inputLowerCase),this._rows=[new Array(t.length+1).fill(0),new Array(t.length+1).fill(0),new Array(t.length+1).fill(0)];}measure(t,n){if(this._input===t)return 0;let r=t.toLowerCase();if(this._inputLowerCase===r)return 1;let o=ft(r),i=this._inputArray;if(o.length<i.length){let a=o;o=i,i=a;}let s=o.length,l=i.length;if(s-l>n)return;let u=this._rows;for(let a=0;a<=l;a++)u[0][a]=a;for(let a=1;a<=s;a++){let m=u[(a-1)%3],c=u[a%3],x=c[0]=a;for(let h=1;h<=l;h++){let y=o[a-1]===i[h-1]?0:1,T=Math.min(m[h]+1,c[h-1]+1,m[h-1]+y);if(a>1&&h>1&&o[a-1]===i[h-2]&&o[a-2]===i[h-1]){let N=u[(a-2)%3][h-2];T=Math.min(T,N+1);}T<x&&(x=T),c[h]=T;}if(x>n)return}let p=u[s%3][l];return p<=n?p:void 0}};function ft(e){let t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function k(e){if(e==null)return Object.create(null);if(Object.getPrototypeOf(e)===null)return e;let t=Object.create(null);for(let[n,r]of Object.entries(e))t[n]=r;return t}function yt(e){return `"${e.replace(ln,un)}"`}var ln=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function un(e){return pn[e.charCodeAt(0)]}var pn=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];var cn=Object.freeze({});function ht(e,t,n=ve){let r=new Map;for(let N of Object.values(B))r.set(N,mn(t,N));let o,i=Array.isArray(e),s=[e],l=-1,u=[],p=e,a,m,c=[],x=[];do{l++;let N=l===s.length,g=N&&u.length!==0;if(N){if(a=x.length===0?void 0:c[c.length-1],p=m,m=x.pop(),g)if(i){p=p.slice();let R=0;for(let[I,E]of u){let b=I-R;E===null?(p.splice(b,1),R++):p[b]=E;}}else {p={...p};for(let[R,I]of u)p[R]=I;}l=o.index,s=o.keys,u=o.edits,i=o.inArray,o=o.prev;}else if(m){if(a=i?l:s[l],p=m[a],p==null)continue;c.push(a);}let D;if(!Array.isArray(p)){var h,y;Oe(p)||C(false,`Invalid AST Node: ${P(p)}.`);let R=N?(h=r.get(p.kind))===null||h===void 0?void 0:h.leave:(y=r.get(p.kind))===null||y===void 0?void 0:y.enter;if(D=R?.call(t,p,a,m,c,x),D===cn)break;if(D===false){if(!N){c.pop();continue}}else if(D!==void 0&&(u.push([a,D]),!N))if(Oe(D))p=D;else {c.pop();continue}}if(D===void 0&&g&&u.push([a,p]),N)c.pop();else {var T;o={inArray:i,index:l,keys:s,edits:u,prev:o},i=Array.isArray(p),s=i?p:(T=n[p.kind])!==null&&T!==void 0?T:[],l=-1,u=[],m&&x.push(m),m=p;}}while(o!==void 0);return u.length!==0?u[u.length-1][1]:e}function mn(e,t){let n=e[t];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function Fe(e){return ht(e,dn)}var fn=80,dn={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>f(e.definitions,`
|
|
61
|
-
|
|
62
|
-
`)},OperationDefinition:{leave(e){let t=S("(",f(e.variableDefinitions,", "),")"),n=f([e.operation,f([e.name,t]),f(e.directives," ")]," ");return (n==="query"?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+S(" = ",n)+S(" ",f(r," "))},SelectionSet:{leave:({selections:e})=>q(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:o}){let i=S("",e,": ")+t,s=i+S("(",f(n,", "),")");return s.length>fn&&(s=i+S(`(
|
|
63
|
-
`,de(f(n,`
|
|
64
|
-
`)),`
|
|
65
|
-
)`)),f([s,f(r," "),o]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+S(" ",f(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>f(["...",S("on ",e),f(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:o})=>`fragment ${e}${S("(",f(n,", "),")")} on ${t} ${S("",f(r," ")," ")}`+o},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?ut(e):yt(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+f(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+f(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+S("(",f(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>S("",e,`
|
|
66
|
-
`)+f(["schema",f(t," "),q(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>S("",e,`
|
|
67
|
-
`)+f(["scalar",t,f(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:o})=>S("",e,`
|
|
68
|
-
`)+f(["type",t,S("implements ",f(n," & ")),f(r," "),q(o)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:o})=>S("",e,`
|
|
69
|
-
`)+t+(bt(n)?S(`(
|
|
70
|
-
`,de(f(n,`
|
|
71
|
-
`)),`
|
|
72
|
-
)`):S("(",f(n,", "),")"))+": "+r+S(" ",f(o," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:o})=>S("",e,`
|
|
73
|
-
`)+f([t+": "+n,S("= ",r),f(o," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:o})=>S("",e,`
|
|
74
|
-
`)+f(["interface",t,S("implements ",f(n," & ")),f(r," "),q(o)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>S("",e,`
|
|
75
|
-
`)+f(["union",t,f(n," "),S("= ",f(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>S("",e,`
|
|
76
|
-
`)+f(["enum",t,f(n," "),q(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>S("",e,`
|
|
77
|
-
`)+f([t,f(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>S("",e,`
|
|
78
|
-
`)+f(["input",t,f(n," "),q(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:o})=>S("",e,`
|
|
79
|
-
`)+"directive @"+t+(bt(n)?S(`(
|
|
80
|
-
`,de(f(n,`
|
|
81
|
-
`)),`
|
|
82
|
-
)`):S("(",f(n,", "),")"))+(r?" repeatable":"")+" on "+f(o," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>f(["extend schema",f(e," "),q(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>f(["extend scalar",e,f(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>f(["extend type",e,S("implements ",f(t," & ")),f(n," "),q(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>f(["extend interface",e,S("implements ",f(t," & ")),f(n," "),q(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>f(["extend union",e,f(t," "),S("= ",f(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>f(["extend enum",e,f(t," "),q(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>f(["extend input",e,f(t," "),q(n)]," ")}};function f(e,t=""){var n;return (n=e?.filter(r=>r).join(t))!==null&&n!==void 0?n:""}function q(e){return S(`{
|
|
83
|
-
`,de(f(e,`
|
|
84
|
-
`)),`
|
|
85
|
-
}`)}function S(e,t,n=""){return t!=null&&t!==""?e+t+n:""}function de(e){return S(" ",e.replace(/\n/g,`
|
|
86
|
-
`))}function bt(e){var t;return (t=e?.some(n=>n.includes(`
|
|
87
|
-
`)))!==null&&t!==void 0?t:false}function ye(e,t){switch(e.kind){case B.NULL:return null;case B.INT:return parseInt(e.value,10);case B.FLOAT:return parseFloat(e.value);case B.STRING:case B.ENUM:case B.BOOLEAN:return e.value;case B.LIST:return e.values.map(n=>ye(n,t));case B.OBJECT:return ie(e.fields,n=>n.name.value,n=>ye(n.value,t));case B.VARIABLE:return t?.[e.name.value]}}function Q(e){if(e!=null||C(false,"Must provide name."),typeof e=="string"||C(false,"Expected name to be a string."),e.length===0)throw new L("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!lt(e.charCodeAt(t)))throw new L(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!at(e.charCodeAt(0)))throw new L(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function je(e){if(e==="true"||e==="false"||e==="null")throw new L(`Enum values cannot be named: ${e}`);return Q(e)}function be(e){return _e(e)||Qe(e)||ke(e)||qe(e)||ze(e)||Ue(e)||Ge(e)||ge(e)}function _e(e){return z(e,W)}function Qe(e){return z(e,J)}function ke(e){return z(e,se)}function qe(e){return z(e,ae)}function ze(e){return z(e,X)}function Ue(e){return z(e,K)}function Ge(e){return z(e,M)}function ge(e){return z(e,U)}var M=class{constructor(t){be(t)||C(false,`Expected ${P(t)} to be a GraphQL type.`),this.ofType=t;}get[Symbol.toStringTag](){return "GraphQLList"}toString(){return "["+String(this.ofType)+"]"}toJSON(){return this.toString()}},U=class{constructor(t){$e(t)||C(false,`Expected ${P(t)} to be a GraphQL nullable type.`),this.ofType=t;}get[Symbol.toStringTag](){return "GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}};function $e(e){return be(e)&&!ge(e)}function Te(e){return typeof e=="function"?e():e}function xe(e){return typeof e=="function"?e():e}var W=class{constructor(t){var n,r,o,i;let s=(n=t.parseValue)!==null&&n!==void 0?n:Be;this.name=Q(t.name),this.description=t.description,this.specifiedByURL=t.specifiedByURL,this.serialize=(r=t.serialize)!==null&&r!==void 0?r:Be,this.parseValue=s,this.parseLiteral=(o=t.parseLiteral)!==null&&o!==void 0?o:(l,u)=>s(ye(l,u)),this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(i=t.extensionASTNodes)!==null&&i!==void 0?i:[],t.specifiedByURL==null||typeof t.specifiedByURL=="string"||C(false,`${this.name} must provide "specifiedByURL" as a string, but got: ${P(t.specifiedByURL)}.`),t.serialize==null||typeof t.serialize=="function"||C(false,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),t.parseLiteral&&(typeof t.parseValue=="function"&&typeof t.parseLiteral=="function"||C(false,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`));}get[Symbol.toStringTag](){return "GraphQLScalarType"}toConfig(){return {name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}},J=class{constructor(t){var n;this.name=Q(t.name),this.description=t.description,this.isTypeOf=t.isTypeOf,this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>xt(t),this._interfaces=()=>Tt(t),t.isTypeOf==null||typeof t.isTypeOf=="function"||C(false,`${this.name} must provide "isTypeOf" as a function, but got: ${P(t.isTypeOf)}.`);}get[Symbol.toStringTag](){return "GraphQLObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return {name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:St(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function Tt(e){var t;let n=Te((t=e.interfaces)!==null&&t!==void 0?t:[]);return Array.isArray(n)||C(false,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function xt(e){let t=xe(e.fields);return Z(t)||C(false,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),oe(t,(n,r)=>{var o;Z(n)||C(false,`${e.name}.${r} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||C(false,`${e.name}.${r} field resolver must be a function if provided, but got: ${P(n.resolve)}.`);let i=(o=n.args)!==null&&o!==void 0?o:{};return Z(i)||C(false,`${e.name}.${r} args must be an object with argument names as keys.`),{name:Q(r),description:n.description,type:n.type,args:yn(i),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:k(n.extensions),astNode:n.astNode}})}function yn(e){return Object.entries(e).map(([t,n])=>({name:Q(t),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:k(n.extensions),astNode:n.astNode}))}function Z(e){return ce(e)&&!Array.isArray(e)}function St(e){return oe(e,t=>({description:t.description,type:t.type,args:hn(t.args),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}function hn(e){return ie(e,t=>t.name,t=>({description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}var se=class{constructor(t){var n;this.name=Q(t.name),this.description=t.description,this.resolveType=t.resolveType,this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=xt.bind(void 0,t),this._interfaces=Tt.bind(void 0,t),t.resolveType==null||typeof t.resolveType=="function"||C(false,`${this.name} must provide "resolveType" as a function, but got: ${P(t.resolveType)}.`);}get[Symbol.toStringTag](){return "GraphQLInterfaceType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return {name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:St(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}},ae=class{constructor(t){var n;this.name=Q(t.name),this.description=t.description,this.resolveType=t.resolveType,this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._types=bn.bind(void 0,t),t.resolveType==null||typeof t.resolveType=="function"||C(false,`${this.name} must provide "resolveType" as a function, but got: ${P(t.resolveType)}.`);}get[Symbol.toStringTag](){return "GraphQLUnionType"}getTypes(){return typeof this._types=="function"&&(this._types=this._types()),this._types}toConfig(){return {name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function bn(e){let t=Te(e.types);return Array.isArray(t)||C(false,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}var X=class{constructor(t){var n;this.name=Q(t.name),this.description=t.description,this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._values=typeof t.values=="function"?t.values:gt(this.name,t.values),this._valueLookup=null,this._nameLookup=null;}get[Symbol.toStringTag](){return "GraphQLEnumType"}getValues(){return typeof this._values=="function"&&(this._values=gt(this.name,this._values())),this._values}getValue(t){return this._nameLookup===null&&(this._nameLookup=ct(this.getValues(),n=>n.name)),this._nameLookup[t]}serialize(t){this._valueLookup===null&&(this._valueLookup=new Map(this.getValues().map(r=>[r.value,r])));let n=this._valueLookup.get(t);if(n===void 0)throw new L(`Enum "${this.name}" cannot represent value: ${P(t)}`);return n.name}parseValue(t){if(typeof t!="string"){let r=P(t);throw new L(`Enum "${this.name}" cannot represent non-string value: ${r}.`+he(this,r))}let n=this.getValue(t);if(n==null)throw new L(`Value "${t}" does not exist in "${this.name}" enum.`+he(this,t));return n.value}parseLiteral(t,n){if(t.kind!==B.ENUM){let o=Fe(t);throw new L(`Enum "${this.name}" cannot represent non-enum value: ${o}.`+he(this,o),{nodes:t})}let r=this.getValue(t.value);if(r==null){let o=Fe(t);throw new L(`Value "${o}" does not exist in "${this.name}" enum.`+he(this,o),{nodes:t})}return r.value}toConfig(){let t=ie(this.getValues(),n=>n.name,n=>({description:n.description,value:n.value,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return {name:this.name,description:this.description,values:t,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function he(e,t){let n=e.getValues().map(o=>o.name),r=dt(t,n);return pt("the enum value",r)}function gt(e,t){return Z(t)||C(false,`${e} values must be an object with value names as keys.`),Object.entries(t).map(([n,r])=>(Z(r)||C(false,`${e}.${n} must refer to an object with a "value" key representing an internal value but got: ${P(r)}.`),{name:je(n),description:r.description,value:r.value!==void 0?r.value:n,deprecationReason:r.deprecationReason,extensions:k(r.extensions),astNode:r.astNode}))}var K=class{constructor(t){var n,r;this.name=Q(t.name),this.description=t.description,this.extensions=k(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this.isOneOf=(r=t.isOneOf)!==null&&r!==void 0?r:false,this._fields=gn.bind(void 0,t);}get[Symbol.toStringTag](){return "GraphQLInputObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}toConfig(){let t=oe(this.getFields(),n=>({description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return {name:this.name,description:this.description,fields:t,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,isOneOf:this.isOneOf}}toString(){return this.name}toJSON(){return this.toString()}};function gn(e){let t=xe(e.fields);return Z(t)||C(false,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),oe(t,(n,r)=>(!("resolve"in n)||C(false,`${e.name}.${r} field has a resolve property, but Input Types cannot define resolvers.`),{name:Q(r),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:k(n.extensions),astNode:n.astNode}))}function Ve(e){if(e instanceof J)return Kn(e);if(e instanceof W)return er(e);if(e instanceof X)return tr(e);if(e instanceof K)return Yn(e)}function Kn(e){let t=new Map;for(let[n,r]of Object.entries(e.getFields()))t.set(n,Hn(r.type,r.args));return `{
|
|
88
|
-
${t.entries().map(([n,r])=>`${n}: ${r}`).toArray().join(`,
|
|
41
|
+
}`,{imports:o,code:t}}function he(e){if(e instanceof graphql.GraphQLObjectType)return nt(e);if(e instanceof graphql.GraphQLScalarType)return at(e);if(e instanceof graphql.GraphQLEnumType)return lt(e);if(e instanceof graphql.GraphQLInputObjectType)return rt(e);throw new Error(`Unknown model type: ${e}`)}function nt(e){let n=new Map;for(let[r,i]of Object.entries(e.getFields()))n.set(r,it(i.type,i.args));return `{
|
|
42
|
+
${n.entries().map(([r,i])=>`${r}: ${i}`).toArray().join(`,
|
|
89
43
|
`)}
|
|
90
|
-
}`}function
|
|
91
|
-
${
|
|
44
|
+
}`}function rt(e){let n=new Map;for(let[r,i]of Object.entries(e.getFields()))n.set(r,ot(i.type));return `{
|
|
45
|
+
${n.entries().map(([r,i])=>`${r}${i.includes("| undefined")?"?":""}: ${i}`).toArray().join(`,
|
|
92
46
|
`)}
|
|
93
|
-
}`}function
|
|
94
|
-
${
|
|
47
|
+
}`}function it(e,n){let r=false,i=false;for(let a=0;a<3;a++)e instanceof graphql.GraphQLList&&(i=true,e=e.ofType),e instanceof graphql.GraphQLNonNull&&(r=true,e=e.ofType);let o=e.name;i&&(o+="[]"),r||(o+=" | null");let t=e instanceof graphql.GraphQLObjectType,l=new Map;for(let a of n??[])l.set(a.name,st(a.type));if(t){let a=l.entries().every(([,m])=>m.includes("| undefined"));return `(${(n??[]).length>0?`p${a?"?":""}: {
|
|
48
|
+
${l.entries().map(([m,u])=>` ${m}${u.includes("| undefined")?"?":""}: ${u}`).toArray().join(`,
|
|
95
49
|
`)}
|
|
96
|
-
}`:""}) => ${o}`}else return o}function
|
|
97
|
-
export type ${
|
|
98
|
-
`);let
|
|
50
|
+
}`:""}) => ${o}`}else return o}function ot(e){let n=false,r=false;for(let o=0;o<3;o++)e instanceof graphql.GraphQLList&&(r=true,e=e.ofType),e instanceof graphql.GraphQLNonNull&&(n=true,e=e.ofType);let i=e.name;return r&&(i+="[]"),n?r&&(i+=" | undefined"):i+=" | null | undefined",i}function st(e){let n="unknown",r=true;return e instanceof graphql.GraphQLNonNull&&(r=false,e=e.ofType),(e instanceof graphql.GraphQLInputObjectType||e instanceof graphql.GraphQLScalarType)&&(n=e.name),r&&(n+=" | null | undefined"),n}function at(e){switch(e.name){case "ID":return "string";case "String":return "string";case "Boolean":return "boolean";case "Int":return "number";case "Float":return "number";case "Date":return "Date";case "DateTime":return "Date";case "JSON":return "any";default:return "unknown"}}function lt(e){return e.getValues().map(n=>`"${n.name}"`).join(" | ")}async function oe({outputPath:e,schema:n,rumbleImportPath:r="@m1212e/rumble",apiUrl:i,useExternalUrqlClient:o=false}){try{await promises.access(e),await promises.rm(e,{recursive:!0,force:!0});}catch{}await promises.mkdir(e,{recursive:true}),e.endsWith("/")||(e+="/");let t=[],l="",a=new Map;for(let[m,u]of Object.entries(n.getTypeMap()))m.startsWith("__")||a.set(m,u);for(let[m,u]of a.entries()){let d=he(u);d!==m&&(l+=`
|
|
51
|
+
export type ${m} = ${d};
|
|
52
|
+
`);}let s=ye({apiUrl:i,useExternalUrqlClient:o,rumbleImportPath:r,availableSubscriptions:new Set(Object.keys(n.getSubscriptionType()?.getFields()||{}))});t.push(...s.imports),l+=s.code,await promises.writeFile(path.join(e,"client.ts"),`${t.join(`
|
|
99
53
|
`)}
|
|
100
|
-
${
|
|
101
|
-
`,
|
|
102
|
-
`;}else
|
|
103
|
-
`;return
|
|
54
|
+
${l}`);}var O="__args";function W({queryName:e,input:n,client:r,enableSubscription:i=false}){let o=`${esToolkit.capitalize(e)}Query`,t=_(n[O]??{}),l=u=>`${u} ${o} { ${e}${t} { ${U(n)} }}`,a,s=wonka.pipe(wonka.merge([r.query(l("query"),{}),i?r.subscription(l("subscription"),{}):wonka.empty]),wonka.map(u=>{let d=u.data?.[e];if(!d&&u.error)throw u.error;return d}),wonka.onPush(u=>{a&&Object.assign(a,u);})),m=new Promise(u=>{let d=wonka.toObservable(s).subscribe(p=>{d();let D=wonka.pipe(wonka.merge([s,wonka.fromValue(p)]),wonka.toObservable);a={...p,...D},u(a);}).unsubscribe;});return Object.assign(m,wonka.toObservable(s)),m}function xe({mutationName:e,input:n,client:r}){let i=`${esToolkit.capitalize(e)}Mutation`,o=_(n[O]??{}),t=wonka.pipe(r.mutation(`mutation ${i} { ${e}${o} { ${U(n)} }}`,{}),wonka.map(s=>{let m=s.data?.[e];if(!m&&s.error)throw s.error;return m})),l=wonka.toObservable(t),a=wonka.toPromise(t).then(s=>(Object.assign(s,l),s));return Object.assign(a,l),a}function Se({subscriptionName:e,input:n,client:r}){let i=`${esToolkit.capitalize(e)}Subscription`,o=_(n[O]??{});return wonka.pipe(r.subscription(`subscription ${i} { ${e}${o} { ${U(n)} }}`,{}),wonka.map(t=>{let l=t.data?.[e];if(!l&&t.error)throw t.error;return l}),wonka.toObservable)}function U(e){return Object.entries(e).filter(([n])=>n!==O).reduce((n,[r,i])=>{if(typeof i=="object"){if(i[O]){let o=_(i[O]);return n+=`${r}${o} { ${U(i)} }
|
|
55
|
+
`,n}n+=`${r} { ${U(i)} }
|
|
56
|
+
`;}else n+=`${r}
|
|
57
|
+
`;return n},"")}function _(e){let n=Object.entries(e);return n.length===0?"":`(${n.map(([r,i])=>`${r}: ${De(i)}`).join(", ")})`}function De(e){switch(typeof e){case "string":return `"${e}"`;case "number":return `${e}`;case "bigint":return `${e}`;case "boolean":return `${e}`;case "symbol":throw new Error("Cannot stringify a symbol to send as gql arg");case "undefined":return "null";case "object":return `{ ${Object.entries(e).map(([n,r])=>`${n}: ${De(r)}`).join(", ")} }`;case "function":throw new Error("Cannot stringify a function to send as gql arg")}}function ht({urqlClient:e,availableSubscriptions:n}){return new Proxy({},{get:(r,i)=>o=>W({queryName:i,input:o,client:e,enableSubscription:n.has(i)})})}function Tt({urqlClient:e}){return new Proxy({},{get:(n,r)=>i=>xe({mutationName:r,input:i,client:e})})}function xt({urqlClient:e}){return new Proxy({},{get:(n,r)=>i=>W({queryName:r,input:i,client:e,enableSubscription:false})})}function St({urqlClient:e}){return new Proxy({},{get:(n,r)=>i=>Se({subscriptionName:r,input:i,client:e})})}var A=class extends Error{constructor(n){super(n),this.name="RumbleError";}},F=class extends graphql.GraphQLError{};var le=e=>{if(!e)throw new F("Value not found but required (findFirst)");return e},Ct=e=>{let n=e.at(0);if(!n)throw new F("Value not found but required (firstEntry)");return n},Ce=async({filters:e,entities:n,context:r})=>Array.from((await Promise.all(e.map(i=>i({context:r,entities:n})))).reduce((i,o)=>(o.forEach(t=>i.add(t)),i),new Set));function Rt(e){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,r===null?void 0:r]))}function Q(e){let n,r=false;return ()=>(r||(n=e(),r=true),n)}var Re=["serial","int","integer","tinyint","smallint","mediumint"];function M(e){return Re.includes(e)}var Ae=["real","decimal","double","float","numeric"];function K(e){return Ae.includes(e)}var Ie=["string","text","varchar","char","text(256)"];function V(e){return Ie.includes(e)}var Be=["uuid"];function J(e){return Be.includes(e)}var Ne=["boolean"];function H(e){return Ne.includes(e)}var Ee=["timestamp","datetime"];function X(e){return Ee.includes(e)}var Pe=["date"];function Y(e){return Pe.includes(e)}var Le=["json"];function Z(e){return Le.includes(e)}var ee=(e,n)=>new A(`RumbleError: Unknown SQL type '${e}'. Please open an issue (https://github.com/m1212e/rumble/issues) so it can be added. (${n})`);function Qe(e){if(M(e))return {value1:1,value2:2};if(K(e))return {value1:1.1,value2:2.2};if(V(e))return {value1:"a",value2:"b"};if(J(e))return {value1:"fba31870-5528-42d7-b27e-2e5ee657aea5",value2:"fc65db81-c2d1-483d-8a25-a30e2cf6e02d"};if(H(e))return {value1:true,value2:false};if(X(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(Y(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(Z(e))return {value1:{a:1},value2:{b:2}};throw ee(e,"Distinct")}var ue=Symbol.for("drizzle:Name"),we=Symbol.for("drizzle:Columns");function E({dbName:e,tsName:n,table:r,db:i}){let o=r;if(n&&(o=i._.relations.schema[n]),e&&(o=Object.values(i._.relations.schema).find(t=>t[ue]===e)),!o)throw new A(`Could not find schema for ${JSON.stringify({tsName:n,dbName:e,table:r?.[ue]}).toString()}`);return {tableSchema:o,columns:o[we],get primaryColumns(){return Object.entries(o[we]).filter(([,t])=>t.primary).reduce((t,[l,a])=>(t[l]=a,t),{})},relations:i._.relations.config[n],dbName:o[ue],get tsName(){return Object.entries(i._.relations.schema).find(([,t])=>t===o).at(0)}}}function Bt(e){return typeof e!="function"}function Nt(e){return typeof e=="function"&&e.constructor.name!=="AsyncFunction"}var Et=esToolkit.debounce((e,n)=>{console.warn(`
|
|
104
58
|
Warning! No abilities have been registered for
|
|
105
59
|
|
|
106
|
-
${e}/${
|
|
60
|
+
${e}/${n}
|
|
107
61
|
|
|
108
62
|
but has been accessed. This will block everything. If this is intended, you can ignore this warning. If not, please ensure that you register the ability in your ability builder.
|
|
109
|
-
`);},1e3),
|
|
110
|
-
Please ensure that you use the enum at least once as a column of a table!`);u=x.enumValues;}else if(i){let c=Object.entries(e._.relations.schema).find(([,x])=>x===i.config.enum);if(!c)throw new O(`Could not find enum in schema for ${i.name}!`);l=c[0],u=i.enumValues;}if(!l||!u)throw new O("Could not determine enum structure!");let p=s??`${esToolkit.capitalize(casing.toCamelCase(l))}Enum`,a=n.get(p);return a||(a=t.enumType(p,{values:u}),n.set(p,a),a)}};var wt={paths:{"/webhook":{post:{operationId:"webhook_create",description:"Creates a webhook subscription.",tags:[],parameters:[],requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookCreateBody"}}}},responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}}},"/webhook/{id}":{post:{operationId:"webhook_update",description:"Updates a webhook subscription.",parameters:[{name:"id",in:"path",description:"The ID of the webhook to update",required:true,schema:{type:"string"}}],requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookCreateBody"}}}},responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}},delete:{operationId:"webhook_delete",description:"Removes a webhook subscription.",tags:[],parameters:[{name:"id",in:"path",description:"The ID of the webhook to delete",required:true,schema:{type:"string"}}],responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}}}},components:{schemas:{WebhookCreateBody:{type:"object",properties:{subscription:{description:"The subscription to subscribe to. In many cases, these match the available query IDs without the '_query' suffix. E.g., 'findFirstUser_query' -> 'findFirstUser'. See the graphql schema for more details on what subscriptions are available.",type:"string"},variables:{description:"The variables to pass to the subscription.",type:"object"},url:{description:"The URL to send the webhook to.",type:"string"}}},WebhookDetailResponse:{type:"object",properties:{id:{description:"The ID of the webhook. Can be used as reference in update or delete calls.",type:"string"}}},DateTime:{type:"string",format:"date-time"},Date:{type:"string",format:"date"}}}};function Ce({sqlType:e,fieldName:t}){let n;if(["serial","int","integer","tinyint","smallint","mediumint"].includes(e)&&(n="Int"),["real","decimal","double","float"].includes(e)&&(n="Float"),["string","text","varchar","char","text(256)"].includes(e)&&(t&&(t.toLowerCase().endsWith("_id")||t.toLowerCase().endsWith("id"))?n="ID":n="String"),["uuid"].includes(e)&&(n="ID"),["boolean"].includes(e)&&(n="Boolean"),["timestamp","datetime"].includes(e)&&(n="DateTime"),["date"].includes(e)&&(n="Date"),["json"].includes(e)&&(n="JSON"),n!==void 0)return n;throw Ee(e,"SQL to GQL")}function Rr(e){let t=new Set;for(let r of Object.values(e))typeof r=="object"&&(r instanceof pgCore.PgTable?t.add("postgres"):r instanceof mysqlCore.MySqlTable?t.add("mysql"):r instanceof sqliteCore.SQLiteTable&&t.add("sqlite"));let n=Array.from(t);if(n.length===1)return n[0];throw n.length===0?new Error("No tables found in schema, could not determine dialect"):new Error(`Multiple dialects found in schema: ${n.join(", ")}`)}function Pt(e){return Rr(e._.relations.schema)==="postgres"}async function jt(e){if(!Pt(e)){console.info("Database dialect is not compatible with search, skipping search initialization.");return}await e.execute(drizzleOrm.sql`CREATE EXTENSION IF NOT EXISTS pg_trgm;`);}function Ie({search:e,args:t,tableSchema:n,abilities:r}){if(e?.enabled&&t.search&&t.search.length>0){let o=esToolkit.cloneDeep(t.orderBy);t.orderBy=s=>{let l=drizzleOrm.sql.join(Object.entries(o??{}).map(([m,c])=>{if(c==="asc")return drizzleOrm.sql`${s[m]} ASC`;if(c==="desc")return drizzleOrm.sql`${s[m]} DESC`;throw new Error(`Invalid value ${c} for orderBy`)}),drizzleOrm.sql.raw(", ")),u=r.query.many.columns?Object.entries(n.columns).filter(([m])=>r.query.many.columns[m]):Object.entries(n.columns),p=drizzleOrm.sql`GREATEST(${drizzleOrm.sql.join(u.map(([m])=>drizzleOrm.sql`similarity(${s[m]}::TEXT, ${t.search})`),drizzleOrm.sql.raw(", "))}) DESC`;return o?drizzleOrm.sql.join([l,p],drizzleOrm.sql.raw(", ")):p};let i=esToolkit.cloneDeep(t.where);t.where={AND:[i??{},{RAW:s=>drizzleOrm.sql`GREATEST(${drizzleOrm.sql.join(Object.entries(n.columns).map(([l])=>drizzleOrm.sql`similarity(${s[l]}::TEXT, ${t.search})`),drizzleOrm.sql.raw(", "))}) > ${e.threshold??.1}`}]};}}var wr=e=>typeof e!="object"?false:!!Object.keys(e).some(t=>["args","nullable","query","subscribe","description","type","resolve"].find(n=>n===t)),_t=({db:e,search:t,schemaBuilder:n,makePubSubInstance:r,whereArgImplementer:o,orderArgImplementer:i,enumImplementer:s,abilityBuilder:l})=>({table:u,refName:p,readAction:a="read",adjust:m})=>{let c=_({db:e,tsName:u});Object.keys(c.primaryColumns).length===0&&console.warn(`Could not find primary key for ${u.toString()}. Cannot register subscriptions!`);let x=Object.values(c.primaryColumns)[0],{registerOnInstance:h}=r({table:u});return n.drizzleObject(u,{name:p??esToolkit.capitalize(u.toString()),subscribe:(y,T,N)=>{if(!x)return;let g=T[x.name];if(!g){console.warn(`Could not find primary key value for ${JSON.stringify(T)}. Cannot register subscription!`);return}h({instance:y,action:"updated",primaryKeyValue:g});},applyFilters:l?.z_registeredFilters?.[u]?.[a],fields:y=>{let T=c.columns,N=(E,b,d)=>{let A=Ce({sqlType:E,fieldName:b});switch(A){case "Int":return y.exposeInt(b,{nullable:d});case "String":return y.exposeString(b,{nullable:d});case "Boolean":return y.exposeBoolean(b,{nullable:d});case "Date":return y.field({type:"Date",resolve:v=>v[b],nullable:d});case "DateTime":return y.field({type:"DateTime",resolve:v=>v[b],nullable:d});case "Float":return y.exposeFloat(b,{nullable:d});case "ID":return y.exposeID(b,{nullable:d});case "JSON":return y.field({type:"JSON",resolve:v=>v[b],nullable:d});default:throw new O(`Unsupported object type ${A} for column ${b}`)}},g=new Map,D=m?.(new Proxy(y,{get:(E,b)=>typeof E[b]!="function"||b==="arg"||b==="builder"||b==="graphqlKind"||b==="kind"||b==="listRef"||b==="table"||b==="typename"||b==="variant"||b.toString().startsWith("boolean")||b.toString().startsWith("float")||b.toString().startsWith("id")||b.toString().startsWith("int")||b.toString().startsWith("string")||b.toString().startsWith("expose")?E[b]:(...d)=>{let A=E[b](...d),v=d.find(wr);if(!v)throw new O("Expected config object to be passed to adjust field");return g.set(A,{params:d,creatorFunction:E[b],configObject:v}),A}}))??{},R=Object.entries(T).reduce((E,[b,d])=>{if(D[b]){let{params:A,creatorFunction:v,configObject:Y}=g.get(D[b]);return typeof Y.nullable!="boolean"&&(Y.nullable=!d.notNull),D[b]=v.bind(y)(...A),E}if(Ae(d)){let A=s({enumColumn:d});E[b]=y.field({type:A,resolve:v=>v[b],nullable:!d.notNull});}else E[b]=N(d.getSQLType(),b,!d.notNull);return E},{}),I=Object.entries(c.relations??{}).reduce((E,[b,d])=>{let A=_({db:e,table:d.targetTable}),v=o({dbName:A.dbName}),Y=i({dbName:A.dbName}),H=r({table:A.tsName}),$=false,w=true,pe="many";d instanceof drizzleOrm.One&&(w=false,$=d.optional,pe="single");let Xe=(j,ne)=>{H.registerOnInstance({instance:j,action:"created"}),H.registerOnInstance({instance:j,action:"removed"});};if(D[b]){let{params:j,creatorFunction:ne,configObject:V}=g.get(D[b]);return typeof V.nullable!="boolean"&&(V.nullable=$),typeof V.subscribe!="function"&&(V.subscribe=Xe),D[b]=ne.bind(y)(...j),E}let Ze={where:y.arg({type:v,required:false}),orderBy:y.arg({type:Y,required:false}),...w?{offset:y.arg.int({required:false}),limit:y.arg.int({required:false})}:{},search:y.arg.string({required:false})};return (!t?.enabled||!w)&&delete Ze.search,E[b]=y.relation(b,{args:Ze,subscribe:Xe,nullable:$,description:`Get the ${pluralize.plural(A.tsName)} related to this ${pluralize.singular(c.tsName)}`,query:(j,ne)=>{j=JSON.parse(JSON.stringify(j)),w&&Ie({search:t,args:j,tableSchema:A,abilities:ne.abilities[A.tsName].filter(a)});let V=ne.abilities[A.tsName].filter(a,{inject:{where:j.where,limit:j.limit}}).query[pe];return j.offset&&(V.offset=j.offset),j.orderBy&&(V.orderBy=j.orderBy),V}}),E},{});return {...R,...I,...D}}})};var jr=e=>`${esToolkit.capitalize(casing.toCamelCase(e.toString()))}OrderInputArgument`,Qt=({db:e,schemaBuilder:t})=>{let n=new Map,r=G(()=>t.enumType("SortingParameter",{values:["asc","desc"]})),o=({table:i,refName:s,dbName:l})=>{let u=_({db:e,dbName:l,tsName:i}),p=s??jr(u.tsName),a=n.get(p);return a||(a=t.inputType(p,{fields:c=>{let x=Object.entries(u.columns).reduce((y,[T])=>(y[T]=c.field({type:r(),required:false}),y),{}),h=Object.entries(u.relations??{}).reduce((y,[T,N])=>{let g=_({db:e,table:N.targetTable}),D=o({dbName:g.dbName});return y[T]=c.field({type:D,required:false}),y},{});return {...x,...h}}}),n.set(p,a),a)};return o};var _r="RUMBLE_SUBSCRIPTION_NOTIFICATION",Qr="REMOVED",kr="UPDATED",qr="CREATED",qt=({subscriptions:e})=>{let t=e?graphqlYoga.createPubSub(...e):graphqlYoga.createPubSub();return {pubsub:t,makePubSubInstance:({table:r})=>{function o({action:i,tableName:s,primaryKeyValue:l}){let u;switch(i){case "created":u=qr;break;case "removed":u=Qr;break;case "updated":u=kr;break;default:throw new Error(`Unknown action: ${i}`)}return `${_r}/${s}${l?`/${l}`:""}/${u}`}return {registerOnInstance({instance:i,action:s,primaryKeyValue:l}){let u=o({tableName:r.toString(),action:s,primaryKeyValue:l});i.register(u);},created(){let i=o({tableName:r.toString(),action:"created"});return t.publish(i)},removed(){let i=o({tableName:r.toString(),action:"removed"});return t.publish(i)},updated(i){let l=(Array.isArray(i)?i:[i]).map(p=>o({tableName:r.toString(),action:"updated",primaryKeyValue:p})),u=Array.from(new Set(l));for(let p of u)t.publish(p);}}}}};var Gt=({db:e,schemaBuilder:t,search:n,whereArgImplementer:r,orderArgImplementer:o,makePubSubInstance:i})=>({table:s,readAction:l="read",listAction:u="read"})=>{let p=r({table:s}),a=o({table:s}),m=_({db:e,tsName:s}),c=Object.values(m.primaryColumns)[0],{registerOnInstance:x}=i({table:s});return t.queryFields(h=>{let y={where:h.arg({type:p,required:false}),orderBy:h.arg({type:a,required:false}),limit:h.arg.int({required:false}),offset:h.arg.int({required:false}),search:h.arg.string({required:false})};return n?.enabled||delete y.search,{[pluralize.plural(s.toString())]:h.drizzleField({type:[s],nullable:false,smartSubscription:true,description:`List all ${pluralize.plural(s.toString())}`,subscribe:(T,N,g,D,R)=>{x({instance:T,action:"created"}),x({instance:T,action:"removed"});},args:y,resolve:(T,N,g,D,R)=>{g=JSON.parse(JSON.stringify(g)),Ie({search:n,args:g,tableSchema:m,abilities:D.abilities[s].filter(u)});let I=D.abilities[s].filter(u,g.where||g.limit||g.offset?{inject:{where:g.where,limit:g.limit}}:void 0).query.many;g.offset&&(I.offset=g.offset),g.orderBy&&(I.orderBy=g.orderBy);let E=T(I);return I.columns&&(E.columns=I.columns),e.query[s].findMany(E)}}),[pluralize.singular(s.toString())]:h.drizzleField({type:s,nullable:false,smartSubscription:true,description:`Get a single ${pluralize.singular(s.toString())} by ID`,args:{id:h.arg.id({required:true})},resolve:(T,N,g,D,R)=>{g=JSON.parse(JSON.stringify(g));let I=D.abilities[s].filter(l,{inject:{where:{[c.name]:g.id}}}).query.single,E=T(I);return I.columns&&(E.columns=I.columns),e.query[s].findFirst(E).then(Ke)}})}})};var Vt="ManualFiltersPlugin",Mt=Vt,$t="applyFilters",He=class extends zr.BasePlugin{wrapResolve(t,n){return async(r,o,i,s)=>{let l,u=n?.type;if(u.kind==="List"?l=u.type?.ref.currentConfig.pothosOptions[$t]:u.kind==="Object"&&(l=u.ref.currentConfig.pothosOptions[$t]),!l||!Array.isArray(l)||l.length===0)return t(r,o,i,s);let p=await t(r,o,i,s),a=Array.isArray(p)?p:[p],m=Array.isArray(l)?l:[l],c=await Ct({filters:m,entities:a,context:i});return Array.isArray(p)?c:c[0]??null}}};zr__default.default.registerPlugin(Vt,He);var Vr=e=>`${esToolkit.capitalize(casing.toCamelCase(e.toString()))}WhereInputArgument`,Wt=({db:e,schemaBuilder:t,enumImplementer:n})=>{let r=new Map,o=({table:i,refName:s,dbName:l})=>{let u=_({db:e,dbName:l,tsName:i}),p=s??Vr(u.tsName),a=r.get(p);return a||(a=t.inputType(p,{fields:c=>{let x=(T,N)=>{let g=Ce({sqlType:T,fieldName:N});switch(g){case "Int":return c.field({type:"IntWhereInputArgument"});case "String":return c.field({type:"StringWhereInputArgument"});case "Boolean":return c.boolean({required:false});case "Date":return c.field({type:"DateWhereInputArgument"});case "DateTime":return c.field({type:"DateWhereInputArgument"});case "Float":return c.field({type:"FloatWhereInputArgument"});case "ID":return c.id({required:false});case "JSON":return c.field({type:"JSON",required:false});default:throw new O(`Unsupported argument type ${g} for column ${T}`)}},h=Object.entries(u.columns).reduce((T,[N,g])=>{if(Ae(g)){let D=n({enumColumn:g});T[N]=c.field({type:D,required:false});}else T[N]=x(g.getSQLType(),N);return T},{}),y=Object.entries(u.relations??{}).reduce((T,[N,g])=>{let D=_({db:e,table:g.targetTable}),R=o({dbName:D.dbName});return T[N]=c.field({type:R,required:false}),T},{});return {...h,...y}}}),r.set(p,a),a)};return o};function Jt(e){let t=e.inputRef("IntWhereInputArgument").implement({fields:i=>({eq:i.int(),ne:i.int(),gt:i.int(),gte:i.int(),lt:i.int(),lte:i.int(),in:i.intList(),notIn:i.intList(),like:i.string(),ilike:i.string(),notLike:i.string(),notIlike:i.string(),isNull:i.boolean(),isNotNull:i.boolean(),arrayOverlaps:i.intList(),arrayContained:i.intList(),arrayContains:i.intList(),AND:i.field({type:[t]}),OR:i.field({type:[t]}),NOT:i.field({type:t})})}),n=e.inputRef("FloatWhereInputArgument").implement({fields:i=>({eq:i.float(),ne:i.float(),gt:i.float(),gte:i.float(),lt:i.float(),lte:i.float(),in:i.floatList(),notIn:i.floatList(),like:i.string(),ilike:i.string(),notLike:i.string(),notIlike:i.string(),isNull:i.boolean(),isNotNull:i.boolean(),arrayOverlaps:i.floatList(),arrayContained:i.floatList(),arrayContains:i.floatList(),AND:i.field({type:[n]}),OR:i.field({type:[n]}),NOT:i.field({type:n})})}),r=e.inputRef("StringWhereInputArgument").implement({fields:i=>({eq:i.string(),ne:i.string(),gt:i.string(),gte:i.string(),lt:i.string(),lte:i.string(),in:i.stringList(),notIn:i.stringList(),like:i.string(),ilike:i.string(),notLike:i.string(),notIlike:i.string(),isNull:i.boolean(),isNotNull:i.boolean(),arrayOverlaps:i.stringList(),arrayContained:i.stringList(),arrayContains:i.stringList(),AND:i.field({type:[r]}),OR:i.field({type:[r]}),NOT:i.field({type:r})})}),o=e.inputRef("DateWhereInputArgument").implement({fields:i=>({eq:i.field({type:"Date"}),ne:i.field({type:"Date"}),gt:i.field({type:"Date"}),gte:i.field({type:"Date"}),lt:i.field({type:"Date"}),lte:i.field({type:"Date"}),in:i.field({type:["Date"]}),notIn:i.field({type:["Date"]}),like:i.string(),ilike:i.string(),notLike:i.string(),notIlike:i.string(),isNull:i.boolean(),isNotNull:i.boolean(),arrayOverlaps:i.field({type:["Date"]}),arrayContained:i.field({type:["Date"]}),arrayContains:i.field({type:["Date"]}),AND:i.field({type:[o]}),OR:i.field({type:[o]}),NOT:i.field({type:o})})});}var Kt=({db:e,disableDefaultObjects:t,pubsub:n,pothosConfig:r})=>{let o=new zr__default.default({...r,plugins:[Mt,Wr__default.default,Jr__default.default,...r?.plugins??[]],drizzle:{client:e,relations:e._.relations,getTableConfig(i){return {columns:Object.values(i[Symbol.for("drizzle:Columns")]),primaryKeys:Object.values(i[Symbol.for("drizzle:Columns")]).filter(s=>s.primary)}}},smartSubscriptions:{...Jr.subscribeOptionsFromIterator((i,s)=>n.subscribe(i))}});return o.addScalarType("JSON",graphqlScalars.JSONResolver),o.addScalarType("Date",graphqlScalars.DateResolver),o.addScalarType("DateTime",graphqlScalars.DateTimeISOResolver),Jt(o),t?.query||o.queryType({}),t?.subscription||o.subscriptionType({}),t?.mutation||o.mutationType({}),{schemaBuilder:o}};var ii=e=>{e.actions||(e.actions=["read","update","delete"]),e.defaultLimit===void 0&&(e.defaultLimit=100),e.search?.enabled&&jt(e.db);let t=vt(e),n=Lt({...e,abilityBuilder:t}),{makePubSubInstance:r,pubsub:o}=qt({...e}),{schemaBuilder:i}=Kt({...e,pubsub:o}),s=Bt({...e,schemaBuilder:i}),l=Wt({...e,schemaBuilder:i,enumImplementer:s}),u=Qt({...e,schemaBuilder:i}),p=_t({...e,schemaBuilder:i,makePubSubInstance:r,whereArgImplementer:l,orderArgImplementer:u,enumImplementer:s,abilityBuilder:t}),a=Gt({...e,schemaBuilder:i,whereArgImplementer:l,orderArgImplementer:u,makePubSubInstance:r}),m=G(()=>i.toSchema()),c=y=>{let T=y?.enableApiDocs??process?.env?.NODE_ENV==="development"??false;return graphqlYoga.createYoga({...y,graphiql:T,plugins:[...y?.plugins??[],...T?[]:[pluginDisableIntrospection.useDisableIntrospection(),graphqlArmor.EnvelopArmorPlugin()]].filter(Boolean),schema:m(),context:n})},x=y=>(y.openAPI&&esToolkit.merge(y.openAPI,wt),sofaApi.useSofa({...y,schema:m(),context:n})),h=Ot({...e,builtSchema:m});return {abilityBuilder:t,schemaBuilder:i,createYoga:c,createSofa:x,object:p,whereArg:l,orderArg:u,query:a,pubsub:r,enum_:s,clientCreator:h}};exports.RumbleError=O;exports.RumbleErrorSafe=te;exports.assertFindFirstExists=Ke;exports.assertFirstEntryExists=yr;exports.generateFromSchema=Me;exports.makeLiveQuery=cr;exports.makeMutation=mr;exports.makeQuery=fr;exports.makeSubscription=dr;exports.mapNullFieldsToUndefined=hr;exports.rumble=ii;//# sourceMappingURL=index.cjs.map
|
|
63
|
+
`);},1e3),ke=({db:e,actions:n,defaultLimit:r})=>{let i={},o={},t={},l=a=>{for(let s of n)t[a]||(t[a]={}),t[a][s]||(t[a][s]=[]);return {allow:s=>{let m=o[a];m||(m={},o[a]=m);let u=Array.isArray(s)?s:[s];for(let d of u){let p=m[d];p||(p="unspecified",m[d]=p);}return {when:d=>{for(let p of u)m[p]==="unspecified"&&(m[p]=[]),m[p].push(d);}}},filter:s=>{let m=Array.isArray(s)?s:[s];return {by:u=>{for(let d of m)t[a][d].push(u);}}}}};for(let a of Object.keys(e.query))i[a]=l(a);return {...i,z_registeredQueryFilters:o,z_registeredFilters:t,z_buildWithUserContext:a=>{let s={},m=u=>({filter:(d,p)=>{let D=c=>{let x=Q(()=>{if(!(!c?.where&&!p?.inject?.where)){if(p?.inject?.where&&c?.where)return {AND:[c?.where,p?.inject?.where]};if(p?.inject?.where&&!c?.where)return p?.inject?.where;if(!p?.inject?.where&&c?.where)return c?.where;!p?.inject?.where&&c?.where;}}),C=Q(()=>{let P=x();if(!P)return;let G=E({tsName:u,db:e});return drizzleOrm.relationsFilterToSQL(G.tableSchema,P)}),q=Q(()=>{let P=c?.limit??r;return p?.inject?.limit&&(!P||P>p.inject.limit)&&(P=p.inject.limit),P??void 0}),z=Q(()=>{if(!(!c?.columns&&!p?.inject?.columns))return {...c?.columns,...p?.inject?.columns}}),k={query:{single:{get where(){return x()},columns:z()},many:{get where(){return x()},columns:z(),get limit(){return q()}}},sql:{get where(){return C()}}};return z()||(delete k.query.many.columns,delete k.query.single.columns),k},h=()=>{let c=E({db:e,tsName:u});if(Object.keys(c.primaryColumns).length===0)throw new A(`No primary key found for entity ${u.toString()}`);let x=Object.values(c.primaryColumns)[0],C=Qe(x.getSQLType());return {where:{AND:[{[x.name]:C.value1},{[x.name]:C.value2}]}}},y=o?.[u]?.[d];if(y==="unspecified")return D();y||(Et(u.toString(),d),y=[h()]);let b=y.filter(Bt),R=y.filter(Nt).map(c=>c(a)),g=R.some(c=>c==="allow"),T=[...b,...R].filter(c=>c!==void 0).filter(c=>c!=="allow");!g&&T.length===0&&(T=[h()]);let L;for(let c of T)c?.limit&&(L===void 0||c.limit>L)&&(L=c.limit);let I;for(let c of [...T,p?.inject])c?.columns&&(I===void 0?I=c.columns:I={...I,...c.columns});let S=g?[]:T.filter(c=>c?.where).map(c=>c.where),f=S.length>0?{OR:S}:void 0;return D({where:f,columns:I,limit:L})},runtimeFilters:d=>t[u][d]});for(let u of Object.keys(e.query))s[u]=m(u);return s}}};var qe=({builtSchema:e})=>(process.env.NODE_ENV!=="development"&&console.warn("Running rumble client generation in non development mode. Are you sure this is correct?"),async({apiUrl:r,outputPath:i,rumbleImportPath:o,useExternalUrqlClient:t})=>{let l=e();await oe({schema:l,outputPath:i,rumbleImportPath:o,apiUrl:r,useExternalUrqlClient:t});});var ze=({context:e,abilityBuilder:n})=>async r=>{let i=e?await e(r):{};return {...i,abilities:n.z_buildWithUserContext(i)}};function te(e){return e instanceof pgCore.PgEnumColumn}var Oe=({db:e,schemaBuilder:n})=>{let r=new Map;return ({tsName:o,enumColumn:t,refName:l})=>{let a,s;if(o){let p=e._.relations.schema[o];a=o.toString();let D=Object.values(e._.relations.schema).filter(h=>typeof h=="object").map(h=>Object.values(h[Symbol.for("drizzle:Columns")])).flat(2).find(h=>h.config?.enum===p);if(!D)throw new A(`Could not find applied enum column for ${o.toString()}.
|
|
64
|
+
Please ensure that you use the enum at least once as a column of a table!`);s=D.enumValues;}else if(t){let p=Object.entries(e._.relations.schema).find(([,D])=>D===t.config.enum);if(!p)throw new A(`Could not find enum in schema for ${t.name}!`);a=p[0],s=t.enumValues;}if(!a||!s)throw new A("Could not determine enum structure!");let m=l??`${esToolkit.capitalize(casing.toCamelCase(a))}Enum`,u=r.get(m);return u||(u=n.enumType(m,{values:s}),r.set(m,u),u)}};var Fe={paths:{"/webhook":{post:{operationId:"webhook_create",description:"Creates a webhook subscription.",tags:[],parameters:[],requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookCreateBody"}}}},responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}}},"/webhook/{id}":{post:{operationId:"webhook_update",description:"Updates a webhook subscription.",parameters:[{name:"id",in:"path",description:"The ID of the webhook to update",required:true,schema:{type:"string"}}],requestBody:{content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookCreateBody"}}}},responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}},delete:{operationId:"webhook_delete",description:"Removes a webhook subscription.",tags:[],parameters:[{name:"id",in:"path",description:"The ID of the webhook to delete",required:true,schema:{type:"string"}}],responses:{200:{description:"",content:{"application/json":{schema:{$ref:"#/components/schemas/WebhookDetailResponse"}}}}}}}},components:{schemas:{WebhookCreateBody:{type:"object",properties:{subscription:{description:"The subscription to subscribe to. In many cases, these match the available query IDs without the '_query' suffix. E.g., 'findFirstUser_query' -> 'findFirstUser'. See the graphql schema for more details on what subscriptions are available.",type:"string"},variables:{description:"The variables to pass to the subscription.",type:"object"},url:{description:"The URL to send the webhook to.",type:"string"}}},WebhookDetailResponse:{type:"object",properties:{id:{description:"The ID of the webhook. Can be used as reference in update or delete calls.",type:"string"}}},DateTime:{type:"string",format:"date-time"},Date:{type:"string",format:"date"}}}};function ne({sqlType:e,fieldName:n}){let r;if(M(e)&&(r="Int"),K(e)&&(r="Float"),V(e)&&(n&&(n.toLowerCase().endsWith("_id")||n.toLowerCase().endsWith("id"))?r="ID":r="String"),J(e)&&(r="ID"),H(e)&&(r="Boolean"),X(e)&&(r="DateTime"),Y(e)&&(r="Date"),Z(e)&&(r="JSON"),r!==void 0)return r;throw ee(e,"SQL to GQL")}function zt(e){let n=new Set;for(let i of Object.values(e))typeof i=="object"&&(i instanceof pgCore.PgTable?n.add("postgres"):i instanceof mysqlCore.MySqlTable?n.add("mysql"):i instanceof sqliteCore.SQLiteTable&&n.add("sqlite"));let r=Array.from(n);if(r.length===1)return r[0];throw r.length===0?new Error("No tables found in schema, could not determine dialect"):new Error(`Multiple dialects found in schema: ${r.join(", ")}`)}function ve(e){return zt(e._.relations.schema)==="postgres"}async function Ue(e){if(!ve(e)){console.info("Database dialect is not compatible with search, skipping search initialization.");return}await e.execute(drizzleOrm.sql`CREATE EXTENSION IF NOT EXISTS pg_trgm;`);}function re({search:e,args:n,tableSchema:r,abilities:i}){if(e?.enabled&&n.search&&n.search.length>0){let o=esToolkit.cloneDeep(n.orderBy);n.orderBy=l=>{let a=drizzleOrm.sql.join(Object.entries(o??{}).map(([d,p])=>{if(p==="asc")return drizzleOrm.sql`${l[d]} ASC`;if(p==="desc")return drizzleOrm.sql`${l[d]} DESC`;throw new Error(`Invalid value ${p} for orderBy`)}),drizzleOrm.sql.raw(", ")),s=i.query.many.columns?Object.entries(r.columns).filter(([d])=>i.query.many.columns[d]):Object.entries(r.columns),m=drizzleOrm.sql`GREATEST(${drizzleOrm.sql.join(s.map(([d])=>drizzleOrm.sql`similarity(${l[d]}::TEXT, ${n.search})`),drizzleOrm.sql.raw(", "))}) DESC`;return o?drizzleOrm.sql.join([a,m],drizzleOrm.sql.raw(", ")):m};let t=esToolkit.cloneDeep(n.where);n.where={AND:[t??{},{RAW:l=>drizzleOrm.sql`GREATEST(${drizzleOrm.sql.join(Object.entries(r.columns).map(([a])=>drizzleOrm.sql`similarity(${l[a]}::TEXT, ${n.search})`),drizzleOrm.sql.raw(", "))}) > ${e.threshold??.1}`}]};}}var Ut=e=>typeof e!="object"?false:!!Object.keys(e).some(n=>["args","nullable","query","subscribe","description","type","resolve"].find(r=>r===n)),Ge=({db:e,search:n,schemaBuilder:r,makePubSubInstance:i,whereArgImplementer:o,orderArgImplementer:t,enumImplementer:l,abilityBuilder:a})=>({table:s,refName:m,readAction:u="read",adjust:d})=>{let p=E({db:e,tsName:s});Object.keys(p.primaryColumns).length===0&&console.warn(`Could not find primary key for ${s.toString()}. Cannot register subscriptions!`);let D=Object.values(p.primaryColumns)[0],{registerOnInstance:h}=i({table:s});return r.drizzleObject(s,{name:m??esToolkit.capitalize(s.toString()),subscribe:(y,b,R)=>{if(!D)return;let g=b[D.name];if(!g){console.warn(`Could not find primary key value for ${JSON.stringify(b)}. Cannot register subscription!`);return}h({instance:y,action:"updated",primaryKeyValue:g});},applyFilters:a?.z_registeredFilters?.[s]?.[u],fields:y=>{let b=p.columns,R=(S,f,c)=>{let x=ne({sqlType:S,fieldName:f});switch(x){case "Int":return y.exposeInt(f,{nullable:c});case "String":return y.exposeString(f,{nullable:c});case "Boolean":return y.exposeBoolean(f,{nullable:c});case "Date":return y.field({type:"Date",resolve:C=>C[f],nullable:c});case "DateTime":return y.field({type:"DateTime",resolve:C=>C[f],nullable:c});case "Float":return y.exposeFloat(f,{nullable:c});case "ID":return y.exposeID(f,{nullable:c});case "JSON":return y.field({type:"JSON",resolve:C=>C[f],nullable:c});default:throw new A(`Unsupported object type ${x} for column ${f}`)}},g=new Map,T=d?.(new Proxy(y,{get:(S,f)=>typeof S[f]!="function"||f==="arg"||f==="builder"||f==="graphqlKind"||f==="kind"||f==="listRef"||f==="table"||f==="typename"||f==="variant"||f.toString().startsWith("boolean")||f.toString().startsWith("float")||f.toString().startsWith("id")||f.toString().startsWith("int")||f.toString().startsWith("string")||f.toString().startsWith("expose")?S[f]:(...c)=>{let x=S[f](...c),C=c.find(Ut);if(!C)throw new A("Expected config object to be passed to adjust field");return g.set(x,{params:c,creatorFunction:S[f],configObject:C}),x}}))??{},L=Object.entries(b).reduce((S,[f,c])=>{if(T[f]){let{params:x,creatorFunction:C,configObject:q}=g.get(T[f]);return typeof q.nullable!="boolean"&&(q.nullable=!c.notNull),T[f]=C.bind(y)(...x),S}if(te(c)){let x=l({enumColumn:c});S[f]=y.field({type:x,resolve:C=>C[f],nullable:!c.notNull});}else S[f]=R(c.getSQLType(),f,!c.notNull);return S},{}),I=Object.entries(p.relations??{}).reduce((S,[f,c])=>{let x=E({db:e,table:c.targetTable}),C=o({dbName:x.dbName}),q=t({dbName:x.dbName}),z=i({table:x.tsName}),k=false,P=true,G="many";c instanceof drizzleOrm.One&&(P=false,k=c.optional,G="single");let me=(N,v)=>{z.registerOnInstance({instance:N,action:"created"}),z.registerOnInstance({instance:N,action:"removed"});};if(T[f]){let{params:N,creatorFunction:v,configObject:w}=g.get(T[f]);return typeof w.nullable!="boolean"&&(w.nullable=k),typeof w.subscribe!="function"&&(w.subscribe=me),T[f]=v.bind(y)(...N),S}let ce={where:y.arg({type:C,required:false}),orderBy:y.arg({type:q,required:false}),...P?{offset:y.arg.int({required:false}),limit:y.arg.int({required:false})}:{},search:y.arg.string({required:false})};return (!n?.enabled||!P)&&delete ce.search,S[f]=y.relation(f,{args:ce,subscribe:me,nullable:k,description:`Get the ${pluralize.plural(x.tsName)} related to this ${pluralize.singular(p.tsName)}`,query:(N,v)=>{N=JSON.parse(JSON.stringify(N)),P&&re({search:n,args:N,tableSchema:x,abilities:v.abilities[x.tsName].filter(u)});let w=v.abilities[x.tsName].filter(u,{inject:{where:N.where,limit:N.limit}}).query[G];return N.offset&&(w.offset=N.offset),N.orderBy&&(w.orderBy=N.orderBy),w}}),S},{});return {...L,...I,...T}}})};var Wt=e=>`${esToolkit.capitalize(casing.toCamelCase(e.toString()))}OrderInputArgument`,$e=({db:e,schemaBuilder:n})=>{let r=new Map,i=Q(()=>n.enumType("SortingParameter",{values:["asc","desc"]})),o=({table:t,refName:l,dbName:a})=>{let s=E({db:e,dbName:a,tsName:t}),m=l??Wt(s.tsName),u=r.get(m);return u||(u=n.inputType(m,{fields:p=>{let D=Object.entries(s.columns).reduce((y,[b])=>(y[b]=p.field({type:i(),required:false}),y),{}),h=Object.entries(s.relations??{}).reduce((y,[b,R])=>{let g=E({db:e,table:R.targetTable}),T=o({dbName:g.dbName});return y[b]=p.field({type:T,required:false}),y},{});return {...D,...h}}}),r.set(m,u),u)};return o};var _t="RUMBLE_SUBSCRIPTION_NOTIFICATION",Mt="REMOVED",Kt="UPDATED",Vt="CREATED",_e=({subscriptions:e})=>{let n=e?graphqlYoga.createPubSub(...e):graphqlYoga.createPubSub();return {pubsub:n,makePubSubInstance:({table:i})=>{function o({action:t,tableName:l,primaryKeyValue:a}){let s;switch(t){case "created":s=Vt;break;case "removed":s=Mt;break;case "updated":s=Kt;break;default:throw new Error(`Unknown action: ${t}`)}return `${_t}/${l}${a?`/${a}`:""}/${s}`}return {registerOnInstance({instance:t,action:l,primaryKeyValue:a}){let s=o({tableName:i.toString(),action:l,primaryKeyValue:a});t.register(s);},created(){let t=o({tableName:i.toString(),action:"created"});return n.publish(t)},removed(){let t=o({tableName:i.toString(),action:"removed"});return n.publish(t)},updated(t){let a=(Array.isArray(t)?t:[t]).map(m=>o({tableName:i.toString(),action:"updated",primaryKeyValue:m})),s=Array.from(new Set(a));for(let m of s)n.publish(m);}}}}};var Ve=({db:e,schemaBuilder:n,search:r,whereArgImplementer:i,orderArgImplementer:o,makePubSubInstance:t})=>({table:l,readAction:a="read",listAction:s="read"})=>{let m=i({table:l}),u=o({table:l}),d=E({db:e,tsName:l}),p=Object.values(d.primaryColumns)[0],{registerOnInstance:D}=t({table:l});return n.queryFields(h=>{let y={where:h.arg({type:m,required:false}),orderBy:h.arg({type:u,required:false}),limit:h.arg.int({required:false}),offset:h.arg.int({required:false}),search:h.arg.string({required:false})};return r?.enabled||delete y.search,{[pluralize.plural(l.toString())]:h.drizzleField({type:[l],nullable:false,smartSubscription:true,description:`List all ${pluralize.plural(l.toString())}`,subscribe:(b,R,g,T,L)=>{D({instance:b,action:"created"}),D({instance:b,action:"removed"});},args:y,resolve:(b,R,g,T,L)=>{g=JSON.parse(JSON.stringify(g)),re({search:r,args:g,tableSchema:d,abilities:T.abilities[l].filter(s)});let I=T.abilities[l].filter(s,g.where||g.limit||g.offset?{inject:{where:g.where,limit:g.limit}}:void 0).query.many;g.offset&&(I.offset=g.offset),g.orderBy&&(I.orderBy=g.orderBy);let S=b(I);return I.columns&&(S.columns=I.columns),e.query[l].findMany(S)}}),[pluralize.singular(l.toString())]:h.drizzleField({type:l,nullable:false,smartSubscription:true,description:`Get a single ${pluralize.singular(l.toString())} by ID`,args:{id:h.arg.id({required:true})},resolve:(b,R,g,T,L)=>{g=JSON.parse(JSON.stringify(g));let I=T.abilities[l].filter(a,{inject:{where:{[p.name]:g.id}}}).query.single,S=b(I);return I.columns&&(S.columns=I.columns),e.query[l].findFirst(S).then(le)}})}})};var He="ManualFiltersPlugin",Xe=He,Je="applyFilters",pe=class extends Jt.BasePlugin{wrapResolve(n,r){return async(i,o,t,l)=>{let a,s=r?.type;if(s.kind==="List"?a=s.type?.ref.currentConfig.pothosOptions[Je]:s.kind==="Object"&&(a=s.ref.currentConfig.pothosOptions[Je]),!a||!Array.isArray(a)||a.length===0)return n(i,o,t,l);let m=await n(i,o,t,l),u=Array.isArray(m)?m:[m],d=Array.isArray(a)?a:[a],p=await Ce({filters:d,entities:u,context:t});return Array.isArray(m)?p:p[0]??null}}};Jt__default.default.registerPlugin(He,pe);var Zt=e=>`${esToolkit.capitalize(casing.toCamelCase(e.toString()))}WhereInputArgument`,Ye=({db:e,schemaBuilder:n,enumImplementer:r})=>{let i=new Map,o=({table:t,refName:l,dbName:a})=>{let s=E({db:e,dbName:a,tsName:t}),m=l??Zt(s.tsName),u=i.get(m);return u||(u=n.inputType(m,{fields:p=>{let D=(b,R)=>{let g=ne({sqlType:b,fieldName:R});switch(g){case "Int":return p.field({type:"IntWhereInputArgument"});case "String":return p.field({type:"StringWhereInputArgument"});case "Boolean":return p.boolean({required:false});case "Date":return p.field({type:"DateWhereInputArgument"});case "DateTime":return p.field({type:"DateWhereInputArgument"});case "Float":return p.field({type:"FloatWhereInputArgument"});case "ID":return p.id({required:false});case "JSON":return p.field({type:"JSON",required:false});default:throw new A(`Unsupported argument type ${g} for column ${b}`)}},h=Object.entries(s.columns).reduce((b,[R,g])=>{if(te(g)){let T=r({enumColumn:g});b[R]=p.field({type:T,required:false});}else b[R]=D(g.getSQLType(),R);return b},{}),y=Object.entries(s.relations??{}).reduce((b,[R,g])=>{let T=E({db:e,table:g.targetTable}),L=o({dbName:T.dbName});return b[R]=p.field({type:L,required:false}),b},{});return {...h,...y}}}),i.set(m,u),u)};return o};function Ze(e){let n=e.inputRef("IntWhereInputArgument").implement({fields:t=>({eq:t.int(),ne:t.int(),gt:t.int(),gte:t.int(),lt:t.int(),lte:t.int(),in:t.intList(),notIn:t.intList(),like:t.string(),ilike:t.string(),notLike:t.string(),notIlike:t.string(),isNull:t.boolean(),isNotNull:t.boolean(),arrayOverlaps:t.intList(),arrayContained:t.intList(),arrayContains:t.intList(),AND:t.field({type:[n]}),OR:t.field({type:[n]}),NOT:t.field({type:n})})}),r=e.inputRef("FloatWhereInputArgument").implement({fields:t=>({eq:t.float(),ne:t.float(),gt:t.float(),gte:t.float(),lt:t.float(),lte:t.float(),in:t.floatList(),notIn:t.floatList(),like:t.string(),ilike:t.string(),notLike:t.string(),notIlike:t.string(),isNull:t.boolean(),isNotNull:t.boolean(),arrayOverlaps:t.floatList(),arrayContained:t.floatList(),arrayContains:t.floatList(),AND:t.field({type:[r]}),OR:t.field({type:[r]}),NOT:t.field({type:r})})}),i=e.inputRef("StringWhereInputArgument").implement({fields:t=>({eq:t.string(),ne:t.string(),gt:t.string(),gte:t.string(),lt:t.string(),lte:t.string(),in:t.stringList(),notIn:t.stringList(),like:t.string(),ilike:t.string(),notLike:t.string(),notIlike:t.string(),isNull:t.boolean(),isNotNull:t.boolean(),arrayOverlaps:t.stringList(),arrayContained:t.stringList(),arrayContains:t.stringList(),AND:t.field({type:[i]}),OR:t.field({type:[i]}),NOT:t.field({type:i})})}),o=e.inputRef("DateWhereInputArgument").implement({fields:t=>({eq:t.field({type:"Date"}),ne:t.field({type:"Date"}),gt:t.field({type:"Date"}),gte:t.field({type:"Date"}),lt:t.field({type:"Date"}),lte:t.field({type:"Date"}),in:t.field({type:["Date"]}),notIn:t.field({type:["Date"]}),like:t.string(),ilike:t.string(),notLike:t.string(),notIlike:t.string(),isNull:t.boolean(),isNotNull:t.boolean(),arrayOverlaps:t.field({type:["Date"]}),arrayContained:t.field({type:["Date"]}),arrayContains:t.field({type:["Date"]}),AND:t.field({type:[o]}),OR:t.field({type:[o]}),NOT:t.field({type:o})})});}var et=({db:e,disableDefaultObjects:n,pubsub:r,pothosConfig:i})=>{let o=new Jt__default.default({...i,plugins:[Xe,tn__default.default,nn__default.default,...i?.plugins??[]],drizzle:{client:e,relations:e._.relations,getTableConfig(t){return {columns:Object.values(t[Symbol.for("drizzle:Columns")]),primaryKeys:Object.values(t[Symbol.for("drizzle:Columns")]).filter(l=>l.primary)}}},smartSubscriptions:{...nn.subscribeOptionsFromIterator((t,l)=>r.subscribe(t))}});return o.addScalarType("JSON",graphqlScalars.JSONResolver),o.addScalarType("Date",graphqlScalars.DateResolver),o.addScalarType("DateTime",graphqlScalars.DateTimeISOResolver),Ze(o),n?.query||o.queryType({}),n?.subscription||o.subscriptionType({}),n?.mutation||o.mutationType({}),{schemaBuilder:o}};var yn=e=>{e.actions||(e.actions=["read","update","delete"]),e.defaultLimit===void 0&&(e.defaultLimit=100),e.search?.enabled&&Ue(e.db);let n=ke(e),r=ze({...e,abilityBuilder:n}),{makePubSubInstance:i,pubsub:o}=_e({...e}),{schemaBuilder:t}=et({...e,pubsub:o}),l=Oe({...e,schemaBuilder:t}),a=Ye({...e,schemaBuilder:t,enumImplementer:l}),s=$e({...e,schemaBuilder:t}),m=Ge({...e,schemaBuilder:t,makePubSubInstance:i,whereArgImplementer:a,orderArgImplementer:s,enumImplementer:l,abilityBuilder:n}),u=Ve({...e,schemaBuilder:t,whereArgImplementer:a,orderArgImplementer:s,makePubSubInstance:i}),d=Q(()=>t.toSchema()),p=y=>{let b=y?.enableApiDocs??process?.env?.NODE_ENV==="development";return graphqlYoga.createYoga({...y,graphiql:b,plugins:[...y?.plugins??[],...b?[]:[pluginDisableIntrospection.useDisableIntrospection(),graphqlArmor.EnvelopArmorPlugin()]].filter(Boolean),schema:d(),context:r})},D=y=>(y.openAPI&&esToolkit.merge(y.openAPI,Fe),sofaApi.useSofa({...y,schema:d(),context:r})),h=qe({...e,builtSchema:d});return {abilityBuilder:n,schemaBuilder:t,createYoga:p,createSofa:D,object:m,whereArg:a,orderArg:s,query:u,pubsub:i,enum_:l,clientCreator:h}};exports.RumbleError=A;exports.RumbleErrorSafe=F;exports.assertFindFirstExists=le;exports.assertFirstEntryExists=Ct;exports.generateFromSchema=oe;exports.makeLiveQuery=ht;exports.makeMutation=Tt;exports.makeQuery=xt;exports.makeSubscription=St;exports.mapNullFieldsToUndefined=Rt;exports.rumble=yn;//# sourceMappingURL=index.cjs.map
|
|
111
65
|
//# sourceMappingURL=index.cjs.map
|