@ez4/database 0.3.0 → 0.5.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/stream.d.ts +8 -1
- package/dist/library.cjs +64 -62
- package/dist/library.mjs +59 -53
- package/dist/metadata/stream.d.ts +4 -2
- package/dist/metadata/utils.d.ts +3 -3
- package/dist/triggers/register.d.ts +1 -4
- package/package.json +9 -6
package/dist/errors/stream.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { IncompleteTypeError } from '@ez4/common/library';
|
|
1
|
+
import { IncompleteTypeError, IncorrectTypeError, InvalidTypeError } from '@ez4/common/library';
|
|
2
2
|
export declare class IncompleteStreamError extends IncompleteTypeError {
|
|
3
3
|
constructor(properties: string[], fileName?: string);
|
|
4
4
|
}
|
|
5
|
+
export declare class InvalidStreamTypeError extends InvalidTypeError {
|
|
6
|
+
constructor(fileName?: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class IncorrectStreamTypeError extends IncorrectTypeError {
|
|
9
|
+
streamType: string;
|
|
10
|
+
constructor(streamType: string, fileName?: string);
|
|
11
|
+
}
|
package/dist/library.cjs
CHANGED
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let o of
|
|
3
|
-
|
|
4
|
-
IncompleteTableError:()=>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
super("Incomplete database service",t,r)}};var
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";var C=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,a)=>{if(t&&
|
|
2
|
+
typeof t=="object"||typeof t=="function")for(let o of ue(t))!be.call(e,o)&&o!==r&&
|
|
3
|
+
C(e,o,{get:()=>t[o],enumerable:!(a=ce(t,o))||a.enumerable});return e};var de=e=>Te(C({},"__esModule",{value:!0}),e);var De={};fe(De,{IncompleteHandlerError:()=>A,IncompleteServiceError:()=>x,IncompleteStreamError:()=>j,
|
|
4
|
+
IncompleteTableError:()=>g,IncorrectIndexesTypeError:()=>M,IncorrectSchemaTypeError:()=>D,
|
|
5
|
+
IncorrectStreamTypeError:()=>P,InvalidIndexReferenceError:()=>I,InvalidIndexTypeError:()=>h,
|
|
6
|
+
InvalidIndexesTypeError:()=>S,InvalidSchemaTypeError:()=>v,InvalidStreamTypeError:()=>E,
|
|
7
|
+
ServiceType:()=>k,getDatabaseServices:()=>F,getDatabaseTable:()=>q,getTableSchema:()=>N,
|
|
8
|
+
isDatabaseService:()=>ye,registerTriggers:()=>ve});module.exports=de(De);var pe=require("@ez4/common/library"),me=require("@ez4/schema/library"),le=require("@ez4/project/library");var c=require("@ez4/common/library"),se=require("@ez4/reflection");var k="@ez4/database",ye=e=>e.type===k;var V=require("@ez4/common/library"),x=class extends V.IncompleteTypeError{constructor(t,r){
|
|
9
|
+
super("Incomplete database service",t,r)}};var p=require("@ez4/common/library"),w=require("@ez4/reflection"),z=e=>(0,p.isClassDeclaration)(
|
|
10
|
+
e)&&(0,p.hasHeritageType)(e,"Database.Service"),U=e=>(0,p.isModelDeclaration)(e)&&
|
|
11
|
+
(0,p.hasHeritageType)(e,"Database.Table"),$=e=>(0,w.isTypeCallback)(e)||(0,w.isTypeFunction)(
|
|
12
|
+
e),_=e=>(0,p.hasHeritageType)(e,"Database.Indexes"),B=e=>(0,p.hasHeritageType)(e,
|
|
13
|
+
"Database.Schema"),G=e=>(0,p.hasHeritageType)(e,"Database.Stream");var d=require("@ez4/common/library"),y=require("@ez4/reflection");var J=require("@ez4/common/library"),g=class extends J.IncompleteTypeError{constructor(t,r){
|
|
14
|
+
super("Incomplete database table",t,r)}};var u=require("@ez4/common/library"),S=class extends u.InvalidTypeError{constructor(t){
|
|
15
|
+
super("Invalid table indexes type",void 0,"Database.Indexes",t)}},M=class extends u.IncorrectTypeError{constructor(r,a){
|
|
12
16
|
super("Incorrect table indexes type",r,"Database.Indexes",a);this.schemaType=r}},
|
|
13
|
-
|
|
14
|
-
t follow one of the Index options.`,a);this.indexName=r}},
|
|
15
|
-
super(`Invalid index reference, ${r} must be valid column.`,a);this.indexName=r}};var
|
|
16
|
-
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
e)
|
|
20
|
-
e)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return r.push(new M(s,e.file)),null}}return a};var l=require("@ez4/common/library"),f=require("@ez4/reflection");var X=require("@ez4/common/library"),D=class extends X.IncompleteTypeError{constructor(t,r){
|
|
32
|
-
super("Incomplete table stream",t,r)}};var Y=require("@ez4/common/library"),j=class extends Y.IncompleteTypeError{constructor(t,r){
|
|
33
|
-
super("Incomplete stream handler",t,r)}};var Z=(e,t,r)=>{if(!B(e))return null;let a={},o=new Set(["name","file","change"]);
|
|
17
|
+
h=class extends u.TypeError{constructor(r,a){super(`Invalid index type, ${r} mus\
|
|
18
|
+
t follow one of the Index options.`,a);this.indexName=r}},I=class extends u.TypeError{constructor(r,a){
|
|
19
|
+
super(`Invalid index reference, ${r} must be valid column.`,a);this.indexName=r}};var R=require("@ez4/reflection"),Q=require("@ez4/common/library"),H=require("@ez4/schema/library");var O=require("@ez4/common/library"),v=class extends O.InvalidTypeError{constructor(t){
|
|
20
|
+
super("Invalid table schema type",void 0,"Database.Schema",t)}},D=class extends O.IncorrectTypeError{constructor(r,a){
|
|
21
|
+
super("Incorrect table schema type",r,"Database.Schema",a);this.schemaType=r}};var N=(e,t,r,a)=>{if(!(0,R.isTypeReference)(e))return K(e,t,r,a);let o=r[e.path];
|
|
22
|
+
return o?K(o,t,r,a):null},K=(e,t,r,a)=>(0,R.isTypeObject)(e)?(0,H.getObjectSchema)(
|
|
23
|
+
e,r):(0,Q.isModelDeclaration)(e)?B(e)?(0,H.getObjectSchema)(e,r):(a.push(new D(e.
|
|
24
|
+
name,e.file)),null):(a.push(new v(t.file)),null);var l=require("@ez4/common/library"),b=require("@ez4/reflection");var Y=(e,t,r,a)=>{if(!(0,b.isTypeReference)(e))return W(e,t,a);let o=r[e.path];return o?
|
|
25
|
+
W(o,t,a):null},W=(e,t,r)=>(0,b.isTypeObject)(e)?X(e,(0,l.getObjectMembers)(e),r):
|
|
26
|
+
(0,l.isModelDeclaration)(e)?_(e)?X(e,(0,l.getModelMembers)(e),r):(r.push(new M(e.
|
|
27
|
+
name,e.file)),null):(r.push(new S(t.file)),null),X=(e,t,r)=>{let a={};for(let o of t){
|
|
28
|
+
if(!(0,b.isModelProperty)(o)||o.inherited)continue;let n=o.name,i=(0,l.getPropertyString)(
|
|
29
|
+
o);switch(i){case"primary":case"regular":case"unique":case"ttl":a[n]=i;break;default:
|
|
30
|
+
return r.push(new h(n,e.file)),null}}return a};var m=require("@ez4/common/library"),T=require("@ez4/reflection");var f=require("@ez4/common/library"),j=class extends f.IncompleteTypeError{constructor(t,r){
|
|
31
|
+
super("Incomplete table stream",t,r)}},E=class extends f.InvalidTypeError{constructor(t){
|
|
32
|
+
super("Invalid table stream type",void 0,"Database.Stream",t)}},P=class extends f.IncorrectTypeError{constructor(r,a){
|
|
33
|
+
super("Incorrect table stream type",r,"Database.Stream",a);this.streamType=r}};var Z=require("@ez4/common/library"),A=class extends Z.IncompleteTypeError{constructor(t,r){
|
|
34
|
+
super("Incomplete stream handler",t,r)}};var L=(e,t,r)=>{if(!$(e))return null;let a={},o=new Set(["name","file","change"]);
|
|
34
35
|
return e.description&&(a.description=e.description),(a.name=e.name)&&o.delete("n\
|
|
35
36
|
ame"),(a.file=e.file)&&o.delete("file"),e.parameters&&o.delete("change"),o.size===
|
|
36
|
-
0&&
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
name
|
|
42
|
-
(0,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
n
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(0,c.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
IncompleteTableError,IncorrectIndexesTypeError,IncorrectSchemaTypeError,
|
|
64
|
-
InvalidIndexTypeError,InvalidIndexesTypeError,InvalidSchemaTypeError,
|
|
65
|
-
getDatabaseServices,getDatabaseTable,getTableSchema,
|
|
37
|
+
0&&xe(a)?a:(r.push(new A([...o],e.file)),null)},xe=e=>!!e.name&&!!e.file;var te=(e,t,r,a)=>{if(!(0,T.isTypeReference)(e))return ee(e,t,r,a);let o=r[e.path];
|
|
38
|
+
return o?ee(o,t,r,a):null},ge=e=>!!e.handler,ee=(e,t,r,a)=>(0,T.isTypeObject)(e)?
|
|
39
|
+
re(e,(0,m.getObjectMembers)(e),r,a):(0,m.isModelDeclaration)(e)?G(e)?re(e,(0,m.getModelMembers)(
|
|
40
|
+
e),r,a):(a.push(new P(e.name,e.file)),null):(a.push(new E(t.file)),null),re=(e,t,r,a)=>{
|
|
41
|
+
let o={},n=new Set(["handler"]);for(let i of t)if(!(!(0,T.isModelProperty)(i)||i.
|
|
42
|
+
inherited))switch(i.name){case"handler":o.handler=L(i.value,r,a);break;case"time\
|
|
43
|
+
out":case"memory":{let s=(0,m.getPropertyNumber)(i);s!=null&&(o[i.name]=s);break}case"\
|
|
44
|
+
variables":o.variables=(0,m.getLinkedVariableList)(i,a);break}return ge(o)?o:(a.
|
|
45
|
+
push(new j([...n],e.file)),null)};var q=(e,t,r)=>{if(!(0,y.isTypeReference)(e))return ae(e,t,r);let a=t[e.path];return a?
|
|
46
|
+
ae(a,t,r):null},Se=e=>!!e.name&&!!e.schema&&!!e.indexes,ae=(e,t,r)=>U(e)?oe(e,(0,d.getModelMembers)(
|
|
47
|
+
e),t,r):(0,y.isTypeObject)(e)?oe(e,(0,d.getObjectMembers)(e),t,r):null,oe=(e,t,r,a)=>{
|
|
48
|
+
let o={},n=new Set(["name","schema","indexes"]);for(let s of t)if(!(!(0,y.isModelProperty)(
|
|
49
|
+
s)||s.inherited))switch(s.name){case"name":(o.name=(0,d.getPropertyString)(s))&&
|
|
50
|
+
n.delete(s.name);break;case"indexes":{(o.indexes=Y(s.value,e,r,a))&&n.delete(s.name);
|
|
51
|
+
break}case"schema":{(o.schema=N(s.value,e,r,a))&&n.delete(s.name);break}case"str\
|
|
52
|
+
eam":{o.stream=te(s.value,e,r,a);break}}if(!Se(o))return a.push(new g([...n],e.file)),
|
|
53
|
+
null;let i=Me(e,o.indexes,o.schema);return i.length?(a.push(...i),null):o},Me=(e,t,r)=>{
|
|
54
|
+
let a=r.properties,o=[];for(let n in t)for(let i of n.split(":"))a[i]||o.push(new I(
|
|
55
|
+
n,e.file));return o};var F=e=>{let t={},r=[];for(let a in e){let o=e[a];if(!z(o))continue;let n={type:k},
|
|
56
|
+
i=new Set(["tables"]);n.name=o.name;for(let s of(0,c.getModelMembers)(o))if(!(!(0,se.isModelProperty)(
|
|
57
|
+
s)||s.inherited))switch(s.name){case"tables":(n.tables=Ie(s,e,r))&&i.delete(s.name);
|
|
58
|
+
break;case"variables":n.variables=(0,c.getLinkedVariableList)(s,r);break;case"se\
|
|
59
|
+
rvices":n.services=(0,c.getLinkedServiceList)(s,e,r);break}if(!he(n)){r.push(new x(
|
|
60
|
+
[...i],o.file));continue}t[o.name]=n}return{services:t,errors:r}},he=e=>!!e.name&&
|
|
61
|
+
!!e.tables,Ie=(e,t,r)=>{let a=(0,c.getPropertyTuple)(e)??[],o=[];for(let n of a){
|
|
62
|
+
let i=q(n,t,r);i&&o.push(i)}return o};var ne=e=>z(e)?e.name:null;var ie=!1,ve=()=>{ie||((0,pe.registerTriggers)(),(0,me.registerTriggers)(),(0,le.createTrigger)(
|
|
63
|
+
"@ez4/database",{"metadata:getServices":F,"metadata:getLinkedService":ne}),ie=!0)};0&&(module.exports={IncompleteHandlerError,IncompleteServiceError,IncompleteStreamError,
|
|
64
|
+
IncompleteTableError,IncorrectIndexesTypeError,IncorrectSchemaTypeError,IncorrectStreamTypeError,
|
|
65
|
+
InvalidIndexReferenceError,InvalidIndexTypeError,InvalidIndexesTypeError,InvalidSchemaTypeError,
|
|
66
|
+
InvalidStreamTypeError,ServiceType,getDatabaseServices,getDatabaseTable,getTableSchema,
|
|
67
|
+
isDatabaseService,registerTriggers});
|
package/dist/library.mjs
CHANGED
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
import{createTrigger as
|
|
3
|
-
import{isModelProperty as
|
|
4
|
-
super("Incomplete database service",t,r)}};import{
|
|
5
|
-
import{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import{registerTriggers as Ve}from"@ez4/common/library";import{registerTriggers as Ue}from"@ez4/schema/library";
|
|
2
|
+
import{createTrigger as $e}from"@ez4/project/library";import{getLinkedServiceList as Oe,getLinkedVariableList as Re,getModelMembers as Ce,
|
|
3
|
+
getPropertyTuple as He}from"@ez4/common/library";import{isModelProperty as Ne}from"@ez4/reflection";var h="@ez4/database",_e=e=>e.type===h;import{IncompleteTypeError as G}from"@ez4/common/library";var m=class extends G{constructor(t,r){
|
|
4
|
+
super("Incomplete database service",t,r)}};import{hasHeritageType as p,isClassDeclaration as J,isModelDeclaration as K}from"@ez4/common/library";
|
|
5
|
+
import{isTypeCallback as Q,isTypeFunction as W}from"@ez4/reflection";var l=e=>J(
|
|
6
|
+
e)&&p(e,"Database.Service"),I=e=>K(e)&&p(e,"Database.Table"),v=e=>Q(e)||W(e),D=e=>p(
|
|
7
|
+
e,"Database.Indexes"),j=e=>p(e,"Database.Schema"),E=e=>p(e,"Database.Stream");import{getModelMembers as De,getObjectMembers as je,getPropertyString as Ee}from"@ez4/common/library";
|
|
8
|
+
import{isModelProperty as Pe,isTypeObject as Ae,isTypeReference as ke}from"@ez4/reflection";import{IncompleteTypeError as X}from"@ez4/common/library";var c=class extends X{constructor(t,r){
|
|
9
|
+
super("Incomplete database table",t,r)}};import{IncorrectTypeError as Y,InvalidTypeError as Z,TypeError as P}from"@ez4/common/library";
|
|
10
|
+
var u=class extends Z{constructor(t){super("Invalid table indexes type",void 0,"\
|
|
11
|
+
Database.Indexes",t)}},b=class extends Y{constructor(r,a){super("Incorrect table\
|
|
12
|
+
indexes type",r,"Database.Indexes",a);this.schemaType=r}},f=class extends P{constructor(r,a){
|
|
10
13
|
super(`Invalid index type, ${r} must follow one of the Index options.`,a);this.indexName=
|
|
11
|
-
r}},
|
|
12
|
-
be valid column.`,a);this.indexName=r}};import{
|
|
13
|
-
import{
|
|
14
|
-
|
|
15
|
-
Schema"),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
super("
|
|
29
|
-
super("Incomplete stream handler",t,r)}};var C=(e,t,r)=>{if(!
|
|
14
|
+
r}},T=class extends P{constructor(r,a){super(`Invalid index reference, ${r} must\
|
|
15
|
+
be valid column.`,a);this.indexName=r}};import{isTypeObject as re,isTypeReference as te}from"@ez4/reflection";import{isModelDeclaration as ae}from"@ez4/common/library";
|
|
16
|
+
import{getObjectSchema as A}from"@ez4/schema/library";import{IncorrectTypeError as L,InvalidTypeError as ee}from"@ez4/common/library";
|
|
17
|
+
var d=class extends ee{constructor(t){super("Invalid table schema type",void 0,"\
|
|
18
|
+
Database.Schema",t)}},y=class extends L{constructor(r,a){super("Incorrect table \
|
|
19
|
+
schema type",r,"Database.Schema",a);this.schemaType=r}};var w=(e,t,r,a)=>{if(!te(e))return k(e,t,r,a);let o=r[e.path];return o?k(o,t,r,a):
|
|
20
|
+
null},k=(e,t,r,a)=>re(e)?A(e,r):ae(e)?j(e)?A(e,r):(a.push(new y(e.name,e.file)),
|
|
21
|
+
null):(a.push(new d(t.file)),null);import{isModelDeclaration as oe,getModelMembers as se,getObjectMembers as ne,getPropertyString as ie}from"@ez4/common/library";
|
|
22
|
+
import{isModelProperty as pe,isTypeObject as me,isTypeReference as le}from"@ez4/reflection";var R=(e,t,r,a)=>{if(!le(e))return z(e,t,a);let o=r[e.path];return o?z(o,t,a):null},
|
|
23
|
+
z=(e,t,r)=>me(e)?O(e,ne(e),r):oe(e)?D(e)?O(e,se(e),r):(r.push(new b(e.name,e.file)),
|
|
24
|
+
null):(r.push(new u(t.file)),null),O=(e,t,r)=>{let a={};for(let o of t){if(!pe(o)||
|
|
25
|
+
o.inherited)continue;let n=o.name,i=ie(o);switch(i){case"primary":case"regular":case"\
|
|
26
|
+
unique":case"ttl":a[n]=i;break;default:return r.push(new f(n,e.file)),null}}return a};import{getLinkedVariableList as de,getModelMembers as ye,getObjectMembers as xe,
|
|
27
|
+
getPropertyNumber as ge,isModelDeclaration as Se}from"@ez4/common/library";import{
|
|
28
|
+
isModelProperty as Me,isTypeObject as he,isTypeReference as Ie}from"@ez4/reflection";import{IncompleteTypeError as ce,IncorrectTypeError as ue,InvalidTypeError as be}from"@ez4/common/library";
|
|
29
|
+
var x=class extends ce{constructor(t,r){super("Incomplete table stream",t,r)}},g=class extends be{constructor(t){
|
|
30
|
+
super("Invalid table stream type",void 0,"Database.Stream",t)}},S=class extends ue{constructor(r,a){
|
|
31
|
+
super("Incorrect table stream type",r,"Database.Stream",a);this.streamType=r}};import{IncompleteTypeError as fe}from"@ez4/common/library";var M=class extends fe{constructor(t,r){
|
|
32
|
+
super("Incomplete stream handler",t,r)}};var C=(e,t,r)=>{if(!v(e))return null;let a={},o=new Set(["name","file","change"]);
|
|
30
33
|
return e.description&&(a.description=e.description),(a.name=e.name)&&o.delete("n\
|
|
31
34
|
ame"),(a.file=e.file)&&o.delete("file"),e.parameters&&o.delete("change"),o.size===
|
|
32
|
-
0&&
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
C(i.value,r,a);break;case"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
R(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
push(i)}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
0&&Te(a)?a:(r.push(new M([...o],e.file)),null)},Te=e=>!!e.name&&!!e.file;var q=(e,t,r,a)=>{if(!Ie(e))return H(e,t,r,a);let o=r[e.path];return o?H(o,t,r,a):
|
|
36
|
+
null},ve=e=>!!e.handler,H=(e,t,r,a)=>he(e)?N(e,xe(e),r,a):Se(e)?E(e)?N(e,ye(e),r,
|
|
37
|
+
a):(a.push(new S(e.name,e.file)),null):(a.push(new g(t.file)),null),N=(e,t,r,a)=>{
|
|
38
|
+
let o={},n=new Set(["handler"]);for(let i of t)if(!(!Me(i)||i.inherited))switch(i.
|
|
39
|
+
name){case"handler":o.handler=C(i.value,r,a);break;case"timeout":case"memory":{let s=ge(
|
|
40
|
+
i);s!=null&&(o[i.name]=s);break}case"variables":o.variables=de(i,a);break}return ve(
|
|
41
|
+
o)?o:(a.push(new x([...n],e.file)),null)};var U=(e,t,r)=>{if(!ke(e))return F(e,t,r);let a=t[e.path];return a?F(a,t,r):null},
|
|
42
|
+
we=e=>!!e.name&&!!e.schema&&!!e.indexes,F=(e,t,r)=>I(e)?V(e,De(e),t,r):Ae(e)?V(e,
|
|
43
|
+
je(e),t,r):null,V=(e,t,r,a)=>{let o={},n=new Set(["name","schema","indexes"]);for(let s of t)
|
|
44
|
+
if(!(!Pe(s)||s.inherited))switch(s.name){case"name":(o.name=Ee(s))&&n.delete(s.name);
|
|
45
|
+
break;case"indexes":{(o.indexes=R(s.value,e,r,a))&&n.delete(s.name);break}case"s\
|
|
46
|
+
chema":{(o.schema=w(s.value,e,r,a))&&n.delete(s.name);break}case"stream":{o.stream=
|
|
47
|
+
q(s.value,e,r,a);break}}if(!we(o))return a.push(new c([...n],e.file)),null;let i=ze(
|
|
48
|
+
e,o.indexes,o.schema);return i.length?(a.push(...i),null):o},ze=(e,t,r)=>{let a=r.
|
|
49
|
+
properties,o=[];for(let n in t)for(let i of n.split(":"))a[i]||o.push(new T(n,e.
|
|
50
|
+
file));return o};var $=e=>{let t={},r=[];for(let a in e){let o=e[a];if(!l(o))continue;let n={type:h},
|
|
51
|
+
i=new Set(["tables"]);n.name=o.name;for(let s of Ce(o))if(!(!Ne(s)||s.inherited))
|
|
52
|
+
switch(s.name){case"tables":(n.tables=Fe(s,e,r))&&i.delete(s.name);break;case"va\
|
|
53
|
+
riables":n.variables=Re(s,r);break;case"services":n.services=Oe(s,e,r);break}if(!qe(
|
|
54
|
+
n)){r.push(new m([...i],o.file));continue}t[o.name]=n}return{services:t,errors:r}},
|
|
55
|
+
qe=e=>!!e.name&&!!e.tables,Fe=(e,t,r)=>{let a=He(e)??[],o=[];for(let n of a){let i=U(
|
|
56
|
+
n,t,r);i&&o.push(i)}return o};var _=e=>l(e)?e.name:null;var B=!1,Zr=()=>{B||(Ve(),Ue(),$e("@ez4/database",{"metadata:getServices":$,"met\
|
|
57
|
+
adata:getLinkedService":_}),B=!0)};export{M as IncompleteHandlerError,m as IncompleteServiceError,x as IncompleteStreamError,
|
|
58
|
+
c as IncompleteTableError,b as IncorrectIndexesTypeError,y as IncorrectSchemaTypeError,
|
|
59
|
+
S as IncorrectStreamTypeError,T as InvalidIndexReferenceError,f as InvalidIndexTypeError,
|
|
60
|
+
u as InvalidIndexesTypeError,d as InvalidSchemaTypeError,g as InvalidStreamTypeError,
|
|
61
|
+
h as ServiceType,$ as getDatabaseServices,U as getDatabaseTable,w as getTableSchema,
|
|
62
|
+
_e as isDatabaseService,Zr as registerTriggers};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { AllType, SourceMap } from '@ez4/reflection';
|
|
1
|
+
import type { AllType, SourceMap, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
import type { TableStream } from '../types/stream.js';
|
|
3
|
-
|
|
3
|
+
type TypeParent = TypeModel | TypeObject;
|
|
4
|
+
export declare const getTableStream: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => TableStream | null;
|
|
5
|
+
export {};
|
package/dist/metadata/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AllType, TypeCallback, TypeClass, TypeFunction, TypeModel } from '@ez4/reflection';
|
|
2
2
|
export declare const isDatabaseService: (type: AllType) => type is TypeClass;
|
|
3
3
|
export declare const isDatabaseTable: (type: AllType) => type is TypeModel;
|
|
4
|
-
export declare const isTableSchema: (type: TypeModel) => boolean;
|
|
5
|
-
export declare const isTableIndexes: (type: TypeModel) => boolean;
|
|
6
|
-
export declare const isTableStream: (type: AllType) => type is TypeModel;
|
|
7
4
|
export declare const isStreamHandler: (type: AllType) => type is TypeCallback | TypeFunction;
|
|
5
|
+
export declare const isTableIndexes: (type: TypeModel) => boolean;
|
|
6
|
+
export declare const isTableSchema: (type: TypeModel) => boolean;
|
|
7
|
+
export declare const isTableStream: (type: TypeModel) => boolean;
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/database",
|
|
3
3
|
"description": "EZ4: Components to build database services",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20.15.0"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/main.d.ts",
|
|
@@ -31,10 +34,10 @@
|
|
|
31
34
|
"live:publish": "npm run test && npm publish --access public"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"@ez4/common": "^0.
|
|
35
|
-
"@ez4/project": "^0.
|
|
36
|
-
"@ez4/reflection": "^0.
|
|
37
|
-
"@ez4/schema": "^0.
|
|
38
|
-
"@ez4/utils": "^0.
|
|
37
|
+
"@ez4/common": "^0.5.0",
|
|
38
|
+
"@ez4/project": "^0.5.0",
|
|
39
|
+
"@ez4/reflection": "^0.5.0",
|
|
40
|
+
"@ez4/schema": "^0.5.0",
|
|
41
|
+
"@ez4/utils": "^0.5.0"
|
|
39
42
|
}
|
|
40
43
|
}
|