@flowerforce/flowerbase 1.4.2-beta.2 → 1.4.2-beta.3

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,11 +1,14 @@
1
- import { AWSError } from 'aws-sdk';
2
- import Lambda from 'aws-sdk/clients/lambda';
3
- import S3 from 'aws-sdk/clients/s3';
4
- import { PromiseResult } from 'aws-sdk/lib/request';
1
+ import { InvokeAsyncCommandInput, InvokeAsyncCommandOutput, InvokeCommandInput, InvokeCommandOutput, Lambda } from '@aws-sdk/client-lambda';
2
+ import { S3 } from '@aws-sdk/client-s3';
3
+ type LambdaInvokeResponse = Omit<InvokeCommandOutput, 'Payload'> & {
4
+ Payload: {
5
+ text: () => string | undefined;
6
+ };
7
+ };
5
8
  declare const Aws: () => {
6
9
  lambda: (region: string) => Lambda & {
7
- Invoke: (...args: Parameters<Lambda["invoke"]>) => Promise<PromiseResult<Lambda.InvocationResponse, AWSError>>;
8
- InvokeAsync: Lambda["invokeAsync"];
10
+ Invoke: (params: InvokeCommandInput) => Promise<LambdaInvokeResponse>;
11
+ InvokeAsync: (params: InvokeAsyncCommandInput) => Promise<InvokeAsyncCommandOutput>;
9
12
  };
10
13
  s3: (region: string) => S3;
11
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAA;AAC/C,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAC3C,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAInD,QAAA,MAAM,GAAG;qBAQY,MAAM;gBAKX,CACN,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAClC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;qBACnD,MAAM,CAAC,aAAa,CAAC;;iBAczB,MAAM;CAStB,CAAA;AAED,eAAe,GAAG,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EAExB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACP,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAGvC,KAAK,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,GAAG;IACjE,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;KAC/B,CAAA;CACF,CAAA;AAUD,QAAA,MAAM,GAAG;qBAUY,MAAM;gBAKX,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,oBAAoB,CAAC;qBACxD,CAAC,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,wBAAwB,CAAC;;iBAwB1E,MAAM;CAOtB,CAAA;AAED,eAAe,GAAG,CAAA"}
@@ -8,39 +8,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const lambda_1 = __importDefault(require("aws-sdk/clients/lambda"));
16
- const s3_1 = __importDefault(require("aws-sdk/clients/s3"));
12
+ const client_lambda_1 = require("@aws-sdk/client-lambda");
13
+ const client_s3_1 = require("@aws-sdk/client-s3");
17
14
  const constants_1 = require("../../constants");
15
+ const decodePayload = (payload) => {
16
+ if (!payload) {
17
+ return undefined;
18
+ }
19
+ return Buffer.from(payload).toString('utf-8');
20
+ };
18
21
  const Aws = () => {
19
- const credentials = {
20
- accessKeyId: constants_1.S3_CONFIG.ACCESS_KEY_ID,
21
- secretAccessKey: constants_1.S3_CONFIG.SECRET_ACCESS_KEY,
22
- };
22
+ const credentials = constants_1.S3_CONFIG.ACCESS_KEY_ID && constants_1.S3_CONFIG.SECRET_ACCESS_KEY
23
+ ? {
24
+ accessKeyId: constants_1.S3_CONFIG.ACCESS_KEY_ID,
25
+ secretAccessKey: constants_1.S3_CONFIG.SECRET_ACCESS_KEY
26
+ }
27
+ : undefined;
23
28
  return {
24
29
  lambda: (region) => {
25
- const lambda = new lambda_1.default({
30
+ const lambda = new client_lambda_1.Lambda({
26
31
  region: region,
27
32
  credentials
28
33
  });
29
- lambda.Invoke = (...args) => __awaiter(void 0, void 0, void 0, function* () {
30
- const res = yield lambda.invoke(...args).promise();
34
+ lambda.Invoke = (params) => __awaiter(void 0, void 0, void 0, function* () {
35
+ const res = yield lambda.send(new client_lambda_1.InvokeCommand(params));
31
36
  return Object.assign(Object.assign({}, res), { Payload: {
32
- text: () => res.Payload
37
+ text: () => decodePayload(res.Payload)
33
38
  } });
34
39
  });
35
- lambda.InvokeAsync = lambda.invokeAsync;
40
+ const invokeAsync = (params) => __awaiter(void 0, void 0, void 0, function* () {
41
+ return lambda.send(new client_lambda_1.InvokeAsyncCommand(params));
42
+ });
43
+ lambda.InvokeAsync = invokeAsync;
44
+ lambda.invokeAsync = invokeAsync;
36
45
  return lambda;
37
46
  },
38
- s3: (region) => new s3_1.default({
47
+ s3: (region) => new client_s3_1.S3({
39
48
  region,
40
- apiVersion: '2006-03-01',
41
49
  credentials,
42
- s3ForcePathStyle: true,
43
- signatureVersion: 'v4'
50
+ forcePathStyle: true
44
51
  })
45
52
  };
46
53
  };
@@ -114,11 +114,15 @@ export declare const services: {
114
114
  }>;
115
115
  };
116
116
  aws: () => {
117
- lambda: (region: string) => import("aws-sdk").Lambda & {
118
- Invoke: (...args: Parameters<import("aws-sdk").Lambda["invoke"]>) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/lambda").InvocationResponse, import("aws-sdk").AWSError>>;
119
- InvokeAsync: import("aws-sdk").Lambda["invokeAsync"];
117
+ lambda: (region: string) => import("@aws-sdk/client-lambda/dist-types").Lambda & {
118
+ Invoke: (params: import("@aws-sdk/client-lambda/dist-types").InvokeCommandInput) => Promise<Omit<import("@aws-sdk/client-lambda/dist-types").InvokeCommandOutput, "Payload"> & {
119
+ Payload: {
120
+ text: () => string | undefined;
121
+ };
122
+ }>;
123
+ InvokeAsync: (params: import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandInput) => Promise<import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandOutput>;
120
124
  };
121
- s3: (region: string) => import("aws-sdk").S3;
125
+ s3: (region: string) => import("@aws-sdk/client-s3/dist-types").S3;
122
126
  };
123
127
  auth: import("./auth/model").AuthServiceType;
124
128
  'mongodb-atlas': import("./mongodb-atlas/model").MongodbAtlasFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAMqT,GAAc;;;;;;;CADvV,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKpB,CAAA"}
@@ -155,11 +155,15 @@ export declare const generateContextData: ({ user, services, app, rules, current
155
155
  context: object;
156
156
  }>;
157
157
  } | {
158
- lambda: (region: string) => import("aws-sdk").Lambda & {
159
- Invoke: (...args: Parameters<import("aws-sdk").Lambda["invoke"]>) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/lambda").InvocationResponse, import("aws-sdk").AWSError>>;
160
- InvokeAsync: import("aws-sdk").Lambda["invokeAsync"];
158
+ lambda: (region: string) => import("@aws-sdk/client-lambda/dist-types").Lambda & {
159
+ Invoke: (params: import("@aws-sdk/client-lambda/dist-types").InvokeCommandInput) => Promise<Omit<import("@aws-sdk/client-lambda/dist-types").InvokeCommandOutput, "Payload"> & {
160
+ Payload: {
161
+ text: () => string | undefined;
162
+ };
163
+ }>;
164
+ InvokeAsync: (params: import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandInput) => Promise<import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandOutput>;
161
165
  };
162
- s3: (region: string) => import("aws-sdk").S3;
166
+ s3: (region: string) => import("@aws-sdk/client-s3/dist-types").S3;
163
167
  } | {
164
168
  emailPasswordAuth: {
165
169
  registerUser: ReturnType<import("../../shared/models/handleUserRegistration.model").HandleUserRegistration>;
@@ -284,11 +288,15 @@ export declare const generateContextData: ({ user, services, app, rules, current
284
288
  context: object;
285
289
  }>;
286
290
  } | {
287
- lambda: (region: string) => import("aws-sdk").Lambda & {
288
- Invoke: (...args: Parameters<import("aws-sdk").Lambda["invoke"]>) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/lambda").InvocationResponse, import("aws-sdk").AWSError>>;
289
- InvokeAsync: import("aws-sdk").Lambda["invokeAsync"];
291
+ lambda: (region: string) => import("@aws-sdk/client-lambda/dist-types").Lambda & {
292
+ Invoke: (params: import("@aws-sdk/client-lambda/dist-types").InvokeCommandInput) => Promise<Omit<import("@aws-sdk/client-lambda/dist-types").InvokeCommandOutput, "Payload"> & {
293
+ Payload: {
294
+ text: () => string | undefined;
295
+ };
296
+ }>;
297
+ InvokeAsync: (params: import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandInput) => Promise<import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandOutput>;
290
298
  };
291
- s3: (region: string) => import("aws-sdk").S3;
299
+ s3: (region: string) => import("@aws-sdk/client-s3/dist-types").S3;
292
300
  } | {
293
301
  emailPasswordAuth: {
294
302
  registerUser: ReturnType<import("../../shared/models/handleUserRegistration.model").HandleUserRegistration>;
@@ -412,11 +420,15 @@ export declare const generateContextData: ({ user, services, app, rules, current
412
420
  context: object;
413
421
  }>;
414
422
  } | {
415
- lambda: (region: string) => import("aws-sdk").Lambda & {
416
- Invoke: (...args: Parameters<import("aws-sdk").Lambda["invoke"]>) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/lambda").InvocationResponse, import("aws-sdk").AWSError>>;
417
- InvokeAsync: import("aws-sdk").Lambda["invokeAsync"];
423
+ lambda: (region: string) => import("@aws-sdk/client-lambda/dist-types").Lambda & {
424
+ Invoke: (params: import("@aws-sdk/client-lambda/dist-types").InvokeCommandInput) => Promise<Omit<import("@aws-sdk/client-lambda/dist-types").InvokeCommandOutput, "Payload"> & {
425
+ Payload: {
426
+ text: () => string | undefined;
427
+ };
428
+ }>;
429
+ InvokeAsync: (params: import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandInput) => Promise<import("@aws-sdk/client-lambda/dist-types").InvokeAsyncCommandOutput>;
418
430
  };
419
- s3: (region: string) => import("aws-sdk").S3;
431
+ s3: (region: string) => import("@aws-sdk/client-s3/dist-types").S3;
420
432
  } | {
421
433
  emailPasswordAuth: {
422
434
  registerUser: ReturnType<import("../../shared/models/handleUserRegistration.model").HandleUserRegistration>;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/context/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,a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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA6ChC,MAAM,OAAO,aAAa,WAAW,SAAS;;;CAerE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.4.2-beta.2",
3
+ "version": "1.4.2-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,8 @@
25
25
  "@fastify/mongodb": "^9.0.1",
26
26
  "@fastify/swagger": "^9.5.1",
27
27
  "@fastify/swagger-ui": "^5.2.3",
28
- "aws-sdk": "^2.1692.0",
28
+ "@aws-sdk/client-lambda": "^3.974.0",
29
+ "@aws-sdk/client-s3": "^3.974.0",
29
30
  "bson": "^6.8.0",
30
31
  "dotenv": "^16.4.7",
31
32
  "fastify": "^5.0.0",
@@ -1,16 +1,37 @@
1
- import { AWSError, Credentials } from 'aws-sdk'
2
- import Lambda from 'aws-sdk/clients/lambda'
3
- import S3 from 'aws-sdk/clients/s3'
4
- import { PromiseResult } from 'aws-sdk/lib/request'
1
+ import {
2
+ InvokeAsyncCommand,
3
+ InvokeAsyncCommandInput,
4
+ InvokeAsyncCommandOutput,
5
+ InvokeCommand,
6
+ InvokeCommandInput,
7
+ InvokeCommandOutput,
8
+ Lambda
9
+ } from '@aws-sdk/client-lambda'
10
+ import { S3 } from '@aws-sdk/client-s3'
5
11
  import { S3_CONFIG } from '../../constants'
6
12
 
13
+ type LambdaInvokeResponse = Omit<InvokeCommandOutput, 'Payload'> & {
14
+ Payload: {
15
+ text: () => string | undefined
16
+ }
17
+ }
7
18
 
8
- const Aws = () => {
19
+ const decodePayload = (payload?: Uint8Array): string | undefined => {
20
+ if (!payload) {
21
+ return undefined
22
+ }
9
23
 
10
- const credentials = {
11
- accessKeyId: S3_CONFIG.ACCESS_KEY_ID,
12
- secretAccessKey: S3_CONFIG.SECRET_ACCESS_KEY,
13
- } as Credentials
24
+ return Buffer.from(payload).toString('utf-8')
25
+ }
26
+
27
+ const Aws = () => {
28
+ const credentials =
29
+ S3_CONFIG.ACCESS_KEY_ID && S3_CONFIG.SECRET_ACCESS_KEY
30
+ ? {
31
+ accessKeyId: S3_CONFIG.ACCESS_KEY_ID,
32
+ secretAccessKey: S3_CONFIG.SECRET_ACCESS_KEY
33
+ }
34
+ : undefined
14
35
 
15
36
  return {
16
37
  lambda: (region: string) => {
@@ -18,30 +39,36 @@ const Aws = () => {
18
39
  region: region,
19
40
  credentials
20
41
  }) as Lambda & {
21
- Invoke: (
22
- ...args: Parameters<Lambda['invoke']>
23
- ) => Promise<PromiseResult<Lambda.InvocationResponse, AWSError>>
24
- InvokeAsync: Lambda['invokeAsync']
42
+ Invoke: (params: InvokeCommandInput) => Promise<LambdaInvokeResponse>
43
+ InvokeAsync: (params: InvokeAsyncCommandInput) => Promise<InvokeAsyncCommandOutput>
25
44
  }
26
- lambda.Invoke = async (...args: Parameters<Lambda['invoke']>) => {
27
- const res = await lambda.invoke(...args).promise()
45
+
46
+ lambda.Invoke = async (params: InvokeCommandInput): Promise<LambdaInvokeResponse> => {
47
+ const res = await lambda.send(new InvokeCommand(params))
28
48
  return {
29
49
  ...res,
30
50
  Payload: {
31
- text: () => res.Payload
51
+ text: () => decodePayload(res.Payload)
32
52
  }
33
53
  }
34
54
  }
35
- lambda.InvokeAsync = lambda.invokeAsync
55
+
56
+ const invokeAsync = async (
57
+ params: InvokeAsyncCommandInput
58
+ ): Promise<InvokeAsyncCommandOutput> => {
59
+ return lambda.send(new InvokeAsyncCommand(params))
60
+ }
61
+
62
+ lambda.InvokeAsync = invokeAsync
63
+ lambda.invokeAsync = invokeAsync
64
+
36
65
  return lambda
37
66
  },
38
67
  s3: (region: string) =>
39
68
  new S3({
40
69
  region,
41
- apiVersion: '2006-03-01',
42
70
  credentials,
43
- s3ForcePathStyle: true,
44
- signatureVersion: 'v4'
71
+ forcePathStyle: true
45
72
  })
46
73
  }
47
74
  }