@cedarjs/api 6.0.0-canary.2788 → 6.0.0-canary.2792

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.
Files changed (109) hide show
  1. package/dist/bins/cedar.js +14 -0
  2. package/dist/bins/cfw.js +14 -0
  3. package/dist/bins/redwood.js +14 -0
  4. package/dist/bins/tsc.js +8 -0
  5. package/dist/index.js +3 -3
  6. package/package.json +15 -39
  7. package/dist/cjs/auth/index.d.ts +0 -64
  8. package/dist/cjs/auth/index.d.ts.map +0 -1
  9. package/dist/cjs/auth/index.js +0 -143
  10. package/dist/cjs/auth/parseJWT.d.ts +0 -6
  11. package/dist/cjs/auth/parseJWT.d.ts.map +0 -1
  12. package/dist/cjs/auth/parseJWT.js +0 -57
  13. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +0 -18
  14. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +0 -1
  15. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +0 -77
  16. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +0 -18
  17. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +0 -1
  18. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +0 -77
  19. package/dist/cjs/auth/verifiers/common.d.ts +0 -112
  20. package/dist/cjs/auth/verifiers/common.d.ts.map +0 -1
  21. package/dist/cjs/auth/verifiers/common.js +0 -89
  22. package/dist/cjs/auth/verifiers/index.d.ts +0 -8
  23. package/dist/cjs/auth/verifiers/index.d.ts.map +0 -1
  24. package/dist/cjs/auth/verifiers/index.js +0 -39
  25. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +0 -18
  26. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +0 -1
  27. package/dist/cjs/auth/verifiers/jwtVerifier.js +0 -84
  28. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +0 -11
  29. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +0 -1
  30. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +0 -43
  31. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +0 -17
  32. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +0 -1
  33. package/dist/cjs/auth/verifiers/sha1Verifier.js +0 -85
  34. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +0 -17
  35. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +0 -1
  36. package/dist/cjs/auth/verifiers/sha256Verifier.js +0 -85
  37. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +0 -11
  38. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +0 -1
  39. package/dist/cjs/auth/verifiers/skipVerifier.js +0 -40
  40. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +0 -14
  41. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +0 -1
  42. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +0 -86
  43. package/dist/cjs/bins/cedar.d.ts +0 -9
  44. package/dist/cjs/bins/cedar.d.ts.map +0 -1
  45. package/dist/cjs/bins/cedar.js +0 -36
  46. package/dist/cjs/bins/cfw.d.ts +0 -3
  47. package/dist/cjs/bins/cfw.d.ts.map +0 -1
  48. package/dist/cjs/bins/cfw.js +0 -36
  49. package/dist/cjs/bins/redwood.d.ts +0 -9
  50. package/dist/cjs/bins/redwood.d.ts.map +0 -1
  51. package/dist/cjs/bins/redwood.js +0 -36
  52. package/dist/cjs/bins/tsc.d.ts +0 -3
  53. package/dist/cjs/bins/tsc.d.ts.map +0 -1
  54. package/dist/cjs/bins/tsc.js +0 -30
  55. package/dist/cjs/cache/clients/BaseClient.d.ts +0 -11
  56. package/dist/cjs/cache/clients/BaseClient.d.ts.map +0 -1
  57. package/dist/cjs/cache/clients/BaseClient.js +0 -31
  58. package/dist/cjs/cache/clients/InMemoryClient.d.ts +0 -31
  59. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +0 -1
  60. package/dist/cjs/cache/clients/InMemoryClient.js +0 -94
  61. package/dist/cjs/cache/clients/MemcachedClient.d.ts +0 -16
  62. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +0 -1
  63. package/dist/cjs/cache/clients/MemcachedClient.js +0 -79
  64. package/dist/cjs/cache/clients/RedisClient.d.ts +0 -20
  65. package/dist/cjs/cache/clients/RedisClient.d.ts.map +0 -1
  66. package/dist/cjs/cache/clients/RedisClient.js +0 -83
  67. package/dist/cjs/cache/errors.d.ts +0 -4
  68. package/dist/cjs/cache/errors.d.ts.map +0 -1
  69. package/dist/cjs/cache/errors.js +0 -33
  70. package/dist/cjs/cache/index.d.ts +0 -35
  71. package/dist/cjs/cache/index.d.ts.map +0 -1
  72. package/dist/cjs/cache/index.js +0 -165
  73. package/dist/cjs/cors.d.ts +0 -16
  74. package/dist/cjs/cors.d.ts.map +0 -1
  75. package/dist/cjs/cors.js +0 -93
  76. package/dist/cjs/errors.d.ts +0 -5
  77. package/dist/cjs/errors.d.ts.map +0 -1
  78. package/dist/cjs/errors.js +0 -38
  79. package/dist/cjs/event.d.ts +0 -3
  80. package/dist/cjs/event.d.ts.map +0 -1
  81. package/dist/cjs/event.js +0 -34
  82. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +0 -4
  83. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +0 -1
  84. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +0 -72
  85. package/dist/cjs/index.d.ts +0 -15
  86. package/dist/cjs/index.d.ts.map +0 -1
  87. package/dist/cjs/index.js +0 -54
  88. package/dist/cjs/logger/index.d.ts +0 -179
  89. package/dist/cjs/logger/index.d.ts.map +0 -1
  90. package/dist/cjs/logger/index.js +0 -185
  91. package/dist/cjs/package.json +0 -1
  92. package/dist/cjs/runtime.d.ts +0 -42
  93. package/dist/cjs/runtime.d.ts.map +0 -1
  94. package/dist/cjs/runtime.js +0 -191
  95. package/dist/cjs/transforms.d.ts +0 -36
  96. package/dist/cjs/transforms.d.ts.map +0 -1
  97. package/dist/cjs/transforms.js +0 -176
  98. package/dist/cjs/types.d.ts +0 -25
  99. package/dist/cjs/types.d.ts.map +0 -1
  100. package/dist/cjs/types.js +0 -16
  101. package/dist/cjs/validations/errors.d.ts +0 -101
  102. package/dist/cjs/validations/errors.d.ts.map +0 -1
  103. package/dist/cjs/validations/errors.js +0 -298
  104. package/dist/cjs/validations/validations.d.ts +0 -235
  105. package/dist/cjs/validations/validations.d.ts.map +0 -1
  106. package/dist/cjs/validations/validations.js +0 -353
  107. package/dist/cjs/webhooks/index.d.ts +0 -77
  108. package/dist/cjs/webhooks/index.d.ts.map +0 -1
  109. package/dist/cjs/webhooks/index.js +0 -102
package/dist/cjs/index.js DELETED
@@ -1,54 +0,0 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var index_exports = {};
21
- __export(index_exports, {
22
- cedarVersion: () => cedarVersion,
23
- cedarjsVersion: () => cedarjsVersion,
24
- prismaVersion: () => prismaVersion,
25
- redwoodVersion: () => redwoodVersion
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
- __reExport(index_exports, require("./auth/index.js"), module.exports);
29
- __reExport(index_exports, require("./errors.js"), module.exports);
30
- __reExport(index_exports, require("./validations/validations.js"), module.exports);
31
- __reExport(index_exports, require("./validations/errors.js"), module.exports);
32
- __reExport(index_exports, require("./types.js"), module.exports);
33
- __reExport(index_exports, require("./transforms.js"), module.exports);
34
- __reExport(index_exports, require("./cors.js"), module.exports);
35
- __reExport(index_exports, require("./event.js"), module.exports);
36
- const prismaVersion = "7.8.0";
37
- const redwoodVersion = "6.0.0-canary.2788";
38
- const cedarjsVersion = "6.0.0-canary.2788";
39
- const cedarVersion = "6.0.0-canary.2788";
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- cedarVersion,
43
- cedarjsVersion,
44
- prismaVersion,
45
- redwoodVersion,
46
- ...require("./auth/index.js"),
47
- ...require("./errors.js"),
48
- ...require("./validations/validations.js"),
49
- ...require("./validations/errors.js"),
50
- ...require("./types.js"),
51
- ...require("./transforms.js"),
52
- ...require("./cors.js"),
53
- ...require("./event.js")
54
- });
@@ -1,179 +0,0 @@
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
@@ -1 +0,0 @@
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,GAAI,uCAI1B,oBAAoB,KAAG,MAuCzB,CAAA;AAQD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,EAA8B,CAAA;AAErE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc,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,GAAI,QAAQ,mBAAmB,KAAG,IA8CjE,CAAA"}
@@ -1,185 +0,0 @@
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 logger_exports = {};
20
- __export(logger_exports, {
21
- createLogger: () => createLogger,
22
- defaultLogLevels: () => defaultLogLevels,
23
- defaultLoggerOptions: () => defaultLoggerOptions,
24
- emitLogLevels: () => emitLogLevels,
25
- handlePrismaLogging: () => handlePrismaLogging,
26
- isDevelopment: () => isDevelopment,
27
- isProduction: () => isProduction,
28
- isTest: () => isTest,
29
- logLevel: () => logLevel,
30
- redactionsList: () => redactionsList
31
- });
32
- module.exports = __toCommonJS(logger_exports);
33
- var import_pino = require("pino");
34
- const isDevelopment = process.env.NODE_ENV === "development";
35
- const isTest = process.env.NODE_ENV === "test";
36
- const isProduction = !isDevelopment && !isTest;
37
- const redactionsList = [
38
- "access_token",
39
- "data.access_token",
40
- "data.*.access_token",
41
- "data.*.accessToken",
42
- "accessToken",
43
- "data.accessToken",
44
- "DATABASE_URL",
45
- "data.*.email",
46
- "data.email",
47
- "email",
48
- "event.headers.authorization",
49
- "data.hashedPassword",
50
- "data.*.hashedPassword",
51
- "hashedPassword",
52
- "host",
53
- "jwt",
54
- "data.jwt",
55
- "data.*.jwt",
56
- "JWT",
57
- "data.JWT",
58
- "data.*.JWT",
59
- "password",
60
- "data.password",
61
- "data.*.password",
62
- "params",
63
- "data.salt",
64
- "data.*.salt",
65
- "salt",
66
- "secret",
67
- "data.secret",
68
- "data.*.secret"
69
- ];
70
- const logLevel = (() => {
71
- if (typeof process.env.LOG_LEVEL !== "undefined") {
72
- return process.env.LOG_LEVEL;
73
- } else if (isProduction) {
74
- return "warn";
75
- } else if (isTest) {
76
- return "silent";
77
- } else {
78
- return "trace";
79
- }
80
- })();
81
- const defaultLoggerOptions = {
82
- level: logLevel,
83
- redact: redactionsList
84
- };
85
- const createLogger = ({
86
- options,
87
- destination,
88
- showConfig = false
89
- }) => {
90
- const hasDestination = typeof destination !== "undefined";
91
- const isFile = hasDestination && typeof destination === "string";
92
- const isStream = hasDestination && !isFile;
93
- const stream = destination;
94
- options = { ...defaultLoggerOptions, ...options };
95
- if (showConfig) {
96
- console.log("Logger Configuration");
97
- console.log(`isProduction: ${isProduction}`);
98
- console.log(`isDevelopment: ${isDevelopment}`);
99
- console.log(`isTest: ${isTest}`);
100
- console.log(`isFile: ${isFile}`);
101
- console.log(`isStream: ${isStream}`);
102
- console.log(`logLevel: ${logLevel}`);
103
- console.log(`options: ${JSON.stringify(options, null, 2)}`);
104
- console.log(`destination: ${destination}`);
105
- }
106
- if (isFile) {
107
- if (isProduction) {
108
- console.warn(
109
- "Please make certain that file system access is available when logging to a file in a production environment."
110
- );
111
- }
112
- return (0, import_pino.pino)(options, stream);
113
- } else {
114
- if (isStream && isDevelopment && !isTest) {
115
- console.warn(
116
- "Logs will be sent to the transport stream in the current development environment."
117
- );
118
- }
119
- return (0, import_pino.pino)(options, stream);
120
- }
121
- };
122
- const DEFAULT_SLOW_QUERY_THRESHOLD = 2e3;
123
- const defaultLogLevels = ["info", "warn", "error"];
124
- const emitLogLevels = (setLogLevels) => {
125
- return setLogLevels?.map((level) => {
126
- return { emit: "event", level };
127
- });
128
- };
129
- const handlePrismaLogging = (config) => {
130
- const logger = config.logger.child({
131
- // @TODO Change this once this issue is resolved
132
- // See https://github.com/prisma/prisma/issues/8290
133
- prisma: { clientVersion: config.db["_clientVersion"] }
134
- });
135
- const slowQueryThreshold = config.slowQueryThreshold ?? DEFAULT_SLOW_QUERY_THRESHOLD;
136
- config.logLevels?.forEach((level) => {
137
- if (level === "query") {
138
- config.db.$on(level, (event) => {
139
- const queryEvent = event;
140
- if (queryEvent.duration >= slowQueryThreshold) {
141
- logger.warn(
142
- { ...queryEvent },
143
- `Slow Query performed in ${queryEvent.duration} msec`
144
- );
145
- } else {
146
- logger.debug(
147
- { ...queryEvent },
148
- `Query performed in ${queryEvent.duration} msec`
149
- );
150
- }
151
- });
152
- } else {
153
- config.db.$on(level, (event) => {
154
- const logEvent = event;
155
- switch (level) {
156
- case "info":
157
- logger.info({ ...logEvent }, logEvent.message);
158
- break;
159
- case "warn":
160
- logger.warn({ ...logEvent }, logEvent.message);
161
- break;
162
- case "error":
163
- logger.error({ ...logEvent }, logEvent.message);
164
- break;
165
- default:
166
- logger.info({ ...logEvent }, logEvent.message);
167
- }
168
- });
169
- }
170
- });
171
- return;
172
- };
173
- // Annotate the CommonJS export names for ESM import in node:
174
- 0 && (module.exports = {
175
- createLogger,
176
- defaultLogLevels,
177
- defaultLoggerOptions,
178
- emitLogLevels,
179
- handlePrismaLogging,
180
- isDevelopment,
181
- isProduction,
182
- isTest,
183
- logLevel,
184
- redactionsList
185
- });
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,42 +0,0 @@
1
- import type { APIGatewayProxyEvent, APIGatewayProxyResult, Context as LambdaContext } from 'aws-lambda';
2
- import { getAuthenticationContext } from './auth/index.js';
3
- export interface CedarRequestContext {
4
- params: Record<string, string>;
5
- query: URLSearchParams;
6
- cookies: ReadonlyMap<string, string>;
7
- serverAuthState?: Awaited<ReturnType<typeof getAuthenticationContext>>;
8
- }
9
- export type CedarHandler = (request: Request, ctx: CedarRequestContext) => Promise<Response> | Response;
10
- export type CedarMiddleware = (request: Request, ctx: CedarRequestContext, next: () => Promise<Response>) => Promise<Response>;
11
- export interface CedarRouteRecord {
12
- /**
13
- * Unique identifier for this route, typically the URL path (e.g. `/graphql`).
14
- * Used to derive the UD `EntryMeta.id`.
15
- */
16
- id: string;
17
- path: string;
18
- methods: string[];
19
- type: 'graphql' | 'auth' | 'function' | 'health';
20
- entry: string;
21
- }
22
- export interface BuildCedarContextOptions {
23
- params?: Record<string, string>;
24
- authDecoder?: Parameters<typeof getAuthenticationContext>[0]['authDecoder'];
25
- lambdaContext?: LambdaContext;
26
- }
27
- export interface LegacyHandlerContext {
28
- event: APIGatewayProxyEvent;
29
- context: LambdaContext;
30
- request: Request;
31
- cedarContext: CedarRequestContext;
32
- }
33
- export type LegacyHandlerResult = APIGatewayProxyResult | Response;
34
- export type LegacyHandler = (event: APIGatewayProxyEvent, context: LambdaContext) => Promise<LegacyHandlerResult> | LegacyHandlerResult;
35
- export declare function buildCedarContext(request: Request, options?: BuildCedarContextOptions): Promise<CedarRequestContext>;
36
- export declare function composeCedarMiddleware(handler: CedarHandler, middleware: CedarMiddleware[]): CedarHandler;
37
- export declare function createRouteManifest(routes: CedarRouteRecord[]): CedarRouteRecord[];
38
- export declare function routeManifestToJSON(routes: CedarRouteRecord[]): string;
39
- export declare function wrapLegacyHandler(legacyHandler: LegacyHandler, options?: BuildCedarContextOptions): CedarHandler;
40
- export declare function requestToLegacyEvent(request: Request, ctx: CedarRequestContext): Promise<APIGatewayProxyEvent>;
41
- export declare function legacyResultToResponse(result: LegacyHandlerResult): Response;
42
- //# sourceMappingURL=runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG1D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,KAAK,EAAE,eAAe,CAAA;IACtB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAA;CACvE;AAED,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,KACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;AAEjC,MAAM,MAAM,eAAe,GAAG,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,KAC1B,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA;IAChD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;IAC3E,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,oBAAoB,CAAA;IAC3B,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,mBAAmB,CAAA;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG,QAAQ,CAAA;AAElE,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,aAAa,KACnB,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAA;AAyBvD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAwB9B;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,eAAe,EAAE,GAC5B,YAAY,CAMd;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAEtE;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAQd;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,CAsD5E"}
@@ -1,191 +0,0 @@
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var runtime_exports = {};
30
- __export(runtime_exports, {
31
- buildCedarContext: () => buildCedarContext,
32
- composeCedarMiddleware: () => composeCedarMiddleware,
33
- createRouteManifest: () => createRouteManifest,
34
- legacyResultToResponse: () => legacyResultToResponse,
35
- requestToLegacyEvent: () => requestToLegacyEvent,
36
- routeManifestToJSON: () => routeManifestToJSON,
37
- wrapLegacyHandler: () => wrapLegacyHandler
38
- });
39
- module.exports = __toCommonJS(runtime_exports);
40
- var cookie = __toESM(require("cookie"), 1);
41
- var import_picoquery = require("picoquery");
42
- var import_auth = require("./auth/index.js");
43
- var import_transforms = require("./transforms.js");
44
- const DEFAULT_LAMBDA_CONTEXT = {
45
- callbackWaitsForEmptyEventLoop: false,
46
- functionName: "cedar",
47
- functionVersion: "$LATEST",
48
- invokedFunctionArn: "cedar",
49
- memoryLimitInMB: "0",
50
- awsRequestId: "cedar-request",
51
- logGroupName: "cedar",
52
- logStreamName: "cedar",
53
- getRemainingTimeInMillis() {
54
- return 0;
55
- },
56
- done() {
57
- return void 0;
58
- },
59
- fail() {
60
- return void 0;
61
- },
62
- succeed() {
63
- return void 0;
64
- }
65
- };
66
- async function buildCedarContext(request, options = {}) {
67
- const url = new URL(request.url);
68
- const query = url.searchParams;
69
- const cookies = new Map(
70
- Object.entries(cookie.parse(request.headers.get("cookie") ?? "")).filter(
71
- (entry) => {
72
- return entry[1] !== void 0;
73
- }
74
- )
75
- );
76
- const params = options.params ?? {};
77
- const serverAuthState = await (0, import_auth.getAuthenticationContext)({
78
- authDecoder: options.authDecoder,
79
- event: request,
80
- context: options.lambdaContext
81
- });
82
- return {
83
- params,
84
- query,
85
- cookies,
86
- serverAuthState
87
- };
88
- }
89
- function composeCedarMiddleware(handler, middleware) {
90
- return middleware.reduceRight((next, current) => {
91
- return (request, ctx) => {
92
- return current(request, ctx, async () => next(request, ctx));
93
- };
94
- }, handler);
95
- }
96
- function createRouteManifest(routes) {
97
- return routes.map((route) => {
98
- return {
99
- ...route,
100
- methods: [...route.methods]
101
- };
102
- });
103
- }
104
- function routeManifestToJSON(routes) {
105
- return JSON.stringify(createRouteManifest(routes), null, 2);
106
- }
107
- function wrapLegacyHandler(legacyHandler, options = {}) {
108
- return async (request, ctx) => {
109
- const lambdaContext = options.lambdaContext ?? DEFAULT_LAMBDA_CONTEXT;
110
- const event = await requestToLegacyEvent(request, ctx);
111
- const result = await legacyHandler(event, lambdaContext);
112
- return legacyResultToResponse(result);
113
- };
114
- }
115
- async function requestToLegacyEvent(request, ctx) {
116
- const url = new URL(request.url);
117
- const base = await (0, import_transforms.requestToBaseEvent)(request);
118
- const queryStringParameters = (0, import_picoquery.parse)(url.search ? url.search.slice(1) : "", {
119
- nestingSyntax: "index",
120
- arrayRepeat: true,
121
- arrayRepeatSyntax: "bracket"
122
- });
123
- return {
124
- ...base,
125
- queryStringParameters,
126
- multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
127
- pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : base.pathParameters
128
- };
129
- }
130
- function legacyResultToResponse(result) {
131
- if (result instanceof Response) {
132
- return result;
133
- }
134
- const headers = new Headers();
135
- if (result.headers) {
136
- for (const [name, value] of Object.entries(result.headers)) {
137
- if (Array.isArray(value)) {
138
- for (const item of value) {
139
- headers.append(name, item);
140
- }
141
- } else if (value !== void 0) {
142
- headers.set(name, String(value));
143
- }
144
- }
145
- }
146
- if (result.multiValueHeaders) {
147
- for (const [name, values] of Object.entries(result.multiValueHeaders)) {
148
- if (!values) {
149
- continue;
150
- }
151
- for (const value of values) {
152
- headers.append(name, String(value));
153
- }
154
- }
155
- }
156
- const status = result.statusCode ?? 200;
157
- const isNoBodyStatus = status === 204 || status === 205 || status === 304;
158
- const body = isNoBodyStatus ? null : result.body ?? "";
159
- if (result.isBase64Encoded && !isNoBodyStatus) {
160
- return new Response(Buffer.from(body || "", "base64"), {
161
- status,
162
- headers
163
- });
164
- }
165
- return new Response(body, {
166
- status,
167
- headers
168
- });
169
- }
170
- function toMultiValueQueryStringParameters(url) {
171
- const values = /* @__PURE__ */ new Map();
172
- for (const [name, value] of url.searchParams.entries()) {
173
- const existing = values.get(name) ?? [];
174
- existing.push(value);
175
- values.set(name, existing);
176
- }
177
- if (values.size === 0) {
178
- return null;
179
- }
180
- return Object.fromEntries(values.entries());
181
- }
182
- // Annotate the CommonJS export names for ESM import in node:
183
- 0 && (module.exports = {
184
- buildCedarContext,
185
- composeCedarMiddleware,
186
- createRouteManifest,
187
- legacyResultToResponse,
188
- requestToLegacyEvent,
189
- routeManifestToJSON,
190
- wrapLegacyHandler
191
- });