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