@flowerforce/flowerbase 1.8.4-beta.5 → 1.8.4-beta.6

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 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAUzC;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,iBA0IlE"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAUzC;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,iBA2IlE"}
@@ -70,7 +70,8 @@ function customFunctionController(app) {
70
70
  url,
71
71
  method,
72
72
  ip,
73
- id
73
+ id,
74
+ headers: req.headers
74
75
  }
75
76
  });
76
77
  if (!authResult.id) {
@@ -229,7 +229,8 @@ const executeLocal = (_a) => __awaiter(void 0, [_a], void 0, function* ({ basePa
229
229
  url: 'cli://local',
230
230
  host: 'cli',
231
231
  id: 'cli',
232
- hostname: 'cli'
232
+ hostname: 'cli',
233
+ headers: {}
233
234
  }
234
235
  });
235
236
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA0IhD,eAAO,MAAM,iCAAiC,GAAI,OAAO,OAAO,KAAG,OA0BlE,CAAA;AAID,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,OAgD9D,CAAA;AAqHD,eAAO,MAAM,oCAAoC,GAAI,QAAQ,QAAQ,YAClC,CAAA;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAsSjC,CAAA"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA0IhD,eAAO,MAAM,iCAAiC,GAAI,OAAO,OAAO,KAAG,OA0BlE,CAAA;AAID,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,OAgD9D,CAAA;AAqHD,eAAO,MAAM,oCAAoC,GAAI,QAAQ,QAAQ,YAClC,CAAA;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAuSjC,CAAA"}
@@ -356,7 +356,8 @@ const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0
356
356
  currentFunction,
357
357
  functionName: String(method),
358
358
  functionsList,
359
- services: services_1.services
359
+ services: services_1.services,
360
+ request: req
360
361
  });
361
362
  const normalizedResult = yield normalizeFunctionResult(result);
362
363
  if (isReturnedError(normalizedResult)) {
@@ -33,14 +33,17 @@ export declare const generateContextData: ({ user, services, app, rules, current
33
33
  };
34
34
  context: {
35
35
  request: {
36
- remoteIPAddress: string | undefined;
37
- id?: string | undefined;
38
- ips?: string[];
39
- host?: string | undefined;
40
- hostname?: string | undefined;
41
- url?: string | undefined;
42
- method?: string | undefined;
43
- ip?: string | undefined;
36
+ remoteIPAddress: string;
37
+ requestHeaders: {
38
+ [k: string]: string[];
39
+ };
40
+ webhookUrl: string | undefined;
41
+ httpMethod: string | undefined;
42
+ rawQueryString: string;
43
+ httpReferrer: string | undefined;
44
+ httpUserAgent: string | undefined;
45
+ service: string;
46
+ action: string;
44
47
  };
45
48
  user: unknown;
46
49
  environment: {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAsGT,CAAC;iCAAa,CAAC;;;;;;;;;;;;;;;;;;;kCAtGP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsGT,CAAC;6BAAa,CAAC;;;;;;;;;;;;;;;;;;kCAtGP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsGT,CAAC;6BAAa,CAAC;;;;;;;;;;;;;;;4BAyFF,MAAM,OAAO,aAAa,WAAW,SAAS;;;CAkBrE,CAAA"}
@@ -109,7 +109,7 @@ const createJwtUtils = () => {
109
109
  * @param functionsList -> the list of all functions
110
110
  */
111
111
  const generateContextData = ({ user, services, app, rules, currentFunction, functionName, functionsList, GenerateContextSync, request }) => {
112
- var _a;
112
+ var _a, _b, _c, _d, _e, _f;
113
113
  const BSON = mongodb_1.mongodb.BSON;
114
114
  const Binary = BSON === null || BSON === void 0 ? void 0 : BSON.Binary;
115
115
  if (Binary && typeof Binary.fromBase64 !== 'function') {
@@ -160,7 +160,24 @@ const generateContextData = ({ user, services, app, rules, currentFunction, func
160
160
  }
161
161
  },
162
162
  context: {
163
- request: Object.assign(Object.assign({}, request), { remoteIPAddress: request === null || request === void 0 ? void 0 : request.ip }),
163
+ request: {
164
+ remoteIPAddress: (_b = request === null || request === void 0 ? void 0 : request.ip) !== null && _b !== void 0 ? _b : '',
165
+ requestHeaders: (request === null || request === void 0 ? void 0 : request.headers)
166
+ ? Object.fromEntries(Object.entries(request.headers).map(([key, value]) => [
167
+ key,
168
+ Array.isArray(value) ? value : value !== undefined ? [value] : []
169
+ ]))
170
+ : {},
171
+ webhookUrl: (_c = request === null || request === void 0 ? void 0 : request.url) === null || _c === void 0 ? void 0 : _c.split('?')[0],
172
+ httpMethod: request === null || request === void 0 ? void 0 : request.method,
173
+ rawQueryString: ((_d = request === null || request === void 0 ? void 0 : request.url) === null || _d === void 0 ? void 0 : _d.includes('?'))
174
+ ? request.url.substring(request.url.indexOf('?'))
175
+ : '',
176
+ httpReferrer: (_e = request === null || request === void 0 ? void 0 : request.headers) === null || _e === void 0 ? void 0 : _e.referer,
177
+ httpUserAgent: (_f = request === null || request === void 0 ? void 0 : request.headers) === null || _f === void 0 ? void 0 : _f['user-agent'],
178
+ service: '',
179
+ action: ''
180
+ },
164
181
  user,
165
182
  environment: {
166
183
  tag: process.env.NODE_ENV
@@ -17,7 +17,7 @@ export interface GenerateContextParams {
17
17
  enqueue?: boolean;
18
18
  request?: ContextRequest;
19
19
  }
20
- type ContextRequest = Pick<FastifyRequest, "ips" | "host" | "hostname" | "url" | "method" | "ip" | "id">;
20
+ type ContextRequest = Pick<FastifyRequest, "ips" | "host" | "hostname" | "url" | "method" | "ip" | "id" | "headers">;
21
21
  export interface GenerateContextDataParams extends Omit<GenerateContextParams, 'args'> {
22
22
  GenerateContext: (params: GenerateContextParams) => Promise<unknown>;
23
23
  GenerateContextSync: (params: GenerateContextParams) => unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/utils/context/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEnD,MAAM,WAAW,qBAA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EAAE,SAAS,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAED,KAAK,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;AACpH,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACpF,eAAe,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACpE,mBAAmB,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAA;CAChE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.8.4-beta.5",
3
+ "version": "1.8.4-beta.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -75,7 +75,8 @@ export async function customFunctionController(app: FastifyInstance) {
75
75
  url,
76
76
  method,
77
77
  ip,
78
- id
78
+ id,
79
+ headers: req.headers
79
80
  }
80
81
  }) as CustomFunctionAuthResult
81
82
 
@@ -233,7 +233,8 @@ const executeLocal = async ({
233
233
  url: 'cli://local',
234
234
  host: 'cli',
235
235
  id: 'cli',
236
- hostname: 'cli'
236
+ hostname: 'cli',
237
+ headers: {}
237
238
  }
238
239
  })
239
240
  } finally {
@@ -441,7 +441,8 @@ export const functionsController: FunctionController = async (
441
441
  currentFunction,
442
442
  functionName: String(method),
443
443
  functionsList,
444
- services
444
+ services,
445
+ request: req
445
446
  })
446
447
  const normalizedResult = await normalizeFunctionResult(result)
447
448
  if (isReturnedError(normalizedResult)) {
@@ -187,8 +187,24 @@ export const generateContextData = ({
187
187
  },
188
188
  context: {
189
189
  request: {
190
- ...request,
191
- remoteIPAddress: request?.ip
190
+ remoteIPAddress: request?.ip ?? '',
191
+ requestHeaders: request?.headers
192
+ ? Object.fromEntries(
193
+ Object.entries(request.headers).map(([key, value]) => [
194
+ key,
195
+ Array.isArray(value) ? value : value !== undefined ? [value] : []
196
+ ])
197
+ )
198
+ : {},
199
+ webhookUrl: request?.url?.split('?')[0],
200
+ httpMethod: request?.method,
201
+ rawQueryString: request?.url?.includes('?')
202
+ ? request.url.substring(request.url.indexOf('?'))
203
+ : '',
204
+ httpReferrer: request?.headers?.referer as string | undefined,
205
+ httpUserAgent: request?.headers?.['user-agent'] as string | undefined,
206
+ service: '',
207
+ action: ''
192
208
  },
193
209
  user,
194
210
  environment: {
@@ -19,7 +19,7 @@ export interface GenerateContextParams {
19
19
  request?: ContextRequest
20
20
  }
21
21
 
22
- type ContextRequest = Pick<FastifyRequest, "ips" | "host" | "hostname" | "url" | "method" | "ip" | "id">
22
+ type ContextRequest = Pick<FastifyRequest, "ips" | "host" | "hostname" | "url" | "method" | "ip" | "id" | "headers">
23
23
  export interface GenerateContextDataParams extends Omit<GenerateContextParams, 'args'> {
24
24
  GenerateContext: (params: GenerateContextParams) => Promise<unknown>
25
25
  GenerateContextSync: (params: GenerateContextParams) => unknown