@owlmeans/server-api 0.1.18-rc.8 → 0.1.18

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 (140) hide show
  1. package/README.md +203 -46
  2. package/agent-meta/manifest.json +3 -3
  3. package/agent-meta/skills/server-api/SKILL.md +142 -22
  4. package/build/consts.local.d.ts +2 -0
  5. package/build/consts.local.d.ts.map +1 -0
  6. package/build/consts.local.js +2 -0
  7. package/build/consts.local.js.map +1 -0
  8. package/build/errors.d.ts +12 -0
  9. package/build/errors.d.ts.map +1 -1
  10. package/build/errors.js +16 -0
  11. package/build/errors.js.map +1 -1
  12. package/build/helper.d.ts +3 -6
  13. package/build/helper.d.ts.map +1 -1
  14. package/build/helper.js +10 -1
  15. package/build/helper.js.map +1 -1
  16. package/build/hold.d.ts +35 -0
  17. package/build/hold.d.ts.map +1 -0
  18. package/build/hold.js +57 -0
  19. package/build/hold.js.map +1 -0
  20. package/build/index.d.ts +2 -0
  21. package/build/index.d.ts.map +1 -1
  22. package/build/index.js +2 -0
  23. package/build/index.js.map +1 -1
  24. package/build/protocol.d.ts +18 -0
  25. package/build/protocol.d.ts.map +1 -0
  26. package/build/protocol.js +87 -0
  27. package/build/protocol.js.map +1 -0
  28. package/build/server.d.ts +2 -3
  29. package/build/server.d.ts.map +1 -1
  30. package/build/server.js +42 -34
  31. package/build/server.js.map +1 -1
  32. package/build/types.d.ts +31 -2
  33. package/build/types.d.ts.map +1 -1
  34. package/build/types.local.d.ts +38 -0
  35. package/build/types.local.d.ts.map +1 -0
  36. package/build/types.local.js +2 -0
  37. package/build/types.local.js.map +1 -0
  38. package/build/utils/consts.d.ts +2 -0
  39. package/build/utils/consts.d.ts.map +1 -0
  40. package/build/utils/consts.js +2 -0
  41. package/build/utils/consts.js.map +1 -0
  42. package/build/utils/consts.local.d.ts +5 -0
  43. package/build/utils/consts.local.d.ts.map +1 -0
  44. package/build/utils/consts.local.js +5 -0
  45. package/build/utils/consts.local.js.map +1 -0
  46. package/build/utils/context/types.d.ts +13 -0
  47. package/build/utils/context/types.d.ts.map +1 -0
  48. package/build/utils/context/types.js +2 -0
  49. package/build/utils/context/types.js.map +1 -0
  50. package/build/utils/context.d.ts +3 -3
  51. package/build/utils/context.d.ts.map +1 -1
  52. package/build/utils/context.js +5 -2
  53. package/build/utils/context.js.map +1 -1
  54. package/build/utils/error/types.d.ts +52 -0
  55. package/build/utils/error/types.d.ts.map +1 -0
  56. package/build/utils/error/types.js +2 -0
  57. package/build/utils/error/types.js.map +1 -0
  58. package/build/utils/error.d.ts +5 -15
  59. package/build/utils/error.d.ts.map +1 -1
  60. package/build/utils/error.js +134 -29
  61. package/build/utils/error.js.map +1 -1
  62. package/build/utils/guards.d.ts +1 -5
  63. package/build/utils/guards.d.ts.map +1 -1
  64. package/build/utils/guards.js +15 -19
  65. package/build/utils/guards.js.map +1 -1
  66. package/build/utils/index.d.ts +6 -1
  67. package/build/utils/index.d.ts.map +1 -1
  68. package/build/utils/index.js +2 -1
  69. package/build/utils/index.js.map +1 -1
  70. package/build/utils/log/consts.d.ts +14 -0
  71. package/build/utils/log/consts.d.ts.map +1 -0
  72. package/build/utils/log/consts.js +17 -0
  73. package/build/utils/log/consts.js.map +1 -0
  74. package/build/utils/log/types.d.ts +42 -0
  75. package/build/utils/log/types.d.ts.map +1 -0
  76. package/build/utils/log/types.js +2 -0
  77. package/build/utils/log/types.js.map +1 -0
  78. package/build/utils/log.d.ts +4 -0
  79. package/build/utils/log.d.ts.map +1 -0
  80. package/build/utils/log.js +170 -0
  81. package/build/utils/log.js.map +1 -0
  82. package/build/utils/payload/types.d.ts +18 -0
  83. package/build/utils/payload/types.d.ts.map +1 -0
  84. package/build/utils/payload/types.js +2 -0
  85. package/build/utils/payload/types.js.map +1 -0
  86. package/build/utils/payload.d.ts +3 -15
  87. package/build/utils/payload.d.ts.map +1 -1
  88. package/build/utils/payload.js +41 -57
  89. package/build/utils/payload.js.map +1 -1
  90. package/build/utils/schema.d.ts +7 -0
  91. package/build/utils/schema.d.ts.map +1 -0
  92. package/build/utils/schema.js +20 -0
  93. package/build/utils/schema.js.map +1 -0
  94. package/build/utils/server.d.ts +3 -6
  95. package/build/utils/server.d.ts.map +1 -1
  96. package/build/utils/server.js +12 -13
  97. package/build/utils/server.js.map +1 -1
  98. package/build/utils/types.d.ts +18 -0
  99. package/build/utils/types.d.ts.map +1 -0
  100. package/build/utils/types.js +2 -0
  101. package/build/utils/types.js.map +1 -0
  102. package/build/utils/types.local.d.ts +9 -0
  103. package/build/utils/types.local.d.ts.map +1 -0
  104. package/build/utils/types.local.js +2 -0
  105. package/build/utils/types.local.js.map +1 -0
  106. package/package.json +23 -19
  107. package/src/consts.local.ts +1 -0
  108. package/src/errors.ts +18 -0
  109. package/src/helper.ts +13 -8
  110. package/src/hold.ts +66 -0
  111. package/src/index.ts +2 -0
  112. package/src/protocol.ts +149 -0
  113. package/src/server.ts +72 -69
  114. package/src/types.local.ts +44 -0
  115. package/src/types.ts +38 -4
  116. package/src/utils/consts.local.ts +7 -0
  117. package/src/utils/consts.ts +1 -0
  118. package/src/utils/context/types.ts +13 -0
  119. package/src/utils/context.ts +9 -4
  120. package/src/utils/error/types.ts +52 -0
  121. package/src/utils/error.ts +156 -29
  122. package/src/utils/guards.ts +16 -26
  123. package/src/utils/index.ts +6 -1
  124. package/src/utils/log/consts.ts +18 -0
  125. package/src/utils/log/types.ts +43 -0
  126. package/src/utils/log.ts +193 -0
  127. package/src/utils/payload/types.ts +18 -0
  128. package/src/utils/payload.ts +42 -60
  129. package/src/utils/schema.ts +23 -0
  130. package/src/utils/server.ts +16 -21
  131. package/src/utils/types.local.ts +12 -0
  132. package/src/utils/types.ts +18 -0
  133. package/tests/error-status.spec.ts +349 -0
  134. package/tests/handlers.spec.ts +83 -0
  135. package/tests/json-body.spec.ts +72 -0
  136. package/tests/log-adapter.spec.ts +62 -0
  137. package/tests/log-redaction.spec.ts +181 -0
  138. package/tests/tsconfig.json +12 -0
  139. package/tsconfig.json +1 -0
  140. package/build/.gitkeep +0 -0
@@ -0,0 +1,170 @@
1
+ import { LogController } from 'fastify';
2
+ import { FORBIDDEN_ERROR, SERVER_ERROR, UNAUTHORIZED_ERROR } from '@owlmeans/api';
3
+ import { logger } from '@owlmeans/log';
4
+ import { QUERY_IN_TEXT, SAFE_DATA_DEPTH, UNSAFE_LOG_KEYS } from './log/consts.js';
5
+ const pathOf = (url) => url.split('?')[0];
6
+ const withoutQueries = (text) => text.replace(QUERY_IN_TEXT, '$1');
7
+ /** The error itself, or — when its message names a URL with a query — a copy without the query. */
8
+ const safeError = (error) => {
9
+ const message = withoutQueries(error.message);
10
+ if (message === error.message) {
11
+ return error;
12
+ }
13
+ const copy = Object.assign(Object.create(Object.getPrototypeOf(error)), error);
14
+ copy.message = message;
15
+ copy.stack = error.stack != null ? withoutQueries(error.stack) : undefined;
16
+ return copy;
17
+ };
18
+ const isPlain = (value) => {
19
+ const proto = Object.getPrototypeOf(value);
20
+ return proto === Object.prototype || proto === null;
21
+ };
22
+ const levelName = (log) => {
23
+ const order = ['debug', 'info', 'warn', 'error'];
24
+ return order.find(level => log.enabled(level)) ?? 'silent';
25
+ };
26
+ export const createFastifyLogUtils = () => {
27
+ const http = logger('http');
28
+ const requestOf = (request) => {
29
+ const { method, url } = (request ?? {});
30
+ return {
31
+ ...(typeof method === 'string' ? { method } : {}),
32
+ ...(typeof url === 'string' ? { path: pathOf(url) } : {}),
33
+ };
34
+ };
35
+ /** A class instance as a record may carry it: a request or reply by summary, anything else by name. */
36
+ const instanceOf = (value) => {
37
+ const shape = value;
38
+ if (typeof shape.method === 'string' && typeof shape.url === 'string') {
39
+ return requestOf(value);
40
+ }
41
+ if (typeof shape.statusCode === 'number') {
42
+ return { statusCode: shape.statusCode };
43
+ }
44
+ const name = value.constructor?.name ?? 'object';
45
+ if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
46
+ return `[${name} ${value.byteLength} bytes]`;
47
+ }
48
+ return `[${name}]`;
49
+ };
50
+ const safe = (value, depth, seen) => {
51
+ if (typeof value === 'string') {
52
+ return withoutQueries(value);
53
+ }
54
+ if (value instanceof Error) {
55
+ return safeError(value);
56
+ }
57
+ if (value == null || typeof value !== 'object' || value instanceof Date) {
58
+ return value;
59
+ }
60
+ if (seen.has(value)) {
61
+ return '[circular]';
62
+ }
63
+ if (!Array.isArray(value) && !isPlain(value)) {
64
+ return instanceOf(value);
65
+ }
66
+ if (depth >= SAFE_DATA_DEPTH) {
67
+ return '[…]';
68
+ }
69
+ seen.add(value);
70
+ if (Array.isArray(value)) {
71
+ return value.map(item => safe(item, depth + 1, seen));
72
+ }
73
+ const out = {};
74
+ for (const [key, item] of Object.entries(value)) {
75
+ // A count or a flag under such a key (`limits.files: 5`) says nothing a caller sent.
76
+ if (UNSAFE_LOG_KEYS.has(key) && typeof item !== 'number' && typeof item !== 'boolean') {
77
+ continue;
78
+ }
79
+ out[key] = key === 'url' && typeof item === 'string' ? pathOf(item) : safe(item, depth + 1, seen);
80
+ }
81
+ return out;
82
+ };
83
+ const safeData = (data) => safe(data, 0, new WeakSet());
84
+ const failure = (error, request, status, incidentId) => {
85
+ const where = { ...requestOf(request), status, ...(incidentId != null ? { incidentId } : {}) };
86
+ const safe = safeError(error);
87
+ if (status >= SERVER_ERROR) {
88
+ http.error('Request failed', { err: safe, ...where });
89
+ }
90
+ else if (status === FORBIDDEN_ERROR) {
91
+ http.warn('Access forbidden', { type: error.type, message: safe.message, ...where }, { event: 'access.forbidden' });
92
+ }
93
+ else if (status === UNAUTHORIZED_ERROR) {
94
+ http.debug('Authentication refused', { message: safe.message, ...where }, { event: 'auth.refused' });
95
+ }
96
+ else {
97
+ const code = error.code;
98
+ http.debug('Request refused', { ...(typeof code === 'string' ? { code } : {}), message: safe.message, ...where });
99
+ }
100
+ };
101
+ /**
102
+ * Fastify announces its listening address at info; the server writes `server.listening` itself.
103
+ * Its request lines no longer reach the adapter at all — `controller()` owns them.
104
+ */
105
+ const levelOf = (level, message) => level === 'info' && typeof message === 'string' && message.startsWith('Server listening at') ? 'debug' : level;
106
+ const fastifyLogger = (log = http, bindings) => {
107
+ const call = (requested) => (first, second) => {
108
+ const [object, message] = typeof first === 'string' || first instanceof Error
109
+ ? [undefined, first] : [first, second];
110
+ const level = levelOf(requested, message);
111
+ if (!log.enabled(level)) {
112
+ return;
113
+ }
114
+ const data = bindings != null && Object.keys(bindings).length > 0
115
+ ? { ...bindings, ...(object != null && typeof object === 'object' ? object : {}) } : object;
116
+ const text = message == null ? '' : message instanceof Error ? safeError(message) : withoutQueries(String(message));
117
+ log[level](text, safeData(data));
118
+ };
119
+ const adapter = {
120
+ get level() { return levelName(log); },
121
+ set level(_value) { },
122
+ fatal: call('error'), error: call('error'), warn: call('warn'),
123
+ info: call('info'), debug: call('debug'), trace: call('debug'),
124
+ silent: () => undefined,
125
+ // Fastify's second argument (pino options: its own `req`/`res` serializers) is ignored —
126
+ // `safeData` is this adapter's serializer.
127
+ child: (extra) => fastifyLogger(log, { ...bindings, ...extra }),
128
+ };
129
+ return adapter;
130
+ };
131
+ /**
132
+ * Fastify accepts a `logController` only as an instance of its own class, so this one member is a
133
+ * subclass; its methods use no `this`.
134
+ */
135
+ const controller = () => {
136
+ class SafeLogController extends LogController {
137
+ incomingRequest() { }
138
+ requestCompleted(error, request, reply) {
139
+ if (error != null) {
140
+ http.error('Response failed', { err: error, ...requestOf(request), status: reply.statusCode });
141
+ }
142
+ }
143
+ defaultErrorLog(error, request, reply) {
144
+ failure(error, request, reply.statusCode);
145
+ }
146
+ streamError(error, request, reply) {
147
+ const where = { ...requestOf(request), status: reply.statusCode };
148
+ if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
149
+ http.debug('Response stream closed prematurely', where);
150
+ }
151
+ else {
152
+ http.warn('Response stream failed after its headers were sent', { err: error, ...where });
153
+ }
154
+ }
155
+ routeNotFound(request) {
156
+ http.debug('Route not found', requestOf(request));
157
+ }
158
+ writeHeadError(error, request, reply) {
159
+ http.warn('Response headers not written', { err: error, ...requestOf(request), status: reply.statusCode });
160
+ }
161
+ serializerError(error, request, _reply, metadata) {
162
+ http.error('Response serializer failed', { err: error, ...requestOf(request), status: metadata.statusCode });
163
+ }
164
+ }
165
+ return new SafeLogController();
166
+ };
167
+ return { logger: fastifyLogger, controller, safeData, requestOf, failure };
168
+ };
169
+ export const fastifyLogUtils = createFastifyLogUtils();
170
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,MAAM,EAA8B,MAAM,eAAe,CAAA;AAElE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGjF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAEzD,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;AAElF,mGAAmG;AACnG,MAAM,SAAS,GAAG,CAAC,KAAY,EAAS,EAAE;IACxC,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7C,IAAI,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,IAAI,GAAU,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAW,CAAU,EAAE,KAAK,CAAC,CAAA;IACxG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC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1,18 @@
1
+ import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint';
2
+ import type { Request, Response } from '../../types.js';
3
+ /** Moves an exchange between Fastify and the entrypoint shapes: the request in, the response out. */
4
+ export interface PayloadHelper {
5
+ /** The entrypoint request of a Fastify request; `provision` keeps the original on it. */
6
+ provideRequest: (alias: string, req: Request, provision?: boolean) => AbstractRequest;
7
+ /**
8
+ * Emits the response onto the fastify reply if the handler produced an
9
+ * error or an outcome. Returns `true` when something was actually sent so
10
+ * callers don't rely on `reply.sent`, which in fastify v5 only flips once
11
+ * the raw socket finishes writing (asynchronously) and therefore reads
12
+ * `false` synchronously right after `reply.send()`.
13
+ *
14
+ * @throws {Error}
15
+ */
16
+ executeResponse: <T>(response: AbstractResponse<T>, reply: Response, throwOnError?: boolean) => boolean;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/payload/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEvD,qGAAqG;AACrG,MAAM,WAAW,aAAa;IAC5B,yFAAyF;IACzF,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,eAAe,CAAA;IACrF;;;;;;;;OAQG;IACH,eAAe,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;CACxG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/payload/types.ts"],"names":[],"mappings":""}
@@ -1,16 +1,4 @@
1
- import type { AbstractResponse, AbstractRequest } from '@owlmeans/entrypoint';
2
- import type { Request, Response } from '../types.js';
3
- import type { AnySchemaObject } from 'ajv';
4
- export declare const provideRequest: (alias: string, req: Request, provision?: boolean) => AbstractRequest;
5
- /**
6
- * Emits the response onto the fastify reply if the handler produced an
7
- * error or an outcome. Returns `true` when something was actually sent so
8
- * callers don't rely on `reply.sent`, which in fastify v5 only flips once
9
- * the raw socket finishes writing (asynchronously) and therefore reads
10
- * `false` synchronously right after `reply.send()`.
11
- *
12
- * @throws {Error}
13
- */
14
- export declare const executeResponse: <T>(response: AbstractResponse<T>, reply: Response, throwOnError?: boolean) => boolean;
15
- export declare const fixFormatDates: (schema: AnySchemaObject) => AnySchemaObject;
1
+ import type { PayloadHelper } from './payload/types.js';
2
+ export declare const createPayloadHelper: () => PayloadHelper;
3
+ export declare const payloadHelper: PayloadHelper;
16
4
  //# sourceMappingURL=payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/utils/payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AAE1C,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,KAAK,OAAO,EAAE,YAAY,OAAO,KAAG,eAYjF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,UAAU,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,QAAQ,EAAE,eAAe,OAAO,KAAG,OAuB3G,CAAA;AAGD,eAAO,MAAM,cAAc,GAAI,QAAQ,eAAe,oBAgBrD,CAAA"}
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/utils/payload.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,eAAO,MAAM,mBAAmB,QAAO,aA4CtC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA"}
@@ -1,64 +1,48 @@
1
1
  import { EntrypointOutcome } from '@owlmeans/entrypoint';
2
- import { ACCEPTED, CREATED, OK, SERVER_ERROR } from '@owlmeans/api';
3
- export const provideRequest = (alias, req, provision) => {
4
- provision = provision ?? false;
5
- return {
6
- alias,
7
- auth: req._auth ?? undefined,
8
- params: req.params,
9
- body: req.body,
10
- headers: req.headers,
11
- query: req.query,
12
- path: req.url,
13
- original: provision ? req : undefined
2
+ import { ACCEPTED, CREATED, OK } from '@owlmeans/api';
3
+ import { httpErrorHelper } from './error.js';
4
+ export const createPayloadHelper = () => {
5
+ const provideRequest = (alias, req, provision) => {
6
+ provision = provision ?? false;
7
+ return {
8
+ alias,
9
+ auth: req._auth ?? undefined,
10
+ // Resolved once by `authorize` and carried by reference, exactly like `_auth`, so a handler
11
+ // reached through any path sees the same entity the guard admitted.
12
+ entity: req._entity ?? undefined,
13
+ params: req.params,
14
+ body: req.body,
15
+ headers: req.headers,
16
+ query: req.query,
17
+ path: req.url,
18
+ original: provision ? req : undefined
19
+ };
14
20
  };
15
- };
16
- /**
17
- * Emits the response onto the fastify reply if the handler produced an
18
- * error or an outcome. Returns `true` when something was actually sent so
19
- * callers don't rely on `reply.sent`, which in fastify v5 only flips once
20
- * the raw socket finishes writing (asynchronously) and therefore reads
21
- * `false` synchronously right after `reply.send()`.
22
- *
23
- * @throws {Error}
24
- */
25
- export const executeResponse = (response, reply, throwOnError) => {
26
- if (response.error != null) {
27
- if (throwOnError ?? false) {
28
- throw response.error;
29
- }
30
- reply.code(SERVER_ERROR).send(response.error.message);
31
- return true;
32
- }
33
- else if (response.outcome != null) {
34
- switch (response.outcome) {
35
- case EntrypointOutcome.Accepted:
36
- reply.code(ACCEPTED).send(response.value);
37
- break;
38
- case EntrypointOutcome.Created:
39
- reply.code(CREATED).send(response.value);
40
- break;
41
- case EntrypointOutcome.Ok:
42
- default:
43
- reply.code(OK).send(response.value);
44
- }
45
- return true;
46
- }
47
- return false;
48
- };
49
- export const fixFormatDates = (schema) => {
50
- if (schema.type === 'object') {
51
- if (schema.format === 'date-time') {
52
- schema.type = 'string';
53
- schema.format = 'date-time';
54
- if (schema.required != null) {
55
- delete schema.required;
21
+ const executeResponse = (response, reply, throwOnError) => {
22
+ if (response.error != null) {
23
+ if (throwOnError ?? false) {
24
+ throw response.error;
56
25
  }
26
+ httpErrorHelper.handleError(response.error, reply);
27
+ return true;
57
28
  }
58
- else if (schema.properties != null) {
59
- schema.properties = Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => [key, fixFormatDates(value)]));
29
+ else if (response.outcome != null) {
30
+ switch (response.outcome) {
31
+ case EntrypointOutcome.Accepted:
32
+ reply.code(ACCEPTED).send(response.value);
33
+ break;
34
+ case EntrypointOutcome.Created:
35
+ reply.code(CREATED).send(response.value);
36
+ break;
37
+ case EntrypointOutcome.Ok:
38
+ default:
39
+ reply.code(OK).send(response.value);
40
+ }
41
+ return true;
60
42
  }
61
- }
62
- return schema;
43
+ return false;
44
+ };
45
+ return { provideRequest, executeResponse };
63
46
  };
47
+ export const payloadHelper = createPayloadHelper();
64
48
  //# sourceMappingURL=payload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payload.js","sourceRoot":"","sources":["../../src/utils/payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGxD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,GAAY,EAAE,SAAmB,EAAmB,EAAE;IAClG,SAAS,GAAG,SAAS,IAA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CAAC;gBAC1B;oBACE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YACvC,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAA;AAC5C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { AnySchemaObject } from 'ajv';
2
+ /**
3
+ * A request schema Fastify can serve: a `date-time` object becomes a `date-time` string (and loses
4
+ * its `required` list), recursively through object properties. Mutates and returns `schema`.
5
+ */
6
+ export declare const fixFormatDates: (schema: AnySchemaObject) => AnySchemaObject;
7
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,cAAc,WAAY,eAAe,KAAG,eAgBxD,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A request schema Fastify can serve: a `date-time` object becomes a `date-time` string (and loses
3
+ * its `required` list), recursively through object properties. Mutates and returns `schema`.
4
+ */
5
+ export const fixFormatDates = (schema) => {
6
+ if (schema.type === 'object') {
7
+ if (schema.format === 'date-time') {
8
+ schema.type = 'string';
9
+ schema.format = 'date-time';
10
+ if (schema.required != null) {
11
+ delete schema.required;
12
+ }
13
+ }
14
+ else if (schema.properties != null) {
15
+ schema.properties = Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => [key, fixFormatDates(value)]));
16
+ }
17
+ }
18
+ return schema;
19
+ };
20
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAmB,EAAE;IACzE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAA;YACtB,MAAM,CAAC,MAAM,GAAG,WAAW,CAAA;YAC3B,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;gBAC5B,OAAO,MAAM,CAAC,QAAQ,CAAA;YACxB,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YACrC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,KAAwB,CAAC,CAAC,CAAC,CACzG,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
@@ -1,10 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from 'fastify';
2
2
  import type { ServerEntrypoint } from '@owlmeans/server-entrypoint';
3
- import type { CommonEntrypoint } from '@owlmeans/entrypoint';
4
- import type { ServerContext, ServerConfig } from '@owlmeans/server-context';
5
- type Config = ServerConfig;
6
- type Context = ServerContext<Config>;
7
- export declare const canServeModule: (context: Context, module: CommonEntrypoint) => module is ServerEntrypoint<unknown>;
3
+ import { type CommonEntrypoint } from '@owlmeans/entrypoint';
4
+ import type { ServerContext2 } from './types.local.js';
5
+ export declare const canServeModule: (context: ServerContext2, module: CommonEntrypoint) => module is ServerEntrypoint<unknown>;
8
6
  export declare const createServerHandler: (module: ServerEntrypoint<FastifyRequest>, location: string) => (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
9
- export {};
10
7
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/utils/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,KAAK,EAAgB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAG5D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAQ3E,KAAK,MAAM,GAAG,YAAY,CAAA;AAC1B,KAAK,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;AAEpC,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,EAAE,QAAQ,gBAAgB,KAAG,MAAM,IAAI,gBAAgB,CAAC,OAAO,CAY7G,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,QAAQ,gBAAgB,CAAC,cAAc,CAAC,EAAE,UAAU,MAAM,MACrF,KAAK,cAAc,EAAE,OAAO,YAAY,kBA0C9C,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/utils/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAgB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACjF,OAAO,EAAE,KAAK,gBAAgB,EAAqC,MAAM,sBAAsB,CAAA;AAQ/F,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGrE,eAAO,MAAM,cAAc,YAAa,cAAc,UAAU,gBAAgB,KAAG,MAAM,IAAI,gBAAgB,CAAC,OAAO,CAcpH,CAAA;AAED,eAAO,MAAM,mBAAmB,WAAY,gBAAgB,CAAC,cAAc,CAAC,YAAY,MAAM,WAChF,cAAc,SAAS,YAAY,kBAuC9C,CAAA"}
@@ -1,10 +1,10 @@
1
- import { AppType } from '@owlmeans/context';
2
- import { assertContext } from '@owlmeans/context';
1
+ import { AppType, assertContext } from '@owlmeans/context';
3
2
  import { provideResponse } from '@owlmeans/entrypoint';
4
3
  import { ResilientError } from '@owlmeans/error';
5
4
  import { OK } from '@owlmeans/api';
6
- import { handleError } from './error.js';
7
- import { executeResponse, provideRequest } from './payload.js';
5
+ import { logger } from '@owlmeans/log';
6
+ import { httpErrorHelper } from './error.js';
7
+ import { payloadHelper } from './payload.js';
8
8
  import { authorize } from './guards.js';
9
9
  import { RouteProtocols } from '@owlmeans/route';
10
10
  export const canServeModule = (context, module) => {
@@ -14,7 +14,9 @@ export const canServeModule = (context, module) => {
14
14
  if (module.route.route.service != null && module.route.route.service !== context.cfg.service) {
15
15
  return false;
16
16
  }
17
- if (module.route.route.protocol === RouteProtocols.SOCKET) {
17
+ // HTTP serves only its own protocol. Custom transports are handled by their owning packages.
18
+ if (module.route.route.protocol != null
19
+ && module.route.route.protocol !== RouteProtocols.WEB) {
18
20
  return false;
19
21
  }
20
22
  return 'isIntermediate' in module.route;
@@ -27,12 +29,12 @@ export const createServerHandler = (module, location) => async (req, reply) => {
27
29
  context = authorized[0];
28
30
  module = authorized[1];
29
31
  const response = provideResponse(reply);
30
- const request = provideRequest(module.alias, req, true);
32
+ const request = payloadHelper.provideRequest(module.alias, req, true);
31
33
  const gates = module.getGates();
32
34
  for (const [srv, params] of gates) {
33
35
  const gate = context.service(srv);
34
36
  await gate.assert(request, response, params);
35
- executeResponse(response, reply, true);
37
+ payloadHelper.executeResponse(response, reply, true);
36
38
  }
37
39
  await module.handle(request, response);
38
40
  // Don't rely on `reply.sent` here: in fastify v5 it is backed by
@@ -41,22 +43,19 @@ export const createServerHandler = (module, location) => async (req, reply) => {
41
43
  // synchronously right after `reply.send()`. Track the emitted state
42
44
  // explicitly instead, and only fall back to a default response when
43
45
  // neither `executeResponse` nor the handler itself (hijack) replied.
44
- const responded = executeResponse(response, reply, true);
46
+ const responded = payloadHelper.executeResponse(response, reply, true);
45
47
  if (!responded && !reply.sent) {
46
- console.warn(`SENDS DEFAULT RESPONSE: ${module.alias}`);
48
+ logger('http').warn(`SENDS DEFAULT RESPONSE: ${module.alias}`);
47
49
  reply.code(OK).send(response.value);
48
50
  }
49
51
  }
50
52
  catch (error) {
51
- console.error(`Error in ${module.alias} (${location})`);
52
- console.error(JSON.stringify(error, null, 2));
53
- console.error(error);
54
53
  if (module.fixer != null) {
55
54
  const fixer = context.service(module.fixer);
56
55
  fixer.handle(reply, ResilientError.ensure(error));
57
56
  return;
58
57
  }
59
- handleError(error, reply);
58
+ httpErrorHelper.handleError(error, reply, httpErrorHelper.errorExposure(context.cfg));
60
59
  }
61
60
  };
62
61
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/utils/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAIjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAKhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,MAAwB,EAAuC,EAAE;IAChH,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,K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AE,CAAC;YAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;YAC9D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,KAAK,GAAiB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACzD,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,KAAc,CAAC,CAAC,CAAA;YAC1D,OAAM;QACR,CAAC;QACD,eAAe,CAAC,WAAW,CAAC,KAAc,EAAE,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IAChG,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What an error class may declare about the HTTP status it is answered with.
3
+ *
4
+ * Structural on purpose: the classes that declare it live in packages that must not depend on an
5
+ * HTTP server (`@owlmeans/payment`, a product's contract package), so they write a plain
6
+ * `public static httpStatus = 409` and nothing imports this type.
7
+ */
8
+ export interface HttpStatusDeclaration {
9
+ httpStatus?: unknown;
10
+ /** Explicit opt-in for a declared 5xx response. Client-error declarations need no opt-in. */
11
+ allowServerErrorStatus?: unknown;
12
+ }
13
+ export interface SerializedHttpError {
14
+ status: number;
15
+ body: string;
16
+ incidentId: string;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { ServerConfig, ServerContext } from '@owlmeans/server-context';
2
+ import type { Config as ApiConfig } from '../types.js';
3
+ export type Config = ServerConfig;
4
+ export interface Context<C extends Config = Config> extends ServerContext<C> {
5
+ }
6
+ export type Severity = 'debug' | 'info' | 'warn' | 'error';
7
+ export type ServerConfig2 = ApiConfig;
8
+ export type ServerContext2 = ServerContext<ServerConfig2>;
9
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../../src/utils/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,MAAM,GAAG,YAAY,CAAA;AAEjC,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAI;AAEhF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE1D,MAAM,MAAM,aAAa,GAAG,SAAS,CAAA;AAErC,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../../src/utils/types.local.ts"],"names":[],"mappings":""}