@ez4/database 0.35.0 → 0.37.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/README.md +119 -2
- package/dist/library.cjs +143 -143
- package/dist/library.mjs +136 -136
- package/dist/main.cjs +3 -3
- package/dist/metadata/engine.d.ts +2 -2
- package/dist/metadata/handler.d.ts +2 -3
- package/dist/metadata/indexes.d.ts +2 -2
- package/dist/metadata/relations.d.ts +2 -2
- package/dist/metadata/scalability.d.ts +2 -2
- package/dist/metadata/schema.d.ts +2 -2
- package/dist/metadata/service.d.ts +2 -2
- package/dist/metadata/stream.d.ts +2 -2
- package/dist/metadata/table.d.ts +2 -2
- package/dist/services/contract.d.ts +4 -0
- package/dist/services/query.d.ts +66 -0
- package/dist/services/streams.d.ts +3 -3
- package/dist/types/handler.d.ts +2 -6
- package/dist/types/service.d.ts +11 -1
- package/package.json +6 -6
- package/dist/services/database.d.ts +0 -142
package/dist/library.mjs
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
var
|
|
2
|
-
import{tryCreateTrigger as
|
|
3
|
-
getLinkedServiceList as
|
|
4
|
-
import{isModelProperty as
|
|
5
|
-
|
|
6
|
-
super("
|
|
1
|
+
var he=Object.defineProperty;var o=(e,t)=>he(e,"name",{value:t,configurable:!0});import{registerTriggers as dt}from"@ez4/common/library";import{registerTriggers as ft}from"@ez4/schema/library";
|
|
2
|
+
import{tryCreateTrigger as bt}from"@ez4/project/library";import{DuplicateServiceError as Lr,InvalidServicePropertyError as et,isExternalDeclaration as rt,
|
|
3
|
+
getLinkedServiceList as tt,getLinkedVariableList as nt,getPropertyTuple as ot,getModelMembers as at}from"@ez4/common/library";
|
|
4
|
+
import{isModelProperty as st}from"@ez4/reflection";import{isObjectWith as it}from"@ez4/utils";import{createServiceMetadata as ve}from"@ez4/project/library";var V="@ez4/database",yt=o(e=>e.type===V,"isDatabaseService"),H=o(e=>({...ve(V,e),
|
|
5
|
+
variables:{},services:{}}),"createDatabaseService");import{IncompleteTypeError as De}from"@ez4/common/library";var T=class extends De{static{o(this,"IncompleteServiceError")}constructor(t,r){
|
|
6
|
+
super("Incomplete database service",t,r)}};import{IncorrectTypeError as Ee,InvalidTypeError as Re,TypeError as I}from"@ez4/common/library";var u=class extends Re{static{o(this,"InvalidRelationsTypeError")}constructor(t){
|
|
7
|
+
super("Invalid table relations type",void 0,"Database.Relations",t)}},y=class extends Ee{constructor(r,a){
|
|
7
8
|
super("Incorrect table relations type",r,"Database.Relations",a);this.schemaType=
|
|
8
|
-
r}static{
|
|
9
|
+
r}static{o(this,"IncorrectRelationsTypeError")}},x=class extends I{constructor(r,a){
|
|
9
10
|
super(`Target ${r} must follow the pattern 'column@alias'.`,a);this.relationSource=
|
|
10
|
-
r}static{
|
|
11
|
-
super(`Relation table ${r} don't exists.`,a);this.relationTable=r}static{
|
|
12
|
-
"InvalidRelationTableError")}},b=class extends
|
|
13
|
-
n column ${r} don't exists.`,a);this.relationColumn=r}static{
|
|
14
|
-
tionColumnError")}},M=class extends
|
|
15
|
-
can't override table columns.`,a);this.relationAlias=r}static{
|
|
16
|
-
lationAliasError")}};import{InvalidServicePropertyError as
|
|
17
|
-
getObjectMembers as
|
|
18
|
-
isTypeObject as
|
|
19
|
-
super("Incomplete database scalability",t,r)}};import{hasHeritageType as
|
|
20
|
-
import{isTypeCallback as
|
|
21
|
-
"Database.Engine"),"isDatabaseEngine"),_=
|
|
22
|
-
abaseTable"),B=
|
|
23
|
-
ns"),"isTableRelations"),J=
|
|
24
|
-
e,"Database.Schema"),"isTableSchema"),Q=
|
|
25
|
-
am");var
|
|
26
|
-
"getDatabaseScalability")
|
|
27
|
-
lability"),
|
|
28
|
-
e),r)},"getTypeScalability"),
|
|
29
|
-
maxCapacity"]);for(let i of r)if(!(!
|
|
30
|
-
push(new
|
|
31
|
-
i);
|
|
32
|
-
return}return
|
|
33
|
-
import{InvalidServicePropertyError as
|
|
34
|
-
getPropertyString as
|
|
35
|
-
"Incomplete database engine",t,r)}};var
|
|
36
|
-
"getDatabaseEngine"),
|
|
37
|
-
!!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,"isValidEngine"),
|
|
38
|
-
if(
|
|
39
|
-
(e,t,r,a)=>{let
|
|
40
|
-
|
|
41
|
-
switch(i.name){default:a.push(new
|
|
42
|
-
name=
|
|
43
|
-
"index","both"]))&&s.delete(i.name);break;case"transactionMode":(
|
|
44
|
-
d(i,["static","interactive"]))&&s.delete(i.name);break;case"insensitiveMode":(
|
|
11
|
+
r}static{o(this,"InvalidRelationTargetError")}},g=class extends I{constructor(r,a){
|
|
12
|
+
super(`Relation table ${r} don't exists.`,a);this.relationTable=r}static{o(this,
|
|
13
|
+
"InvalidRelationTableError")}},b=class extends I{constructor(r,a){super(`Relatio\
|
|
14
|
+
n column ${r} don't exists.`,a);this.relationColumn=r}static{o(this,"InvalidRela\
|
|
15
|
+
tionColumnError")}},M=class extends I{constructor(r,a){super(`Relation alias ${r}\
|
|
16
|
+
can't override table columns.`,a);this.relationAlias=r}static{o(this,"InvalidRe\
|
|
17
|
+
lationAliasError")}};import{InvalidServicePropertyError as je,getModelMembers as Ae,getPropertyNumber as ze,
|
|
18
|
+
getObjectMembers as Ce,getReferenceType as Ne}from"@ez4/common/library";import{isModelProperty as Fe,
|
|
19
|
+
isTypeObject as qe,isTypeReference as Ue}from"@ez4/reflection";import{isAnyNumber as U}from"@ez4/utils";import{IncompleteTypeError as Pe}from"@ez4/common/library";var S=class extends Pe{static{o(this,"IncompleteScalabilityError")}constructor(t,r){
|
|
20
|
+
super("Incomplete database scalability",t,r)}};import{hasHeritageType as m,isClassDeclaration as ke,isModelDeclaration as W}from"@ez4/common/library";
|
|
21
|
+
import{isTypeCallback as Oe,isTypeFunction as we}from"@ez4/reflection";var h=o(e=>ke(e)&&m(e,"Database.Service"),"isDatabaseService"),v=o(e=>W(e)&&m(e,
|
|
22
|
+
"Database.Engine"),"isDatabaseEngine"),_=o(e=>W(e)&&m(e,"Database.Table"),"isDat\
|
|
23
|
+
abaseTable"),B=o(e=>Oe(e)||we(e),"isStreamHandler"),G=o(e=>m(e,"Database.Relatio\
|
|
24
|
+
ns"),"isTableRelations"),J=o(e=>m(e,"Database.Indexes"),"isTableIndexes"),K=o(e=>m(
|
|
25
|
+
e,"Database.Schema"),"isTableSchema"),Q=o(e=>m(e,"Database.Stream"),"isTableStre\
|
|
26
|
+
am");var Z=o((e,t,r,a)=>{if(!Ue(e))return X(e,t,a);let n=Ne(e,r);if(n)return X(n,t,a)},
|
|
27
|
+
"getDatabaseScalability"),$e=o(e=>U(e.minCapacity)&&U(e.maxCapacity),"isValidSca\
|
|
28
|
+
lability"),X=o((e,t,r)=>{if(v(e))return Y(e,t,Ae(e),r);if(qe(e))return Y(e,t,Ce(
|
|
29
|
+
e),r)},"getTypeScalability"),Y=o((e,t,r,a)=>{let n={},s=new Set(["minCapacity","\
|
|
30
|
+
maxCapacity"]);for(let i of r)if(!(!Fe(i)||i.inherited))switch(i.name){default:a.
|
|
31
|
+
push(new je(t.name,i.name,e.file));break;case"minCapacity":case"maxCapacity":let p=ze(
|
|
32
|
+
i);U(p)&&(n[i.name]=p,s.delete(i.name));break}if(!$e(n)){a.push(new S([...s],e.file));
|
|
33
|
+
return}return n},"getTypeFromMembers");import{isModelProperty as He,isTypeObject as We,isTypeReference as _e}from"@ez4/reflection";
|
|
34
|
+
import{InvalidServicePropertyError as Be,getModelMembers as Ge,getObjectMembers as Je,
|
|
35
|
+
getPropertyString as Ke,getPropertyStringIn as d,getReferenceType as Qe}from"@ez4/common/library";import{IncompleteTypeError as Ve}from"@ez4/common/library";var D=class extends Ve{static{o(this,"IncompleteEngineError")}constructor(t,r){super(
|
|
36
|
+
"Incomplete database engine",t,r)}};var re=o((e,t,r,a)=>{if(!_e(e))return L(e,t,a);let n=Qe(e,r);if(n)return L(n,t,a)},
|
|
37
|
+
"getDatabaseEngine"),Xe=o(e=>!!e.name&&!!e.parametersMode&&!!e.transactionMode&&
|
|
38
|
+
!!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,"isValidEngine"),L=o((e,t,r)=>{
|
|
39
|
+
if(v(e))return ee(e,t,Ge(e),r);if(We(e))return ee(e,t,Je(e),r)},"getTypeEngine"),
|
|
40
|
+
ee=o((e,t,r,a)=>{let n={},s=new Set(["name","parametersMode","transactionMode","\
|
|
41
|
+
insensitiveMode","paginationMode","orderMode"]);for(let i of r)if(!(!He(i)||i.inherited))
|
|
42
|
+
switch(i.name){default:a.push(new Be(t.name,i.name,e.file));break;case"name":(n.
|
|
43
|
+
name=Ke(i))&&s.delete(i.name);break;case"parametersMode":(n.parametersMode=d(i,[
|
|
44
|
+
"index","both"]))&&s.delete(i.name);break;case"transactionMode":(n.transactionMode=
|
|
45
|
+
d(i,["static","interactive"]))&&s.delete(i.name);break;case"insensitiveMode":(n.
|
|
45
46
|
insensitiveMode=d(i,["unsupported","enabled"]))&&s.delete(i.name);break;case"pag\
|
|
46
|
-
inationMode":(
|
|
47
|
-
orderMode":(
|
|
48
|
-
ode":(
|
|
49
|
-
|
|
50
|
-
getPropertyString as
|
|
51
|
-
isModelProperty as
|
|
52
|
-
"Incomplete database table",t,r)}};import{IncorrectTypeError as
|
|
53
|
-
"Invalid table indexes type",void 0,"Database.Indexes",t)}},
|
|
47
|
+
inationMode":(n.paginationMode=d(i,["cursor","offset"]))&&s.delete(i.name);break;case"\
|
|
48
|
+
orderMode":(n.orderMode=d(i,["any","index"]))&&s.delete(i.name);break;case"lockM\
|
|
49
|
+
ode":(n.lockMode=d(i,["unsupported","supported"]))&&s.delete(i.name);break}if(!Xe(
|
|
50
|
+
n)){a.push(new D([...s],e.file));return}return n},"getTypeFromMembers");import{InvalidServicePropertyError as Wr,getModelMembers as _r,getObjectMembers as Br,
|
|
51
|
+
getPropertyString as Gr,getReferenceType as Jr}from"@ez4/common/library";import{
|
|
52
|
+
isModelProperty as Kr,isTypeObject as Qr,isTypeReference as Xr}from"@ez4/reflection";import{IncompleteTypeError as Ye}from"@ez4/common/library";var E=class extends Ye{static{o(this,"IncompleteTableError")}constructor(t,r){super(
|
|
53
|
+
"Incomplete database table",t,r)}};import{IncorrectTypeError as Ze,InvalidTypeError as Le,TypeError as te}from"@ez4/common/library";var R=class extends Le{static{o(this,"InvalidIndexesTypeError")}constructor(t){super(
|
|
54
|
+
"Invalid table indexes type",void 0,"Database.Indexes",t)}},P=class extends Ze{constructor(r,a){
|
|
54
55
|
super("Incorrect table indexes type",r,"Database.Indexes",a);this.schemaType=r}static{
|
|
55
|
-
|
|
56
|
+
o(this,"IncorrectIndexesTypeError")}},k=class extends te{constructor(r,a){super(
|
|
56
57
|
`Invalid index type, ${r} must follow one of the Index options.`,a);this.indexName=
|
|
57
|
-
r}static{
|
|
58
|
+
r}static{o(this,"InvalidIndexTypeError")}},O=class extends te{constructor(r,a){super(
|
|
58
59
|
`Invalid index reference, ${r} must be valid column.`,a);this.indexName=r}static{
|
|
59
|
-
|
|
60
|
-
getReferenceType as
|
|
61
|
-
isTypeReference as
|
|
62
|
-
a)},"getTableRelations"),
|
|
63
|
-
r.push(new
|
|
64
|
-
e,
|
|
65
|
-
|
|
66
|
-
let[p,
|
|
67
|
-
targetColumn:p,targetAlias:
|
|
68
|
-
getReferenceType as
|
|
69
|
-
isTypeReference as
|
|
70
|
-
"ttl",
|
|
71
|
-
a)},"getTableIndexes"),
|
|
72
|
-
push(new
|
|
73
|
-
e,
|
|
74
|
-
|
|
60
|
+
o(this,"InvalidIndexReferenceError")}};import{isModelDeclaration as er,getModelMembers as rr,getObjectMembers as tr,getPropertyString as nr,
|
|
61
|
+
getReferenceType as or}from"@ez4/common/library";import{isModelProperty as ar,isTypeObject as sr,
|
|
62
|
+
isTypeReference as ir}from"@ez4/reflection";var ae=o((e,t,r,a)=>{if(!ir(e))return ne(e,t,a);let n=or(e,r);if(n)return ne(n,t,
|
|
63
|
+
a)},"getTableRelations"),ne=o((e,t,r)=>{if(sr(e))return oe(e,tr(e),r);if(!er(e)){
|
|
64
|
+
r.push(new u(t.file));return}if(!G(e)){r.push(new y(e.name,e.file));return}return oe(
|
|
65
|
+
e,rr(e),r)},"getTypeRelations"),oe=o((e,t,r)=>{let a=[];for(let n of t){if(!ar(n)||
|
|
66
|
+
n.inherited)continue;let s=nr(n),i=n.name;if(!s){r.push(new x(i,e.file));return}
|
|
67
|
+
let[p,l]=i.split("@",2),[c,f]=s.split(":",2);a.push({sourceTable:c,sourceColumn:f,
|
|
68
|
+
targetColumn:p,targetAlias:l})}return a},"getTypeFromMembers");import{isModelDeclaration as lr,getModelMembers as cr,getObjectMembers as mr,getPropertyString as dr,
|
|
69
|
+
getReferenceType as fr}from"@ez4/common/library";import{isModelProperty as br,isTypeObject as Tr,
|
|
70
|
+
isTypeReference as ur}from"@ez4/reflection";var pr=(n=>(n.Primary="primary",n.Secondary="secondary",n.Unique="unique",n.TTL=
|
|
71
|
+
"ttl",n))(pr||{});var pe=o((e,t,r,a)=>{if(!ur(e))return se(e,t,a);let n=fr(e,r);if(n)return se(n,t,
|
|
72
|
+
a)},"getTableIndexes"),se=o((e,t,r)=>{if(Tr(e))return ie(e,mr(e),r);if(!lr(e)){r.
|
|
73
|
+
push(new R(t.file));return}if(!J(e)){r.push(new P(e.name,e.file));return}return ie(
|
|
74
|
+
e,cr(e),r)},"getTypeIndexes"),ie=o((e,t,r)=>{let a=[];for(let n of t){if(!br(n)||
|
|
75
|
+
n.inherited)continue;let s=n.name,i=dr(n);switch(i){case"primary":case"secondary":case"\
|
|
75
76
|
unique":case"ttl":a.push({name:s,columns:s.split(":"),type:i});break;default:r.push(
|
|
76
|
-
new
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"Invalid table schema type",void 0,"Database.Schema",t)}},
|
|
77
|
+
new k(s,e.file));return}}return a},"getTypeFromMembers");import{isTypeObject as gr,isTypeReference as Mr}from"@ez4/reflection";import{getReferenceType as Ir,
|
|
78
|
+
isModelDeclaration as Sr}from"@ez4/common/library";import{createSchemaContext as hr,
|
|
79
|
+
isObjectSchema as vr}from"@ez4/schema";import{getObjectSchema as Dr}from"@ez4/schema/library";import{IncorrectTypeError as yr,InvalidTypeError as xr}from"@ez4/common/library";var w=class extends xr{static{o(this,"InvalidSchemaTypeError")}constructor(t){super(
|
|
80
|
+
"Invalid table schema type",void 0,"Database.Schema",t)}},j=class extends yr{constructor(r,a){
|
|
80
81
|
super("Incorrect table schema type",r,"Database.Schema",a);this.schemaType=r}static{
|
|
81
|
-
|
|
82
|
-
t,r,a)},"getTableSchema"),
|
|
83
|
-
push(new
|
|
84
|
-
e,r)},"getTypeSchema"),
|
|
85
|
-
"getSchema");import{InvalidServicePropertyError as wr,isModelDeclaration as
|
|
86
|
-
getModelMembers as
|
|
87
|
-
getReferenceType as
|
|
88
|
-
isTypeReference as
|
|
89
|
-
"Incomplete table stream",t,r)}},z=class extends
|
|
82
|
+
o(this,"IncorrectSchemaTypeError")}};var me=o((e,t,r,a)=>{if(!Mr(e))return le(e,t,r,a);let n=Ir(e,r);if(n)return le(n,
|
|
83
|
+
t,r,a)},"getTableSchema"),le=o((e,t,r,a)=>{if(gr(e))return ce(e,r);if(!Sr(e)){a.
|
|
84
|
+
push(new w(t.file));return}if(!K(e)){a.push(new j(e.name,e.file));return}return ce(
|
|
85
|
+
e,r)},"getTypeSchema"),ce=o((e,t)=>{let r=Dr(e,t,hr({nullish:!0}));if(r&&vr(r))return r},
|
|
86
|
+
"getSchema");import{InvalidServicePropertyError as wr,isModelDeclaration as jr,getLinkedVariableList as Ar,
|
|
87
|
+
getModelMembers as zr,getObjectMembers as Cr,getPropertyNumber as Nr,getServiceListener as Fr,
|
|
88
|
+
getReferenceType as qr}from"@ez4/common/library";import{isModelProperty as Ur,isTypeObject as $r,
|
|
89
|
+
isTypeReference as Vr}from"@ez4/reflection";import{IncompleteTypeError as Er,IncorrectTypeError as Rr,InvalidTypeError as Pr}from"@ez4/common/library";var A=class extends Er{static{o(this,"IncompleteStreamError")}constructor(t,r){super(
|
|
90
|
+
"Incomplete table stream",t,r)}},z=class extends Pr{static{o(this,"InvalidStream\
|
|
90
91
|
TypeError")}constructor(t){super("Invalid table stream type",void 0,"Database.St\
|
|
91
|
-
ream",t)}},C=class extends
|
|
92
|
-
e",r,"Database.Stream",a);this.streamType=r}static{
|
|
93
|
-
ror")}};import{IncompleteTypeError as
|
|
94
|
-
super("Incomplete stream handler",t,r)}};var
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
break;case"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
ye as getDatabaseTable,ce as getTableSchema,ft as isDatabaseService,un as registerTriggers};
|
|
92
|
+
ream",t)}},C=class extends Rr{constructor(r,a){super("Incorrect table stream typ\
|
|
93
|
+
e",r,"Database.Stream",a);this.streamType=r}static{o(this,"IncorrectStreamTypeEr\
|
|
94
|
+
ror")}};import{getFunctionSignature as Or}from"@ez4/common/library";import{IncompleteTypeError as kr}from"@ez4/common/library";var N=class extends kr{static{o(this,"IncompleteHandlerError")}constructor(t,r){
|
|
95
|
+
super("Incomplete stream handler",t,r)}};var de=o((e,t,r)=>{if(!B(e))return;let a=Or(e),n=new Set(["change"]);if(e.parameters&&
|
|
96
|
+
n.delete("change"),!a||n.size){r.push(new N([...n],e.file));return}return a},"ge\
|
|
97
|
+
tStreamHandler");var Te=o((e,t,r,a)=>{if(!Vr(e))return fe(e,t,r,a);let n=qr(e,r);if(n)return fe(n,
|
|
98
|
+
t,r,a)},"getTableStream"),Hr=o(e=>!!e.handler,"isValidStream"),fe=o((e,t,r,a)=>{
|
|
99
|
+
if($r(e))return be(e,t,Cr(e),r,a);if(!jr(e)){a.push(new z(t.file));return}if(!Q(
|
|
100
|
+
e)){a.push(new C(e.name,e.file));return}return be(e,t,zr(e),r,a)},"getTypeStream"),
|
|
101
|
+
be=o((e,t,r,a,n)=>{let s={},i=new Set(["handler"]);for(let p of r)if(!(!Ur(p)||p.
|
|
102
|
+
inherited))switch(p.name){default:n.push(new wr(t.name,p.name,e.file));break;case"\
|
|
103
|
+
handler":s.handler=de(p.value,a,n);break;case"listener":s.listener=Fr(p.value,n);
|
|
104
|
+
break;case"memory":case"logRetention":case"timeout":s[p.name]=Nr(p);break;case"v\
|
|
105
|
+
ariables":s.variables=Ar(p,n);break}if(Hr(s))return s;n.push(new A([...i],e.file))},
|
|
106
|
+
"getTypeFromMembers");var xe=o((e,t,r,a)=>{if(!Xr(e))return ue(e,t,r,a);let n=Jr(e,r);if(n)return ue(n,
|
|
107
|
+
t,r,a)},"getDatabaseTable"),Yr=o(e=>!!e.name&&!!e.schema&&!!e.indexes,"isValidTa\
|
|
108
|
+
ble"),ue=o((e,t,r,a)=>{if(_(e))return ye(e,t,_r(e),r,a);if(Qr(e))return ye(e,t,Br(
|
|
109
|
+
e),r,a)},"getTypeTable"),ye=o((e,t,r,a,n)=>{let s={},i=new Set(["name","schema",
|
|
110
|
+
"indexes"]);for(let l of r)if(!(!Kr(l)||l.inherited))switch(l.name){default:n.push(
|
|
111
|
+
new Wr(t.name,l.name,e.file));break;case"name":(s.name=Gr(l))&&i.delete(l.name);
|
|
112
|
+
break;case"schema":(s.schema=me(l.value,e,a,n))&&i.delete(l.name);break;case"ind\
|
|
113
|
+
exes":(s.indexes=pe(l.value,e,a,n))&&i.delete(l.name);break;case"relations":s.relations=
|
|
114
|
+
ae(l.value,e,a,n);break;case"stream":s.stream=Te(l.value,t,a,n);break}if(!Yr(s)){
|
|
115
|
+
n.push(new E([...i],e.file));return}let p=Zr(e,s.indexes,s.schema);if(p.length){
|
|
116
|
+
n.push(...p);return}return s},"getTypeFromMembers"),Zr=o((e,t,r)=>{let a=r.properties,
|
|
117
|
+
n=[];for(let{name:s,columns:i}of t)i.some(l=>!a[l])&&n.push(new O(s,e.file));return n},
|
|
118
|
+
"validateIndexes");var Me=o(e=>{let t={},r=[];for(let a in e){let n=e[a];if(!h(n)||rt(n))continue;let s=H(
|
|
119
|
+
n.name),i=new Set(["engine","tables"]),p=n.file;for(let c of at(n))if(!(!st(c)||
|
|
120
|
+
c.inherited))switch(c.name){default:r.push(new et(s.name,c.name,p));break;case"c\
|
|
121
|
+
lient":break;case"scalability":s.scalability=Z(c.value,n,e,r);break;case"engine":
|
|
122
|
+
(s.engine=re(c.value,n,e,r))&&i.delete(c.name);break;case"tables":(s.tables=lt(c,
|
|
123
|
+
n,e,r))&&i.delete(c.name);break;case"variables":s.variables=nt(c,r);break;case"s\
|
|
124
|
+
ervices":s.services=tt(c,e,r);break}if(!pt(s)){r.push(new T([...i],p));continue}
|
|
125
|
+
let l=ct(n,s.tables);if(l.length){r.push(...l);continue}if(t[n.name]){r.push(new Lr(
|
|
126
|
+
n.name,p));continue}t[n.name]=s}return{services:t,errors:r}},"getDatabaseService\
|
|
127
|
+
s"),pt=o(e=>it(e,["engine","tables","variables","services"]),"isCompleteService"),
|
|
128
|
+
lt=o((e,t,r,a)=>{let n=ot(e)??[],s=[];for(let i of n){let p=xe(i,t,r,a);p&&s.push(
|
|
129
|
+
p)}return s},"getAllTables"),ct=o((e,t)=>{let r=mt(t),a=[];for(let{relations:n,schema:s,
|
|
130
|
+
indexes:i}of t){if(!n)continue;let p=s.properties;for(let l of n){let{sourceTable:c,
|
|
131
|
+
sourceColumn:f,targetColumn:F,targetAlias:$}=l;p[F]||a.push(new b(F,e.file)),p[$]&&
|
|
132
|
+
a.push(new M($,e.file));let q=r[c]?.schema.properties;q||a.push(new g(c,e.file)),
|
|
133
|
+
q&&!q[f]&&a.push(new b(f,e.file));let Se=r[c]?.indexes??[];l.sourceIndex=ge(Se,f),
|
|
134
|
+
l.targetIndex=ge(i,F)}}return a},"validateRelations"),ge=o((e,t)=>e.find(({name:r})=>r===
|
|
135
|
+
t)?.type,"getIndexType"),mt=o(e=>e.reduce((t,r)=>({...t,[r.name]:r}),{}),"getTab\
|
|
136
|
+
leMap");var Ie=o(e=>h(e)?e.name:null,"getLinkedService");var So=o(()=>{dt(),ft(),bt("@ez4/database",{"metadata:getServices":Me,"metadata:\
|
|
137
|
+
getLinkedService":Ie})},"registerTriggers");export{D as IncompleteEngineError,N as IncompleteHandlerError,S as IncompleteScalabilityError,
|
|
138
|
+
T as IncompleteServiceError,A as IncompleteStreamError,E as IncompleteTableError,
|
|
139
|
+
P as IncorrectIndexesTypeError,y as IncorrectRelationsTypeError,j as IncorrectSchemaTypeError,
|
|
140
|
+
C as IncorrectStreamTypeError,pr as Index,O as InvalidIndexReferenceError,k as InvalidIndexTypeError,
|
|
141
|
+
R as InvalidIndexesTypeError,M as InvalidRelationAliasError,b as InvalidRelationColumnError,
|
|
142
|
+
g as InvalidRelationTableError,x as InvalidRelationTargetError,u as InvalidRelationsTypeError,
|
|
143
|
+
w as InvalidSchemaTypeError,z as InvalidStreamTypeError,V as ServiceType,H as createDatabaseService,
|
|
144
|
+
Me as getDatabaseServices,xe as getDatabaseTable,me as getTableSchema,yt as isDatabaseService,
|
|
145
|
+
So as registerTriggers};
|
|
146
146
|
//# sourceMappingURL=library.mjs.map
|
package/dist/main.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var
|
|
2
|
-
typeof a=="object"||typeof a=="function")for(let t of I(a))!
|
|
3
|
-
o(n,t,{get:()=>a[t],enumerable:!(r=b(a,t))||r.enumerable});return n};var f=n=>g(o({},"__esModule",{value:!0}),n);var D={};
|
|
1
|
+
"use strict";var o=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var u=(n,a)=>{for(var e in a)o(n,e,{get:a[e],enumerable:!0})},g=(n,a,e,r)=>{if(a&&
|
|
2
|
+
typeof a=="object"||typeof a=="function")for(let t of I(a))!S.call(n,t)&&t!==e&&
|
|
3
|
+
o(n,t,{get:()=>a[t],enumerable:!(r=b(a,t))||r.enumerable});return n};var f=n=>g(o({},"__esModule",{value:!0}),n);var D={};u(D,{Database:()=>y,Index:()=>c,InsensitiveMode:()=>m,LockMode:()=>x,Order:()=>l,
|
|
4
4
|
OrderMode:()=>T,PaginationMode:()=>d,ParametersMode:()=>p,StreamChangeType:()=>s,
|
|
5
5
|
TransactionMode:()=>i});module.exports=f(D);var s=(r=>(r.Insert="insert",r.Update="update",r.Delete="delete",r))(s||{});var p=(e=>(e.NameAndIndex="both",e.OnlyIndex="index",e))(p||{});var i=(e=>(e.Interactive="interactive",e.Static="static",e))(i||{});var m=(e=>(e.Unsupported="unsupported",e.Enabled="enabled",e))(m||{});var d=(e=>(e.Cursor="cursor",e.Offset="offset",e))(d||{});var l=(e=>(e.Asc="asc",e.Desc="desc",e))(l||{}),T=(e=>(e.IndexColumns="index",e.
|
|
6
6
|
AnyColumns="any",e))(T||{});var x=(e=>(e.Unsupported="unsupported",e.Supported="supported",e))(x||{});var y;(n=>{})(y||={});var c=(t=>(t.Primary="primary",t.Secondary="secondary",t.Unique="unique",t.TTL="\
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { DatabaseEngine } from '../types/engine';
|
|
3
|
-
export declare const getDatabaseEngine: (type: AllType, parent: TypeModel, reflection:
|
|
3
|
+
export declare const getDatabaseEngine: (type: AllType, parent: TypeModel, reflection: ReflectionTypes, errorList: Error[]) => DatabaseEngine | undefined;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { AllType,
|
|
2
|
-
|
|
3
|
-
export declare const getStreamHandler: (type: AllType, _reflection: SourceMap, errorList: Error[]) => StreamHandler | undefined;
|
|
1
|
+
import type { AllType, ReflectionTypes } from '@ez4/reflection';
|
|
2
|
+
export declare const getStreamHandler: (type: AllType, _reflection: ReflectionTypes, errorList: Error[]) => import("@ez4/common/library").FunctionSignature | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
import type { TableIndex } from '../types/indexes';
|
|
3
3
|
type TypeParent = TypeModel | TypeObject;
|
|
4
|
-
export declare const getTableIndexes: (type: AllType, parent: TypeParent, reflection:
|
|
4
|
+
export declare const getTableIndexes: (type: AllType, parent: TypeParent, reflection: ReflectionTypes, errorList: Error[]) => TableIndex[] | undefined;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
import type { TableRelation } from '../types/relations';
|
|
3
3
|
type TypeParent = TypeModel | TypeObject;
|
|
4
|
-
export declare const getTableRelations: (type: AllType, parent: TypeParent, reflection:
|
|
4
|
+
export declare const getTableRelations: (type: AllType, parent: TypeParent, reflection: ReflectionTypes, errorList: Error[]) => TableRelation[] | undefined;
|
|
5
5
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { DatabaseScalability } from '../types/scalability';
|
|
3
|
-
export declare const getDatabaseScalability: (type: AllType, parent: TypeModel, reflection:
|
|
3
|
+
export declare const getDatabaseScalability: (type: AllType, parent: TypeModel, reflection: ReflectionTypes, errorList: Error[]) => DatabaseScalability | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
type TypeParent = TypeModel | TypeObject;
|
|
3
|
-
export declare const getTableSchema: (type: AllType, parent: TypeParent, reflection:
|
|
3
|
+
export declare const getTableSchema: (type: AllType, parent: TypeParent, reflection: ReflectionTypes, errorList: Error[]) => import("@ez4/schema").ObjectSchema | undefined;
|
|
4
4
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReflectionTypes } from '@ez4/reflection';
|
|
2
2
|
import type { DatabaseService } from '../types/service';
|
|
3
|
-
export declare const getDatabaseServices: (reflection:
|
|
3
|
+
export declare const getDatabaseServices: (reflection: ReflectionTypes) => {
|
|
4
4
|
services: Record<string, DatabaseService>;
|
|
5
5
|
errors: Error[];
|
|
6
6
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { TableStream } from '../types/stream';
|
|
3
|
-
export declare const getTableStream: (type: AllType, parent: TypeModel, reflection:
|
|
3
|
+
export declare const getTableStream: (type: AllType, parent: TypeModel, reflection: ReflectionTypes, errorList: Error[]) => TableStream | undefined;
|
package/dist/metadata/table.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType,
|
|
1
|
+
import type { AllType, ReflectionTypes, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { DatabaseTable } from '../types/table';
|
|
3
|
-
export declare const getDatabaseTable: (type: AllType, parent: TypeModel, reflection:
|
|
3
|
+
export declare const getDatabaseTable: (type: AllType, parent: TypeModel, reflection: ReflectionTypes, errorList: Error[]) => DatabaseTable | undefined;
|
|
@@ -36,6 +36,10 @@ export declare namespace Database {
|
|
|
36
36
|
* Database Scalability definition.
|
|
37
37
|
*/
|
|
38
38
|
type UseScalability<T extends DatabaseScalability> = T;
|
|
39
|
+
/**
|
|
40
|
+
* Database Table stream definition.
|
|
41
|
+
*/
|
|
42
|
+
type UseTableStream<T extends Stream<any>> = T;
|
|
39
43
|
/**
|
|
40
44
|
* Database service.
|
|
41
45
|
*/
|
package/dist/services/query.d.ts
CHANGED
|
@@ -96,8 +96,17 @@ export declare namespace Query {
|
|
|
96
96
|
order?: StrictIncludeOrder<V>;
|
|
97
97
|
};
|
|
98
98
|
export type WhereInput<T extends TableMetadata, I extends boolean = false> = Prettify<WhereInputFilters<T, I extends true ? T['indexes'] : {}> & {
|
|
99
|
+
/**
|
|
100
|
+
* Check whether the expression is not true.
|
|
101
|
+
*/
|
|
99
102
|
NOT?: WhereInput<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Check whether all the expressions are true.
|
|
105
|
+
*/
|
|
100
106
|
AND?: WhereInput<T>[];
|
|
107
|
+
/**
|
|
108
|
+
* Check whether any of all the expressions are true.
|
|
109
|
+
*/
|
|
101
110
|
OR?: WhereInput<T>[];
|
|
102
111
|
}>;
|
|
103
112
|
type SelectInputFields<T extends Database.Schema, R extends RelationMetadata> = IsObjectEmpty<R['selects']> extends true ? T : T & R['selects'];
|
|
@@ -108,8 +117,17 @@ export declare namespace Query {
|
|
|
108
117
|
[P in keyof V]?: WhereField<V[P], E>;
|
|
109
118
|
};
|
|
110
119
|
type WhereRelationField<V extends AnyObject, E extends DatabaseEngine> = WhereObjectField<V, E> & {
|
|
120
|
+
/**
|
|
121
|
+
* Check whether the expression is not true.
|
|
122
|
+
*/
|
|
111
123
|
NOT?: WhereRelationField<V, E>;
|
|
124
|
+
/**
|
|
125
|
+
* Check whether all the expressions are true.
|
|
126
|
+
*/
|
|
112
127
|
AND?: WhereRelationField<V, E>[];
|
|
128
|
+
/**
|
|
129
|
+
* Check whether any of all the expressions are true.
|
|
130
|
+
*/
|
|
113
131
|
OR?: WhereRelationField<V, E>[];
|
|
114
132
|
};
|
|
115
133
|
type WhereRelationFilters<V extends AnyObject, E extends DatabaseEngine> = {
|
|
@@ -128,39 +146,75 @@ export declare namespace Query {
|
|
|
128
146
|
type WhereInputFilters<T extends TableMetadata, I extends Database.Indexes> = WhereCommonFilters<T['schema'], T, I> & (IsObjectEmpty<T['relations']['filters']> extends false ? WhereRelationFilters<T['relations']['filters'], T['engine']> : {});
|
|
129
147
|
export type WhereOperators = keyof (WhereNegate<any, never> & WhereEqual<any, never> & WhereGreaterThan<any> & WhereGreaterThanOrEqual<any> & WhereLessThan<any> & WhereLessThanOrEqual<any> & WhereIn<any> & WhereBetween<any> & WhereIsMissing & WhereIsNull & WhereStartsWith<never> & WhereContains<any, never>);
|
|
130
148
|
type WhereNegate<V, E extends DatabaseEngine> = (V extends string ? InsensitiveModeUtils.Input<E> : {}) & {
|
|
149
|
+
/**
|
|
150
|
+
* Check whether the entity value is not equal to the given one.
|
|
151
|
+
*/
|
|
131
152
|
not: V;
|
|
132
153
|
};
|
|
133
154
|
type WhereEqual<V, E extends DatabaseEngine> = (V extends string ? InsensitiveModeUtils.Input<E> : {}) & {
|
|
155
|
+
/**
|
|
156
|
+
* Check whether the entity value is equal to the given one.
|
|
157
|
+
*/
|
|
134
158
|
equal: V;
|
|
135
159
|
};
|
|
136
160
|
type WhereGreaterThan<V> = {
|
|
161
|
+
/**
|
|
162
|
+
* Check whether the entity value is greater than the given one.
|
|
163
|
+
*/
|
|
137
164
|
gt: V;
|
|
138
165
|
};
|
|
139
166
|
type WhereGreaterThanOrEqual<V> = {
|
|
167
|
+
/**
|
|
168
|
+
* Check whether the entity value is greater than or equal the given one.
|
|
169
|
+
*/
|
|
140
170
|
gte: V;
|
|
141
171
|
};
|
|
142
172
|
type WhereLessThan<V> = {
|
|
173
|
+
/**
|
|
174
|
+
* Check whether the entity value is less than the given one.
|
|
175
|
+
*/
|
|
143
176
|
lt: V;
|
|
144
177
|
};
|
|
145
178
|
type WhereLessThanOrEqual<V> = {
|
|
179
|
+
/**
|
|
180
|
+
* Check whether the entity value is less than or equal the given one.
|
|
181
|
+
*/
|
|
146
182
|
lte: V;
|
|
147
183
|
};
|
|
148
184
|
type WhereIn<V> = {
|
|
185
|
+
/**
|
|
186
|
+
* Check whether the entity value is in the given ones.
|
|
187
|
+
*/
|
|
149
188
|
isIn: IsArray<V> extends true ? V : IsObject<V> extends true ? V : Exclude<V, undefined>[];
|
|
150
189
|
};
|
|
151
190
|
type WhereBetween<V> = {
|
|
191
|
+
/**
|
|
192
|
+
* Check whether the entity value is between the given ones.
|
|
193
|
+
*/
|
|
152
194
|
isBetween: [Exclude<V, undefined>, Exclude<V, undefined>];
|
|
153
195
|
};
|
|
154
196
|
type WhereIsMissing = {
|
|
197
|
+
/**
|
|
198
|
+
* Check whether the entity value is missing.
|
|
199
|
+
*/
|
|
155
200
|
isMissing: boolean;
|
|
156
201
|
};
|
|
157
202
|
type WhereIsNull = {
|
|
203
|
+
/**
|
|
204
|
+
* Check whether the entity value is null.
|
|
205
|
+
*/
|
|
158
206
|
isNull: boolean;
|
|
159
207
|
};
|
|
160
208
|
type WhereStartsWith<E extends DatabaseEngine> = InsensitiveModeUtils.Input<E> & {
|
|
209
|
+
/**
|
|
210
|
+
* Check whether the entity value starts with the given one.
|
|
211
|
+
*/
|
|
161
212
|
startsWith: string;
|
|
162
213
|
};
|
|
163
214
|
type WhereContains<V, E extends DatabaseEngine> = (V extends string ? InsensitiveModeUtils.Input<E> : {}) & {
|
|
215
|
+
/**
|
|
216
|
+
* Check whether the entity value contains all the given ones.
|
|
217
|
+
*/
|
|
164
218
|
contains: IsObject<V> extends true ? Partial<V> : V;
|
|
165
219
|
};
|
|
166
220
|
export type AtomicOperators = keyof (AtomicIncrement & AtomicDecrement & AtomicMultiply & AtomicDivide);
|
|
@@ -174,15 +228,27 @@ export declare namespace Query {
|
|
|
174
228
|
};
|
|
175
229
|
type AtomicOperation = AtomicIncrement | AtomicDecrement | AtomicMultiply | AtomicDivide;
|
|
176
230
|
type AtomicIncrement = {
|
|
231
|
+
/**
|
|
232
|
+
* Increment the entity value by the given amount.
|
|
233
|
+
*/
|
|
177
234
|
increment: number;
|
|
178
235
|
};
|
|
179
236
|
type AtomicDecrement = {
|
|
237
|
+
/**
|
|
238
|
+
* Decrement the entity value by the given amount.
|
|
239
|
+
*/
|
|
180
240
|
decrement: number;
|
|
181
241
|
};
|
|
182
242
|
type AtomicMultiply = {
|
|
243
|
+
/**
|
|
244
|
+
* Multiply the entity value by the given amount.
|
|
245
|
+
*/
|
|
183
246
|
multiply: number;
|
|
184
247
|
};
|
|
185
248
|
type AtomicDivide = {
|
|
249
|
+
/**
|
|
250
|
+
* Divide the entity value by the given amount.
|
|
251
|
+
*/
|
|
186
252
|
divide: number;
|
|
187
253
|
};
|
|
188
254
|
export {};
|
|
@@ -6,11 +6,11 @@ import type { TableSchema } from './schemas';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface TableStream<T extends TableSchema> {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Life-cycle listener function for the stream.
|
|
10
10
|
*/
|
|
11
11
|
readonly listener?: TableStreamListener<T>;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Entry-point handler function for the stream.
|
|
14
14
|
*/
|
|
15
15
|
readonly handler: TableStreamHandler<T>;
|
|
16
16
|
/**
|
|
@@ -26,7 +26,7 @@ export interface TableStream<T extends TableSchema> {
|
|
|
26
26
|
*/
|
|
27
27
|
readonly timeout?: number;
|
|
28
28
|
/**
|
|
29
|
-
* Amount of memory available for the handler.
|
|
29
|
+
* Amount of memory available (in megabytes) for the handler.
|
|
30
30
|
*/
|
|
31
31
|
readonly memory?: number;
|
|
32
32
|
}
|
package/dist/types/handler.d.ts
CHANGED