@ya-accelerators/nextjs-framework 0.0.128 → 0.0.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.generated/policy/error-log.d.ts +1 -0
- package/dist/.generated/policy/error-log.js +1 -0
- package/dist/.generated/policy/error-log.js.map +1 -1
- package/dist/lib/error-log/index.d.ts +4 -5
- package/dist/lib/error-log/index.js +9 -3
- package/dist/lib/error-log/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-log.js","sourceRoot":"","sources":["../../../../src/.generated/policy/error-log.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,CAAC,MAAM,EAAE,WAAW,CAAU;IAC/C,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,CAAU;CAC/C,CAAA"}
|
|
1
|
+
{"version":3,"file":"error-log.js","sourceRoot":"","sources":["../../../../src/.generated/policy/error-log.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,CAAC,MAAM,EAAE,WAAW,CAAU;IAC/C,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,CAAU;CAC/C,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HTTPHeaders } from '@trpc/client';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
declare const errorLogPayloadSchema: z.ZodObject<{
|
|
3
4
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -6,10 +7,8 @@ declare const errorLogPayloadSchema: z.ZodObject<{
|
|
|
6
7
|
userAgent: z.ZodString;
|
|
7
8
|
}, z.core.$strip>;
|
|
8
9
|
export type ErrorLogPayload = z.infer<typeof errorLogPayloadSchema>;
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
'x-forwarded-for': string;
|
|
13
|
-
}>;
|
|
10
|
+
export declare const createErrorLogAction: (mutation: (input: ErrorLogPayload & {
|
|
11
|
+
reporterKey: string;
|
|
12
|
+
}, headers?: HTTPHeaders) => Promise<unknown>, allowedConsumerHeaders: readonly string[]) => (payload: ErrorLogPayload) => Promise<unknown>;
|
|
14
13
|
export declare const createErrorLogRoute: (action: (input: ErrorLogPayload) => Promise<unknown>) => (request: Request) => Promise<Response>;
|
|
15
14
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { errorLogConstants } from '../../constants';
|
|
3
3
|
import { logger } from '../../logger';
|
|
4
|
+
import { mergeDefaultHeaders } from '../trpc';
|
|
4
5
|
let lastFailureNoticeAt = 0;
|
|
5
6
|
const boundedField = z.string().max(errorLogConstants.ERROR_LOG_MAX_FIELD_LENGTH);
|
|
6
7
|
const errorLogPayloadShape = {
|
|
@@ -10,10 +11,15 @@ const errorLogPayloadShape = {
|
|
|
10
11
|
stack: boundedField.optional(),
|
|
11
12
|
};
|
|
12
13
|
const errorLogPayloadSchema = z.object(errorLogPayloadShape);
|
|
13
|
-
export const
|
|
14
|
+
export const createErrorLogAction = (mutation, allowedConsumerHeaders) => async (payload) => {
|
|
14
15
|
const { headers } = await import('next/headers');
|
|
15
|
-
const
|
|
16
|
-
return
|
|
16
|
+
const { createHash } = await import('node:crypto');
|
|
17
|
+
return mutation({
|
|
18
|
+
...payload,
|
|
19
|
+
reporterKey: createHash('sha256')
|
|
20
|
+
.update((await headers()).get('x-forwarded-for')?.split(',').pop()?.trim() || '<unresolved>')
|
|
21
|
+
.digest('hex'),
|
|
22
|
+
}, await mergeDefaultHeaders(undefined, allowedConsumerHeaders));
|
|
17
23
|
};
|
|
18
24
|
export const createErrorLogRoute = (action) => async (request) => {
|
|
19
25
|
let parsed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/error-log/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/error-log/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,IAAI,mBAAmB,GAAG,CAAC,CAAA;AAE3B,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAAA;AAEjF,MAAM,oBAAoB,GAC6E;IACrG,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,YAAY,CAAC,QAAQ,EAAE;CAC/B,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAG5D,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CACE,QAAuG,EACvG,sBAAyC,EACzC,EAAE,CACJ,KAAK,EAAE,OAAwB,EAAE,EAAE;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAClD,OAAO,QAAQ,CACb;QACE,GAAG,OAAO;QACV,WAAW,EAAE,UAAU,CAAC,QAAQ,CAAC;aAC9B,MAAM,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GA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