@ez4/database 0.29.0 → 0.30.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,148 +1,148 @@
1
- "use strict";var X=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var o=(e,r)=>X(e,"name",{value:r,configurable:!0});var et=(e,r)=>{for(var t in r)X(e,t,{get:r[t],enumerable:!0})},tt=(e,r,t,a)=>{if(r&&
2
- typeof r=="object"||typeof r=="function")for(let n of Ze(r))!Le.call(e,n)&&n!==t&&
3
- X(e,n,{get:()=>r[n],enumerable:!(a=Ye(r,n))||a.enumerable});return e};var rt=e=>tt(X({},"__esModule",{value:!0}),e);var Tt={};et(Tt,{IncompleteEngineError:()=>H,IncompleteHandlerError:()=>W,IncompleteScalabilityError:()=>N,
4
- IncompleteServiceError:()=>A,IncompleteStreamError:()=>_,IncompleteTableError:()=>F,
5
- IncorrectIndexesTypeError:()=>V,IncorrectRelationsTypeError:()=>j,IncorrectSchemaTypeError:()=>B,
6
- IncorrectStreamTypeError:()=>K,Index:()=>ie,InvalidIndexReferenceError:()=>G,InvalidIndexTypeError:()=>$,
7
- InvalidIndexesTypeError:()=>q,InvalidRelationAliasError:()=>z,InvalidRelationColumnError:()=>I,
8
- InvalidRelationTableError:()=>U,InvalidRelationTargetError:()=>C,InvalidRelationsTypeError:()=>w,
9
- InvalidSchemaTypeError:()=>Q,InvalidStreamTypeError:()=>J,ServiceType:()=>Y,getDatabaseServices:()=>me,
10
- getDatabaseTable:()=>le,getTableSchema:()=>pe,isDatabaseService:()=>nt,registerTriggers:()=>bt});
11
- module.exports=rt(Tt);var Je=require("@ez4/common/library"),Ke=require("@ez4/schema/library"),We=require("@ez4/project/library");var u=require("@ez4/common/library"),Qe=require("@ez4/reflection");var Y="@ez4/database",nt=o(e=>e.type===Y,"isDatabaseService");var de=require("@ez4/common/library");var A=class extends de.IncompleteTypeError{static{o(this,"IncompleteServiceError")}constructor(r,t){
12
- super("Incomplete database service",r,t)}};var g=require("@ez4/common/library");var w=class extends g.InvalidTypeError{static{o(this,"InvalidRelationsTypeError")}constructor(r){
13
- super("Invalid table relations type",void 0,"Database.Relations",r)}},j=class extends g.IncorrectTypeError{constructor(t,a){
14
- super("Incorrect table relations type",t,"Database.Relations",a);this.schemaType=
15
- t}static{o(this,"IncorrectRelationsTypeError")}},C=class extends g.TypeError{constructor(t,a){
16
- super(`Target ${t} must follow the pattern 'column@alias'.`,a);this.relationSource=
17
- t}static{o(this,"InvalidRelationTargetError")}},U=class extends g.TypeError{constructor(t,a){
18
- super(`Relation table ${t} don't exists.`,a);this.relationTable=t}static{o(this,
19
- "InvalidRelationTableError")}},I=class extends g.TypeError{constructor(t,a){super(
20
- `Relation column ${t} don't exists.`,a);this.relationColumn=t}static{o(this,"Inv\
21
- alidRelationColumnError")}},z=class extends g.TypeError{constructor(t,a){super(`\
22
- Relation alias ${t} can't override table columns.`,a);this.relationAlias=t}static{
23
- o(this,"InvalidRelationAliasError")}};var T=require("@ez4/common/library"),S=require("@ez4/reflection"),te=require("@ez4/utils");var ue=require("@ez4/common/library");var N=class extends ue.IncompleteTypeError{static{o(this,"IncompleteScalabilityE\
24
- rror")}constructor(r,t){super("Incomplete database scalability",r,t)}};var b=require("@ez4/common/library"),Z=require("@ez4/reflection");var L=o(e=>(0,b.isClassDeclaration)(e)&&(0,b.hasHeritageType)(e,"Database.Servic\
25
- e"),"isDatabaseService"),ee=o(e=>(0,b.isModelDeclaration)(e)&&(0,b.hasHeritageType)(
26
- e,"Database.Engine"),"isDatabaseEngine"),be=o(e=>(0,b.isModelDeclaration)(e)&&(0,b.hasHeritageType)(
27
- e,"Database.Table"),"isDatabaseTable"),Te=o(e=>(0,Z.isTypeCallback)(e)||(0,Z.isTypeFunction)(
28
- e),"isStreamHandler"),ye=o(e=>(0,b.hasHeritageType)(e,"Database.Relations"),"isT\
29
- ableRelations"),fe=o(e=>(0,b.hasHeritageType)(e,"Database.Indexes"),"isTableInde\
30
- xes"),xe=o(e=>(0,b.hasHeritageType)(e,"Database.Schema"),"isTableSchema"),ge=o(e=>(0,b.hasHeritageType)(
31
- e,"Database.Stream"),"isTableStream");var Se=o((e,r,t,a)=>{if(!(0,S.isTypeReference)(e))return Me(e,r,a);let n=(0,T.getReferenceType)(
32
- e,t);return n?Me(n,r,a):null},"getDatabaseScalability"),at=o(e=>(0,te.isAnyNumber)(
33
- e.minCapacity)&&(0,te.isAnyNumber)(e.maxCapacity),"isValidScalability"),Me=o((e,r,t)=>ee(
34
- e)?Ie(e,r,(0,T.getModelMembers)(e),t):(0,S.isTypeObject)(e)?Ie(e,r,(0,T.getObjectMembers)(
35
- e),t):null,"getTypeScalability"),Ie=o((e,r,t,a)=>{let n={},s=new Set(["minCapaci\
36
- ty","maxCapacity"]);for(let i of t)if(!(!(0,S.isModelProperty)(i)||i.inherited))
37
- switch(i.name){default:a.push(new T.InvalidServicePropertyError(r.name,i.name,e.
38
- file));break;case"minCapacity":case"maxCapacity":let p=(0,T.getPropertyNumber)(i);
39
- (0,te.isAnyNumber)(p)&&(n[i.name]=p,s.delete(i.name));break}return at(n)?n:(a.push(
40
- new N([...s],e.file)),null)},"getTypeFromMembers");var D=require("@ez4/reflection"),c=require("@ez4/common/library");var De=require("@ez4/common/library");var H=class extends De.IncompleteTypeError{static{o(this,"IncompleteEngineError")}constructor(r,t){
41
- super("Incomplete database engine",r,t)}};var Ee=o((e,r,t,a)=>{if(!(0,D.isTypeReference)(e))return he(e,r,a);let n=(0,c.getReferenceType)(
42
- e,t);return n?he(n,r,a):null},"getDatabaseEngine"),ot=o(e=>!!e.name&&!!e.parametersMode&&
1
+ "use strict";var X=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var n=(e,t)=>X(e,"name",{value:t,configurable:!0});var er=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},rr=(e,t,r,a)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let o of Ze(t))!Le.call(e,o)&&o!==r&&
3
+ X(e,o,{get:()=>t[o],enumerable:!(a=Ye(t,o))||a.enumerable});return e};var tr=e=>rr(X({},"__esModule",{value:!0}),e);var fr={};er(fr,{IncompleteEngineError:()=>F,IncompleteHandlerError:()=>W,IncompleteScalabilityError:()=>H,
4
+ IncompleteServiceError:()=>j,IncompleteStreamError:()=>J,IncompleteTableError:()=>U,
5
+ IncorrectIndexesTypeError:()=>$,IncorrectRelationsTypeError:()=>R,IncorrectSchemaTypeError:()=>G,
6
+ IncorrectStreamTypeError:()=>Q,Index:()=>Oe,InvalidIndexReferenceError:()=>_,InvalidIndexTypeError:()=>q,
7
+ InvalidIndexesTypeError:()=>V,InvalidRelationAliasError:()=>N,InvalidRelationColumnError:()=>S,
8
+ InvalidRelationTableError:()=>C,InvalidRelationTargetError:()=>z,InvalidRelationsTypeError:()=>A,
9
+ InvalidSchemaTypeError:()=>B,InvalidStreamTypeError:()=>K,ServiceType:()=>Y,getDatabaseServices:()=>pe,
10
+ getDatabaseTable:()=>le,getTableSchema:()=>ie,isDatabaseService:()=>or,registerTriggers:()=>br});
11
+ module.exports=tr(fr);var Ke=require("@ez4/common/library"),Qe=require("@ez4/schema/library"),We=require("@ez4/project/library");var u=require("@ez4/common/library"),Be=require("@ez4/reflection");var Y="@ez4/database",or=n(e=>e.type===Y,"isDatabaseService");var ce=require("@ez4/common/library");var j=class extends ce.IncompleteTypeError{static{n(this,"IncompleteServiceError")}constructor(t,r){
12
+ super("Incomplete database service",t,r)}};var g=require("@ez4/common/library");var A=class extends g.InvalidTypeError{static{n(this,"InvalidRelationsTypeError")}constructor(t){
13
+ super("Invalid table relations type",void 0,"Database.Relations",t)}},R=class extends g.IncorrectTypeError{constructor(r,a){
14
+ super("Incorrect table relations type",r,"Database.Relations",a);this.schemaType=
15
+ r}static{n(this,"IncorrectRelationsTypeError")}},z=class extends g.TypeError{constructor(r,a){
16
+ super(`Target ${r} must follow the pattern 'column@alias'.`,a);this.relationSource=
17
+ r}static{n(this,"InvalidRelationTargetError")}},C=class extends g.TypeError{constructor(r,a){
18
+ super(`Relation table ${r} don't exists.`,a);this.relationTable=r}static{n(this,
19
+ "InvalidRelationTableError")}},S=class extends g.TypeError{constructor(r,a){super(
20
+ `Relation column ${r} don't exists.`,a);this.relationColumn=r}static{n(this,"Inv\
21
+ alidRelationColumnError")}},N=class extends g.TypeError{constructor(r,a){super(`\
22
+ Relation alias ${r} can't override table columns.`,a);this.relationAlias=r}static{
23
+ n(this,"InvalidRelationAliasError")}};var f=require("@ez4/common/library"),I=require("@ez4/reflection"),re=require("@ez4/utils");var de=require("@ez4/common/library");var H=class extends de.IncompleteTypeError{static{n(this,"IncompleteScalabilityE\
24
+ rror")}constructor(t,r){super("Incomplete database scalability",t,r)}};var b=require("@ez4/common/library"),Z=require("@ez4/reflection");var L=n(e=>(0,b.isClassDeclaration)(e)&&(0,b.hasHeritageType)(e,"Database.Servic\
25
+ e"),"isDatabaseService"),ee=n(e=>(0,b.isModelDeclaration)(e)&&(0,b.hasHeritageType)(
26
+ e,"Database.Engine"),"isDatabaseEngine"),ue=n(e=>(0,b.isModelDeclaration)(e)&&(0,b.hasHeritageType)(
27
+ e,"Database.Table"),"isDatabaseTable"),be=n(e=>(0,Z.isTypeCallback)(e)||(0,Z.isTypeFunction)(
28
+ e),"isStreamHandler"),fe=n(e=>(0,b.hasHeritageType)(e,"Database.Relations"),"isT\
29
+ ableRelations"),Te=n(e=>(0,b.hasHeritageType)(e,"Database.Indexes"),"isTableInde\
30
+ xes"),ye=n(e=>(0,b.hasHeritageType)(e,"Database.Schema"),"isTableSchema"),xe=n(e=>(0,b.hasHeritageType)(
31
+ e,"Database.Stream"),"isTableStream");var Se=n((e,t,r,a)=>{if(!(0,I.isTypeReference)(e))return ge(e,t,a);let o=(0,f.getReferenceType)(
32
+ e,r);return o?ge(o,t,a):null},"getDatabaseScalability"),ar=n(e=>(0,re.isAnyNumber)(
33
+ e.minCapacity)&&(0,re.isAnyNumber)(e.maxCapacity),"isValidScalability"),ge=n((e,t,r)=>ee(
34
+ e)?Me(e,t,(0,f.getModelMembers)(e),r):(0,I.isTypeObject)(e)?Me(e,t,(0,f.getObjectMembers)(
35
+ e),r):null,"getTypeScalability"),Me=n((e,t,r,a)=>{let o={},s=new Set(["minCapaci\
36
+ ty","maxCapacity"]);for(let i of r)if(!(!(0,I.isModelProperty)(i)||i.inherited))
37
+ switch(i.name){default:a.push(new f.InvalidServicePropertyError(t.name,i.name,e.
38
+ file));break;case"minCapacity":case"maxCapacity":let l=(0,f.getPropertyNumber)(i);
39
+ (0,re.isAnyNumber)(l)&&(o[i.name]=l,s.delete(i.name));break}return ar(o)?o:(a.push(
40
+ new H([...s],e.file)),null)},"getTypeFromMembers");var h=require("@ez4/reflection"),c=require("@ez4/common/library");var Ie=require("@ez4/common/library");var F=class extends Ie.IncompleteTypeError{static{n(this,"IncompleteEngineError")}constructor(t,r){
41
+ super("Incomplete database engine",t,r)}};var ve=n((e,t,r,a)=>{if(!(0,h.isTypeReference)(e))return he(e,t,a);let o=(0,c.getReferenceType)(
42
+ e,r);return o?he(o,t,a):null},"getDatabaseEngine"),nr=n(e=>!!e.name&&!!e.parametersMode&&
43
43
  !!e.transactionMode&&!!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,"isV\
44
- alidEngine"),he=o((e,r,t)=>ee(e)?ve(e,r,(0,c.getModelMembers)(e),t):(0,D.isTypeObject)(
45
- e)?ve(e,r,(0,c.getObjectMembers)(e),t):null,"getTypeEngine"),ve=o((e,r,t,a)=>{let n={},
44
+ alidEngine"),he=n((e,t,r)=>ee(e)?De(e,t,(0,c.getModelMembers)(e),r):(0,h.isTypeObject)(
45
+ e)?De(e,t,(0,c.getObjectMembers)(e),r):null,"getTypeEngine"),De=n((e,t,r,a)=>{let o={},
46
46
  s=new Set(["name","parametersMode","transactionMode","insensitiveMode","paginati\
47
- onMode","orderMode"]);for(let i of t)if(!(!(0,D.isModelProperty)(i)||i.inherited))
48
- switch(i.name){default:a.push(new c.InvalidServicePropertyError(r.name,i.name,e.
49
- file));break;case"name":(n.name=(0,c.getPropertyString)(i))&&s.delete(i.name);break;case"\
50
- parametersMode":(n.parametersMode=(0,c.getPropertyStringIn)(i,["index","both"]))&&
51
- s.delete(i.name);break;case"transactionMode":(n.transactionMode=(0,c.getPropertyStringIn)(
52
- i,["static","interactive"]))&&s.delete(i.name);break;case"insensitiveMode":(n.insensitiveMode=
47
+ onMode","orderMode"]);for(let i of r)if(!(!(0,h.isModelProperty)(i)||i.inherited))
48
+ switch(i.name){default:a.push(new c.InvalidServicePropertyError(t.name,i.name,e.
49
+ file));break;case"name":(o.name=(0,c.getPropertyString)(i))&&s.delete(i.name);break;case"\
50
+ parametersMode":(o.parametersMode=(0,c.getPropertyStringIn)(i,["index","both"]))&&
51
+ s.delete(i.name);break;case"transactionMode":(o.transactionMode=(0,c.getPropertyStringIn)(
52
+ i,["static","interactive"]))&&s.delete(i.name);break;case"insensitiveMode":(o.insensitiveMode=
53
53
  (0,c.getPropertyStringIn)(i,["unsupported","enabled"]))&&s.delete(i.name);break;case"\
54
- paginationMode":(n.paginationMode=(0,c.getPropertyStringIn)(i,["cursor","offset"]))&&
55
- s.delete(i.name);break;case"orderMode":(n.orderMode=(0,c.getPropertyStringIn)(i,
56
- ["any","index"]))&&s.delete(i.name);break;case"lockMode":(n.lockMode=(0,c.getPropertyStringIn)(
57
- i,["unsupported","supported"]))&&s.delete(i.name);break}return ot(n)?n:(a.push(new H(
58
- [...s],e.file)),null)},"getTypeFromMembers");var x=require("@ez4/common/library"),k=require("@ez4/reflection");var Pe=require("@ez4/common/library");var F=class extends Pe.IncompleteTypeError{static{o(this,"IncompleteTableError")}constructor(r,t){
59
- super("Incomplete database table",r,t)}};var M=require("@ez4/common/library");var q=class extends M.InvalidTypeError{static{o(this,"InvalidIndexesTypeError")}constructor(r){
60
- super("Invalid table indexes type",void 0,"Database.Indexes",r)}},V=class extends M.IncorrectTypeError{constructor(t,a){
61
- super("Incorrect table indexes type",t,"Database.Indexes",a);this.schemaType=t}static{
62
- o(this,"IncorrectIndexesTypeError")}},$=class extends M.TypeError{constructor(t,a){
63
- super(`Invalid index type, ${t} must follow one of the Index options.`,a);this.indexName=
64
- t}static{o(this,"InvalidIndexTypeError")}},G=class extends M.TypeError{constructor(t,a){
65
- super(`Invalid index reference, ${t} must be valid column.`,a);this.indexName=t}static{
66
- o(this,"InvalidIndexReferenceError")}};var y=require("@ez4/common/library"),h=require("@ez4/reflection");var Re=o((e,r,t,a)=>{if(!(0,h.isTypeReference)(e))return Oe(e,r,a);let n=(0,y.getReferenceType)(
67
- e,t);return n?Oe(n,r,a):null},"getTableRelations"),Oe=o((e,r,t)=>(0,h.isTypeObject)(
68
- e)?ke(e,(0,y.getObjectMembers)(e),t):(0,y.isModelDeclaration)(e)?ye(e)?ke(e,(0,y.getModelMembers)(
69
- e),t):(t.push(new j(e.name,e.file)),null):(t.push(new w(r.file)),null),"getTypeR\
70
- elations"),ke=o((e,r,t)=>{let a=[];for(let n of r){if(!(0,h.isModelProperty)(n)||
71
- n.inherited)continue;let s=(0,y.getPropertyString)(n),i=n.name;if(!s)return t.push(
72
- new C(i,e.file)),null;let[p,l]=i.split("@",2),[m,R]=s.split(":",2);a.push({sourceTable:m,
73
- sourceColumn:R,targetColumn:p,targetAlias:l})}return a},"getTypeFromMembers");var f=require("@ez4/common/library"),v=require("@ez4/reflection");var ie=(n=>(n.Primary="primary",n.Secondary="secondary",n.Unique="unique",n.TTL=
74
- "ttl",n))(ie||{});var je=o((e,r,t,a)=>{if(!(0,v.isTypeReference)(e))return Ae(e,r,a);let n=(0,f.getReferenceType)(
75
- e,t);return n?Ae(n,r,a):null},"getTableIndexes"),Ae=o((e,r,t)=>(0,v.isTypeObject)(
76
- e)?we(e,(0,f.getObjectMembers)(e),t):(0,f.isModelDeclaration)(e)?fe(e)?we(e,(0,f.getModelMembers)(
77
- e),t):(t.push(new V(e.name,e.file)),null):(t.push(new q(r.file)),null),"getTypeI\
78
- ndexes"),we=o((e,r,t)=>{let a=[];for(let n of r){if(!(0,v.isModelProperty)(n)||n.
79
- inherited)continue;let s=n.name,i=(0,f.getPropertyString)(n);switch(i){case"prim\
54
+ paginationMode":(o.paginationMode=(0,c.getPropertyStringIn)(i,["cursor","offset"]))&&
55
+ s.delete(i.name);break;case"orderMode":(o.orderMode=(0,c.getPropertyStringIn)(i,
56
+ ["any","index"]))&&s.delete(i.name);break;case"lockMode":(o.lockMode=(0,c.getPropertyStringIn)(
57
+ i,["unsupported","supported"]))&&s.delete(i.name);break}return nr(o)?o:(a.push(new F(
58
+ [...s],e.file)),null)},"getTypeFromMembers");var x=require("@ez4/common/library"),w=require("@ez4/reflection");var Ee=require("@ez4/common/library");var U=class extends Ee.IncompleteTypeError{static{n(this,"IncompleteTableError")}constructor(t,r){
59
+ super("Incomplete database table",t,r)}};var M=require("@ez4/common/library");var V=class extends M.InvalidTypeError{static{n(this,"InvalidIndexesTypeError")}constructor(t){
60
+ super("Invalid table indexes type",void 0,"Database.Indexes",t)}},$=class extends M.IncorrectTypeError{constructor(r,a){
61
+ super("Incorrect table indexes type",r,"Database.Indexes",a);this.schemaType=r}static{
62
+ n(this,"IncorrectIndexesTypeError")}},q=class extends M.TypeError{constructor(r,a){
63
+ super(`Invalid index type, ${r} must follow one of the Index options.`,a);this.indexName=
64
+ r}static{n(this,"InvalidIndexTypeError")}},_=class extends M.TypeError{constructor(r,a){
65
+ super(`Invalid index reference, ${r} must be valid column.`,a);this.indexName=r}static{
66
+ n(this,"InvalidIndexReferenceError")}};var T=require("@ez4/common/library"),D=require("@ez4/reflection");var we=n((e,t,r,a)=>{if(!(0,D.isTypeReference)(e))return Pe(e,t,a);let o=(0,T.getReferenceType)(
67
+ e,r);return o?Pe(o,t,a):null},"getTableRelations"),Pe=n((e,t,r)=>(0,D.isTypeObject)(
68
+ e)?ke(e,(0,T.getObjectMembers)(e),r):(0,T.isModelDeclaration)(e)?fe(e)?ke(e,(0,T.getModelMembers)(
69
+ e),r):(r.push(new R(e.name,e.file)),null):(r.push(new A(t.file)),null),"getTypeR\
70
+ elations"),ke=n((e,t,r)=>{let a=[];for(let o of t){if(!(0,D.isModelProperty)(o)||
71
+ o.inherited)continue;let s=(0,T.getPropertyString)(o),i=o.name;if(!s)return r.push(
72
+ new z(i,e.file)),null;let[l,p]=i.split("@",2),[m,O]=s.split(":",2);a.push({sourceTable:m,
73
+ sourceColumn:O,targetColumn:l,targetAlias:p})}return a},"getTypeFromMembers");var y=require("@ez4/common/library"),v=require("@ez4/reflection");var Oe=(o=>(o.Primary="primary",o.Secondary="secondary",o.Unique="unique",o.TTL=
74
+ "ttl",o))(Oe||{});var Re=n((e,t,r,a)=>{if(!(0,v.isTypeReference)(e))return je(e,t,a);let o=(0,y.getReferenceType)(
75
+ e,r);return o?je(o,t,a):null},"getTableIndexes"),je=n((e,t,r)=>(0,v.isTypeObject)(
76
+ e)?Ae(e,(0,y.getObjectMembers)(e),r):(0,y.isModelDeclaration)(e)?Te(e)?Ae(e,(0,y.getModelMembers)(
77
+ e),r):(r.push(new $(e.name,e.file)),null):(r.push(new V(t.file)),null),"getTypeI\
78
+ ndexes"),Ae=n((e,t,r)=>{let a=[];for(let o of t){if(!(0,v.isModelProperty)(o)||o.
79
+ inherited)continue;let s=o.name,i=(0,y.getPropertyString)(o);switch(i){case"prim\
80
80
  ary":case"secondary":case"unique":case"ttl":a.push({name:s,columns:s.split(":"),
81
- type:i});break;default:return t.push(new $(s,e.file)),null}}return a},"getTypeFr\
82
- omMembers");var E=require("@ez4/schema/library"),ne=require("@ez4/common/library"),ae=require("@ez4/reflection");var re=require("@ez4/common/library");var Q=class extends re.InvalidTypeError{static{o(this,"InvalidSchemaTypeError")}constructor(r){
83
- super("Invalid table schema type",void 0,"Database.Schema",r)}},B=class extends re.IncorrectTypeError{constructor(t,a){
84
- super("Incorrect table schema type",t,"Database.Schema",a);this.schemaType=t}static{
85
- o(this,"IncorrectSchemaTypeError")}};var pe=o((e,r,t,a)=>{if(!(0,ae.isTypeReference)(e))return Ce(e,r,t,a);let n=(0,ne.getReferenceType)(
86
- e,t);return n?Ce(n,r,t,a):null},"getTableSchema"),Ce=o((e,r,t,a)=>(0,ae.isTypeObject)(
87
- e)?Ue(e,t):(0,ne.isModelDeclaration)(e)?xe(e)?Ue(e,t):(a.push(new B(e.name,e.file)),
88
- null):(a.push(new Q(r.file)),null),"getTypeSchema"),Ue=o((e,r)=>{let t=(0,E.getObjectSchema)(
89
- e,r,(0,E.createSchemaContext)({nullish:!0}));return t&&(0,E.isObjectSchema)(t)?t:
90
- null},"getSchema");var d=require("@ez4/common/library"),O=require("@ez4/reflection");var P=require("@ez4/common/library");var _=class extends P.IncompleteTypeError{static{o(this,"IncompleteStreamError")}constructor(r,t){
91
- super("Incomplete table stream",r,t)}},J=class extends P.InvalidTypeError{static{
92
- o(this,"InvalidStreamTypeError")}constructor(r){super("Invalid table stream type",
93
- void 0,"Database.Stream",r)}},K=class extends P.IncorrectTypeError{constructor(t,a){
94
- super("Incorrect table stream type",t,"Database.Stream",a);this.streamType=t}static{
95
- o(this,"IncorrectStreamTypeError")}};var ze=require("@ez4/common/library");var W=class extends ze.IncompleteTypeError{static{o(this,"IncompleteHandlerError")}constructor(r,t){
96
- super("Incomplete stream handler",r,t)}};var Ne=o((e,r,t)=>{if(!Te(e))return null;let{description:a,module:n}=e,s={...a&&
97
- {description:a},...n&&{module:n}},i=new Set(["name","file","change"]);return(s.name=
81
+ type:i});break;default:return r.push(new q(s,e.file)),null}}return a},"getTypeFr\
82
+ omMembers");var E=require("@ez4/schema/library"),oe=require("@ez4/common/library"),ae=require("@ez4/reflection");var te=require("@ez4/common/library");var B=class extends te.InvalidTypeError{static{n(this,"InvalidSchemaTypeError")}constructor(t){
83
+ super("Invalid table schema type",void 0,"Database.Schema",t)}},G=class extends te.IncorrectTypeError{constructor(r,a){
84
+ super("Incorrect table schema type",r,"Database.Schema",a);this.schemaType=r}static{
85
+ n(this,"IncorrectSchemaTypeError")}};var ie=n((e,t,r,a)=>{if(!(0,ae.isTypeReference)(e))return ze(e,t,r,a);let o=(0,oe.getReferenceType)(
86
+ e,r);return o?ze(o,t,r,a):null},"getTableSchema"),ze=n((e,t,r,a)=>(0,ae.isTypeObject)(
87
+ e)?Ce(e,r):(0,oe.isModelDeclaration)(e)?ye(e)?Ce(e,r):(a.push(new G(e.name,e.file)),
88
+ null):(a.push(new B(t.file)),null),"getTypeSchema"),Ce=n((e,t)=>{let r=(0,E.getObjectSchema)(
89
+ e,t,(0,E.createSchemaContext)({nullish:!0}));return r&&(0,E.isObjectSchema)(r)?r:
90
+ null},"getSchema");var d=require("@ez4/common/library"),k=require("@ez4/reflection");var P=require("@ez4/common/library");var J=class extends P.IncompleteTypeError{static{n(this,"IncompleteStreamError")}constructor(t,r){
91
+ super("Incomplete table stream",t,r)}},K=class extends P.InvalidTypeError{static{
92
+ n(this,"InvalidStreamTypeError")}constructor(t){super("Invalid table stream type",
93
+ void 0,"Database.Stream",t)}},Q=class extends P.IncorrectTypeError{constructor(r,a){
94
+ super("Incorrect table stream type",r,"Database.Stream",a);this.streamType=r}static{
95
+ n(this,"IncorrectStreamTypeError")}};var Ne=require("@ez4/common/library");var W=class extends Ne.IncompleteTypeError{static{n(this,"IncompleteHandlerError")}constructor(t,r){
96
+ super("Incomplete stream handler",t,r)}};var He=n((e,t,r)=>{if(!be(e))return null;let{description:a,module:o}=e,s={...a&&
97
+ {description:a},...o&&{module:o}},i=new Set(["name","file","change"]);return(s.name=
98
98
  e.name)&&i.delete("name"),(s.file=e.file)&&i.delete("file"),e.parameters&&i.delete(
99
- "change"),i.size===0&&st(s)?s:(t.push(new W([...i],e.file)),null)},"getStreamHan\
100
- dler"),st=o(e=>!!e.name&&!!e.file,"isValidHandler");var qe=o((e,r,t,a)=>{if(!(0,O.isTypeReference)(e))return He(e,r,t,a);let n=(0,d.getReferenceType)(
101
- e,t);return n?He(n,r,t,a):null},"getTableStream"),it=o(e=>!!e.handler,"isValidSt\
102
- ream"),He=o((e,r,t,a)=>(0,O.isTypeObject)(e)?Fe(e,r,(0,d.getObjectMembers)(e),t,
103
- a):(0,d.isModelDeclaration)(e)?ge(e)?Fe(e,r,(0,d.getModelMembers)(e),t,a):(a.push(
104
- new K(e.name,e.file)),null):(a.push(new J(r.file)),null),"getTypeStream"),Fe=o((e,r,t,a,n)=>{
105
- let s={},i=new Set(["handler"]);for(let p of t)if(!(!(0,O.isModelProperty)(p)||p.
106
- inherited))switch(p.name){default:n.push(new d.InvalidServicePropertyError(r.name,
107
- p.name,e.file));break;case"handler":s.handler=Ne(p.value,a,n);break;case"listene\
108
- r":s.listener=(0,d.getServiceListener)(p.value,n);break;case"memory":case"logRet\
109
- ention":case"timeout":s[p.name]=(0,d.getPropertyNumber)(p);break;case"variables":
110
- s.variables=(0,d.getLinkedVariableList)(p,n);break}return it(s)?s:(n.push(new _(
111
- [...i],e.file)),null)},"getTypeFromMembers");var le=o((e,r,t,a)=>{if(!(0,k.isTypeReference)(e))return Ve(e,r,t,a);let n=(0,x.getReferenceType)(
112
- e,t);return n?Ve(n,r,t,a):null},"getDatabaseTable"),pt=o(e=>!!e.name&&!!e.schema&&
113
- !!e.indexes,"isValidTable"),Ve=o((e,r,t,a)=>be(e)?$e(e,r,(0,x.getModelMembers)(e),
114
- t,a):(0,k.isTypeObject)(e)?$e(e,r,(0,x.getObjectMembers)(e),t,a):null,"getTypeTa\
115
- ble"),$e=o((e,r,t,a,n)=>{let s={},i=new Set(["name","schema","indexes"]);for(let l of t)
116
- if(!(!(0,k.isModelProperty)(l)||l.inherited))switch(l.name){default:n.push(new x.InvalidServicePropertyError(
117
- r.name,l.name,e.file));break;case"name":(s.name=(0,x.getPropertyString)(l))&&i.delete(
118
- l.name);break;case"schema":(s.schema=pe(l.value,e,a,n))&&i.delete(l.name);break;case"\
119
- indexes":(s.indexes=je(l.value,e,a,n))&&i.delete(l.name);break;case"relations":s.
120
- relations=Re(l.value,e,a,n);break;case"stream":s.stream=qe(l.value,r,a,n);break}
121
- if(!pt(s))return n.push(new F([...i],e.file)),null;let p=lt(e,s.indexes,s.schema);
122
- return p.length?(n.push(...p),null):s},"getTypeFromMembers"),lt=o((e,r,t)=>{let a=t.
123
- properties,n=[];for(let{name:s,columns:i}of r)i.some(l=>!a[l])&&n.push(new G(s,e.
124
- file));return n},"validateIndexes");var me=o(e=>{let r={},t=[];for(let a in e){let n=e[a];if(!L(n)||(0,u.isExternalDeclaration)(
125
- n))continue;let s={type:Y,extras:{}},i=new Set(["engine","tables"]),p=n.file;s.name=
126
- n.name;for(let m of(0,u.getModelMembers)(n))if(!(!(0,Qe.isModelProperty)(m)||m.inherited))
127
- switch(m.name){default:t.push(new u.InvalidServicePropertyError(s.name,m.name,p));
128
- break;case"client":break;case"scalability":(s.scalability=Se(m.value,n,e,t))&&i.
129
- delete(m.name);break;case"engine":(s.engine=Ee(m.value,n,e,t))&&i.delete(m.name);
130
- break;case"tables":(s.tables=ct(m,n,e,t))&&i.delete(m.name);break;case"variables":
131
- s.variables=(0,u.getLinkedVariableList)(m,t);break;case"services":s.services=(0,u.getLinkedServiceList)(
132
- m,e,t);break}if(!mt(s)){t.push(new A([...i],p));continue}let l=dt(n,s.tables);if(l.
133
- length){t.push(...l);continue}if(r[n.name]){t.push(new u.DuplicateServiceError(n.
134
- name,p));continue}r[n.name]=s}return{services:r,errors:t}},"getDatabaseServices"),
135
- mt=o(e=>!!e.name&&!!e.tables&&!!e.extras,"isValidService"),ct=o((e,r,t,a)=>{let n=(0,u.getPropertyTuple)(
136
- e)??[],s=[];for(let i of n){let p=le(i,r,t,a);p&&s.push(p)}return s},"getAllTabl\
137
- es"),dt=o((e,r)=>{let t=ut(r),a=[];for(let{relations:n,schema:s,indexes:i}of r){
138
- if(!n)continue;let p=s.properties;for(let l of n){let{sourceTable:m,sourceColumn:R,
139
- targetColumn:oe,targetAlias:ce}=l;p[oe]||a.push(new I(oe,e.file)),p[ce]&&a.push(
140
- new z(ce,e.file));let se=t[m]?.schema.properties;se||a.push(new U(m,e.file)),se&&
141
- !se[R]&&a.push(new I(R,e.file));let Xe=t[m]?.indexes??[];l.sourceIndex=Ge(Xe,R),
142
- l.targetIndex=Ge(i,oe)}}return a},"validateRelations"),Ge=o((e,r)=>e.find(({name:t})=>t===
143
- r)?.type,"getIndexType"),ut=o(e=>e.reduce((r,t)=>({...r,[t.name]:t}),{}),"getTab\
144
- leMap");var Be=o(e=>L(e)?e.name:null,"getLinkedService");var _e=!1,bt=o(()=>{_e||((0,Je.registerTriggers)(),(0,Ke.registerTriggers)(),(0,We.createTrigger)(
145
- "@ez4/database",{"metadata:getServices":me,"metadata:getLinkedService":Be}),_e=!0)},
99
+ "change"),i.size===0&&sr(s)?s:(r.push(new W([...i],e.file)),null)},"getStreamHan\
100
+ dler"),sr=n(e=>!!e.name&&!!e.file,"isValidHandler");var Ve=n((e,t,r,a)=>{if(!(0,k.isTypeReference)(e))return Fe(e,t,r,a);let o=(0,d.getReferenceType)(
101
+ e,r);return o?Fe(o,t,r,a):null},"getTableStream"),ir=n(e=>!!e.handler,"isValidSt\
102
+ ream"),Fe=n((e,t,r,a)=>(0,k.isTypeObject)(e)?Ue(e,t,(0,d.getObjectMembers)(e),r,
103
+ a):(0,d.isModelDeclaration)(e)?xe(e)?Ue(e,t,(0,d.getModelMembers)(e),r,a):(a.push(
104
+ new Q(e.name,e.file)),null):(a.push(new K(t.file)),null),"getTypeStream"),Ue=n((e,t,r,a,o)=>{
105
+ let s={},i=new Set(["handler"]);for(let l of r)if(!(!(0,k.isModelProperty)(l)||l.
106
+ inherited))switch(l.name){default:o.push(new d.InvalidServicePropertyError(t.name,
107
+ l.name,e.file));break;case"handler":s.handler=He(l.value,a,o);break;case"listene\
108
+ r":s.listener=(0,d.getServiceListener)(l.value,o);break;case"memory":case"logRet\
109
+ ention":case"timeout":s[l.name]=(0,d.getPropertyNumber)(l);break;case"variables":
110
+ s.variables=(0,d.getLinkedVariableList)(l,o);break}return ir(s)?s:(o.push(new J(
111
+ [...i],e.file)),null)},"getTypeFromMembers");var le=n((e,t,r,a)=>{if(!(0,w.isTypeReference)(e))return $e(e,t,r,a);let o=(0,x.getReferenceType)(
112
+ e,r);return o?$e(o,t,r,a):null},"getDatabaseTable"),lr=n(e=>!!e.name&&!!e.schema&&
113
+ !!e.indexes,"isValidTable"),$e=n((e,t,r,a)=>ue(e)?qe(e,t,(0,x.getModelMembers)(e),
114
+ r,a):(0,w.isTypeObject)(e)?qe(e,t,(0,x.getObjectMembers)(e),r,a):null,"getTypeTa\
115
+ ble"),qe=n((e,t,r,a,o)=>{let s={},i=new Set(["name","schema","indexes"]);for(let p of r)
116
+ if(!(!(0,w.isModelProperty)(p)||p.inherited))switch(p.name){default:o.push(new x.InvalidServicePropertyError(
117
+ t.name,p.name,e.file));break;case"name":(s.name=(0,x.getPropertyString)(p))&&i.delete(
118
+ p.name);break;case"schema":(s.schema=ie(p.value,e,a,o))&&i.delete(p.name);break;case"\
119
+ indexes":(s.indexes=Re(p.value,e,a,o))&&i.delete(p.name);break;case"relations":s.
120
+ relations=we(p.value,e,a,o);break;case"stream":s.stream=Ve(p.value,t,a,o);break}
121
+ if(!lr(s))return o.push(new U([...i],e.file)),null;let l=pr(e,s.indexes,s.schema);
122
+ return l.length?(o.push(...l),null):s},"getTypeFromMembers"),pr=n((e,t,r)=>{let a=r.
123
+ properties,o=[];for(let{name:s,columns:i}of t)i.some(p=>!a[p])&&o.push(new _(s,e.
124
+ file));return o},"validateIndexes");var pe=n(e=>{let t={},r=[];for(let a in e){let o=e[a];if(!L(o)||(0,u.isExternalDeclaration)(
125
+ o))continue;let s={type:Y,extras:{}},i=new Set(["engine","tables"]),l=o.file;s.name=
126
+ o.name;for(let m of(0,u.getModelMembers)(o))if(!(!(0,Be.isModelProperty)(m)||m.inherited))
127
+ switch(m.name){default:r.push(new u.InvalidServicePropertyError(s.name,m.name,l));
128
+ break;case"client":break;case"scalability":(s.scalability=Se(m.value,o,e,r))&&i.
129
+ delete(m.name);break;case"engine":(s.engine=ve(m.value,o,e,r))&&i.delete(m.name);
130
+ break;case"tables":(s.tables=cr(m,o,e,r))&&i.delete(m.name);break;case"variables":
131
+ s.variables=(0,u.getLinkedVariableList)(m,r);break;case"services":s.services=(0,u.getLinkedServiceList)(
132
+ m,e,r);break}if(!mr(s)){r.push(new j([...i],l));continue}let p=dr(o,s.tables);if(p.
133
+ length){r.push(...p);continue}if(t[o.name]){r.push(new u.DuplicateServiceError(o.
134
+ name,l));continue}t[o.name]=s}return{services:t,errors:r}},"getDatabaseServices"),
135
+ mr=n(e=>!!e.name&&!!e.tables&&!!e.extras,"isValidService"),cr=n((e,t,r,a)=>{let o=(0,u.getPropertyTuple)(
136
+ e)??[],s=[];for(let i of o){let l=le(i,t,r,a);l&&s.push(l)}return s},"getAllTabl\
137
+ es"),dr=n((e,t)=>{let r=ur(t),a=[];for(let{relations:o,schema:s,indexes:i}of t){
138
+ if(!o)continue;let l=s.properties;for(let p of o){let{sourceTable:m,sourceColumn:O,
139
+ targetColumn:ne,targetAlias:me}=p;l[ne]||a.push(new S(ne,e.file)),l[me]&&a.push(
140
+ new N(me,e.file));let se=r[m]?.schema.properties;se||a.push(new C(m,e.file)),se&&
141
+ !se[O]&&a.push(new S(O,e.file));let Xe=r[m]?.indexes??[];p.sourceIndex=_e(Xe,O),
142
+ p.targetIndex=_e(i,ne)}}return a},"validateRelations"),_e=n((e,t)=>e.find(({name:r})=>r===
143
+ t)?.type,"getIndexType"),ur=n(e=>e.reduce((t,r)=>({...t,[r.name]:r}),{}),"getTab\
144
+ leMap");var Ge=n(e=>L(e)?e.name:null,"getLinkedService");var Je=!1,br=n(()=>{Je||((0,Ke.registerTriggers)(),(0,Qe.registerTriggers)(),(0,We.createTrigger)(
145
+ "@ez4/database",{"metadata:getServices":pe,"metadata:getLinkedService":Ge}),Je=!0)},
146
146
  "registerTriggers");0&&(module.exports={IncompleteEngineError,IncompleteHandlerError,IncompleteScalabilityError,
147
147
  IncompleteServiceError,IncompleteStreamError,IncompleteTableError,IncorrectIndexesTypeError,
148
148
  IncorrectRelationsTypeError,IncorrectSchemaTypeError,IncorrectStreamTypeError,Index,
package/dist/library.d.ts CHANGED
@@ -11,8 +11,8 @@ export * from './errors/relations';
11
11
  export * from './errors/indexes';
12
12
  export * from './errors/stream';
13
13
  export * from './errors/handler';
14
- export * from './services/indexes';
15
14
  export * from './services/relations';
15
+ export * from './services/indexes';
16
16
  export * from './types/service';
17
17
  export * from './types/relations';
18
18
  export * from './types/indexes';
package/dist/library.mjs CHANGED
@@ -1,144 +1,144 @@
1
- var he=Object.defineProperty;var a=(e,r)=>he(e,"name",{value:r,configurable:!0});import{registerTriggers as mr}from"@ez4/common/library";import{registerTriggers as cr}from"@ez4/schema/library";
2
- import{createTrigger as dr}from"@ez4/project/library";import{DuplicateServiceError as Zt,InvalidServicePropertyError as Lt,isExternalDeclaration as er,
3
- getLinkedServiceList as tr,getLinkedVariableList as rr,getPropertyTuple as nr,getModelMembers as ar}from"@ez4/common/library";
4
- import{isModelProperty as or}from"@ez4/reflection";var F="@ez4/database",br=a(e=>e.type===F,"isDatabaseService");import{IncompleteTypeError as ve}from"@ez4/common/library";var T=class extends ve{static{a(this,"IncompleteServiceError")}constructor(r,t){
5
- super("Incomplete database service",r,t)}};import{IncorrectTypeError as Ee,InvalidTypeError as Pe,TypeError as I}from"@ez4/common/library";var y=class extends Pe{static{a(this,"InvalidRelationsTypeError")}constructor(r){
6
- super("Invalid table relations type",void 0,"Database.Relations",r)}},f=class extends Ee{constructor(t,o){
7
- super("Incorrect table relations type",t,"Database.Relations",o);this.schemaType=
8
- t}static{a(this,"IncorrectRelationsTypeError")}},x=class extends I{constructor(t,o){
9
- super(`Target ${t} must follow the pattern 'column@alias'.`,o);this.relationSource=
10
- t}static{a(this,"InvalidRelationTargetError")}},g=class extends I{constructor(t,o){
11
- super(`Relation table ${t} don't exists.`,o);this.relationTable=t}static{a(this,
12
- "InvalidRelationTableError")}},b=class extends I{constructor(t,o){super(`Relatio\
13
- n column ${t} don't exists.`,o);this.relationColumn=t}static{a(this,"InvalidRela\
14
- tionColumnError")}},M=class extends I{constructor(t,o){super(`Relation alias ${t}\
15
- can't override table columns.`,o);this.relationAlias=t}static{a(this,"InvalidRe\
16
- lationAliasError")}};import{InvalidServicePropertyError as we,getModelMembers as je,getPropertyNumber as Ce,
17
- getObjectMembers as Ue,getReferenceType as ze}from"@ez4/common/library";import{isModelProperty as Ne,
18
- isTypeObject as He,isTypeReference as Fe}from"@ez4/reflection";import{isAnyNumber as q}from"@ez4/utils";import{IncompleteTypeError as Oe}from"@ez4/common/library";var S=class extends Oe{static{a(this,"IncompleteScalabilityError")}constructor(r,t){
19
- super("Incomplete database scalability",r,t)}};import{hasHeritageType as c,isClassDeclaration as ke,isModelDeclaration as $}from"@ez4/common/library";
20
- import{isTypeCallback as Re,isTypeFunction as Ae}from"@ez4/reflection";var D=a(e=>ke(e)&&c(e,"Database.Service"),"isDatabaseService"),h=a(e=>$(e)&&c(e,
21
- "Database.Engine"),"isDatabaseEngine"),G=a(e=>$(e)&&c(e,"Database.Table"),"isDat\
22
- abaseTable"),Q=a(e=>Re(e)||Ae(e),"isStreamHandler"),B=a(e=>c(e,"Database.Relatio\
23
- ns"),"isTableRelations"),_=a(e=>c(e,"Database.Indexes"),"isTableIndexes"),J=a(e=>c(
24
- e,"Database.Schema"),"isTableSchema"),K=a(e=>c(e,"Database.Stream"),"isTableStre\
25
- am");var Y=a((e,r,t,o)=>{if(!Fe(e))return W(e,r,o);let n=ze(e,t);return n?W(n,r,o):null},
26
- "getDatabaseScalability"),qe=a(e=>q(e.minCapacity)&&q(e.maxCapacity),"isValidSca\
27
- lability"),W=a((e,r,t)=>h(e)?X(e,r,je(e),t):He(e)?X(e,r,Ue(e),t):null,"getTypeSc\
28
- alability"),X=a((e,r,t,o)=>{let n={},s=new Set(["minCapacity","maxCapacity"]);for(let i of t)
29
- if(!(!Ne(i)||i.inherited))switch(i.name){default:o.push(new we(r.name,i.name,e.file));
30
- break;case"minCapacity":case"maxCapacity":let p=Ce(i);q(p)&&(n[i.name]=p,s.delete(
31
- i.name));break}return qe(n)?n:(o.push(new S([...s],e.file)),null)},"getTypeFromM\
32
- embers");import{isModelProperty as $e,isTypeObject as Ge,isTypeReference as Qe}from"@ez4/reflection";
33
- import{InvalidServicePropertyError as Be,getModelMembers as _e,getObjectMembers as Je,
34
- getPropertyString as Ke,getPropertyStringIn as d,getReferenceType as We}from"@ez4/common/library";import{IncompleteTypeError as Ve}from"@ez4/common/library";var v=class extends Ve{static{a(this,"IncompleteEngineError")}constructor(r,t){super(
35
- "Incomplete database engine",r,t)}};var ee=a((e,r,t,o)=>{if(!Qe(e))return Z(e,r,o);let n=We(e,t);return n?Z(n,r,o):null},
36
- "getDatabaseEngine"),Xe=a(e=>!!e.name&&!!e.parametersMode&&!!e.transactionMode&&
37
- !!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,"isValidEngine"),Z=a((e,r,t)=>h(
38
- e)?L(e,r,_e(e),t):Ge(e)?L(e,r,Je(e),t):null,"getTypeEngine"),L=a((e,r,t,o)=>{let n={},
1
+ var he=Object.defineProperty;var a=(e,t)=>he(e,"name",{value:t,configurable:!0});import{registerTriggers as mt}from"@ez4/common/library";import{registerTriggers as ct}from"@ez4/schema/library";
2
+ import{createTrigger as dt}from"@ez4/project/library";import{DuplicateServiceError as Zr,InvalidServicePropertyError as Lr,isExternalDeclaration as et,
3
+ getLinkedServiceList as rt,getLinkedVariableList as tt,getPropertyTuple as ot,getModelMembers as at}from"@ez4/common/library";
4
+ import{isModelProperty as nt}from"@ez4/reflection";var U="@ez4/database",bt=a(e=>e.type===U,"isDatabaseService");import{IncompleteTypeError as De}from"@ez4/common/library";var f=class extends De{static{a(this,"IncompleteServiceError")}constructor(t,r){
5
+ super("Incomplete database service",t,r)}};import{IncorrectTypeError as ve,InvalidTypeError as Ee,TypeError as S}from"@ez4/common/library";var T=class extends Ee{static{a(this,"InvalidRelationsTypeError")}constructor(t){
6
+ super("Invalid table relations type",void 0,"Database.Relations",t)}},y=class extends ve{constructor(r,n){
7
+ super("Incorrect table relations type",r,"Database.Relations",n);this.schemaType=
8
+ r}static{a(this,"IncorrectRelationsTypeError")}},x=class extends S{constructor(r,n){
9
+ super(`Target ${r} must follow the pattern 'column@alias'.`,n);this.relationSource=
10
+ r}static{a(this,"InvalidRelationTargetError")}},g=class extends S{constructor(r,n){
11
+ super(`Relation table ${r} don't exists.`,n);this.relationTable=r}static{a(this,
12
+ "InvalidRelationTableError")}},b=class extends S{constructor(r,n){super(`Relatio\
13
+ n column ${r} don't exists.`,n);this.relationColumn=r}static{a(this,"InvalidRela\
14
+ tionColumnError")}},M=class extends S{constructor(r,n){super(`Relation alias ${r}\
15
+ can't override table columns.`,n);this.relationAlias=r}static{a(this,"InvalidRe\
16
+ lationAliasError")}};import{InvalidServicePropertyError as je,getModelMembers as Ae,getPropertyNumber as Re,
17
+ getObjectMembers as ze,getReferenceType as Ce}from"@ez4/common/library";import{isModelProperty as Ne,
18
+ isTypeObject as He,isTypeReference as Fe}from"@ez4/reflection";import{isAnyNumber as V}from"@ez4/utils";import{IncompleteTypeError as Pe}from"@ez4/common/library";var I=class extends Pe{static{a(this,"IncompleteScalabilityError")}constructor(t,r){
19
+ super("Incomplete database scalability",t,r)}};import{hasHeritageType as c,isClassDeclaration as ke,isModelDeclaration as q}from"@ez4/common/library";
20
+ import{isTypeCallback as we,isTypeFunction as Oe}from"@ez4/reflection";var h=a(e=>ke(e)&&c(e,"Database.Service"),"isDatabaseService"),D=a(e=>q(e)&&c(e,
21
+ "Database.Engine"),"isDatabaseEngine"),_=a(e=>q(e)&&c(e,"Database.Table"),"isDat\
22
+ abaseTable"),B=a(e=>we(e)||Oe(e),"isStreamHandler"),G=a(e=>c(e,"Database.Relatio\
23
+ ns"),"isTableRelations"),J=a(e=>c(e,"Database.Indexes"),"isTableIndexes"),K=a(e=>c(
24
+ e,"Database.Schema"),"isTableSchema"),Q=a(e=>c(e,"Database.Stream"),"isTableStre\
25
+ am");var Y=a((e,t,r,n)=>{if(!Fe(e))return W(e,t,n);let o=Ce(e,r);return o?W(o,t,n):null},
26
+ "getDatabaseScalability"),Ue=a(e=>V(e.minCapacity)&&V(e.maxCapacity),"isValidSca\
27
+ lability"),W=a((e,t,r)=>D(e)?X(e,t,Ae(e),r):He(e)?X(e,t,ze(e),r):null,"getTypeSc\
28
+ alability"),X=a((e,t,r,n)=>{let o={},s=new Set(["minCapacity","maxCapacity"]);for(let i of r)
29
+ if(!(!Ne(i)||i.inherited))switch(i.name){default:n.push(new je(t.name,i.name,e.file));
30
+ break;case"minCapacity":case"maxCapacity":let l=Re(i);V(l)&&(o[i.name]=l,s.delete(
31
+ i.name));break}return Ue(o)?o:(n.push(new I([...s],e.file)),null)},"getTypeFromM\
32
+ embers");import{isModelProperty as $e,isTypeObject as qe,isTypeReference as _e}from"@ez4/reflection";
33
+ import{InvalidServicePropertyError as Be,getModelMembers as Ge,getObjectMembers as Je,
34
+ getPropertyString as Ke,getPropertyStringIn as d,getReferenceType as Qe}from"@ez4/common/library";import{IncompleteTypeError as Ve}from"@ez4/common/library";var v=class extends Ve{static{a(this,"IncompleteEngineError")}constructor(t,r){super(
35
+ "Incomplete database engine",t,r)}};var ee=a((e,t,r,n)=>{if(!_e(e))return Z(e,t,n);let o=Qe(e,r);return o?Z(o,t,n):null},
36
+ "getDatabaseEngine"),We=a(e=>!!e.name&&!!e.parametersMode&&!!e.transactionMode&&
37
+ !!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,"isValidEngine"),Z=a((e,t,r)=>D(
38
+ e)?L(e,t,Ge(e),r):qe(e)?L(e,t,Je(e),r):null,"getTypeEngine"),L=a((e,t,r,n)=>{let o={},
39
39
  s=new Set(["name","parametersMode","transactionMode","insensitiveMode","paginati\
40
- onMode","orderMode"]);for(let i of t)if(!(!$e(i)||i.inherited))switch(i.name){default:
41
- o.push(new Be(r.name,i.name,e.file));break;case"name":(n.name=Ke(i))&&s.delete(i.
42
- name);break;case"parametersMode":(n.parametersMode=d(i,["index","both"]))&&s.delete(
43
- i.name);break;case"transactionMode":(n.transactionMode=d(i,["static","interactiv\
44
- e"]))&&s.delete(i.name);break;case"insensitiveMode":(n.insensitiveMode=d(i,["uns\
45
- upported","enabled"]))&&s.delete(i.name);break;case"paginationMode":(n.paginationMode=
46
- d(i,["cursor","offset"]))&&s.delete(i.name);break;case"orderMode":(n.orderMode=d(
47
- i,["any","index"]))&&s.delete(i.name);break;case"lockMode":(n.lockMode=d(i,["uns\
48
- upported","supported"]))&&s.delete(i.name);break}return Xe(n)?n:(o.push(new v([...s],
49
- e.file)),null)},"getTypeFromMembers");import{InvalidServicePropertyError as $t,getModelMembers as Gt,getObjectMembers as Qt,
50
- getPropertyString as Bt,getReferenceType as _t}from"@ez4/common/library";import{
51
- isModelProperty as Jt,isTypeObject as Kt,isTypeReference as Wt}from"@ez4/reflection";import{IncompleteTypeError as Ye}from"@ez4/common/library";var E=class extends Ye{static{a(this,"IncompleteTableError")}constructor(r,t){super(
52
- "Incomplete database table",r,t)}};import{IncorrectTypeError as Ze,InvalidTypeError as Le,TypeError as te}from"@ez4/common/library";var P=class extends Le{static{a(this,"InvalidIndexesTypeError")}constructor(r){super(
53
- "Invalid table indexes type",void 0,"Database.Indexes",r)}},O=class extends Ze{constructor(t,o){
54
- super("Incorrect table indexes type",t,"Database.Indexes",o);this.schemaType=t}static{
55
- a(this,"IncorrectIndexesTypeError")}},k=class extends te{constructor(t,o){super(
56
- `Invalid index type, ${t} must follow one of the Index options.`,o);this.indexName=
57
- t}static{a(this,"InvalidIndexTypeError")}},R=class extends te{constructor(t,o){super(
58
- `Invalid index reference, ${t} must be valid column.`,o);this.indexName=t}static{
59
- a(this,"InvalidIndexReferenceError")}};import{isModelDeclaration as et,getModelMembers as tt,getObjectMembers as rt,getPropertyString as nt,
60
- getReferenceType as at}from"@ez4/common/library";import{isModelProperty as ot,isTypeObject as st,
61
- isTypeReference as it}from"@ez4/reflection";var ae=a((e,r,t,o)=>{if(!it(e))return re(e,r,o);let n=at(e,t);return n?re(n,r,o):
62
- null},"getTableRelations"),re=a((e,r,t)=>st(e)?ne(e,rt(e),t):et(e)?B(e)?ne(e,tt(
63
- e),t):(t.push(new f(e.name,e.file)),null):(t.push(new y(r.file)),null),"getTypeR\
64
- elations"),ne=a((e,r,t)=>{let o=[];for(let n of r){if(!ot(n)||n.inherited)continue;
65
- let s=nt(n),i=n.name;if(!s)return t.push(new x(i,e.file)),null;let[p,l]=i.split(
66
- "@",2),[m,u]=s.split(":",2);o.push({sourceTable:m,sourceColumn:u,targetColumn:p,
67
- targetAlias:l})}return o},"getTypeFromMembers");import{isModelDeclaration as pt,getModelMembers as lt,getObjectMembers as mt,getPropertyString as ct,
68
- getReferenceType as dt}from"@ez4/common/library";import{isModelProperty as ut,isTypeObject as bt,
69
- isTypeReference as Tt}from"@ez4/reflection";var oe=(n=>(n.Primary="primary",n.Secondary="secondary",n.Unique="unique",n.TTL=
70
- "ttl",n))(oe||{});var pe=a((e,r,t,o)=>{if(!Tt(e))return se(e,r,o);let n=dt(e,t);return n?se(n,r,o):
71
- null},"getTableIndexes"),se=a((e,r,t)=>bt(e)?ie(e,mt(e),t):pt(e)?_(e)?ie(e,lt(e),
72
- t):(t.push(new O(e.name,e.file)),null):(t.push(new P(r.file)),null),"getTypeInde\
73
- xes"),ie=a((e,r,t)=>{let o=[];for(let n of r){if(!ut(n)||n.inherited)continue;let s=n.
74
- name,i=ct(n);switch(i){case"primary":case"secondary":case"unique":case"ttl":o.push(
75
- {name:s,columns:s.split(":"),type:i});break;default:return t.push(new k(s,e.file)),
76
- null}}return o},"getTypeFromMembers");import{createSchemaContext as xt,getObjectSchema as gt,isObjectSchema as Mt}from"@ez4/schema/library";
77
- import{getReferenceType as It,isModelDeclaration as St}from"@ez4/common/library";
78
- import{isTypeObject as Dt,isTypeReference as ht}from"@ez4/reflection";import{IncorrectTypeError as yt,InvalidTypeError as ft}from"@ez4/common/library";var A=class extends ft{static{a(this,"InvalidSchemaTypeError")}constructor(r){super(
79
- "Invalid table schema type",void 0,"Database.Schema",r)}},w=class extends yt{constructor(t,o){
80
- super("Incorrect table schema type",t,"Database.Schema",o);this.schemaType=t}static{
81
- a(this,"IncorrectSchemaTypeError")}};var ce=a((e,r,t,o)=>{if(!ht(e))return le(e,r,t,o);let n=It(e,t);return n?le(n,r,
82
- t,o):null},"getTableSchema"),le=a((e,r,t,o)=>Dt(e)?me(e,t):St(e)?J(e)?me(e,t):(o.
83
- push(new w(e.name,e.file)),null):(o.push(new A(r.file)),null),"getTypeSchema"),me=a(
84
- (e,r)=>{let t=gt(e,r,xt({nullish:!0}));return t&&Mt(t)?t:null},"getSchema");import{InvalidServicePropertyError as Rt,isModelDeclaration as At,getLinkedVariableList as wt,
85
- getModelMembers as jt,getObjectMembers as Ct,getPropertyNumber as Ut,getServiceListener as zt,
86
- getReferenceType as Nt}from"@ez4/common/library";import{isModelProperty as Ht,isTypeObject as Ft,
87
- isTypeReference as qt}from"@ez4/reflection";import{IncompleteTypeError as vt,IncorrectTypeError as Et,InvalidTypeError as Pt}from"@ez4/common/library";var j=class extends vt{static{a(this,"IncompleteStreamError")}constructor(r,t){super(
88
- "Incomplete table stream",r,t)}},C=class extends Pt{static{a(this,"InvalidStream\
89
- TypeError")}constructor(r){super("Invalid table stream type",void 0,"Database.St\
90
- ream",r)}},U=class extends Et{constructor(t,o){super("Incorrect table stream typ\
91
- e",t,"Database.Stream",o);this.streamType=t}static{a(this,"IncorrectStreamTypeEr\
92
- ror")}};import{IncompleteTypeError as Ot}from"@ez4/common/library";var z=class extends Ot{static{a(this,"IncompleteHandlerError")}constructor(r,t){
93
- super("Incomplete stream handler",r,t)}};var de=a((e,r,t)=>{if(!Q(e))return null;let{description:o,module:n}=e,s={...o&&{
94
- description:o},...n&&{module:n}},i=new Set(["name","file","change"]);return(s.name=
40
+ onMode","orderMode"]);for(let i of r)if(!(!$e(i)||i.inherited))switch(i.name){default:
41
+ n.push(new Be(t.name,i.name,e.file));break;case"name":(o.name=Ke(i))&&s.delete(i.
42
+ name);break;case"parametersMode":(o.parametersMode=d(i,["index","both"]))&&s.delete(
43
+ i.name);break;case"transactionMode":(o.transactionMode=d(i,["static","interactiv\
44
+ e"]))&&s.delete(i.name);break;case"insensitiveMode":(o.insensitiveMode=d(i,["uns\
45
+ upported","enabled"]))&&s.delete(i.name);break;case"paginationMode":(o.paginationMode=
46
+ d(i,["cursor","offset"]))&&s.delete(i.name);break;case"orderMode":(o.orderMode=d(
47
+ i,["any","index"]))&&s.delete(i.name);break;case"lockMode":(o.lockMode=d(i,["uns\
48
+ upported","supported"]))&&s.delete(i.name);break}return We(o)?o:(n.push(new v([...s],
49
+ e.file)),null)},"getTypeFromMembers");import{InvalidServicePropertyError as qr,getModelMembers as _r,getObjectMembers as Br,
50
+ getPropertyString as Gr,getReferenceType as Jr}from"@ez4/common/library";import{
51
+ isModelProperty as Kr,isTypeObject as Qr,isTypeReference as Wr}from"@ez4/reflection";import{IncompleteTypeError as Xe}from"@ez4/common/library";var E=class extends Xe{static{a(this,"IncompleteTableError")}constructor(t,r){super(
52
+ "Incomplete database table",t,r)}};import{IncorrectTypeError as Ye,InvalidTypeError as Ze,TypeError as re}from"@ez4/common/library";var P=class extends Ze{static{a(this,"InvalidIndexesTypeError")}constructor(t){super(
53
+ "Invalid table indexes type",void 0,"Database.Indexes",t)}},k=class extends Ye{constructor(r,n){
54
+ super("Incorrect table indexes type",r,"Database.Indexes",n);this.schemaType=r}static{
55
+ a(this,"IncorrectIndexesTypeError")}},w=class extends re{constructor(r,n){super(
56
+ `Invalid index type, ${r} must follow one of the Index options.`,n);this.indexName=
57
+ r}static{a(this,"InvalidIndexTypeError")}},O=class extends re{constructor(r,n){super(
58
+ `Invalid index reference, ${r} must be valid column.`,n);this.indexName=r}static{
59
+ a(this,"InvalidIndexReferenceError")}};import{isModelDeclaration as Le,getModelMembers as er,getObjectMembers as rr,getPropertyString as tr,
60
+ getReferenceType as or}from"@ez4/common/library";import{isModelProperty as ar,isTypeObject as nr,
61
+ isTypeReference as sr}from"@ez4/reflection";var ae=a((e,t,r,n)=>{if(!sr(e))return te(e,t,n);let o=or(e,r);return o?te(o,t,n):
62
+ null},"getTableRelations"),te=a((e,t,r)=>nr(e)?oe(e,rr(e),r):Le(e)?G(e)?oe(e,er(
63
+ e),r):(r.push(new y(e.name,e.file)),null):(r.push(new T(t.file)),null),"getTypeR\
64
+ elations"),oe=a((e,t,r)=>{let n=[];for(let o of t){if(!ar(o)||o.inherited)continue;
65
+ let s=tr(o),i=o.name;if(!s)return r.push(new x(i,e.file)),null;let[l,p]=i.split(
66
+ "@",2),[m,u]=s.split(":",2);n.push({sourceTable:m,sourceColumn:u,targetColumn:l,
67
+ targetAlias:p})}return n},"getTypeFromMembers");import{isModelDeclaration as lr,getModelMembers as pr,getObjectMembers as mr,getPropertyString as cr,
68
+ getReferenceType as dr}from"@ez4/common/library";import{isModelProperty as ur,isTypeObject as br,
69
+ isTypeReference as fr}from"@ez4/reflection";var ir=(o=>(o.Primary="primary",o.Secondary="secondary",o.Unique="unique",o.TTL=
70
+ "ttl",o))(ir||{});var ie=a((e,t,r,n)=>{if(!fr(e))return ne(e,t,n);let o=dr(e,r);return o?ne(o,t,n):
71
+ null},"getTableIndexes"),ne=a((e,t,r)=>br(e)?se(e,mr(e),r):lr(e)?J(e)?se(e,pr(e),
72
+ r):(r.push(new k(e.name,e.file)),null):(r.push(new P(t.file)),null),"getTypeInde\
73
+ xes"),se=a((e,t,r)=>{let n=[];for(let o of t){if(!ur(o)||o.inherited)continue;let s=o.
74
+ name,i=cr(o);switch(i){case"primary":case"secondary":case"unique":case"ttl":n.push(
75
+ {name:s,columns:s.split(":"),type:i});break;default:return r.push(new w(s,e.file)),
76
+ null}}return n},"getTypeFromMembers");import{createSchemaContext as xr,getObjectSchema as gr,isObjectSchema as Mr}from"@ez4/schema/library";
77
+ import{getReferenceType as Sr,isModelDeclaration as Ir}from"@ez4/common/library";
78
+ import{isTypeObject as hr,isTypeReference as Dr}from"@ez4/reflection";import{IncorrectTypeError as Tr,InvalidTypeError as yr}from"@ez4/common/library";var j=class extends yr{static{a(this,"InvalidSchemaTypeError")}constructor(t){super(
79
+ "Invalid table schema type",void 0,"Database.Schema",t)}},A=class extends Tr{constructor(r,n){
80
+ super("Incorrect table schema type",r,"Database.Schema",n);this.schemaType=r}static{
81
+ a(this,"IncorrectSchemaTypeError")}};var me=a((e,t,r,n)=>{if(!Dr(e))return le(e,t,r,n);let o=Sr(e,r);return o?le(o,t,
82
+ r,n):null},"getTableSchema"),le=a((e,t,r,n)=>hr(e)?pe(e,r):Ir(e)?K(e)?pe(e,r):(n.
83
+ push(new A(e.name,e.file)),null):(n.push(new j(t.file)),null),"getTypeSchema"),pe=a(
84
+ (e,t)=>{let r=gr(e,t,xr({nullish:!0}));return r&&Mr(r)?r:null},"getSchema");import{InvalidServicePropertyError as Or,isModelDeclaration as jr,getLinkedVariableList as Ar,
85
+ getModelMembers as Rr,getObjectMembers as zr,getPropertyNumber as Cr,getServiceListener as Nr,
86
+ getReferenceType as Hr}from"@ez4/common/library";import{isModelProperty as Fr,isTypeObject as Ur,
87
+ isTypeReference as Vr}from"@ez4/reflection";import{IncompleteTypeError as vr,IncorrectTypeError as Er,InvalidTypeError as Pr}from"@ez4/common/library";var R=class extends vr{static{a(this,"IncompleteStreamError")}constructor(t,r){super(
88
+ "Incomplete table stream",t,r)}},z=class extends Pr{static{a(this,"InvalidStream\
89
+ TypeError")}constructor(t){super("Invalid table stream type",void 0,"Database.St\
90
+ ream",t)}},C=class extends Er{constructor(r,n){super("Incorrect table stream typ\
91
+ e",r,"Database.Stream",n);this.streamType=r}static{a(this,"IncorrectStreamTypeEr\
92
+ ror")}};import{IncompleteTypeError as kr}from"@ez4/common/library";var N=class extends kr{static{a(this,"IncompleteHandlerError")}constructor(t,r){
93
+ super("Incomplete stream handler",t,r)}};var ce=a((e,t,r)=>{if(!B(e))return null;let{description:n,module:o}=e,s={...n&&{
94
+ description:n},...o&&{module:o}},i=new Set(["name","file","change"]);return(s.name=
95
95
  e.name)&&i.delete("name"),(s.file=e.file)&&i.delete("file"),e.parameters&&i.delete(
96
- "change"),i.size===0&&kt(s)?s:(t.push(new z([...i],e.file)),null)},"getStreamHan\
97
- dler"),kt=a(e=>!!e.name&&!!e.file,"isValidHandler");var Te=a((e,r,t,o)=>{if(!qt(e))return ue(e,r,t,o);let n=Nt(e,t);return n?ue(n,r,
98
- t,o):null},"getTableStream"),Vt=a(e=>!!e.handler,"isValidStream"),ue=a((e,r,t,o)=>Ft(
99
- e)?be(e,r,Ct(e),t,o):At(e)?K(e)?be(e,r,jt(e),t,o):(o.push(new U(e.name,e.file)),
100
- null):(o.push(new C(r.file)),null),"getTypeStream"),be=a((e,r,t,o,n)=>{let s={},
101
- i=new Set(["handler"]);for(let p of t)if(!(!Ht(p)||p.inherited))switch(p.name){default:
102
- n.push(new Rt(r.name,p.name,e.file));break;case"handler":s.handler=de(p.value,o,
103
- n);break;case"listener":s.listener=zt(p.value,n);break;case"memory":case"logRete\
104
- ntion":case"timeout":s[p.name]=Ut(p);break;case"variables":s.variables=wt(p,n);break}
105
- return Vt(s)?s:(n.push(new j([...i],e.file)),null)},"getTypeFromMembers");var xe=a((e,r,t,o)=>{if(!Wt(e))return ye(e,r,t,o);let n=_t(e,t);return n?ye(n,r,
106
- t,o):null},"getDatabaseTable"),Xt=a(e=>!!e.name&&!!e.schema&&!!e.indexes,"isVali\
107
- dTable"),ye=a((e,r,t,o)=>G(e)?fe(e,r,Gt(e),t,o):Kt(e)?fe(e,r,Qt(e),t,o):null,"ge\
108
- tTypeTable"),fe=a((e,r,t,o,n)=>{let s={},i=new Set(["name","schema","indexes"]);
109
- for(let l of t)if(!(!Jt(l)||l.inherited))switch(l.name){default:n.push(new $t(r.
110
- name,l.name,e.file));break;case"name":(s.name=Bt(l))&&i.delete(l.name);break;case"\
111
- schema":(s.schema=ce(l.value,e,o,n))&&i.delete(l.name);break;case"indexes":(s.indexes=
112
- pe(l.value,e,o,n))&&i.delete(l.name);break;case"relations":s.relations=ae(l.value,
113
- e,o,n);break;case"stream":s.stream=Te(l.value,r,o,n);break}if(!Xt(s))return n.push(
114
- new E([...i],e.file)),null;let p=Yt(e,s.indexes,s.schema);return p.length?(n.push(
115
- ...p),null):s},"getTypeFromMembers"),Yt=a((e,r,t)=>{let o=t.properties,n=[];for(let{
116
- name:s,columns:i}of r)i.some(l=>!o[l])&&n.push(new R(s,e.file));return n},"valid\
117
- ateIndexes");var Me=a(e=>{let r={},t=[];for(let o in e){let n=e[o];if(!D(n)||er(n))continue;let s={
118
- type:F,extras:{}},i=new Set(["engine","tables"]),p=n.file;s.name=n.name;for(let m of ar(
119
- n))if(!(!or(m)||m.inherited))switch(m.name){default:t.push(new Lt(s.name,m.name,
120
- p));break;case"client":break;case"scalability":(s.scalability=Y(m.value,n,e,t))&&
121
- i.delete(m.name);break;case"engine":(s.engine=ee(m.value,n,e,t))&&i.delete(m.name);
122
- break;case"tables":(s.tables=ir(m,n,e,t))&&i.delete(m.name);break;case"variables":
123
- s.variables=rr(m,t);break;case"services":s.services=tr(m,e,t);break}if(!sr(s)){t.
124
- push(new T([...i],p));continue}let l=pr(n,s.tables);if(l.length){t.push(...l);continue}
125
- if(r[n.name]){t.push(new Zt(n.name,p));continue}r[n.name]=s}return{services:r,errors:t}},
126
- "getDatabaseServices"),sr=a(e=>!!e.name&&!!e.tables&&!!e.extras,"isValidService"),
127
- ir=a((e,r,t,o)=>{let n=nr(e)??[],s=[];for(let i of n){let p=xe(i,r,t,o);p&&s.push(
128
- p)}return s},"getAllTables"),pr=a((e,r)=>{let t=lr(r),o=[];for(let{relations:n,schema:s,
129
- indexes:i}of r){if(!n)continue;let p=s.properties;for(let l of n){let{sourceTable:m,
130
- sourceColumn:u,targetColumn:N,targetAlias:V}=l;p[N]||o.push(new b(N,e.file)),p[V]&&
131
- o.push(new M(V,e.file));let H=t[m]?.schema.properties;H||o.push(new g(m,e.file)),
132
- H&&!H[u]&&o.push(new b(u,e.file));let De=t[m]?.indexes??[];l.sourceIndex=ge(De,u),
133
- l.targetIndex=ge(i,N)}}return o},"validateRelations"),ge=a((e,r)=>e.find(({name:t})=>t===
134
- r)?.type,"getIndexType"),lr=a(e=>e.reduce((r,t)=>({...r,[t.name]:t}),{}),"getTab\
135
- leMap");var Ie=a(e=>D(e)?e.name:null,"getLinkedService");var Se=!1,Ca=a(()=>{Se||(mr(),cr(),dr("@ez4/database",{"metadata:getServices":Me,
136
- "metadata:getLinkedService":Ie}),Se=!0)},"registerTriggers");export{v as IncompleteEngineError,z as IncompleteHandlerError,S as IncompleteScalabilityError,
137
- T as IncompleteServiceError,j as IncompleteStreamError,E as IncompleteTableError,
138
- O as IncorrectIndexesTypeError,f as IncorrectRelationsTypeError,w as IncorrectSchemaTypeError,
139
- U as IncorrectStreamTypeError,oe as Index,R as InvalidIndexReferenceError,k as InvalidIndexTypeError,
96
+ "change"),i.size===0&&wr(s)?s:(r.push(new N([...i],e.file)),null)},"getStreamHan\
97
+ dler"),wr=a(e=>!!e.name&&!!e.file,"isValidHandler");var be=a((e,t,r,n)=>{if(!Vr(e))return de(e,t,r,n);let o=Hr(e,r);return o?de(o,t,
98
+ r,n):null},"getTableStream"),$r=a(e=>!!e.handler,"isValidStream"),de=a((e,t,r,n)=>Ur(
99
+ e)?ue(e,t,zr(e),r,n):jr(e)?Q(e)?ue(e,t,Rr(e),r,n):(n.push(new C(e.name,e.file)),
100
+ null):(n.push(new z(t.file)),null),"getTypeStream"),ue=a((e,t,r,n,o)=>{let s={},
101
+ i=new Set(["handler"]);for(let l of r)if(!(!Fr(l)||l.inherited))switch(l.name){default:
102
+ o.push(new Or(t.name,l.name,e.file));break;case"handler":s.handler=ce(l.value,n,
103
+ o);break;case"listener":s.listener=Nr(l.value,o);break;case"memory":case"logRete\
104
+ ntion":case"timeout":s[l.name]=Cr(l);break;case"variables":s.variables=Ar(l,o);break}
105
+ return $r(s)?s:(o.push(new R([...i],e.file)),null)},"getTypeFromMembers");var ye=a((e,t,r,n)=>{if(!Wr(e))return fe(e,t,r,n);let o=Jr(e,r);return o?fe(o,t,
106
+ r,n):null},"getDatabaseTable"),Xr=a(e=>!!e.name&&!!e.schema&&!!e.indexes,"isVali\
107
+ dTable"),fe=a((e,t,r,n)=>_(e)?Te(e,t,_r(e),r,n):Qr(e)?Te(e,t,Br(e),r,n):null,"ge\
108
+ tTypeTable"),Te=a((e,t,r,n,o)=>{let s={},i=new Set(["name","schema","indexes"]);
109
+ for(let p of r)if(!(!Kr(p)||p.inherited))switch(p.name){default:o.push(new qr(t.
110
+ name,p.name,e.file));break;case"name":(s.name=Gr(p))&&i.delete(p.name);break;case"\
111
+ schema":(s.schema=me(p.value,e,n,o))&&i.delete(p.name);break;case"indexes":(s.indexes=
112
+ ie(p.value,e,n,o))&&i.delete(p.name);break;case"relations":s.relations=ae(p.value,
113
+ e,n,o);break;case"stream":s.stream=be(p.value,t,n,o);break}if(!Xr(s))return o.push(
114
+ new E([...i],e.file)),null;let l=Yr(e,s.indexes,s.schema);return l.length?(o.push(
115
+ ...l),null):s},"getTypeFromMembers"),Yr=a((e,t,r)=>{let n=r.properties,o=[];for(let{
116
+ name:s,columns:i}of t)i.some(p=>!n[p])&&o.push(new O(s,e.file));return o},"valid\
117
+ ateIndexes");var ge=a(e=>{let t={},r=[];for(let n in e){let o=e[n];if(!h(o)||et(o))continue;let s={
118
+ type:U,extras:{}},i=new Set(["engine","tables"]),l=o.file;s.name=o.name;for(let m of at(
119
+ o))if(!(!nt(m)||m.inherited))switch(m.name){default:r.push(new Lr(s.name,m.name,
120
+ l));break;case"client":break;case"scalability":(s.scalability=Y(m.value,o,e,r))&&
121
+ i.delete(m.name);break;case"engine":(s.engine=ee(m.value,o,e,r))&&i.delete(m.name);
122
+ break;case"tables":(s.tables=it(m,o,e,r))&&i.delete(m.name);break;case"variables":
123
+ s.variables=tt(m,r);break;case"services":s.services=rt(m,e,r);break}if(!st(s)){r.
124
+ push(new f([...i],l));continue}let p=lt(o,s.tables);if(p.length){r.push(...p);continue}
125
+ if(t[o.name]){r.push(new Zr(o.name,l));continue}t[o.name]=s}return{services:t,errors:r}},
126
+ "getDatabaseServices"),st=a(e=>!!e.name&&!!e.tables&&!!e.extras,"isValidService"),
127
+ it=a((e,t,r,n)=>{let o=ot(e)??[],s=[];for(let i of o){let l=ye(i,t,r,n);l&&s.push(
128
+ l)}return s},"getAllTables"),lt=a((e,t)=>{let r=pt(t),n=[];for(let{relations:o,schema:s,
129
+ indexes:i}of t){if(!o)continue;let l=s.properties;for(let p of o){let{sourceTable:m,
130
+ sourceColumn:u,targetColumn:H,targetAlias:$}=p;l[H]||n.push(new b(H,e.file)),l[$]&&
131
+ n.push(new M($,e.file));let F=r[m]?.schema.properties;F||n.push(new g(m,e.file)),
132
+ F&&!F[u]&&n.push(new b(u,e.file));let Ie=r[m]?.indexes??[];p.sourceIndex=xe(Ie,u),
133
+ p.targetIndex=xe(i,H)}}return n},"validateRelations"),xe=a((e,t)=>e.find(({name:r})=>r===
134
+ t)?.type,"getIndexType"),pt=a(e=>e.reduce((t,r)=>({...t,[r.name]:r}),{}),"getTab\
135
+ leMap");var Me=a(e=>h(e)?e.name:null,"getLinkedService");var Se=!1,fa=a(()=>{Se||(mt(),ct(),dt("@ez4/database",{"metadata:getServices":ge,
136
+ "metadata:getLinkedService":Me}),Se=!0)},"registerTriggers");export{v as IncompleteEngineError,N as IncompleteHandlerError,I as IncompleteScalabilityError,
137
+ f as IncompleteServiceError,R as IncompleteStreamError,E as IncompleteTableError,
138
+ k as IncorrectIndexesTypeError,y as IncorrectRelationsTypeError,A as IncorrectSchemaTypeError,
139
+ C as IncorrectStreamTypeError,ir as Index,O as InvalidIndexReferenceError,w as InvalidIndexTypeError,
140
140
  P as InvalidIndexesTypeError,M as InvalidRelationAliasError,b as InvalidRelationColumnError,
141
- g as InvalidRelationTableError,x as InvalidRelationTargetError,y as InvalidRelationsTypeError,
142
- A as InvalidSchemaTypeError,C as InvalidStreamTypeError,F as ServiceType,Me as getDatabaseServices,
143
- xe as getDatabaseTable,ce as getTableSchema,br as isDatabaseService,Ca as registerTriggers};
141
+ g as InvalidRelationTableError,x as InvalidRelationTargetError,T as InvalidRelationsTypeError,
142
+ j as InvalidSchemaTypeError,z as InvalidStreamTypeError,U as ServiceType,ge as getDatabaseServices,
143
+ ye as getDatabaseTable,me as getTableSchema,bt as isDatabaseService,fa as registerTriggers};
144
144
  //# sourceMappingURL=library.mjs.map
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.29.0",
4
+ "version": "0.30.0",
5
5
  "author": "Silas B.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -28,6 +28,10 @@
28
28
  "import": "./dist/library.mjs"
29
29
  }
30
30
  },
31
+ "sideEffects": [
32
+ "./dist/library.cjs",
33
+ "./dist/library.mjs"
34
+ ],
31
35
  "workspaces": [
32
36
  "foundation/*",
33
37
  "contracts/*"
@@ -42,10 +46,10 @@
42
46
  "live:publish": "npm run build && npm publish --access public"
43
47
  },
44
48
  "dependencies": {
45
- "@ez4/common": "^0.29.0",
46
- "@ez4/project": "^0.29.0",
47
- "@ez4/reflection": "^0.29.0",
48
- "@ez4/schema": "^0.29.0",
49
- "@ez4/utils": "^0.29.0"
49
+ "@ez4/common": "^0.30.0",
50
+ "@ez4/project": "^0.30.0",
51
+ "@ez4/reflection": "^0.30.0",
52
+ "@ez4/schema": "^0.30.0",
53
+ "@ez4/utils": "^0.30.0"
50
54
  }
51
55
  }