@ez4/storage 0.14.0 → 0.15.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 +37 -33
- package/dist/library.mjs +50 -45
- package/dist/main.cjs +3 -3
- package/dist/main.d.ts +1 -1
- package/dist/main.mjs +1 -1
- package/dist/services/common.d.ts +41 -26
- package/dist/services/contract.d.ts +14 -8
- package/dist/types/common.d.ts +2 -0
- package/package.json +4 -4
package/dist/library.cjs
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
"use strict";var I=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},$=(e,t,r,n)=>{if(t&&
|
|
2
2
|
typeof t=="object"||typeof t=="function")for(let o of X(t))!Y.call(e,o)&&o!==r&&
|
|
3
|
-
I(e,o,{get:()=>t[o],enumerable:!(n=W(t,o))||n.enumerable});return e};var ee=e=>$(I({},"__esModule",{value:!0}),e);var pe={};Z(pe,{IncompleteCorsError:()=>
|
|
4
|
-
IncorrectCorsTypeError:()=>
|
|
5
|
-
InvalidEventTypeError:()=>k,ServiceType:()=>
|
|
3
|
+
I(e,o,{get:()=>t[o],enumerable:!(n=W(t,o))||n.enumerable});return e};var ee=e=>$(I({},"__esModule",{value:!0}),e);var pe={};Z(pe,{IncompleteCorsError:()=>T,IncompleteEventError:()=>g,IncompleteServiceError:()=>d,
|
|
4
|
+
IncorrectCorsTypeError:()=>E,IncorrectEventTypeError:()=>b,InvalidCorsTypeError:()=>S,
|
|
5
|
+
InvalidEventTypeError:()=>k,ServiceType:()=>x,getBucketCors:()=>P,getBucketEvent:()=>w,
|
|
6
6
|
getBucketServices:()=>j,getEventHandler:()=>C,isBucketService:()=>re,registerTriggers:()=>ce});
|
|
7
|
-
module.exports=ee(pe);var Q=require("@ez4/common/library"),U=require("@ez4/project/library");var
|
|
8
|
-
super("Incomplete bucket service",t,r)}};var
|
|
9
|
-
e)&&(0,
|
|
10
|
-
e),A=e=>(0,
|
|
11
|
-
cket.Cors");var
|
|
7
|
+
module.exports=ee(pe);var Q=require("@ez4/common/library"),U=require("@ez4/project/library");var p=require("@ez4/common/library"),G=require("@ez4/reflection"),J=require("@ez4/utils");var x="@ez4/bucket",re=e=>e.type===x;var z=require("@ez4/common/library"),d=class extends z.IncompleteTypeError{constructor(t,r){
|
|
8
|
+
super("Incomplete bucket service",t,r)}};var l=require("@ez4/common/library"),M=require("@ez4/reflection"),B=e=>(0,l.isClassDeclaration)(
|
|
9
|
+
e)&&(0,l.hasHeritageType)(e,"Bucket.Service"),O=e=>(0,M.isTypeCallback)(e)||(0,M.isTypeFunction)(
|
|
10
|
+
e),A=e=>(0,l.hasHeritageType)(e,"Bucket.Event"),H=e=>(0,l.hasHeritageType)(e,"Bu\
|
|
11
|
+
cket.Cors");var c=require("@ez4/common/library"),f=require("@ez4/reflection"),V=require("@ez4/utils");var u=require("@ez4/common/library"),g=class extends u.IncompleteTypeError{constructor(t,r){
|
|
12
12
|
super("Incomplete bucket event",t,r)}},k=class extends u.InvalidTypeError{constructor(t){
|
|
13
|
-
super("Invalid bucket event type",void 0,"Bucket.Event",t)}},
|
|
13
|
+
super("Invalid bucket event type",void 0,"Bucket.Event",t)}},b=class extends u.IncorrectTypeError{constructor(r,n){
|
|
14
14
|
super("Incorrect bucket event type",r,"Bucket.Event",n);this.eventType=r}};var N=require("@ez4/common/library"),h=class extends N.IncompleteTypeError{constructor(t,r){
|
|
15
15
|
super("Incomplete event handler",t,r)}};var C=(e,t,r)=>{if(!O(e))return null;let n={},o=new Set(["name","file"]);return e.
|
|
16
16
|
description&&(n.description=e.description),(n.name=e.name)&&o.delete("name"),(n.
|
|
17
17
|
file=e.file)&&o.delete("file"),o.size===0&&te(n)?n:(r.push(new h([...o],e.file)),
|
|
18
18
|
null)},te=e=>!!e.name&&!!e.file;var w=(e,t,r,n)=>{if(!(0,f.isTypeReference)(e))return D(e,t,r,n);let o=r[e.path];
|
|
19
19
|
return o?D(o,t,r,n):null},oe=e=>!!e.handler,D=(e,t,r,n)=>(0,f.isTypeObject)(e)?R(
|
|
20
|
-
e,(0,
|
|
21
|
-
e),r,n):(n.push(new
|
|
20
|
+
e,(0,c.getObjectMembers)(e),r,n):(0,c.isModelDeclaration)(e)?A(e)?R(e,(0,c.getModelMembers)(
|
|
21
|
+
e),r,n):(n.push(new b(e.name,e.file)),null):(n.push(new k(t.file)),null),R=(e,t,r,n)=>{
|
|
22
22
|
let o={},s=new Set(["handler"]);for(let i of t)if(!(!(0,f.isModelProperty)(i)||i.
|
|
23
|
-
inherited))switch(i.name){
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
inherited))switch(i.name){default:n.push(new c.InvalidServicePropertyError(parent.
|
|
24
|
+
name,i.name,e.file));break;case"listener":{let a=(0,c.getServiceListener)(i.value,
|
|
25
|
+
n);a&&(o.listener=a);break}case"handler":o.handler=C(i.value,r,n);break;case"pat\
|
|
26
|
+
h":{let a=(0,c.getPropertyString)(i);a&&(o[i.name]=a);break}case"timeout":case"m\
|
|
27
|
+
emory":{let a=(0,c.getPropertyNumber)(i);(0,V.isAnyNumber)(a)&&(o[i.name]=a);break}case"\
|
|
28
|
+
variables":o.variables=(0,c.getLinkedVariableList)(i,n);break}return oe(o)?o:(n.
|
|
29
|
+
push(new g([...s],e.file)),null)};var m=require("@ez4/common/library"),v=require("@ez4/reflection"),q=require("@ez4/utils");var y=require("@ez4/common/library"),T=class extends y.IncompleteTypeError{constructor(t,r){
|
|
28
30
|
super("Incomplete bucket CORS",t,r)}},S=class extends y.InvalidTypeError{constructor(t){
|
|
29
|
-
super("Invalid bucket CORS type",void 0,"Bucket.Cors",t)}},
|
|
31
|
+
super("Invalid bucket CORS type",void 0,"Bucket.Cors",t)}},E=class extends y.IncorrectTypeError{constructor(r,n){
|
|
30
32
|
super("Incorrect bucket CORS type",r,"Bucket.Cors",n);this.fallbackType=r}};var P=(e,t,r,n)=>{if(!(0,v.isTypeReference)(e))return F(e,t,n);let o=r[e.path];return o?
|
|
31
|
-
F(o,t,n):null},ne=e=>!!e.allowOrigins?.length,F=(e,t,r)=>(0,v.isTypeObject)(e)?
|
|
32
|
-
e,(0,m.getObjectMembers)(e),r):(0,m.isModelDeclaration)(e)?H(e)?
|
|
33
|
-
e),r):(r.push(new
|
|
33
|
+
F(o,t,n):null},ne=e=>!!e.allowOrigins?.length,F=(e,t,r)=>(0,v.isTypeObject)(e)?_(
|
|
34
|
+
e,(0,m.getObjectMembers)(e),r):(0,m.isModelDeclaration)(e)?H(e)?_(e,(0,m.getModelMembers)(
|
|
35
|
+
e),r):(r.push(new E(e.name,e.file)),null):(r.push(new S(t.file)),null),_=(e,t,r)=>{
|
|
34
36
|
let n={},o=new Set(["allowOrigins"]);for(let s of t)if(!(!(0,v.isModelProperty)(
|
|
35
|
-
s)||s.inherited))switch(s.name){
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
o))
|
|
41
|
-
|
|
42
|
-
i)
|
|
43
|
-
|
|
37
|
+
s)||s.inherited))switch(s.name){default:r.push(new m.InvalidServicePropertyError(
|
|
38
|
+
parent.name,s.name,e.file));break;case"allowOrigins":case"allowMethods":case"all\
|
|
39
|
+
owHeaders":case"exposeHeaders":{let i=ie(s);i.length&&(n[s.name]=i);break}case"m\
|
|
40
|
+
axAge":{let i=(0,m.getPropertyNumber)(s);(0,q.isAnyNumber)(i)&&(n[s.name]=i);break}}
|
|
41
|
+
return ne(n)?n:(r.push(new T([...o],e.file)),null)},ie=e=>{let t=(0,m.getPropertyTuple)(
|
|
42
|
+
e)??[],r=[];for(let n of t){let o=(0,m.getLiteralString)(n);o&&r.push(o)}return r};var j=e=>{let t={},r=[];for(let n in e){let o=e[n];if(!B(o)||(0,p.isExternalStatement)(
|
|
43
|
+
o))continue;let s={type:x};s.name=o.name;for(let i of(0,p.getModelMembers)(o))if(!(!(0,G.isModelProperty)(
|
|
44
|
+
i)||i.inherited))switch(i.name){default:r.push(new p.InvalidServicePropertyError(
|
|
45
|
+
parent.name,i.name,o.file));break;case"localPath":case"globalName":{let a=(0,p.getPropertyString)(
|
|
46
|
+
i);a&&(s[i.name]=a);break}case"autoExpireDays":{let a=(0,p.getPropertyNumber)(i);
|
|
47
|
+
(0,J.isAnyNumber)(a)&&(s.autoExpireDays=a);break}case"events":s.events=w(i.value,
|
|
44
48
|
o,e,r);break;case"cors":s.cors=P(i.value,o,e,r);break;case"variables":s.variables=
|
|
45
|
-
(0,
|
|
46
|
-
i,e,r);break}if(!se(s)){r.push(new d([],o.file));continue}if(t[o.name]){r.push(new
|
|
47
|
-
o.name,o.file));continue}t[o.name]=s}return{services:t,errors:r}},se=e=>!!e.name;var
|
|
48
|
-
{"metadata:getServices":j,"metadata:getLinkedService":
|
|
49
|
+
(0,p.getLinkedVariableList)(i,r);break;case"services":s.services=(0,p.getLinkedServiceList)(
|
|
50
|
+
i,e,r);break}if(!se(s)){r.push(new d([],o.file));continue}if(t[o.name]){r.push(new p.DuplicateServiceError(
|
|
51
|
+
o.name,o.file));continue}t[o.name]=s}return{services:t,errors:r}},se=e=>!!e.name;var K=e=>B(e)?e.name:null;var L=!1,ce=()=>{L||((0,Q.registerTriggers)(),(0,U.createTrigger)("@ez4/bucket",
|
|
52
|
+
{"metadata:getServices":j,"metadata:getLinkedService":K}),L=!0)};0&&(module.exports={IncompleteCorsError,IncompleteEventError,IncompleteServiceError,
|
|
49
53
|
IncorrectCorsTypeError,IncorrectEventTypeError,InvalidCorsTypeError,InvalidEventTypeError,
|
|
50
54
|
ServiceType,getBucketCors,getBucketEvent,getBucketServices,getEventHandler,isBucketService,
|
|
51
55
|
registerTriggers});
|
package/dist/library.mjs
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
getLinkedServiceList as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
super("
|
|
12
|
-
super("
|
|
13
|
-
super("
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
null},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
handler"
|
|
21
|
-
break
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
o
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import{registerTriggers as Ie}from"@ez4/common/library";import{createTrigger as Ce}from"@ez4/project/library";import{DuplicateServiceError as de,InvalidServicePropertyError as ge,isExternalStatement as ke,
|
|
2
|
+
getLinkedVariableList as be,getLinkedServiceList as Te,getModelMembers as Se,getPropertyNumber as Ee,
|
|
3
|
+
getPropertyString as xe}from"@ez4/common/library";import{isModelProperty as Me}from"@ez4/reflection";
|
|
4
|
+
import{isAnyNumber as Be}from"@ez4/utils";var g="@ez4/bucket",we=e=>e.type===g;import{IncompleteTypeError as z}from"@ez4/common/library";var p=class extends z{constructor(n,r){
|
|
5
|
+
super("Incomplete bucket service",n,r)}};import{hasHeritageType as k,isClassDeclaration as O}from"@ez4/common/library";import{
|
|
6
|
+
isTypeCallback as A,isTypeFunction as H}from"@ez4/reflection";var a=e=>O(e)&&k(e,
|
|
7
|
+
"Bucket.Service"),b=e=>A(e)||H(e),T=e=>k(e,"Bucket.Event"),S=e=>k(e,"Bucket.Cors");import{InvalidServicePropertyError as _,isModelDeclaration as q,getLinkedVariableList as G,
|
|
8
|
+
getModelMembers as J,getObjectMembers as K,getPropertyNumber as L,getPropertyString as Q,
|
|
9
|
+
getServiceListener as U}from"@ez4/common/library";import{isModelProperty as W,isTypeObject as X,
|
|
10
|
+
isTypeReference as Y}from"@ez4/reflection";import{isAnyNumber as Z}from"@ez4/utils";import{IncompleteTypeError as N,IncorrectTypeError as D,InvalidTypeError as R}from"@ez4/common/library";
|
|
11
|
+
var m=class extends N{constructor(n,r){super("Incomplete bucket event",n,r)}},l=class extends R{constructor(n){
|
|
12
|
+
super("Invalid bucket event type",void 0,"Bucket.Event",n)}},u=class extends D{constructor(r,o){
|
|
13
|
+
super("Incorrect bucket event type",r,"Bucket.Event",o);this.eventType=r}};import{IncompleteTypeError as V}from"@ez4/common/library";var f=class extends V{constructor(n,r){
|
|
14
|
+
super("Incomplete event handler",n,r)}};var E=(e,n,r)=>{if(!b(e))return null;let o={},t=new Set(["name","file"]);return e.
|
|
15
|
+
description&&(o.description=e.description),(o.name=e.name)&&t.delete("name"),(o.
|
|
16
|
+
file=e.file)&&t.delete("file"),t.size===0&&F(o)?o:(r.push(new f([...t],e.file)),
|
|
17
|
+
null)},F=e=>!!e.name&&!!e.file;var B=(e,n,r,o)=>{if(!Y(e))return x(e,n,r,o);let t=r[e.path];return t?x(t,n,r,o):
|
|
18
|
+
null},$=e=>!!e.handler,x=(e,n,r,o)=>X(e)?M(e,K(e),r,o):q(e)?T(e)?M(e,J(e),r,o):(o.
|
|
19
|
+
push(new u(e.name,e.file)),null):(o.push(new l(n.file)),null),M=(e,n,r,o)=>{let t={},
|
|
20
|
+
s=new Set(["handler"]);for(let i of n)if(!(!W(i)||i.inherited))switch(i.name){default:
|
|
21
|
+
o.push(new _(parent.name,i.name,e.file));break;case"listener":{let c=U(i.value,o);
|
|
22
|
+
c&&(t.listener=c);break}case"handler":t.handler=E(i.value,r,o);break;case"path":{
|
|
23
|
+
let c=Q(i);c&&(t[i.name]=c);break}case"timeout":case"memory":{let c=L(i);Z(c)&&(t[i.
|
|
24
|
+
name]=c);break}case"variables":t.variables=G(i,o);break}return $(t)?t:(o.push(new m(
|
|
25
|
+
[...s],e.file)),null)};import{InvalidServicePropertyError as oe,isModelDeclaration as ne,getLiteralString as ie,
|
|
26
|
+
getModelMembers as se,getObjectMembers as ce,getPropertyNumber as pe,getPropertyTuple as ae}from"@ez4/common/library";
|
|
27
|
+
import{isModelProperty as me,isTypeObject as le,isTypeReference as ue}from"@ez4/reflection";
|
|
28
|
+
import{isAnyNumber as fe}from"@ez4/utils";import{IncompleteTypeError as ee,IncorrectTypeError as re,InvalidTypeError as te}from"@ez4/common/library";
|
|
29
|
+
var y=class extends ee{constructor(n,r){super("Incomplete bucket CORS",n,r)}},v=class extends te{constructor(n){
|
|
30
|
+
super("Invalid bucket CORS type",void 0,"Bucket.Cors",n)}},d=class extends re{constructor(r,o){
|
|
31
|
+
super("Incorrect bucket CORS type",r,"Bucket.Cors",o);this.fallbackType=r}};var C=(e,n,r,o)=>{if(!ue(e))return h(e,n,o);let t=r[e.path];return t?h(t,n,o):null},
|
|
32
|
+
ye=e=>!!e.allowOrigins?.length,h=(e,n,r)=>le(e)?I(e,ce(e),r):ne(e)?S(e)?I(e,se(e),
|
|
33
|
+
r):(r.push(new d(e.name,e.file)),null):(r.push(new v(n.file)),null),I=(e,n,r)=>{
|
|
34
|
+
let o={},t=new Set(["allowOrigins"]);for(let s of n)if(!(!me(s)||s.inherited))switch(s.
|
|
35
|
+
name){default:r.push(new oe(parent.name,s.name,e.file));break;case"allowOrigins":case"\
|
|
36
|
+
allowMethods":case"allowHeaders":case"exposeHeaders":{let i=ve(s);i.length&&(o[s.
|
|
37
|
+
name]=i);break}case"maxAge":{let i=pe(s);fe(i)&&(o[s.name]=i);break}}return ye(o)?
|
|
38
|
+
o:(r.push(new y([...t],e.file)),null)},ve=e=>{let n=ae(e)??[],r=[];for(let o of n){
|
|
39
|
+
let t=ie(o);t&&r.push(t)}return r};var w=e=>{let n={},r=[];for(let o in e){let t=e[o];if(!a(t)||ke(t))continue;let s={
|
|
40
|
+
type:g};s.name=t.name;for(let i of Se(t))if(!(!Me(i)||i.inherited))switch(i.name){default:
|
|
41
|
+
r.push(new ge(parent.name,i.name,t.file));break;case"localPath":case"globalName":{
|
|
42
|
+
let c=xe(i);c&&(s[i.name]=c);break}case"autoExpireDays":{let c=Ee(i);Be(c)&&(s.autoExpireDays=
|
|
43
|
+
c);break}case"events":s.events=B(i.value,t,e,r);break;case"cors":s.cors=C(i.value,
|
|
44
|
+
t,e,r);break;case"variables":s.variables=be(i,r);break;case"services":s.services=
|
|
45
|
+
Te(i,e,r);break}if(!he(s)){r.push(new p([],t.file));continue}if(n[t.name]){r.push(
|
|
46
|
+
new de(t.name,t.file));continue}n[t.name]=s}return{services:n,errors:r}},he=e=>!!e.
|
|
47
|
+
name;var P=e=>a(e)?e.name:null;var j=!1,br=()=>{j||(Ie(),Ce("@ez4/bucket",{"metadata:getServices":w,"metadata:g\
|
|
48
|
+
etLinkedService":P}),j=!0)};export{y as IncompleteCorsError,m as IncompleteEventError,p as IncompleteServiceError,
|
|
44
49
|
d as IncorrectCorsTypeError,u as IncorrectEventTypeError,v as InvalidCorsTypeError,
|
|
45
|
-
|
|
46
|
-
w as getBucketServices,
|
|
50
|
+
l as InvalidEventTypeError,g as ServiceType,C as getBucketCors,B as getBucketEvent,
|
|
51
|
+
w as getBucketServices,E as getEventHandler,we as isBucketService,br as registerTriggers};
|
package/dist/main.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof e=="object"||typeof e=="function")for(let
|
|
3
|
-
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,c)=>{if(e&&
|
|
2
|
+
typeof e=="object"||typeof e=="function")for(let n of m(e))!a.call(t,n)&&n!==r&&
|
|
3
|
+
o(t,n,{get:()=>e[n],enumerable:!(c=p(e,n))||c.enumerable});return t};var l=t=>u(o({},"__esModule",{value:!0}),t);var x={};v(x,{Bucket:()=>s,BucketEventType:()=>i});module.exports=l(x);var i=(r=>(r.Create="create",r.Delete="delete",r))(i||{});var s;(t=>{})(s||={});0&&(module.exports={Bucket,BucketEventType});
|
package/dist/main.d.ts
CHANGED
package/dist/main.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=(e=>(e.Create="create",e.Delete="delete",e))(t||{});var r;(
|
|
1
|
+
var t=(e=>(e.Create="create",e.Delete="delete",e))(t||{});var r;(n=>{})(r||={});export{r as Bucket,t as BucketEventType};
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
import type { Service } from '@ez4/common';
|
|
2
|
+
import type { Bucket } from './contract.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bucket event type.
|
|
5
|
+
*/
|
|
6
|
+
export declare const enum BucketEventType {
|
|
7
|
+
Create = "create",
|
|
8
|
+
Delete = "delete"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Bucket event.
|
|
12
|
+
*/
|
|
13
|
+
export type BucketEvent = {
|
|
14
|
+
/**
|
|
15
|
+
* Type of event.
|
|
16
|
+
*/
|
|
17
|
+
eventType: BucketEventType;
|
|
18
|
+
/**
|
|
19
|
+
* Bucket from the event.
|
|
20
|
+
*/
|
|
21
|
+
bucketName: string;
|
|
22
|
+
/**
|
|
23
|
+
* Object key in the bucket.
|
|
24
|
+
*/
|
|
25
|
+
objectKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* Size of the created object.
|
|
28
|
+
*/
|
|
29
|
+
objectSize?: number;
|
|
30
|
+
};
|
|
1
31
|
/**
|
|
2
32
|
* Bucket CORS configuration.
|
|
3
33
|
*/
|
|
@@ -24,34 +54,19 @@ export interface BucketCors {
|
|
|
24
54
|
maxAge?: number;
|
|
25
55
|
}
|
|
26
56
|
/**
|
|
27
|
-
*
|
|
57
|
+
* Incoming event.
|
|
28
58
|
*/
|
|
29
|
-
export
|
|
30
|
-
Create = "create",
|
|
31
|
-
Delete = "delete"
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Bucket event.
|
|
35
|
-
*/
|
|
36
|
-
export type BucketEvent = {
|
|
59
|
+
export type BucketIncoming<T extends BucketEvent> = T & {
|
|
37
60
|
/**
|
|
38
|
-
* Request Id.
|
|
61
|
+
* Request tracking Id.
|
|
39
62
|
*/
|
|
40
63
|
requestId: string;
|
|
41
|
-
/**
|
|
42
|
-
* Type of event.
|
|
43
|
-
*/
|
|
44
|
-
eventType: BucketEventType;
|
|
45
|
-
/**
|
|
46
|
-
* Bucket from the event.
|
|
47
|
-
*/
|
|
48
|
-
bucketName: string;
|
|
49
|
-
/**
|
|
50
|
-
* Size of the created object.
|
|
51
|
-
*/
|
|
52
|
-
objectSize?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Object key in the bucket.
|
|
55
|
-
*/
|
|
56
|
-
objectKey: string;
|
|
57
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Message listener.
|
|
67
|
+
*/
|
|
68
|
+
export type BucketListener<T extends BucketEvent> = (event: Service.Event<BucketIncoming<T>>, context: Service.Context<Bucket.Service>) => Promise<void> | void;
|
|
69
|
+
/**
|
|
70
|
+
* Event handler.
|
|
71
|
+
*/
|
|
72
|
+
export type BucketHandler<T extends BucketEvent> = (request: BucketIncoming<T> | T, context: Service.Context<Bucket.Service>) => Promise<void> | void;
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import type { LinkedVariables } from '@ez4/project/library';
|
|
2
2
|
import type { Service } from '@ez4/common';
|
|
3
|
-
import type { BucketCors, BucketEvent } from './common.js';
|
|
4
3
|
import type { Client } from './client.js';
|
|
4
|
+
import type { BucketCors, BucketEvent, BucketHandler, BucketIncoming, BucketListener } from './common.js';
|
|
5
5
|
/**
|
|
6
6
|
* Provide all contracts for a self-managed Bucket service.
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace Bucket {
|
|
9
9
|
type Cors = BucketCors;
|
|
10
|
+
type Event = BucketEvent;
|
|
11
|
+
type Incoming = BucketIncoming<Event>;
|
|
12
|
+
type Listener = BucketListener<Event>;
|
|
13
|
+
type Handler = BucketHandler<Event>;
|
|
14
|
+
type ServiceEvent = Service.Event<Incoming>;
|
|
10
15
|
/**
|
|
11
|
-
* Bucket
|
|
16
|
+
* Bucket events.
|
|
12
17
|
*/
|
|
13
|
-
interface
|
|
18
|
+
interface Events {
|
|
19
|
+
/**
|
|
20
|
+
* Event listener.
|
|
21
|
+
*/
|
|
22
|
+
listener?: Listener;
|
|
14
23
|
/**
|
|
15
24
|
* Event handler.
|
|
16
|
-
*
|
|
17
|
-
* @param event Event object.
|
|
18
|
-
* @param context Handler context.
|
|
19
25
|
*/
|
|
20
|
-
handler:
|
|
26
|
+
handler: Handler;
|
|
21
27
|
/**
|
|
22
28
|
* Path associated to the event.
|
|
23
29
|
*/
|
|
@@ -54,7 +60,7 @@ export declare namespace Bucket {
|
|
|
54
60
|
/**
|
|
55
61
|
* Bucket events.
|
|
56
62
|
*/
|
|
57
|
-
events?:
|
|
63
|
+
events?: Events;
|
|
58
64
|
/**
|
|
59
65
|
* CORS configuration.
|
|
60
66
|
*/
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LinkedVariables } from '@ez4/project/library';
|
|
2
|
+
import type { ServiceListener } from '@ez4/common/library';
|
|
2
3
|
export type BucketCors = {
|
|
3
4
|
allowOrigins: string[];
|
|
4
5
|
allowMethods?: string[];
|
|
@@ -12,6 +13,7 @@ export type EventHandler = {
|
|
|
12
13
|
description?: string;
|
|
13
14
|
};
|
|
14
15
|
export type BucketEvent = {
|
|
16
|
+
listener?: ServiceListener;
|
|
15
17
|
handler: EventHandler;
|
|
16
18
|
path?: string;
|
|
17
19
|
variables?: LinkedVariables | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/storage",
|
|
3
3
|
"description": "EZ4: Components to build storage services",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -42,8 +42,8 @@
|
|
|
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.
|
|
45
|
+
"@ez4/common": "^0.15.0",
|
|
46
|
+
"@ez4/project": "^0.15.0",
|
|
47
|
+
"@ez4/reflection": "^0.15.0"
|
|
48
48
|
}
|
|
49
49
|
}
|