@ez4/database 0.20.0 → 0.21.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/errors/engine.d.ts +4 -0
- package/dist/errors/scalability.d.ts +4 -0
- package/dist/library.cjs +115 -102
- package/dist/library.d.ts +2 -0
- package/dist/library.mjs +118 -107
- package/dist/metadata/scalability.d.ts +3 -0
- package/dist/services/database.d.ts +11 -0
- package/dist/types/scalability.d.ts +4 -0
- package/dist/types/service.d.ts +2 -0
- package/package.json +6 -6
package/dist/library.cjs
CHANGED
|
@@ -1,117 +1,130 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof r=="object"||typeof r=="function")for(let a of
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";var oe=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ze=(e,r)=>{for(var t in r)oe(e,t,{get:r[t],enumerable:!0})},Le=(e,r,t,n)=>{if(r&&
|
|
2
|
+
typeof r=="object"||typeof r=="function")for(let a of Xe(r))!Ye.call(e,a)&&a!==t&&
|
|
3
|
+
oe(e,a,{get:()=>r[a],enumerable:!(n=We(r,a))||n.enumerable});return e};var et=e=>Le(oe({},"__esModule",{value:!0}),e);var ut={};Ze(ut,{IncompleteEngineError:()=>U,IncompleteHandlerError:()=>J,IncompleteScalabilityError:()=>z,
|
|
4
|
+
IncompleteServiceError:()=>O,IncompleteStreamError:()=>Q,IncompleteTableError:()=>N,
|
|
5
|
+
IncorrectIndexesTypeError:()=>F,IncorrectRelationsTypeError:()=>R,IncorrectSchemaTypeError:()=>G,
|
|
6
|
+
IncorrectStreamTypeError:()=>_,InvalidIndexReferenceError:()=>V,InvalidIndexTypeError:()=>q,
|
|
7
|
+
InvalidIndexesTypeError:()=>H,InvalidRelationAliasError:()=>C,InvalidRelationColumnError:()=>M,
|
|
8
|
+
InvalidRelationTableError:()=>w,InvalidRelationTargetError:()=>A,InvalidRelationsTypeError:()=>k,
|
|
9
|
+
InvalidSchemaTypeError:()=>$,InvalidStreamTypeError:()=>B,ServiceType:()=>K,getDatabaseServices:()=>pe,
|
|
10
|
+
getDatabaseTable:()=>ie,getTableSchema:()=>se,isDatabaseService:()=>tt,registerTriggers:()=>dt});
|
|
11
|
+
module.exports=et(ut);var Be=require("@ez4/common/library"),_e=require("@ez4/schema/library"),Je=require("@ez4/project/library");var d=require("@ez4/common/library"),$e=require("@ez4/reflection");var K="@ez4/database",tt=e=>e.type===K;var me=require("@ez4/common/library"),O=class extends me.IncompleteTypeError{constructor(r,t){
|
|
12
|
+
super("Incomplete database service",r,t)}};var x=require("@ez4/common/library"),k=class extends x.InvalidTypeError{constructor(r){
|
|
13
|
+
super("Invalid table relations type",void 0,"Database.Relations",r)}},R=class extends x.IncorrectTypeError{constructor(t,n){
|
|
12
14
|
super("Incorrect table relations type",t,"Database.Relations",n);this.schemaType=
|
|
13
|
-
t}},
|
|
14
|
-
the pattern 'column@alias'.`,n);this.relationSource=t}},
|
|
15
|
-
super(`Relation table ${t} don't exists.`,n);this.relationTable=t}},
|
|
16
|
-
super(`Relation column ${t} don't exists.`,n);this.relationColumn=t}},C=class extends
|
|
15
|
+
t}},A=class extends x.TypeError{constructor(t,n){super(`Target ${t} must follow \
|
|
16
|
+
the pattern 'column@alias'.`,n);this.relationSource=t}},w=class extends x.TypeError{constructor(t,n){
|
|
17
|
+
super(`Relation table ${t} don't exists.`,n);this.relationTable=t}},M=class extends x.TypeError{constructor(t,n){
|
|
18
|
+
super(`Relation column ${t} don't exists.`,n);this.relationColumn=t}},C=class extends x.TypeError{constructor(t,n){
|
|
17
19
|
super(`Relation alias ${t} can't override table columns.`,n);this.relationAlias=
|
|
18
|
-
t}};var
|
|
19
|
-
super("Incomplete database
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
e,"Database.
|
|
24
|
-
e,"Database.
|
|
25
|
-
e,
|
|
26
|
-
e,t)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
name
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
file))
|
|
41
|
-
|
|
20
|
+
t}};var b=require("@ez4/common/library"),I=require("@ez4/reflection"),Z=require("@ez4/utils");var ce=require("@ez4/common/library"),z=class extends ce.IncompleteTypeError{constructor(r,t){
|
|
21
|
+
super("Incomplete database scalability",r,t)}};var u=require("@ez4/common/library"),W=require("@ez4/reflection"),X=e=>(0,u.isClassDeclaration)(
|
|
22
|
+
e)&&(0,u.hasHeritageType)(e,"Database.Service"),Y=e=>(0,u.isModelDeclaration)(e)&&
|
|
23
|
+
(0,u.hasHeritageType)(e,"Database.Engine"),de=e=>(0,u.isModelDeclaration)(e)&&(0,u.hasHeritageType)(
|
|
24
|
+
e,"Database.Table"),ue=e=>(0,W.isTypeCallback)(e)||(0,W.isTypeFunction)(e),be=e=>(0,u.hasHeritageType)(
|
|
25
|
+
e,"Database.Relations"),Te=e=>(0,u.hasHeritageType)(e,"Database.Indexes"),fe=e=>(0,u.hasHeritageType)(
|
|
26
|
+
e,"Database.Schema"),ye=e=>(0,u.hasHeritageType)(e,"Database.Stream");var Me=(e,r,t,n)=>{if(!(0,I.isTypeReference)(e))return xe(e,r,n);let a=(0,b.getReferenceType)(
|
|
27
|
+
e,t);return a?xe(a,r,n):null},rt=e=>(0,Z.isAnyNumber)(e.minCapacity)&&(0,Z.isAnyNumber)(
|
|
28
|
+
e.maxCapacity),xe=(e,r,t)=>Y(e)?ge(e,r,(0,b.getModelMembers)(e),t):(0,I.isTypeObject)(
|
|
29
|
+
e)?ge(e,r,(0,b.getObjectMembers)(e),t):null,ge=(e,r,t,n)=>{let a={},o=new Set(["\
|
|
30
|
+
minCapacity","maxCapacity"]);for(let s of t)if(!(!(0,I.isModelProperty)(s)||s.inherited))
|
|
31
|
+
switch(s.name){default:n.push(new b.InvalidServicePropertyError(r.name,s.name,e.
|
|
32
|
+
file));break;case"minCapacity":case"maxCapacity":let i=(0,b.getPropertyNumber)(s);
|
|
33
|
+
(0,Z.isAnyNumber)(i)&&(a[s.name]=i,o.delete(s.name));break}return rt(a)?a:(n.push(
|
|
34
|
+
new z([...o],e.file)),null)};var S=require("@ez4/reflection"),m=require("@ez4/common/library");var Ie=require("@ez4/common/library"),U=class extends Ie.IncompleteTypeError{constructor(r,t){
|
|
35
|
+
super("Incomplete database engine",r,t)}};var he=(e,r,t,n)=>{if(!(0,S.isTypeReference)(e))return Se(e,r,n);let a=(0,m.getReferenceType)(
|
|
36
|
+
e,t);return a?Se(a,r,n):null},nt=e=>!!e.name&&!!e.parametersMode&&!!e.transactionMode&&
|
|
37
|
+
!!e.insensitiveMode&&!!e.paginationMode&&!!e.orderMode,Se=(e,r,t)=>Y(e)?De(e,r,(0,m.getModelMembers)(
|
|
38
|
+
e),t):(0,S.isTypeObject)(e)?De(e,r,(0,m.getObjectMembers)(e),t):null,De=(e,r,t,n)=>{
|
|
39
|
+
let a={},o=new Set(["name","parametersMode","transactionMode","insensitiveMode",
|
|
40
|
+
"paginationMode","orderMode"]);for(let s of t)if(!(!(0,S.isModelProperty)(s)||s.
|
|
41
|
+
inherited))switch(s.name){default:n.push(new m.InvalidServicePropertyError(r.name,
|
|
42
|
+
s.name,e.file));break;case"name":(a.name=(0,m.getPropertyString)(s))&&o.delete(s.
|
|
43
|
+
name);break;case"parametersMode":(a.parametersMode=(0,m.getPropertyStringIn)(s,[
|
|
44
|
+
"index","both"]))&&o.delete(s.name);break;case"transactionMode":(a.transactionMode=
|
|
45
|
+
(0,m.getPropertyStringIn)(s,["static","interactive"]))&&o.delete(s.name);break;case"\
|
|
46
|
+
insensitiveMode":(a.insensitiveMode=(0,m.getPropertyStringIn)(s,["unsupported","\
|
|
47
|
+
enabled"]))&&o.delete(s.name);break;case"paginationMode":(a.paginationMode=(0,m.getPropertyStringIn)(
|
|
48
|
+
s,["cursor","offset"]))&&o.delete(s.name);break;case"orderMode":(a.orderMode=(0,m.getPropertyStringIn)(
|
|
49
|
+
s,["any","index"]))&&o.delete(s.name);break}return nt(a)?a:(n.push(new U([...o],
|
|
50
|
+
e.file)),null)};var y=require("@ez4/common/library"),j=require("@ez4/reflection");var ve=require("@ez4/common/library"),N=class extends ve.IncompleteTypeError{constructor(r,t){
|
|
51
|
+
super("Incomplete database table",r,t)}};var g=require("@ez4/common/library"),H=class extends g.InvalidTypeError{constructor(r){
|
|
52
|
+
super("Invalid table indexes type",void 0,"Database.Indexes",r)}},F=class extends g.IncorrectTypeError{constructor(t,n){
|
|
42
53
|
super("Incorrect table indexes type",t,"Database.Indexes",n);this.schemaType=t}},
|
|
43
|
-
|
|
44
|
-
t follow one of the Index options.`,n);this.indexName=t}},
|
|
45
|
-
super(`Invalid index reference, ${t} must be valid column.`,n);this.indexName=t}};var
|
|
46
|
-
e,t);return a?
|
|
47
|
-
e),t):(0,
|
|
48
|
-
new
|
|
49
|
-
if(!(0,
|
|
50
|
-
a),s=a.name;if(!o)return t.push(new
|
|
54
|
+
q=class extends g.TypeError{constructor(t,n){super(`Invalid index type, ${t} mus\
|
|
55
|
+
t follow one of the Index options.`,n);this.indexName=t}},V=class extends g.TypeError{constructor(t,n){
|
|
56
|
+
super(`Invalid index reference, ${t} must be valid column.`,n);this.indexName=t}};var T=require("@ez4/common/library"),D=require("@ez4/reflection");var Pe=(e,r,t,n)=>{if(!(0,D.isTypeReference)(e))return Ee(e,r,n);let a=(0,T.getReferenceType)(
|
|
57
|
+
e,t);return a?Ee(a,r,n):null},Ee=(e,r,t)=>(0,D.isTypeObject)(e)?je(e,(0,T.getObjectMembers)(
|
|
58
|
+
e),t):(0,T.isModelDeclaration)(e)?be(e)?je(e,(0,T.getModelMembers)(e),t):(t.push(
|
|
59
|
+
new R(e.name,e.file)),null):(t.push(new k(r.file)),null),je=(e,r,t)=>{let n=[];for(let a of r){
|
|
60
|
+
if(!(0,D.isModelProperty)(a)||a.inherited)continue;let o=(0,T.getPropertyString)(
|
|
61
|
+
a),s=a.name;if(!o)return t.push(new A(s,e.file)),null;let[i,p]=s.split("@",2),[l,
|
|
51
62
|
P]=o.split(":",2);n.push({sourceTable:l,sourceColumn:P,targetColumn:i,targetAlias:p})}
|
|
52
|
-
return n};var
|
|
53
|
-
e,t);return a?
|
|
54
|
-
e),t):(0,
|
|
55
|
-
new
|
|
56
|
-
if(!(0,h.isModelProperty)(a)||a.inherited)continue;let o=a.name,s=(0,
|
|
63
|
+
return n};var f=require("@ez4/common/library"),h=require("@ez4/reflection");var Re=(e,r,t,n)=>{if(!(0,h.isTypeReference)(e))return Oe(e,r,n);let a=(0,f.getReferenceType)(
|
|
64
|
+
e,t);return a?Oe(a,r,n):null},Oe=(e,r,t)=>(0,h.isTypeObject)(e)?ke(e,(0,f.getObjectMembers)(
|
|
65
|
+
e),t):(0,f.isModelDeclaration)(e)?Te(e)?ke(e,(0,f.getModelMembers)(e),t):(t.push(
|
|
66
|
+
new F(e.name,e.file)),null):(t.push(new H(r.file)),null),ke=(e,r,t)=>{let n=[];for(let a of r){
|
|
67
|
+
if(!(0,h.isModelProperty)(a)||a.inherited)continue;let o=a.name,s=(0,f.getPropertyString)(
|
|
57
68
|
a);switch(s){case"primary":case"secondary":case"unique":case"ttl":n.push({name:o,
|
|
58
|
-
columns:o.split(":"),type:s});break;default:return t.push(new
|
|
59
|
-
return n};var
|
|
60
|
-
super("Invalid table schema type",void 0,"Database.Schema",r)}},
|
|
61
|
-
super("Incorrect table schema type",t,"Database.Schema",n);this.schemaType=t}};var
|
|
62
|
-
e,t);return a?
|
|
63
|
-
e)?
|
|
64
|
-
|
|
65
|
-
null};var c=require("@ez4/common/library"),
|
|
66
|
-
super("Incomplete table stream",r,t)}},
|
|
67
|
-
super("Invalid table stream type",void 0,"Database.Stream",r)}},
|
|
68
|
-
super("Incorrect table stream type",t,"Database.Stream",n);this.streamType=t}};var
|
|
69
|
-
super("Incomplete stream handler",r,t)}};var
|
|
69
|
+
columns:o.split(":"),type:s});break;default:return t.push(new q(o,e.file)),null}}
|
|
70
|
+
return n};var ee=require("@ez4/common/library"),te=require("@ez4/schema/library"),re=require("@ez4/reflection");var L=require("@ez4/common/library"),$=class extends L.InvalidTypeError{constructor(r){
|
|
71
|
+
super("Invalid table schema type",void 0,"Database.Schema",r)}},G=class extends L.IncorrectTypeError{constructor(t,n){
|
|
72
|
+
super("Incorrect table schema type",t,"Database.Schema",n);this.schemaType=t}};var se=(e,r,t,n)=>{if(!(0,re.isTypeReference)(e))return Ae(e,r,t,n);let a=(0,ee.getReferenceType)(
|
|
73
|
+
e,t);return a?Ae(a,r,t,n):null},Ae=(e,r,t,n)=>(0,re.isTypeObject)(e)?we(e,t):(0,ee.isModelDeclaration)(
|
|
74
|
+
e)?fe(e)?we(e,t):(n.push(new G(e.name,e.file)),null):(n.push(new $(r.file)),null),
|
|
75
|
+
we=(e,r)=>{let t=(0,te.getObjectSchema)(e,r);return t&&(0,te.isObjectSchema)(t)?
|
|
76
|
+
t:null};var c=require("@ez4/common/library"),E=require("@ez4/reflection");var v=require("@ez4/common/library"),Q=class extends v.IncompleteTypeError{constructor(r,t){
|
|
77
|
+
super("Incomplete table stream",r,t)}},B=class extends v.InvalidTypeError{constructor(r){
|
|
78
|
+
super("Invalid table stream type",void 0,"Database.Stream",r)}},_=class extends v.IncorrectTypeError{constructor(t,n){
|
|
79
|
+
super("Incorrect table stream type",t,"Database.Stream",n);this.streamType=t}};var Ce=require("@ez4/common/library"),J=class extends Ce.IncompleteTypeError{constructor(r,t){
|
|
80
|
+
super("Incomplete stream handler",r,t)}};var ze=(e,r,t)=>{if(!ue(e))return null;let n={},a=new Set(["name","file","change"]);
|
|
70
81
|
return e.description&&(n.description=e.description),(n.name=e.name)&&a.delete("n\
|
|
71
82
|
ame"),(n.file=e.file)&&a.delete("file"),e.parameters&&a.delete("change"),a.size===
|
|
72
|
-
0&&
|
|
73
|
-
e,t);return a?
|
|
74
|
-
e)?
|
|
75
|
-
r,(0,c.getModelMembers)(e),t,n):(n.push(new
|
|
76
|
-
r.file)),null),
|
|
83
|
+
0&&at(n)?n:(t.push(new J([...a],e.file)),null)},at=e=>!!e.name&&!!e.file;var He=(e,r,t,n)=>{if(!(0,E.isTypeReference)(e))return Ue(e,r,t,n);let a=(0,c.getReferenceType)(
|
|
84
|
+
e,t);return a?Ue(a,r,t,n):null},ot=e=>!!e.handler,Ue=(e,r,t,n)=>(0,E.isTypeObject)(
|
|
85
|
+
e)?Ne(e,r,(0,c.getObjectMembers)(e),t,n):(0,c.isModelDeclaration)(e)?ye(e)?Ne(e,
|
|
86
|
+
r,(0,c.getModelMembers)(e),t,n):(n.push(new _(e.name,e.file)),null):(n.push(new B(
|
|
87
|
+
r.file)),null),Ne=(e,r,t,n,a)=>{let o={},s=new Set(["handler"]);for(let i of t)if(!(!(0,E.isModelProperty)(
|
|
77
88
|
i)||i.inherited))switch(i.name){default:a.push(new c.InvalidServicePropertyError(
|
|
78
|
-
r.name,i.name,e.file));break;case"handler":o.handler=
|
|
89
|
+
r.name,i.name,e.file));break;case"handler":o.handler=ze(i.value,n,a);break;case"\
|
|
79
90
|
listener":o.listener=(0,c.getServiceListener)(i.value,a);break;case"memory":case"\
|
|
80
91
|
logRetention":case"timeout":o[i.name]=(0,c.getPropertyNumber)(i);break;case"vari\
|
|
81
|
-
ables":o.variables=(0,c.getLinkedVariableList)(i,a);break}return
|
|
82
|
-
new
|
|
83
|
-
e,t);return a?
|
|
84
|
-
e)?
|
|
85
|
-
e),t,n):null,
|
|
86
|
-
if(!(!(0,
|
|
87
|
-
r.name,p.name,e.file));break;case"name":(o.name=(0,
|
|
88
|
-
p.name);break;case"schema":(o.schema=
|
|
89
|
-
indexes":(o.indexes=
|
|
90
|
-
relations=
|
|
91
|
-
if(!
|
|
92
|
-
return i.length?(a.push(...i),null):o},
|
|
93
|
-
name:o,columns:s}of r)s.some(p=>!n[p])&&a.push(new
|
|
94
|
-
a))continue;let o={type:
|
|
95
|
-
a.name;for(let l of(0,d.getModelMembers)(a))if(!(!(0
|
|
92
|
+
ables":o.variables=(0,c.getLinkedVariableList)(i,a);break}return ot(o)?o:(a.push(
|
|
93
|
+
new Q([...s],e.file)),null)};var ie=(e,r,t,n)=>{if(!(0,j.isTypeReference)(e))return Fe(e,r,t,n);let a=(0,y.getReferenceType)(
|
|
94
|
+
e,t);return a?Fe(a,r,t,n):null},st=e=>!!e.name&&!!e.schema&&!!e.indexes,Fe=(e,r,t,n)=>de(
|
|
95
|
+
e)?qe(e,r,(0,y.getModelMembers)(e),t,n):(0,j.isTypeObject)(e)?qe(e,r,(0,y.getObjectMembers)(
|
|
96
|
+
e),t,n):null,qe=(e,r,t,n,a)=>{let o={},s=new Set(["name","schema","indexes"]);for(let p of t)
|
|
97
|
+
if(!(!(0,j.isModelProperty)(p)||p.inherited))switch(p.name){default:a.push(new y.InvalidServicePropertyError(
|
|
98
|
+
r.name,p.name,e.file));break;case"name":(o.name=(0,y.getPropertyString)(p))&&s.delete(
|
|
99
|
+
p.name);break;case"schema":(o.schema=se(p.value,e,n,a))&&s.delete(p.name);break;case"\
|
|
100
|
+
indexes":(o.indexes=Re(p.value,e,n,a))&&s.delete(p.name);break;case"relations":o.
|
|
101
|
+
relations=Pe(p.value,e,n,a);break;case"stream":o.stream=He(p.value,r,n,a);break}
|
|
102
|
+
if(!st(o))return a.push(new N([...s],e.file)),null;let i=it(e,o.indexes,o.schema);
|
|
103
|
+
return i.length?(a.push(...i),null):o},it=(e,r,t)=>{let n=t.properties,a=[];for(let{
|
|
104
|
+
name:o,columns:s}of r)s.some(p=>!n[p])&&a.push(new V(o,e.file));return a};var pe=e=>{let r={},t=[];for(let n in e){let a=e[n];if(!X(a)||(0,d.isExternalDeclaration)(
|
|
105
|
+
a))continue;let o={type:K,extras:{}},s=new Set(["engine","tables"]),i=a.file;o.name=
|
|
106
|
+
a.name;for(let l of(0,d.getModelMembers)(a))if(!(!(0,$e.isModelProperty)(l)||l.inherited))
|
|
96
107
|
switch(l.name){default:t.push(new d.InvalidServicePropertyError(o.name,l.name,i));
|
|
97
|
-
break;case"client":break;case"
|
|
98
|
-
break;case"
|
|
108
|
+
break;case"client":break;case"scalability":(o.scalability=Me(l.value,a,e,t))&&s.
|
|
109
|
+
delete(l.name);break;case"engine":(o.engine=he(l.value,a,e,t))&&s.delete(l.name);
|
|
110
|
+
break;case"tables":(o.tables=lt(l,a,e,t))&&s.delete(l.name);break;case"variables":
|
|
99
111
|
o.variables=(0,d.getLinkedVariableList)(l,t);break;case"services":o.services=(0,d.getLinkedServiceList)(
|
|
100
|
-
l,e,t);break}if(!
|
|
112
|
+
l,e,t);break}if(!pt(o)){t.push(new O([...s],i));continue}let p=mt(a,o.tables);if(p.
|
|
101
113
|
length){t.push(...p);continue}if(r[a.name]){t.push(new d.DuplicateServiceError(a.
|
|
102
|
-
name,i));continue}r[a.name]=o}return{services:r,errors:t}},
|
|
103
|
-
!!e.extras,
|
|
104
|
-
let i=
|
|
114
|
+
name,i));continue}r[a.name]=o}return{services:r,errors:t}},pt=e=>!!e.name&&!!e.tables&&
|
|
115
|
+
!!e.extras,lt=(e,r,t,n)=>{let a=(0,d.getPropertyTuple)(e)??[],o=[];for(let s of a){
|
|
116
|
+
let i=ie(s,r,t,n);i&&o.push(i)}return o},mt=(e,r)=>{let t=ct(r),n=[];for(let{relations:a,
|
|
105
117
|
schema:o,indexes:s}of r){if(!a)continue;let i=o.properties;for(let p of a){let{sourceTable:l,
|
|
106
|
-
sourceColumn:P,targetColumn:
|
|
107
|
-
n.push(new C(
|
|
108
|
-
|
|
109
|
-
p.targetIndex=
|
|
110
|
-
reduce((r,t)=>({...r,[t.name]:t}),{});var
|
|
111
|
-
"@ez4/database",{"metadata:getServices":
|
|
112
|
-
IncompleteTableError,IncorrectIndexesTypeError,
|
|
113
|
-
IncorrectStreamTypeError,InvalidIndexReferenceError,
|
|
114
|
-
InvalidRelationAliasError,InvalidRelationColumnError,
|
|
115
|
-
InvalidRelationsTypeError,InvalidSchemaTypeError,
|
|
116
|
-
getDatabaseServices,getDatabaseTable,getTableSchema,
|
|
118
|
+
sourceColumn:P,targetColumn:ne,targetAlias:le}=p;i[ne]||n.push(new M(ne,e.file)),
|
|
119
|
+
i[le]&&n.push(new C(le,e.file));let ae=t[l]?.schema.properties;ae||n.push(new w(
|
|
120
|
+
l,e.file)),ae&&!ae[P]&&n.push(new M(P,e.file));let Ke=t[l]?.indexes??[];p.sourceIndex=
|
|
121
|
+
Ve(Ke,P),p.targetIndex=Ve(s,ne)}}return n},Ve=(e,r)=>e.find(({name:t})=>t===r)?.
|
|
122
|
+
type,ct=e=>e.reduce((r,t)=>({...r,[t.name]:t}),{});var Ge=e=>X(e)?e.name:null;var Qe=!1,dt=()=>{Qe||((0,Be.registerTriggers)(),(0,_e.registerTriggers)(),(0,Je.createTrigger)(
|
|
123
|
+
"@ez4/database",{"metadata:getServices":pe,"metadata:getLinkedService":Ge}),Qe=!0)};0&&(module.exports={IncompleteEngineError,IncompleteHandlerError,IncompleteScalabilityError,
|
|
124
|
+
IncompleteServiceError,IncompleteStreamError,IncompleteTableError,IncorrectIndexesTypeError,
|
|
125
|
+
IncorrectRelationsTypeError,IncorrectSchemaTypeError,IncorrectStreamTypeError,InvalidIndexReferenceError,
|
|
126
|
+
InvalidIndexTypeError,InvalidIndexesTypeError,InvalidRelationAliasError,InvalidRelationColumnError,
|
|
127
|
+
InvalidRelationTableError,InvalidRelationTargetError,InvalidRelationsTypeError,InvalidSchemaTypeError,
|
|
128
|
+
InvalidStreamTypeError,ServiceType,getDatabaseServices,getDatabaseTable,getTableSchema,
|
|
129
|
+
isDatabaseService,registerTriggers});
|
|
117
130
|
//# sourceMappingURL=library.cjs.map
|
package/dist/library.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export * from './metadata/service.js';
|
|
|
3
3
|
export * from './metadata/table.js';
|
|
4
4
|
export * from './metadata/schema.js';
|
|
5
5
|
export * from './errors/service.js';
|
|
6
|
+
export * from './errors/scalability.js';
|
|
7
|
+
export * from './errors/engine.js';
|
|
6
8
|
export * from './errors/table.js';
|
|
7
9
|
export * from './errors/schema.js';
|
|
8
10
|
export * from './errors/relations.js';
|
package/dist/library.mjs
CHANGED
|
@@ -1,113 +1,124 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
import{createTrigger as
|
|
3
|
-
getLinkedServiceList as
|
|
4
|
-
import{isModelProperty as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import{registerTriggers as sr}from"@ez4/common/library";import{registerTriggers as ir}from"@ez4/schema/library";
|
|
2
|
+
import{createTrigger as pr}from"@ez4/project/library";import{DuplicateServiceError as Kt,InvalidServicePropertyError as Wt,isExternalDeclaration as Xt,
|
|
3
|
+
getLinkedServiceList as Yt,getLinkedVariableList as Zt,getPropertyTuple as Lt,getModelMembers as er}from"@ez4/common/library";
|
|
4
|
+
import{isModelProperty as tr}from"@ez4/reflection";var H="@ez4/database",lr=e=>e.type===H;import{IncompleteTypeError as Se}from"@ez4/common/library";var b=class extends Se{constructor(r,t){
|
|
5
|
+
super("Incomplete database service",r,t)}};import{IncorrectTypeError as De,InvalidTypeError as he,TypeError as M}from"@ez4/common/library";
|
|
6
|
+
var T=class extends he{constructor(r){super("Invalid table relations type",void 0,
|
|
7
|
+
"Database.Relations",r)}},f=class extends De{constructor(t,n){super("Incorrect t\
|
|
8
|
+
able relations type",t,"Database.Relations",n);this.schemaType=t}},y=class extends M{constructor(t,n){
|
|
8
9
|
super(`Target ${t} must follow the pattern 'column@alias'.`,n);this.relationSource=
|
|
9
|
-
t}},x=class extends
|
|
10
|
-
n);this.relationTable=t}},
|
|
11
|
-
umn ${t} don't exists.`,n);this.relationColumn=t}},g=class extends
|
|
10
|
+
t}},x=class extends M{constructor(t,n){super(`Relation table ${t} don't exists.`,
|
|
11
|
+
n);this.relationTable=t}},d=class extends M{constructor(t,n){super(`Relation col\
|
|
12
|
+
umn ${t} don't exists.`,n);this.relationColumn=t}},g=class extends M{constructor(t,n){
|
|
12
13
|
super(`Relation alias ${t} can't override table columns.`,n);this.relationAlias=
|
|
13
|
-
t}};import{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
14
|
+
t}};import{InvalidServicePropertyError as Oe,getModelMembers as ke,getPropertyNumber as Re,
|
|
15
|
+
getObjectMembers as Ae,getReferenceType as we}from"@ez4/common/library";import{isModelProperty as Ce,
|
|
16
|
+
isTypeObject as ze,isTypeReference as Ue}from"@ez4/reflection";import{isAnyNumber as F}from"@ez4/utils";import{IncompleteTypeError as ve}from"@ez4/common/library";var I=class extends ve{constructor(r,t){
|
|
17
|
+
super("Incomplete database scalability",r,t)}};import{hasHeritageType as m,isClassDeclaration as Ee,isModelDeclaration as V}from"@ez4/common/library";
|
|
18
|
+
import{isTypeCallback as je,isTypeFunction as Pe}from"@ez4/reflection";var S=e=>Ee(
|
|
19
|
+
e)&&m(e,"Database.Service"),D=e=>V(e)&&m(e,"Database.Engine"),$=e=>V(e)&&m(e,"Da\
|
|
20
|
+
tabase.Table"),G=e=>je(e)||Pe(e),Q=e=>m(e,"Database.Relations"),B=e=>m(e,"Databa\
|
|
21
|
+
se.Indexes"),_=e=>m(e,"Database.Schema"),J=e=>m(e,"Database.Stream");var X=(e,r,t,n)=>{if(!Ue(e))return K(e,r,n);let a=we(e,t);return a?K(a,r,n):null},
|
|
22
|
+
Ne=e=>F(e.minCapacity)&&F(e.maxCapacity),K=(e,r,t)=>D(e)?W(e,r,ke(e),t):ze(e)?W(
|
|
23
|
+
e,r,Ae(e),t):null,W=(e,r,t,n)=>{let a={},o=new Set(["minCapacity","maxCapacity"]);
|
|
24
|
+
for(let s of t)if(!(!Ce(s)||s.inherited))switch(s.name){default:n.push(new Oe(r.
|
|
25
|
+
name,s.name,e.file));break;case"minCapacity":case"maxCapacity":let i=Re(s);F(i)&&
|
|
26
|
+
(a[s.name]=i,o.delete(s.name));break}return Ne(a)?a:(n.push(new I([...o],e.file)),
|
|
27
|
+
null)};import{isModelProperty as Fe,isTypeObject as qe,isTypeReference as Ve}from"@ez4/reflection";
|
|
28
|
+
import{InvalidServicePropertyError as $e,getModelMembers as Ge,getObjectMembers as Qe,
|
|
29
|
+
getPropertyString as Be,getPropertyStringIn as u,getReferenceType as _e}from"@ez4/common/library";import{IncompleteTypeError as He}from"@ez4/common/library";var h=class extends He{constructor(r,t){
|
|
30
|
+
super("Incomplete database engine",r,t)}};var L=(e,r,t,n)=>{if(!Ve(e))return Y(e,r,n);let a=_e(e,t);return a?Y(a,r,n):null},
|
|
31
|
+
Je=e=>!!e.name&&!!e.parametersMode&&!!e.transactionMode&&!!e.insensitiveMode&&!!e.
|
|
32
|
+
paginationMode&&!!e.orderMode,Y=(e,r,t)=>D(e)?Z(e,r,Ge(e),t):qe(e)?Z(e,r,Qe(e),t):
|
|
33
|
+
null,Z=(e,r,t,n)=>{let a={},o=new Set(["name","parametersMode","transactionMode",
|
|
34
|
+
"insensitiveMode","paginationMode","orderMode"]);for(let s of t)if(!(!Fe(s)||s.inherited))
|
|
35
|
+
switch(s.name){default:n.push(new $e(r.name,s.name,e.file));break;case"name":(a.
|
|
36
|
+
name=Be(s))&&o.delete(s.name);break;case"parametersMode":(a.parametersMode=u(s,[
|
|
37
|
+
"index","both"]))&&o.delete(s.name);break;case"transactionMode":(a.transactionMode=
|
|
38
|
+
u(s,["static","interactive"]))&&o.delete(s.name);break;case"insensitiveMode":(a.
|
|
39
|
+
insensitiveMode=u(s,["unsupported","enabled"]))&&o.delete(s.name);break;case"pag\
|
|
40
|
+
inationMode":(a.paginationMode=u(s,["cursor","offset"]))&&o.delete(s.name);break;case"\
|
|
41
|
+
orderMode":(a.orderMode=u(s,["any","index"]))&&o.delete(s.name);break}return Je(
|
|
42
|
+
a)?a:(n.push(new h([...o],e.file)),null)};import{InvalidServicePropertyError as Ht,getModelMembers as Ft,getObjectMembers as qt,
|
|
43
|
+
getPropertyString as Vt,getReferenceType as $t}from"@ez4/common/library";import{
|
|
44
|
+
isModelProperty as Gt,isTypeObject as Qt,isTypeReference as Bt}from"@ez4/reflection";import{IncompleteTypeError as Ke}from"@ez4/common/library";var v=class extends Ke{constructor(r,t){
|
|
45
|
+
super("Incomplete database table",r,t)}};import{IncorrectTypeError as We,InvalidTypeError as Xe,TypeError as ee}from"@ez4/common/library";
|
|
46
|
+
var E=class extends Xe{constructor(r){super("Invalid table indexes type",void 0,
|
|
47
|
+
"Database.Indexes",r)}},j=class extends We{constructor(t,n){super("Incorrect tab\
|
|
48
|
+
le indexes type",t,"Database.Indexes",n);this.schemaType=t}},P=class extends ee{constructor(t,n){
|
|
39
49
|
super(`Invalid index type, ${t} must follow one of the Index options.`,n);this.indexName=
|
|
40
|
-
t}},
|
|
41
|
-
be valid column.`,n);this.indexName=t}};import{isModelDeclaration as
|
|
42
|
-
getReferenceType as
|
|
43
|
-
isTypeReference as
|
|
44
|
-
|
|
45
|
-
null):(t.push(new
|
|
46
|
-
a.inherited)continue;let o=
|
|
47
|
-
let[i,p]=s.split("@",2),[l,
|
|
48
|
-
targetColumn:i,targetAlias:p})}return n};import{isModelDeclaration as
|
|
49
|
-
getReferenceType as
|
|
50
|
-
isTypeReference as
|
|
51
|
-
|
|
52
|
-
null):(t.push(new
|
|
53
|
-
a)||a.inherited)continue;let o=a.name,s=
|
|
54
|
-
|
|
55
|
-
return t.push(new
|
|
56
|
-
import{getObjectSchema as
|
|
57
|
-
isTypeObject as
|
|
58
|
-
var
|
|
59
|
-
Database.Schema",r)}},
|
|
60
|
-
schema type",t,"Database.Schema",n);this.schemaType=t}};var
|
|
61
|
-
n):null},
|
|
62
|
-
null):(n.push(new
|
|
63
|
-
getModelMembers as
|
|
64
|
-
getReferenceType as
|
|
65
|
-
isTypeReference as
|
|
66
|
-
var
|
|
67
|
-
super("Invalid table stream type",void 0,"Database.Stream",r)}},
|
|
68
|
-
super("Incorrect table stream type",t,"Database.Stream",n);this.streamType=t}};import{IncompleteTypeError as
|
|
69
|
-
super("Incomplete stream handler",r,t)}};var
|
|
50
|
+
t}},O=class extends ee{constructor(t,n){super(`Invalid index reference, ${t} mus\
|
|
51
|
+
t be valid column.`,n);this.indexName=t}};import{isModelDeclaration as Ye,getModelMembers as Ze,getObjectMembers as Le,getPropertyString as et,
|
|
52
|
+
getReferenceType as tt}from"@ez4/common/library";import{isModelProperty as rt,isTypeObject as nt,
|
|
53
|
+
isTypeReference as at}from"@ez4/reflection";var ne=(e,r,t,n)=>{if(!at(e))return te(e,r,n);let a=tt(e,t);return a?te(a,r,n):null},
|
|
54
|
+
te=(e,r,t)=>nt(e)?re(e,Le(e),t):Ye(e)?Q(e)?re(e,Ze(e),t):(t.push(new f(e.name,e.
|
|
55
|
+
file)),null):(t.push(new T(r.file)),null),re=(e,r,t)=>{let n=[];for(let a of r){
|
|
56
|
+
if(!rt(a)||a.inherited)continue;let o=et(a),s=a.name;if(!o)return t.push(new y(s,
|
|
57
|
+
e.file)),null;let[i,p]=s.split("@",2),[l,c]=o.split(":",2);n.push({sourceTable:l,
|
|
58
|
+
sourceColumn:c,targetColumn:i,targetAlias:p})}return n};import{isModelDeclaration as ot,getModelMembers as st,getObjectMembers as it,getPropertyString as pt,
|
|
59
|
+
getReferenceType as lt}from"@ez4/common/library";import{isModelProperty as mt,isTypeObject as ct,
|
|
60
|
+
isTypeReference as dt}from"@ez4/reflection";var se=(e,r,t,n)=>{if(!dt(e))return ae(e,r,n);let a=lt(e,t);return a?ae(a,r,n):null},
|
|
61
|
+
ae=(e,r,t)=>ct(e)?oe(e,it(e),t):ot(e)?B(e)?oe(e,st(e),t):(t.push(new j(e.name,e.
|
|
62
|
+
file)),null):(t.push(new E(r.file)),null),oe=(e,r,t)=>{let n=[];for(let a of r){
|
|
63
|
+
if(!mt(a)||a.inherited)continue;let o=a.name,s=pt(a);switch(s){case"primary":case"\
|
|
64
|
+
secondary":case"unique":case"ttl":n.push({name:o,columns:o.split(":"),type:s});break;default:
|
|
65
|
+
return t.push(new P(o,e.file)),null}}return n};import{getReferenceType as Tt,isModelDeclaration as ft}from"@ez4/common/library";
|
|
66
|
+
import{getObjectSchema as yt,isObjectSchema as xt}from"@ez4/schema/library";import{
|
|
67
|
+
isTypeObject as gt,isTypeReference as Mt}from"@ez4/reflection";import{IncorrectTypeError as ut,InvalidTypeError as bt}from"@ez4/common/library";
|
|
68
|
+
var k=class extends bt{constructor(r){super("Invalid table schema type",void 0,"\
|
|
69
|
+
Database.Schema",r)}},R=class extends ut{constructor(t,n){super("Incorrect table\
|
|
70
|
+
schema type",t,"Database.Schema",n);this.schemaType=t}};var le=(e,r,t,n)=>{if(!Mt(e))return ie(e,r,t,n);let a=Tt(e,t);return a?ie(a,r,t,
|
|
71
|
+
n):null},ie=(e,r,t,n)=>gt(e)?pe(e,t):ft(e)?_(e)?pe(e,t):(n.push(new R(e.name,e.file)),
|
|
72
|
+
null):(n.push(new k(r.file)),null),pe=(e,r)=>{let t=yt(e,r);return t&&xt(t)?t:null};import{InvalidServicePropertyError as Et,isModelDeclaration as jt,getLinkedVariableList as Pt,
|
|
73
|
+
getModelMembers as Ot,getObjectMembers as kt,getPropertyNumber as Rt,getServiceListener as At,
|
|
74
|
+
getReferenceType as wt}from"@ez4/common/library";import{isModelProperty as Ct,isTypeObject as zt,
|
|
75
|
+
isTypeReference as Ut}from"@ez4/reflection";import{IncompleteTypeError as It,IncorrectTypeError as St,InvalidTypeError as Dt}from"@ez4/common/library";
|
|
76
|
+
var A=class extends It{constructor(r,t){super("Incomplete table stream",r,t)}},w=class extends Dt{constructor(r){
|
|
77
|
+
super("Invalid table stream type",void 0,"Database.Stream",r)}},C=class extends St{constructor(t,n){
|
|
78
|
+
super("Incorrect table stream type",t,"Database.Stream",n);this.streamType=t}};import{IncompleteTypeError as ht}from"@ez4/common/library";var z=class extends ht{constructor(r,t){
|
|
79
|
+
super("Incomplete stream handler",r,t)}};var me=(e,r,t)=>{if(!G(e))return null;let n={},a=new Set(["name","file","change"]);
|
|
70
80
|
return e.description&&(n.description=e.description),(n.name=e.name)&&a.delete("n\
|
|
71
81
|
ame"),(n.file=e.file)&&a.delete("file"),e.parameters&&a.delete("change"),a.size===
|
|
72
|
-
0&&
|
|
73
|
-
n):null},
|
|
74
|
-
r,
|
|
75
|
-
let o={},s=new Set(["handler"]);for(let i of t)if(!(!
|
|
76
|
-
name){default:a.push(new
|
|
77
|
-
|
|
78
|
-
logRetention":case"timeout":o[i.name]=
|
|
79
|
-
i,a);break}return
|
|
80
|
-
n):null},
|
|
81
|
-
t,n):
|
|
82
|
-
chema","indexes"]);for(let p of t)if(!(!
|
|
83
|
-
a.push(new
|
|
84
|
-
name);break;case"schema":(o.schema=
|
|
85
|
-
indexes":(o.indexes=
|
|
86
|
-
relations=
|
|
87
|
-
o))return a.push(new
|
|
88
|
-
length?(a.push(...i),null):o},
|
|
89
|
-
columns:s}of r)s.some(p=>!n[p])&&a.push(new
|
|
90
|
-
type:
|
|
91
|
-
a))if(!(!
|
|
92
|
-
i));break;case"client":break;case"
|
|
93
|
-
l.name);break;case"
|
|
94
|
-
|
|
95
|
-
o
|
|
96
|
-
continue}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
r),n=[];for(let{relations:a,
|
|
100
|
-
for(let p of a){let{sourceTable:l,
|
|
101
|
-
i[
|
|
102
|
-
|
|
103
|
-
[]
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
82
|
+
0&&vt(n)?n:(t.push(new z([...a],e.file)),null)},vt=e=>!!e.name&&!!e.file;var ue=(e,r,t,n)=>{if(!Ut(e))return ce(e,r,t,n);let a=wt(e,t);return a?ce(a,r,t,
|
|
83
|
+
n):null},Nt=e=>!!e.handler,ce=(e,r,t,n)=>zt(e)?de(e,r,kt(e),t,n):jt(e)?J(e)?de(e,
|
|
84
|
+
r,Ot(e),t,n):(n.push(new C(e.name,e.file)),null):(n.push(new w(r.file)),null),de=(e,r,t,n,a)=>{
|
|
85
|
+
let o={},s=new Set(["handler"]);for(let i of t)if(!(!Ct(i)||i.inherited))switch(i.
|
|
86
|
+
name){default:a.push(new Et(r.name,i.name,e.file));break;case"handler":o.handler=
|
|
87
|
+
me(i.value,n,a);break;case"listener":o.listener=At(i.value,a);break;case"memory":case"\
|
|
88
|
+
logRetention":case"timeout":o[i.name]=Rt(i);break;case"variables":o.variables=Pt(
|
|
89
|
+
i,a);break}return Nt(o)?o:(a.push(new A([...s],e.file)),null)};var fe=(e,r,t,n)=>{if(!Bt(e))return be(e,r,t,n);let a=$t(e,t);return a?be(a,r,t,
|
|
90
|
+
n):null},_t=e=>!!e.name&&!!e.schema&&!!e.indexes,be=(e,r,t,n)=>$(e)?Te(e,r,Ft(e),
|
|
91
|
+
t,n):Qt(e)?Te(e,r,qt(e),t,n):null,Te=(e,r,t,n,a)=>{let o={},s=new Set(["name","s\
|
|
92
|
+
chema","indexes"]);for(let p of t)if(!(!Gt(p)||p.inherited))switch(p.name){default:
|
|
93
|
+
a.push(new Ht(r.name,p.name,e.file));break;case"name":(o.name=Vt(p))&&s.delete(p.
|
|
94
|
+
name);break;case"schema":(o.schema=le(p.value,e,n,a))&&s.delete(p.name);break;case"\
|
|
95
|
+
indexes":(o.indexes=se(p.value,e,n,a))&&s.delete(p.name);break;case"relations":o.
|
|
96
|
+
relations=ne(p.value,e,n,a);break;case"stream":o.stream=ue(p.value,r,n,a);break}
|
|
97
|
+
if(!_t(o))return a.push(new v([...s],e.file)),null;let i=Jt(e,o.indexes,o.schema);
|
|
98
|
+
return i.length?(a.push(...i),null):o},Jt=(e,r,t)=>{let n=t.properties,a=[];for(let{
|
|
99
|
+
name:o,columns:s}of r)s.some(p=>!n[p])&&a.push(new O(o,e.file));return a};var xe=e=>{let r={},t=[];for(let n in e){let a=e[n];if(!S(a)||Xt(a))continue;let o={
|
|
100
|
+
type:H,extras:{}},s=new Set(["engine","tables"]),i=a.file;o.name=a.name;for(let l of er(
|
|
101
|
+
a))if(!(!tr(l)||l.inherited))switch(l.name){default:t.push(new Wt(o.name,l.name,
|
|
102
|
+
i));break;case"client":break;case"scalability":(o.scalability=X(l.value,a,e,t))&&
|
|
103
|
+
s.delete(l.name);break;case"engine":(o.engine=L(l.value,a,e,t))&&s.delete(l.name);
|
|
104
|
+
break;case"tables":(o.tables=nr(l,a,e,t))&&s.delete(l.name);break;case"variables":
|
|
105
|
+
o.variables=Zt(l,t);break;case"services":o.services=Yt(l,e,t);break}if(!rr(o)){t.
|
|
106
|
+
push(new b([...s],i));continue}let p=ar(a,o.tables);if(p.length){t.push(...p);continue}
|
|
107
|
+
if(r[a.name]){t.push(new Kt(a.name,i));continue}r[a.name]=o}return{services:r,errors:t}},
|
|
108
|
+
rr=e=>!!e.name&&!!e.tables&&!!e.extras,nr=(e,r,t,n)=>{let a=Lt(e)??[],o=[];for(let s of a){
|
|
109
|
+
let i=fe(s,r,t,n);i&&o.push(i)}return o},ar=(e,r)=>{let t=or(r),n=[];for(let{relations:a,
|
|
110
|
+
schema:o,indexes:s}of r){if(!a)continue;let i=o.properties;for(let p of a){let{sourceTable:l,
|
|
111
|
+
sourceColumn:c,targetColumn:U,targetAlias:q}=p;i[U]||n.push(new d(U,e.file)),i[q]&&
|
|
112
|
+
n.push(new g(q,e.file));let N=t[l]?.schema.properties;N||n.push(new x(l,e.file)),
|
|
113
|
+
N&&!N[c]&&n.push(new d(c,e.file));let Ie=t[l]?.indexes??[];p.sourceIndex=ye(Ie,c),
|
|
114
|
+
p.targetIndex=ye(s,U)}}return n},ye=(e,r)=>e.find(({name:t})=>t===r)?.type,or=e=>e.
|
|
115
|
+
reduce((r,t)=>({...r,[t.name]:t}),{});var ge=e=>S(e)?e.name:null;var Me=!1,sa=()=>{Me||(sr(),ir(),pr("@ez4/database",{"metadata:getServices":xe,"\
|
|
116
|
+
metadata:getLinkedService":ge}),Me=!0)};export{h as IncompleteEngineError,z as IncompleteHandlerError,I as IncompleteScalabilityError,
|
|
117
|
+
b as IncompleteServiceError,A as IncompleteStreamError,v as IncompleteTableError,
|
|
118
|
+
j as IncorrectIndexesTypeError,f as IncorrectRelationsTypeError,R as IncorrectSchemaTypeError,
|
|
119
|
+
C as IncorrectStreamTypeError,O as InvalidIndexReferenceError,P as InvalidIndexTypeError,
|
|
120
|
+
E as InvalidIndexesTypeError,g as InvalidRelationAliasError,d as InvalidRelationColumnError,
|
|
121
|
+
x as InvalidRelationTableError,y as InvalidRelationTargetError,T as InvalidRelationsTypeError,
|
|
122
|
+
k as InvalidSchemaTypeError,w as InvalidStreamTypeError,H as ServiceType,xe as getDatabaseServices,
|
|
123
|
+
fe as getDatabaseTable,le as getTableSchema,lr as isDatabaseService,sa as registerTriggers};
|
|
113
124
|
//# sourceMappingURL=library.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
|
+
import { DatabaseScalability } from '../types/scalability.js';
|
|
3
|
+
export declare const getDatabaseScalability: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => DatabaseScalability | null;
|
|
@@ -52,6 +52,13 @@ export declare namespace Database {
|
|
|
52
52
|
* Service engine.
|
|
53
53
|
*/
|
|
54
54
|
type Engine = DatabaseEngine;
|
|
55
|
+
/**
|
|
56
|
+
* Service scalability configuration.
|
|
57
|
+
*/
|
|
58
|
+
interface Scalability {
|
|
59
|
+
minCapacity: number;
|
|
60
|
+
maxCapacity: number;
|
|
61
|
+
}
|
|
55
62
|
/**
|
|
56
63
|
* Table stream.
|
|
57
64
|
*/
|
|
@@ -119,6 +126,10 @@ export declare namespace Database {
|
|
|
119
126
|
* Describe all available tables for the service.
|
|
120
127
|
*/
|
|
121
128
|
abstract tables: Table<any>[];
|
|
129
|
+
/**
|
|
130
|
+
* Scalability configuration.
|
|
131
|
+
*/
|
|
132
|
+
scalability: Scalability;
|
|
122
133
|
/**
|
|
123
134
|
* Service client.
|
|
124
135
|
*/
|
package/dist/types/service.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ServiceMetadata } from '@ez4/project/library';
|
|
2
|
+
import type { DatabaseScalability } from './scalability.js';
|
|
2
3
|
import type { DatabaseEngine } from './engine.js';
|
|
3
4
|
import type { DatabaseTable } from './table.js';
|
|
4
5
|
export declare const ServiceType = "@ez4/database";
|
|
5
6
|
export type DatabaseService = ServiceMetadata & {
|
|
6
7
|
type: typeof ServiceType;
|
|
8
|
+
scalability?: DatabaseScalability | null;
|
|
7
9
|
engine: DatabaseEngine;
|
|
8
10
|
tables: DatabaseTable[];
|
|
9
11
|
name: string;
|
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.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"live:publish": "npm run test && npm publish --access public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ez4/common": "^0.
|
|
46
|
-
"@ez4/project": "^0.
|
|
47
|
-
"@ez4/reflection": "^0.
|
|
48
|
-
"@ez4/schema": "^0.
|
|
49
|
-
"@ez4/utils": "^0.
|
|
45
|
+
"@ez4/common": "^0.21.0",
|
|
46
|
+
"@ez4/project": "^0.21.0",
|
|
47
|
+
"@ez4/reflection": "^0.21.0",
|
|
48
|
+
"@ez4/schema": "^0.21.0",
|
|
49
|
+
"@ez4/utils": "^0.21.0"
|
|
50
50
|
}
|
|
51
51
|
}
|