@ez4/database 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/library.cjs CHANGED
@@ -1,93 +1,96 @@
1
- "use strict";var K=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var r in t)K(e,r,{get:t[r],enumerable:!0})},ze=(e,t,r,o)=>{if(t&&
2
- typeof t=="object"||typeof t=="function")for(let a of Oe(t))!Re.call(e,a)&&a!==r&&
3
- K(e,a,{get:()=>t[a],enumerable:!(o=Ae(t,a))||o.enumerable});return e};var Ce=e=>ze(K({},"__esModule",{value:!0}),e);var Ke={};ke(Ke,{IncompleteHandlerError:()=>F,IncompleteServiceError:()=>E,IncompleteStreamError:()=>H,
4
- IncompleteTableError:()=>w,IncorrectIndexesTypeError:()=>O,IncorrectRelationsTypeError:()=>v,
5
- IncorrectSchemaTypeError:()=>C,IncorrectStreamTypeError:()=>$,InvalidIndexReferenceError:()=>k,
6
- InvalidIndexTypeError:()=>R,InvalidIndexesTypeError:()=>A,InvalidRelationAliasError:()=>P,
7
- InvalidRelationColumnError:()=>d,InvalidRelationTableError:()=>j,InvalidRelationTargetError:()=>D,
8
- InvalidRelationsTypeError:()=>I,InvalidSchemaTypeError:()=>z,InvalidStreamTypeError:()=>N,
9
- ServiceType:()=>q,getDatabaseServices:()=>Y,getDatabaseTable:()=>X,getTableSchema:()=>W,
10
- isDatabaseService:()=>He,registerTriggers:()=>Je});module.exports=Ce(Ke);var je=require("@ez4/common/library"),Pe=require("@ez4/schema/library"),Ee=require("@ez4/project/library");var c=require("@ez4/common/library"),Ie=require("@ez4/reflection");var u=require("@ez4/common/library"),I=class extends u.InvalidTypeError{constructor(t){
1
+ "use strict";var X=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var He=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},$e=(e,t,r,o)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let s of Ce(t))!Ne.call(e,s)&&s!==r&&
3
+ X(e,s,{get:()=>t[s],enumerable:!(o=ze(t,s))||o.enumerable});return e};var qe=e=>$e(X({},"__esModule",{value:!0}),e);var Xe={};He(Xe,{IncompleteHandlerError:()=>F,IncompleteServiceError:()=>w,IncompleteStreamError:()=>H,
4
+ IncompleteTableError:()=>O,IncorrectIndexesTypeError:()=>k,IncorrectRelationsTypeError:()=>v,
5
+ IncorrectSchemaTypeError:()=>N,IncorrectStreamTypeError:()=>q,InvalidIndexReferenceError:()=>z,
6
+ InvalidIndexTypeError:()=>R,InvalidIndexesTypeError:()=>A,InvalidRelationAliasError:()=>E,
7
+ InvalidRelationColumnError:()=>f,InvalidRelationTableError:()=>j,InvalidRelationTargetError:()=>P,
8
+ InvalidRelationsTypeError:()=>D,InvalidSchemaTypeError:()=>C,InvalidStreamTypeError:()=>$,
9
+ ServiceType:()=>U,getDatabaseServices:()=>L,getDatabaseTable:()=>Z,getTableSchema:()=>Y,
10
+ isDatabaseService:()=>Fe,registerTriggers:()=>We});module.exports=qe(Xe);var Oe=require("@ez4/common/library"),Ae=require("@ez4/schema/library"),ke=require("@ez4/project/library");var l=require("@ez4/common/library"),je=require("@ez4/reflection");var u=require("@ez4/common/library"),D=class extends u.InvalidTypeError{constructor(t){
11
11
  super("Invalid table relations type",void 0,"Database.Relations",t)}},v=class extends u.IncorrectTypeError{constructor(r,o){
12
12
  super("Incorrect table relations type",r,"Database.Relations",o);this.schemaType=
13
- r}},D=class extends u.TypeError{constructor(r,o){super(`Target ${r} must follow \
13
+ r}},P=class extends u.TypeError{constructor(r,o){super(`Target ${r} must follow \
14
14
  the pattern 'column@alias'.`,o);this.relationSource=r}},j=class extends u.TypeError{constructor(r,o){
15
- super(`Relation table ${r} don't exists.`,o);this.relationTable=r}},d=class extends u.TypeError{constructor(r,o){
16
- super(`Relation column ${r} don't exists.`,o);this.relationColumn=r}},P=class extends u.TypeError{constructor(r,o){
15
+ super(`Relation table ${r} don't exists.`,o);this.relationTable=r}},f=class extends u.TypeError{constructor(r,o){
16
+ super(`Relation column ${r} don't exists.`,o);this.relationColumn=r}},E=class extends u.TypeError{constructor(r,o){
17
17
  super(`Relation alias ${r} can't override table columns.`,o);this.relationAlias=
18
- r}};var q="@ez4/database",He=e=>e.type===q;var L=require("@ez4/common/library"),E=class extends L.IncompleteTypeError{constructor(t,r){
19
- super("Incomplete database service",t,r)}};var p=require("@ez4/common/library"),U=require("@ez4/reflection"),_=e=>(0,p.isClassDeclaration)(
20
- e)&&(0,p.hasHeritageType)(e,"Database.Service"),ee=e=>(0,p.isModelDeclaration)(e)&&
21
- (0,p.hasHeritageType)(e,"Database.Table"),re=e=>(0,U.isTypeCallback)(e)||(0,U.isTypeFunction)(
22
- e),te=e=>(0,p.hasHeritageType)(e,"Database.Relations"),oe=e=>(0,p.hasHeritageType)(
23
- e,"Database.Indexes"),ae=e=>(0,p.hasHeritageType)(e,"Database.Schema"),se=e=>(0,p.hasHeritageType)(
24
- e,"Database.Stream");var M=require("@ez4/common/library"),h=require("@ez4/reflection");var ne=require("@ez4/common/library"),w=class extends ne.IncompleteTypeError{constructor(t,r){
18
+ r}};var U="@ez4/database",Fe=e=>e.type===U;var re=require("@ez4/common/library"),w=class extends re.IncompleteTypeError{constructor(t,r){
19
+ super("Incomplete database service",t,r)}};var m=require("@ez4/common/library"),V=require("@ez4/reflection"),_=e=>(0,m.isClassDeclaration)(
20
+ e)&&(0,m.hasHeritageType)(e,"Database.Service"),te=e=>(0,m.isModelDeclaration)(e)&&
21
+ (0,m.hasHeritageType)(e,"Database.Table"),oe=e=>(0,V.isTypeCallback)(e)||(0,V.isTypeFunction)(
22
+ e),se=e=>(0,m.hasHeritageType)(e,"Database.Relations"),ae=e=>(0,m.hasHeritageType)(
23
+ e,"Database.Indexes"),ne=e=>(0,m.hasHeritageType)(e,"Database.Schema"),ie=e=>(0,m.hasHeritageType)(
24
+ e,"Database.Stream");var I=require("@ez4/common/library"),M=require("@ez4/reflection");var pe=require("@ez4/common/library"),O=class extends pe.IncompleteTypeError{constructor(t,r){
25
25
  super("Incomplete database table",t,r)}};var T=require("@ez4/common/library"),A=class extends T.InvalidTypeError{constructor(t){
26
- super("Invalid table indexes type",void 0,"Database.Indexes",t)}},O=class extends T.IncorrectTypeError{constructor(r,o){
26
+ super("Invalid table indexes type",void 0,"Database.Indexes",t)}},k=class extends T.IncorrectTypeError{constructor(r,o){
27
27
  super("Incorrect table indexes type",r,"Database.Indexes",o);this.schemaType=r}},
28
28
  R=class extends T.TypeError{constructor(r,o){super(`Invalid index type, ${r} mus\
29
- t follow one of the Index options.`,o);this.indexName=r}},k=class extends T.TypeError{constructor(r,o){
30
- super(`Invalid index reference, ${r} must be valid column.`,o);this.indexName=r}};var b=require("@ez4/common/library"),y=require("@ez4/reflection");var pe=(e,t,r,o)=>{if(!(0,y.isTypeReference)(e))return ie(e,t,o);let a=r[e.path];
31
- return a?ie(a,t,o):null},ie=(e,t,r)=>(0,y.isTypeObject)(e)?le(e,(0,b.getObjectMembers)(
32
- e),r):(0,b.isModelDeclaration)(e)?te(e)?le(e,(0,b.getModelMembers)(e),r):(r.push(
33
- new v(e.name,e.file)),null):(r.push(new I(t.file)),null),le=(e,t,r)=>{let o=[];for(let a of t){
34
- if(!(0,y.isModelProperty)(a)||a.inherited)continue;let s=(0,b.getPropertyString)(
35
- a);if(!s)return r.push(new D(a.name,e.file)),null;let[n,i]=a.name.split(":",2),[
36
- l,V]=s.split("@",2);o.push({foreign:!1,sourceTable:n,sourceColumn:i,targetColumn:l,
37
- targetAlias:V})}return o};var f=require("@ez4/common/library"),x=require("@ez4/reflection");var ue=(e,t,r,o)=>{if(!(0,x.isTypeReference)(e))return me(e,t,o);let a=r[e.path];
38
- return a?me(a,t,o):null},me=(e,t,r)=>(0,x.isTypeObject)(e)?ce(e,(0,f.getObjectMembers)(
39
- e),r):(0,f.isModelDeclaration)(e)?oe(e)?ce(e,(0,f.getModelMembers)(e),r):(r.push(
40
- new O(e.name,e.file)),null):(r.push(new A(t.file)),null),ce=(e,t,r)=>{let o=[];for(let a of t){
41
- if(!(0,x.isModelProperty)(a)||a.inherited)continue;let s=a.name,n=(0,f.getPropertyString)(
42
- a);switch(n){case"primary":case"secondary":case"unique":case"ttl":o.push({name:s,
43
- columns:s.split(":"),type:n});break;default:return r.push(new R(s,e.file)),null}}
44
- return o};var G=require("@ez4/reflection"),fe=require("@ez4/common/library"),Q=require("@ez4/schema/library");var B=require("@ez4/common/library"),z=class extends B.InvalidTypeError{constructor(t){
45
- super("Invalid table schema type",void 0,"Database.Schema",t)}},C=class extends B.IncorrectTypeError{constructor(r,o){
46
- super("Incorrect table schema type",r,"Database.Schema",o);this.schemaType=r}};var W=(e,t,r,o)=>{if(!(0,G.isTypeReference)(e))return be(e,t,r,o);let a=r[e.path];
47
- return a?be(a,t,r,o):null},be=(e,t,r,o)=>(0,G.isTypeObject)(e)?(0,Q.getObjectSchema)(
48
- e,r):(0,fe.isModelDeclaration)(e)?ae(e)?(0,Q.getObjectSchema)(e,r):(o.push(new C(
49
- e.name,e.file)),null):(o.push(new z(t.file)),null);var m=require("@ez4/common/library"),S=require("@ez4/reflection"),ge=require("@ez4/utils");var g=require("@ez4/common/library"),H=class extends g.IncompleteTypeError{constructor(t,r){
50
- super("Incomplete table stream",t,r)}},N=class extends g.InvalidTypeError{constructor(t){
51
- super("Invalid table stream type",void 0,"Database.Stream",t)}},$=class extends g.IncorrectTypeError{constructor(r,o){
52
- super("Incorrect table stream type",r,"Database.Stream",o);this.streamType=r}};var Te=require("@ez4/common/library"),F=class extends Te.IncompleteTypeError{constructor(t,r){
53
- super("Incomplete stream handler",t,r)}};var de=(e,t,r)=>{if(!re(e))return null;let o={},a=new Set(["name","file","change"]);
54
- return e.description&&(o.description=e.description),(o.name=e.name)&&a.delete("n\
55
- ame"),(o.file=e.file)&&a.delete("file"),e.parameters&&a.delete("change"),a.size===
56
- 0&&$e(o)?o:(r.push(new F([...a],e.file)),null)},$e=e=>!!e.name&&!!e.file;var Se=(e,t,r,o)=>{if(!(0,S.isTypeReference)(e))return ye(e,t,r,o);let a=r[e.path];
57
- return a?ye(a,t,r,o):null},Fe=e=>!!e.handler,ye=(e,t,r,o)=>(0,S.isTypeObject)(e)?
58
- xe(e,(0,m.getObjectMembers)(e),r,o):(0,m.isModelDeclaration)(e)?se(e)?xe(e,(0,m.getModelMembers)(
59
- e),r,o):(o.push(new $(e.name,e.file)),null):(o.push(new N(t.file)),null),xe=(e,t,r,o)=>{
60
- let a={},s=new Set(["handler"]);for(let n of t)if(!(!(0,S.isModelProperty)(n)||n.
61
- inherited))switch(n.name){case"handler":a.handler=de(n.value,r,o);break;case"tim\
62
- eout":case"memory":{let i=(0,m.getPropertyNumber)(n);(0,ge.isAnyNumber)(i)&&(a[n.
63
- name]=i);break}case"variables":a.variables=(0,m.getLinkedVariableList)(n,o);break}
64
- return Fe(a)?a:(o.push(new H([...s],e.file)),null)};var X=(e,t,r)=>{if(!(0,h.isTypeReference)(e))return Me(e,t,r);let o=t[e.path];return o?
65
- Me(o,t,r):null},Ve=e=>!!e.name&&!!e.schema&&!!e.indexes,Me=(e,t,r)=>ee(e)?he(e,(0,M.getModelMembers)(
66
- e),t,r):(0,h.isTypeObject)(e)?he(e,(0,M.getObjectMembers)(e),t,r):null,he=(e,t,r,o)=>{
67
- let a={},s=new Set(["name","schema","indexes"]);for(let i of t)if(!(!(0,h.isModelProperty)(
68
- i)||i.inherited))switch(i.name){case"name":(a.name=(0,M.getPropertyString)(i))&&
69
- s.delete(i.name);break;case"relations":{let l=pe(i.value,e,r,o);l&&(a.relations=
70
- l);break}case"indexes":{(a.indexes=ue(i.value,e,r,o))&&s.delete(i.name);break}case"\
71
- schema":{(a.schema=W(i.value,e,r,o))&&s.delete(i.name);break}case"stream":{a.stream=
72
- Se(i.value,e,r,o);break}}if(!Ve(a))return o.push(new w([...s],e.file)),null;let n=qe(
73
- e,a.indexes,a.schema);return n.length?(o.push(...n),null):(a.relations&&Ue(a.relations,
74
- a.indexes),a)},qe=(e,t,r)=>{let o=r.properties,a=[];for(let{name:s,columns:n}of t)
75
- n.some(l=>!o[l])&&a.push(new k(s,e.file));return a},Ue=(e,t)=>{for(let r of e)r.
76
- foreign=!t.some(({name:o,type:a})=>a==="primary"&&o===r.targetColumn)};var Y=e=>{let t={},r=[];for(let o in e){let a=e[o];if(!_(a))continue;let s={type:q},
77
- n=new Set(["engine","tables"]);s.name=a.name;for(let l of(0,c.getModelMembers)(a))
78
- if(!(!(0,Ie.isModelProperty)(l)||l.inherited))switch(l.name){case"engine":{(s.engine=
79
- (0,c.getPropertyString)(l))&&n.delete(l.name);break}case"tables":(s.tables=Be(l,
80
- e,r))&&n.delete(l.name);break;case"variables":s.variables=(0,c.getLinkedVariableList)(
81
- l,r);break;case"services":s.services=(0,c.getLinkedServiceList)(l,e,r);break}if(!_e(
82
- s)){r.push(new E([...n],a.file));continue}let i=Ge(a,s.tables);if(i.length){r.push(
83
- ...i);continue}t[a.name]=s}return{services:t,errors:r}},_e=e=>!!e.name&&!!e.tables,
84
- Be=(e,t,r)=>{let o=(0,c.getPropertyTuple)(e)??[],a=[];for(let s of o){let n=X(s,
85
- t,r);n&&a.push(n)}return a},Ge=(e,t)=>{let r=[];for(let{relations:o,schema:a}of t){
86
- if(!o)continue;let s=a.properties;for(let n of o){let{sourceTable:i,sourceColumn:l,
87
- targetColumn:V,targetAlias:Z}=n,J=t.find(({name:we})=>we===i)?.schema.properties;
88
- s[V]||r.push(new d(V,e.file)),s[Z]&&r.push(new P(Z,e.file)),J||r.push(new j(i,e.
89
- file)),J&&!J[l]&&r.push(new d(l,e.file))}}return r};var ve=e=>_(e)?e.name:null;var De=!1,Je=()=>{De||((0,je.registerTriggers)(),(0,Pe.registerTriggers)(),(0,Ee.createTrigger)(
90
- "@ez4/database",{"metadata:getServices":Y,"metadata:getLinkedService":ve}),De=!0)};0&&(module.exports={IncompleteHandlerError,IncompleteServiceError,IncompleteStreamError,
29
+ t follow one of the Index options.`,o);this.indexName=r}},z=class extends T.TypeError{constructor(r,o){
30
+ super(`Invalid index reference, ${r} must be valid column.`,o);this.indexName=r}};var b=require("@ez4/common/library"),y=require("@ez4/reflection");var ce=(e,t,r,o)=>{if(!(0,y.isTypeReference)(e))return le(e,t,o);let s=r[e.path];
31
+ return s?le(s,t,o):null},le=(e,t,r)=>(0,y.isTypeObject)(e)?me(e,(0,b.getObjectMembers)(
32
+ e),r):(0,b.isModelDeclaration)(e)?se(e)?me(e,(0,b.getModelMembers)(e),r):(r.push(
33
+ new v(e.name,e.file)),null):(r.push(new D(t.file)),null),me=(e,t,r)=>{let o=[];for(let s of t){
34
+ if(!(0,y.isModelProperty)(s)||s.inherited)continue;let a=(0,b.getPropertyString)(
35
+ s);if(!a)return r.push(new P(s.name,e.file)),null;let[n,i]=s.name.split(":",2),[
36
+ p,h]=a.split("@",2);o.push({sourceTable:n,sourceColumn:i,targetColumn:p,targetAlias:h})}
37
+ return o};var d=require("@ez4/common/library"),x=require("@ez4/reflection");var de=(e,t,r,o)=>{if(!(0,x.isTypeReference)(e))return ue(e,t,o);let s=r[e.path];
38
+ return s?ue(s,t,o):null},ue=(e,t,r)=>(0,x.isTypeObject)(e)?be(e,(0,d.getObjectMembers)(
39
+ e),r):(0,d.isModelDeclaration)(e)?ae(e)?be(e,(0,d.getModelMembers)(e),r):(r.push(
40
+ new k(e.name,e.file)),null):(r.push(new A(t.file)),null),be=(e,t,r)=>{let o=[];for(let s of t){
41
+ if(!(0,x.isModelProperty)(s)||s.inherited)continue;let a=s.name,n=(0,d.getPropertyString)(
42
+ s);switch(n){case"primary":case"secondary":case"unique":case"ttl":o.push({name:a,
43
+ columns:a.split(":"),type:n});break;default:return r.push(new R(a,e.file)),null}}
44
+ return o};var G=require("@ez4/schema/library"),J=require("@ez4/reflection"),ye=require("@ez4/common/library");var B=require("@ez4/common/library"),C=class extends B.InvalidTypeError{constructor(t){
45
+ super("Invalid table schema type",void 0,"Database.Schema",t)}},N=class extends B.IncorrectTypeError{constructor(r,o){
46
+ super("Incorrect table schema type",r,"Database.Schema",o);this.schemaType=r}};var Y=(e,t,r,o)=>{if(!(0,J.isTypeReference)(e))return Te(e,t,r,o);let s=r[e.path];
47
+ return s?Te(s,t,r,o):null},Te=(e,t,r,o)=>(0,J.isTypeObject)(e)?fe(e,r):(0,ye.isModelDeclaration)(
48
+ e)?ne(e)?fe(e,r):(o.push(new N(e.name,e.file)),null):(o.push(new C(t.file)),null),
49
+ fe=(e,t)=>{let r=(0,G.getObjectSchema)(e,t);return r&&(0,G.isObjectSchema)(r)?r:
50
+ null};var c=require("@ez4/common/library"),S=require("@ez4/reflection"),Me=require("@ez4/utils");var g=require("@ez4/common/library"),H=class extends g.IncompleteTypeError{constructor(t,r){
51
+ super("Incomplete table stream",t,r)}},$=class extends g.InvalidTypeError{constructor(t){
52
+ super("Invalid table stream type",void 0,"Database.Stream",t)}},q=class extends g.IncorrectTypeError{constructor(r,o){
53
+ super("Incorrect table stream type",r,"Database.Stream",o);this.streamType=r}};var xe=require("@ez4/common/library"),F=class extends xe.IncompleteTypeError{constructor(t,r){
54
+ super("Incomplete stream handler",t,r)}};var ge=(e,t,r)=>{if(!oe(e))return null;let o={},s=new Set(["name","file","change"]);
55
+ return e.description&&(o.description=e.description),(o.name=e.name)&&s.delete("n\
56
+ ame"),(o.file=e.file)&&s.delete("file"),e.parameters&&s.delete("change"),s.size===
57
+ 0&&Ue(o)?o:(r.push(new F([...s],e.file)),null)},Ue=e=>!!e.name&&!!e.file;var he=(e,t,r,o)=>{if(!(0,S.isTypeReference)(e))return Se(e,t,r,o);let s=r[e.path];
58
+ return s?Se(s,t,r,o):null},Ve=e=>!!e.handler,Se=(e,t,r,o)=>(0,S.isTypeObject)(e)?
59
+ Ie(e,(0,c.getObjectMembers)(e),r,o):(0,c.isModelDeclaration)(e)?ie(e)?Ie(e,(0,c.getModelMembers)(
60
+ e),r,o):(o.push(new q(e.name,e.file)),null):(o.push(new $(t.file)),null),Ie=(e,t,r,o)=>{
61
+ let s={},a=new Set(["handler"]);for(let n of t)if(!(!(0,S.isModelProperty)(n)||n.
62
+ inherited))switch(n.name){case"handler":s.handler=ge(n.value,r,o);break;case"tim\
63
+ eout":case"memory":{let i=(0,c.getPropertyNumber)(n);(0,Me.isAnyNumber)(i)&&(s[n.
64
+ name]=i);break}case"variables":s.variables=(0,c.getLinkedVariableList)(n,o);break}
65
+ return Ve(s)?s:(o.push(new H([...a],e.file)),null)};var Z=(e,t,r)=>{if(!(0,M.isTypeReference)(e))return De(e,t,r);let o=t[e.path];return o?
66
+ De(o,t,r):null},_e=e=>!!e.name&&!!e.schema&&!!e.indexes,De=(e,t,r)=>te(e)?ve(e,(0,I.getModelMembers)(
67
+ e),t,r):(0,M.isTypeObject)(e)?ve(e,(0,I.getObjectMembers)(e),t,r):null,ve=(e,t,r,o)=>{
68
+ let s={},a=new Set(["name","schema","indexes"]);for(let i of t)if(!(!(0,M.isModelProperty)(
69
+ i)||i.inherited))switch(i.name){case"name":(s.name=(0,I.getPropertyString)(i))&&
70
+ a.delete(i.name);break;case"relations":{let p=ce(i.value,e,r,o);p&&(s.relations=
71
+ p);break}case"indexes":{(s.indexes=de(i.value,e,r,o))&&a.delete(i.name);break}case"\
72
+ schema":{(s.schema=Y(i.value,e,r,o))&&a.delete(i.name);break}case"stream":{s.stream=
73
+ he(i.value,e,r,o);break}}if(!_e(s))return o.push(new O([...a],e.file)),null;let n=Be(
74
+ e,s.indexes,s.schema);return n.length?(o.push(...n),null):s},Be=(e,t,r)=>{let o=r.
75
+ properties,s=[];for(let{name:a,columns:n}of t)n.some(p=>!o[p])&&s.push(new z(a,e.
76
+ file));return s};var L=e=>{let t={},r=[];for(let o in e){let s=e[o];if(!_(s)||(0,l.isExternalStatement)(
77
+ s))continue;let a={type:U},n=new Set(["engine","tables"]);a.name=s.name;for(let p of(0,l.getModelMembers)(
78
+ s))if(!(!(0,je.isModelProperty)(p)||p.inherited))switch(p.name){case"engine":{(a.
79
+ engine=(0,l.getPropertyString)(p))&&n.delete(p.name);break}case"tables":(a.tables=
80
+ Je(p,e,r))&&n.delete(p.name);break;case"variables":a.variables=(0,l.getLinkedVariableList)(
81
+ p,r);break;case"services":a.services=(0,l.getLinkedServiceList)(p,e,r);break}if(!Ge(
82
+ a)){r.push(new w([...n],s.file));continue}let i=Ke(s,a.tables);if(i.length){r.push(
83
+ ...i);continue}if(t[s.name]){r.push(new l.DuplicateServiceError(s.name,s.file));
84
+ continue}t[s.name]=a}return{services:t,errors:r}},Ge=e=>!!e.name&&!!e.tables,Je=(e,t,r)=>{
85
+ let o=(0,l.getPropertyTuple)(e)??[],s=[];for(let a of o){let n=Z(a,t,r);n&&s.push(
86
+ n)}return s},Ke=(e,t)=>{let r=Qe(t),o=[];for(let{relations:s,schema:a,indexes:n}of t){
87
+ if(!s)continue;let i=a.properties;for(let p of s){let{sourceTable:h,sourceColumn:K,
88
+ targetColumn:Q,targetAlias:ee}=p;i[Q]||o.push(new f(Q,e.file)),i[ee]&&o.push(new E(
89
+ ee,e.file));let W=r[h]?.schema.properties;W||o.push(new j(h,e.file)),W&&!W[K]&&o.
90
+ push(new f(K,e.file));let Re=r[h]?.indexes??[];p.sourceIndex=Pe(Re,K),p.targetIndex=
91
+ Pe(n,Q)}}return o},Pe=(e,t)=>e.find(({name:r})=>r===t)?.type,Qe=e=>e.reduce((t,r)=>({
92
+ ...t,[r.name]:r}),{});var Ee=e=>_(e)?e.name:null;var we=!1,We=()=>{we||((0,Oe.registerTriggers)(),(0,Ae.registerTriggers)(),(0,ke.createTrigger)(
93
+ "@ez4/database",{"metadata:getServices":L,"metadata:getLinkedService":Ee}),we=!0)};0&&(module.exports={IncompleteHandlerError,IncompleteServiceError,IncompleteStreamError,
91
94
  IncompleteTableError,IncorrectIndexesTypeError,IncorrectRelationsTypeError,IncorrectSchemaTypeError,
92
95
  IncorrectStreamTypeError,InvalidIndexReferenceError,InvalidIndexTypeError,InvalidIndexesTypeError,
93
96
  InvalidRelationAliasError,InvalidRelationColumnError,InvalidRelationTableError,InvalidRelationTargetError,
package/dist/library.mjs CHANGED
@@ -1,89 +1,92 @@
1
- import{registerTriggers as dr}from"@ez4/common/library";import{registerTriggers as yr}from"@ez4/schema/library";
2
- import{createTrigger as xr}from"@ez4/project/library";import{getLinkedServiceList as ir,getLinkedVariableList as lr,getPropertyString as pr,
3
- getPropertyTuple as mr,getModelMembers as cr}from"@ez4/common/library";import{isModelProperty as ur}from"@ez4/reflection";import{IncorrectTypeError as ie,InvalidTypeError as le,TypeError as y}from"@ez4/common/library";
4
- var u=class extends le{constructor(o){super("Invalid table relations type",void 0,
5
- "Database.Relations",o)}},b=class extends ie{constructor(r,t){super("Incorrect t\
6
- able relations type",r,"Database.Relations",t);this.schemaType=r}},f=class extends y{constructor(r,t){
7
- super(`Target ${r} must follow the pattern 'column@alias'.`,t);this.relationSource=
8
- r}},T=class extends y{constructor(r,t){super(`Relation table ${r} don't exists.`,
9
- t);this.relationTable=r}},m=class extends y{constructor(r,t){super(`Relation col\
10
- umn ${r} don't exists.`,t);this.relationColumn=r}},d=class extends y{constructor(r,t){
11
- super(`Relation alias ${r} can't override table columns.`,t);this.relationAlias=
12
- r}};var R="@ez4/database",Mr=e=>e.type===R;import{IncompleteTypeError as pe}from"@ez4/common/library";var x=class extends pe{constructor(o,r){
13
- super("Incomplete database service",o,r)}};import{hasHeritageType as p,isClassDeclaration as me,isModelDeclaration as ce}from"@ez4/common/library";
14
- import{isTypeCallback as ue,isTypeFunction as be}from"@ez4/reflection";var g=e=>me(
15
- e)&&p(e,"Database.Service"),z=e=>ce(e)&&p(e,"Database.Table"),C=e=>ue(e)||be(e),
16
- H=e=>p(e,"Database.Relations"),N=e=>p(e,"Database.Indexes"),$=e=>p(e,"Database.S\
17
- chema"),F=e=>p(e,"Database.Stream");import{getModelMembers as Ze,getObjectMembers as Le,getPropertyString as er}from"@ez4/common/library";
18
- import{isModelProperty as rr,isTypeObject as tr,isTypeReference as or}from"@ez4/reflection";import{IncompleteTypeError as fe}from"@ez4/common/library";var S=class extends fe{constructor(o,r){
19
- super("Incomplete database table",o,r)}};import{IncorrectTypeError as Te,InvalidTypeError as de,TypeError as V}from"@ez4/common/library";
20
- var M=class extends de{constructor(o){super("Invalid table indexes type",void 0,
21
- "Database.Indexes",o)}},h=class extends Te{constructor(r,t){super("Incorrect tab\
22
- le indexes type",r,"Database.Indexes",t);this.schemaType=r}},I=class extends V{constructor(r,t){
23
- super(`Invalid index type, ${r} must follow one of the Index options.`,t);this.indexName=
24
- r}},v=class extends V{constructor(r,t){super(`Invalid index reference, ${r} must\
25
- be valid column.`,t);this.indexName=r}};import{isModelDeclaration as ye,getModelMembers as xe,getObjectMembers as ge,getPropertyString as Se}from"@ez4/common/library";
26
- import{isModelProperty as Me,isTypeObject as he,isTypeReference as Ie}from"@ez4/reflection";var _=(e,o,r,t)=>{if(!Ie(e))return q(e,o,t);let a=r[e.path];return a?q(a,o,t):null},
27
- q=(e,o,r)=>he(e)?U(e,ge(e),r):ye(e)?H(e)?U(e,xe(e),r):(r.push(new b(e.name,e.file)),
28
- null):(r.push(new u(o.file)),null),U=(e,o,r)=>{let t=[];for(let a of o){if(!Me(a)||
29
- a.inherited)continue;let s=Se(a);if(!s)return r.push(new f(a.name,e.file)),null;
30
- let[n,i]=a.name.split(":",2),[l,c]=s.split("@",2);t.push({foreign:!1,sourceTable:n,
31
- sourceColumn:i,targetColumn:l,targetAlias:c})}return t};import{isModelDeclaration as De,getModelMembers as je,getObjectMembers as Pe,getPropertyString as Ee}from"@ez4/common/library";
32
- import{isModelProperty as we,isTypeObject as Ae,isTypeReference as Oe}from"@ez4/reflection";var J=(e,o,r,t)=>{if(!Oe(e))return B(e,o,t);let a=r[e.path];return a?B(a,o,t):null},
33
- B=(e,o,r)=>Ae(e)?G(e,Pe(e),r):De(e)?N(e)?G(e,je(e),r):(r.push(new h(e.name,e.file)),
34
- null):(r.push(new M(o.file)),null),G=(e,o,r)=>{let t=[];for(let a of o){if(!we(a)||
35
- a.inherited)continue;let s=a.name,n=Ee(a);switch(n){case"primary":case"secondary":case"\
36
- unique":case"ttl":t.push({name:s,columns:s.split(":"),type:n});break;default:return r.
37
- push(new I(s,e.file)),null}}return t};import{isTypeObject as ze,isTypeReference as Ce}from"@ez4/reflection";import{isModelDeclaration as He}from"@ez4/common/library";
38
- import{getObjectSchema as K}from"@ez4/schema/library";import{IncorrectTypeError as Re,InvalidTypeError as ke}from"@ez4/common/library";
39
- var D=class extends ke{constructor(o){super("Invalid table schema type",void 0,"\
40
- Database.Schema",o)}},j=class extends Re{constructor(r,t){super("Incorrect table\
41
- schema type",r,"Database.Schema",t);this.schemaType=r}};var W=(e,o,r,t)=>{if(!Ce(e))return Q(e,o,r,t);let a=r[e.path];return a?Q(a,o,r,t):
42
- null},Q=(e,o,r,t)=>ze(e)?K(e,r):He(e)?$(e)?K(e,r):(t.push(new j(e.name,e.file)),
43
- null):(t.push(new D(o.file)),null);import{getLinkedVariableList as Ue,getModelMembers as _e,getObjectMembers as Be,
44
- getPropertyNumber as Ge,isModelDeclaration as Je}from"@ez4/common/library";import{
45
- isModelProperty as Ke,isTypeObject as Qe,isTypeReference as We}from"@ez4/reflection";
46
- import{isAnyNumber as Xe}from"@ez4/utils";import{IncompleteTypeError as Ne,IncorrectTypeError as $e,InvalidTypeError as Fe}from"@ez4/common/library";
47
- var P=class extends Ne{constructor(o,r){super("Incomplete table stream",o,r)}},E=class extends Fe{constructor(o){
48
- super("Invalid table stream type",void 0,"Database.Stream",o)}},w=class extends $e{constructor(r,t){
49
- super("Incorrect table stream type",r,"Database.Stream",t);this.streamType=r}};import{IncompleteTypeError as Ve}from"@ez4/common/library";var A=class extends Ve{constructor(o,r){
50
- super("Incomplete stream handler",o,r)}};var X=(e,o,r)=>{if(!C(e))return null;let t={},a=new Set(["name","file","change"]);
51
- return e.description&&(t.description=e.description),(t.name=e.name)&&a.delete("n\
52
- ame"),(t.file=e.file)&&a.delete("file"),e.parameters&&a.delete("change"),a.size===
53
- 0&&qe(t)?t:(r.push(new A([...a],e.file)),null)},qe=e=>!!e.name&&!!e.file;var L=(e,o,r,t)=>{if(!We(e))return Y(e,o,r,t);let a=r[e.path];return a?Y(a,o,r,t):
54
- null},Ye=e=>!!e.handler,Y=(e,o,r,t)=>Qe(e)?Z(e,Be(e),r,t):Je(e)?F(e)?Z(e,_e(e),r,
55
- t):(t.push(new w(e.name,e.file)),null):(t.push(new E(o.file)),null),Z=(e,o,r,t)=>{
56
- let a={},s=new Set(["handler"]);for(let n of o)if(!(!Ke(n)||n.inherited))switch(n.
57
- name){case"handler":a.handler=X(n.value,r,t);break;case"timeout":case"memory":{let i=Ge(
58
- n);Xe(i)&&(a[n.name]=i);break}case"variables":a.variables=Ue(n,t);break}return Ye(
59
- a)?a:(t.push(new P([...s],e.file)),null)};var te=(e,o,r)=>{if(!or(e))return ee(e,o,r);let t=o[e.path];return t?ee(t,o,r):null},
60
- ar=e=>!!e.name&&!!e.schema&&!!e.indexes,ee=(e,o,r)=>z(e)?re(e,Ze(e),o,r):tr(e)?re(
61
- e,Le(e),o,r):null,re=(e,o,r,t)=>{let a={},s=new Set(["name","schema","indexes"]);
62
- for(let i of o)if(!(!rr(i)||i.inherited))switch(i.name){case"name":(a.name=er(i))&&
63
- s.delete(i.name);break;case"relations":{let l=_(i.value,e,r,t);l&&(a.relations=l);
64
- break}case"indexes":{(a.indexes=J(i.value,e,r,t))&&s.delete(i.name);break}case"s\
65
- chema":{(a.schema=W(i.value,e,r,t))&&s.delete(i.name);break}case"stream":{a.stream=
66
- L(i.value,e,r,t);break}}if(!ar(a))return t.push(new S([...s],e.file)),null;let n=sr(
67
- e,a.indexes,a.schema);return n.length?(t.push(...n),null):(a.relations&&nr(a.relations,
68
- a.indexes),a)},sr=(e,o,r)=>{let t=r.properties,a=[];for(let{name:s,columns:n}of o)
69
- n.some(l=>!t[l])&&a.push(new v(s,e.file));return a},nr=(e,o)=>{for(let r of e)r.
70
- foreign=!o.some(({name:t,type:a})=>a==="primary"&&t===r.targetColumn)};var oe=e=>{let o={},r=[];for(let t in e){let a=e[t];if(!g(a))continue;let s={type:R},
71
- n=new Set(["engine","tables"]);s.name=a.name;for(let l of cr(a))if(!(!ur(l)||l.inherited))
72
- switch(l.name){case"engine":{(s.engine=pr(l))&&n.delete(l.name);break}case"table\
73
- s":(s.tables=fr(l,e,r))&&n.delete(l.name);break;case"variables":s.variables=lr(l,
74
- r);break;case"services":s.services=ir(l,e,r);break}if(!br(s)){r.push(new x([...n],
75
- a.file));continue}let i=Tr(a,s.tables);if(i.length){r.push(...i);continue}o[a.name]=
76
- s}return{services:o,errors:r}},br=e=>!!e.name&&!!e.tables,fr=(e,o,r)=>{let t=mr(
77
- e)??[],a=[];for(let s of t){let n=te(s,o,r);n&&a.push(n)}return a},Tr=(e,o)=>{let r=[];
78
- for(let{relations:t,schema:a}of o){if(!t)continue;let s=a.properties;for(let n of t){
79
- let{sourceTable:i,sourceColumn:l,targetColumn:c,targetAlias:k}=n,O=o.find(({name:ne})=>ne===
80
- i)?.schema.properties;s[c]||r.push(new m(c,e.file)),s[k]&&r.push(new d(k,e.file)),
81
- O||r.push(new T(i,e.file)),O&&!O[l]&&r.push(new m(l,e.file))}}return r};var ae=e=>g(e)?e.name:null;var se=!1,$t=()=>{se||(dr(),yr(),xr("@ez4/database",{"metadata:getServices":oe,"\
82
- metadata:getLinkedService":ae}),se=!0)};export{A as IncompleteHandlerError,x as IncompleteServiceError,P as IncompleteStreamError,
83
- S as IncompleteTableError,h as IncorrectIndexesTypeError,b as IncorrectRelationsTypeError,
84
- j as IncorrectSchemaTypeError,w as IncorrectStreamTypeError,v as InvalidIndexReferenceError,
85
- I as InvalidIndexTypeError,M as InvalidIndexesTypeError,d as InvalidRelationAliasError,
86
- m as InvalidRelationColumnError,T as InvalidRelationTableError,f as InvalidRelationTargetError,
87
- u as InvalidRelationsTypeError,D as InvalidSchemaTypeError,E as InvalidStreamTypeError,
88
- R as ServiceType,oe as getDatabaseServices,te as getDatabaseTable,W as getTableSchema,
89
- Mr as isDatabaseService,$t as registerTriggers};
1
+ import{registerTriggers as Mr}from"@ez4/common/library";import{registerTriggers as hr}from"@ez4/schema/library";
2
+ import{createTrigger as Dr}from"@ez4/project/library";import{DuplicateServiceError as mr,isExternalStatement as cr,getLinkedServiceList as ur,
3
+ getLinkedVariableList as br,getPropertyString as dr,getPropertyTuple as Tr,getModelMembers as fr}from"@ez4/common/library";
4
+ import{isModelProperty as yr}from"@ez4/reflection";import{IncorrectTypeError as me,InvalidTypeError as ce,TypeError as y}from"@ez4/common/library";
5
+ var u=class extends ce{constructor(t){super("Invalid table relations type",void 0,
6
+ "Database.Relations",t)}},b=class extends me{constructor(r,o){super("Incorrect t\
7
+ able relations type",r,"Database.Relations",o);this.schemaType=r}},d=class extends y{constructor(r,o){
8
+ super(`Target ${r} must follow the pattern 'column@alias'.`,o);this.relationSource=
9
+ r}},T=class extends y{constructor(r,o){super(`Relation table ${r} don't exists.`,
10
+ o);this.relationTable=r}},c=class extends y{constructor(r,o){super(`Relation col\
11
+ umn ${r} don't exists.`,o);this.relationColumn=r}},f=class extends y{constructor(r,o){
12
+ super(`Relation alias ${r} can't override table columns.`,o);this.relationAlias=
13
+ r}};var z="@ez4/database",jr=e=>e.type===z;import{IncompleteTypeError as ue}from"@ez4/common/library";var x=class extends ue{constructor(t,r){
14
+ super("Incomplete database service",t,r)}};import{hasHeritageType as l,isClassDeclaration as be,isModelDeclaration as de}from"@ez4/common/library";
15
+ import{isTypeCallback as Te,isTypeFunction as fe}from"@ez4/reflection";var g=e=>be(
16
+ e)&&l(e,"Database.Service"),N=e=>de(e)&&l(e,"Database.Table"),H=e=>Te(e)||fe(e),
17
+ $=e=>l(e,"Database.Relations"),q=e=>l(e,"Database.Indexes"),F=e=>l(e,"Database.S\
18
+ chema"),U=e=>l(e,"Database.Stream");import{getModelMembers as tr,getObjectMembers as or,getPropertyString as sr}from"@ez4/common/library";
19
+ import{isModelProperty as ar,isTypeObject as nr,isTypeReference as ir}from"@ez4/reflection";import{IncompleteTypeError as ye}from"@ez4/common/library";var S=class extends ye{constructor(t,r){
20
+ super("Incomplete database table",t,r)}};import{IncorrectTypeError as xe,InvalidTypeError as ge,TypeError as V}from"@ez4/common/library";
21
+ var I=class extends ge{constructor(t){super("Invalid table indexes type",void 0,
22
+ "Database.Indexes",t)}},M=class extends xe{constructor(r,o){super("Incorrect tab\
23
+ le indexes type",r,"Database.Indexes",o);this.schemaType=r}},h=class extends V{constructor(r,o){
24
+ super(`Invalid index type, ${r} must follow one of the Index options.`,o);this.indexName=
25
+ r}},D=class extends V{constructor(r,o){super(`Invalid index reference, ${r} must\
26
+ be valid column.`,o);this.indexName=r}};import{isModelDeclaration as Se,getModelMembers as Ie,getObjectMembers as Me,getPropertyString as he}from"@ez4/common/library";
27
+ import{isModelProperty as De,isTypeObject as ve,isTypeReference as Pe}from"@ez4/reflection";var G=(e,t,r,o)=>{if(!Pe(e))return _(e,t,o);let s=r[e.path];return s?_(s,t,o):null},
28
+ _=(e,t,r)=>ve(e)?B(e,Me(e),r):Se(e)?$(e)?B(e,Ie(e),r):(r.push(new b(e.name,e.file)),
29
+ null):(r.push(new u(t.file)),null),B=(e,t,r)=>{let o=[];for(let s of t){if(!De(s)||
30
+ s.inherited)continue;let a=he(s);if(!a)return r.push(new d(s.name,e.file)),null;
31
+ let[n,i]=s.name.split(":",2),[p,m]=a.split("@",2);o.push({sourceTable:n,sourceColumn:i,
32
+ targetColumn:p,targetAlias:m})}return o};import{isModelDeclaration as je,getModelMembers as Ee,getObjectMembers as we,getPropertyString as Oe}from"@ez4/common/library";
33
+ import{isModelProperty as Ae,isTypeObject as ke,isTypeReference as Re}from"@ez4/reflection";var Q=(e,t,r,o)=>{if(!Re(e))return J(e,t,o);let s=r[e.path];return s?J(s,t,o):null},
34
+ J=(e,t,r)=>ke(e)?K(e,we(e),r):je(e)?q(e)?K(e,Ee(e),r):(r.push(new M(e.name,e.file)),
35
+ null):(r.push(new I(t.file)),null),K=(e,t,r)=>{let o=[];for(let s of t){if(!Ae(s)||
36
+ s.inherited)continue;let a=s.name,n=Oe(s);switch(n){case"primary":case"secondary":case"\
37
+ unique":case"ttl":o.push({name:a,columns:a.split(":"),type:n});break;default:return r.
38
+ push(new h(a,e.file)),null}}return o};import{getObjectSchema as Ne,isObjectSchema as He}from"@ez4/schema/library";import{
39
+ isTypeObject as $e,isTypeReference as qe}from"@ez4/reflection";import{isModelDeclaration as Fe}from"@ez4/common/library";import{IncorrectTypeError as ze,InvalidTypeError as Ce}from"@ez4/common/library";
40
+ var v=class extends Ce{constructor(t){super("Invalid table schema type",void 0,"\
41
+ Database.Schema",t)}},P=class extends ze{constructor(r,o){super("Incorrect table\
42
+ schema type",r,"Database.Schema",o);this.schemaType=r}};var Y=(e,t,r,o)=>{if(!qe(e))return W(e,t,r,o);let s=r[e.path];return s?W(s,t,r,o):
43
+ null},W=(e,t,r,o)=>$e(e)?X(e,r):Fe(e)?F(e)?X(e,r):(o.push(new P(e.name,e.file)),
44
+ null):(o.push(new v(t.file)),null),X=(e,t)=>{let r=Ne(e,t);return r&&He(r)?r:null};import{getLinkedVariableList as Je,getModelMembers as Ke,getObjectMembers as Qe,
45
+ getPropertyNumber as We,isModelDeclaration as Xe}from"@ez4/common/library";import{
46
+ isModelProperty as Ye,isTypeObject as Ze,isTypeReference as Le}from"@ez4/reflection";
47
+ import{isAnyNumber as er}from"@ez4/utils";import{IncompleteTypeError as Ue,IncorrectTypeError as Ve,InvalidTypeError as _e}from"@ez4/common/library";
48
+ var j=class extends Ue{constructor(t,r){super("Incomplete table stream",t,r)}},E=class extends _e{constructor(t){
49
+ super("Invalid table stream type",void 0,"Database.Stream",t)}},w=class extends Ve{constructor(r,o){
50
+ super("Incorrect table stream type",r,"Database.Stream",o);this.streamType=r}};import{IncompleteTypeError as Be}from"@ez4/common/library";var O=class extends Be{constructor(t,r){
51
+ super("Incomplete stream handler",t,r)}};var Z=(e,t,r)=>{if(!H(e))return null;let o={},s=new Set(["name","file","change"]);
52
+ return e.description&&(o.description=e.description),(o.name=e.name)&&s.delete("n\
53
+ ame"),(o.file=e.file)&&s.delete("file"),e.parameters&&s.delete("change"),s.size===
54
+ 0&&Ge(o)?o:(r.push(new O([...s],e.file)),null)},Ge=e=>!!e.name&&!!e.file;var re=(e,t,r,o)=>{if(!Le(e))return L(e,t,r,o);let s=r[e.path];return s?L(s,t,r,
55
+ o):null},rr=e=>!!e.handler,L=(e,t,r,o)=>Ze(e)?ee(e,Qe(e),r,o):Xe(e)?U(e)?ee(e,Ke(
56
+ e),r,o):(o.push(new w(e.name,e.file)),null):(o.push(new E(t.file)),null),ee=(e,t,r,o)=>{
57
+ let s={},a=new Set(["handler"]);for(let n of t)if(!(!Ye(n)||n.inherited))switch(n.
58
+ name){case"handler":s.handler=Z(n.value,r,o);break;case"timeout":case"memory":{let i=We(
59
+ n);er(i)&&(s[n.name]=i);break}case"variables":s.variables=Je(n,o);break}return rr(
60
+ s)?s:(o.push(new j([...a],e.file)),null)};var se=(e,t,r)=>{if(!ir(e))return te(e,t,r);let o=t[e.path];return o?te(o,t,r):null},
61
+ pr=e=>!!e.name&&!!e.schema&&!!e.indexes,te=(e,t,r)=>N(e)?oe(e,tr(e),t,r):nr(e)?oe(
62
+ e,or(e),t,r):null,oe=(e,t,r,o)=>{let s={},a=new Set(["name","schema","indexes"]);
63
+ for(let i of t)if(!(!ar(i)||i.inherited))switch(i.name){case"name":(s.name=sr(i))&&
64
+ a.delete(i.name);break;case"relations":{let p=G(i.value,e,r,o);p&&(s.relations=p);
65
+ break}case"indexes":{(s.indexes=Q(i.value,e,r,o))&&a.delete(i.name);break}case"s\
66
+ chema":{(s.schema=Y(i.value,e,r,o))&&a.delete(i.name);break}case"stream":{s.stream=
67
+ re(i.value,e,r,o);break}}if(!pr(s))return o.push(new S([...a],e.file)),null;let n=lr(
68
+ e,s.indexes,s.schema);return n.length?(o.push(...n),null):s},lr=(e,t,r)=>{let o=r.
69
+ properties,s=[];for(let{name:a,columns:n}of t)n.some(p=>!o[p])&&s.push(new D(a,e.
70
+ file));return s};var ne=e=>{let t={},r=[];for(let o in e){let s=e[o];if(!g(s)||cr(s))continue;let a={
71
+ type:z},n=new Set(["engine","tables"]);a.name=s.name;for(let p of fr(s))if(!(!yr(
72
+ p)||p.inherited))switch(p.name){case"engine":{(a.engine=dr(p))&&n.delete(p.name);
73
+ break}case"tables":(a.tables=gr(p,e,r))&&n.delete(p.name);break;case"variables":
74
+ a.variables=br(p,r);break;case"services":a.services=ur(p,e,r);break}if(!xr(a)){r.
75
+ push(new x([...n],s.file));continue}let i=Sr(s,a.tables);if(i.length){r.push(...i);
76
+ continue}if(t[s.name]){r.push(new mr(s.name,s.file));continue}t[s.name]=a}return{
77
+ services:t,errors:r}},xr=e=>!!e.name&&!!e.tables,gr=(e,t,r)=>{let o=Tr(e)??[],s=[];
78
+ for(let a of o){let n=se(a,t,r);n&&s.push(n)}return s},Sr=(e,t)=>{let r=Ir(t),o=[];
79
+ for(let{relations:s,schema:a,indexes:n}of t){if(!s)continue;let i=a.properties;for(let p of s){
80
+ let{sourceTable:m,sourceColumn:A,targetColumn:k,targetAlias:C}=p;i[k]||o.push(new c(
81
+ k,e.file)),i[C]&&o.push(new f(C,e.file));let R=r[m]?.schema.properties;R||o.push(
82
+ new T(m,e.file)),R&&!R[A]&&o.push(new c(A,e.file));let le=r[m]?.indexes??[];p.sourceIndex=
83
+ ae(le,A),p.targetIndex=ae(n,k)}}return o},ae=(e,t)=>e.find(({name:r})=>r===t)?.type,
84
+ Ir=e=>e.reduce((t,r)=>({...t,[r.name]:r}),{});var ie=e=>g(e)?e.name:null;var pe=!1,Bt=()=>{pe||(Mr(),hr(),Dr("@ez4/database",{"metadata:getServices":ne,"\
85
+ metadata:getLinkedService":ie}),pe=!0)};export{O as IncompleteHandlerError,x as IncompleteServiceError,j as IncompleteStreamError,
86
+ S as IncompleteTableError,M as IncorrectIndexesTypeError,b as IncorrectRelationsTypeError,
87
+ P as IncorrectSchemaTypeError,w as IncorrectStreamTypeError,D as InvalidIndexReferenceError,
88
+ h as InvalidIndexTypeError,I as InvalidIndexesTypeError,f as InvalidRelationAliasError,
89
+ c as InvalidRelationColumnError,T as InvalidRelationTableError,d as InvalidRelationTargetError,
90
+ u as InvalidRelationsTypeError,v as InvalidSchemaTypeError,E as InvalidStreamTypeError,
91
+ z as ServiceType,ne as getDatabaseServices,se as getDatabaseTable,Y as getTableSchema,
92
+ jr as isDatabaseService,Bt as registerTriggers};
package/dist/main.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(r,t)=>{for(var a in t)s(r,a,{get:t[a],enumerable:!0})},y=(r,t,a,n)=>{if(t&&
2
- typeof t=="object"||typeof t=="function")for(let e of d(t))!T.call(r,e)&&e!==a&&
3
- s(r,e,{get:()=>t[e],enumerable:!(n=i(t,e))||n.enumerable});return r};var l=r=>y(s({},"__esModule",{value:!0}),r);var b={};c(b,{Database:()=>o,Index:()=>m,Order:()=>p,StreamType:()=>x});module.exports=
4
- l(b);var x=(n=>(n.Insert="insert",n.Update="update",n.Delete="delete",n))(x||{});var o;(r=>{})(o||={});var m=(e=>(e.Primary="primary",e.Secondary="secondary",e.Unique="unique",e.TTL="\
5
- ttl",e))(m||{});var p=(a=>(a.Asc="asc",a.Desc="desc",a))(p||{});0&&(module.exports={Database,Index,Order,StreamType});
1
+ "use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(a,t)=>{for(var r in t)s(a,r,{get:t[r],enumerable:!0})},y=(a,t,r,n)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let e of i(t))!T.call(a,e)&&e!==r&&
3
+ s(a,e,{get:()=>t[e],enumerable:!(n=d(t,e))||n.enumerable});return a};var I=a=>y(s({},"__esModule",{value:!0}),a);var l={};c(l,{Database:()=>o,Index:()=>x,Order:()=>m,StreamType:()=>p});module.exports=
4
+ I(l);var p=(n=>(n.Insert="insert",n.Update="update",n.Delete="delete",n))(p||{});var o;(a=>{})(o||={});var x=(e=>(e.Primary="primary",e.Secondary="secondary",e.Unique="unique",e.TTL="\
5
+ ttl",e))(x||{});var m=(r=>(r.Asc="asc",r.Desc="desc",r))(m||{});0&&(module.exports={Database,Index,Order,StreamType});
package/dist/main.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './services/streams.js';
2
2
  export { Client } from './services/client.js';
3
- export { Database } from './services/database.js';
3
+ export { RelationMetadata } from './services/relations.js';
4
4
  export { Transaction } from './services/transaction.js';
5
- export { Relations } from './services/relations.js';
5
+ export { Database } from './services/database.js';
6
6
  export { Index } from './services/indexes.js';
7
7
  export { Table } from './services/table.js';
8
8
  export { Query } from './services/query.js';
package/dist/main.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var o=(t=>(t.Insert="insert",t.Update="update",t.Delete="delete",t))(o||{});var a;(m=>{})(a||={});var n=(e=>(e.Primary="primary",e.Secondary="secondary",e.Unique="unique",e.TTL="\
2
- ttl",e))(n||{});var s=(r=>(r.Asc="asc",r.Desc="desc",r))(s||{});export{a as Database,n as Index,s as Order,o as StreamType};
1
+ var o=(t=>(t.Insert="insert",t.Update="update",t.Delete="delete",t))(o||{});var r;(x=>{})(r||={});var n=(e=>(e.Primary="primary",e.Secondary="secondary",e.Unique="unique",e.TTL="\
2
+ ttl",e))(n||{});var s=(a=>(a.Asc="asc",a.Desc="desc",a))(s||{});export{r as Database,n as Index,s as Order,o as StreamType};
@@ -19,12 +19,30 @@ export type DecomposeIndexName<T> = T extends `${infer L}:${infer R}` ? L | Deco
19
19
  export type PrimaryIndexes<T extends Database.Indexes> = {
20
20
  [P in keyof T as Index.Primary extends T[P] ? P : never]: T[P];
21
21
  };
22
+ /**
23
+ * Given an index object `T`, it produces an object containing only unique indexes.
24
+ */
25
+ export type UniqueIndexes<T extends Database.Indexes> = {
26
+ [P in keyof T as Index.Unique extends T[P] ? P : never]: T[P];
27
+ };
22
28
  /**
23
29
  * Given an index object `T`, it produces an object containing only secondary indexes.
24
30
  */
25
31
  export type SecondaryIndexes<T extends Database.Indexes> = {
26
- [P in keyof T as Index.Secondary | Index.Unique | Index.TTL extends T[P] ? P : never]: T[P];
32
+ [P in keyof T as Index.Secondary | Index.TTL extends T[P] ? P : never]: T[P];
27
33
  };
34
+ /**
35
+ * Given an index object `T`, it produces the primary decomposed index names.
36
+ */
37
+ export type DecomposePrimaryIndexNames<T extends Database.Indexes> = DecomposeIndexName<keyof PrimaryIndexes<T>>;
38
+ /**
39
+ * Given an index object `T`, it produces the unique decomposed index names.
40
+ */
41
+ export type DecomposeUniqueIndexNames<T extends Database.Indexes> = DecomposeIndexName<keyof UniqueIndexes<T>>;
42
+ /**
43
+ * Given an index object `T`, it produces the secondary decomposed index names.
44
+ */
45
+ export type DecomposeSecondaryIndexNames<T extends Database.Indexes> = DecomposeIndexName<keyof SecondaryIndexes<T>>;
28
46
  /**
29
47
  * Given a database service `T`, it produces an object with all tables containing indexes.
30
48
  */
@@ -1,91 +1,116 @@
1
- import type { DecomposeIndexName, PrimaryIndexes } from './indexes.js';
2
- import type { Relations } from './relations.js';
1
+ import type { RelationMetadata } from './relations.js';
3
2
  import type { Database } from './database.js';
4
3
  import type { Order } from './order.js';
5
- import type { AnyObject, PartialProperties, PartialObject, DeepPartial, FlatObject, IsObject } from '@ez4/utils';
4
+ import type { DecomposeIndexName, DecomposePrimaryIndexNames, DecomposeUniqueIndexNames } from './indexes.js';
5
+ import type { AnyObject, PartialProperties, PartialObject, FlatObject, OptionalObject, StrictObject, IsNullable, IsObjectEmpty, IsObject } from '@ez4/utils';
6
6
  /**
7
7
  * Query builder types.
8
8
  */
9
9
  export declare namespace Query {
10
- type InsertOneInput<T extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
11
- data: T | (Omit<T, DecomposeIndexName<keyof I>> & R);
12
- };
13
- type UpdateOneInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
14
- select?: S;
15
- data: DeepPartial<T | FlatObject<Omit<T, DecomposeIndexName<keyof I>> & R>>;
16
- where: WhereInput<T, I>;
17
- };
18
- type FindOneInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>> = {
19
- select: S;
20
- where: WhereInput<T, I>;
21
- };
22
- type UpsertOneInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
23
- select?: S;
24
- insert: T | (Omit<T, DecomposeIndexName<keyof I>> & R);
25
- update: DeepPartial<T | FlatObject<Omit<T, DecomposeIndexName<keyof I>> & R>>;
26
- where: WhereInput<T, I>;
27
- };
28
- type DeleteOneInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>> = {
29
- select?: S;
30
- where: WhereInput<T, I>;
31
- };
32
- type InsertManyInput<T extends Database.Schema> = {
10
+ export type InsertOneInput<T extends Database.Schema, R extends RelationMetadata> = {
11
+ data: InsertDataInput<T, R>;
12
+ };
13
+ export type UpdateOneInput<T extends Database.Schema, S extends AnyObject, I extends Database.Indexes<T>, R extends RelationMetadata> = {
14
+ select?: StrictSelectInput<T, S, R>;
15
+ include?: StrictIncludeInput<S, R>;
16
+ data: OptionalObject<UpdateDataInput<T, R>>;
17
+ where: WhereInput<T, I, R>;
18
+ };
19
+ export type FindOneInput<T extends Database.Schema, S extends AnyObject, I extends Database.Indexes<T>, R extends RelationMetadata> = {
20
+ select: StrictSelectInput<T, S, R>;
21
+ include?: StrictIncludeInput<S, R>;
22
+ where: WhereInput<T, I, R>;
23
+ };
24
+ export type UpsertOneInput<T extends Database.Schema, S extends AnyObject, I extends Database.Indexes<T>, R extends RelationMetadata> = {
25
+ select?: StrictSelectInput<T, S, R>;
26
+ include?: StrictIncludeInput<S, R>;
27
+ update: OptionalObject<UpdateDataInput<T, R>>;
28
+ insert: InsertDataInput<T, R>;
29
+ where: WhereInput<T, I, R>;
30
+ };
31
+ export type DeleteOneInput<T extends Database.Schema, S extends AnyObject, I extends Database.Indexes<T>, R extends RelationMetadata> = {
32
+ select?: StrictSelectInput<T, S, R>;
33
+ include?: StrictIncludeInput<S, R>;
34
+ where: WhereInput<T, I, R>;
35
+ };
36
+ export type InsertManyInput<T extends Database.Schema = {}> = {
33
37
  data: T[];
34
38
  };
35
- type UpdateManyInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
36
- select?: S;
37
- data: DeepPartial<T | FlatObject<Omit<T, DecomposeIndexName<keyof I>> & R>>;
38
- where?: WhereInput<T>;
39
+ export type UpdateManyInput<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = {
40
+ select?: StrictSelectInput<T, S, R>;
41
+ include?: StrictIncludeInput<S, R>;
42
+ data: OptionalObject<UpdateDataInput<T, R>>;
43
+ where?: WhereInput<T, {}, R>;
39
44
  limit?: number;
40
45
  };
41
- type FindManyInput<T extends Database.Schema, S extends Database.Schema, I extends Database.Indexes<T>> = {
42
- select: S;
43
- where?: WhereInput<T>;
46
+ export type FindManyInput<T extends Database.Schema, S extends AnyObject, I extends Database.Indexes<T>, R extends RelationMetadata> = {
47
+ select: StrictSelectInput<T, S, R>;
48
+ include?: StrictIncludeInput<S, R>;
49
+ where?: WhereInput<T, {}, R>;
44
50
  order?: OrderInput<I>;
45
51
  cursor?: number | string;
46
52
  limit?: number;
47
53
  };
48
- type DeleteManyInput<T extends Database.Schema, S extends Database.Schema> = {
49
- select?: S;
50
- where?: WhereInput<T>;
54
+ export type DeleteManyInput<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = {
55
+ select?: StrictSelectInput<T, S, R>;
56
+ include?: StrictIncludeInput<S, R>;
57
+ where?: WhereInput<T, {}, R>;
51
58
  limit?: number;
52
59
  };
53
- type InsertOneResult = void;
54
- type UpdateOneResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R> | undefined;
55
- type FindOneResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R> | undefined;
56
- type UpsertOneResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R> | undefined;
57
- type DeleteOneResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R> | undefined;
58
- type InsertManyResult = void;
59
- type UpdateManyResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R>[];
60
- type FindManyResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = {
60
+ export type InsertOneResult = void;
61
+ export type UpdateOneResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R> | undefined;
62
+ export type FindOneResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R> | undefined;
63
+ export type UpsertOneResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R> | undefined;
64
+ export type DeleteOneResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R> | undefined;
65
+ export type InsertManyResult = void;
66
+ export type UpdateManyResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R>[];
67
+ export type FindManyResult<T extends Database.Schema, S extends Database.Schema, R extends RelationMetadata> = {
61
68
  records: Record<T, S, R>[];
62
69
  cursor?: number | string;
63
70
  };
64
- type DeleteManyResult<T extends Database.Schema, S extends AnyObject, R extends Relations> = Record<T, S, R>[];
65
- type Record<T extends Database.Schema, S extends AnyObject, R extends Relations> = PartialObject<T & R, S, false>;
66
- type SelectInput<T extends Database.Schema, R extends Relations> = PartialProperties<T & R>;
67
- type OrderInput<I extends Database.Indexes> = {
71
+ export type DeleteManyResult<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = Record<T, S, R>[];
72
+ export type Record<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = PartialObject<SelectFields<T, R>, S, false>;
73
+ export type SelectInput<T extends Database.Schema, R extends RelationMetadata> = PartialProperties<SelectFields<T, R>>;
74
+ export type StrictSelectInput<T extends Database.Schema, S extends AnyObject, R extends RelationMetadata> = StrictObject<S, FlatObject<SelectFields<T, R>>>;
75
+ export type InsertDataInput<T extends Database.Schema, R extends RelationMetadata> = Omit<IsObjectEmpty<R['changes']> extends true ? T : T & R['changes'], IndexFields<R>>;
76
+ export type UpdateDataInput<T extends Database.Schema, R extends RelationMetadata> = Omit<IsObjectEmpty<R['changes']> extends true ? T : T & FlatObject<R['changes']>, IndexFields<R>>;
77
+ export type StrictIncludeInput<S extends AnyObject, R extends RelationMetadata> = IsObjectEmpty<R['filters']> extends true ? never : IncludeFilters<R['filters'], S>;
78
+ export type OrderInput<I extends Database.Indexes> = {
68
79
  [P in DecomposeIndexName<keyof I>]?: Order;
69
80
  };
70
- type WhereInput<T extends Database.Schema, I extends Database.Indexes<T> = {}> = WhereFields<T, I> & WhereNot<T, I> & WhereAnd<T, I> & WhereOr<T, I>;
71
- type WhereRequiredFields<T extends Database.Schema, I extends Database.Indexes<T>> = {
72
- [P in DecomposeIndexName<keyof PrimaryIndexes<I>>]: P extends keyof T ? IsObject<T[P]> extends true ? WhereFields<NonNullable<T[P]>, I> : T[P] | WhereOperations<T[P]> : never;
81
+ export type WhereInput<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = WhereInputFilters<T, I, R> & WhereNot<WhereInputFilters<T, I, R>> & WhereAnd<WhereInputFilters<T, I, R>> & WhereOr<WhereInputFilters<T, I, R>>;
82
+ export type WhereOperators = keyof (WhereNegate<any> & WhereEqual<any> & WhereGreaterThan<any> & WhereGreaterThanOrEqual<any> & WhereLessThan<any> & WhereLessThanOrEqual<any> & WhereIn<any> & WhereBetween<any> & WhereIsMissing & WhereIsNull & WhereStartsWith & WhereContains);
83
+ type IndexFields<R extends RelationMetadata> = string extends R['indexes'] ? never : R['indexes'];
84
+ type SelectFields<T extends Database.Schema, R extends RelationMetadata> = IsObjectEmpty<R['selects']> extends true ? T : T & R['selects'];
85
+ type IncludeFilters<T extends AnyObject, S extends AnyObject> = {
86
+ [P in keyof T]?: P extends keyof S ? IsObject<T[P]> extends true ? null | WhereRelationField<NonNullable<T[P]>> : never : never;
73
87
  };
74
- type WhereOptionalFields<T extends Database.Schema, I extends Database.Indexes<T>> = {
75
- [P in Exclude<keyof T, DecomposeIndexName<keyof PrimaryIndexes<I>>>]?: IsObject<T[P]> extends true ? WhereFields<NonNullable<T[P]>, I> : T[P] | WhereOperations<T[P]>;
88
+ type WhereOperations<T> = WhereNegate<T> | WhereEqual<T> | WhereGreaterThan<T> | WhereGreaterThanOrEqual<T> | WhereLessThan<T> | WhereLessThanOrEqual<T> | WhereIn<T> | WhereBetween<T> | WhereIsMissing | WhereIsNull | WhereStartsWith | WhereContains;
89
+ type WhereField<T> = IsObject<T> extends false ? T | WhereOperations<T> : IsNullable<T> extends true ? null | WhereObjectField<NonNullable<T>> : WhereObjectField<NonNullable<T>>;
90
+ type WhereObjectField<T extends AnyObject> = {
91
+ [P in keyof T]?: WhereField<T[P]>;
76
92
  };
77
- type WhereFields<T extends Database.Schema, I extends Database.Indexes<T>> = WhereRequiredFields<T, I> & WhereOptionalFields<T, I>;
78
- type WhereNot<T extends Database.Schema, I extends Database.Indexes<T>> = {
79
- NOT?: WhereInput<T, I> | WhereAnd<T, I> | WhereOr<T, I>;
93
+ type WhereRelationField<T extends AnyObject> = WhereObjectField<T> & WhereNot<WhereObjectField<T>> & WhereAnd<WhereObjectField<T>> & WhereOr<WhereObjectField<T>>;
94
+ type WhereRelationFilters<T extends AnyObject> = {
95
+ [P in keyof T]?: IsObject<T[P]> extends true ? IsObjectEmpty<T[P]> extends false ? null | WhereRelationField<NonNullable<T[P]>> : null | {} : never;
80
96
  };
81
- type WhereAnd<T extends Database.Schema, I extends Database.Indexes<T>> = {
82
- AND?: (WhereInput<T, I> | WhereOr<T, I> | WhereNot<T, I>)[];
97
+ type WhereRequiredFilters<T extends AnyObject, N extends string> = {
98
+ [P in N as P extends keyof T ? P : never]: P extends keyof T ? WhereField<T[P]> : never;
83
99
  };
84
- type WhereOr<T extends Database.Schema, I extends Database.Indexes<T>> = {
85
- OR?: (WhereInput<T, I> | WhereAnd<T, I> | WhereNot<T, I>)[];
100
+ type WhereOptionalFilters<T extends AnyObject, N extends string> = {
101
+ [P in Exclude<keyof T, N>]?: WhereField<T[P]>;
102
+ };
103
+ type WhereCommonFilters<T extends AnyObject, I extends Database.Indexes<T>> = (WhereRequiredFilters<T, DecomposePrimaryIndexNames<I>> & WhereOptionalFilters<T, DecomposePrimaryIndexNames<I>>) | (WhereRequiredFilters<T, DecomposeUniqueIndexNames<I>> & WhereOptionalFilters<T, DecomposeUniqueIndexNames<I>>);
104
+ type WhereInputFilters<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = WhereCommonFilters<T, I> & WhereRelationFilters<R['filters']>;
105
+ type WhereNot<T extends AnyObject> = {
106
+ NOT?: T | WhereAnd<T> | WhereOr<T>;
107
+ };
108
+ type WhereAnd<T extends AnyObject> = {
109
+ AND?: (T | WhereNot<T> | WhereAnd<T> | WhereOr<T>)[];
110
+ };
111
+ type WhereOr<T extends AnyObject> = {
112
+ OR?: (T | WhereNot<T> | WhereAnd<T> | WhereOr<T>)[];
86
113
  };
87
- type WhereOperations<T> = WhereNegate<T> | WhereEqual<T> | WhereGreaterThan<T> | WhereGreaterThanOrEqual<T> | WhereLessThan<T> | WhereLessThanOrEqual<T> | WhereIn<T> | WhereBetween<T> | WhereIsMissing | WhereIsNull | WhereStartsWith | WhereContains;
88
- type WhereOperators = keyof (WhereNegate<any> & WhereEqual<any> & WhereGreaterThan<any> & WhereGreaterThanOrEqual<any> & WhereLessThan<any> & WhereLessThanOrEqual<any> & WhereIn<any> & WhereBetween<any> & WhereIsMissing & WhereIsNull & WhereStartsWith & WhereContains);
89
114
  type WhereNegate<T> = {
90
115
  not: T | WhereOperations<T>;
91
116
  };
@@ -122,4 +147,5 @@ export declare namespace Query {
122
147
  type WhereContains = {
123
148
  contains: string;
124
149
  };
150
+ export {};
125
151
  }
@@ -1,11 +1,16 @@
1
- import type { ArrayRest, IsArrayEmpty, PropertyType } from '@ez4/utils';
2
- import type { IndexedTables, PrimaryIndexes } from './indexes.js';
1
+ import type { IndexedTables, PrimaryIndexes, UniqueIndexes } from './indexes.js';
3
2
  import type { Database, DatabaseTables } from './database.js';
4
3
  import type { TableSchemas } from './schemas.js';
4
+ import type { AnyObject, ArrayRest, PropertyType, ExclusiveType, IsArrayEmpty, IsUndefined } from '@ez4/utils';
5
5
  /**
6
6
  * Internal relation type.
7
7
  */
8
- export type Relations = Record<string, unknown>;
8
+ export type RelationMetadata = {
9
+ indexes: string;
10
+ filters: Record<string, unknown>;
11
+ selects: Record<string, unknown>;
12
+ changes: Record<string, unknown>;
13
+ };
9
14
  /**
10
15
  * Given a relation source name `T`, it produces the source table name.
11
16
  */
@@ -37,27 +42,54 @@ type MergeRelations<T extends Database.Table[], S extends Record<string, Databas
37
42
  type TableRelation<T, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>> = T extends {
38
43
  name: infer N;
39
44
  relations: infer R;
40
- } ? N extends string ? R extends Relations ? {
41
- [P in N]: RequiredRelationSchemas<PropertyType<N, S>, S, I, R> & OptionalRelationSchemas<PropertyType<N, S>, S, I, R>;
45
+ } ? N extends string ? R extends AnyObject ? {
46
+ [P in N]: {
47
+ indexes: RequiredRelationIndexes<PropertyType<N, S>, I, R>;
48
+ filters: FilterableRelationSchemas<S, I, R>;
49
+ changes: RequiredRelationSchemas<PropertyType<N, S>, S, I, R, true> & OptionalRelationSchemas<PropertyType<N, S>, S, I, R, true>;
50
+ selects: RequiredRelationSchemas<PropertyType<N, S>, S, I, R, false> & OptionalRelationSchemas<PropertyType<N, S>, S, I, R, false>;
51
+ };
42
52
  } : {} : {} : {};
53
+ /**
54
+ * Produce an object containing all required relation indexes.
55
+ */
56
+ type RequiredRelationIndexes<T extends Database.Schema, I extends Record<string, Database.Indexes>, R extends AnyObject> = keyof {
57
+ [C in keyof R as IsOptionalRelation<C, R[C], T, I, true> extends true ? never : RelationTargetColumn<R[C]>]: never;
58
+ };
59
+ /**
60
+ * Produce an object containing all filterable relation schemas.
61
+ */
62
+ type FilterableRelationSchemas<S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, R extends AnyObject> = {
63
+ [C in keyof R as RelationTargetAlias<R[C]>]: IsPrimaryIndex<C, I> extends false ? Omit<PropertyType<RelationSourceTable<C>, S>, RelationSourceColumn<C>> : PropertyType<RelationSourceTable<C>, S>;
64
+ };
43
65
  /**
44
66
  * Produce an object containing only required relation schemas.
45
67
  */
46
- type RequiredRelationSchemas<T extends Database.Schema, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, R extends Relations> = {
47
- [C in keyof R as IsOptionalRelation<C, R[C], T, I> extends true ? never : RelationTargetAlias<R[C]>]: RelationSchema<C, S, I>;
68
+ type RequiredRelationSchemas<T extends Database.Schema, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, R extends AnyObject, E extends boolean> = {
69
+ [C in keyof R as IsOptionalRelation<C, R[C], T, I, E> extends false ? RelationTargetAlias<R[C]> : never]: RelationSchema<C, R[C], T, S, I, E>;
48
70
  };
49
71
  /**
50
72
  * Produce an object containing only optional relation schemas.
51
73
  */
52
- type OptionalRelationSchemas<T extends Database.Schema, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, R extends Relations> = {
53
- [C in keyof R as IsOptionalRelation<C, R[C], T, I> extends true ? RelationTargetAlias<R[C]> : never]?: RelationSchema<C, S, I>;
74
+ type OptionalRelationSchemas<T extends Database.Schema, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, R extends AnyObject, E extends boolean> = {
75
+ [C in keyof R as IsOptionalRelation<C, R[C], T, I, E> extends true ? RelationTargetAlias<R[C]> : never]?: RelationSchema<C, R[C], T, S, I, E>;
54
76
  };
55
77
  /**
56
78
  * Check whether a relation is optional or not.
57
79
  */
58
- type IsOptionalRelation<C, V, S extends Database.Schema, I extends Record<string, Database.Indexes>> = RelationSourceColumn<C> extends keyof PrimaryIndexes<PropertyType<RelationSourceTable<C>, I>> ? undefined extends PropertyType<RelationTargetColumn<V>, S> ? true : false : true;
80
+ type IsOptionalRelation<C, V, T extends Database.Schema, I extends Record<string, Database.Indexes>, E extends boolean> = RelationSourceColumn<C> extends keyof PrimaryIndexes<PropertyType<RelationSourceTable<C>, I>> ? IsUndefined<PropertyType<RelationTargetColumn<V>, T>> extends true ? true : false : RelationSourceColumn<C> extends keyof UniqueIndexes<PropertyType<RelationSourceTable<C>, I>> ? true : E;
81
+ /**
82
+ * Check whether a column is primary.
83
+ */
84
+ type IsPrimaryIndex<C, I extends Record<string, Database.Indexes>> = RelationSourceColumn<C> extends keyof PrimaryIndexes<PropertyType<RelationSourceTable<C>, I>> ? true : false;
85
+ /**
86
+ * Check whether a column is unique.
87
+ */
88
+ type IsUniqueIndex<C, I extends Record<string, Database.Indexes>> = RelationSourceColumn<C> extends keyof UniqueIndexes<PropertyType<RelationSourceTable<C>, I>> ? true : false;
59
89
  /**
60
90
  * Produce a relation schema according to its indexation.
61
91
  */
62
- type RelationSchema<C, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>> = RelationSourceColumn<C> extends keyof PrimaryIndexes<PropertyType<RelationSourceTable<C>, I>> ? PropertyType<RelationSourceTable<C>, S> : Omit<PropertyType<RelationSourceTable<C>, S>, RelationSourceColumn<C>>[];
92
+ type RelationSchema<C, V, T extends Database.Schema, S extends Record<string, Database.Schema>, I extends Record<string, Database.Indexes>, E extends boolean> = IsPrimaryIndex<C, I> extends true ? E extends false ? PropertyType<RelationSourceTable<C>, S> : ExclusiveType<PropertyType<RelationSourceTable<C>, S>, {
93
+ [P in RelationTargetColumn<V>]: PropertyType<RelationTargetColumn<V>, T>;
94
+ }> : IsUniqueIndex<C, I> extends true ? E extends false ? PropertyType<RelationSourceTable<C>, S> : Omit<PropertyType<RelationSourceTable<C>, S>, RelationSourceColumn<C>> : Omit<PropertyType<RelationSourceTable<C>, S>, RelationSourceColumn<C>>[];
63
95
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { AnyObject, ArrayRest, IsArrayEmpty, IsAny, PropertyExists } from '@ez4/utils';
2
- import type { Relations, RelationTables } from './relations.js';
2
+ import type { RelationMetadata, RelationTables } from './relations.js';
3
3
  import type { IndexedTables } from './indexes.js';
4
4
  import type { TableSchemas } from './schemas.js';
5
5
  import type { Database } from './database.js';
@@ -14,10 +14,10 @@ export type TableTypes<T extends Database.Schema[]> = IsAny<T> extends true ? an
14
14
  */
15
15
  export type TableIndex<P, T extends AnyObject> = PropertyExists<P, T> extends true ? (T[P] extends Database.Indexes ? T[P] : {}) : {};
16
16
  /**
17
- * Given a table `T` and a property `P`, it returns all the relations corresponding
18
- * to the given property.
17
+ * Given a table `T` and a property `P`, it returns all the relations corresponding to the
18
+ * given property.
19
19
  */
20
- export type TableRelation<P, T extends AnyObject> = PropertyExists<P, T> extends true ? (T[P] extends Relations ? T[P] : {}) : {};
20
+ export type TableRelation<P, T extends AnyObject> = PropertyExists<P, T> extends true ? T[P] extends RelationMetadata ? T[P] : RelationMetadata : RelationMetadata;
21
21
  /**
22
22
  * Given a database service `T`, it returns all table clients.
23
23
  */
@@ -27,19 +27,19 @@ export type TableClients<T extends Database.Service<any>> = {
27
27
  /**
28
28
  * Table client.
29
29
  */
30
- export interface Table<T extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> {
30
+ export interface Table<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> {
31
31
  /**
32
32
  * Insert one record into the database.
33
33
  *
34
34
  * @param query Input query.
35
35
  */
36
- insertOne(query: Query.InsertOneInput<T, I, R>): Promise<Query.InsertOneResult>;
36
+ insertOne(query: Query.InsertOneInput<T, R>): Promise<Query.InsertOneResult>;
37
37
  /**
38
38
  * Find one database record.
39
39
  *
40
40
  * @param query Input query.
41
41
  */
42
- findOne<S extends Query.SelectInput<T, R>>(query: Query.FindOneInput<T, S, I>): Promise<Query.FindOneResult<T, S, R>>;
42
+ findOne<S extends Query.SelectInput<T, R>>(query: Query.FindOneInput<T, S, I, R>): Promise<Query.FindOneResult<T, S, R>>;
43
43
  /**
44
44
  * Update one database record.
45
45
  *
@@ -57,7 +57,7 @@ export interface Table<T extends Database.Schema, I extends Database.Indexes<T>,
57
57
  *
58
58
  * @param query Input query.
59
59
  */
60
- deleteOne<S extends Query.SelectInput<T, R>>(query: Query.DeleteOneInput<T, S, I>): Promise<Query.DeleteOneResult<T, S, R>>;
60
+ deleteOne<S extends Query.SelectInput<T, R>>(query: Query.DeleteOneInput<T, S, I, R>): Promise<Query.DeleteOneResult<T, S, R>>;
61
61
  /**
62
62
  * Insert multiple records into the database.
63
63
  *
@@ -69,17 +69,17 @@ export interface Table<T extends Database.Schema, I extends Database.Indexes<T>,
69
69
  *
70
70
  * @param query Input query.
71
71
  */
72
- findMany<S extends Query.SelectInput<T, R>>(query: Query.FindManyInput<T, S, I>): Promise<Query.FindManyResult<T, S, R>>;
72
+ findMany<S extends Query.SelectInput<T, R>>(query: Query.FindManyInput<T, S, I, R>): Promise<Query.FindManyResult<T, S, R>>;
73
73
  /**
74
74
  * Update multiple database records.
75
75
  *
76
76
  * @param query Input query.
77
77
  */
78
- updateMany<S extends Query.SelectInput<T, R>>(query: Query.UpdateManyInput<T, S, I, R>): Promise<Query.UpdateManyResult<T, S, R>>;
78
+ updateMany<S extends Query.SelectInput<T, R>>(query: Query.UpdateManyInput<T, S, R>): Promise<Query.UpdateManyResult<T, S, R>>;
79
79
  /**
80
80
  * Delete multiple database records.
81
81
  *
82
82
  * @param query Input query.
83
83
  */
84
- deleteMany<S extends Query.SelectInput<T, R>>(query: Query.DeleteManyInput<T, S>): Promise<Query.DeleteManyResult<T, S, R>>;
84
+ deleteMany<S extends Query.SelectInput<T, R>>(query: Query.DeleteManyInput<T, S, R>): Promise<Query.DeleteManyResult<T, S, R>>;
85
85
  }
@@ -1,4 +1,5 @@
1
- import type { Relations, RelationTables } from './relations.js';
1
+ import type { AnyObject } from '@ez4/utils';
2
+ import type { RelationMetadata, RelationTables } from './relations.js';
2
3
  import type { TableIndex, TableRelation } from './table.js';
3
4
  import type { IndexedTables } from './indexes.js';
4
5
  import type { TableSchemas } from './schemas.js';
@@ -12,18 +13,17 @@ export declare namespace Transaction {
12
13
  * Write operations.
13
14
  */
14
15
  export type WriteOperations<T extends Database.Service<any>> = {
15
- [P in keyof TableSchemas<T>]?: TableSchemas<T>[P] extends Database.Schema ? {
16
- [alias: string]: InsertOperation<TableSchemas<T>[P], TableIndex<P, IndexedTables<T>>, TableRelation<P, RelationTables<T>>> | UpdateOperation<TableSchemas<T>[P], TableIndex<P, IndexedTables<T>>, TableRelation<P, RelationTables<T>>> | DeleteOperation<TableSchemas<T>[P], TableIndex<P, IndexedTables<T>>, TableRelation<P, RelationTables<T>>>;
17
- } : never;
16
+ [P in keyof TableSchemas<T>]?: (TableSchemas<T>[P] extends Database.Schema ? AnyOperation<TableSchemas<T>[P], TableIndex<P, IndexedTables<T>>, TableRelation<P, RelationTables<T>>> : AnyObject)[];
18
17
  };
19
- type InsertOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
20
- insert: Query.InsertOneInput<T, I, R>;
18
+ type AnyOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = InsertOperation<T, R> | UpdateOperation<T, I, R> | DeleteOperation<T, I, R>;
19
+ type InsertOperation<T extends Database.Schema, R extends RelationMetadata> = {
20
+ insert: Query.InsertOneInput<T, R>;
21
21
  };
22
- type UpdateOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
23
- update: Omit<Query.UpdateOneInput<T, Query.SelectInput<T, R>, I, R>, 'select'>;
22
+ type UpdateOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = {
23
+ update: Omit<Query.UpdateOneInput<T, Query.SelectInput<T, R>, I, R>, 'select' | 'include'>;
24
24
  };
25
- type DeleteOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends Relations> = {
26
- delete: Omit<Query.DeleteOneInput<T, Query.SelectInput<T, R>, I>, 'select'>;
25
+ type DeleteOperation<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = {
26
+ delete: Omit<Query.DeleteOneInput<T, Query.SelectInput<T, R>, I, R>, 'select' | 'include'>;
27
27
  };
28
28
  export {};
29
29
  }
@@ -1,7 +1,9 @@
1
+ import type { Index } from '../services/indexes.js';
1
2
  export type TableRelation = {
2
3
  sourceTable: string;
3
4
  sourceColumn: string;
5
+ sourceIndex?: Index;
4
6
  targetColumn: string;
5
7
  targetAlias: string;
6
- foreign: boolean;
8
+ targetIndex?: Index;
7
9
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ez4/database",
3
3
  "description": "EZ4: Components to build database services",
4
- "version": "0.9.0",
4
+ "version": "0.11.0",
5
5
  "author": "Silas B.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -42,12 +42,12 @@
42
42
  "live:publish": "npm run test && npm publish --access public"
43
43
  },
44
44
  "peerDependencies": {
45
- "@ez4/project": "^0.9.0"
45
+ "@ez4/project": "^0.11.0"
46
46
  },
47
47
  "dependencies": {
48
- "@ez4/common": "^0.9.0",
49
- "@ez4/reflection": "^0.9.0",
50
- "@ez4/schema": "^0.9.0",
51
- "@ez4/utils": "^0.9.0"
48
+ "@ez4/common": "^0.11.0",
49
+ "@ez4/reflection": "^0.11.0",
50
+ "@ez4/schema": "^0.11.0",
51
+ "@ez4/utils": "^0.11.0"
52
52
  }
53
53
  }
@@ -1,10 +0,0 @@
1
- export declare namespace Schema {
2
- /**
3
- * Set property to be a primary index.
4
- */
5
- type Primary<T> = T;
6
- /**
7
- * Set property to be a regular index.
8
- */
9
- type Index<T> = T;
10
- }
@@ -1,104 +0,0 @@
1
- import type { EveryType, TypeObject } from '@ez4/reflection';
2
- export type RichTypes = {
3
- index?: string;
4
- type: EveryType;
5
- };
6
- export declare const getRichTypes: (type: TypeObject) => RichTypes | null;
7
- export declare const createRichType: (richType: RichTypes) => {
8
- extra: {
9
- index: "primary" | "regular";
10
- };
11
- type: import("@ez4/reflection").TypeName.Object;
12
- file?: string;
13
- members?: import("@ez4/reflection").EveryMemberType[];
14
- } | {
15
- extra: {
16
- index: "primary" | "regular";
17
- };
18
- type: import("@ez4/reflection").TypeName.Any;
19
- } | {
20
- extra: {
21
- index: "primary" | "regular";
22
- };
23
- type: import("@ez4/reflection").TypeName.Void;
24
- } | {
25
- extra: {
26
- index: "primary" | "regular";
27
- };
28
- type: import("@ez4/reflection").TypeName.Never;
29
- } | {
30
- extra: {
31
- index: "primary" | "regular";
32
- };
33
- type: import("@ez4/reflection").TypeName.Unknown;
34
- } | {
35
- extra: {
36
- index: "primary" | "regular";
37
- };
38
- type: import("@ez4/reflection").TypeName.Undefined;
39
- } | {
40
- extra: {
41
- index: "primary" | "regular";
42
- };
43
- type: import("@ez4/reflection").TypeName.Null;
44
- literal?: boolean;
45
- default?: boolean;
46
- } | {
47
- extra: {
48
- index: "primary" | "regular";
49
- };
50
- type: import("@ez4/reflection").TypeName.Boolean;
51
- literal?: boolean;
52
- default?: boolean;
53
- } | {
54
- extra: {
55
- index: "primary" | "regular";
56
- };
57
- type: import("@ez4/reflection").TypeName.Number;
58
- literal?: number;
59
- default?: number;
60
- } | {
61
- extra: {
62
- index: "primary" | "regular";
63
- };
64
- type: import("@ez4/reflection").TypeName.String;
65
- literal?: string;
66
- default?: string;
67
- } | {
68
- extra: {
69
- index: "primary" | "regular";
70
- };
71
- type: import("@ez4/reflection").TypeName.Reference;
72
- namespace?: string;
73
- internal?: boolean;
74
- path: string;
75
- } | {
76
- extra: {
77
- index: "primary" | "regular";
78
- };
79
- type: import("@ez4/reflection").TypeName.Union;
80
- elements: EveryType[];
81
- } | {
82
- extra: {
83
- index: "primary" | "regular";
84
- };
85
- type: import("@ez4/reflection").TypeName.Array;
86
- element: EveryType;
87
- spread?: boolean;
88
- } | {
89
- extra: {
90
- index: "primary" | "regular";
91
- };
92
- type: import("@ez4/reflection").TypeName.Tuple;
93
- elements: EveryType[];
94
- } | {
95
- extra: {
96
- index: "primary" | "regular";
97
- };
98
- type: import("@ez4/reflection").TypeName.Callback;
99
- name?: string;
100
- file?: string;
101
- description?: string;
102
- parameters?: import("@ez4/reflection").TypeParameter[];
103
- return?: EveryType;
104
- } | null;
@@ -1,12 +0,0 @@
1
- import type { ArrayRest, IsArrayEmpty, IsAny } from '@ez4/utils';
2
- import type { Database } from './database.js';
3
- /**
4
- * Given an array of schemas `T`, it returns an union of `Database.Table` for each schema.
5
- */
6
- export type TableTypes<T extends Database.Schema[]> = IsAny<T> extends true ? any : IsArrayEmpty<T> extends true ? Database.Table<Database.Schema> : Database.Table<T[0]> | TableTypes<ArrayRest<T>>;
7
- /**
8
- * Given a database service `T`, it returns all its table types.
9
- */
10
- export type DatabaseTables<T> = T extends {
11
- tables: infer U;
12
- } ? U : [];
@@ -1,34 +0,0 @@
1
- /**
2
- * Stream change for `insert`, `update` or `delete` operations.
3
- */
4
- export type StreamChange<T> = StreamInsertChange<T> | StreamUpdateChange<T> | StreamDeleteChange<T>;
5
- /**
6
- * Stream change for an `insert` operation.
7
- */
8
- export type StreamInsertChange<T> = {
9
- type: StreamType.Insert;
10
- record: T;
11
- };
12
- /**
13
- * Stream change for an `update` operation.
14
- */
15
- export type StreamUpdateChange<T> = {
16
- type: StreamType.Update;
17
- oldRecord: T;
18
- newRecord: T;
19
- };
20
- /**
21
- * Stream change for an `delete` operation.
22
- */
23
- export type StreamDeleteChange<T> = {
24
- type: StreamType.Delete;
25
- record: T;
26
- };
27
- /**
28
- * Stream change types.
29
- */
30
- export declare const enum StreamType {
31
- Insert = "insert",
32
- Update = "update",
33
- Delete = "delete"
34
- }
@@ -1,100 +0,0 @@
1
- import type { TypeObject } from '@ez4/reflection';
2
- export declare const applyRichTypePath: (file: string) => string | null;
3
- export declare const applyRichTypeObject: (type: TypeObject) => {
4
- extra: {
5
- index: "primary" | "regular";
6
- };
7
- type: import("@ez4/reflection").TypeName.Object;
8
- file?: string;
9
- members?: import("@ez4/reflection").EveryMemberType[];
10
- } | {
11
- extra: {
12
- index: "primary" | "regular";
13
- };
14
- type: import("@ez4/reflection").TypeName.Any;
15
- } | {
16
- extra: {
17
- index: "primary" | "regular";
18
- };
19
- type: import("@ez4/reflection").TypeName.Void;
20
- } | {
21
- extra: {
22
- index: "primary" | "regular";
23
- };
24
- type: import("@ez4/reflection").TypeName.Never;
25
- } | {
26
- extra: {
27
- index: "primary" | "regular";
28
- };
29
- type: import("@ez4/reflection").TypeName.Unknown;
30
- } | {
31
- extra: {
32
- index: "primary" | "regular";
33
- };
34
- type: import("@ez4/reflection").TypeName.Undefined;
35
- } | {
36
- extra: {
37
- index: "primary" | "regular";
38
- };
39
- type: import("@ez4/reflection").TypeName.Null;
40
- literal?: boolean;
41
- default?: boolean;
42
- } | {
43
- extra: {
44
- index: "primary" | "regular";
45
- };
46
- type: import("@ez4/reflection").TypeName.Boolean;
47
- literal?: boolean;
48
- default?: boolean;
49
- } | {
50
- extra: {
51
- index: "primary" | "regular";
52
- };
53
- type: import("@ez4/reflection").TypeName.Number;
54
- literal?: number;
55
- default?: number;
56
- } | {
57
- extra: {
58
- index: "primary" | "regular";
59
- };
60
- type: import("@ez4/reflection").TypeName.String;
61
- literal?: string;
62
- default?: string;
63
- } | {
64
- extra: {
65
- index: "primary" | "regular";
66
- };
67
- type: import("@ez4/reflection").TypeName.Reference;
68
- namespace?: string;
69
- internal?: boolean;
70
- path: string;
71
- } | {
72
- extra: {
73
- index: "primary" | "regular";
74
- };
75
- type: import("@ez4/reflection").TypeName.Union;
76
- elements: import("@ez4/reflection").EveryType[];
77
- } | {
78
- extra: {
79
- index: "primary" | "regular";
80
- };
81
- type: import("@ez4/reflection").TypeName.Array;
82
- element: import("@ez4/reflection").EveryType;
83
- spread?: boolean;
84
- } | {
85
- extra: {
86
- index: "primary" | "regular";
87
- };
88
- type: import("@ez4/reflection").TypeName.Tuple;
89
- elements: import("@ez4/reflection").EveryType[];
90
- } | {
91
- extra: {
92
- index: "primary" | "regular";
93
- };
94
- type: import("@ez4/reflection").TypeName.Callback;
95
- name?: string;
96
- file?: string;
97
- description?: string;
98
- parameters?: import("@ez4/reflection").TypeParameter[];
99
- return?: import("@ez4/reflection").EveryType;
100
- } | null;