@ez4/aws-function 0.38.0 → 0.40.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.
@@ -1,6 +1,6 @@
1
+ import type { Arn, OperationLogLine, ResourceTags } from '@ez4/aws-common';
1
2
  import type { ArchitectureType, RuntimeType } from '@ez4/project';
2
3
  import type { LinkedVariables } from '@ez4/project/library';
3
- import type { Arn, ResourceTags } from '@ez4/aws-common';
4
4
  export type CreateRequest = {
5
5
  roleArn: Arn;
6
6
  sourceFile: string;
@@ -37,17 +37,14 @@ export type UpdateSourceCodeRequest = {
37
37
  sourceFile: string;
38
38
  publish?: boolean;
39
39
  };
40
- export declare const importFunction: (functionName: string, version?: string) => Promise<ImportOrCreateResponse | undefined>;
41
- export declare const createFunction: (request: CreateRequest) => Promise<ImportOrCreateResponse>;
42
- export declare const updateSourceCode: (functionName: string, request: UpdateSourceCodeRequest) => Promise<{
43
- functionVersion: string | undefined;
40
+ export declare const importFunction: (logger: OperationLogLine, functionName: string, version?: string) => Promise<ImportOrCreateResponse | undefined>;
41
+ export declare const createFunction: (logger: OperationLogLine, request: CreateRequest) => Promise<ImportOrCreateResponse>;
42
+ export declare const updateSourceCode: (logger: OperationLogLine, functionName: string, request: UpdateSourceCodeRequest) => Promise<{
43
+ functionVersion?: string | undefined;
44
44
  functionArn: `arn:aws:${string}:${string}:${string}:${string}`;
45
- } | {
46
- functionArn: `arn:aws:${string}:${string}:${string}:${string}`;
47
- functionVersion?: undefined;
48
45
  }>;
49
- export declare const updateConfiguration: (functionName: string, request: UpdateConfigurationRequest) => Promise<void>;
50
- export declare const deleteFunction: (functionName: string) => Promise<void>;
51
- export declare const publishFunction: (functionName: string) => Promise<string | undefined>;
52
- export declare const tagFunction: (functionArn: Arn, tags: ResourceTags) => Promise<void>;
53
- export declare const untagFunction: (functionArn: Arn, tagKeys: string[]) => Promise<void>;
46
+ export declare const updateConfiguration: (logger: OperationLogLine, functionName: string, request: UpdateConfigurationRequest) => Promise<void>;
47
+ export declare const deleteFunction: (functionName: string, logger: OperationLogLine) => Promise<void>;
48
+ export declare const publishFunction: (logger: OperationLogLine, functionName: string) => Promise<string | undefined>;
49
+ export declare const tagFunction: (logger: OperationLogLine, functionArn: Arn, tags: ResourceTags) => Promise<void>;
50
+ export declare const untagFunction: (logger: OperationLogLine, functionArn: Arn, tagKeys: string[]) => Promise<void>;
@@ -8,11 +8,17 @@ export type GetFunctionFiles = () => [string, string[]];
8
8
  export type GetFunctionVariables = () => Promise<LinkedVariables> | LinkedVariables;
9
9
  export type GetFunctionBundle = (context: StepContext) => Promise<string> | string;
10
10
  export type GetFunctionHash = () => Promise<string | undefined> | string | undefined;
11
+ export type FunctionRelease = {
12
+ tagName?: string;
13
+ variableName?: string;
14
+ version: string;
15
+ };
11
16
  export type FunctionParameters = Omit<CreateRequest, 'roleArn' | 'publish' | 'variables'> & {
12
17
  getFunctionFiles: GetFunctionFiles;
13
18
  getFunctionVariables: GetFunctionVariables;
14
19
  getFunctionBundle: GetFunctionBundle;
15
20
  getFunctionHash: GetFunctionHash;
21
+ release?: FunctionRelease;
16
22
  };
17
23
  export type FunctionResult = ImportOrCreateResponse & {
18
24
  variables: LinkedVariables;
package/dist/main.cjs CHANGED
@@ -1,162 +1,177 @@
1
- "use strict";var rt=Object.create;var M=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var n=(e,t)=>M(e,"name",{value:t,configurable:!0});var at=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},ne=(e,t,r,o)=>{if(t&&
2
- typeof t=="object"||typeof t=="function")for(let i of ot(t))!st.call(e,i)&&i!==r&&
3
- M(e,i,{get:()=>t[i],enumerable:!(o=nt(t,i))||o.enumerable});return e};var pt=(e,t,r)=>(r=e!=null?rt(it(e)):{},ne(t||!e||!e.__esModule?M(r,"default",{value:e,
4
- enumerable:!0}):r,e)),ct=e=>ne(M({},"__esModule",{value:!0}),e);var Wt={};at(Wt,{FunctionArchitecture:()=>ie,FunctionDefaults:()=>tt,FunctionRuntime:()=>oe,
5
- FunctionServiceName:()=>p,FunctionServiceType:()=>f,MappingService:()=>ee,MappingServiceName:()=>F,
6
- MappingServiceType:()=>P,PermissionServiceName:()=>v,PermissionServiceType:()=>R,
7
- buildFunctionArn:()=>Bt,createFunction:()=>Gt,createMapping:()=>kt,createPermission:()=>Dt,
8
- getFunctionArchitecture:()=>H,getFunctionArn:()=>bt,getFunctionName:()=>N,getFunctionRuntime:()=>V,
9
- getFunctionState:()=>Pt,getPermission:()=>qt,isFunctionState:()=>X,isMappingState:()=>Ot,
10
- registerTriggers:()=>zt,tryGetFunctionArn:()=>he,tryGetFunctionState:()=>ht});module.
11
- exports=ct(Wt);var je=require("@ez4/aws-common"),Ze=require("@ez4/aws-identity"),Qe=require("@ez4/aws-logs"),
12
- _e=require("@ez4/project/library");var we=require("@ez4/aws-common");var S=require("@ez4/aws-common"),b=require("@ez4/utils"),_=require("@ez4/aws-logs"),
13
- J=require("@ez4/aws-identity");var s=require("@aws-sdk/client-lambda"),m=require("@ez4/aws-common");var B=require("@ez4/project");var oe=(r=>(r.Node22="nodejs22.x",r.Node24="nodejs24.x",r))(oe||{});var mt={[B.RuntimeType.Node22]:"nodejs22.x",[B.RuntimeType.Node24]:"nodejs24.x"},
14
- V=n(e=>mt[e],"getFunctionRuntime");var W=require("@ez4/project");var ie=(r=>(r.Arm="arm64",r.x86="x86_64",r))(ie||{});var ut={[W.ArchitectureType.Arm]:"arm64",[W.ArchitectureType.x86]:"x86_64"},H=n(
15
- e=>ut[e],"getFunctionArchitecture");var se=require("@ez4/aws-common"),ae=require("@ez4/utils");var p="AWS:Lambda/Function",f="aws:lambda.function";var lt=/[a-z][\w]+/i,gt=n(e=>lt.test(e),"isValidName"),$=n(e=>{for(let t in e)if(!gt(
16
- t))throw new se.InvalidParameterError(p,`${t} is an invalid variable name .`)},"\
17
- assertVariables"),E=n(e=>{let t={};for(let r in e)t[r]=(0,ae.hashData)(e[r]);return t},
18
- "protectVariables");var pe=pt(require("adm-zip"),1),ce=require("node:fs/promises");var me=n(async(e,t)=>{let r=new pe.default,o=await(0,ce.readFile)(e);return r.addFile(
19
- t,o),r.toBufferPromise()},"getZipBuffer");var w=new s.LambdaClient({}),U={minDelay:15,maxWaitTime:1800,maxDelay:60,client:w},
20
- ue=n(async(e,t)=>{m.Logger.logImport(p,e);try{let r=await w.send(new s.GetFunctionCommand(
21
- {FunctionName:e,Qualifier:t})),o=r.Configuration.Version,i=r.Configuration.FunctionArn;
22
- return{functionVersion:o,functionArn:i}}catch(r){if(!(r instanceof s.ResourceNotFoundException))
23
- throw r;return}},"importFunction"),le=n(async e=>{let{functionName:t,variables:r}=e;
24
- m.Logger.logCreate(p,t),r&&$(r);let o=Se(e.handlerName),i=await fe(e.sourceFile),
25
- {description:a,memory:c,timeout:l,architecture:g,runtime:y,debug:d,roleArn:x,logGroup:C}=e,
26
- O=await(0,m.waitCreation)(()=>w.send(new s.CreateFunctionCommand({FunctionName:t,
27
- Description:a,MemorySize:c,Timeout:l,Role:x,Handler:o,Architectures:[H(g)],Runtime:V(
28
- y),PackageType:"Zip",LoggingConfig:{LogGroup:C,ApplicationLogLevel:d?s.ApplicationLogLevel.
29
- Debug:s.ApplicationLogLevel.Warn,SystemLogLevel:s.SystemLogLevel.Warn,LogFormat:s.LogFormat.
30
- Json},Code:{ZipFile:i},Environment:{Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}})));
31
- m.Logger.logWait(p,t),await(0,s.waitUntilFunctionActive)(U,{FunctionName:t});let L=O.
32
- FunctionArn;return e.publish?{functionVersion:await de(t),functionArn:L}:{functionArn:L}},
33
- "createFunction"),j=n(async(e,t)=>{m.Logger.logUpdate(p,`${e} source code`);let r=await fe(
34
- t.sourceFile),{publish:o,architecture:i}=t,a=await w.send(new s.UpdateFunctionCodeCommand(
35
- {Architectures:i&&[H(i)],FunctionName:e,ZipFile:r,Publish:o}));m.Logger.logWait(
36
- p,e),await(0,s.waitUntilFunctionUpdated)(U,{FunctionName:e});let c=a.FunctionArn;
37
- return t.publish?{functionVersion:await de(e),functionArn:c}:{functionArn:c}},"u\
38
- pdateSourceCode"),Z=n(async(e,t)=>{let{handlerName:r,variables:o}=t;m.Logger.logUpdate(
39
- p,`${e} configuration`),o&&$(o);let{description:i,memory:a,timeout:c,runtime:l,debug:g,
40
- roleArn:y,logGroup:d}=t;await w.send(new s.UpdateFunctionConfigurationCommand({Runtime:l&&
41
- V(l),FunctionName:e,Description:i,MemorySize:a,Timeout:c,Role:y,...r&&{Handler:Se(
42
- r)},LoggingConfig:{LogGroup:d,ApplicationLogLevel:g?s.ApplicationLogLevel.Debug:
1
+ "use strict";var it=Object.create;var M=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var o=(t,e)=>M(t,"name",{value:e,configurable:!0});var ut=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,r)=>{if(e&&
2
+ typeof e=="object"||typeof e=="function")for(let i of st(e))!ct.call(t,i)&&i!==n&&
3
+ M(t,i,{get:()=>e[i],enumerable:!(r=at(e,i))||r.enumerable});return t};var mt=(t,e,n)=>(n=t!=null?it(pt(t)):{},ae(e||!t||!t.__esModule?M(n,"default",{value:t,
4
+ enumerable:!0}):n,t)),lt=t=>ae(M({},"__esModule",{value:!0}),t);var Zt={};ut(Zt,{FunctionArchitecture:()=>ce,FunctionDefaults:()=>rt,FunctionRuntime:()=>pe,
5
+ FunctionServiceName:()=>F,FunctionServiceType:()=>x,MappingService:()=>Me,MappingServiceName:()=>R,
6
+ MappingServiceType:()=>v,PermissionServiceName:()=>E,PermissionServiceType:()=>w,
7
+ buildFunctionArn:()=>jt,createFunction:()=>qt,createMapping:()=>Wt,createPermission:()=>kt,
8
+ getFunctionArchitecture:()=>G,getFunctionArn:()=>At,getFunctionName:()=>L,getFunctionRuntime:()=>z,
9
+ getFunctionState:()=>Ct,getPermission:()=>Bt,isFunctionState:()=>te,isMappingState:()=>$t,
10
+ registerTriggers:()=>Dt,tryGetFunctionArn:()=>Pe,tryGetFunctionState:()=>Pt});module.
11
+ exports=lt(Zt);var Qe=require("@ez4/aws-common"),_e=require("@ez4/aws-identity"),Je=require("@ez4/aws-logs"),
12
+ Ke=require("@ez4/project/library");var be=require("@ez4/aws-common");var S=require("@ez4/aws-common"),P=require("@ez4/utils"),X=require("@ez4/aws-logs"),
13
+ Y=require("@ez4/aws-identity");var s=require("@aws-sdk/client-lambda"),D=require("@ez4/aws-common");var O=require("@ez4/aws-common"),se=require("@aws-sdk/client-lambda");var d=o(()=>new se.LambdaClient((0,O.getAwsClientOptions)()),"getLambdaClient"),
14
+ U=o(t=>({...(0,O.getAwsClientWaiter)(),client:t}),"getLambdaWaiter");var j=require("@ez4/project");var pe=(n=>(n.Node22="nodejs22.x",n.Node24="nodejs24.x",n))(pe||{});var gt={[j.RuntimeType.Node22]:"nodejs22.x",[j.RuntimeType.Node24]:"nodejs24.x"},
15
+ z=o(t=>gt[t],"getFunctionRuntime");var Z=require("@ez4/project");var ce=(n=>(n.Arm="arm64",n.x86="x86_64",n))(ce||{});var dt={[Z.ArchitectureType.Arm]:"arm64",[Z.ArchitectureType.x86]:"x86_64"},G=o(
16
+ t=>dt[t],"getFunctionArchitecture");var ue=require("@ez4/aws-common"),me=require("@ez4/utils");var F="AWS:Lambda/Function",x="aws:lambda.function";var ft=/[a-z][\w]+/i,yt=o(t=>ft.test(t),"isValidName"),Q=o(t=>{for(let e in t)if(!yt(
17
+ e))throw new ue.InvalidParameterError(F,`${e} is an invalid variable name .`)},"\
18
+ assertVariables"),A=o(t=>{let e={};for(let n in t)e[n]=(0,me.hashData)(t[n]);return e},
19
+ "protectVariables");var le=mt(require("adm-zip"),1),ge=require("node:fs/promises");var de=o(async(t,e)=>{let n=new le.default,r=await(0,ge.readFile)(t);return n.addFile(
20
+ e,r),n.toBufferPromise()},"getZipBuffer");var fe=o(async(t,e,n)=>{t.update("Importing function");try{let r=await d().send(
21
+ new s.GetFunctionCommand({FunctionName:e,Qualifier:n})),i=r.Configuration.Version,
22
+ a=r.Configuration.FunctionArn;return{functionVersion:i,functionArn:a}}catch(r){if(!(r instanceof
23
+ s.ResourceNotFoundException))throw r;return}},"importFunction"),ye=o(async(t,e)=>{
24
+ t.update("Creating function");let{functionName:n,variables:r}=e;r&&Q(r);let i=we(
25
+ e.handlerName),a=await xe(e.sourceFile),{description:p,memory:c,timeout:m,publish:u,
26
+ architecture:l,runtime:g,debug:y,roleArn:h,logGroup:C}=e,V=d(),H=await(0,D.waitCreation)(
27
+ ()=>V.send(new s.CreateFunctionCommand({FunctionName:n,Description:p,MemorySize:c,
28
+ Timeout:m,Role:h,Publish:u,Handler:i,Architectures:[G(l)],Runtime:z(g),PackageType:"\
29
+ Zip",LoggingConfig:{LogGroup:C,ApplicationLogLevel:y?s.ApplicationLogLevel.Debug:
43
30
  s.ApplicationLogLevel.Warn,SystemLogLevel:s.SystemLogLevel.Warn,LogFormat:s.LogFormat.
44
- Json},Environment:{Variables:o}})),m.Logger.logWait(p,e),await(0,s.waitUntilFunctionUpdated)(
45
- U,{FunctionName:e})},"updateConfiguration"),ge=n(async e=>{m.Logger.logDelete(p,
46
- e),await(0,m.waitDeletion)(async()=>{try{await w.send(new s.DeleteFunctionCommand(
47
- {FunctionName:e}))}catch(t){if(!(t instanceof s.ResourceNotFoundException))throw t}})},
48
- "deleteFunction"),de=n(async e=>{m.Logger.logPublish(p,e);let t=await w.send(new s.PublishVersionCommand(
49
- {FunctionName:e}));m.Logger.logWait(p,e);let r=t.Version;return await(0,s.waitUntilPublishedVersionActive)(
50
- U,{FunctionName:e,Qualifier:r}),r},"publishFunction"),Q=n(async(e,t)=>{let r=(0,m.tryParseArn)(
51
- e)?.resourceName??e;m.Logger.logTag(p,r),await w.send(new s.TagResourceCommand({
52
- Resource:e,Tags:{...t,ManagedBy:"EZ4"}}))},"tagFunction"),ye=n(async(e,t)=>{let r=(0,m.tryParseArn)(
53
- e)?.resourceName??e;m.Logger.logUntag(p,r),await w.send(new s.UntagResourceCommand(
54
- {Resource:e,TagKeys:t}))},"untagFunction"),fe=n(e=>me(e,"main.mjs"),"getSourceZi\
55
- pFile"),Se=n(e=>`main.${e}`,"getSourceHandlerName");var Fe=n(()=>({equals:dt,create:xe,replace:ft,preview:yt,update:St,delete:Ft}),"\
56
- getFunctionHandler"),dt=n((e,t)=>!!e.result&&e.result.functionArn===t.result?.functionArn,
57
- "equalsResource"),yt=n(async(e,t)=>{let r=e.parameters,o=t.parameters,i=(0,b.deepCompare)(
58
- {...r,connections:e.connections,dependencies:e.dependencies,variables:E(await r.
59
- getFunctionVariables()),sourceHash:await(0,S.getBundleHash)(...r.getFunctionFiles()),
60
- valuesHash:r.getFunctionHash()},{...o,connections:t.connections,dependencies:t.dependencies,
61
- variables:t.result?.variables,sourceHash:t.result?.sourceHash,valuesHash:t.result?.
62
- valuesHash});if(i.counts)return{...i,name:r.functionName}},"previewResource"),ft=n(
63
- async(e,t,r)=>{if(t.result)throw new S.ReplaceResourceError(p,e.entryId,t.entryId);
64
- return xe(e,r)},"replaceResource"),xe=n(async(e,t)=>{let{functionName:r,...o}=e.
65
- parameters,i=(0,_.getLogGroupName)(p,r,t),a=(0,J.getRoleArn)(p,r,t),[c,l,g,y]=await Promise.
66
- all([(0,S.getBundleHash)(...o.getFunctionFiles()),o.getFunctionBundle(t),o.getFunctionHash(),
67
- o.getFunctionVariables()]),d=await ue(r),x=await(0,b.hashFile)(l);if(d)return await Z(
68
- r,{...o,variables:y,logGroup:i,roleArn:a}),await j(r,{architecture:o.architecture,
69
- publish:!1,sourceFile:l}),await Q(d.functionArn,{...o.tags}),{functionArn:d.functionArn,
70
- functionVersion:d.functionVersion,variables:E(y),valuesHash:g,sourceHash:c,bundleHash:x,
71
- logGroup:i,roleArn:a};let C=await le({...o,publish:!0,functionName:r,sourceFile:l,
72
- variables:y,logGroup:i,roleArn:a});return{functionArn:C.functionArn,functionVersion:C.
73
- functionVersion,variables:E(y),valuesHash:g,sourceHash:c,bundleHash:x,logGroup:i,
74
- roleArn:a}},"createResource"),St=n(async(e,t,r)=>{let{parameters:o,result:i}=e;if(!i)
75
- return;let a=o.functionName,c=await o.getFunctionVariables(),l=t.result?.variables??
76
- c,g=(0,J.getRoleArn)(p,a,r),y=t.result?.roleArn??g,d=(0,_.getLogGroupName)(p,a,r),
77
- x=t.result?.logGroup??d,C={...o,variables:c,roleArn:g,logGroup:d},O={...t.parameters,
78
- variables:l,roleArn:y,logGroup:x};await xt(a,C,O,r),await wt(i.functionArn,o,t.parameters);
79
- let L=await Rt(a,o,t.result,r);return{...i,...L,variables:E(c),logGroup:d,roleArn:g}},
80
- "updateResource"),Ft=n(async e=>{let{result:t,parameters:r}=e;t&&await ge(r.functionName)},
81
- "deleteResource"),xt=n(async(e,t,r,o)=>{let{variables:i,...a}=t,c={variables:E(i),
82
- ...a};(!(0,b.deepEqual)(c,r,{exclude:{sourceFile:!0,functionName:!0,architecture:!0,
83
- tags:!0}})||o.force)&&await Z(e,t)},"checkConfigurationUpdates"),wt=n(async(e,t,r)=>{
84
- await(0,S.applyTagUpdates)(t.tags,r.tags,o=>Q(e,o),o=>ye(e,o))},"checkTagUpdates"),
85
- Rt=n(async(e,t,r,o)=>{let[i,a]=await Promise.all([(0,S.getBundleHash)(...t.getFunctionFiles()),
86
- t.getFunctionHash()]),c=r?.sourceHash,l=r?.valuesHash;if(i!==c||a!==l||o.force){
87
- let g=await t.getFunctionBundle(o),y=await(0,b.hashFile)(g),d=r?.bundleHash;if(y===
88
- d&&a===l)return S.Logger.logSkip(p,`${e} source code`),{valuesHash:a,sourceHash:i};
89
- let{functionVersion:x}=await j(e,{architecture:t.architecture,publish:!r?.functionVersion,
90
- sourceFile:g});return{valuesHash:a,sourceHash:i,bundleHash:y,...x&&{functionVersion:x}}}},
91
- "checkSourceCodeUpdates");var Re=n(()=>{(0,we.tryRegisterProvider)(f,Fe())},"registerFunctionProvider");var Ne=require("@ez4/aws-common");var Ae=require("@ez4/aws-common");var K=require("@ez4/aws-common");var z=class extends Error{static{n(this,"FunctionNotFoundError")}constructor(t){
92
- super(`Function ${t} wasn't found.`)}};var X=n(e=>e.type===f,"isFunctionState"),ht=n((e,t,r)=>{try{let o=e.getServiceState(
93
- t,r);if(X(o))return o}catch{}},"tryGetFunctionState"),Pt=n((e,t,r)=>{let o=e.getServiceState(
94
- t,r);if(!X(o))throw new z(t);return o},"getFunctionState"),N=n((e,t,r)=>{let o=r.
95
- getDependencies(f).at(0)?.parameters;if(!o?.functionName)throw new K.IncompleteResourceError(
96
- e,t,"functionName");return o.functionName},"getFunctionName"),he=n(e=>e.getDependencies(
97
- f)[0]?.result?.functionArn,"tryGetFunctionArn"),bt=n((e,t,r)=>{let o=he(r);if(!o)
98
- throw new K.IncompleteResourceError(e,t,"functionArn");return o},"getFunctionArn");var h=require("@aws-sdk/client-lambda"),Y=require("@ez4/aws-common");var v="AWS:Lambda/Permission",R="aws:lambda.permission";var Pe=new h.LambdaClient({}),be=n(async e=>{Y.Logger.logCreate(v,e.functionName);
99
- let t=e.statementId??`ID${Date.now()}`;return await Pe.send(new h.AddPermissionCommand(
100
- {StatementId:t,FunctionName:e.functionName,SourceArn:e.sourceArn,Principal:e.principal,
101
- Action:e.action})),{statementId:t}},"createPermission"),ve=n(async(e,t)=>{Y.Logger.
102
- logDelete(v,e);try{return await Pe.send(new h.RemovePermissionCommand({FunctionName:e,
103
- StatementId:t})),!0}catch(r){if(!(r instanceof h.ResourceNotFoundException))throw r;
104
- return!1}},"deletePermission");var Ce=n(()=>({equals:vt,create:Ee,replace:Ct,preview:At,update:Et,delete:Nt}),"\
105
- getPermissionHandler"),vt=n((e,t)=>!!e.result&&e.result.functionName===t.result?.
106
- functionName,"equalsResource"),At=n((e,t)=>{},"previewResource"),Ct=n(async(e,t,r)=>{
107
- if(t.result)throw new Ae.ReplaceResourceError(v,e.entryId,t.entryId);return Ee(e,
108
- r)},"replaceResource"),Ee=n(async(e,t)=>{let r=e.parameters,o=N(v,"permission",t),
109
- i=await r.getPermission(t);return{statementId:(await be({action:"lambda:InvokeFu\
110
- nction",sourceArn:i.sourceArn,principal:i.principal,functionName:o})).statementId,
111
- functionName:o}},"createResource"),Et=n(async()=>{},"updateResource"),Nt=n(async e=>{
112
- let t=e.result;t&&await ve(t.functionName,t.statementId)},"deleteResource");var Ie=n(()=>{(0,Ne.tryRegisterProvider)(R,Ce())},"registerPermissionProvider");var qe=require("@ez4/aws-common");var ze=require("@ez4/aws-common"),G=require("@ez4/utils");var u=require("@aws-sdk/client-lambda"),A=require("@ez4/aws-common"),te=require("@ez4/utils");var F="AWS:Lambda/Mapping",P="aws:lambda.mapping",ee=(r=>(r.DynamoDB="dynamodb",
113
- r.Queue="sqs",r))(ee||{});var T=new u.LambdaClient({}),Me=n(async(e,t)=>{A.Logger.logImport(F,e);let r=await T.
114
- send(new u.ListEventSourceMappingsCommand({FunctionName:e,EventSourceArn:t})),[o]=r.
115
- EventSourceMappings;return o?{eventId:o.UUID}:void 0},"importMapping"),Te=n(async e=>{
116
- let{sourceArn:t,functionName:r}=e;A.Logger.logCreate(F,r);let i=(await T.send(new u.CreateEventSourceMappingCommand(
117
- {FunctionName:r,EventSourceArn:t,...Ue(e)}))).UUID;return await He(i),{eventId:i}},
118
- "createMapping"),Le=n(async(e,t)=>{let{functionName:r}=t;A.Logger.logUpdate(F,`${r}\
119
- (${e})`),await T.send(new u.UpdateEventSourceMappingCommand({UUID:e,FunctionName:r,
120
- ...Ue(t)})),await He(e)},"updateMapping"),Ve=n(async e=>{A.Logger.logDelete(F,e);
121
- try{return await T.send(new u.DeleteEventSourceMappingCommand({UUID:e})),!0}catch(t){
122
- if(!(t instanceof u.ResourceNotFoundException))throw t;return!1}},"deleteMapping"),
123
- It=n(async e=>(await T.send(new u.GetEventSourceMappingCommand({UUID:e}))).State,
124
- "getMappingState"),He=n(async e=>{let t=new Set(["Enabled","Disabled"]);await te.Wait.
125
- until(async()=>{let r=await It(e);return t.has(r)?!0:te.Wait.RetryAttempt})},"wa\
126
- itForReadyState"),Ue=n(e=>{let{sourceArn:t,enabled:r,concurrency:o,batch:i}=e,{service:a}=(0,A.parseArn)(
127
- t);return{Enabled:r,FunctionResponseTypes:[u.FunctionResponseType.ReportBatchItemFailures],
31
+ Json},Code:{ZipFile:a},Environment:{Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}}))),
32
+ ot=H.FunctionArn,oe=H.Version,ie=U(V);return await(0,s.waitUntilFunctionActive)(
33
+ ie,{FunctionName:n}),u&&await(0,s.waitUntilPublishedVersionActive)(ie,{FunctionName:n,
34
+ Qualifier:oe}),{functionArn:ot,...u&&{functionVersion:oe}}},"createFunction"),_=o(
35
+ async(t,e,n)=>{t.update("Updating source code");let r=await xe(n.sourceFile),{publish:i,
36
+ architecture:a}=n,p=d(),c=await p.send(new s.UpdateFunctionCodeCommand({Architectures:a&&
37
+ [G(a)],FunctionName:e,ZipFile:r,Publish:i})),m=c.FunctionArn,u=c.Version,l=U(p);
38
+ return await(0,s.waitUntilFunctionUpdated)(l,{FunctionName:e}),i&&await(0,s.waitUntilPublishedVersionActive)(
39
+ l,{FunctionName:e,Qualifier:u}),{functionArn:m,...i&&{functionVersion:u}}},"upda\
40
+ teSourceCode"),J=o(async(t,e,n)=>{t.update("Updating configuration");let{handlerName:r,
41
+ variables:i}=n;i&&Q(i);let{description:a,memory:p,timeout:c,runtime:m,debug:u,roleArn:l,
42
+ logGroup:g}=n,y=d();await y.send(new s.UpdateFunctionConfigurationCommand({Runtime:m&&
43
+ z(m),FunctionName:e,Description:a,MemorySize:p,Timeout:c,Role:l,...r&&{Handler:we(
44
+ r)},LoggingConfig:{LogGroup:g,ApplicationLogLevel:u?s.ApplicationLogLevel.Debug:
45
+ s.ApplicationLogLevel.Warn,SystemLogLevel:s.SystemLogLevel.Warn,LogFormat:s.LogFormat.
46
+ Json},Environment:{Variables:i}})),await(0,s.waitUntilFunctionUpdated)(U(y),{FunctionName:e})},
47
+ "updateConfiguration"),Se=o(async(t,e)=>{e.update("Deleting function");let n=d();
48
+ await(0,D.waitDeletion)(async()=>{try{await n.send(new s.DeleteFunctionCommand({
49
+ FunctionName:t}))}catch(r){if(!(r instanceof s.ResourceNotFoundException))throw r}})},
50
+ "deleteFunction");var K=o(async(t,e,n)=>{t.update("Tag function"),await d().send(new s.TagResourceCommand(
51
+ {Resource:e,Tags:{...n,ManagedBy:"EZ4"}}))},"tagFunction"),Fe=o(async(t,e,n)=>{t.
52
+ update("Untag function"),await d().send(new s.UntagResourceCommand({Resource:e,TagKeys:n}))},
53
+ "untagFunction"),xe=o(t=>de(t,"main.mjs"),"getSourceZipFile"),we=o(t=>`main.${t}`,
54
+ "getSourceHandlerName");var Re=o(()=>({equals:St,create:ve,replace:xt,preview:Ft,update:wt,delete:Rt}),"\
55
+ getFunctionHandler"),St=o((t,e)=>!!t.result&&t.result.functionArn===e.result?.functionArn,
56
+ "equalsResource"),Ft=o(async(t,e)=>{let n=t.parameters,r=e.parameters,i=(0,P.deepCompare)(
57
+ {...n,connections:t.connections,dependencies:t.dependencies,variables:A(await n.
58
+ getFunctionVariables()),sourceHash:await(0,S.getBundleHash)(...n.getFunctionFiles()),
59
+ valuesHash:n.getFunctionHash()},{...r,connections:e.connections,dependencies:e.dependencies,
60
+ variables:e.result?.variables,sourceHash:e.result?.sourceHash,valuesHash:e.result?.
61
+ valuesHash},{exclude:{release:!0}});if(i.counts)return{...i,name:n.functionName}},
62
+ "previewResource"),xt=o(async(t,e,n)=>{if(e.result)throw new S.ReplaceResourceError(
63
+ F,t.entryId,e.entryId);return ve(t,n)},"replaceResource"),ve=o((t,e)=>{let{functionName:n,
64
+ release:r,...i}=t.parameters;return S.OperationLogger.logExecution(F,n,"creation",
65
+ async a=>{let p=(0,X.getLogGroupName)(F,n,e),c=(0,Y.getRoleArn)(F,n,e),[m,u,l,g]=await Promise.
66
+ all([(0,S.getBundleHash)(...i.getFunctionFiles()),i.getFunctionBundle(e),i.getFunctionHash(),
67
+ i.getFunctionVariables()]),y=await fe(a,n),h=await(0,P.hashFile)(u);if(y)return await _(
68
+ a,n,{architecture:i.architecture,publish:!1,sourceFile:u}),await J(a,n,{...i,logGroup:p,
69
+ roleArn:c,variables:{...g,...r?.variableName&&{[r.variableName]:r.version}}}),await K(
70
+ a,y.functionArn,{...i.tags,...r?.tagName&&{[r.tagName]:r.version}}),{functionArn:y.
71
+ functionArn,functionVersion:y.functionVersion,variables:A(g),valuesHash:l,sourceHash:m,
72
+ bundleHash:h,logGroup:p,roleArn:c};let C=await ye(a,{...i,publish:!0,functionName:n,
73
+ sourceFile:u,logGroup:p,roleArn:c,variables:{...g,...r?.variableName&&{[r.variableName]:r.
74
+ version}},tags:{...i.tags,...r?.tagName&&{[r.tagName]:r.version}}});return{functionArn:C.
75
+ functionArn,functionVersion:C.functionVersion,variables:A(g),valuesHash:l,sourceHash:m,
76
+ bundleHash:h,logGroup:p,roleArn:c}})},"createResource"),wt=o((t,e,n)=>{let{parameters:r,
77
+ result:i}=t,{functionName:a}=r;if(!i)throw new S.CorruptedResourceError(F,a);return S.OperationLogger.
78
+ logExecution(F,a,"updates",async p=>{let c=await r.getFunctionVariables(),m=e.result?.
79
+ variables??c,u=(0,Y.getRoleArn)(F,a,n),l=e.result?.roleArn??u,g=(0,X.getLogGroupName)(
80
+ F,a,n),y=e.result?.logGroup??g,{isUpdated:h,...C}=await ht(p,a,r,e.result,n),V={
81
+ ...r,variables:c,roleArn:u,logGroup:g},H={...e.parameters,variables:m,roleArn:l,
82
+ logGroup:y};return await vt(p,a,V,H,h,n),await bt(p,i.functionArn,r,e.parameters,
83
+ h),{...i,...C,variables:A(c),logGroup:g,roleArn:u}})},"updateResource"),Rt=o(async t=>{
84
+ let{result:e,parameters:n}=t;if(!e)return;let{functionName:r}=n;await S.OperationLogger.
85
+ logExecution(F,r,"deletion",async i=>{await Se(r,i)})},"deleteResource"),vt=o(async(t,e,n,r,i,a)=>{
86
+ let{variables:p,...c}=n,m={variables:A(p),...c},u=!(0,P.deepEqual)(m,r,{exclude:{
87
+ sourceFile:!0,functionName:!0,architecture:!0,release:!0,tags:!0}}),l=i?n.release:
88
+ r.release,g=i&&l?.variableName;(u||g||a.force)&&await J(t,e,{...n,variables:{...n.
89
+ variables,...l?.variableName&&{[l.variableName]:l.version}}})},"checkConfigurati\
90
+ onUpdates"),bt=o(async(t,e,n,r,i)=>{let p=i&&n.release?.version!==r.release?.version?
91
+ n.release:void 0,c={...n.tags,...p?.tagName&&{[p.tagName]:p.version}};await(0,S.applyTagUpdates)(
92
+ c,r.tags,m=>K(t,e,m),m=>Fe(t,e,m))},"checkTagUpdates"),ht=o(async(t,e,n,r,i)=>{let[
93
+ a,p]=await Promise.all([(0,S.getBundleHash)(...n.getFunctionFiles()),n.getFunctionHash()]),
94
+ c=r?.sourceHash,m=r?.valuesHash;if(a!==c||p!==m||i.force){let u=await n.getFunctionBundle(
95
+ i),l=await(0,P.hashFile)(u),g=r?.bundleHash;if(l===g&&p===m)return t.update("Ski\
96
+ pping source code update"),{isUpdated:!1,valuesHash:p,sourceHash:a};let{functionVersion:y}=await _(
97
+ t,e,{architecture:n.architecture,publish:!r?.functionVersion,sourceFile:u});return{
98
+ isUpdated:!0,valuesHash:p,sourceHash:a,bundleHash:l,...y&&{functionVersion:y}}}return{
99
+ isUpdated:!1}},"checkSourceCodeUpdates");var he=o(()=>{(0,be.tryRegisterProvider)(x,Re())},"registerFunctionProvider");var Ee=require("@ez4/aws-common");var T=require("@ez4/aws-common");var ee=require("@ez4/aws-common");var q=class extends Error{static{o(this,"FunctionNotFoundError")}constructor(e){
100
+ super(`Function ${e} wasn't found.`)}};var te=o(t=>t.type===x,"isFunctionState"),Pt=o((t,e,n)=>{try{let r=t.getServiceState(
101
+ e,n);if(te(r))return r}catch{}},"tryGetFunctionState"),Ct=o((t,e,n)=>{let r=t.getServiceState(
102
+ e,n);if(!te(r))throw new q(e);return r},"getFunctionState"),L=o((t,e,n)=>{let r=n.
103
+ getDependencies(x).at(0)?.parameters;if(!r?.functionName)throw new ee.IncompleteResourceError(
104
+ t,e,"functionName");return r.functionName},"getFunctionName"),Pe=o(t=>t.getDependencies(
105
+ x)[0]?.result?.functionArn,"tryGetFunctionArn"),At=o((t,e,n)=>{let r=Pe(n);if(!r)
106
+ throw new ee.IncompleteResourceError(t,e,"functionArn");return r},"getFunctionAr\
107
+ n");var N=require("@aws-sdk/client-lambda");var Ce=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
108
+ now()}`;return await d().send(new N.AddPermissionCommand({StatementId:n,FunctionName:e.
109
+ functionName,SourceArn:e.sourceArn,Principal:e.principal,Action:e.action})),{statementId:n}},
110
+ "createPermission"),Ae=o(async(t,e,n)=>{t.update("Deleting permission");try{return await d().
111
+ send(new N.RemovePermissionCommand({FunctionName:e,StatementId:n})),!0}catch(r){
112
+ if(!(r instanceof N.ResourceNotFoundException))throw r;return!1}},"deletePermiss\
113
+ ion");var E="AWS:Lambda/Permission",w="aws:lambda.permission";var Le=o(()=>({equals:Lt,create:Ne,replace:Et,preview:Nt,update:It,delete:Mt}),"\
114
+ getPermissionHandler"),Lt=o((t,e)=>!!t.result&&t.result.functionName===e.result?.
115
+ functionName,"equalsResource"),Nt=o((t,e)=>{},"previewResource"),Et=o(async(t,e,n)=>{
116
+ if(e.result)throw new T.ReplaceResourceError(E,t.entryId,e.entryId);return Ne(t,
117
+ n)},"replaceResource"),Ne=o((t,e)=>{let n=t.parameters,r=L(E,"permission",e);return T.OperationLogger.
118
+ logExecution(E,r,"creation",async i=>{let a=await n.getPermission(e);return{statementId:(await Ce(
119
+ i,{action:"lambda:InvokeFunction",sourceArn:a.sourceArn,principal:a.principal,functionName:r})).
120
+ statementId,functionName:r}})},"createResource"),It=o(async()=>{},"updateResourc\
121
+ e"),Mt=o(async t=>{let e=t.result;if(!e)return;let{functionName:n,statementId:r}=e;
122
+ await T.OperationLogger.logExecution(E,n,"deletion",async i=>{await Ae(i,n,r)})},
123
+ "deleteResource");var Ie=o(()=>{(0,Ee.tryRegisterProvider)(w,Le())},"registerPermissionProvider");var ke=require("@ez4/aws-common");var b=require("@ez4/aws-common"),k=require("@ez4/utils");var f=require("@aws-sdk/client-lambda"),Te=require("@ez4/aws-common"),ne=require("@ez4/utils");var R="AWS:Lambda/Mapping",v="aws:lambda.mapping",Me=(n=>(n.DynamoDB="dynamodb",
124
+ n.Queue="sqs",n))(Me||{});var Ve=o(async(t,e,n)=>{t.update("Importing mapping");let r=await d().send(new f.ListEventSourceMappingsCommand(
125
+ {FunctionName:e,EventSourceArn:n})),[i]=r.EventSourceMappings;return i?{eventId:i.
126
+ UUID}:void 0},"importMapping"),He=o(async(t,e)=>{t.update("Creating mapping");let{
127
+ sourceArn:n,functionName:r}=e,a=(await d().send(new f.CreateEventSourceMappingCommand(
128
+ {FunctionName:r,EventSourceArn:n,...Ge(e)}))).UUID;return await ze(a),{eventId:a}},
129
+ "createMapping"),Oe=o(async(t,e,n)=>{t.update("Updating mapping");let{functionName:r}=n;
130
+ await d().send(new f.UpdateEventSourceMappingCommand({UUID:e,FunctionName:r,...Ge(
131
+ n)})),await ze(e)},"updateMapping"),Ue=o(async(t,e)=>{t.update("Deleting mapping");
132
+ try{return await d().send(new f.DeleteEventSourceMappingCommand({UUID:e})),!0}catch(n){
133
+ if(!(n instanceof f.ResourceNotFoundException))throw n;return!1}},"deleteMapping"),
134
+ Tt=o(async t=>(await d().send(new f.GetEventSourceMappingCommand({UUID:t}))).State,
135
+ "getMappingState"),ze=o(async t=>{let e=new Set(["Enabled","Disabled"]);await ne.Wait.
136
+ until(async()=>{let n=await Tt(t);return e.has(n)?!0:ne.Wait.RetryAttempt})},"wa\
137
+ itForReadyState"),Ge=o(t=>{let{sourceArn:e,enabled:n,concurrency:r,batch:i}=t,{service:a}=(0,Te.parseArn)(
138
+ e);return{Enabled:n,FunctionResponseTypes:[f.FunctionResponseType.ReportBatchItemFailures],
128
139
  MaximumBatchingWindowInSeconds:i?.maxWait,BatchSize:i?.size,...a==="dynamodb"&&{
129
- StartingPosition:u.EventSourcePosition.LATEST},...a==="sqs"&&{ScalingConfig:{MaximumConcurrency:o}}}},
130
- "upsertMappingRequest");var Ge=n(()=>({equals:Mt,create:De,replace:Lt,preview:Tt,update:Vt,delete:Ht}),"\
131
- getMappingHandler"),Mt=n((e,t)=>!!e.result&&e.result.eventId===t.result?.eventId,
132
- "equalsResource"),Tt=n((e,t)=>{let r={...e.parameters,dependencies:e.dependencies},
133
- o={...t.parameters,dependencies:t.dependencies},i=(0,G.deepCompare)(r,o,{exclude:{
134
- getSourceArn:!0}});if(i.counts)return{...i,name:r.fromService}},"previewResource"),
135
- Lt=n(async(e,t,r)=>{if(t.result)throw new ze.ReplaceResourceError(F,e.entryId,t.
136
- entryId);return De(e,r)},"replaceResource"),De=n(async(e,t)=>{let r=e.parameters,
137
- o=N(F,"mapping",t),i=await r.getSourceArn(t);return{eventId:(await Me(o,i)??await Te(
138
- {...e.parameters,functionName:o,sourceArn:i})).eventId,functionName:o,sourceArn:i}},
139
- "createResource"),Vt=n(async(e,t,r)=>{let o=e.result;if(!o)return;let i=o.sourceArn,
140
- a=N(F,"mapping",r),c=t.result?.functionName??o.functionName,l={...e.parameters,functionName:a,
141
- sourceArn:i},g={...t.parameters,functionName:c,sourceArn:i};return await Ut(o.eventId,
142
- l,g),{...o,functionName:a}},"updateResource"),Ht=n(async e=>{let t=e.result;t&&await Ve(
143
- t.eventId)},"deleteResource"),Ut=n(async(e,t,r)=>{!(0,G.deepEqual)(t,r,{exclude:{
144
- getSourceArn:!0,fromService:!0}})&&await Le(e,t)},"checkGeneralUpdates");var ke=n(()=>{(0,qe.tryRegisterProvider)(P,Ge())},"registerMappingProvider");var Oe=n(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");var D=require("@ez4/aws-identity"),We=require("@ez4/project/library");var I=require("@ez4/aws-identity");var Be=n(async e=>{let[t,r]=await Promise.all([(0,I.getRegion)(),(0,I.getAccountId)()]);
140
+ StartingPosition:f.EventSourcePosition.LATEST},...a==="sqs"&&{ScalingConfig:{MaximumConcurrency:r}}}},
141
+ "upsertMappingRequest");var De=o(()=>({equals:Vt,create:qe,replace:Ot,preview:Ht,update:Ut,delete:zt}),"\
142
+ getMappingHandler"),Vt=o((t,e)=>!!t.result&&t.result.eventId===e.result?.eventId,
143
+ "equalsResource"),Ht=o((t,e)=>{let n={...t.parameters,dependencies:t.dependencies},
144
+ r={...e.parameters,dependencies:e.dependencies},i=(0,k.deepCompare)(n,r,{exclude:{
145
+ getSourceArn:!0}});if(i.counts)return{...i,name:n.fromService}},"previewResource"),
146
+ Ot=o(async(t,e,n)=>{if(e.result)throw new b.ReplaceResourceError(R,t.entryId,e.entryId);
147
+ return qe(t,n)},"replaceResource"),qe=o((t,e)=>{let n=t.parameters,r=L(R,"mappin\
148
+ g",e);return b.OperationLogger.logExecution(R,r,"creation",async i=>{let a=await n.
149
+ getSourceArn(e);return{eventId:(await Ve(i,r,a)??await He(i,{...t.parameters,functionName:r,
150
+ sourceArn:a})).eventId,functionName:r,sourceArn:a}})},"createResource"),Ut=o((t,e,n)=>{
151
+ let{result:r,parameters:i}=t,{fromService:a}=i;if(!r)throw new b.CorruptedResourceError(
152
+ R,"mapping");return b.OperationLogger.logExecution(R,a,"updates",async p=>{let c=L(
153
+ R,"mapping",n),m=e.result?.functionName??r.functionName,u=r.sourceArn,l={...t.parameters,
154
+ functionName:c,sourceArn:u},g={...e.parameters,functionName:m,sourceArn:u};return await Gt(
155
+ p,r.eventId,l,g),{...r,functionName:c}})},"updateResource"),zt=o(async t=>{let e=t.
156
+ result;if(!e)return;let{functionName:n}=e;await b.OperationLogger.logExecution(R,
157
+ n,"deletion",async r=>{await Ue(r,e.eventId)})},"deleteResource"),Gt=o(async(t,e,n,r)=>{
158
+ !(0,k.deepEqual)(n,r,{exclude:{getSourceArn:!0,fromService:!0}})&&await Oe(t,e,n)},
159
+ "checkGeneralUpdates");var Be=o(()=>{(0,ke.tryRegisterProvider)(v,De())},"registerMappingProvider");var We=o(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");var B=require("@ez4/aws-identity"),je=require("@ez4/project/library");var I=require("@ez4/aws-identity");var $e=o(async t=>{let[e,n]=await Promise.all([(0,I.getRegion)(),(0,I.getAccountId)()]);
145
160
  return(0,I.createPolicyDocument)([{permissions:["logs:CreateLogStream","logs:Put\
146
- LogEvents"],resourceIds:[`arn:aws:logs:${t}:${r}:log-group:${e}-*:*`]}])},"getPo\
147
- licyDocument");var $e=n(async e=>{let{state:t,options:r}=e,o=(0,We.getServiceName)("",r),i=`${o}\
148
- -lambda-policy`;return(0,D.tryGetPolicy)(t,i)??(0,D.createPolicy)(t,{tags:r.tags,
149
- policyDocument:await Be(o),policyName:i})},"prepareExecutionPolicy");var zt=n(()=>{(0,je.registerTriggers)(),(0,Ze.registerTriggers)(),(0,Qe.registerTriggers)(),
150
- (0,_e.tryCreateTrigger)("@ez4/aws-function",{"deploy:prepareIdentityAccount":Oe,
151
- "deploy:prepareExecutionPolicy":$e}),Re(),Ie(),ke()},"registerTriggers");var q=require("@ez4/utils"),Je=require("@ez4/stateful");var Gt=n((e,t,r,o)=>{let i=(0,q.toKebabCase)(o.functionName),a=(0,q.hashData)(f,
152
- t.entryId,i),c=[t.entryId];return r&&c.push(r.entryId),(0,Je.attachEntry)(e,{type:f,
153
- entryId:a,dependencies:c,parameters:{...o,functionName:i}})},"createFunction");var Xe=require("@ez4/stateful"),re=require("@ez4/utils");var Ke=n(e=>e.type===R,"isPermissionState");var Dt=n((e,t,r,o)=>{let i=(0,re.hashData)(R,t.entryId,r.entryId);return(0,Xe.attachEntry)(
154
- e,{type:R,entryId:i,dependencies:[t.entryId,r.entryId],parameters:o})},"createPe\
155
- rmission"),qt=n((e,t,r)=>{let o=(0,re.hashData)(R,t.entryId,r.entryId),i=e[o];return i&&
156
- Ke(i)?i:null},"getPermission");var Ye=require("@ez4/utils"),et=require("@ez4/stateful");var kt=n((e,t,r,o)=>{let i=(0,Ye.hashData)(P,t.entryId,r.entryId);return(0,et.attachEntry)(
157
- e,{type:P,entryId:i,dependencies:[t.entryId,r.entryId],parameters:o})},"createMa\
158
- pping");var Ot=n(e=>e.type===P,"isMappingState");var Bt=n((e,t,r)=>`arn:aws:lambda:${e}:${t}:function:${r}`,"buildFunctionArn");var k=require("@ez4/project"),tt;(a=>(a.LogRetention=90,a.Architecture=k.ArchitectureType.
159
- x86,a.Runtime=k.RuntimeType.Node24,a.Timeout=90,a.Memory=192))(tt||={});0&&(module.exports={FunctionArchitecture,FunctionDefaults,FunctionRuntime,FunctionServiceName,
161
+ LogEvents"],resourceIds:[`arn:aws:logs:${e}:${n}:log-group:${t}-*:*`]}])},"getPo\
162
+ licyDocument");var Ze=o(async t=>{let{state:e,options:n}=t,r=(0,je.getServiceName)("",n),i=`${r}\
163
+ -lambda-policy`;return(0,B.tryGetPolicy)(e,i)??(0,B.createPolicy)(e,{tags:n.tags,
164
+ policyDocument:await $e(r),policyName:i})},"prepareExecutionPolicy");var Dt=o(()=>{(0,Qe.registerTriggers)(),(0,_e.registerTriggers)(),(0,Je.registerTriggers)(),
165
+ (0,Ke.tryCreateTrigger)("@ez4/aws-function",{"deploy:prepareIdentityAccount":We,
166
+ "deploy:prepareExecutionPolicy":Ze}),he(),Ie(),Be()},"registerTriggers");var W=require("@ez4/utils"),Xe=require("@ez4/stateful");var qt=o((t,e,n,r)=>{let i=(0,W.toKebabCase)(r.functionName),a=(0,W.hashData)(x,
167
+ e.entryId,i),p=[e.entryId];return n&&p.push(n.entryId),(0,Xe.attachEntry)(t,{type:x,
168
+ entryId:a,dependencies:p,parameters:{...r,functionName:i}})},"createFunction");var et=require("@ez4/stateful"),re=require("@ez4/utils");var Ye=o(t=>t.type===w,"isPermissionState");var kt=o((t,e,n,r)=>{let i=(0,re.hashData)(w,e.entryId,n.entryId);return(0,et.attachEntry)(
169
+ t,{type:w,entryId:i,dependencies:[e.entryId,n.entryId],parameters:r})},"createPe\
170
+ rmission"),Bt=o((t,e,n)=>{let r=(0,re.hashData)(w,e.entryId,n.entryId),i=t[r];return i&&
171
+ Ye(i)?i:null},"getPermission");var tt=require("@ez4/utils"),nt=require("@ez4/stateful");var Wt=o((t,e,n,r)=>{let i=(0,tt.hashData)(v,e.entryId,n.entryId);return(0,nt.attachEntry)(
172
+ t,{type:v,entryId:i,dependencies:[e.entryId,n.entryId],parameters:r})},"createMa\
173
+ pping");var $t=o(t=>t.type===v,"isMappingState");var jt=o((t,e,n)=>`arn:aws:lambda:${t}:${e}:function:${n}`,"buildFunctionArn");var $=require("@ez4/project"),rt;(a=>(a.LogRetention=90,a.Architecture=$.ArchitectureType.
174
+ x86,a.Runtime=$.RuntimeType.Node24,a.Timeout=90,a.Memory=192))(rt||={});0&&(module.exports={FunctionArchitecture,FunctionDefaults,FunctionRuntime,FunctionServiceName,
160
175
  FunctionServiceType,MappingService,MappingServiceName,MappingServiceType,PermissionServiceName,
161
176
  PermissionServiceType,buildFunctionArn,createFunction,createMapping,createPermission,
162
177
  getFunctionArchitecture,getFunctionArn,getFunctionName,getFunctionRuntime,getFunctionState,
package/dist/main.mjs CHANGED
@@ -1,148 +1,162 @@
1
- var Ie=Object.defineProperty;var n=(e,t)=>Ie(e,"name",{value:t,configurable:!0});import{registerTriggers as Yt}from"@ez4/aws-common";import{registerTriggers as er}from"@ez4/aws-identity";
2
- import{registerTriggers as tr}from"@ez4/aws-logs";import{tryCreateTrigger as rr}from"@ez4/project/library";import{tryRegisterProvider as gt}from"@ez4/aws-common";import{applyTagUpdates as et,getBundleHash as z,Logger as tt,ReplaceResourceError as rt}from"@ez4/aws-common";
3
- import{deepCompare as nt,deepEqual as ot,hashFile as Y}from"@ez4/utils";import{getLogGroupName as ee}from"@ez4/aws-logs";
4
- import{getRoleArn as te}from"@ez4/aws-identity";import{LambdaClient as ke,GetFunctionCommand as Oe,CreateFunctionCommand as Be,DeleteFunctionCommand as We,
5
- UpdateFunctionCodeCommand as $e,UpdateFunctionConfigurationCommand as je,PublishVersionCommand as Ze,
6
- TagResourceCommand as Qe,UntagResourceCommand as _e,waitUntilFunctionActive as Je,
7
- waitUntilFunctionUpdated as k,waitUntilPublishedVersionActive as Ke,ResourceNotFoundException as O,
8
- ApplicationLogLevel as A,SystemLogLevel as B,LogFormat as W}from"@aws-sdk/client-lambda";
9
- import{Logger as g,tryParseArn as $,waitCreation as Xe,waitDeletion as Ye}from"@ez4/aws-common";import{RuntimeType as G}from"@ez4/project";var Me=(r=>(r.Node22="nodejs22.x",r.Node24="nodejs24.x",r))(Me||{});var Te={[G.Node22]:"nodejs22.x",[G.Node24]:"nodejs24.x"},M=n(e=>Te[e],"getFuncti\
10
- onRuntime");import{ArchitectureType as D}from"@ez4/project";var Le=(r=>(r.Arm="arm64",r.x86="x86_64",r))(Le||{});var Ve={[D.Arm]:"arm64",[D.x86]:"x86_64"},T=n(e=>Ve[e],"getFunctionArchitecture");import{InvalidParameterError as He}from"@ez4/aws-common";import{hashData as Ue}from"@ez4/utils";var p="AWS:Lambda/Function",y="aws:lambda.function";var ze=/[a-z][\w]+/i,Ge=n(e=>ze.test(e),"isValidName"),L=n(e=>{for(let t in e)if(!Ge(
11
- t))throw new He(p,`${t} is an invalid variable name .`)},"assertVariables"),R=n(
12
- e=>{let t={};for(let r in e)t[r]=Ue(e[r]);return t},"protectVariables");import De from"adm-zip";import{readFile as qe}from"node:fs/promises";var q=n(async(e,t)=>{let r=new De,o=await qe(e);return r.addFile(t,o),r.toBufferPromise()},
13
- "getZipBuffer");var f=new ke({}),C={minDelay:15,maxWaitTime:1800,maxDelay:60,client:f},j=n(async(e,t)=>{
14
- g.logImport(p,e);try{let r=await f.send(new Oe({FunctionName:e,Qualifier:t})),o=r.
15
- Configuration.Version,i=r.Configuration.FunctionArn;return{functionVersion:o,functionArn:i}}catch(r){
16
- if(!(r instanceof O))throw r;return}},"importFunction"),Z=n(async e=>{let{functionName:t,
17
- variables:r}=e;g.logCreate(p,t),r&&L(r);let o=X(e.handlerName),i=await K(e.sourceFile),
18
- {description:s,memory:a,timeout:c,architecture:m,runtime:l,debug:u,roleArn:d,logGroup:w}=e,
19
- I=await Xe(()=>f.send(new Be({FunctionName:t,Description:s,MemorySize:a,Timeout:c,
20
- Role:d,Handler:o,Architectures:[T(m)],Runtime:M(l),PackageType:"Zip",LoggingConfig:{
21
- LogGroup:w,ApplicationLogLevel:u?A.Debug:A.Warn,SystemLogLevel:B.Warn,LogFormat:W.
22
- Json},Code:{ZipFile:i},Environment:{Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}})));
23
- g.logWait(p,t),await Je(C,{FunctionName:t});let v=I.FunctionArn;return e.publish?
24
- {functionVersion:await _(t),functionArn:v}:{functionArn:v}},"createFunction"),V=n(
25
- async(e,t)=>{g.logUpdate(p,`${e} source code`);let r=await K(t.sourceFile),{publish:o,
26
- architecture:i}=t,s=await f.send(new $e({Architectures:i&&[T(i)],FunctionName:e,
27
- ZipFile:r,Publish:o}));g.logWait(p,e),await k(C,{FunctionName:e});let a=s.FunctionArn;
28
- return t.publish?{functionVersion:await _(e),functionArn:a}:{functionArn:a}},"up\
29
- dateSourceCode"),H=n(async(e,t)=>{let{handlerName:r,variables:o}=t;g.logUpdate(p,
30
- `${e} configuration`),o&&L(o);let{description:i,memory:s,timeout:a,runtime:c,debug:m,
31
- roleArn:l,logGroup:u}=t;await f.send(new je({Runtime:c&&M(c),FunctionName:e,Description:i,
32
- MemorySize:s,Timeout:a,Role:l,...r&&{Handler:X(r)},LoggingConfig:{LogGroup:u,ApplicationLogLevel:m?
33
- A.Debug:A.Warn,SystemLogLevel:B.Warn,LogFormat:W.Json},Environment:{Variables:o}})),
34
- g.logWait(p,e),await k(C,{FunctionName:e})},"updateConfiguration"),Q=n(async e=>{
35
- g.logDelete(p,e),await Ye(async()=>{try{await f.send(new We({FunctionName:e}))}catch(t){
36
- if(!(t instanceof O))throw t}})},"deleteFunction"),_=n(async e=>{g.logPublish(p,
37
- e);let t=await f.send(new Ze({FunctionName:e}));g.logWait(p,e);let r=t.Version;return await Ke(
38
- C,{FunctionName:e,Qualifier:r}),r},"publishFunction"),U=n(async(e,t)=>{let r=$(e)?.
39
- resourceName??e;g.logTag(p,r),await f.send(new Qe({Resource:e,Tags:{...t,ManagedBy:"\
40
- EZ4"}}))},"tagFunction"),J=n(async(e,t)=>{let r=$(e)?.resourceName??e;g.logUntag(
41
- p,r),await f.send(new _e({Resource:e,TagKeys:t}))},"untagFunction"),K=n(e=>q(e,"\
42
- main.mjs"),"getSourceZipFile"),X=n(e=>`main.${e}`,"getSourceHandlerName");var re=n(()=>({equals:it,create:ne,replace:at,preview:st,update:pt,delete:ct}),"\
43
- getFunctionHandler"),it=n((e,t)=>!!e.result&&e.result.functionArn===t.result?.functionArn,
44
- "equalsResource"),st=n(async(e,t)=>{let r=e.parameters,o=t.parameters,i=nt({...r,
45
- connections:e.connections,dependencies:e.dependencies,variables:R(await r.getFunctionVariables()),
46
- sourceHash:await z(...r.getFunctionFiles()),valuesHash:r.getFunctionHash()},{...o,
47
- connections:t.connections,dependencies:t.dependencies,variables:t.result?.variables,
48
- sourceHash:t.result?.sourceHash,valuesHash:t.result?.valuesHash});if(i.counts)return{
49
- ...i,name:r.functionName}},"previewResource"),at=n(async(e,t,r)=>{if(t.result)throw new rt(
50
- p,e.entryId,t.entryId);return ne(e,r)},"replaceResource"),ne=n(async(e,t)=>{let{
51
- functionName:r,...o}=e.parameters,i=ee(p,r,t),s=te(p,r,t),[a,c,m,l]=await Promise.
52
- all([z(...o.getFunctionFiles()),o.getFunctionBundle(t),o.getFunctionHash(),o.getFunctionVariables()]),
53
- u=await j(r),d=await Y(c);if(u)return await H(r,{...o,variables:l,logGroup:i,roleArn:s}),
54
- await V(r,{architecture:o.architecture,publish:!1,sourceFile:c}),await U(u.functionArn,
55
- {...o.tags}),{functionArn:u.functionArn,functionVersion:u.functionVersion,variables:R(
56
- l),valuesHash:m,sourceHash:a,bundleHash:d,logGroup:i,roleArn:s};let w=await Z({...o,
57
- publish:!0,functionName:r,sourceFile:c,variables:l,logGroup:i,roleArn:s});return{
58
- functionArn:w.functionArn,functionVersion:w.functionVersion,variables:R(l),valuesHash:m,
59
- sourceHash:a,bundleHash:d,logGroup:i,roleArn:s}},"createResource"),pt=n(async(e,t,r)=>{
60
- let{parameters:o,result:i}=e;if(!i)return;let s=o.functionName,a=await o.getFunctionVariables(),
61
- c=t.result?.variables??a,m=te(p,s,r),l=t.result?.roleArn??m,u=ee(p,s,r),d=t.result?.
62
- logGroup??u,w={...o,variables:a,roleArn:m,logGroup:u},I={...t.parameters,variables:c,
63
- roleArn:l,logGroup:d};await mt(s,w,I,r),await ut(i.functionArn,o,t.parameters);let v=await lt(
64
- s,o,t.result,r);return{...i,...v,variables:R(a),logGroup:u,roleArn:m}},"updateRe\
65
- source"),ct=n(async e=>{let{result:t,parameters:r}=e;t&&await Q(r.functionName)},
66
- "deleteResource"),mt=n(async(e,t,r,o)=>{let{variables:i,...s}=t,a={variables:R(i),
67
- ...s};(!ot(a,r,{exclude:{sourceFile:!0,functionName:!0,architecture:!0,tags:!0}})||
68
- o.force)&&await H(e,t)},"checkConfigurationUpdates"),ut=n(async(e,t,r)=>{await et(
69
- t.tags,r.tags,o=>U(e,o),o=>J(e,o))},"checkTagUpdates"),lt=n(async(e,t,r,o)=>{let[
70
- i,s]=await Promise.all([z(...t.getFunctionFiles()),t.getFunctionHash()]),a=r?.sourceHash,
71
- c=r?.valuesHash;if(i!==a||s!==c||o.force){let m=await t.getFunctionBundle(o),l=await Y(
72
- m),u=r?.bundleHash;if(l===u&&s===c)return tt.logSkip(p,`${e} source code`),{valuesHash:s,
73
- sourceHash:i};let{functionVersion:d}=await V(e,{architecture:t.architecture,publish:!r?.
74
- functionVersion,sourceFile:m});return{valuesHash:s,sourceHash:i,bundleHash:l,...d&&
75
- {functionVersion:d}}}},"checkSourceCodeUpdates");var oe=n(()=>{gt(y,re())},"registerFunctionProvider");import{tryRegisterProvider as vt}from"@ez4/aws-common";import{ReplaceResourceError as xt}from"@ez4/aws-common";import{IncompleteResourceError as ie}from"@ez4/aws-common";var E=class extends Error{static{n(this,"FunctionNotFoundError")}constructor(t){
76
- super(`Function ${t} wasn't found.`)}};var se=n(e=>e.type===y,"isFunctionState"),an=n((e,t,r)=>{try{let o=e.getServiceState(
77
- t,r);if(se(o))return o}catch{}},"tryGetFunctionState"),pn=n((e,t,r)=>{let o=e.getServiceState(
78
- t,r);if(!se(o))throw new E(t);return o},"getFunctionState"),P=n((e,t,r)=>{let o=r.
79
- getDependencies(y).at(0)?.parameters;if(!o?.functionName)throw new ie(e,t,"funct\
80
- ionName");return o.functionName},"getFunctionName"),dt=n(e=>e.getDependencies(y)[0]?.
81
- result?.functionArn,"tryGetFunctionArn"),cn=n((e,t,r)=>{let o=dt(r);if(!o)throw new ie(
82
- e,t,"functionArn");return o},"getFunctionArn");import{LambdaClient as yt,AddPermissionCommand as ft,RemovePermissionCommand as St,
83
- ResourceNotFoundException as Ft}from"@aws-sdk/client-lambda";import{Logger as ae}from"@ez4/aws-common";var h="AWS:Lambda/Permission",F="aws:lambda.permission";var pe=new yt({}),ce=n(async e=>{ae.logCreate(h,e.functionName);let t=e.statementId??
84
- `ID${Date.now()}`;return await pe.send(new ft({StatementId:t,FunctionName:e.functionName,
85
- SourceArn:e.sourceArn,Principal:e.principal,Action:e.action})),{statementId:t}},
86
- "createPermission"),me=n(async(e,t)=>{ae.logDelete(h,e);try{return await pe.send(
87
- new St({FunctionName:e,StatementId:t})),!0}catch(r){if(!(r instanceof Ft))throw r;
88
- return!1}},"deletePermission");var ue=n(()=>({equals:wt,create:le,replace:ht,preview:Rt,update:Pt,delete:bt}),"\
89
- getPermissionHandler"),wt=n((e,t)=>!!e.result&&e.result.functionName===t.result?.
90
- functionName,"equalsResource"),Rt=n((e,t)=>{},"previewResource"),ht=n(async(e,t,r)=>{
91
- if(t.result)throw new xt(h,e.entryId,t.entryId);return le(e,r)},"replaceResource"),
92
- le=n(async(e,t)=>{let r=e.parameters,o=P(h,"permission",t),i=await r.getPermission(
93
- t);return{statementId:(await ce({action:"lambda:InvokeFunction",sourceArn:i.sourceArn,
94
- principal:i.principal,functionName:o})).statementId,functionName:o}},"createReso\
95
- urce"),Pt=n(async()=>{},"updateResource"),bt=n(async e=>{let t=e.result;t&&await me(
96
- t.functionName,t.statementId)},"deleteResource");var ge=n(()=>{vt(F,ue())},"registerPermissionProvider");import{tryRegisterProvider as jt}from"@ez4/aws-common";import{ReplaceResourceError as zt}from"@ez4/aws-common";import{deepCompare as Gt,
97
- deepEqual as Dt}from"@ez4/utils";import{LambdaClient as At,GetEventSourceMappingCommand as Ct,CreateEventSourceMappingCommand as Et,
98
- UpdateEventSourceMappingCommand as Nt,DeleteEventSourceMappingCommand as It,ListEventSourceMappingsCommand as Mt,
99
- FunctionResponseType as Tt,EventSourcePosition as Lt,ResourceNotFoundException as Vt}from"@aws-sdk/client-lambda";
100
- import{Logger as N,parseArn as Ht}from"@ez4/aws-common";import{Wait as ye}from"@ez4/utils";var S="AWS:Lambda/Mapping",x="aws:lambda.mapping",de=(r=>(r.DynamoDB="dynamodb",
101
- r.Queue="sqs",r))(de||{});var b=new At({}),fe=n(async(e,t)=>{N.logImport(S,e);let r=await b.send(new Mt({FunctionName:e,
102
- EventSourceArn:t})),[o]=r.EventSourceMappings;return o?{eventId:o.UUID}:void 0},
103
- "importMapping"),Se=n(async e=>{let{sourceArn:t,functionName:r}=e;N.logCreate(S,
104
- r);let i=(await b.send(new Et({FunctionName:r,EventSourceArn:t,...Re(e)}))).UUID;
105
- return await we(i),{eventId:i}},"createMapping"),Fe=n(async(e,t)=>{let{functionName:r}=t;
106
- N.logUpdate(S,`${r} (${e})`),await b.send(new Nt({UUID:e,FunctionName:r,...Re(t)})),
107
- await we(e)},"updateMapping"),xe=n(async e=>{N.logDelete(S,e);try{return await b.
108
- send(new It({UUID:e})),!0}catch(t){if(!(t instanceof Vt))throw t;return!1}},"del\
109
- eteMapping"),Ut=n(async e=>(await b.send(new Ct({UUID:e}))).State,"getMappingSta\
110
- te"),we=n(async e=>{let t=new Set(["Enabled","Disabled"]);await ye.until(async()=>{
111
- let r=await Ut(e);return t.has(r)?!0:ye.RetryAttempt})},"waitForReadyState"),Re=n(
112
- e=>{let{sourceArn:t,enabled:r,concurrency:o,batch:i}=e,{service:s}=Ht(t);return{
113
- Enabled:r,FunctionResponseTypes:[Tt.ReportBatchItemFailures],MaximumBatchingWindowInSeconds:i?.
114
- maxWait,BatchSize:i?.size,...s==="dynamodb"&&{StartingPosition:Lt.LATEST},...s===
115
- "sqs"&&{ScalingConfig:{MaximumConcurrency:o}}}},"upsertMappingRequest");var he=n(()=>({equals:qt,create:Pe,replace:Ot,preview:kt,update:Bt,delete:Wt}),"\
116
- getMappingHandler"),qt=n((e,t)=>!!e.result&&e.result.eventId===t.result?.eventId,
117
- "equalsResource"),kt=n((e,t)=>{let r={...e.parameters,dependencies:e.dependencies},
118
- o={...t.parameters,dependencies:t.dependencies},i=Gt(r,o,{exclude:{getSourceArn:!0}});
119
- if(i.counts)return{...i,name:r.fromService}},"previewResource"),Ot=n(async(e,t,r)=>{
120
- if(t.result)throw new zt(S,e.entryId,t.entryId);return Pe(e,r)},"replaceResource"),
121
- Pe=n(async(e,t)=>{let r=e.parameters,o=P(S,"mapping",t),i=await r.getSourceArn(t);
122
- return{eventId:(await fe(o,i)??await Se({...e.parameters,functionName:o,sourceArn:i})).
123
- eventId,functionName:o,sourceArn:i}},"createResource"),Bt=n(async(e,t,r)=>{let o=e.
124
- result;if(!o)return;let i=o.sourceArn,s=P(S,"mapping",r),a=t.result?.functionName??
125
- o.functionName,c={...e.parameters,functionName:s,sourceArn:i},m={...t.parameters,
126
- functionName:a,sourceArn:i};return await $t(o.eventId,c,m),{...o,functionName:s}},
127
- "updateResource"),Wt=n(async e=>{let t=e.result;t&&await xe(t.eventId)},"deleteR\
128
- esource"),$t=n(async(e,t,r)=>{!Dt(t,r,{exclude:{getSourceArn:!0,fromService:!0}})&&
129
- await Fe(e,t)},"checkGeneralUpdates");var be=n(()=>{jt(x,he())},"registerMappingProvider");var ve=n(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");import{createPolicy as Jt,tryGetPolicy as Kt}from"@ez4/aws-identity";import{getServiceName as Xt}from"@ez4/project/library";import{getAccountId as Zt,getRegion as Qt,createPolicyDocument as _t}from"@ez4/aws-identity";var Ae=n(async e=>{let[t,r]=await Promise.all([Qt(),Zt()]);return _t([{permissions:[
130
- "logs:CreateLogStream","logs:PutLogEvents"],resourceIds:[`arn:aws:logs:${t}:${r}\
131
- :log-group:${e}-*:*`]}])},"getPolicyDocument");var Ce=n(async e=>{let{state:t,options:r}=e,o=Xt("",r),i=`${o}-lambda-policy`;return Kt(
132
- t,i)??Jt(t,{tags:r.tags,policyDocument:await Ae(o),policyName:i})},"prepareExecu\
133
- tionPolicy");var go=n(()=>{Yt(),er(),tr(),rr("@ez4/aws-function",{"deploy:prepareIdentityAcco\
134
- unt":ve,"deploy:prepareExecutionPolicy":Ce}),oe(),ge(),be()},"registerTriggers");import{toKebabCase as nr,hashData as or}from"@ez4/utils";import{attachEntry as ir}from"@ez4/stateful";var wo=n((e,t,r,o)=>{let i=nr(o.functionName),s=or(y,t.entryId,i),a=[t.entryId];
135
- return r&&a.push(r.entryId),ir(e,{type:y,entryId:s,dependencies:a,parameters:{...o,
136
- functionName:i}})},"createFunction");import{attachEntry as sr}from"@ez4/stateful";import{hashData as Ne}from"@ez4/utils";var Ee=n(e=>e.type===F,"isPermissionState");var Io=n((e,t,r,o)=>{let i=Ne(F,t.entryId,r.entryId);return sr(e,{type:F,entryId:i,
137
- dependencies:[t.entryId,r.entryId],parameters:o})},"createPermission"),Mo=n((e,t,r)=>{
138
- let o=Ne(F,t.entryId,r.entryId),i=e[o];return i&&Ee(i)?i:null},"getPermission");import{hashData as ar}from"@ez4/utils";import{attachEntry as pr}from"@ez4/stateful";var zo=n((e,t,r,o)=>{let i=ar(x,t.entryId,r.entryId);return pr(e,{type:x,entryId:i,
139
- dependencies:[t.entryId,r.entryId],parameters:o})},"createMapping");var ko=n(e=>e.type===x,"isMappingState");var Wo=n((e,t,r)=>`arn:aws:lambda:${e}:${t}:function:${r}`,"buildFunctionArn");import{ArchitectureType as cr,RuntimeType as mr}from"@ez4/project";var ur;(s=>(s.
140
- LogRetention=90,s.Architecture=cr.x86,s.Runtime=mr.Node24,s.Timeout=90,s.Memory=
141
- 192))(ur||={});export{Le as FunctionArchitecture,ur as FunctionDefaults,Me as FunctionRuntime,p as FunctionServiceName,
142
- y as FunctionServiceType,de as MappingService,S as MappingServiceName,x as MappingServiceType,
143
- h as PermissionServiceName,F as PermissionServiceType,Wo as buildFunctionArn,wo as createFunction,
144
- zo as createMapping,Io as createPermission,T as getFunctionArchitecture,cn as getFunctionArn,
145
- P as getFunctionName,M as getFunctionRuntime,pn as getFunctionState,Mo as getPermission,
146
- se as isFunctionState,ko as isMappingState,go as registerTriggers,dt as tryGetFunctionArn,
147
- an as tryGetFunctionState};
1
+ var Ie=Object.defineProperty;var o=(t,e)=>Ie(t,"name",{value:e,configurable:!0});import{registerTriggers as en}from"@ez4/aws-common";import{registerTriggers as tn}from"@ez4/aws-identity";
2
+ import{registerTriggers as nn}from"@ez4/aws-logs";import{tryCreateTrigger as rn}from"@ez4/project/library";import{tryRegisterProvider as dt}from"@ez4/aws-common";import{applyTagUpdates as tt,CorruptedResourceError as nt,getBundleHash as O,OperationLogger as U,
3
+ ReplaceResourceError as rt}from"@ez4/aws-common";import{deepCompare as ot,deepEqual as it,
4
+ hashFile as te}from"@ez4/utils";import{getLogGroupName as ne}from"@ez4/aws-logs";
5
+ import{getRoleArn as re}from"@ez4/aws-identity";import{GetFunctionCommand as $e,CreateFunctionCommand as je,DeleteFunctionCommand as Ze,
6
+ UpdateFunctionCodeCommand as Qe,UpdateFunctionConfigurationCommand as _e,PublishVersionCommand as zn,
7
+ TagResourceCommand as Je,UntagResourceCommand as Ke,waitUntilFunctionActive as Xe,
8
+ waitUntilFunctionUpdated as W,waitUntilPublishedVersionActive as $,ResourceNotFoundException as j,
9
+ ApplicationLogLevel as L,SystemLogLevel as Z,LogFormat as Q}from"@aws-sdk/client-lambda";
10
+ import{waitCreation as Ye,waitDeletion as et}from"@ez4/aws-common";import{getAwsClientOptions as Me,getAwsClientWaiter as Te}from"@ez4/aws-common";
11
+ import{LambdaClient as Ve}from"@aws-sdk/client-lambda";var g=o(()=>new Ve(Me()),"getLambdaClient"),A=o(t=>({...Te(),client:t}),"getLamb\
12
+ daWaiter");import{RuntimeType as q}from"@ez4/project";var He=(n=>(n.Node22="nodejs22.x",n.Node24="nodejs24.x",n))(He||{});var Oe={[q.Node22]:"nodejs22.x",[q.Node24]:"nodejs24.x"},E=o(t=>Oe[t],"getFuncti\
13
+ onRuntime");import{ArchitectureType as k}from"@ez4/project";var Ue=(n=>(n.Arm="arm64",n.x86="x86_64",n))(Ue||{});var ze={[k.Arm]:"arm64",[k.x86]:"x86_64"},I=o(t=>ze[t],"getFunctionArchitecture");import{InvalidParameterError as Ge}from"@ez4/aws-common";import{hashData as De}from"@ez4/utils";var f="AWS:Lambda/Function",y="aws:lambda.function";var qe=/[a-z][\w]+/i,ke=o(t=>qe.test(t),"isValidName"),M=o(t=>{for(let e in t)if(!ke(
14
+ e))throw new Ge(f,`${e} is an invalid variable name .`)},"assertVariables"),v=o(
15
+ t=>{let e={};for(let n in t)e[n]=De(t[n]);return e},"protectVariables");import Be from"adm-zip";import{readFile as We}from"node:fs/promises";var B=o(async(t,e)=>{let n=new Be,r=await We(t);return n.addFile(e,r),n.toBufferPromise()},
16
+ "getZipBuffer");var _=o(async(t,e,n)=>{t.update("Importing function");try{let r=await g().send(new $e(
17
+ {FunctionName:e,Qualifier:n})),i=r.Configuration.Version,a=r.Configuration.FunctionArn;
18
+ return{functionVersion:i,functionArn:a}}catch(r){if(!(r instanceof j))throw r;return}},
19
+ "importFunction"),J=o(async(t,e)=>{t.update("Creating function");let{functionName:n,
20
+ variables:r}=e;r&&M(r);let i=ee(e.handlerName),a=await Y(e.sourceFile),{description:s,
21
+ memory:p,timeout:u,publish:c,architecture:m,runtime:l,debug:d,roleArn:x,logGroup:R}=e,
22
+ P=g(),C=await Ye(()=>P.send(new je({FunctionName:n,Description:s,MemorySize:p,Timeout:u,
23
+ Role:x,Publish:c,Handler:i,Architectures:[I(m)],Runtime:E(l),PackageType:"Zip",LoggingConfig:{
24
+ LogGroup:R,ApplicationLogLevel:d?L.Debug:L.Warn,SystemLogLevel:Z.Warn,LogFormat:Q.
25
+ Json},Code:{ZipFile:a},Environment:{Variables:r},Tags:{...e.tags,ManagedBy:"EZ4"}}))),
26
+ Ee=C.FunctionArn,G=C.Version,D=A(P);return await Xe(D,{FunctionName:n}),c&&await $(
27
+ D,{FunctionName:n,Qualifier:G}),{functionArn:Ee,...c&&{functionVersion:G}}},"cre\
28
+ ateFunction"),T=o(async(t,e,n)=>{t.update("Updating source code");let r=await Y(
29
+ n.sourceFile),{publish:i,architecture:a}=n,s=g(),p=await s.send(new Qe({Architectures:a&&
30
+ [I(a)],FunctionName:e,ZipFile:r,Publish:i})),u=p.FunctionArn,c=p.Version,m=A(s);
31
+ return await W(m,{FunctionName:e}),i&&await $(m,{FunctionName:e,Qualifier:c}),{functionArn:u,
32
+ ...i&&{functionVersion:c}}},"updateSourceCode"),V=o(async(t,e,n)=>{t.update("Upd\
33
+ ating configuration");let{handlerName:r,variables:i}=n;i&&M(i);let{description:a,
34
+ memory:s,timeout:p,runtime:u,debug:c,roleArn:m,logGroup:l}=n,d=g();await d.send(
35
+ new _e({Runtime:u&&E(u),FunctionName:e,Description:a,MemorySize:s,Timeout:p,Role:m,
36
+ ...r&&{Handler:ee(r)},LoggingConfig:{LogGroup:l,ApplicationLogLevel:c?L.Debug:L.
37
+ Warn,SystemLogLevel:Z.Warn,LogFormat:Q.Json},Environment:{Variables:i}})),await W(
38
+ A(d),{FunctionName:e})},"updateConfiguration"),K=o(async(t,e)=>{e.update("Deleti\
39
+ ng function");let n=g();await et(async()=>{try{await n.send(new Ze({FunctionName:t}))}catch(r){
40
+ if(!(r instanceof j))throw r}})},"deleteFunction");var H=o(async(t,e,n)=>{t.update("Tag function"),await g().send(new Je({Resource:e,
41
+ Tags:{...n,ManagedBy:"EZ4"}}))},"tagFunction"),X=o(async(t,e,n)=>{t.update("Unta\
42
+ g function"),await g().send(new Ke({Resource:e,TagKeys:n}))},"untagFunction"),Y=o(
43
+ t=>B(t,"main.mjs"),"getSourceZipFile"),ee=o(t=>`main.${t}`,"getSourceHandlerName");var oe=o(()=>({equals:at,create:ie,replace:pt,preview:st,update:ct,delete:ut}),"\
44
+ getFunctionHandler"),at=o((t,e)=>!!t.result&&t.result.functionArn===e.result?.functionArn,
45
+ "equalsResource"),st=o(async(t,e)=>{let n=t.parameters,r=e.parameters,i=ot({...n,
46
+ connections:t.connections,dependencies:t.dependencies,variables:v(await n.getFunctionVariables()),
47
+ sourceHash:await O(...n.getFunctionFiles()),valuesHash:n.getFunctionHash()},{...r,
48
+ connections:e.connections,dependencies:e.dependencies,variables:e.result?.variables,
49
+ sourceHash:e.result?.sourceHash,valuesHash:e.result?.valuesHash},{exclude:{release:!0}});
50
+ if(i.counts)return{...i,name:n.functionName}},"previewResource"),pt=o(async(t,e,n)=>{
51
+ if(e.result)throw new rt(f,t.entryId,e.entryId);return ie(t,n)},"replaceResource"),
52
+ ie=o((t,e)=>{let{functionName:n,release:r,...i}=t.parameters;return U.logExecution(
53
+ f,n,"creation",async a=>{let s=ne(f,n,e),p=re(f,n,e),[u,c,m,l]=await Promise.all(
54
+ [O(...i.getFunctionFiles()),i.getFunctionBundle(e),i.getFunctionHash(),i.getFunctionVariables()]),
55
+ d=await _(a,n),x=await te(c);if(d)return await T(a,n,{architecture:i.architecture,
56
+ publish:!1,sourceFile:c}),await V(a,n,{...i,logGroup:s,roleArn:p,variables:{...l,
57
+ ...r?.variableName&&{[r.variableName]:r.version}}}),await H(a,d.functionArn,{...i.
58
+ tags,...r?.tagName&&{[r.tagName]:r.version}}),{functionArn:d.functionArn,functionVersion:d.
59
+ functionVersion,variables:v(l),valuesHash:m,sourceHash:u,bundleHash:x,logGroup:s,
60
+ roleArn:p};let R=await J(a,{...i,publish:!0,functionName:n,sourceFile:c,logGroup:s,
61
+ roleArn:p,variables:{...l,...r?.variableName&&{[r.variableName]:r.version}},tags:{
62
+ ...i.tags,...r?.tagName&&{[r.tagName]:r.version}}});return{functionArn:R.functionArn,
63
+ functionVersion:R.functionVersion,variables:v(l),valuesHash:m,sourceHash:u,bundleHash:x,
64
+ logGroup:s,roleArn:p}})},"createResource"),ct=o((t,e,n)=>{let{parameters:r,result:i}=t,
65
+ {functionName:a}=r;if(!i)throw new nt(f,a);return U.logExecution(f,a,"updates",async s=>{
66
+ let p=await r.getFunctionVariables(),u=e.result?.variables??p,c=re(f,a,n),m=e.result?.
67
+ roleArn??c,l=ne(f,a,n),d=e.result?.logGroup??l,{isUpdated:x,...R}=await gt(s,a,r,
68
+ e.result,n),P={...r,variables:p,roleArn:c,logGroup:l},C={...e.parameters,variables:u,
69
+ roleArn:m,logGroup:d};return await mt(s,a,P,C,x,n),await lt(s,i.functionArn,r,e.
70
+ parameters,x),{...i,...R,variables:v(p),logGroup:l,roleArn:c}})},"updateResource"),
71
+ ut=o(async t=>{let{result:e,parameters:n}=t;if(!e)return;let{functionName:r}=n;await U.
72
+ logExecution(f,r,"deletion",async i=>{await K(r,i)})},"deleteResource"),mt=o(async(t,e,n,r,i,a)=>{
73
+ let{variables:s,...p}=n,u={variables:v(s),...p},c=!it(u,r,{exclude:{sourceFile:!0,
74
+ functionName:!0,architecture:!0,release:!0,tags:!0}}),m=i?n.release:r.release,l=i&&
75
+ m?.variableName;(c||l||a.force)&&await V(t,e,{...n,variables:{...n.variables,...m?.
76
+ variableName&&{[m.variableName]:m.version}}})},"checkConfigurationUpdates"),lt=o(
77
+ async(t,e,n,r,i)=>{let s=i&&n.release?.version!==r.release?.version?n.release:void 0,
78
+ p={...n.tags,...s?.tagName&&{[s.tagName]:s.version}};await tt(p,r.tags,u=>H(t,e,
79
+ u),u=>X(t,e,u))},"checkTagUpdates"),gt=o(async(t,e,n,r,i)=>{let[a,s]=await Promise.
80
+ all([O(...n.getFunctionFiles()),n.getFunctionHash()]),p=r?.sourceHash,u=r?.valuesHash;
81
+ if(a!==p||s!==u||i.force){let c=await n.getFunctionBundle(i),m=await te(c),l=r?.
82
+ bundleHash;if(m===l&&s===u)return t.update("Skipping source code update"),{isUpdated:!1,
83
+ valuesHash:s,sourceHash:a};let{functionVersion:d}=await T(t,e,{architecture:n.architecture,
84
+ publish:!r?.functionVersion,sourceFile:c});return{isUpdated:!0,valuesHash:s,sourceHash:a,
85
+ bundleHash:m,...d&&{functionVersion:d}}}return{isUpdated:!1}},"checkSourceCodeUp\
86
+ dates");var ae=o(()=>{dt(y,oe())},"registerFunctionProvider");import{tryRegisterProvider as Pt}from"@ez4/aws-common";import{OperationLogger as me,ReplaceResourceError as xt}from"@ez4/aws-common";import{IncompleteResourceError as se}from"@ez4/aws-common";var N=class extends Error{static{o(this,"FunctionNotFoundError")}constructor(e){
87
+ super(`Function ${e} wasn't found.`)}};var pe=o(t=>t.type===y,"isFunctionState"),lr=o((t,e,n)=>{try{let r=t.getServiceState(
88
+ e,n);if(pe(r))return r}catch{}},"tryGetFunctionState"),gr=o((t,e,n)=>{let r=t.getServiceState(
89
+ e,n);if(!pe(r))throw new N(e);return r},"getFunctionState"),b=o((t,e,n)=>{let r=n.
90
+ getDependencies(y).at(0)?.parameters;if(!r?.functionName)throw new se(t,e,"funct\
91
+ ionName");return r.functionName},"getFunctionName"),ft=o(t=>t.getDependencies(y)[0]?.
92
+ result?.functionArn,"tryGetFunctionArn"),dr=o((t,e,n)=>{let r=ft(n);if(!r)throw new se(
93
+ t,e,"functionArn");return r},"getFunctionArn");import{AddPermissionCommand as yt,RemovePermissionCommand as St,ResourceNotFoundException as Ft}from"@aws-sdk/client-lambda";var ce=o(async(t,e)=>{t.update("Creating permission");let n=e.statementId??`ID${Date.
94
+ now()}`;return await g().send(new yt({StatementId:n,FunctionName:e.functionName,
95
+ SourceArn:e.sourceArn,Principal:e.principal,Action:e.action})),{statementId:n}},
96
+ "createPermission"),ue=o(async(t,e,n)=>{t.update("Deleting permission");try{return await g().
97
+ send(new St({FunctionName:e,StatementId:n})),!0}catch(r){if(!(r instanceof Ft))throw r;
98
+ return!1}},"deletePermission");var h="AWS:Lambda/Permission",S="aws:lambda.permission";var le=o(()=>({equals:wt,create:ge,replace:vt,preview:Rt,update:bt,delete:ht}),"\
99
+ getPermissionHandler"),wt=o((t,e)=>!!t.result&&t.result.functionName===e.result?.
100
+ functionName,"equalsResource"),Rt=o((t,e)=>{},"previewResource"),vt=o(async(t,e,n)=>{
101
+ if(e.result)throw new xt(h,t.entryId,e.entryId);return ge(t,n)},"replaceResource"),
102
+ ge=o((t,e)=>{let n=t.parameters,r=b(h,"permission",e);return me.logExecution(h,r,
103
+ "creation",async i=>{let a=await n.getPermission(e);return{statementId:(await ce(
104
+ i,{action:"lambda:InvokeFunction",sourceArn:a.sourceArn,principal:a.principal,functionName:r})).
105
+ statementId,functionName:r}})},"createResource"),bt=o(async()=>{},"updateResourc\
106
+ e"),ht=o(async t=>{let e=t.result;if(!e)return;let{functionName:n,statementId:r}=e;
107
+ await me.logExecution(h,n,"deletion",async i=>{await ue(i,n,r)})},"deleteResourc\
108
+ e");var de=o(()=>{Pt(S,le())},"registerPermissionProvider");import{tryRegisterProvider as Zt}from"@ez4/aws-common";import{CorruptedResourceError as Ut,OperationLogger as z,ReplaceResourceError as zt}from"@ez4/aws-common";
109
+ import{deepCompare as Gt,deepEqual as Dt}from"@ez4/utils";import{GetEventSourceMappingCommand as At,CreateEventSourceMappingCommand as Lt,
110
+ UpdateEventSourceMappingCommand as Nt,DeleteEventSourceMappingCommand as Et,ListEventSourceMappingsCommand as It,
111
+ FunctionResponseType as Mt,EventSourcePosition as Tt,ResourceNotFoundException as Vt}from"@aws-sdk/client-lambda";
112
+ import{parseArn as Ht}from"@ez4/aws-common";import{Wait as fe}from"@ez4/utils";var F="AWS:Lambda/Mapping",w="aws:lambda.mapping",Ct=(n=>(n.DynamoDB="dynamodb",
113
+ n.Queue="sqs",n))(Ct||{});var ye=o(async(t,e,n)=>{t.update("Importing mapping");let r=await g().send(new It(
114
+ {FunctionName:e,EventSourceArn:n})),[i]=r.EventSourceMappings;return i?{eventId:i.
115
+ UUID}:void 0},"importMapping"),Se=o(async(t,e)=>{t.update("Creating mapping");let{
116
+ sourceArn:n,functionName:r}=e,a=(await g().send(new Lt({FunctionName:r,EventSourceArn:n,
117
+ ...Re(e)}))).UUID;return await we(a),{eventId:a}},"createMapping"),Fe=o(async(t,e,n)=>{
118
+ t.update("Updating mapping");let{functionName:r}=n;await g().send(new Nt({UUID:e,
119
+ FunctionName:r,...Re(n)})),await we(e)},"updateMapping"),xe=o(async(t,e)=>{t.update(
120
+ "Deleting mapping");try{return await g().send(new Et({UUID:e})),!0}catch(n){if(!(n instanceof
121
+ Vt))throw n;return!1}},"deleteMapping"),Ot=o(async t=>(await g().send(new At({UUID:t}))).
122
+ State,"getMappingState"),we=o(async t=>{let e=new Set(["Enabled","Disabled"]);await fe.
123
+ until(async()=>{let n=await Ot(t);return e.has(n)?!0:fe.RetryAttempt})},"waitFor\
124
+ ReadyState"),Re=o(t=>{let{sourceArn:e,enabled:n,concurrency:r,batch:i}=t,{service:a}=Ht(
125
+ e);return{Enabled:n,FunctionResponseTypes:[Mt.ReportBatchItemFailures],MaximumBatchingWindowInSeconds:i?.
126
+ maxWait,BatchSize:i?.size,...a==="dynamodb"&&{StartingPosition:Tt.LATEST},...a===
127
+ "sqs"&&{ScalingConfig:{MaximumConcurrency:r}}}},"upsertMappingRequest");var ve=o(()=>({equals:qt,create:be,replace:Bt,preview:kt,update:Wt,delete:$t}),"\
128
+ getMappingHandler"),qt=o((t,e)=>!!t.result&&t.result.eventId===e.result?.eventId,
129
+ "equalsResource"),kt=o((t,e)=>{let n={...t.parameters,dependencies:t.dependencies},
130
+ r={...e.parameters,dependencies:e.dependencies},i=Gt(n,r,{exclude:{getSourceArn:!0}});
131
+ if(i.counts)return{...i,name:n.fromService}},"previewResource"),Bt=o(async(t,e,n)=>{
132
+ if(e.result)throw new zt(F,t.entryId,e.entryId);return be(t,n)},"replaceResource"),
133
+ be=o((t,e)=>{let n=t.parameters,r=b(F,"mapping",e);return z.logExecution(F,r,"cr\
134
+ eation",async i=>{let a=await n.getSourceArn(e);return{eventId:(await ye(i,r,a)??
135
+ await Se(i,{...t.parameters,functionName:r,sourceArn:a})).eventId,functionName:r,
136
+ sourceArn:a}})},"createResource"),Wt=o((t,e,n)=>{let{result:r,parameters:i}=t,{fromService:a}=i;
137
+ if(!r)throw new Ut(F,"mapping");return z.logExecution(F,a,"updates",async s=>{let p=b(
138
+ F,"mapping",n),u=e.result?.functionName??r.functionName,c=r.sourceArn,m={...t.parameters,
139
+ functionName:p,sourceArn:c},l={...e.parameters,functionName:u,sourceArn:c};return await jt(
140
+ s,r.eventId,m,l),{...r,functionName:p}})},"updateResource"),$t=o(async t=>{let e=t.
141
+ result;if(!e)return;let{functionName:n}=e;await z.logExecution(F,n,"deletion",async r=>{
142
+ await xe(r,e.eventId)})},"deleteResource"),jt=o(async(t,e,n,r)=>{!Dt(n,r,{exclude:{
143
+ getSourceArn:!0,fromService:!0}})&&await Fe(t,e,n)},"checkGeneralUpdates");var he=o(()=>{Zt(w,ve())},"registerMappingProvider");var Pe=o(()=>[{account:"lambda.amazonaws.com"}],"prepareIdentityAccount");import{createPolicy as Kt,tryGetPolicy as Xt}from"@ez4/aws-identity";import{getServiceName as Yt}from"@ez4/project/library";import{getAccountId as Qt,getRegion as _t,createPolicyDocument as Jt}from"@ez4/aws-identity";var Ce=o(async t=>{let[e,n]=await Promise.all([_t(),Qt()]);return Jt([{permissions:[
144
+ "logs:CreateLogStream","logs:PutLogEvents"],resourceIds:[`arn:aws:logs:${e}:${n}\
145
+ :log-group:${t}-*:*`]}])},"getPolicyDocument");var Ae=o(async t=>{let{state:e,options:n}=t,r=Yt("",n),i=`${r}-lambda-policy`;return Xt(
146
+ e,i)??Kt(e,{tags:n.tags,policyDocument:await Ce(r),policyName:i})},"prepareExecu\
147
+ tionPolicy");var Fo=o(()=>{en(),tn(),nn(),rn("@ez4/aws-function",{"deploy:prepareIdentityAcco\
148
+ unt":Pe,"deploy:prepareExecutionPolicy":Ae}),ae(),de(),he()},"registerTriggers");import{toKebabCase as on,hashData as an}from"@ez4/utils";import{attachEntry as sn}from"@ez4/stateful";var ho=o((t,e,n,r)=>{let i=on(r.functionName),a=an(y,e.entryId,i),s=[e.entryId];
149
+ return n&&s.push(n.entryId),sn(t,{type:y,entryId:a,dependencies:s,parameters:{...r,
150
+ functionName:i}})},"createFunction");import{attachEntry as pn}from"@ez4/stateful";import{hashData as Ne}from"@ez4/utils";var Le=o(t=>t.type===S,"isPermissionState");var Vo=o((t,e,n,r)=>{let i=Ne(S,e.entryId,n.entryId);return pn(t,{type:S,entryId:i,
151
+ dependencies:[e.entryId,n.entryId],parameters:r})},"createPermission"),Ho=o((t,e,n)=>{
152
+ let r=Ne(S,e.entryId,n.entryId),i=t[r];return i&&Le(i)?i:null},"getPermission");import{hashData as cn}from"@ez4/utils";import{attachEntry as un}from"@ez4/stateful";var qo=o((t,e,n,r)=>{let i=cn(w,e.entryId,n.entryId);return un(t,{type:w,entryId:i,
153
+ dependencies:[e.entryId,n.entryId],parameters:r})},"createMapping");var $o=o(t=>t.type===w,"isMappingState");var Qo=o((t,e,n)=>`arn:aws:lambda:${t}:${e}:function:${n}`,"buildFunctionArn");import{ArchitectureType as mn,RuntimeType as ln}from"@ez4/project";var gn;(a=>(a.
154
+ LogRetention=90,a.Architecture=mn.x86,a.Runtime=ln.Node24,a.Timeout=90,a.Memory=
155
+ 192))(gn||={});export{Ue as FunctionArchitecture,gn as FunctionDefaults,He as FunctionRuntime,f as FunctionServiceName,
156
+ y as FunctionServiceType,Ct as MappingService,F as MappingServiceName,w as MappingServiceType,
157
+ h as PermissionServiceName,S as PermissionServiceType,Qo as buildFunctionArn,ho as createFunction,
158
+ qo as createMapping,Vo as createPermission,I as getFunctionArchitecture,dr as getFunctionArn,
159
+ b as getFunctionName,E as getFunctionRuntime,gr as getFunctionState,Ho as getPermission,
160
+ pe as isFunctionState,$o as isMappingState,Fo as registerTriggers,ft as tryGetFunctionArn,
161
+ lr as tryGetFunctionState};
148
162
  //# sourceMappingURL=main.mjs.map
@@ -1,4 +1,4 @@
1
- import type { Arn } from '@ez4/aws-common';
1
+ import type { Arn, OperationLogLine } from '@ez4/aws-common';
2
2
  export type BatchOptions = {
3
3
  maxWait?: number;
4
4
  size: number;
@@ -14,7 +14,7 @@ export type ImportOrCreateResponse = {
14
14
  eventId: string;
15
15
  };
16
16
  export type UpdateRequest = CreateRequest;
17
- export declare const importMapping: (functionName: string, sourceArn: string) => Promise<ImportOrCreateResponse | undefined>;
18
- export declare const createMapping: (request: CreateRequest) => Promise<ImportOrCreateResponse>;
19
- export declare const updateMapping: (eventId: string, request: UpdateRequest) => Promise<void>;
20
- export declare const deleteMapping: (eventId: string) => Promise<boolean>;
17
+ export declare const importMapping: (logger: OperationLogLine, functionName: string, sourceArn: string) => Promise<ImportOrCreateResponse | undefined>;
18
+ export declare const createMapping: (logger: OperationLogLine, request: CreateRequest) => Promise<ImportOrCreateResponse>;
19
+ export declare const updateMapping: (logger: OperationLogLine, eventId: string, request: UpdateRequest) => Promise<void>;
20
+ export declare const deleteMapping: (logger: OperationLogLine, eventId: string) => Promise<boolean>;
@@ -1,3 +1,4 @@
1
+ import type { OperationLogLine } from '@ez4/aws-common';
1
2
  import type { Arn } from '@ez4/aws-common';
2
3
  export type CreateRequest = {
3
4
  functionName: string;
@@ -9,5 +10,5 @@ export type CreateRequest = {
9
10
  export type CreateResponse = {
10
11
  statementId: string;
11
12
  };
12
- export declare const createPermission: (request: CreateRequest) => Promise<CreateResponse>;
13
- export declare const deletePermission: (functionName: string, statementId: string) => Promise<boolean>;
13
+ export declare const createPermission: (logger: OperationLogLine, request: CreateRequest) => Promise<CreateResponse>;
14
+ export declare const deletePermission: (logger: OperationLogLine, functionName: string, statementId: string) => Promise<boolean>;
@@ -0,0 +1,8 @@
1
+ import { LambdaClient } from '@aws-sdk/client-lambda';
2
+ export declare const getLambdaClient: () => LambdaClient;
3
+ export declare const getLambdaWaiter: (client: LambdaClient) => {
4
+ client: LambdaClient;
5
+ maxWaitTime: number;
6
+ maxDelay: number;
7
+ minDelay: number;
8
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ez4/aws-function",
3
3
  "description": "EZ4: Self-managed AWS lambda function provider",
4
- "version": "0.38.0",
4
+ "version": "0.40.0",
5
5
  "author": "Silas B.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "lint": "eslint --cache",
37
- "clean": "rm -f *.tsbuildinfo && rm -rf dist/*",
37
+ "clean": "rm -rf dist/* *.tsbuildinfo .eslintcache",
38
38
  "build": "tsc && node tools/bundler.mjs",
39
39
  "test": "npm run build && tsc -p tsconfig.test.json && ez4 test -e ../../../local.env",
40
40
  "local:publish": "npm run build && npm run clean:registry && npm publish --registry http://localhost:4873",
@@ -43,13 +43,13 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@aws-sdk/client-lambda": "^3.958.0",
46
- "@ez4/aws-common": "^0.38.0",
47
- "@ez4/aws-identity": "^0.38.0",
48
- "@ez4/aws-logs": "^0.38.0",
49
- "@ez4/project": "^0.38.0",
50
- "@ez4/common": "^0.38.0",
51
- "@ez4/stateful": "^0.38.0",
52
- "@ez4/utils": "^0.38.0",
46
+ "@ez4/aws-common": "^0.40.0",
47
+ "@ez4/aws-identity": "^0.40.0",
48
+ "@ez4/aws-logs": "^0.40.0",
49
+ "@ez4/project": "^0.40.0",
50
+ "@ez4/common": "^0.40.0",
51
+ "@ez4/stateful": "^0.40.0",
52
+ "@ez4/utils": "^0.40.0",
53
53
  "@types/adm-zip": "^0.5.5",
54
54
  "adm-zip": "^0.5.14"
55
55
  }