expediate 1.0.4 → 1.0.5

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 (52) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +417 -30
  3. package/dist/apis.d.ts +138 -21
  4. package/dist/apis.d.ts.map +1 -1
  5. package/dist/apis.js +172 -79
  6. package/dist/apis.js.map +1 -1
  7. package/dist/cjs/apis.js +327 -0
  8. package/dist/cjs/git.js +293 -0
  9. package/dist/cjs/index.js +2583 -0
  10. package/dist/cjs/jwt-auth.js +532 -0
  11. package/dist/cjs/middleware.js +511 -0
  12. package/dist/cjs/mimetypes.json +1 -0
  13. package/dist/cjs/misc.js +787 -0
  14. package/dist/cjs/openapi.js +485 -0
  15. package/dist/cjs/package.json +1 -0
  16. package/dist/cjs/router.js +898 -0
  17. package/dist/cjs/static.js +669 -0
  18. package/dist/git.d.ts +71 -8
  19. package/dist/git.d.ts.map +1 -1
  20. package/dist/git.js +127 -72
  21. package/dist/git.js.map +1 -1
  22. package/dist/index.d.ts +17 -13
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +14 -24
  25. package/dist/index.js.map +1 -1
  26. package/dist/jwt-auth.d.ts +147 -57
  27. package/dist/jwt-auth.d.ts.map +1 -1
  28. package/dist/jwt-auth.js +445 -205
  29. package/dist/jwt-auth.js.map +1 -1
  30. package/dist/middleware.d.ts +476 -0
  31. package/dist/middleware.d.ts.map +1 -0
  32. package/dist/middleware.js +647 -0
  33. package/dist/middleware.js.map +1 -0
  34. package/dist/mimetypes.json +1 -1
  35. package/dist/misc.d.ts +112 -5
  36. package/dist/misc.d.ts.map +1 -1
  37. package/dist/misc.js +235 -102
  38. package/dist/misc.js.map +1 -1
  39. package/dist/openapi.d.ts +290 -0
  40. package/dist/openapi.d.ts.map +1 -0
  41. package/dist/openapi.js +481 -0
  42. package/dist/openapi.js.map +1 -0
  43. package/dist/router.d.ts +405 -46
  44. package/dist/router.d.ts.map +1 -1
  45. package/dist/router.js +658 -153
  46. package/dist/router.js.map +1 -1
  47. package/dist/static.d.ts +1 -1
  48. package/dist/static.d.ts.map +1 -1
  49. package/dist/static.js +88 -84
  50. package/dist/static.js.map +1 -1
  51. package/package.json +21 -4
  52. package/.npmignore +0 -16
@@ -0,0 +1,481 @@
1
+ /* Copyright 2021 Fabien Bavent
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a
4
+ * copy of this software and associated documentation files (the "Software"),
5
+ * to deal in the Software without restriction, including without limitation
6
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ * and/or sell copies of the Software, and to permit persons to whom the
8
+ * Software is furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included
11
+ * in all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
+ * DEALINGS IN THE SOFTWARE.
20
+ */
21
+ 'use strict';
22
+ // ── YAML serialiser (zero-dependency, block-style) ────────────────────────────
23
+ /**
24
+ * YAML reserved keywords that must be quoted as scalars so that YAML parsers
25
+ * do not interpret them as the corresponding typed values.
26
+ */
27
+ const YAML_KW = new Set([
28
+ 'true', 'false', 'yes', 'no', 'on', 'off', 'null', '~',
29
+ ]);
30
+ /**
31
+ * Pattern for "safe" plain scalars: they can be represented without quoting.
32
+ * A scalar is safe when it:
33
+ * - contains only letters, digits, `_`, `-`, `.` or `/`
34
+ * - starts with a letter, `_`, `/`, or `$`
35
+ * - is not a YAML reserved keyword
36
+ * - does not look like a number
37
+ */
38
+ const SAFE_SCALAR = /^[a-zA-Z$_/][a-zA-Z0-9$_\-./]*$/;
39
+ /** Pattern matching integer and floating-point number strings. */
40
+ const LOOKS_LIKE_NUMBER = /^[-+]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$|^0x[0-9a-fA-F]+$|^0o[0-7]+$/;
41
+ /**
42
+ * Serialise a string as a YAML scalar value or key.
43
+ *
44
+ * The string is returned unquoted when it is a valid YAML plain scalar —
45
+ * i.e. it cannot be misinterpreted as another type and does not contain
46
+ * characters that would confuse a YAML parser.
47
+ *
48
+ * Otherwise the value is wrapped in double quotes with control characters,
49
+ * backslashes, and `"` escaped so the output is always valid YAML 1.2.
50
+ *
51
+ * @param s - The string to serialise.
52
+ */
53
+ function yamlString(s) {
54
+ if (s === '')
55
+ return '""';
56
+ const needsQuote =
57
+ // Would be misinterpreted as a YAML typed value.
58
+ YAML_KW.has(s.toLowerCase()) ||
59
+ LOOKS_LIKE_NUMBER.test(s) ||
60
+ // Starts with a YAML indicator that has special meaning at the start of a
61
+ // plain scalar (block context).
62
+ /^[-?:,[\]{}#&*!|>'"%@`~]/.test(s) ||
63
+ // Inline sequences that break block-mapping parsing.
64
+ s.includes(': ') ||
65
+ s.endsWith(':') ||
66
+ s.includes(' #') ||
67
+ // Leading / trailing whitespace.
68
+ s !== s.trim() ||
69
+ // Flow indicator characters anywhere — present in path patterns such as
70
+ // `/items/{id}` and must be quoted to avoid flow-collection ambiguity.
71
+ /[{}\[\]]/.test(s) ||
72
+ // Control characters.
73
+ /[\x00-\x1f\x7f]/.test(s);
74
+ if (!needsQuote)
75
+ return s;
76
+ // Double-quoted style: always valid, handles all edge cases.
77
+ return '"' +
78
+ s
79
+ .replace(/\\/g, '\\\\')
80
+ .replace(/"/g, '\\"')
81
+ .replace(/\n/g, '\\n')
82
+ .replace(/\r/g, '\\r')
83
+ .replace(/\t/g, '\\t')
84
+ .replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, c => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`)
85
+ + '"';
86
+ }
87
+ /**
88
+ * Serialise a mapping key as a YAML scalar.
89
+ *
90
+ * Uses the same quoting rules as {@link yamlString}. Numbers as keys
91
+ * (e.g. HTTP status codes `200`, `500`) are always quoted so that YAML
92
+ * parsers do not interpret them as integer keys.
93
+ */
94
+ function yamlKey(key) {
95
+ return yamlString(key);
96
+ }
97
+ /**
98
+ * Recursively serialise a JSON-compatible value into an array of YAML block
99
+ * notation lines.
100
+ *
101
+ * Each returned line has **no leading indentation** — it is the caller's
102
+ * responsibility to prefix nested lines with `' '` (two spaces) when
103
+ * embedding them inside a mapping value or sequence item.
104
+ *
105
+ * @param value - The value to serialise.
106
+ */
107
+ function toYamlLines(value) {
108
+ // ── Scalars ─────────────────────────────────────────────────────────────────
109
+ if (value === null || value === undefined)
110
+ return ['null'];
111
+ if (typeof value === 'boolean')
112
+ return [String(value)];
113
+ if (typeof value === 'number')
114
+ return [isFinite(value) ? String(value) : '.inf'];
115
+ if (typeof value === 'string')
116
+ return [yamlString(value)];
117
+ // ── Sequences ────────────────────────────────────────────────────────────────
118
+ if (Array.isArray(value)) {
119
+ if (value.length === 0)
120
+ return ['[]'];
121
+ const lines = [];
122
+ for (const item of value) {
123
+ const itemLines = toYamlLines(item);
124
+ // First line of the item goes on the same line as the dash.
125
+ lines.push(`- ${itemLines[0]}`);
126
+ // Subsequent lines are indented by two spaces (relative to the `-`).
127
+ for (const l of itemLines.slice(1))
128
+ lines.push(` ${l}`);
129
+ }
130
+ return lines;
131
+ }
132
+ // ── Mappings ─────────────────────────────────────────────────────────────────
133
+ if (typeof value === 'object') {
134
+ const obj = value;
135
+ const entries = Object.entries(obj).filter(([, v]) => v !== undefined);
136
+ if (entries.length === 0)
137
+ return ['{}'];
138
+ const lines = [];
139
+ for (const [key, val] of entries) {
140
+ const k = yamlKey(key);
141
+ const valLines = toYamlLines(val);
142
+ // Inline only when the value is a scalar, null, or an empty collection
143
+ // (`{}` / `[]`). Non-empty objects and arrays — even when they happen
144
+ // to serialise to a single line (e.g. `$ref: "#/..."`) — must go block
145
+ // style; inlining them produces ambiguous YAML like `key: $ref: "..."`.
146
+ const isComplex = typeof val === 'object' && val !== null;
147
+ const isEmptyCollection = valLines.length === 1 &&
148
+ (valLines[0] === '{}' || valLines[0] === '[]');
149
+ if (!isComplex || isEmptyCollection) {
150
+ // Scalar or empty collection: fits on the same line as the key.
151
+ lines.push(`${k}: ${valLines[0]}`);
152
+ }
153
+ else {
154
+ // Block style: key on its own line, value indented below.
155
+ lines.push(`${k}:`);
156
+ for (const l of valLines)
157
+ lines.push(` ${l}`);
158
+ }
159
+ }
160
+ return lines;
161
+ }
162
+ return [String(value)];
163
+ }
164
+ /**
165
+ * Serialise an {@link OpenApiDocument} to either JSON or YAML.
166
+ *
167
+ * - `'json'` — pretty-printed with 2-space indentation.
168
+ * - `'yaml'` — block-style YAML 1.2, produced by a zero-dependency serialiser
169
+ * built into expediate.
170
+ *
171
+ * @param doc - The document to serialise.
172
+ * @param format - Output format (`'json'` by default).
173
+ */
174
+ export function serializeSpec(doc, format = 'json') {
175
+ if (format === 'yaml')
176
+ return toYamlLines(doc).join('\n') + '\n';
177
+ return JSON.stringify(doc, null, 2);
178
+ }
179
+ // ---------------------------------------------------------------------------
180
+ // Symbol for attaching metadata to handler functions
181
+ // ---------------------------------------------------------------------------
182
+ /**
183
+ * Unique symbol used as a non-enumerable property key on handler functions
184
+ * that have been annotated via {@link describe}.
185
+ *
186
+ * Using a `unique symbol` (rather than a plain string key) prevents accidental
187
+ * collisions with user-defined properties on handler objects.
188
+ */
189
+ export const DESCRIBE_META = Symbol('expediate.openapi.meta');
190
+ // ---------------------------------------------------------------------------
191
+ // Public API
192
+ // ---------------------------------------------------------------------------
193
+ /**
194
+ * Annotate a service method handler with OpenAPI operation metadata.
195
+ *
196
+ * The metadata is attached to the returned function via a non-enumerable
197
+ * property keyed by {@link DESCRIBE_META}. The returned function is otherwise
198
+ * identical to `handler` — it can be used directly in a `ServiceDefinition`
199
+ * route map.
200
+ *
201
+ * ```ts
202
+ * GET: {
203
+ * '/items/:id': describe(
204
+ * function (this: TodoService, p) {
205
+ * return this.findOrFail(p.id);
206
+ * },
207
+ * {
208
+ * summary: 'Get a single item by ID',
209
+ * tags: ['items'],
210
+ * parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
211
+ * responses: {
212
+ * '200': { description: 'The item', content: { 'application/json': { schema: { $ref: '#/components/schemas/Item' } } } },
213
+ * '404': { description: 'Not found' },
214
+ * },
215
+ * },
216
+ * ),
217
+ * }
218
+ * ```
219
+ *
220
+ * @param handler - The service method to annotate.
221
+ * @param meta - OpenAPI operation metadata.
222
+ * @returns The same handler function, with metadata attached.
223
+ */
224
+ export function describe(handler, meta) {
225
+ // Wrap the handler so we have a fresh function object to attach metadata to,
226
+ // avoiding unexpected mutations of functions shared across route maps.
227
+ const described = function (ctx, body) {
228
+ return handler.apply(this, [ctx, body]);
229
+ };
230
+ // Attach metadata as a non-enumerable property so it is invisible to
231
+ // Object.keys() / JSON.stringify() and does not pollute the function's
232
+ // "own" enumerable surface.
233
+ Object.defineProperty(described, DESCRIBE_META, {
234
+ value: meta,
235
+ enumerable: false,
236
+ configurable: true,
237
+ writable: false,
238
+ });
239
+ return described;
240
+ }
241
+ // ---------------------------------------------------------------------------
242
+ // Internal path-translation helpers
243
+ // ---------------------------------------------------------------------------
244
+ /**
245
+ * Convert an Express-style path pattern to an OpenAPI path pattern.
246
+ *
247
+ * - `:param` segments become `{param}`.
248
+ * - An optional `basePath` prefix is prepended (with duplicate-slash guards).
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * toOpenApiPath('/items/:id', '/api/v1') // → '/api/v1/items/{id}'
253
+ * toOpenApiPath('/items', '') // → '/items'
254
+ * ```
255
+ */
256
+ function toOpenApiPath(pattern, basePath) {
257
+ const converted = pattern.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g, '{$1}');
258
+ if (!basePath)
259
+ return converted;
260
+ const base = basePath.replace(/\/+$/, '');
261
+ const path = converted.replace(/^\/+/, '/');
262
+ return base + (path.startsWith('/') ? path : `/${path}`);
263
+ }
264
+ /**
265
+ * Extract named path parameters from an Express-style pattern as
266
+ * {@link ParameterObject} entries with `in: 'path'` and `required: true`.
267
+ *
268
+ * Parameters already listed in `annotated` (by name) are skipped to avoid
269
+ * duplicates when the caller has provided explicit metadata for them.
270
+ *
271
+ * @param pattern - Express-style route pattern (e.g. `/items/:id`).
272
+ * @param annotated - Explicit parameters provided by the caller (may be empty).
273
+ */
274
+ function extractPathParams(pattern, annotated) {
275
+ const annotatedNames = new Set(annotated.map(p => p.name));
276
+ const params = [];
277
+ for (const match of pattern.matchAll(/:([A-Za-z_][A-Za-z0-9_]*)/g)) {
278
+ const name = match[1];
279
+ if (!annotatedNames.has(name)) {
280
+ params.push({
281
+ name,
282
+ in: 'path',
283
+ required: true,
284
+ schema: { type: 'string' },
285
+ });
286
+ }
287
+ }
288
+ return params;
289
+ }
290
+ /**
291
+ * Build an `operationId` string from an HTTP verb and a path pattern.
292
+ *
293
+ * The algorithm:
294
+ * 1. Lowercase the verb (e.g. `'GET'` → `'get'`).
295
+ * 2. Split the pattern on `/` and `:` (and `{` / `}` for pre-translated paths).
296
+ * 3. CamelCase each non-empty segment (first-letter uppercase).
297
+ * 4. Prefix each path-param segment with `'By'`.
298
+ * 5. Join everything into a single camelCase string.
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * buildOperationId('GET', '/items') // → 'getItems'
303
+ * buildOperationId('GET', '/items/:id') // → 'getItemsById'
304
+ * buildOperationId('DELETE', '/a/:b/:c') // → 'deleteAByBByC'
305
+ * ```
306
+ */
307
+ function buildOperationId(verb, pattern) {
308
+ const parts = pattern.split(/[/:{} ]+/).filter(Boolean);
309
+ let result = verb.toLowerCase();
310
+ for (const part of parts) {
311
+ const isParam = pattern.includes(`:${part}`) || pattern.includes(`{${part}}`);
312
+ const pascal = part.charAt(0).toUpperCase() + part.slice(1);
313
+ result += isParam ? `By${pascal}` : pascal;
314
+ }
315
+ return result;
316
+ }
317
+ /**
318
+ * Build the default responses for an operation when none are provided by the
319
+ * caller.
320
+ *
321
+ * - `POST` → `201 No Content` (successful write with no response body).
322
+ * - All other verbs → `200 OK` with a generic JSON response.
323
+ * - `500` → always added as a reference to the built-in `ApiError` component.
324
+ */
325
+ function buildDefaultResponses(verb) {
326
+ const ok = verb === 'POST'
327
+ ? { description: 'Created' }
328
+ : { description: 'OK', content: { 'application/json': {} } };
329
+ return {
330
+ [verb === 'POST' ? '201' : '200']: ok,
331
+ '500': { $ref: '#/components/responses/ApiError' },
332
+ };
333
+ }
334
+ /**
335
+ * Convert caller-provided `responses` metadata into the OpenAPI responses
336
+ * map, injecting the built-in `ApiError` reference for `500` unless the
337
+ * caller has explicitly provided one.
338
+ */
339
+ function buildAnnotatedResponses(responses) {
340
+ const result = { ...responses };
341
+ if (!result['500']) {
342
+ result['500'] = { $ref: '#/components/responses/ApiError' };
343
+ }
344
+ return result;
345
+ }
346
+ // ---------------------------------------------------------------------------
347
+ // Core spec generator
348
+ // ---------------------------------------------------------------------------
349
+ /** The five HTTP verbs supported by `apiBuilder`. */
350
+ const VERBS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
351
+ /**
352
+ * Generate an OpenAPI 3.1.0 document from a {@link ServiceDefinition}.
353
+ *
354
+ * Route handlers that have been annotated with {@link describe} contribute
355
+ * rich operation metadata (summary, description, parameters, requestBody,
356
+ * responses). Unannotated handlers receive sensible defaults automatically.
357
+ *
358
+ * The generated document always includes:
359
+ * - An `ApiError` schema (shape: `{ status?, message?, data? }`) in
360
+ * `components.schemas`.
361
+ * - An `ApiError` response (`500` reference) in `components.responses`.
362
+ *
363
+ * Caller-supplied `opts.schemas` and service-level `openapi.schemas` are
364
+ * deep-merged on top of the built-in components (caller schemas take
365
+ * precedence over service schemas, which take precedence over built-ins).
366
+ *
367
+ * @param service - The service definition to document.
368
+ * @param opts - Top-level spec options (title, version, basePath, …).
369
+ * @returns A fully-formed OpenAPI 3.1.0 document object.
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * const spec = openApiSpec(todoDefinition, {
374
+ * title: 'Todo API',
375
+ * version: '1.0.0',
376
+ * basePath: '/api',
377
+ * });
378
+ *
379
+ * app.get('/openapi.json', (_req, res) => {
380
+ * res.json(spec);
381
+ * });
382
+ * ```
383
+ */
384
+ export function openApiSpec(service, opts) {
385
+ const basePath = opts.basePath ?? '';
386
+ const svcMeta = service.openapi;
387
+ const defaultTag = svcMeta?.tag;
388
+ // ── Components ──────────────────────────────────────────────────────────────
389
+ const builtinSchemas = {
390
+ ApiError: {
391
+ type: 'object',
392
+ properties: {
393
+ status: { type: 'integer', description: 'HTTP status code' },
394
+ message: { type: 'string', description: 'Human-readable error message' },
395
+ data: { description: 'Structured error payload (overrides message when present)' },
396
+ },
397
+ },
398
+ };
399
+ const builtinResponses = {
400
+ ApiError: {
401
+ description: 'API error response',
402
+ content: {
403
+ 'application/json': { schema: { $ref: '#/components/schemas/ApiError' } },
404
+ },
405
+ },
406
+ };
407
+ // Merge schemas: built-ins ← service-level ← caller-level (last wins).
408
+ const schemas = {
409
+ ...builtinSchemas,
410
+ ...svcMeta?.schemas,
411
+ ...opts.schemas,
412
+ };
413
+ const responses = {
414
+ ...builtinResponses,
415
+ ...svcMeta?.responses,
416
+ };
417
+ // ── Tags ─────────────────────────────────────────────────────────────────────
418
+ const tags = [];
419
+ if (defaultTag) {
420
+ tags.push({ name: defaultTag, description: svcMeta?.tagDescription });
421
+ }
422
+ // ── Paths ────────────────────────────────────────────────────────────────────
423
+ const paths = {};
424
+ for (const verb of VERBS) {
425
+ const routeMap = service[verb];
426
+ if (!routeMap)
427
+ continue;
428
+ for (const [pattern, handler] of Object.entries(routeMap)) {
429
+ const openApiPath = toOpenApiPath(pattern, basePath);
430
+ if (!paths[openApiPath])
431
+ paths[openApiPath] = {};
432
+ // Retrieve attached metadata (if any).
433
+ const meta = handler[DESCRIBE_META];
434
+ // ── Parameters ─────────────────────────────────────────────────────────
435
+ const annotatedParams = meta?.parameters ?? [];
436
+ const inferredParams = extractPathParams(pattern, annotatedParams);
437
+ const parameters = [...annotatedParams, ...inferredParams];
438
+ // ── Responses ──────────────────────────────────────────────────────────
439
+ const operationResponses = meta?.responses
440
+ ? buildAnnotatedResponses(meta.responses)
441
+ : buildDefaultResponses(verb);
442
+ // ── Operation object ───────────────────────────────────────────────────
443
+ const operation = {
444
+ operationId: meta?.operationId ?? buildOperationId(verb, pattern),
445
+ ...(meta?.summary && { summary: meta.summary }),
446
+ ...(meta?.description && { description: meta.description }),
447
+ ...(meta?.deprecated && { deprecated: true }),
448
+ ...(parameters.length > 0 && { parameters }),
449
+ ...(meta?.requestBody && { requestBody: meta.requestBody }),
450
+ responses: operationResponses,
451
+ };
452
+ // Apply default tag when the operation has no explicit tags.
453
+ const opTags = meta?.tags ?? (defaultTag ? [defaultTag] : undefined);
454
+ if (opTags)
455
+ operation['tags'] = opTags;
456
+ // Carry through any vendor extensions (x-* keys).
457
+ if (meta) {
458
+ for (const [k, v] of Object.entries(meta)) {
459
+ if (k.startsWith('x-'))
460
+ operation[k] = v;
461
+ }
462
+ }
463
+ paths[openApiPath][verb.toLowerCase()] = operation;
464
+ }
465
+ }
466
+ // ── Assemble document ────────────────────────────────────────────────────────
467
+ const doc = {
468
+ openapi: '3.1.0',
469
+ info: {
470
+ title: opts.title,
471
+ version: opts.version,
472
+ ...(opts.description && { description: opts.description }),
473
+ },
474
+ ...(opts.servers && { servers: opts.servers }),
475
+ ...(tags.length > 0 && { tags }),
476
+ paths,
477
+ components: { schemas, responses },
478
+ };
479
+ return doc;
480
+ }
481
+ //# sourceMappingURL=openapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AA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