@redmix/api 9.0.0-canary.581 → 9.0.0-canary.582
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/auth/index.js +10 -49
- package/dist/auth/parseJWT.js +3 -26
- package/dist/auth/verifiers/base64Sha1Verifier.js +18 -37
- package/dist/auth/verifiers/base64Sha256Verifier.js +18 -37
- package/dist/auth/verifiers/common.js +19 -58
- package/dist/auth/verifiers/index.js +8 -33
- package/dist/auth/verifiers/jwtVerifier.js +17 -47
- package/dist/auth/verifiers/secretKeyVerifier.js +7 -26
- package/dist/auth/verifiers/sha1Verifier.js +18 -37
- package/dist/auth/verifiers/sha256Verifier.js +18 -37
- package/dist/auth/verifiers/skipVerifier.js +4 -23
- package/dist/auth/verifiers/timestampSchemeVerifier.js +18 -33
- package/dist/cache/clients/BaseClient.js +4 -23
- package/dist/cache/clients/InMemoryClient.js +6 -35
- package/dist/cache/clients/MemcachedClient.js +6 -35
- package/dist/cache/clients/RedisClient.js +6 -35
- package/dist/cache/errors.js +3 -26
- package/dist/cache/index.js +14 -52
- package/dist/cjs/auth/index.d.ts +51 -0
- package/dist/cjs/auth/index.d.ts.map +1 -0
- package/dist/cjs/auth/index.js +129 -0
- package/dist/cjs/auth/parseJWT.d.ts +6 -0
- package/dist/cjs/auth/parseJWT.d.ts.map +1 -0
- package/dist/cjs/auth/parseJWT.js +57 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +19 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +77 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +19 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +77 -0
- package/dist/cjs/auth/verifiers/common.d.ts +104 -0
- package/dist/cjs/auth/verifiers/common.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/common.js +99 -0
- package/dist/cjs/auth/verifiers/index.d.ts +8 -0
- package/dist/cjs/auth/verifiers/index.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/index.js +38 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +26 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.js +86 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +14 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.js +40 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +25 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.js +85 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +25 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.js +85 -0
- package/dist/cjs/auth/verifiers/skipVerifier.d.ts +13 -0
- package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/skipVerifier.js +37 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +16 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +81 -0
- package/dist/cjs/bins/redwood.d.ts +9 -0
- package/dist/cjs/bins/redwood.d.ts.map +1 -0
- package/dist/cjs/bins/rwfw.d.ts +3 -0
- package/dist/cjs/bins/rwfw.d.ts.map +1 -0
- package/dist/cjs/bins/tsc.d.ts +3 -0
- package/dist/cjs/bins/tsc.d.ts.map +1 -0
- package/dist/{bins → cjs/bins}/tsc.js +2 -2
- package/dist/cjs/cache/clients/BaseClient.d.ts +11 -0
- package/dist/cjs/cache/clients/BaseClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/BaseClient.js +27 -0
- package/dist/cjs/cache/clients/InMemoryClient.d.ts +31 -0
- package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/InMemoryClient.js +100 -0
- package/dist/cjs/cache/clients/MemcachedClient.d.ts +16 -0
- package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/MemcachedClient.js +75 -0
- package/dist/cjs/cache/clients/RedisClient.d.ts +20 -0
- package/dist/cjs/cache/clients/RedisClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/RedisClient.js +79 -0
- package/dist/cjs/cache/errors.d.ts +4 -0
- package/dist/cjs/cache/errors.d.ts.map +1 -0
- package/dist/cjs/cache/errors.js +33 -0
- package/dist/cjs/cache/index.d.ts +35 -0
- package/dist/cjs/cache/index.d.ts.map +1 -0
- package/dist/cjs/cache/index.js +171 -0
- package/dist/cjs/cors.d.ts +16 -0
- package/dist/cjs/cors.d.ts.map +1 -0
- package/dist/cjs/cors.js +93 -0
- package/dist/cjs/errors.d.ts +5 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +38 -0
- package/dist/cjs/event.d.ts +3 -0
- package/dist/cjs/event.d.ts.map +1 -0
- package/dist/cjs/event.js +34 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +4 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +1 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +72 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/logger/index.d.ts +179 -0
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js +195 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/transforms.d.ts +35 -0
- package/dist/cjs/transforms.d.ts.map +1 -0
- package/dist/cjs/transforms.js +98 -0
- package/dist/cjs/types.d.ts +25 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/validations/errors.d.ts +101 -0
- package/dist/cjs/validations/errors.d.ts.map +1 -0
- package/dist/cjs/validations/errors.js +298 -0
- package/dist/cjs/validations/validations.d.ts +222 -0
- package/dist/cjs/validations/validations.d.ts.map +1 -0
- package/dist/cjs/validations/validations.js +351 -0
- package/dist/cjs/webhooks/index.d.ts +76 -0
- package/dist/cjs/webhooks/index.d.ts.map +1 -0
- package/dist/cjs/webhooks/index.js +107 -0
- package/dist/cors.js +7 -30
- package/dist/errors.js +3 -26
- package/dist/event.js +5 -28
- package/dist/functions/fixtures/apiGatewayProxyEvent.fixture.js +4 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -46
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +6 -48
- package/dist/package.json +1 -0
- package/dist/transforms.js +6 -33
- package/dist/types.js +1 -16
- package/dist/validations/errors.js +8 -66
- package/dist/validations/validations.js +8 -44
- package/dist/webhooks/index.js +25 -46
- package/package.json +53 -18
- /package/dist/{bins → cjs/bins}/redwood.js +0 -0
- /package/dist/{bins → cjs/bins}/rwfw.js +0 -0
package/dist/cjs/cors.js
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var cors_exports = {};
|
20
|
+
__export(cors_exports, {
|
21
|
+
createCorsContext: () => createCorsContext
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(cors_exports);
|
24
|
+
var import_fetch = require("@whatwg-node/fetch");
|
25
|
+
function createCorsContext(cors) {
|
26
|
+
const corsHeaders = new import_fetch.Headers();
|
27
|
+
if (cors) {
|
28
|
+
if (cors.methods) {
|
29
|
+
if (typeof cors.methods === "string") {
|
30
|
+
corsHeaders.set("access-control-allow-methods", cors.methods);
|
31
|
+
} else if (Array.isArray(cors.methods)) {
|
32
|
+
corsHeaders.set("access-control-allow-methods", cors.methods.join(","));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (cors.allowedHeaders) {
|
36
|
+
if (typeof cors.allowedHeaders === "string") {
|
37
|
+
corsHeaders.set("access-control-allow-headers", cors.allowedHeaders);
|
38
|
+
} else if (Array.isArray(cors.allowedHeaders)) {
|
39
|
+
corsHeaders.set(
|
40
|
+
"access-control-allow-headers",
|
41
|
+
cors.allowedHeaders.join(",")
|
42
|
+
);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
if (cors.exposedHeaders) {
|
46
|
+
if (typeof cors.exposedHeaders === "string") {
|
47
|
+
corsHeaders.set("access-control-expose-headers", cors.exposedHeaders);
|
48
|
+
} else if (Array.isArray(cors.exposedHeaders)) {
|
49
|
+
corsHeaders.set(
|
50
|
+
"access-control-expose-headers",
|
51
|
+
cors.exposedHeaders.join(",")
|
52
|
+
);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
if (cors.credentials) {
|
56
|
+
corsHeaders.set("access-control-allow-credentials", "true");
|
57
|
+
}
|
58
|
+
if (typeof cors.maxAge === "number") {
|
59
|
+
corsHeaders.set("access-control-max-age", cors.maxAge.toString());
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return {
|
63
|
+
shouldHandleCors(request) {
|
64
|
+
return request.method === "OPTIONS";
|
65
|
+
},
|
66
|
+
getRequestHeaders(request) {
|
67
|
+
const eventHeaders = new import_fetch.Headers(request.headers);
|
68
|
+
const requestCorsHeaders = new import_fetch.Headers(corsHeaders);
|
69
|
+
if (cors?.origin) {
|
70
|
+
const requestOrigin = eventHeaders.get("origin");
|
71
|
+
if (typeof cors.origin === "string") {
|
72
|
+
requestCorsHeaders.set("access-control-allow-origin", cors.origin);
|
73
|
+
} else if (requestOrigin && (typeof cors.origin === "boolean" || Array.isArray(cors.origin) && requestOrigin && cors.origin.includes(requestOrigin))) {
|
74
|
+
requestCorsHeaders.set("access-control-allow-origin", requestOrigin);
|
75
|
+
}
|
76
|
+
const requestAccessControlRequestHeaders = eventHeaders.get(
|
77
|
+
"access-control-request-headers"
|
78
|
+
);
|
79
|
+
if (!cors.allowedHeaders && requestAccessControlRequestHeaders) {
|
80
|
+
requestCorsHeaders.set(
|
81
|
+
"access-control-allow-headers",
|
82
|
+
requestAccessControlRequestHeaders
|
83
|
+
);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
return Object.fromEntries(requestCorsHeaders.entries());
|
87
|
+
}
|
88
|
+
};
|
89
|
+
}
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
91
|
+
0 && (module.exports = {
|
92
|
+
createCorsContext
|
93
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;gBAC/B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAQ9D"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var errors_exports = {};
|
20
|
+
__export(errors_exports, {
|
21
|
+
RedwoodError: () => RedwoodError
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
24
|
+
class RedwoodError extends Error {
|
25
|
+
extensions;
|
26
|
+
constructor(message, extensions) {
|
27
|
+
super(message);
|
28
|
+
this.name = "RedwoodError";
|
29
|
+
this.extensions = {
|
30
|
+
...extensions,
|
31
|
+
code: extensions?.code || "REDWOODJS_ERROR"
|
32
|
+
};
|
33
|
+
}
|
34
|
+
}
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
36
|
+
0 && (module.exports = {
|
37
|
+
RedwoodError
|
38
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,eAAO,MAAM,cAAc,UAClB,oBAAoB,GAAG,OAAO,cACzB,MAAM,8BAOnB,CAAA"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var event_exports = {};
|
20
|
+
__export(event_exports, {
|
21
|
+
getEventHeader: () => getEventHeader
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(event_exports);
|
24
|
+
var import_transforms = require("./transforms.js");
|
25
|
+
const getEventHeader = (event, headerName) => {
|
26
|
+
if ((0, import_transforms.isFetchApiRequest)(event)) {
|
27
|
+
return event.headers.get(headerName);
|
28
|
+
}
|
29
|
+
return event.headers[headerName] || event.headers[headerName.toLowerCase()];
|
30
|
+
};
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
32
|
+
0 && (module.exports = {
|
33
|
+
getEventHeader
|
34
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"apiGatewayProxyEvent.fixture.d.ts","sourceRoot":"","sources":["../../../../src/functions/fixtures/apiGatewayProxyEvent.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,eAAO,MAAM,0BAA0B,EAAE,oBA0CxC,CAAA;AAED,eAAe,0BAA0B,CAAA"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var apiGatewayProxyEvent_fixture_exports = {};
|
20
|
+
__export(apiGatewayProxyEvent_fixture_exports, {
|
21
|
+
default: () => apiGatewayProxyEvent_fixture_default,
|
22
|
+
mockedAPIGatewayProxyEvent: () => mockedAPIGatewayProxyEvent
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(apiGatewayProxyEvent_fixture_exports);
|
25
|
+
const mockedAPIGatewayProxyEvent = {
|
26
|
+
body: "MOCKED_BODY",
|
27
|
+
headers: {},
|
28
|
+
multiValueHeaders: {},
|
29
|
+
httpMethod: "POST",
|
30
|
+
isBase64Encoded: false,
|
31
|
+
path: "/MOCK_PATH",
|
32
|
+
pathParameters: null,
|
33
|
+
queryStringParameters: null,
|
34
|
+
multiValueQueryStringParameters: null,
|
35
|
+
stageVariables: null,
|
36
|
+
requestContext: {
|
37
|
+
accountId: "MOCKED_ACCOUNT",
|
38
|
+
apiId: "MOCKED_API_ID",
|
39
|
+
authorizer: { name: "MOCKED_AUTHORIZER" },
|
40
|
+
protocol: "HTTP",
|
41
|
+
identity: {
|
42
|
+
accessKey: null,
|
43
|
+
accountId: null,
|
44
|
+
apiKey: null,
|
45
|
+
apiKeyId: null,
|
46
|
+
caller: null,
|
47
|
+
clientCert: null,
|
48
|
+
cognitoAuthenticationProvider: null,
|
49
|
+
cognitoAuthenticationType: null,
|
50
|
+
cognitoIdentityId: null,
|
51
|
+
cognitoIdentityPoolId: null,
|
52
|
+
principalOrgId: null,
|
53
|
+
sourceIp: "123.123.123.123",
|
54
|
+
user: null,
|
55
|
+
userAgent: null,
|
56
|
+
userArn: null
|
57
|
+
},
|
58
|
+
httpMethod: "POST",
|
59
|
+
path: "/MOCK_PATH",
|
60
|
+
stage: "MOCK_STAGE",
|
61
|
+
requestId: "MOCKED_REQUEST_ID",
|
62
|
+
requestTimeEpoch: 1,
|
63
|
+
resourceId: "MOCKED_RESOURCE_ID",
|
64
|
+
resourcePath: "MOCKED_RESOURCE_PATH"
|
65
|
+
},
|
66
|
+
resource: "MOCKED_RESOURCE"
|
67
|
+
};
|
68
|
+
var apiGatewayProxyEvent_fixture_default = mockedAPIGatewayProxyEvent;
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
70
|
+
0 && (module.exports = {
|
71
|
+
mockedAPIGatewayProxyEvent
|
72
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from './auth/index.js';
|
2
|
+
export * from './errors.js';
|
3
|
+
export * from './validations/validations.js';
|
4
|
+
export * from './validations/errors.js';
|
5
|
+
export * from './types.js';
|
6
|
+
export * from './transforms.js';
|
7
|
+
export * from './cors.js';
|
8
|
+
export * from './event.js';
|
9
|
+
export declare const prismaVersion: any;
|
10
|
+
export declare const redwoodVersion: any;
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAM1B,eAAO,MAAM,aAAa,KAA8C,CAAA;AACxE,eAAO,MAAM,cAAc,KAAuB,CAAA"}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
27
|
+
mod
|
28
|
+
));
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
+
var index_exports = {};
|
31
|
+
__export(index_exports, {
|
32
|
+
prismaVersion: () => prismaVersion,
|
33
|
+
redwoodVersion: () => redwoodVersion
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
36
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
37
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
38
|
+
__reExport(index_exports, require("./auth/index.js"), module.exports);
|
39
|
+
__reExport(index_exports, require("./errors.js"), module.exports);
|
40
|
+
__reExport(index_exports, require("./validations/validations.js"), module.exports);
|
41
|
+
__reExport(index_exports, require("./validations/errors.js"), module.exports);
|
42
|
+
__reExport(index_exports, require("./types.js"), module.exports);
|
43
|
+
__reExport(index_exports, require("./transforms.js"), module.exports);
|
44
|
+
__reExport(index_exports, require("./cors.js"), module.exports);
|
45
|
+
__reExport(index_exports, require("./event.js"), module.exports);
|
46
|
+
const packageJson = JSON.parse(
|
47
|
+
import_node_fs.default.readFileSync(import_node_path.default.join(__dirname, "../package.json"), "utf8")
|
48
|
+
);
|
49
|
+
const prismaVersion = packageJson?.dependencies["@prisma/client"];
|
50
|
+
const redwoodVersion = packageJson?.version;
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
52
|
+
0 && (module.exports = {
|
53
|
+
prismaVersion,
|
54
|
+
redwoodVersion,
|
55
|
+
...require("./auth/index.js"),
|
56
|
+
...require("./errors.js"),
|
57
|
+
...require("./validations/validations.js"),
|
58
|
+
...require("./validations/errors.js"),
|
59
|
+
...require("./types.js"),
|
60
|
+
...require("./transforms.js"),
|
61
|
+
...require("./cors.js"),
|
62
|
+
...require("./event.js")
|
63
|
+
});
|
@@ -0,0 +1,179 @@
|
|
1
|
+
import type P from 'pino';
|
2
|
+
/**
|
3
|
+
* Types from Pino
|
4
|
+
* @see https://github.com/pinojs/pino/blob/master/pino.d.ts
|
5
|
+
*/
|
6
|
+
export type Logger = P.Logger;
|
7
|
+
export type BaseLogger = P.BaseLogger;
|
8
|
+
export type DestinationStream = P.DestinationStream;
|
9
|
+
export type LevelWithSilent = P.LevelWithSilent;
|
10
|
+
export type LoggerOptions = P.LoggerOptions;
|
11
|
+
export type LogLevel = 'info' | 'query' | 'warn' | 'error';
|
12
|
+
type PrismaClient = any;
|
13
|
+
type LogDefinition = {
|
14
|
+
level: LogLevel;
|
15
|
+
emit: 'stdout' | 'event';
|
16
|
+
};
|
17
|
+
/**
|
18
|
+
* Determines if log environment is development
|
19
|
+
*
|
20
|
+
* @type {boolean}
|
21
|
+
*
|
22
|
+
*/
|
23
|
+
export declare const isDevelopment: boolean;
|
24
|
+
/**
|
25
|
+
* Determines if log environment is test
|
26
|
+
*
|
27
|
+
* @type {boolean}
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
export declare const isTest: boolean;
|
31
|
+
/**
|
32
|
+
* Determines if log environment is production by checking if not development
|
33
|
+
*
|
34
|
+
* @type {boolean}
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
export declare const isProduction: boolean;
|
38
|
+
export declare const redactionsList: string[];
|
39
|
+
/**
|
40
|
+
* Determines if log level based on environment variables and
|
41
|
+
* development or deployment environment defaults
|
42
|
+
*
|
43
|
+
* Set `LOG_LEVEL` env to the desired logging level. In order of priority, available levels are:
|
44
|
+
*
|
45
|
+
* - 'fatal'
|
46
|
+
* - 'error'
|
47
|
+
* - 'warn'
|
48
|
+
* - 'info'
|
49
|
+
* - 'debug'
|
50
|
+
* - 'trace'
|
51
|
+
*
|
52
|
+
* The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
|
53
|
+
* and `'info'` logs will be enabled.
|
54
|
+
*
|
55
|
+
* You can pass `'silent'` to disable logging.
|
56
|
+
*
|
57
|
+
* @default 'warn' in Production
|
58
|
+
* @default 'trace' in Development
|
59
|
+
* @default 'silent' in Test
|
60
|
+
*
|
61
|
+
*/
|
62
|
+
export declare const logLevel: LevelWithSilent | string;
|
63
|
+
/**
|
64
|
+
* Defines an opinionated base logger configuration that defines
|
65
|
+
* how to log and what to ignore.
|
66
|
+
*
|
67
|
+
* @default logger options are:
|
68
|
+
*
|
69
|
+
* - Ignore certain event attributes like hostname and pid for cleaner log statements
|
70
|
+
* - Prefix the log output with log level
|
71
|
+
* - Use a shorted log message that omits server name
|
72
|
+
* - Humanize time in GMT
|
73
|
+
* - Set the default log level in test to silent, development to trace
|
74
|
+
* and warn in prod
|
75
|
+
* Or set via LOG_LEVEL environment variable
|
76
|
+
* - Redact the host and other keys via a set redactionList
|
77
|
+
*
|
78
|
+
* Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
|
79
|
+
*
|
80
|
+
* If an object is supplied, three options can be specified:
|
81
|
+
*
|
82
|
+
* paths (String[]): Required. An array of paths
|
83
|
+
* censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
|
84
|
+
* remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
|
85
|
+
*
|
86
|
+
* @see {@link https://github.com/pinojs/pino/blob/master/docs/api.md}
|
87
|
+
*/
|
88
|
+
export declare const defaultLoggerOptions: {
|
89
|
+
level: string;
|
90
|
+
redact: string[];
|
91
|
+
};
|
92
|
+
/**
|
93
|
+
* RedwoodLoggerOptions defines custom logger options that extend those available in LoggerOptions
|
94
|
+
* and can define a destination like a file or other supported pin log transport stream
|
95
|
+
*
|
96
|
+
* @typedef {Object} RedwoodLoggerOptions
|
97
|
+
* @extends LoggerOptions
|
98
|
+
* @property {options} LoggerOptions - options define how to log
|
99
|
+
* @property {string | DestinationStream} destination - destination defines where to log
|
100
|
+
* @property {boolean} showConfig - Display logger configuration on initialization
|
101
|
+
*/
|
102
|
+
export interface RedwoodLoggerOptions {
|
103
|
+
options?: LoggerOptions;
|
104
|
+
destination?: string | DestinationStream;
|
105
|
+
showConfig?: boolean;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* Creates the logger
|
109
|
+
*
|
110
|
+
* @param options {RedwoodLoggerOptions} - Override the default logger configuration
|
111
|
+
* @param destination {DestinationStream} - An optional destination stream
|
112
|
+
* @param showConfig {Boolean} - Show the logger configuration. This is off by default.
|
113
|
+
*
|
114
|
+
* @example
|
115
|
+
* // Create the logger to log just at the error level
|
116
|
+
* createLogger({ options: { level: 'error' } })
|
117
|
+
*
|
118
|
+
* @example
|
119
|
+
* // Create the logger to log to a file
|
120
|
+
* createLogger({ destination: { 'var/logs/redwood-api.log' } })
|
121
|
+
*
|
122
|
+
* @return {Logger} - The configured logger
|
123
|
+
*/
|
124
|
+
export declare const createLogger: ({ options, destination, showConfig, }: RedwoodLoggerOptions) => Logger;
|
125
|
+
/**
|
126
|
+
* Determines the type and level of logging.
|
127
|
+
*
|
128
|
+
* @see {@link https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#log}
|
129
|
+
*/
|
130
|
+
export declare const defaultLogLevels: LogLevel[];
|
131
|
+
/**
|
132
|
+
* Generates the Prisma Log Definitions for the Prisma Client to emit
|
133
|
+
*
|
134
|
+
* @return Prisma.LogDefinition[]
|
135
|
+
*/
|
136
|
+
export declare const emitLogLevels: (setLogLevels: LogLevel[]) => LogDefinition[];
|
137
|
+
/**
|
138
|
+
* Defines what is needed to setup Prisma Client logging used in handlePrismaLogging
|
139
|
+
*
|
140
|
+
*
|
141
|
+
* @param db {PrismaClient} - The Prisma Client instance
|
142
|
+
* @param logger {BaseLogger} - The Redwood logger instance
|
143
|
+
* @param logLevels {LogLevel[]} - The log levels . Should match those set with emitLogLevels
|
144
|
+
* @param slowQueryThreshold {number} - The threshold for slow queries. Default: 2 seconds
|
145
|
+
*
|
146
|
+
* @see emitLogLevels
|
147
|
+
*
|
148
|
+
*/
|
149
|
+
interface PrismaLoggingConfig {
|
150
|
+
db: PrismaClient;
|
151
|
+
logger: Logger;
|
152
|
+
logLevels: LogLevel[];
|
153
|
+
slowQueryThreshold?: number;
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* Sets up event-based logging on the Prisma client
|
157
|
+
*
|
158
|
+
* Sets emit to event for a specific log level, such as query
|
159
|
+
* using the $on() method to subscribe to the event
|
160
|
+
*
|
161
|
+
* @see {@link https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/logging}
|
162
|
+
*
|
163
|
+
* @param PrismaLoggingConfig
|
164
|
+
*
|
165
|
+
* @example
|
166
|
+
*
|
167
|
+
* handlePrismaLogging({
|
168
|
+
* db,
|
169
|
+
* logger,
|
170
|
+
* logLevels: ['info', 'warn', 'error'],
|
171
|
+
* slowQueryThreshold: 2000,
|
172
|
+
* })
|
173
|
+
*
|
174
|
+
* @return {void}
|
175
|
+
*
|
176
|
+
*/
|
177
|
+
export declare const handlePrismaLogging: (config: PrismaLoggingConfig) => void;
|
178
|
+
export {};
|
179
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,MAAM,CAAA;AAGzB;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAA;AAC7B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,CAAA;AACrC,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,iBAAiB,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,eAAe,CAAA;AAC/C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,aAAa,CAAA;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAI1D,KAAK,YAAY,GAAG,GAAG,CAAA;AAEvB,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;CACzB,CAAA;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAyC,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,MAAM,SAAkC,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAA4B,CAAA;AAQrD,eAAO,MAAM,cAAc,EAAE,MAAM,EAgClC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ,EAAE,eAAe,GAAG,MAUrC,CAAA;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB;;;CAGR,CAAA;AAEzB;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAA;IACxC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,0CAItB,oBAAoB,KAAG,MAyCzB,CAAA;AAQD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,EAA8B,CAAA;AAErE;;;;GAIG;AACH,eAAO,MAAM,aAAa,iBAAkB,QAAQ,EAAE,KAAG,aAAa,EAIrE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,UAAU,mBAAmB;IAC3B,EAAE,EAAE,YAAY,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,WAAY,mBAAmB,KAAG,IA8CjE,CAAA"}
|