@owlmeans/server-api 0.1.18-rc.50 → 0.1.18-rc.52

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 (55) hide show
  1. package/README.md +20 -19
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/server-api/SKILL.md +9 -9
  4. package/build/server.js +3 -3
  5. package/build/server.js.map +1 -1
  6. package/build/utils/context/types.d.ts +13 -0
  7. package/build/utils/context/types.d.ts.map +1 -0
  8. package/build/utils/context/types.js +2 -0
  9. package/build/utils/context/types.js.map +1 -0
  10. package/build/utils/context.d.ts +3 -3
  11. package/build/utils/context.d.ts.map +1 -1
  12. package/build/utils/context.js +5 -2
  13. package/build/utils/context.js.map +1 -1
  14. package/build/utils/error/types.d.ts +52 -0
  15. package/build/utils/error/types.d.ts.map +1 -0
  16. package/build/utils/error/types.js +2 -0
  17. package/build/utils/error/types.js.map +1 -0
  18. package/build/utils/error.d.ts +4 -47
  19. package/build/utils/error.d.ts.map +1 -1
  20. package/build/utils/error.js +154 -187
  21. package/build/utils/error.js.map +1 -1
  22. package/build/utils/guards.d.ts.map +1 -1
  23. package/build/utils/guards.js +6 -6
  24. package/build/utils/guards.js.map +1 -1
  25. package/build/utils/index.d.ts +4 -1
  26. package/build/utils/index.d.ts.map +1 -1
  27. package/build/utils/index.js +1 -1
  28. package/build/utils/index.js.map +1 -1
  29. package/build/utils/payload/types.d.ts +18 -0
  30. package/build/utils/payload/types.d.ts.map +1 -0
  31. package/build/utils/payload/types.js +2 -0
  32. package/build/utils/payload/types.js.map +1 -0
  33. package/build/utils/payload.d.ts +3 -15
  34. package/build/utils/payload.d.ts.map +1 -1
  35. package/build/utils/payload.js +40 -60
  36. package/build/utils/payload.js.map +1 -1
  37. package/build/utils/schema.d.ts +7 -0
  38. package/build/utils/schema.d.ts.map +1 -0
  39. package/build/utils/schema.js +20 -0
  40. package/build/utils/schema.js.map +1 -0
  41. package/build/utils/server.js +6 -6
  42. package/build/utils/server.js.map +1 -1
  43. package/package.json +12 -12
  44. package/src/server.ts +3 -3
  45. package/src/utils/context/types.ts +13 -0
  46. package/src/utils/context.ts +9 -4
  47. package/src/utils/error/types.ts +52 -0
  48. package/src/utils/error.ts +156 -186
  49. package/src/utils/guards.ts +6 -6
  50. package/src/utils/index.ts +4 -1
  51. package/src/utils/payload/types.ts +18 -0
  52. package/src/utils/payload.ts +41 -63
  53. package/src/utils/schema.ts +23 -0
  54. package/src/utils/server.ts +6 -6
  55. package/tests/error-status.spec.ts +11 -11
@@ -6,194 +6,161 @@ import { randomUUID } from 'node:crypto';
6
6
  import { logger } from '@owlmeans/log';
7
7
  import { CLIENT_ERROR_FIRST, CLIENT_ERROR_LAST, SERVER_ERROR_FIRST, SERVER_ERROR_LAST } from './consts.local.js';
8
8
  import { INCIDENT_ID_HEADER } from './consts.js';
9
- /**
10
- * The HTTP status an error's class declares, or `null` when it declares none that may be honoured.
11
- *
12
- * Read through the constructor chain — a static property is inherited, so a subclass answers what
13
- * its nearest declaring ancestor says, and redeclares to change it. An integer 4xx is honoured
14
- * directly. A 5xx is honoured only with `allowServerErrorStatus = true`, so a domain class must
15
- * explicitly opt in to exposing a precise availability response. The read is structural, so a
16
- * class from a duplicate module copy declares exactly what the imported one does.
17
- */
18
- export const declaredErrorStatus = (error) => {
19
- if (error == null || typeof error !== 'object') {
20
- return null;
21
- }
22
- const declaration = error.constructor;
23
- const status = declaration?.httpStatus;
24
- if (typeof status !== 'number' || !Number.isInteger(status)) {
9
+ export const createHttpErrorHelper = () => {
10
+ const declaredErrorStatus = (error) => {
11
+ if (error == null || typeof error !== 'object') {
12
+ return null;
13
+ }
14
+ const declaration = error.constructor;
15
+ const status = declaration?.httpStatus;
16
+ if (typeof status !== 'number' || !Number.isInteger(status)) {
17
+ return null;
18
+ }
19
+ if (status >= CLIENT_ERROR_FIRST && status <= CLIENT_ERROR_LAST)
20
+ return status;
21
+ if (status >= SERVER_ERROR_FIRST && status <= SERVER_ERROR_LAST
22
+ && declaration?.allowServerErrorStatus === true)
23
+ return status;
25
24
  return null;
26
- }
27
- if (status >= CLIENT_ERROR_FIRST && status <= CLIENT_ERROR_LAST)
28
- return status;
29
- if (status >= SERVER_ERROR_FIRST && status <= SERVER_ERROR_LAST
30
- && declaration?.allowServerErrorStatus === true)
31
- return status;
32
- return null;
33
- };
34
- /**
35
- * The registered type names an error carries: its own `type`, and the static `typeName` of every
36
- * class on its constructor chain.
37
- *
38
- * This is how a class is recognised when `instanceof` cannot see it. A process that loads a package
39
- * twice — `bun --preserve-symlinks` over a linked workspace resolves one package through several
40
- * `node_modules` paths — holds several copies of every error class, and an error built by one copy
41
- * is not an instance of another. The registered names are the same in every copy. A subclass's
42
- * `typeName` does not reliably embed its parent's (`EntitlementRefusal` extends `AuthForbidden`), so
43
- * a family is recognised by walking the chain and matching names exactly, never by a substring.
44
- */
45
- const typeNamesOf = (error) => {
46
- const names = new Set();
47
- const type = error.type;
48
- if (typeof type === 'string') {
49
- names.add(type);
50
- }
51
- let ctor = error.constructor;
52
- while (typeof ctor === 'function') {
53
- const name = ctor.typeName;
54
- if (typeof name === 'string') {
55
- names.add(name);
56
- }
57
- ctor = Object.getPrototypeOf(ctor);
58
- }
59
- return names;
60
- };
61
- const isOfFamily = (names, family) => family.some(typeName => names.has(typeName));
62
- /**
63
- * The HTTP status an error is answered with, read off the error exactly as given.
64
- *
65
- * Two families reach here and both must be recognised. `AuthFailedError` / `AccessError` are this
66
- * package's own, raised by the request pipeline itself. `AuthorizationError` / `AuthForbidden`
67
- * come from `@owlmeans/auth` and are what the guards and gates actually throw — an unrecognised
68
- * one answers 500, which reports a refused request as a crashed server: the client cannot tell
69
- * "sign in again" from "the service is broken", and a consumer watching statuses concludes the
70
- * application fell over. A family member is recognised by class OR by registered type name
71
- * ({@link typeNamesOf}), so a class from a duplicate module copy answers the same status.
72
- *
73
- * **Order matters.** `AuthForbidden extends AuthorizationError`, so the 403 branch has to be
74
- * tested first or every refusal of a permission is reported as a failure to authenticate. Both
75
- * auth branches come before a class's own declaration, so an auth refusal can never be restated
76
- * as something else. Everything that is neither an auth error nor a class declaring an allowed
77
- * {@link declaredErrorStatus} answers 500.
78
- */
79
- export const errorStatus = (error) => {
80
- if (error == null || typeof error !== 'object') {
81
- return SERVER_ERROR;
82
- }
83
- const names = typeNamesOf(error);
84
- if (error instanceof AuthForbidden || error instanceof AccessError
85
- || isOfFamily(names, [AuthForbidden.typeName, AccessError.typeName])) {
86
- // An established identity that lacks the permission. Re-authenticating changes nothing.
87
- return FORBIDDEN_ERROR;
88
- }
89
- if (error instanceof AuthorizationError || error instanceof AuthFailedError
90
- || isOfFamily(names, [AuthorizationError.typeName, AuthFailedError.typeName])) {
91
- // No usable credential — absent, expired, revoked, or naming a session this server no longer
92
- // holds. The caller is told to sign in, not that signing in would not help.
93
- return UNAUTHORIZED_ERROR;
94
- }
95
- return declaredErrorStatus(error) ?? SERVER_ERROR;
96
- };
97
- /** Invalid or absent configuration always resolves to the production-safe policy. */
98
- export const errorExposure = (config) => config?.http?.errors?.exposure === 'development' ? 'development' : 'production';
99
- /**
100
- * Preserve a typed/marshalled error when possible without asking `ensure` to convert a plain
101
- * error. In particular, `ensure` deliberately rethrows SyntaxError; an HTTP boundary still has
102
- * to serialize it safely and let the incident log retain the original object.
103
- */
104
- const normalizeForWire = (error) => {
105
- if (error instanceof SyntaxError || isResilientError(error)) {
25
+ };
26
+ /**
27
+ * The registered type names an error carries: its own `type`, and the static `typeName` of every
28
+ * class on its constructor chain.
29
+ *
30
+ * This is how a class is recognised when `instanceof` cannot see it. A process that loads a package
31
+ * twice — `bun --preserve-symlinks` over a linked workspace resolves one package through several
32
+ * `node_modules` paths — holds several copies of every error class, and an error built by one copy
33
+ * is not an instance of another. The registered names are the same in every copy. A subclass's
34
+ * `typeName` does not reliably embed its parent's (`EntitlementRefusal` extends `AuthForbidden`), so
35
+ * a family is recognised by walking the chain and matching names exactly, never by a substring.
36
+ */
37
+ const typeNamesOf = (error) => {
38
+ const names = new Set();
39
+ const type = error.type;
40
+ if (typeof type === 'string') {
41
+ names.add(type);
42
+ }
43
+ let ctor = error.constructor;
44
+ while (typeof ctor === 'function') {
45
+ const name = ctor.typeName;
46
+ if (typeof name === 'string') {
47
+ names.add(name);
48
+ }
49
+ ctor = Object.getPrototypeOf(ctor);
50
+ }
51
+ return names;
52
+ };
53
+ const isOfFamily = (names, family) => family.some(typeName => names.has(typeName));
54
+ const errorStatus = (error) => {
55
+ if (error == null || typeof error !== 'object') {
56
+ return SERVER_ERROR;
57
+ }
58
+ const names = typeNamesOf(error);
59
+ if (error instanceof AuthForbidden || error instanceof AccessError
60
+ || isOfFamily(names, [AuthForbidden.typeName, AccessError.typeName])) {
61
+ // An established identity that lacks the permission. Re-authenticating changes nothing.
62
+ return FORBIDDEN_ERROR;
63
+ }
64
+ if (error instanceof AuthorizationError || error instanceof AuthFailedError
65
+ || isOfFamily(names, [AuthorizationError.typeName, AuthFailedError.typeName])) {
66
+ // No usable credential — absent, expired, revoked, or naming a session this server no longer
67
+ // holds. The caller is told to sign in, not that signing in would not help.
68
+ return UNAUTHORIZED_ERROR;
69
+ }
70
+ return declaredErrorStatus(error) ?? SERVER_ERROR;
71
+ };
72
+ const errorExposure = (config) => config?.http?.errors?.exposure === 'development' ? 'development' : 'production';
73
+ /**
74
+ * Preserve a typed/marshalled error when possible without asking `ensure` to convert a plain
75
+ * error. In particular, `ensure` deliberately rethrows SyntaxError; an HTTP boundary still has
76
+ * to serialize it safely and let the incident log retain the original object.
77
+ */
78
+ const normalizeForWire = (error) => {
79
+ if (error instanceof SyntaxError || isResilientError(error)) {
80
+ return error;
81
+ }
82
+ if (error.message.includes(SEPARATOR)) {
83
+ const ensured = ResilientError.ensure(error);
84
+ // The catch-all converter's legacy constructor shape shifts an ordinary error's fields.
85
+ // Only keep `ensure`'s result when a registered wire prefix actually rebuilt something.
86
+ if (ensured.type !== error.message || ensured.message !== error.stack) {
87
+ return ensured;
88
+ }
89
+ }
106
90
  return error;
107
- }
108
- if (error.message.includes(SEPARATOR)) {
109
- const ensured = ResilientError.ensure(error);
110
- // The catch-all converter's legacy constructor shape shifts an ordinary error's fields.
111
- // Only keep `ensure`'s result when a registered wire prefix actually rebuilt something.
112
- if (ensured.type !== error.message || ensured.message !== error.stack) {
113
- return ensured;
114
- }
115
- }
116
- return error;
117
- };
118
- /** One central wire shape for every server error. */
119
- export const serializeError = (error, exposure = 'production') => {
120
- const normalized = normalizeForWire(error);
121
- const thrown = errorStatus(error);
122
- const status = thrown !== SERVER_ERROR ? thrown : errorStatus(normalized);
123
- const incidentId = randomUUID();
124
- // The server log owns every diagnostic. Production callers receive only its correlation key;
125
- // development keeps the typed wire form so local clients can retain their usual error details.
126
- Object.assign(error, { incidentId });
127
- if (isResilientError(normalized))
128
- normalized.incidentId = incidentId;
129
- const body = exposure === 'production'
130
- ? incidentId
131
- : ResilientError.marshal(normalized, { includeStack: true, incidentId }).message;
132
- return { status, body, incidentId };
133
- };
134
- /** Apply safe response metadata carried by an error without coupling its package to Fastify. */
135
- export const applyErrorHeaders = (error, reply) => {
136
- if (error == null || typeof error !== 'object') {
137
- return;
138
- }
139
- const retryAfter = error.retryAfter;
140
- if (typeof retryAfter === 'number' && Number.isFinite(retryAfter) && retryAfter > 0) {
141
- reply.header('Retry-After', String(Math.ceil(retryAfter)));
142
- }
143
- // Match exact registered types. EntitlementRefusal also extends AuthForbidden but is a plan
144
- // decision, not a person's IAM permission denial.
145
- const type = error.type;
146
- if (type === AuthForbidden.typeName || type === AccessError.typeName) {
147
- reply.header(DENIAL_KIND_HEADER, ACCESS_DENIED_KIND);
148
- }
149
- };
150
- const http = logger('http');
151
- /**
152
- * The one log entry of a failed request, by what the failure means:
153
- *
154
- * | Status | Level | Why |
155
- * |---|---|---|
156
- * | 5xx | error | a fault — the one entry that owns type, message and stack, keyed by the incident id |
157
- * | 403 | warn, `access.forbidden` | an established identity was refused; worth an operator's eye |
158
- * | 401 | debug, `auth.refused` | an absent or expired credential is the ordinary shape of a sign-in |
159
- * | other 4xx | debug | the caller's mistake, not the server's |
160
- *
161
- * The method and path are logged; the query string is not — it can carry a token.
162
- */
163
- const logFailure = (error, reply, status, incidentId) => {
164
- const request = reply.request;
165
- const where = { method: request?.method, path: request?.url?.split('?')[0], status, incidentId };
166
- if (status >= SERVER_ERROR) {
167
- http.error('Request failed', { err: error, ...where });
168
- }
169
- else if (status === FORBIDDEN_ERROR) {
170
- http.warn('Access forbidden', { type: error.type, message: error.message, ...where }, { event: 'access.forbidden' });
171
- }
172
- else if (status === UNAUTHORIZED_ERROR) {
173
- http.debug('Authentication refused', { message: error.message, ...where }, { event: 'auth.refused' });
174
- }
175
- else {
176
- http.debug('Request refused', { message: error.message, ...where });
177
- }
178
- };
179
- /**
180
- * Answer a thrown error: a status, and the marshalled `ResilientError` as the body.
181
- *
182
- * The status is resolved in two steps. The error AS THROWN comes first: it is the one object whose
183
- * class is certainly the class that was raised, while `ResilientError.ensure` rebuilds through the
184
- * registry of whichever `@owlmeans/error` copy this module loaded — under duplicate module copies
185
- * that turns a perfectly recognisable auth refusal into a plain `ResilientError` answering 500.
186
- * Only when the thrown error answers 500 is the ENSURED error asked, because the rebuild is what
187
- * gives a status to a marshalled error that crossed a hop as a plain `Error`.
188
- */
189
- export const handleError = (error, reply, exposure = 'production') => {
190
- if (!reply.sent) {
191
- const serialized = serializeError(error, exposure);
192
- applyErrorHeaders(error, reply);
193
- logFailure(error, reply, serialized.status, serialized.incidentId);
194
- reply.header(INCIDENT_ID_HEADER, serialized.incidentId)
195
- .code(serialized.status)
196
- .send(serialized.body);
197
- }
91
+ };
92
+ const serializeError = (error, exposure = 'production') => {
93
+ const normalized = normalizeForWire(error);
94
+ const thrown = errorStatus(error);
95
+ const status = thrown !== SERVER_ERROR ? thrown : errorStatus(normalized);
96
+ const incidentId = randomUUID();
97
+ // The server log owns every diagnostic. Production callers receive only its correlation key;
98
+ // development keeps the typed wire form so local clients can retain their usual error details.
99
+ Object.assign(error, { incidentId });
100
+ if (isResilientError(normalized))
101
+ normalized.incidentId = incidentId;
102
+ const body = exposure === 'production'
103
+ ? incidentId
104
+ : ResilientError.marshal(normalized, { includeStack: true, incidentId }).message;
105
+ return { status, body, incidentId };
106
+ };
107
+ const applyErrorHeaders = (error, reply) => {
108
+ if (error == null || typeof error !== 'object') {
109
+ return;
110
+ }
111
+ const retryAfter = error.retryAfter;
112
+ if (typeof retryAfter === 'number' && Number.isFinite(retryAfter) && retryAfter > 0) {
113
+ reply.header('Retry-After', String(Math.ceil(retryAfter)));
114
+ }
115
+ // Match exact registered types. EntitlementRefusal also extends AuthForbidden but is a plan
116
+ // decision, not a person's IAM permission denial.
117
+ const type = error.type;
118
+ if (type === AuthForbidden.typeName || type === AccessError.typeName) {
119
+ reply.header(DENIAL_KIND_HEADER, ACCESS_DENIED_KIND);
120
+ }
121
+ };
122
+ const http = logger('http');
123
+ /**
124
+ * The one log entry of a failed request, by what the failure means:
125
+ *
126
+ * | Status | Level | Why |
127
+ * |---|---|---|
128
+ * | 5xx | error | a fault — the one entry that owns type, message and stack, keyed by the incident id |
129
+ * | 403 | warn, `access.forbidden` | an established identity was refused; worth an operator's eye |
130
+ * | 401 | debug, `auth.refused` | an absent or expired credential is the ordinary shape of a sign-in |
131
+ * | other 4xx | debug | the caller's mistake, not the server's |
132
+ *
133
+ * The method and path are logged; the query string is not — it can carry a token.
134
+ */
135
+ const logFailure = (error, reply, status, incidentId) => {
136
+ const request = reply.request;
137
+ const where = { method: request?.method, path: request?.url?.split('?')[0], status, incidentId };
138
+ if (status >= SERVER_ERROR) {
139
+ http.error('Request failed', { err: error, ...where });
140
+ }
141
+ else if (status === FORBIDDEN_ERROR) {
142
+ http.warn('Access forbidden', { type: error.type, message: error.message, ...where }, { event: 'access.forbidden' });
143
+ }
144
+ else if (status === UNAUTHORIZED_ERROR) {
145
+ http.debug('Authentication refused', { message: error.message, ...where }, { event: 'auth.refused' });
146
+ }
147
+ else {
148
+ http.debug('Request refused', { message: error.message, ...where });
149
+ }
150
+ };
151
+ const handleError = (error, reply, exposure = 'production') => {
152
+ if (!reply.sent) {
153
+ const serialized = serializeError(error, exposure);
154
+ applyErrorHeaders(error, reply);
155
+ logFailure(error, reply, serialized.status, serialized.incidentId);
156
+ reply.header(INCIDENT_ID_HEADER, serialized.incidentId)
157
+ .code(serialized.status)
158
+ .send(serialized.body);
159
+ }
160
+ };
161
+ return { declaredErrorStatus, errorStatus, errorExposure, serializeError, applyErrorHeaders, handleError };
198
162
  };
163
+ export const httpErrorHelper = createHttpErrorHelper();
164
+ /** @deprecated compat:factory-refactor — use `httpErrorHelper.errorStatus(…)` */
165
+ export const errorStatus = (error) => httpErrorHelper.errorStatus(error);
199
166
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,GAC1F,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIhD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAiB,EAAE;IACnE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK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AM,SAAS,GAAU,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAC3D,CAAC,UAAU,gBAAgB,CAAC,cAAc,CAAC,OAC/C,cAAc,SAAS,YAAY,KACvC,OAAO,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAmD/C,CAAA"}
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAKnE,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAIvD,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAC3D,CAAC,UAAU,gBAAgB,CAAC,cAAc,CAAC,OAC/C,cAAc,SAAS,YAAY,KACvC,OAAO,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAmD/C,CAAA"}
@@ -1,19 +1,19 @@
1
1
  import { provideResponse } from '@owlmeans/entrypoint';
2
- import { executeResponse, provideRequest } from './payload.js';
2
+ import { payloadHelper } from './payload.js';
3
3
  import { AuthFailedError } from '../errors.js';
4
- import { attachEntity } from '@owlmeans/auth-common';
4
+ import { makeEntityScope } from '@owlmeans/auth-common';
5
5
  export const authorize = async (context, module, req, reply) => {
6
6
  const guards = module.getGuards();
7
7
  if (guards.length > 0) {
8
8
  const response = provideResponse(reply);
9
- const request = provideRequest(module.alias, req);
9
+ const request = payloadHelper.provideRequest(module.alias, req);
10
10
  let guard = undefined;
11
11
  for (const alias of guards) {
12
12
  const _guard = context.service(alias);
13
13
  if (await _guard.match(request, response)) {
14
14
  guard = _guard;
15
15
  }
16
- executeResponse(response, reply, true);
16
+ payloadHelper.executeResponse(response, reply, true);
17
17
  if (guard != null) {
18
18
  break;
19
19
  }
@@ -25,7 +25,7 @@ export const authorize = async (context, module, req, reply) => {
25
25
  if (!await guard.handle(request, authResponse)) {
26
26
  throw new AuthFailedError(guard.alias);
27
27
  }
28
- executeResponse(authResponse, reply, true);
28
+ payloadHelper.executeResponse(authResponse, reply, true);
29
29
  // Guard that returns true and does not provide an error is an optional guard
30
30
  // if (authResponse.value == null) {
31
31
  // throw SyntaxError(`Guard that returns true and does not provide an error, should provide authorization`)
@@ -38,7 +38,7 @@ export const authorize = async (context, module, req, reply) => {
38
38
  // infrastructure names — keys on the entity's stable id. Resolving here, once, is what keeps a
39
39
  // rename from being a sweep of every handler: the id arrives on the request, and a slug that
40
40
  // has since been retired still resolves to the entity that retired it.
41
- const entity = await attachEntity(context, request);
41
+ const entity = await makeEntityScope(request).attachEntity(context);
42
42
  if (entity != null) {
43
43
  // Carried on the raw request the same way `_auth` is, so the request the handler is given
44
44
  // later — a different object, built after this runs — sees the same resolution.
@@ -1 +1 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIpD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,OAAU,EAAE,MAAwC,EACpD,GAAmB,EAAE,KAAmB,EACQ,EAAE;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IACjC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;QACvC,MAAM,OAAO,GAAG,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AI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,MAAK;YACP,CAAC;QACH,CAAC;QAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,eAAe,EAAE,CAAA;QAC7B,CAAC;QAED,MAAM,YAAY,GAAG,eAAe,CAAO,KAAK,CAAC,CAAA;QACjD,IAAI,CAAC,MAAM,KAAK,CAAC,MAAM,CAAU,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;QACD,aAAa,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QACxD,6EAA6E;QAC7E,oCAAoC;QACpC,6GAA6G;QAC7G,IAAI;QACJ,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,GAAW,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACnC,CAAC;QAED,4FAA4F;QAC5F,+FAA+F;QAC/F,6FAA6F;QAC7F,uEAAuE;QACvE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QACnE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,0FAA0F;YAC1F,gFAAgF;YAChF,CAAC;YAAC,GAAW,CAAC,OAAO,GAAG,MAAM,CAAA;QAChC,CAAC;IACH,CAAC;IACD,mCAAmC;IAClC,GAAW,CAAC,IAAI,GAAG,OAAO,CAAA;IAE3B,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC1B,CAAC,CAAA"}
@@ -1,9 +1,12 @@
1
1
  export * from './error.js';
2
2
  export * from './consts.js';
3
3
  export type * from './types.js';
4
+ export type * from './error/types.js';
5
+ export type * from './payload/types.js';
6
+ export type * from './context/types.js';
4
7
  export * from './server.js';
5
8
  export * from './payload.js';
6
- export * from './server.js';
9
+ export * from './schema.js';
7
10
  export * from './guards.js';
8
11
  export * from './context.js';
9
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,kBAAkB,CAAA;AACrC,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,oBAAoB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
@@ -2,7 +2,7 @@ export * from './error.js';
2
2
  export * from './consts.js';
3
3
  export * from './server.js';
4
4
  export * from './payload.js';
5
- export * from './server.js';
5
+ export * from './schema.js';
6
6
  export * from './guards.js';
7
7
  export * from './context.js';
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAE3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
@@ -0,0 +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;AAG1C,eAAO,MAAM,cAAc,UAAW,MAAM,OAAO,OAAO,cAAc,OAAO,KAAG,eAejF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,YAAY,gBAAgB,CAAC,CAAC,CAAC,SAAS,QAAQ,iBAAiB,OAAO,KAAG,OAuB3G,CAAA;AAGD,eAAO,MAAM,cAAc,WAAY,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"}