@kubun/graphql 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context.d.ts +54 -9
- package/lib/context.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/scalars.d.ts +2 -0
- package/lib/scalars.js +1 -0
- package/lib/schema.d.ts +0 -1
- package/lib/schema.js +1 -1
- package/package.json +6 -6
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KubunDB } from '@kubun/db';
|
|
2
|
-
import type { DocumentData, DocumentNode } from '@kubun/protocol';
|
|
2
|
+
import type { DocumentData, DocumentFilter, DocumentNode } from '@kubun/protocol';
|
|
3
3
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
4
4
|
import type { Connection, Edge } from 'graphql-relay';
|
|
5
5
|
import type { AllConnectionArguments, ModelAccessDefaults, UpdateMutationInput } from './types.js';
|
|
@@ -11,6 +11,7 @@ export type QueryContext = {
|
|
|
11
11
|
loadDocument(id: string): Promise<DocumentNode | null>;
|
|
12
12
|
resolveConnection(modelIDs: Array<string>, args: AllConnectionArguments): Promise<Connection<DocumentNode>>;
|
|
13
13
|
resolveList(modelIDs: Array<string>, ids: Array<string>): Promise<Array<DocumentNode>>;
|
|
14
|
+
resolveCount(modelIDs: Array<string>, filter?: DocumentFilter): Promise<number>;
|
|
14
15
|
searchDocuments(query: string, modelIDs: Array<string>, first?: number): Promise<Array<{
|
|
15
16
|
documentID: string;
|
|
16
17
|
modelID: string;
|
|
@@ -38,17 +39,61 @@ export type ReadContextParams = {
|
|
|
38
39
|
accessChecker?: AccessChecker;
|
|
39
40
|
};
|
|
40
41
|
export declare function createReadContext(params: ReadContextParams): ReadOnlyContext;
|
|
42
|
+
export type CreateMutationParams = {
|
|
43
|
+
modelID: string;
|
|
44
|
+
data: DocumentData;
|
|
45
|
+
info: GraphQLResolveInfo;
|
|
46
|
+
transactionID?: string | null;
|
|
47
|
+
};
|
|
48
|
+
export type SetMutationParams = {
|
|
49
|
+
modelID: string;
|
|
50
|
+
unique: Uint8Array;
|
|
51
|
+
data: DocumentData;
|
|
52
|
+
info: GraphQLResolveInfo;
|
|
53
|
+
transactionID?: string | null;
|
|
54
|
+
};
|
|
55
|
+
export type UpdateMutationParams = {
|
|
56
|
+
input: UpdateMutationInput;
|
|
57
|
+
info: GraphQLResolveInfo;
|
|
58
|
+
transactionID?: string | null;
|
|
59
|
+
};
|
|
60
|
+
export type RemoveMutationParams = {
|
|
61
|
+
id: string;
|
|
62
|
+
info: GraphQLResolveInfo;
|
|
63
|
+
transactionID?: string | null;
|
|
64
|
+
};
|
|
65
|
+
export type SetModelAccessDefaultsParams = {
|
|
66
|
+
modelID: string;
|
|
67
|
+
permissionType: 'read' | 'write';
|
|
68
|
+
accessLevel: string;
|
|
69
|
+
allowedDIDs: Array<string> | null;
|
|
70
|
+
};
|
|
71
|
+
export type SetDocumentAccessOverrideParams = {
|
|
72
|
+
documentID: string;
|
|
73
|
+
permissionType: 'read' | 'write';
|
|
74
|
+
accessLevel: string;
|
|
75
|
+
allowedDIDs: Array<string> | null;
|
|
76
|
+
};
|
|
41
77
|
/**
|
|
42
78
|
* Mutation function requiring client implementation
|
|
43
79
|
*/
|
|
44
80
|
export type MutationContext = {
|
|
45
|
-
executeCreateMutation(
|
|
46
|
-
executeSetMutation(
|
|
47
|
-
executeUpdateMutation(
|
|
48
|
-
executeRemoveMutation(
|
|
49
|
-
executeSetModelAccessDefaults(
|
|
50
|
-
executeRemoveModelAccessDefaults(
|
|
51
|
-
executeSetDocumentAccessOverride(
|
|
52
|
-
executeRemoveDocumentAccessOverride(
|
|
81
|
+
executeCreateMutation(params: CreateMutationParams): Promise<DocumentNode>;
|
|
82
|
+
executeSetMutation(params: SetMutationParams): Promise<DocumentNode>;
|
|
83
|
+
executeUpdateMutation(params: UpdateMutationParams): Promise<DocumentNode>;
|
|
84
|
+
executeRemoveMutation(params: RemoveMutationParams): Promise<void>;
|
|
85
|
+
executeSetModelAccessDefaults(params: SetModelAccessDefaultsParams): Promise<ModelAccessDefaults>;
|
|
86
|
+
executeRemoveModelAccessDefaults(modelID: string, permissionTypes: Array<'read' | 'write'>): Promise<void>;
|
|
87
|
+
executeSetDocumentAccessOverride(params: SetDocumentAccessOverrideParams): Promise<DocumentNode>;
|
|
88
|
+
executeRemoveDocumentAccessOverride(documentID: string, permissionTypes: Array<'read' | 'write'>): Promise<void>;
|
|
89
|
+
beginTransaction(): {
|
|
90
|
+
transactionID: string;
|
|
91
|
+
};
|
|
92
|
+
commitTransaction(transactionID: string): Promise<{
|
|
93
|
+
success: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
rollbackTransaction(transactionID: string): {
|
|
96
|
+
success: boolean;
|
|
97
|
+
};
|
|
53
98
|
};
|
|
54
99
|
export type Context = ReadOnlyContext & MutationContext;
|
package/lib/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defer as e}from"@enkaku/async";import{DocumentID as t}from"@kubun/id";export function createReadContext(r){let{db:a,viewerDID:n,accessChecker:o}=r;function u(t,r){let n=!1,o=null,u=[],s=a.events.on("document:saved",e=>{if(t(e)){let t=r(e);null==o?u.push(t):(o.resolve(t),o=null)}}),l=()=>(s(),n=!0,Promise.resolve({done:!0,value:void 0}));return{[Symbol.asyncDispose]:()=>(s(),n=!0,Promise.resolve()),[Symbol.asyncIterator](){return this},next:()=>{if(n)return Promise.resolve({done:!0,value:void 0});let t=u.shift();return null!=t?Promise.resolve({value:t,done:!1}):(o=e()).promise.then(e=>({value:e,done:!1}))},return:l,throw:l}}return{getViewer:()=>n,async loadDocument(e){let r=await a.getDocument(t.fromString(e));return r&&(!o||await o(r,"read"))?r:null},searchDocuments:async(e,t,r)=>await a.searchDocuments({query:e,modelIDs:t,first:r}),async resolveConnection(e,t){if(null!=t.search&&""!==t.search.trim()){let r=await a.searchDocuments({query:t.search,modelIDs:e,first:200});if(0===r.length)return{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1,startCursor:null,endCursor:null}};let n=r.map(e=>e.documentID),u=await a.listDocuments({modelIDs:e,docIDs:n}),s=u;if(o)for(let e of(s=[],u))await o(e,"read")&&s.push(e);let l=new Map(r.map(e=>[e.documentID,e.rank]));s.sort((e,t)=>Math.abs(l.get(t.id)??0)-Math.abs(l.get(e.id)??0));let i=s.slice(0,t.first??50);return{edges:i.map((e,t)=>({cursor:String(t),node:e})),pageInfo:{hasNextPage:s.length>i.length,hasPreviousPage:!1,startCursor:i.length>0?"0":null,endCursor:i.length>0?String(i.length-1):null}}}if(null==o){let{entries:r,hasMore:n}=await a.queryDocuments({...t,modelIDs:e});return{edges:r.map(e=>({cursor:e.cursor,node:e.document})),pageInfo:{hasNextPage:!!t.first&&n,hasPreviousPage:!t.first&&n,endCursor:r.at(-1)?.cursor??null,startCursor:r.at(0)?.cursor??null}}}let r=[],n=0,u=0;if(null!=t.first){let s=2*(n=t.first),l=t.after;for(;r.length<n&&u<10;){let{entries:i,hasMore:d}=await a.queryDocuments({...t,modelIDs:e,first:s,after:l});if(0===i.length&&!d)break;for(let e of i)if(await o(e.document,"read")&&(r.push(e),r.length>=n))break;if(!d)break;l=i.at(-1)?.cursor??null,u++}}else if(null!=t.last){let s=2*(n=t.last),l=t.before;for(;r.length<n&&u<10;){let{entries:i,hasMore:d}=await a.queryDocuments({...t,modelIDs:e,last:s,before:l});if(0===i.length&&!d)break;for(let e of[...i].reverse())if(await o(e.document,"read")&&(r.unshift(e),r.length>=n))break;if(!d)break;l=i.at(0)?.cursor??null,u++}}let s=r.slice(0,n),l=r.length>n;return{edges:s.map(e=>({cursor:e.cursor,node:e.document})),pageInfo:{hasNextPage:!!t.first&&l,hasPreviousPage:!t.first&&l,endCursor:s.at(-1)?.cursor??null,startCursor:s.at(0)?.cursor??null}}},async resolveList(e,t){let r=await a.listDocuments({modelIDs:e,docIDs:t});if(!o)return r;let n=[];for(let e of r)await o(e,"read")&&n.push(e);return n},subscribeToDocumentCreated(e){let t=u(t=>"create"===t.type&&e.includes(t.document.model),e=>e.document);return o?async function*(){for await(let e of t)await o(e,"read")&&(yield e)}():t},subscribeToDocumentChanged(e){let t=u(t=>"update"===t.type&&t.document.id===e&&null!==t.document.data,e=>e.document);return o?async function*(){for await(let e of t)await o(e,"read")&&(yield e)}():t},subscribeToDocumentRemoved:()=>u(e=>"update"===e.type&&null===e.document.data,e=>e.document.id),subscribeToDocumentEdgeAdded(e,t){let r=u(r=>null!==r.document.data&&e.includes(r.document.model)&&t(r.document.data)&&("create"===r.type||null!==r.previous.data&&t(r.previous.data)),e=>({cursor:e.getCursor(),node:e.document}));return o?async function*(){for await(let e of r)await o(e.node,"read")&&(yield e)}():r},subscribeToDocumentEdgeRemoved:(e,t)=>u(r=>"update"===r.type&&e.includes(r.document.model)&&null!==r.previous.data&&t(r.previous.data)&&(null===r.document.data||!t(r.document.data)),e=>e.document.id)}}
|
|
1
|
+
import{defer as e}from"@enkaku/async";import{DocumentID as t}from"@kubun/id";export function createReadContext(r){let{db:a,viewerDID:n,accessChecker:o}=r;function u(t,r){let n=!1,o=null,u=[],s=a.events.on("document:saved",e=>{if(t(e)){let t=r(e);null==o?u.push(t):(o.resolve(t),o=null)}}),l=()=>(s(),n=!0,Promise.resolve({done:!0,value:void 0}));return{[Symbol.asyncDispose]:()=>(s(),n=!0,Promise.resolve()),[Symbol.asyncIterator](){return this},next:()=>{if(n)return Promise.resolve({done:!0,value:void 0});let t=u.shift();return null!=t?Promise.resolve({value:t,done:!1}):(o=e()).promise.then(e=>({value:e,done:!1}))},return:l,throw:l}}return{getViewer:()=>n,async loadDocument(e){let r=await a.getDocument(t.fromString(e));return r&&(!o||await o(r,"read"))?r:null},searchDocuments:async(e,t,r)=>await a.searchDocuments({query:e,modelIDs:t,first:r}),async resolveConnection(e,t){if(null!=t.search&&""!==t.search.trim()){let r=await a.searchDocuments({query:t.search,modelIDs:e,first:200});if(0===r.length)return{edges:[],pageInfo:{hasNextPage:!1,hasPreviousPage:!1,startCursor:null,endCursor:null}};let n=r.map(e=>e.documentID),u=await a.listDocuments({modelIDs:e,docIDs:n}),s=u;if(o)for(let e of(s=[],u))await o(e,"read")&&s.push(e);let l=new Map(r.map(e=>[e.documentID,e.rank]));s.sort((e,t)=>Math.abs(l.get(t.id)??0)-Math.abs(l.get(e.id)??0));let i=s.slice(0,t.first??50);return{edges:i.map((e,t)=>({cursor:String(t),node:e})),pageInfo:{hasNextPage:s.length>i.length,hasPreviousPage:!1,startCursor:i.length>0?"0":null,endCursor:i.length>0?String(i.length-1):null}}}if(null==o){let{entries:r,hasMore:n}=await a.queryDocuments({...t,modelIDs:e});return{edges:r.map(e=>({cursor:e.cursor,node:e.document})),pageInfo:{hasNextPage:!!t.first&&n,hasPreviousPage:!t.first&&n,endCursor:r.at(-1)?.cursor??null,startCursor:r.at(0)?.cursor??null}}}let r=[],n=0,u=0;if(null!=t.first){let s=2*(n=t.first),l=t.after;for(;r.length<n&&u<10;){let{entries:i,hasMore:d}=await a.queryDocuments({...t,modelIDs:e,first:s,after:l});if(0===i.length&&!d)break;for(let e of i)if(await o(e.document,"read")&&(r.push(e),r.length>=n))break;if(!d)break;l=i.at(-1)?.cursor??null,u++}}else if(null!=t.last){let s=2*(n=t.last),l=t.before;for(;r.length<n&&u<10;){let{entries:i,hasMore:d}=await a.queryDocuments({...t,modelIDs:e,last:s,before:l});if(0===i.length&&!d)break;for(let e of[...i].reverse())if(await o(e.document,"read")&&(r.unshift(e),r.length>=n))break;if(!d)break;l=i.at(0)?.cursor??null,u++}}let s=r.slice(0,n),l=r.length>n;return{edges:s.map(e=>({cursor:e.cursor,node:e.document})),pageInfo:{hasNextPage:!!t.first&&l,hasPreviousPage:!t.first&&l,endCursor:s.at(-1)?.cursor??null,startCursor:s.at(0)?.cursor??null}}},async resolveList(e,t){let r=await a.listDocuments({modelIDs:e,docIDs:t});if(!o)return r;let n=[];for(let e of r)await o(e,"read")&&n.push(e);return n},resolveCount:async(e,t)=>await a.countDocuments({modelIDs:e,filter:t}),subscribeToDocumentCreated(e){let t=u(t=>"create"===t.type&&e.includes(t.document.model),e=>e.document);return o?async function*(){for await(let e of t)await o(e,"read")&&(yield e)}():t},subscribeToDocumentChanged(e){let t=u(t=>"update"===t.type&&t.document.id===e&&null!==t.document.data,e=>e.document);return o?async function*(){for await(let e of t)await o(e,"read")&&(yield e)}():t},subscribeToDocumentRemoved:()=>u(e=>"update"===e.type&&null===e.document.data,e=>e.document.id),subscribeToDocumentEdgeAdded(e,t){let r=u(r=>null!==r.document.data&&e.includes(r.document.model)&&t(r.document.data)&&("create"===r.type||null!==r.previous.data&&t(r.previous.data)),e=>({cursor:e.getCursor(),node:e.document}));return o?async function*(){for await(let e of r)await o(e.node,"read")&&(yield e)}():r},subscribeToDocumentEdgeRemoved:(e,t)=>u(r=>"update"===r.type&&e.includes(r.document.model)&&null!==r.previous.data&&t(r.previous.data)&&(null===r.document.data||!t(r.document.data)),e=>e.document.id)}}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Context, MutationContext, QueryContext, ReadContextParams, ReadOnlyContext, SubscriptionContext, } from './context.js';
|
|
1
|
+
export type { Context, CreateMutationParams, MutationContext, QueryContext, ReadContextParams, ReadOnlyContext, RemoveMutationParams, SetDocumentAccessOverrideParams, SetModelAccessDefaultsParams, SetMutationParams, SubscriptionContext, UpdateMutationParams, } from './context.js';
|
|
2
2
|
export { createReadContext } from './context.js';
|
|
3
3
|
export { GraphQLAttachmentID, GraphQLDocID } from './identifiers.js';
|
|
4
4
|
export type { SchemaBuilderParams, SharedDefinitions, } from './schema.js';
|
package/lib/scalars.d.ts
ADDED
package/lib/scalars.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GraphQLError as t,GraphQLScalarType as e,Kind as n}from"graphql";function r(e){if("string"!=typeof e)throw new t(`Invalid URL input: expected string, got ${typeof e}`);try{return new URL(e).toString()}catch{throw new t(`Invalid URL: ${e}`)}}export const GraphQLURL=new e({name:"URL",description:"A field whose value conforms to the standard URL format as specified in RFC3986",serialize:r,parseValue:r,parseLiteral(e){if(e.kind!==n.STRING)throw new t(`Can only validate strings as URLs but got a: ${e.kind}`);return r(e.value)}});
|
package/lib/schema.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export type GraphQLNodeDefinitions = {
|
|
|
15
15
|
export type SharedDefinitions = GraphQLNodeDefinitions & {
|
|
16
16
|
accountObject: GraphQLObjectType<string, Context>;
|
|
17
17
|
attachmentObject: GraphQLObjectType<AttachmentID, Context>;
|
|
18
|
-
modelAccessDefaultsObject: GraphQLObjectType;
|
|
19
18
|
documentInterface: GraphQLInterfaceType;
|
|
20
19
|
documentNodeFields: GraphQLFieldConfigMap<DocumentNode, Context>;
|
|
21
20
|
queryFields: GraphQLFieldConfigMap<unknown, Context>;
|
package/lib/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AttachmentID as e,DocumentID as t,DocumentModelID as i,decodeID as n}from"@kubun/id";import{REFERENCE_PREFIX as s}from"@kubun/protocol";import{pascalCase as l}from"change-case";import{GraphQLBoolean as r,GraphQLEnumType as o,GraphQLFloat as a,GraphQLID as u,GraphQLInputObjectType as d,GraphQLInt as c,GraphQLInterfaceType as p,GraphQLList as h,GraphQLNonNull as f,GraphQLObjectType as m,GraphQLSchema as y,GraphQLString as _,isEnumType as b,isListType as w,isNonNullType as g}from"graphql";import{connectionArgs as D,connectionDefinitions as I,mutationWithClientMutationId as O,nodeDefinitions as $}from"graphql-relay";import{GraphQLDateTimeISO as j,GraphQLDID as v,GraphQLDuration as S,GraphQLEmailAddress as M,GraphQLJSON as F,GraphQLJSONObject as T,GraphQLURL as R}from"graphql-scalars";import{GraphQLAttachmentID as A,GraphQLDocID as L}from"./identifiers.js";import{getUniqueDocValue as q}from"./utils.js";let P={date:_,time:_,"date-time":_,duration:S,email:M,uri:R},E={attachmentid:A,did:v,docid:L};function G(e){return e.slice(s.length)}function C(e){return w(e)||g(e)&&w(e.ofType)}export function toDocumentModelID(e){return e instanceof i?e:i.fromString(e)}export function getGlobalID(e,t){let i=toDocumentModelID(e);return i.isLocal?i.toGlobal(toDocumentModelID(t)):i}export function toList(e){return new h(new f(e))}export function toOuputList(e){return new h(new f(e))}function V(e){return new d({name:`${e.name}ValueFilter`,isOneOf:!0,fields:{isNull:{type:r},equalTo:{type:e},notEqualTo:{type:e},in:{type:toList(e)},notIn:{type:toList(e)},lessThan:{type:e},lessThanOrEqualTo:{type:e},greaterThan:{type:e},greaterThanOrEqualTo:{type:e}}})}let x={AccountValueFilter:new d({name:"AccountValueFilter",isOneOf:!0,fields:{equalTo:{type:v},notEqualTo:{type:v},in:{type:toList(v)},notIn:{type:toList(v)}}}),BooleanValueFilter:new d({name:"BooleanValueFilter",isOneOf:!0,fields:{isNull:{type:r},equalTo:{type:r}}}),FloatValueFilter:V(a),IntValueFilter:V(c),StringValueFilter:V(_)},B={GraphQLBoolean:"BooleanValueFilter",GraphQLDID:"AccountValueFilter",GraphQLFloat:"FloatValueFilter",GraphQLInt:"IntValueFilter",GraphQLString:"StringValueFilter"},k=new d({name:"PatchSetOperation",fields:{path:{type:new f(_)},value:{type:F}}}),N=new d({name:"PatchRemoveOperation",fields:{path:{type:new f(_)}}}),Q=new d({name:"PatchDestinationOperation",fields:{from:{type:new f(_)},path:{type:new f(_)}}});export const PatchOperation=new d({name:"PatchOperation",isOneOf:!0,fields:{add:{type:k},set:{type:k},remove:{type:N},replace:{type:k},copy:{type:Q},move:{type:Q}}});let U=new o({name:"OrderByDirection",values:{ASC:{value:"asc"},DESC:{value:"desc"}}});export class SchemaBuilder{_aliases;_aliasToModelID;_definitions;_implemented={};_includedModelIDs;_includeInterfaceDependencies;_includeMutations;_includeRelationDependencies;_includeSubscriptions;_inputObjects={...x,PatchOperation};_mutations={};_nodeModelIDs;_onlyModels;_record;_references={};_relationsTo={};_subscriptions={};_types={OrderByDirection:U};constructor(e){for(let[t,i]of(this._record=e.record,this._onlyModels=e.onlyModels??null,this._includeInterfaceDependencies=e.includeInterfaceDependencies??!0,this._includeRelationDependencies=e.includeRelationDependencies??!0,this._includeMutations=e.includeMutations??!0,this._includeSubscriptions=e.includeSubscriptions??!0,this._aliasToModelID=e.aliases??{},this._aliases={},Object.entries(this._aliasToModelID)))this._aliases[i]=t;this._includedModelIDs=this._resolveModelIDsToInclude();let t={};for(let[n,s]of Object.entries(e.record)){let e=i.fromString(n);for(let i of(Object.assign(this._references,s.schema.$defs??{}),s.interfaces)){let s=getGlobalID(i,e).toString();t[s]??=new Set,t[s].add(n)}for(let[t,i]of Object.entries(s.fieldsMeta))if("document"===i.type&&null!=i.model){let l=G(s.schema.properties[t]?.$ref),r="array"===this._getReferenceSchema(l).type,o=getGlobalID(i.model,e).toString();this._relationsTo[o]??={},this._relationsTo[o][t]??=[],this._relationsTo[o][t].push({model:n,isList:r})}}let n=new Set;for(let e of Object.keys(t)){let i=new Set;for(let s of(!function e(t,i,n){let s=i[n];if(null==s)throw Error(`Interface ${n} not found in record`);for(let n of s)null!=i[n]?e(t,i,n):t.add(n)}(i,t,e),0!==i.size&&(this._implemented[e]=Array.from(i)),i))n.add(s)}this._nodeModelIDs=Array.from(n)}_resolveModelIdentifier(e){if(null!=this._record[e])return e;let t=this._aliasToModelID[e];if(null!=t&&null!=this._record[t])return t;throw Error(`Model identifier "${e}" not found. Must be a valid model ID or alias.`)}_resolveModelIDsToInclude(){if(null==this._onlyModels||0===this._onlyModels.length)return new Set(Object.keys(this._record));let e=new Set;for(let t of this._onlyModels){let i=this._resolveModelIdentifier(t);e.add(i)}if(!this._includeInterfaceDependencies&&!this._includeRelationDependencies)return e;let t=Array.from(e),i=new Set;for(;t.length>0;){let n=t.pop();if(null==n||i.has(n))continue;i.add(n);let s=this._record[n];if(null!=s){if(this._includeInterfaceDependencies)for(let i of s.interfaces){let s=getGlobalID(i,n).toString();e.has(s)||(e.add(s),t.push(s))}if(this._includeRelationDependencies){for(let i of Object.values(s.fieldsMeta))if("document"===i.type&&null!=i.model&&null!==i.model){let s=getGlobalID(i.model,n).toString();e.has(s)||(e.add(s),t.push(s))}}}}return e}getModelIDs(e){return null===e?this._nodeModelIDs:this._implemented[e]??[e]}build(){let e=this._buildSharedDefinitions();this._definitions=e;let t={nodes:e.nodesField,...e.queryFields};for(let e of this._includedModelIDs){this._buildDocument(e);let i=this._aliases[e],n={type:this._inputObjects[`${e}-filter`]};t[`all${i}`]={type:this._types[`${e}-connection`],args:{...D,filter:n,orderBy:{type:toList(this._inputObjects[`${e}-order`])},search:{type:_}},resolve:async(t,i,n)=>await n.resolveConnection(this.getModelIDs(e),i)}}let i=[...this._includedModelIDs][0];if(null!=i){let n=this._types[`${i}-connection`].getFields().pageInfo.type,s=new m({name:"SearchResultEdge",fields:()=>({cursor:{type:new f(_)},node:{type:new f(e.nodeInterface)},rank:{type:new f(a)}})}),l=new m({name:"SearchResultConnection",fields:()=>({edges:{type:new f(new h(new f(s)))},pageInfo:{type:n}})});t.search={type:new f(l),args:{query:{type:new f(_)},models:{type:new h(new f(_))},first:{type:c},after:{type:_}},resolve:async(e,t,i)=>{let{query:n,models:s,first:l}=t;if(""===n.trim())throw Error("Search query must not be empty");let r=s?s.map(e=>this._aliasToModelID[e]??e):[...this._includedModelIDs],o=await i.searchDocuments(n,r,l??20),a=o.map(e=>e.documentID),u=[...new Set(o.map(e=>e.modelID))],d=new Map((a.length>0?await i.resolveList(u,a):[]).map(e=>[e.id,e])),c=[];for(let e of o){let t=d.get(e.documentID);null!=t&&c.push({cursor:String(c.length),node:t,rank:Math.abs(e.rank)})}return{edges:c,pageInfo:{hasNextPage:!1,hasPreviousPage:!1,startCursor:c.length>0?c[0].cursor:null,endCursor:c.length>0?c[c.length-1].cursor:null}}}}}this._includeMutations&&(this._mutations.setModelAccessDefaults={type:e.modelAccessDefaultsObject,args:{modelId:{type:new f(u)},permissionType:{type:new f(_)},accessLevel:{type:new f(_)},allowedDIDs:{type:toList(_)}},resolve:async(e,t,i)=>await i.executeSetModelAccessDefaults(t.modelId,t.permissionType,t.accessLevel,t.allowedDIDs??null)},this._mutations.removeModelAccessDefaults={type:r,args:{modelId:{type:new f(u)},permissionTypes:{type:new f(toList(_))}},resolve:async(e,t,i)=>(await i.executeRemoveModelAccessDefaults(t.modelId,t.permissionTypes),!0)},this._mutations.setDocumentAccessOverride={type:e.documentInterface,args:{documentId:{type:new f(u)},permissionType:{type:new f(_)},accessLevel:{type:new f(_)},allowedDIDs:{type:toList(_)}},resolve:async(e,t,i)=>await i.executeSetDocumentAccessOverride(t.documentId,t.permissionType,t.accessLevel,t.allowedDIDs??null)},this._mutations.removeDocumentAccessOverride={type:r,args:{documentId:{type:new f(u)},permissionTypes:{type:new f(toList(_))}},resolve:async(e,t,i)=>(await i.executeRemoveDocumentAccessOverride(t.documentId,t.permissionTypes),!0)});let n={query:new m({name:"Query",fields:t})};return this._includeMutations&&(n.mutation=new m({name:"Mutation",fields:this._mutations})),this._includeSubscriptions&&(n.subscription=new m({name:"Subscription",fields:()=>{let t={documentChanged:{type:new f(e.documentInterface),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,i)=>i.subscribeToDocumentChanged(t.id)},documentRemoved:{type:new f(u),resolve:e=>e,subscribe:(e,t,i)=>i.subscribeToDocumentRemoved()}};for(let[e,i]of Object.entries(this._record)){if(!this._includedModelIDs.has(e))continue;let n=this._aliases[e];for(let s of(t[`new${n}Created`]={type:new f(this._types[e]),resolve:e=>e,subscribe:(t,i,n)=>n.subscribeToDocumentCreated(this.getModelIDs(e))},i.interfaces??[])){let i=getGlobalID(s,e).toString();for(let[e,n]of Object.entries(this._relationsTo[i]??{}))for(let s of n)this._buildRelationSubscriptions(t,i,e,s)}for(let[i,n]of Object.entries(this._relationsTo[e]??{}))for(let s of n)this._includedModelIDs.has(s.model)&&this._buildRelationSubscriptions(t,e,i,s)}return t}})),new y(n)}_getDefinitions(){if(null==this._definitions)throw Error("Definitions must be initialized");return this._definitions}_getReference(e,t){let i=G(e),n=this._types[i];if(null!=n)return n;let s=this._getReferenceSchema(i);return this._buildReference(i,s,t)}_getReferenceSchema(e){let t=this._references[e];if(null==t)throw Error(`Could not find reference: ${e}`);return t}_getReferenceInput(e,t,i=""){let n=G(e),s=this._getReferenceSchema(n);if("array"===s.type)return new h(new f(this._getReferenceInput(s.items.$ref,!1,s.title)));if("object"===s.type){if(s.additionalProperties)return T;let e=t?`${n}-partial`:n,r=this._inputObjects[e];if(null!=r)return r;let o={};for(let[e,i]of Object.entries(s.properties)){let n=this._getReferenceInput(i.$ref,t,s.title);o[e]={type:t||!s.required.includes(e)?n:new f(n)}}let a=this._aliases[n]??l(i+s.title),u=new d({name:t?`Partial${a}Input`:`${a}Input`,fields:o});return this._inputObjects[e]=u,u}return this._buildScalar(n,s,i)}_buildSharedDefinitions(){let i=$(async(i,s)=>{if(i.startsWith("did:"))return i;let l=n(i);if(l instanceof e)return l;if(l instanceof t)return await s.loadDocument(i);throw Error(`Unsupported node ID: ${i}`)},t=>"string"==typeof t?"AccountNode":t instanceof e?"AttachmentNode":this._aliases[t.model]),s=new m({name:"AccountNode",interfaces:[i.nodeInterface],fields:()=>{let e={id:{type:new f(u),description:"Globally unique identifier of the account (DID string)",resolve:e=>e},isViewer:{type:new f(r),description:"Whether the authenticated request issuer is this account or not",resolve:(e,t,i)=>i.getViewer()===e}};for(let[i,n]of Object.entries(this._record))if(this._includedModelIDs.has(i))switch(n.behavior){case"interface":continue;case"default":{let t=this._aliases[i];e[`own${t}Connection`]={type:this._types[`${i}-connection`],args:{...D,filter:{type:this._inputObjects[`${i}-filter`]},orderBy:{type:toList(this._inputObjects[`${i}-order`])}},resolve:async(e,t,n)=>await n.resolveConnection(this.getModelIDs(i),{...t,owner:e})};break}case"unique":{let s=this._aliases[i];e[`own${s}`]={type:this._types[i],args:n.uniqueFields.length?{with:{type:new f(this._buildSetInputObjectType(i,n.uniqueFields))}}:{},resolve:async(e,s,l)=>{let r=q(n.uniqueFields,s.with),o=t.create(i,e,r);return await l.loadDocument(o.toString())}}}}return e}}),l=new m({name:"AttachmentNode",interfaces:[i.nodeInterface],fields:{id:{type:new f(u),resolve:e=>e.toString()},contentLength:{type:new f(c)},mimeType:{type:new f(_)}}}),o=new m({name:"AccessRule",fields:{level:{type:new f(_)},allowedDIDs:{type:new h(new f(_))}}}),a=new m({name:"AccessPermissions",fields:{read:{type:o},write:{type:o}}}),d=new m({name:"ModelAccessDefaults",fields:()=>({ownerDID:{type:new f(_)},modelId:{type:new f(u)},permissions:{type:new f(a)}})}),y={id:{type:new f(u)},model:{type:new f(_)},owner:{type:new f(s)},createdAt:{type:new f(j)},updatedAt:{type:j},accessPermissions:{type:a,resolve:e=>e.data?.accessPermissions??null}},b=new p({name:"DocumentNode",interfaces:[i.nodeInterface],fields:y,resolveType:e=>this._aliases[e.model]}),w={node:i.nodeField,viewer:{type:s,description:"Account issuing the request, if authenticated",resolve:(e,t,i)=>i.getViewer()}};return{...i,accountObject:s,attachmentObject:l,modelAccessDefaultsObject:d,documentInterface:b,documentNodeFields:y,queryFields:w}}_buildDocument(e){if(null!=this._types[e])return this._types[e];let t=this._record[e];if(null==t)throw Error(`Could not find model id: ${e}`);let i=this._getDefinitions();this._aliases[e]??=l(t.name);let n=this._aliases[e],s={name:n,interfaces:()=>[i.documentInterface,i.nodeInterface].concat(t.interfaces.map(t=>this._types[getGlobalID(t,e).toString()]).filter(e=>null!=e)),fields:()=>this._buildDocumentFields(e,t,n)},r="interface"===t.behavior,o=r?new p({...s,resolveType:e=>this._aliases[e.model]}):new m(s),{connectionType:a,edgeType:d}=I({nodeType:o});return this._types[e]=o,this._types[`${e}-connection`]=a,this._types[`${e}-edge`]=d,this._buildDocumentDataObject(e,t,n),this._buildDocumentInput(e,t),this._buildObjectFilterInput(e,t.schema,n,!0),this._buildObjectOrderByInput(e,t.schema,n,!0),!r&&this._includeMutations&&("default"===t.behavior?this._mutations[`create${n}`]=O({name:`Create${n}`,inputFields:()=>({data:{type:new f(this._inputObjects[e])}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(t,i,n)=>({document:await i.executeCreateMutation(e,t.data,n)})}):"unique"===t.behavior&&(this._mutations[`set${n}`]=O({name:`Set${n}`,inputFields:()=>({data:{type:new f(this._inputObjects[e])}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(i,n,s)=>{let l=q(t.uniqueFields,i.data);return{document:await n.executeSetMutation(e,l,i.data,s)}}})),this._mutations[`update${n}`]=O({name:`Update${n}`,inputFields:()=>({id:{type:new f(u)},patch:{type:new f(toList(PatchOperation))},from:{type:this._inputObjects[`${e}-update`]}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(e,t,i)=>({document:await t.executeUpdateMutation(e,i)})}),this._mutations[`remove${n}`]=O({name:`Remove${n}`,inputFields:()=>({id:{type:new f(u)}}),outputFields:()=>({...i.queryFields,id:{type:new f(u)}}),mutateAndGetPayload:async(e,t,i)=>(await t.executeRemoveMutation(e.id,i),{id:e.id})})),o}_buildDocumentFields(t,i,n){let s=this._buildDocumentDataObject(t,i,n),l=this._getDefinitions(),r={...l.documentNodeFields,data:{type:new f(s)}};for(let[n,o]of Object.entries(s.getFields())){let s=i.fieldsMeta[n];if(null!=s)switch(s.type){case"account":C(o.type)?r[`${n}Accounts`]={type:new f(toOuputList(l.accountObject)),resolve:e=>e.data?.[n]??[]}:r[`${n}Account`]={type:l.accountObject,resolve:e=>e.data?.[n]??null};break;case"attachment":C(o.type)?r[`${n}Attachments`]={type:new f(toOuputList(l.attachmentObject)),resolve:t=>(t.data?.[n]??[]).map(e.fromString)}:r[`${n}Attachment`]={type:l.attachmentObject,resolve:t=>{let i=t.data?.[n];return i?e.fromString(i):null}};break;case"document":{let e,i,a=s.model;if(void 0===a)continue;null===a?(e=null,i=l.documentInterface):(e=getGlobalID(a,t).toString(),this._includedModelIDs.has(e)?i=this._buildDocument(e):(i=l.documentInterface,e=null)),C(o.type)?r[`${n}Documents`]={type:new f(toOuputList(i)),resolve:async(t,i,s)=>{let l=t.data?.[n]??[];return l.length?await s.resolveList(this.getModelIDs(e),l):[]}}:r[`${n}Document`]={type:i,resolve:async(e,t,i)=>{let s=e.data?.[n];return s?await i.loadDocument(s):null}}}}}for(let e of i.interfaces??[]){let i=getGlobalID(e,t).toString();for(let[e,t]of Object.entries(this._relationsTo[i]??{}))for(let i of t)this._includedModelIDs.has(i.model)&&this._buildRelationFields(r,e,i)}for(let[e,i]of Object.entries(this._relationsTo[t]??{}))for(let t of i)this._includedModelIDs.has(t.model)&&this._buildRelationFields(r,e,t);return r}_buildDocumentDataObject(e,t,i){let n=`${e}-data`;if(null!=this._types[n])return this._types[n];let s=t.schema.required??[],l={};for(let[i,n]of Object.entries(t.schema.properties??{})){let t=n.$ref;if(null==t)throw Error(`Missing ref for field ${i} of object ${e}`);let r=this._getReference(t);l[i]={type:s.includes(i)?new f(r):r}}let r={name:`${i}Data`,interfaces:()=>t.interfaces.map(t=>{let i=`${getGlobalID(t,e).toString()}-data`;return this._types[i]}).filter(e=>null!=e),fields:l},o="interface"===t.behavior?new p(r):new m(r);return this._types[n]=o,o}_buildDocumentInput(e,t){if("interface"===t.behavior)return;let i={},n={};for(let[e,s]of Object.entries(t.schema.properties)){let l=s.$ref,r=this._getReferenceInput(l,!1);i[e]={type:t.schema.required.includes(e)?new f(r):r};let o=G(l);null==this._getReferenceSchema(o).const&&(n[e]={type:this._getReferenceInput(l,!0)})}let s=this._aliases[e];this._inputObjects[e]=new d({name:`${s}Input`,fields:i}),this._inputObjects[`${e}-update`]=new d({name:`Partial${s}Input`,fields:n})}_buildReferenceFilterInput(e,t=""){let i=G(e),n=this._getReferenceSchema(i),s=t;if("object"===n.type)return n.additionalProperties?null:this._buildObjectFilterInput(i,n,t);if("array"===n.type){let e=this._aliases[i]??l(t+n.title);return s=e,new d({name:`${e}Filter`,isOneOf:!0,fields:{isNull:{type:r}}})}let o=this._buildScalar(i,n,s),a=B[o.name];if(null!=a)return this._inputObjects[a];let u=b(o)?new d({name:`${o.name}ValueFilter`,isOneOf:!0,fields:{isNull:{type:r},equalTo:{type:o},notEqualTo:{type:o},in:{type:toList(o)},notIn:{type:toList(o)}}}):V(o);return null==this._inputObjects[u.name]&&(this._inputObjects[u.name]=u),this._inputObjects[u.name]}_buildReferenceOrderByInput(e,t=""){let i=G(e),n=this._getReferenceSchema(i);switch(n.type){case"array":return null;case"object":return n.additionalProperties?null:this._buildObjectOrderByInput(i,n,t);default:return U}}_buildObjectFilterInput(e,t,i="",n=!1){let s=`${e}-filter`,r=this._inputObjects[s];if(null!=r)return r;let o=this._aliases[e]??l(i+(t.title??"")),a=n?{_owner:{type:this._inputObjects.AccountValueFilter}}:{};for(let[e,i]of Object.entries(t.properties)){let t=this._buildReferenceFilterInput(i.$ref,o);null!==t&&(a[e]={type:t})}let u=new d({name:`${o}ObjectFilter`,fields:a}),c=new d({name:`${o}Filter`,isOneOf:!0,fields:()=>({where:{type:u},and:{type:toList(this._inputObjects[s])},or:{type:toList(this._inputObjects[s])},not:{type:this._inputObjects[s]}})});return this._inputObjects[s]=c,c}_buildObjectOrderByInput(e,t,i="",n=!1){let s=`${e}-order`,r=this._inputObjects[s];if(null!=r)return r;let o=this._aliases[e]??l(i+(t.title??"")),a=n?{_docOwner:{type:U},_createdAt:{type:U}}:{};for(let[e,i]of Object.entries(t.properties)){let t=this._buildReferenceOrderByInput(i.$ref,o);null!=t&&(a[e]={type:t})}let u=new d({name:`${o}OrderBy`,isOneOf:!0,fields:a});return this._inputObjects[s]=u,u}_buildSetInputObjectType(e,t,i){let n=i?l(i):"",s=`${e}-with-${n}`,r=this._inputObjects[s];if(null!=r)return r;let o=this._record[e],a=this._aliases[e];return this._inputObjects[s]=new d({name:`With${n}${a}Input`,fields:()=>{let e={};for(let i of t){let t=o.schema.properties[i];if(null==t)throw Error(`Field ${i} not found on model ${a}`);let n=this._getReferenceInput(t.$ref,!1);e[i]={type:new f(n)}}return e}}),this._inputObjects[s]}_buildReference(e,t,i=""){if(null!=this._types[e])return this._types[e];switch(t.type){case"array":return this._types[e]=this._buildArray(t,i),this._types[e];case"object":return this._types[e]=t.additionalProperties?T:this._buildObject(e,t,i),this._types[e];default:return this._buildScalar(e,t,i)}}_buildScalar(e,t,i=""){if(null!=this._types[e])return this._types[e];switch(t.type){case"boolean":this._types[e]=r;break;case"integer":this._types[e]=c;break;case"number":this._types[e]=a;break;case"string":this._types[e]=this._buildString(t,i)}return this._types[e]}_buildArray(e,t=""){let i=e.items.$ref;return new h(new f(this._getReference(i,l(t+e.title))))}_buildObject(e,t,i=""){let n=l(i+t.title),s=this._buildObjectFields(e,t,n);return new m({name:n,fields:s})}_buildObjectFields(e,t,i=""){let n=t.required??[],s={};for(let[l,r]of Object.entries(t.properties??{})){let t=r.$ref;if(null==t)throw Error(`Missing ref for field ${l} of object ${e}`);let o=this._getReference(t,i);s[l]={type:n.includes(l)?new f(o):o}}return s}_buildRelationFields(e,t,i){if(i.isList)return;let n=i.model,s=`${l(t)}Of${this._aliases[n]}`;e[`in${s}`]={type:new f(this._types[`${n}-connection`]),args:{...D,filter:{type:this._inputObjects[`${n}-filter`]},orderBy:{type:toList(this._inputObjects[`${n}-order`])}},resolve:(e,i,s)=>{let l={where:{[t]:{equalTo:e.id}}},r=i.filter?{and:[i.filter,l]}:l;return s.resolveConnection(this.getModelIDs(n),{...i,filter:r})}}}_buildRelationSubscriptions(e,t,i,n){if(n.isList)return;let s=l(i);e[`edge${this._aliases[n.model]}AddedAs${s}To${this._aliases[t]}`]={type:new f(this._types[`${n.model}-edge`]),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,s)=>s.subscribeToDocumentEdgeAdded(this.getModelIDs(n.model),e=>e[i]===t.id)},e[`edge${this._aliases[n.model]}RemovedAs${s}From${this._aliases[t]}`]={type:new f(u),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,s)=>s.subscribeToDocumentEdgeRemoved(this.getModelIDs(n.model),e=>e[i]===t.id)}}_buildString(e,t){return null!=e.const?_:null!=e.enum?this._buildEnumString(e,t):null!=e.format?this._buildFormatString(e):this._buildCustomString(e)}_buildCustomString(e){return null==e.title?_:E[e.title.toLowerCase()]??_}_buildEnumString(e,t=""){let i=l(t+e.title),n=`${i}-enum`;if(null==this._types[n]){let t={};for(let i of e.enum)t[i]={value:i};this._types[n]=new o({name:i,values:t})}return this._types[n]}_buildFormatString(e){let t=P[e.format];if(null==t)throw Error(`Unsupported string format: ${e.format}`);return t}}export function createSchema(e){return new SchemaBuilder(e).build()}
|
|
1
|
+
import{AttachmentID as e,DocumentID as t,DocumentModelID as i,decodeID as n}from"@kubun/id";import{REFERENCE_PREFIX as s}from"@kubun/protocol";import{pascalCase as r}from"change-case";import{GraphQLBoolean as l,GraphQLEnumType as o,GraphQLFloat as a,GraphQLID as u,GraphQLInputObjectType as c,GraphQLInt as d,GraphQLInterfaceType as p,GraphQLList as h,GraphQLNonNull as f,GraphQLObjectType as m,GraphQLSchema as y,GraphQLString as _,isEnumType as b,isListType as w,isNonNullType as D}from"graphql";import{connectionArgs as I,connectionDefinitions as g,mutationWithClientMutationId as O,nodeDefinitions as $}from"graphql-relay";import{GraphQLDateTimeISO as v,GraphQLDID as j,GraphQLDuration as S,GraphQLEmailAddress as M,GraphQLJSON as T,GraphQLJSONObject as F}from"graphql-scalars";import{GraphQLAttachmentID as R,GraphQLDocID as A}from"./identifiers.js";import{GraphQLURL as L}from"./scalars.js";import{getUniqueDocValue as q}from"./utils.js";let P={date:_,time:_,"date-time":_,duration:S,email:M,uri:L},C={attachmentid:R,did:j,docid:A};function E(e){return e.slice(s.length)}function G(e){return w(e)||D(e)&&w(e.ofType)}export function toDocumentModelID(e){return e instanceof i?e:i.fromString(e)}export function getGlobalID(e,t){let i=toDocumentModelID(e);return i.isLocal?i.toGlobal(toDocumentModelID(t)):i}export function toList(e){return new h(new f(e))}export function toOuputList(e){return new h(new f(e))}function V(e){return new c({name:`${e.name}ValueFilter`,isOneOf:!0,fields:{isNull:{type:l},equalTo:{type:e},notEqualTo:{type:e},in:{type:toList(e)},notIn:{type:toList(e)},lessThan:{type:e},lessThanOrEqualTo:{type:e},greaterThan:{type:e},greaterThanOrEqualTo:{type:e}}})}let B={AccountValueFilter:new c({name:"AccountValueFilter",isOneOf:!0,fields:{equalTo:{type:j},notEqualTo:{type:j},in:{type:toList(j)},notIn:{type:toList(j)}}}),BooleanValueFilter:new c({name:"BooleanValueFilter",isOneOf:!0,fields:{isNull:{type:l},equalTo:{type:l}}}),FloatValueFilter:V(a),IntValueFilter:V(d),StringValueFilter:V(_)},k={GraphQLBoolean:"BooleanValueFilter",GraphQLDID:"AccountValueFilter",GraphQLFloat:"FloatValueFilter",GraphQLInt:"IntValueFilter",GraphQLString:"StringValueFilter"},x=new c({name:"PatchSetOperation",fields:{path:{type:new f(_)},value:{type:T}}}),N=new c({name:"PatchRemoveOperation",fields:{path:{type:new f(_)}}}),Q=new c({name:"PatchDestinationOperation",fields:{from:{type:new f(_)},path:{type:new f(_)}}});export const PatchOperation=new c({name:"PatchOperation",isOneOf:!0,fields:{add:{type:x},set:{type:x},remove:{type:N},replace:{type:x},copy:{type:Q},move:{type:Q}}});let U=new o({name:"OrderByDirection",values:{ASC:{value:"asc"},DESC:{value:"desc"}}}),W=new m({name:"AccessRule",fields:{level:{type:new f(_)},allowedDIDs:{type:new h(new f(_))}}}),z=new m({name:"AccessPermissions",fields:{read:{type:W},write:{type:W}}}),H=new m({name:"ModelAccessDefaults",fields:()=>({ownerDID:{type:new f(_)},modelId:{type:new f(u)},permissions:{type:new f(z)}})});export class SchemaBuilder{_aliases;_aliasToModelID;_definitions;_implemented={};_includedModelIDs;_includeInterfaceDependencies;_includeMutations;_includeRelationDependencies;_includeSubscriptions;_inputObjects={...B,PatchOperation};_mutations={};_nodeModelIDs;_onlyModels;_record;_references={};_relationsTo={};_subscriptions={};_types={OrderByDirection:U};constructor(e){for(let[t,i]of(this._record=e.record,this._onlyModels=e.onlyModels??null,this._includeInterfaceDependencies=e.includeInterfaceDependencies??!0,this._includeRelationDependencies=e.includeRelationDependencies??!0,this._includeMutations=e.includeMutations??!0,this._includeSubscriptions=e.includeSubscriptions??!0,this._aliasToModelID=e.aliases??{},this._aliases={},Object.entries(this._aliasToModelID)))this._aliases[i]=t;this._includedModelIDs=this._resolveModelIDsToInclude();let t={};for(let[n,s]of Object.entries(e.record)){let e=i.fromString(n);for(let i of(Object.assign(this._references,s.schema.$defs??{}),s.interfaces)){let s=getGlobalID(i,e).toString();t[s]??=new Set,t[s].add(n)}for(let[t,i]of Object.entries(s.fieldsMeta))if("document"===i.type&&null!=i.model){let r=E(s.schema.properties[t]?.$ref),l="array"===this._getReferenceSchema(r).type,o=getGlobalID(i.model,e).toString();this._relationsTo[o]??={},this._relationsTo[o][t]??=[],this._relationsTo[o][t].push({model:n,isList:l})}}let n=new Set;for(let e of Object.keys(t)){let i=new Set;for(let s of(!function e(t,i,n){let s=i[n];if(null==s)throw Error(`Interface ${n} not found in record`);for(let n of s)null!=i[n]?e(t,i,n):t.add(n)}(i,t,e),0!==i.size&&(this._implemented[e]=Array.from(i)),i))n.add(s)}this._nodeModelIDs=Array.from(n)}_resolveModelIdentifier(e){if(null!=this._record[e])return e;let t=this._aliasToModelID[e];if(null!=t&&null!=this._record[t])return t;throw Error(`Model identifier "${e}" not found. Must be a valid model ID or alias.`)}_resolveModelIDsToInclude(){if(null==this._onlyModels||0===this._onlyModels.length)return new Set(Object.keys(this._record));let e=new Set;for(let t of this._onlyModels){let i=this._resolveModelIdentifier(t);e.add(i)}if(!this._includeInterfaceDependencies&&!this._includeRelationDependencies)return e;let t=Array.from(e),i=new Set;for(;t.length>0;){let n=t.pop();if(null==n||i.has(n))continue;i.add(n);let s=this._record[n];if(null!=s){if(this._includeInterfaceDependencies)for(let i of s.interfaces){let s=getGlobalID(i,n).toString();e.has(s)||(e.add(s),t.push(s))}if(this._includeRelationDependencies){for(let i of Object.values(s.fieldsMeta))if("document"===i.type&&null!=i.model&&null!==i.model){let s=getGlobalID(i.model,n).toString();e.has(s)||(e.add(s),t.push(s))}}}}return e}getModelIDs(e){return null===e?this._nodeModelIDs:this._implemented[e]??[e]}build(){let e=this._buildSharedDefinitions();this._definitions=e;let t={nodes:e.nodesField,...e.queryFields};for(let e of this._includedModelIDs){this._buildDocument(e);let i=this._aliases[e],n={type:this._inputObjects[`${e}-filter`]};t[`all${i}`]={type:this._types[`${e}-connection`],args:{...I,filter:n,orderBy:{type:toList(this._inputObjects[`${e}-order`])},search:{type:_}},resolve:async(t,i,n)=>await n.resolveConnection(this.getModelIDs(e),i)},t[`all${i}Count`]={type:new f(d),args:{filter:n},resolve:(t,i,n)=>n.resolveCount(this.getModelIDs(e),i.filter)}}let i=[...this._includedModelIDs][0];if(null!=i){let n=this._types[`${i}-connection`].getFields().pageInfo.type,s=new m({name:"SearchResultEdge",fields:()=>({cursor:{type:new f(_)},node:{type:new f(e.nodeInterface)},rank:{type:new f(a)}})}),r=new m({name:"SearchResultConnection",fields:()=>({edges:{type:new f(new h(new f(s)))},pageInfo:{type:n}})});t.search={type:new f(r),args:{query:{type:new f(_)},models:{type:new h(new f(_))},first:{type:d},after:{type:_}},resolve:async(e,t,i)=>{let{query:n,models:s,first:r}=t;if(""===n.trim())throw Error("Search query must not be empty");let l=s?s.map(e=>this._aliasToModelID[e]??e):[...this._includedModelIDs],o=await i.searchDocuments(n,l,r??20),a=o.map(e=>e.documentID),u=[...new Set(o.map(e=>e.modelID))],c=new Map((a.length>0?await i.resolveList(u,a):[]).map(e=>[e.id,e])),d=[];for(let e of o){let t=c.get(e.documentID);null!=t&&d.push({cursor:String(d.length),node:t,rank:Math.abs(e.rank)})}return{edges:d,pageInfo:{hasNextPage:!1,hasPreviousPage:!1,startCursor:d.length>0?d[0].cursor:null,endCursor:d.length>0?d[d.length-1].cursor:null}}}}}if(this._includeMutations){this._mutations.setModelAccessDefaults={type:H,args:{modelId:{type:new f(u)},permissionType:{type:new f(_)},accessLevel:{type:new f(_)},allowedDIDs:{type:toList(_)}},resolve:async(e,t,i)=>await i.executeSetModelAccessDefaults({modelID:t.modelId,permissionType:t.permissionType,accessLevel:t.accessLevel,allowedDIDs:t.allowedDIDs??null})},this._mutations.removeModelAccessDefaults={type:l,args:{modelId:{type:new f(u)},permissionTypes:{type:new f(toList(_))}},resolve:async(e,t,i)=>(await i.executeRemoveModelAccessDefaults(t.modelId,t.permissionTypes),!0)},this._mutations.setDocumentAccessOverride={type:e.documentInterface,args:{documentId:{type:new f(u)},permissionType:{type:new f(_)},accessLevel:{type:new f(_)},allowedDIDs:{type:toList(_)}},resolve:async(e,t,i)=>await i.executeSetDocumentAccessOverride({documentID:t.documentId,permissionType:t.permissionType,accessLevel:t.accessLevel,allowedDIDs:t.allowedDIDs??null})},this._mutations.removeDocumentAccessOverride={type:l,args:{documentId:{type:new f(u)},permissionTypes:{type:new f(toList(_))}},resolve:async(e,t,i)=>(await i.executeRemoveDocumentAccessOverride(t.documentId,t.permissionTypes),!0)};let t=new m({name:"BeginTransactionPayload",fields:{transactionID:{type:new f(u)}}}),i=new m({name:"CommitTransactionPayload",fields:{success:{type:new f(l)}}}),n=new m({name:"RollbackTransactionPayload",fields:{success:{type:new f(l)}}});this._mutations.beginTransaction={type:new f(t),args:{},resolve:(e,t,i)=>i.beginTransaction()},this._mutations.commitTransaction={type:new f(i),args:{transactionID:{type:new f(u)}},resolve:async(e,t,i)=>await i.commitTransaction(t.transactionID)},this._mutations.rollbackTransaction={type:new f(n),args:{transactionID:{type:new f(u)}},resolve:(e,t,i)=>i.rollbackTransaction(t.transactionID)}}let n={query:new m({name:"Query",fields:t})};return this._includeMutations&&(n.mutation=new m({name:"Mutation",fields:this._mutations})),this._includeSubscriptions&&(n.subscription=new m({name:"Subscription",fields:()=>{let t={documentChanged:{type:new f(e.documentInterface),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,i)=>i.subscribeToDocumentChanged(t.id)},documentRemoved:{type:new f(u),resolve:e=>e,subscribe:(e,t,i)=>i.subscribeToDocumentRemoved()}};for(let[e,i]of Object.entries(this._record)){if(!this._includedModelIDs.has(e))continue;let n=this._aliases[e];for(let s of(t[`new${n}Created`]={type:new f(this._types[e]),resolve:e=>e,subscribe:(t,i,n)=>n.subscribeToDocumentCreated(this.getModelIDs(e))},i.interfaces??[])){let i=getGlobalID(s,e).toString();for(let[e,n]of Object.entries(this._relationsTo[i]??{}))for(let s of n)this._buildRelationSubscriptions(t,i,e,s)}for(let[i,n]of Object.entries(this._relationsTo[e]??{}))for(let s of n)this._includedModelIDs.has(s.model)&&this._buildRelationSubscriptions(t,e,i,s)}return t}})),new y(n)}_getDefinitions(){if(null==this._definitions)throw Error("Definitions must be initialized");return this._definitions}_getReference(e,t){let i=E(e),n=this._types[i];if(null!=n)return n;let s=this._getReferenceSchema(i);return this._buildReference(i,s,t)}_getReferenceSchema(e){let t=this._references[e];if(null==t)throw Error(`Could not find reference: ${e}`);return t}_getReferenceInput(e,t,i=""){let n=E(e),s=this._getReferenceSchema(n);if("array"===s.type)return new h(new f(this._getReferenceInput(s.items.$ref,!1,s.title)));if("object"===s.type){if(s.additionalProperties)return F;let e=t?`${n}-partial`:n,l=this._inputObjects[e];if(null!=l)return l;let o={};for(let[e,i]of Object.entries(s.properties)){let n=this._getReferenceInput(i.$ref,t,s.title);o[e]={type:t||!s.required.includes(e)?n:new f(n)}}let a=this._aliases[n]??r(i+s.title),u=new c({name:t?`Partial${a}Input`:`${a}Input`,fields:o});return this._inputObjects[e]=u,u}return this._buildScalar(n,s,i)}_buildSharedDefinitions(){let i=$(async(i,s)=>{if(i.startsWith("did:"))return i;let r=n(i);if(r instanceof e)return r;if(r instanceof t)return await s.loadDocument(i);throw Error(`Unsupported node ID: ${i}`)},t=>"string"==typeof t?"AccountNode":t instanceof e?"AttachmentNode":this._aliases[t.model]),s=new m({name:"AccountNode",interfaces:[i.nodeInterface],fields:()=>{let e={id:{type:new f(u),description:"Globally unique identifier of the account (DID string)",resolve:e=>e},isViewer:{type:new f(l),description:"Whether the authenticated request issuer is this account or not",resolve:(e,t,i)=>i.getViewer()===e}};for(let[i,n]of Object.entries(this._record))if(this._includedModelIDs.has(i))switch(n.behavior){case"interface":continue;case"default":{let t=this._aliases[i];e[`own${t}Connection`]={type:this._types[`${i}-connection`],args:{...I,filter:{type:this._inputObjects[`${i}-filter`]},orderBy:{type:toList(this._inputObjects[`${i}-order`])}},resolve:async(e,t,n)=>await n.resolveConnection(this.getModelIDs(i),{...t,owner:e})};break}case"unique":{let s=this._aliases[i];e[`own${s}`]={type:this._types[i],args:n.uniqueFields.length?{with:{type:new f(this._buildSetInputObjectType(i,n.uniqueFields))}}:{},resolve:async(e,s,r)=>{let l=q(n.uniqueFields,s.with),o=t.create(i,e,l);return await r.loadDocument(o.toString())}}}}return e}}),r=new m({name:"AttachmentNode",interfaces:[i.nodeInterface],fields:{id:{type:new f(u),resolve:e=>e.toString()},contentLength:{type:new f(d)},mimeType:{type:new f(_)}}}),o={id:{type:new f(u)},model:{type:new f(_)},owner:{type:new f(s)},createdAt:{type:new f(v)},updatedAt:{type:v},accessPermissions:{type:z,resolve:e=>e.data?.accessPermissions??null}},a=new p({name:"DocumentNode",interfaces:[i.nodeInterface],fields:o,resolveType:e=>this._aliases[e.model]}),c={node:i.nodeField,viewer:{type:s,description:"Account issuing the request, if authenticated",resolve:(e,t,i)=>i.getViewer()}};return{...i,accountObject:s,attachmentObject:r,documentInterface:a,documentNodeFields:o,queryFields:c}}_buildDocument(e){if(null!=this._types[e])return this._types[e];let t=this._record[e];if(null==t)throw Error(`Could not find model id: ${e}`);let i=this._getDefinitions();this._aliases[e]??=r(t.name);let n=this._aliases[e],s={name:n,interfaces:()=>[i.documentInterface,i.nodeInterface].concat(t.interfaces.map(t=>this._types[getGlobalID(t,e).toString()]).filter(e=>null!=e)),fields:()=>this._buildDocumentFields(e,t,n)},l="interface"===t.behavior,o=l?new p({...s,resolveType:e=>this._aliases[e.model]}):new m(s),{connectionType:a,edgeType:c}=g({nodeType:o});return this._types[e]=o,this._types[`${e}-connection`]=a,this._types[`${e}-edge`]=c,this._buildDocumentDataObject(e,t,n),this._buildDocumentInput(e,t),this._buildObjectFilterInput(e,t.schema,n,!0),this._buildObjectOrderByInput(e,t.schema,n,!0),!l&&this._includeMutations&&("default"===t.behavior?this._mutations[`create${n}`]=O({name:`Create${n}`,inputFields:()=>({data:{type:new f(this._inputObjects[e])},transactionID:{type:u}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(t,i,n)=>({document:await i.executeCreateMutation({modelID:e,data:t.data,info:n,transactionID:t.transactionID})})}):"unique"===t.behavior&&(this._mutations[`set${n}`]=O({name:`Set${n}`,inputFields:()=>({data:{type:new f(this._inputObjects[e])},transactionID:{type:u}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(i,n,s)=>{let r=q(t.uniqueFields,i.data);return{document:await n.executeSetMutation({modelID:e,unique:r,data:i.data,info:s,transactionID:i.transactionID})}}})),this._mutations[`update${n}`]=O({name:`Update${n}`,inputFields:()=>({id:{type:new f(u)},patch:{type:new f(toList(PatchOperation))},from:{type:this._inputObjects[`${e}-update`]},transactionID:{type:u}}),outputFields:()=>({...i.queryFields,document:{type:this._types[e]}}),mutateAndGetPayload:async(e,t,i)=>({document:await t.executeUpdateMutation({input:e,info:i,transactionID:e.transactionID})})}),this._mutations[`remove${n}`]=O({name:`Remove${n}`,inputFields:()=>({id:{type:new f(u)},transactionID:{type:u}}),outputFields:()=>({...i.queryFields,id:{type:new f(u)}}),mutateAndGetPayload:async(e,t,i)=>(await t.executeRemoveMutation({id:e.id,info:i,transactionID:e.transactionID}),{id:e.id})})),o}_buildDocumentFields(t,i,n){let s=this._buildDocumentDataObject(t,i,n),r=this._getDefinitions(),l={...r.documentNodeFields,data:{type:new f(s)}};for(let[n,o]of Object.entries(s.getFields())){let s=i.fieldsMeta[n];if(null!=s)switch(s.type){case"account":G(o.type)?l[`${n}Accounts`]={type:new f(toOuputList(r.accountObject)),resolve:e=>e.data?.[n]??[]}:l[`${n}Account`]={type:r.accountObject,resolve:e=>e.data?.[n]??null};break;case"attachment":G(o.type)?l[`${n}Attachments`]={type:new f(toOuputList(r.attachmentObject)),resolve:t=>(t.data?.[n]??[]).map(e.fromString)}:l[`${n}Attachment`]={type:r.attachmentObject,resolve:t=>{let i=t.data?.[n];return i?e.fromString(i):null}};break;case"document":{let e,i,a=s.model;if(void 0===a)continue;null===a?(e=null,i=r.documentInterface):(e=getGlobalID(a,t).toString(),this._includedModelIDs.has(e)?i=this._buildDocument(e):(i=r.documentInterface,e=null)),G(o.type)?l[`${n}Documents`]={type:new f(toOuputList(i)),resolve:async(t,i,s)=>{let r=t.data?.[n]??[];return r.length?await s.resolveList(this.getModelIDs(e),r):[]}}:l[`${n}Document`]={type:i,resolve:async(e,t,i)=>{let s=e.data?.[n];return s?await i.loadDocument(s):null}}}}}for(let e of i.interfaces??[]){let i=getGlobalID(e,t).toString();for(let[e,t]of Object.entries(this._relationsTo[i]??{}))for(let i of t)this._includedModelIDs.has(i.model)&&this._buildRelationFields(l,e,i)}for(let[e,i]of Object.entries(this._relationsTo[t]??{}))for(let t of i)this._includedModelIDs.has(t.model)&&this._buildRelationFields(l,e,t);return l}_buildDocumentDataObject(e,t,i){let n=`${e}-data`;if(null!=this._types[n])return this._types[n];let s=t.schema.required??[],r={};for(let[i,n]of Object.entries(t.schema.properties??{})){let t=n.$ref;if(null==t)throw Error(`Missing ref for field ${i} of object ${e}`);let l=this._getReference(t);r[i]={type:s.includes(i)?new f(l):l}}let l={name:`${i}Data`,interfaces:()=>t.interfaces.map(t=>{let i=`${getGlobalID(t,e).toString()}-data`;return this._types[i]}).filter(e=>null!=e),fields:r},o="interface"===t.behavior?new p(l):new m(l);return this._types[n]=o,o}_buildDocumentInput(e,t){if("interface"===t.behavior)return;let i={},n={};for(let[e,s]of Object.entries(t.schema.properties)){let r=s.$ref,l=this._getReferenceInput(r,!1);i[e]={type:t.schema.required.includes(e)?new f(l):l};let o=E(r);null==this._getReferenceSchema(o).const&&(n[e]={type:this._getReferenceInput(r,!0)})}let s=this._aliases[e];this._inputObjects[e]=new c({name:`${s}Input`,fields:i}),this._inputObjects[`${e}-update`]=new c({name:`Partial${s}Input`,fields:n})}_buildReferenceFilterInput(e,t=""){let i=E(e),n=this._getReferenceSchema(i),s=t;if("object"===n.type)return n.additionalProperties?null:this._buildObjectFilterInput(i,n,t);if("array"===n.type){let e=this._aliases[i]??r(t+n.title);return s=e,new c({name:`${e}Filter`,isOneOf:!0,fields:{isNull:{type:l}}})}let o=this._buildScalar(i,n,s),a=k[o.name];if(null!=a)return this._inputObjects[a];let u=b(o)?new c({name:`${o.name}ValueFilter`,isOneOf:!0,fields:{isNull:{type:l},equalTo:{type:o},notEqualTo:{type:o},in:{type:toList(o)},notIn:{type:toList(o)}}}):V(o);return null==this._inputObjects[u.name]&&(this._inputObjects[u.name]=u),this._inputObjects[u.name]}_buildReferenceOrderByInput(e,t=""){let i=E(e),n=this._getReferenceSchema(i);switch(n.type){case"array":return null;case"object":return n.additionalProperties?null:this._buildObjectOrderByInput(i,n,t);default:return U}}_buildObjectFilterInput(e,t,i="",n=!1){let s=`${e}-filter`,l=this._inputObjects[s];if(null!=l)return l;let o=this._aliases[e]??r(i+(t.title??"")),a=n?{_owner:{type:this._inputObjects.AccountValueFilter}}:{};for(let[e,i]of Object.entries(t.properties)){let t=this._buildReferenceFilterInput(i.$ref,o);null!==t&&(a[e]={type:t})}let u=new c({name:`${o}ObjectFilter`,fields:a}),d=new c({name:`${o}Filter`,isOneOf:!0,fields:()=>({where:{type:u},and:{type:toList(this._inputObjects[s])},or:{type:toList(this._inputObjects[s])},not:{type:this._inputObjects[s]}})});return this._inputObjects[s]=d,d}_buildObjectOrderByInput(e,t,i="",n=!1){let s=`${e}-order`,l=this._inputObjects[s];if(null!=l)return l;let o=this._aliases[e]??r(i+(t.title??"")),a=n?{_docOwner:{type:U},_createdAt:{type:U}}:{};for(let[e,i]of Object.entries(t.properties)){let t=this._buildReferenceOrderByInput(i.$ref,o);null!=t&&(a[e]={type:t})}let u=new c({name:`${o}OrderBy`,isOneOf:!0,fields:a});return this._inputObjects[s]=u,u}_buildSetInputObjectType(e,t,i){let n=i?r(i):"",s=`${e}-with-${n}`,l=this._inputObjects[s];if(null!=l)return l;let o=this._record[e],a=this._aliases[e];return this._inputObjects[s]=new c({name:`With${n}${a}Input`,fields:()=>{let e={};for(let i of t){let t=o.schema.properties[i];if(null==t)throw Error(`Field ${i} not found on model ${a}`);let n=this._getReferenceInput(t.$ref,!1);e[i]={type:new f(n)}}return e}}),this._inputObjects[s]}_buildReference(e,t,i=""){if(null!=this._types[e])return this._types[e];switch(t.type){case"array":return this._types[e]=this._buildArray(t,i),this._types[e];case"object":return this._types[e]=t.additionalProperties?F:this._buildObject(e,t,i),this._types[e];default:return this._buildScalar(e,t,i)}}_buildScalar(e,t,i=""){if(null!=this._types[e])return this._types[e];switch(t.type){case"boolean":this._types[e]=l;break;case"integer":this._types[e]=d;break;case"number":this._types[e]=a;break;case"string":this._types[e]=this._buildString(t,i)}return this._types[e]}_buildArray(e,t=""){let i=e.items.$ref;return new h(new f(this._getReference(i,r(t+e.title))))}_buildObject(e,t,i=""){let n=r(i+t.title),s=this._buildObjectFields(e,t,n);return new m({name:n,fields:s})}_buildObjectFields(e,t,i=""){let n=t.required??[],s={};for(let[r,l]of Object.entries(t.properties??{})){let t=l.$ref;if(null==t)throw Error(`Missing ref for field ${r} of object ${e}`);let o=this._getReference(t,i);s[r]={type:n.includes(r)?new f(o):o}}return s}_buildRelationFields(e,t,i){if(i.isList)return;let n=i.model,s=`${r(t)}Of${this._aliases[n]}`;e[`in${s}`]={type:new f(this._types[`${n}-connection`]),args:{...I,filter:{type:this._inputObjects[`${n}-filter`]},orderBy:{type:toList(this._inputObjects[`${n}-order`])}},resolve:(e,i,s)=>{let r={where:{[t]:{equalTo:e.id}}},l=i.filter?{and:[i.filter,r]}:r;return s.resolveConnection(this.getModelIDs(n),{...i,filter:l})}},e[`in${s}Count`]={type:new f(d),args:{filter:{type:this._inputObjects[`${n}-filter`]}},resolve:(e,i,s)=>{let r={where:{[t]:{equalTo:e.id}}},l=i.filter?{and:[i.filter,r]}:r;return s.resolveCount(this.getModelIDs(n),l)}}}_buildRelationSubscriptions(e,t,i,n){if(n.isList)return;let s=r(i);e[`edge${this._aliases[n.model]}AddedAs${s}To${this._aliases[t]}`]={type:new f(this._types[`${n.model}-edge`]),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,s)=>s.subscribeToDocumentEdgeAdded(this.getModelIDs(n.model),e=>e[i]===t.id)},e[`edge${this._aliases[n.model]}RemovedAs${s}From${this._aliases[t]}`]={type:new f(u),args:{id:{type:new f(u)}},resolve:e=>e,subscribe:(e,t,s)=>s.subscribeToDocumentEdgeRemoved(this.getModelIDs(n.model),e=>e[i]===t.id)}}_buildString(e,t){return null!=e.const?_:null!=e.enum?this._buildEnumString(e,t):null!=e.format?this._buildFormatString(e):this._buildCustomString(e)}_buildCustomString(e){return null==e.title?_:C[e.title.toLowerCase()]??_}_buildEnumString(e,t=""){let i=r(t+e.title),n=`${i}-enum`;if(null==this._types[n]){let t={};for(let i of e.enum)t[i]={value:i};this._types[n]=new o({name:i,values:t})}return this._types[n]}_buildFormatString(e){let t=P[e.format];if(null==t)throw Error(`Unsupported string format: ${e.format}`);return t}}export function createSchema(e){return new SchemaBuilder(e).build()}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@enkaku/async": "^0.13.0",
|
|
19
19
|
"@enkaku/codec": "^0.13.0",
|
|
20
20
|
"change-case": "^5.4.4",
|
|
21
|
-
"graphql": "^16.
|
|
21
|
+
"graphql": "^16.13.1",
|
|
22
22
|
"graphql-relay": "^0.10.2",
|
|
23
23
|
"graphql-scalars": "^1.25.0",
|
|
24
24
|
"multiformats": "^13.4.2",
|
|
25
|
-
"@kubun/id": "^0.
|
|
26
|
-
"@kubun/protocol": "^0.
|
|
25
|
+
"@kubun/id": "^0.6.0",
|
|
26
|
+
"@kubun/protocol": "^0.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@enkaku/capability": "^0.13.0",
|
|
30
30
|
"@enkaku/token": "0.13.0",
|
|
31
|
-
"@kubun/db": "^0.
|
|
32
|
-
"@kubun/test-utils": "^0.
|
|
31
|
+
"@kubun/db": "^0.6.0",
|
|
32
|
+
"@kubun/test-utils": "^0.6.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build:clean": "del lib",
|