@ez4/aws-topic 0.29.0 → 0.30.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/main.cjs +10 -10
- package/dist/main.mjs +11 -11
- package/dist/triggers/subscription.d.ts +1 -1
- package/lib/message.ts +1 -1
- package/package.json +20 -16
package/dist/main.cjs
CHANGED
|
@@ -20,7 +20,7 @@ let r=(0,u.tryParseArn)(e)?.resourceName??e;u.Logger.logTag(S,r),await F.send(ne
|
|
|
20
20
|
async(e,t)=>{let r=(0,u.tryParseArn)(e)?.resourceName??e;u.Logger.logUntag(S,r),
|
|
21
21
|
await F.send(new m.UntagResourceCommand({ResourceArn:e,TagKeys:t}))},"untagTopic");var ae=i(()=>({equals:mt,create:me,replace:St,preview:ut,update:ft,delete:lt}),"\
|
|
22
22
|
getTopicHandler"),mt=i((e,t)=>!!e.result&&e.result.topicArn===t.result?.topicArn,
|
|
23
|
-
"equalsResource"),ut=i(
|
|
23
|
+
"equalsResource"),ut=i((e,t)=>{let r={...e.parameters,dependencies:e.dependencies},
|
|
24
24
|
o={...t.parameters,dependencies:t.dependencies},n=(0,ce.deepCompare)(r,o);if(n.counts)
|
|
25
25
|
return{...n,name:r.topicName}},"previewResource"),St=i(async(e,t)=>{if(t.result)
|
|
26
26
|
throw new z.ReplaceResourceError(S,e.entryId,t.entryId);return me(e)},"replaceRe\
|
|
@@ -42,7 +42,7 @@ t ${t} is not supported.`);let{service:r}=(0,b.parseArn)(t);switch(r){case"lambd
|
|
|
42
42
|
a":case"sqs":return r}throw new b.InvalidParameterError(e,`protocol ${r} is not \
|
|
43
43
|
supported.`)},"getSubscriptionProtocol");var be=i(()=>({equals:gt,create:xe,replace:Tt,preview:dt,update:bt,delete:xt}),"\
|
|
44
44
|
getSubscriptionHandler"),gt=i((e,t)=>!!e.result&&e.result.subscriptionArn===t.result?.
|
|
45
|
-
subscriptionArn,"equalsResource"),dt=i(
|
|
45
|
+
subscriptionArn,"equalsResource"),dt=i((e,t)=>{let r={...e.parameters,dependencies:e.
|
|
46
46
|
dependencies},o={...t.parameters,dependencies:t.dependencies},n=(0,Te.deepCompare)(
|
|
47
47
|
r,o,{exclude:{getTopicArn:!0,getEndpoint:!0}});if(n.counts)return{...n,name:r.fromService}},
|
|
48
48
|
"previewResource"),Tt=i(async(e,t,r)=>{if(t.result)throw new de.ReplaceResourceError(
|
|
@@ -88,7 +88,7 @@ alName"),Oe=i((e,t,r)=>`${(0,Me.getServiceName)(e,r)}-${(0,j.toKebabCase)(t)}`,"
|
|
|
88
88
|
getFunctionName");var P=class extends Error{static{i(this,"RoleMissingError")}constructor(){super(
|
|
89
89
|
"Execution role for SNS is missing.")}},C=class extends Error{constructor(r){super(
|
|
90
90
|
`Imported project ${r} wasn't found.`);this.projectName=r}static{i(this,"Project\
|
|
91
|
-
MissingError")}};var N;(o=>(o.LogRetention=90,o.Timeout=90,o.Memory=192))(N||={});var G=i(
|
|
91
|
+
MissingError")}};var N;(o=>(o.LogRetention=90,o.Timeout=90,o.Memory=192))(N||={});var G=i((e,t,r,o,n)=>{if(!n.role||!(0,ee.isRoleState)(n.role))throw new P;for(let s of t.
|
|
92
92
|
subscriptions)switch(s.type){default:throw new Q.InvalidParameterError(a,"subscr\
|
|
93
93
|
iption not supported.");case h.TopicSubscriptionType.Lambda:{if(t.fifoMode)throw new Q.InvalidParameterError(
|
|
94
94
|
a,"lambda subscription not supported for FIFO topics.");let{handler:p,listener:c}=s,
|
|
@@ -101,13 +101,13 @@ name,module:p.module,dependencies:rt},listener:c&&{functionName:c.name,sourceFil
|
|
|
101
101
|
file,module:c.module},variables:{...o.variables,...t.variables,...s.variables}}),
|
|
102
102
|
n.setServiceState(l,f,o)}$(e,r,l,{fromService:l.parameters.functionName});break}case h.TopicSubscriptionType.
|
|
103
103
|
Queue:{let p=(0,te.getQueueState)(n,s.service,o);$(e,r,p,{fromService:p.parameters.
|
|
104
|
-
queueName});break}}},"prepareSubscriptions"),H=i((e,t,r,o)=>{if(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
queueName});break}}},"prepareSubscriptions"),H=i((e,t,r,o)=>{if(!o.role||!(0,ee.isRoleState)(
|
|
105
|
+
o.role))throw new P;for(let n of t.subscriptions)switch(n.type){default:throw new Q.InvalidParameterError(
|
|
106
|
+
a,"subscription not supported.");case h.TopicSubscriptionType.Lambda:{let s=X(t,
|
|
107
|
+
n.handler.name),p=(0,q.getFunctionState)(o,s,r);(0,Y.linkServiceExtras)(e,p.entryId,
|
|
108
|
+
t.extras);break}case h.TopicSubscriptionType.Queue:{let s=(0,te.getQueueState)(o,
|
|
109
|
+
n.service,r);(0,Y.linkServiceExtras)(e,s.entryId,t.extras);break}}},"connectSubs\
|
|
110
|
+
criptions");var $e=require("@ez4/project/library");var _=i((e,t,r)=>{let n=Z(e,t.name,r).entryId,s=(0,$e.getDefinitionName)(n,"topi\
|
|
111
111
|
cArn"),p=JSON.stringify(t.fifoMode??null),c=JSON.stringify(t.schema);return{entryIds:[
|
|
112
112
|
n],constructor:`make(${s}, ${c}, ${p})`,from:"@ez4/aws-topic/client",module:"Cli\
|
|
113
113
|
ent"}},"prepareLinkedClient");var Qe=i(e=>{let{service:t,options:r,context:o}=e;return(0,U.isTopicService)(t)?
|
package/dist/main.mjs
CHANGED
|
@@ -15,7 +15,7 @@ e;b.logTag(S,r),await x.send(new Ie({ResourceArn:e,Tags:$({...t,ManagedBy:"EZ4"}
|
|
|
15
15
|
"tagTopic"),G=i(async(e,t)=>{let r=C(e)?.resourceName??e;b.logUntag(S,r),await x.
|
|
16
16
|
send(new Fe({ResourceArn:e,TagKeys:t}))},"untagTopic");var H=i(()=>({equals:$e,create:_,replace:Qe,preview:je,update:qe,delete:Ge}),"ge\
|
|
17
17
|
tTopicHandler"),$e=i((e,t)=>!!e.result&&e.result.topicArn===t.result?.topicArn,"\
|
|
18
|
-
equalsResource"),je=i(
|
|
18
|
+
equalsResource"),je=i((e,t)=>{let r={...e.parameters,dependencies:e.dependencies},
|
|
19
19
|
o={...t.parameters,dependencies:t.dependencies},n=ke(r,o);if(n.counts)return{...n,
|
|
20
20
|
name:r.topicName}},"previewResource"),Qe=i(async(e,t)=>{if(t.result)throw new Le(
|
|
21
21
|
S,e.entryId,t.entryId);return _(e)},"replaceResource"),_=i(async e=>{let t=e.parameters;
|
|
@@ -35,7 +35,7 @@ teSubscription");var X=i((e,t)=>{if(!Ze(t))throw new V(e,`endpoint ${t} is not s
|
|
|
35
35
|
t);switch(r){case"lambda":case"sqs":return r}throw new V(e,`protocol ${r} is not\
|
|
36
36
|
supported.`)},"getSubscriptionProtocol");var Y=i(()=>({equals:Ye,create:ee,replace:tt,preview:et,update:rt,delete:ot}),"g\
|
|
37
37
|
etSubscriptionHandler"),Ye=i((e,t)=>!!e.result&&e.result.subscriptionArn===t.result?.
|
|
38
|
-
subscriptionArn,"equalsResource"),et=i(
|
|
38
|
+
subscriptionArn,"equalsResource"),et=i((e,t)=>{let r={...e.parameters,dependencies:e.
|
|
39
39
|
dependencies},o={...t.parameters,dependencies:t.dependencies},n=Xe(r,o,{exclude:{
|
|
40
40
|
getTopicArn:!0,getEndpoint:!0}});if(n.counts)return{...n,name:r.fromService}},"p\
|
|
41
41
|
reviewResource"),tt=i(async(e,t,r)=>{if(t.result)throw new Ve(a,e.entryId,t.entryId);
|
|
@@ -50,7 +50,7 @@ icState"),re=i((e,t,r)=>{let o=e.getServiceState(t,r);if(!h(o))throw new v(t);re
|
|
|
50
50
|
"getTopicState"),oe=i((e,t,r)=>{let o=r.getDependencies(f).at(0)?.result;if(!o?.
|
|
51
51
|
topicArn)throw new nt(e,t,"topicArn");return o.topicArn},"getTopicArn");var E=i((e,t)=>{let r=at(t.topicName),o=t.fifoMode?`${r}.fifo`:r,n=N(o,!1);return ct(
|
|
52
52
|
e,{type:f,entryId:n,dependencies:[],parameters:{...t,topicName:o}})},"createTopi\
|
|
53
|
-
c"),
|
|
53
|
+
c"),Kr=i((e,t)=>{let r=N(t),o=e[r];return o&&h(o)?o:null},"getTopic");import{linkServiceExtras as me}from"@ez4/project/library";import{TopicSubscriptionType as w}from"@ez4/topic/library";
|
|
54
54
|
import{getFunctionState as At,tryGetFunctionState as Pt}from"@ez4/aws-function";
|
|
55
55
|
import{InvalidParameterError as D}from"@ez4/aws-common";import{isRoleState as ue}from"@ez4/aws-identity";
|
|
56
56
|
import{createLogGroup as Ct}from"@ez4/aws-logs";import{getQueueState as Se}from"@ez4/aws-queue";import{createFunction as lt}from"@ez4/aws-function";import{hashObject as yt}from"@ez4/utils";import{join as mt}from"node:path";import{getDefinitionsObject as ut}from"@ez4/project/library";
|
|
@@ -77,7 +77,7 @@ xt(a,p,c),"getEndpoint")}})},"createSubscription");import{getServiceName as Rt}f
|
|
|
77
77
|
-${F(t)}`,"getFunctionName");var g=class extends Error{static{i(this,"RoleMissingError")}constructor(){super(
|
|
78
78
|
"Execution role for SNS is missing.")}},d=class extends Error{constructor(r){super(
|
|
79
79
|
`Imported project ${r} wasn't found.`);this.projectName=r}static{i(this,"Project\
|
|
80
|
-
MissingError")}};var T;(o=>(o.LogRetention=90,o.Timeout=90,o.Memory=192))(T||={});var R=i(
|
|
80
|
+
MissingError")}};var T;(o=>(o.LogRetention=90,o.Timeout=90,o.Memory=192))(T||={});var R=i((e,t,r,o,n)=>{if(!n.role||!ue(n.role))throw new g;for(let s of t.subscriptions)
|
|
81
81
|
switch(s.type){default:throw new D(a,"subscription not supported.");case w.Lambda:{
|
|
82
82
|
if(t.fifoMode)throw new D(a,"lambda subscription not supported for FIFO topics.");
|
|
83
83
|
let{handler:p,listener:c}=s,m=z(t,p.name),u=Pt(n,m,o);if(!u){let O=ae(t,p.name,o),
|
|
@@ -89,11 +89,11 @@ module:p.module,dependencies:ve},listener:c&&{functionName:c.name,sourceFile:c.f
|
|
|
89
89
|
module:c.module},variables:{...o.variables,...t.variables,...s.variables}}),n.setServiceState(
|
|
90
90
|
u,m,o)}I(e,r,u,{fromService:u.parameters.functionName});break}case w.Queue:{let p=Se(
|
|
91
91
|
n,s.service,o);I(e,r,p,{fromService:p.parameters.queueName});break}}},"prepareSu\
|
|
92
|
-
bscriptions"),A=i((e,t,r,o)=>{if(
|
|
92
|
+
bscriptions"),A=i((e,t,r,o)=>{if(!o.role||!ue(o.role))throw new g;for(let n of t.
|
|
93
93
|
subscriptions)switch(n.type){default:throw new D(a,"subscription not supported.");case w.
|
|
94
94
|
Lambda:{let s=z(t,n.handler.name),p=At(o,s,r);me(e,p.entryId,t.extras);break}case w.
|
|
95
|
-
Queue:{let s=Se(o,n.service,r);me(e,s.entryId,t.extras);break}}}
|
|
96
|
-
|
|
95
|
+
Queue:{let s=Se(o,n.service,r);me(e,s.entryId,t.extras);break}}},"connectSubscri\
|
|
96
|
+
ptions");import{getDefinitionName as Nt}from"@ez4/project/library";var P=i((e,t,r)=>{let n=re(e,t.name,r).entryId,s=Nt(n,"topicArn"),p=JSON.stringify(
|
|
97
97
|
t.fifoMode??null),c=JSON.stringify(t.schema);return{entryIds:[n],constructor:`ma\
|
|
98
98
|
ke(${s}, ${c}, ${p})`,from:"@ez4/aws-topic/client",module:"Client"}},"prepareLin\
|
|
99
99
|
kedClient");var fe=i(e=>{let{service:t,options:r,context:o}=e;return L(t)?P(o,t,r):null},"pr\
|
|
@@ -111,13 +111,13 @@ context:n}=e;M(r)&&A(t,r,o,n)},"connectImports");import{ServiceType as Ft,Import
|
|
|
111
111
|
tryGetPolicy as Lt}from"@ez4/aws-identity";import{getServiceName as Mt}from"@ez4/project/library";var be=i(async e=>{let{state:t,serviceType:r,options:o}=e;if(r!==Ft&&r!==zt)return null;
|
|
112
112
|
let n=Object.values({options:o,...o.imports}).map(c=>Mt("",c)),[s]=n,p=`${s}-top\
|
|
113
113
|
ic-policy`;return Lt(t,p)??Dt(t,{tags:o.tags,policyDocument:await k(n),policyName:p})},
|
|
114
|
-
"prepareExecutionPolicy");var xe=!1,
|
|
114
|
+
"prepareExecutionPolicy");var xe=!1,wi=i(()=>{xe||(Ot(),kt(),$t(),jt(),Qt(),qt("@ez4/aws-topic",{"deploy:p\
|
|
115
115
|
repareExecutionPolicy":be,"deploy:prepareLinkedService":Gt,"deploy:prepareResour\
|
|
116
116
|
ces":Ht,"deploy:connectResources":_t}),U(),te(),xe=!0)},"registerTriggers"),Gt=i(
|
|
117
117
|
e=>fe(e)??ge(e)??null,"prepareLinkedService"),Ht=i(async e=>await le(e)||await de(
|
|
118
118
|
e),"prepareQueueResources"),_t=i(async e=>{await Promise.all([ye(e),Te(e)])},"co\
|
|
119
|
-
nnectQueueResources");var
|
|
119
|
+
nnectQueueResources");var Ci=i(e=>e.type===l,"isSubscriptionState");export{a as SubscriptionServiceName,l as SubscriptionServiceType,S as TopicServiceName,
|
|
120
120
|
f as TopicServiceType,I as createSubscription,ne as createSubscriptionFunction,E as createTopic,
|
|
121
|
-
N as createTopicStateId,
|
|
122
|
-
h as isTopicState,
|
|
121
|
+
N as createTopicStateId,Kr as getTopic,oe as getTopicArn,re as getTopicState,Ci as isSubscriptionState,
|
|
122
|
+
h as isTopicState,wi as registerTriggers};
|
|
123
123
|
//# sourceMappingURL=main.mjs.map
|
|
@@ -2,5 +2,5 @@ import type { TopicService, TopicImport } from '@ez4/topic/library';
|
|
|
2
2
|
import type { DeployOptions, EventContext } from '@ez4/project/library';
|
|
3
3
|
import type { EntryStates } from '@ez4/stateful';
|
|
4
4
|
import type { TopicState } from '../topic/types';
|
|
5
|
-
export declare const prepareSubscriptions: (state: EntryStates, service: TopicService | TopicImport, topicState: TopicState, options: DeployOptions, context: EventContext) =>
|
|
5
|
+
export declare const prepareSubscriptions: (state: EntryStates, service: TopicService | TopicImport, topicState: TopicState, options: DeployOptions, context: EventContext) => void;
|
|
6
6
|
export declare const connectSubscriptions: (state: EntryStates, service: TopicService | TopicImport, options: DeployOptions, context: EventContext) => void;
|
package/lib/message.ts
CHANGED
|
@@ -69,7 +69,7 @@ const onReady = async (request: Topic.Incoming<Topic.Message>) => {
|
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
const onError = async (error:
|
|
72
|
+
const onError = async (error: unknown, request: Topic.Request | Topic.Incoming<Topic.Message>) => {
|
|
73
73
|
console.error(error);
|
|
74
74
|
|
|
75
75
|
return dispatch(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/aws-topic",
|
|
3
3
|
"description": "EZ4: Self-managed AWS SNS topics provider",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.30.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"import": "./dist/client.mjs"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"./dist/main.cjs",
|
|
33
|
+
"./dist/main.mjs"
|
|
34
|
+
],
|
|
31
35
|
"workspaces": [
|
|
32
36
|
"foundation/*",
|
|
33
37
|
"contracts/*",
|
|
@@ -43,22 +47,22 @@
|
|
|
43
47
|
"live:publish": "npm run build && npm publish --access public"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"@types/aws-lambda": "^8.10.
|
|
50
|
+
"@types/aws-lambda": "^8.10.156"
|
|
47
51
|
},
|
|
48
52
|
"dependencies": {
|
|
49
|
-
"@aws-sdk/client-sns": "^3.
|
|
50
|
-
"@ez4/aws-common": "^0.
|
|
51
|
-
"@ez4/aws-identity": "^0.
|
|
52
|
-
"@ez4/aws-function": "^0.
|
|
53
|
-
"@ez4/aws-logs": "^0.
|
|
54
|
-
"@ez4/aws-queue": "^0.
|
|
55
|
-
"@ez4/topic": "^0.
|
|
56
|
-
"@ez4/project": "^0.
|
|
57
|
-
"@ez4/queue": "^0.
|
|
58
|
-
"@ez4/schema": "^0.
|
|
59
|
-
"@ez4/stateful": "^0.
|
|
60
|
-
"@ez4/transform": "^0.
|
|
61
|
-
"@ez4/validator": "^0.
|
|
62
|
-
"@ez4/utils": "^0.
|
|
53
|
+
"@aws-sdk/client-sns": "^3.913.0",
|
|
54
|
+
"@ez4/aws-common": "^0.30.0",
|
|
55
|
+
"@ez4/aws-identity": "^0.30.0",
|
|
56
|
+
"@ez4/aws-function": "^0.30.0",
|
|
57
|
+
"@ez4/aws-logs": "^0.30.0",
|
|
58
|
+
"@ez4/aws-queue": "^0.30.0",
|
|
59
|
+
"@ez4/topic": "^0.30.0",
|
|
60
|
+
"@ez4/project": "^0.30.0",
|
|
61
|
+
"@ez4/queue": "^0.30.0",
|
|
62
|
+
"@ez4/schema": "^0.30.0",
|
|
63
|
+
"@ez4/stateful": "^0.30.0",
|
|
64
|
+
"@ez4/transform": "^0.30.0",
|
|
65
|
+
"@ez4/validator": "^0.30.0",
|
|
66
|
+
"@ez4/utils": "^0.30.0"
|
|
63
67
|
}
|
|
64
68
|
}
|