@nhtio/lucid-resourceful 0.1.0-master-29dd5a13 → 0.1.0-master-641df8fc

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/adonis-env.d.ts +17 -0
  2. package/bundled_liqe.d.ts +6 -5
  3. package/bundled_xml_js.d.ts +5 -4
  4. package/definitions.d.ts +1 -1
  5. package/encoding.d.ts +6 -6
  6. package/errors.d.ts +23 -8
  7. package/{index-Bsyx9Sty.js → index-B-5JiNqG.js} +76 -221
  8. package/index-B-5JiNqG.js.map +1 -0
  9. package/{index-B6dIMDux.cjs → index-BrGbuAtt.cjs} +76 -221
  10. package/index-BrGbuAtt.cjs.map +1 -0
  11. package/index-C9zyi90j.js.map +1 -1
  12. package/{index-CpyTnwZV.cjs → index-CQApAM0M.cjs} +298 -353
  13. package/index-CQApAM0M.cjs.map +1 -0
  14. package/index-CxRBayw6.cjs.map +1 -1
  15. package/{index-C8mGEf4P.js → index-DLVvkVxI.js} +295 -350
  16. package/index-DLVvkVxI.js.map +1 -0
  17. package/index-DsojAcQ4.js.map +1 -1
  18. package/index-DuzIXu31.cjs.map +1 -1
  19. package/index.cjs +1 -1
  20. package/index.d.ts +7 -7
  21. package/index.mjs +1 -1
  22. package/integration/middlewares/odata_error.cjs +1 -1
  23. package/integration/middlewares/odata_error.d.ts +1 -1
  24. package/integration/middlewares/odata_error.mjs +1 -1
  25. package/integration/middlewares/resourceful_encoded_request.cjs +100 -12
  26. package/integration/middlewares/resourceful_encoded_request.cjs.map +1 -1
  27. package/integration/middlewares/resourceful_encoded_request.d.ts +1 -1
  28. package/integration/middlewares/resourceful_encoded_request.mjs +98 -10
  29. package/integration/middlewares/resourceful_encoded_request.mjs.map +1 -1
  30. package/integration/middlewares/resourceful_error.cjs +1 -1
  31. package/integration/middlewares/resourceful_error.d.ts +1 -1
  32. package/integration/middlewares/resourceful_error.mjs +1 -1
  33. package/integration/provider.cjs +1 -1
  34. package/integration/provider.mjs +1 -1
  35. package/joi.d.ts +1 -1
  36. package/{manager-OLS5T3G7-CJHhMwR7.cjs → manager-OLS5T3G7-BPVI59Zw.cjs} +2 -2
  37. package/{manager-OLS5T3G7-CJHhMwR7.cjs.map → manager-OLS5T3G7-BPVI59Zw.cjs.map} +1 -1
  38. package/{manager-OLS5T3G7-C-NS6lhx.js → manager-OLS5T3G7-DzVckqOB.js} +2 -2
  39. package/{manager-OLS5T3G7-C-NS6lhx.js.map → manager-OLS5T3G7-DzVckqOB.js.map} +1 -1
  40. package/odata/context.d.ts +1 -1
  41. package/odata/macro.d.ts +1 -1
  42. package/{odata_error_middleware-BWfOpQZV.cjs → odata_error_middleware-DhLzccN7.cjs} +4 -4
  43. package/{odata_error_middleware-BWfOpQZV.cjs.map → odata_error_middleware-DhLzccN7.cjs.map} +1 -1
  44. package/{odata_error_middleware-CWYqZMez.js → odata_error_middleware-Dspi8bct.js} +4 -4
  45. package/{odata_error_middleware-CWYqZMez.js.map → odata_error_middleware-Dspi8bct.js.map} +1 -1
  46. package/package.json +1 -1
  47. package/private/data_type_schemas.d.ts +12 -12
  48. package/private/data_types.d.ts +1 -1
  49. package/private/decorator_schemas.d.ts +1 -1
  50. package/private/decorator_utils.d.ts +1 -1
  51. package/private/decorators.d.ts +14 -11
  52. package/private/encoding.d.ts +3 -3
  53. package/private/joi/index.d.ts +3 -3
  54. package/private/lucene_to_lucid_translator.d.ts +1 -1
  55. package/private/mixin.d.ts +25 -8
  56. package/private/odata_macro/controllers/resourceful_model_controller.d.ts +4 -4
  57. package/private/odata_macro/index.d.ts +1 -1
  58. package/private/odata_macro/middlewares/odata_error_middleware.d.ts +22 -10
  59. package/private/odata_macro/services/odata_context_service.d.ts +1 -1
  60. package/private/odata_macro/services/odata_metadata_service.d.ts +3 -3
  61. package/private/odata_macro/utils/odata.d.ts +2 -2
  62. package/private/odata_to_lucid_translator.d.ts +1 -1
  63. package/private/open_api_schema_service.d.ts +3 -3
  64. package/private/router_macro/controllers/resourceful_model_controller.d.ts +5 -5
  65. package/private/router_macro/index.d.ts +3 -3
  66. package/private/router_macro/middlewares/resourceful_error_middleware.d.ts +22 -10
  67. package/private/router_macro/services/resourceful_router_choices_service.d.ts +3 -3
  68. package/private/router_macro/services/resourceful_router_context_service.d.ts +1 -1
  69. package/private/router_macro/services/resourceful_router_model_options_service.d.ts +1 -1
  70. package/private/router_macro/services/resourceful_router_model_resolver_service.d.ts +3 -3
  71. package/private/router_macro/services/resourceful_router_openapi_document_service.d.ts +4 -4
  72. package/private/router_macro/services/resourceful_router_options_service.d.ts +3 -3
  73. package/private/router_macro/types.d.ts +15 -8
  74. package/private/router_macro/utils/errors.d.ts +1 -1
  75. package/private/router_macro/utils/http.d.ts +1 -1
  76. package/private/router_macro/utils/openapi_validation_schemas.d.ts +2 -2
  77. package/private/router_macro/utils/relationships.d.ts +1 -1
  78. package/private/router_macro/utils/type_guards.d.ts +1 -1
  79. package/private/schema_types.d.ts +1 -1
  80. package/private/type_guards.d.ts +5 -5
  81. package/private/types.d.ts +5 -5
  82. package/private/utils/casters.d.ts +1 -1
  83. package/private/utils/consumers.d.ts +1 -1
  84. package/private/utils/preparers.d.ts +1 -1
  85. package/private/utils.d.ts +1 -1
  86. package/{resourceful_error_middleware-CMSZGdoG.js → resourceful_error_middleware-Cb_eTzST.js} +4 -4
  87. package/{resourceful_error_middleware-CMSZGdoG.js.map → resourceful_error_middleware-Cb_eTzST.js.map} +1 -1
  88. package/{resourceful_error_middleware-lXgefPIC.cjs → resourceful_error_middleware-CnjbNoev.cjs} +4 -4
  89. package/{resourceful_error_middleware-lXgefPIC.cjs.map → resourceful_error_middleware-CnjbNoev.cjs.map} +1 -1
  90. package/router/context.d.ts +1 -1
  91. package/router/utils.cjs +1 -1
  92. package/router/utils.d.ts +1 -1
  93. package/router/utils.mjs +1 -1
  94. package/router.cjs +1 -1
  95. package/router.d.ts +2 -2
  96. package/router.mjs +1 -1
  97. package/types.d.ts +13 -13
  98. package/utils.d.ts +4 -4
  99. package/vite-env.d.ts +3 -0
  100. package/index-B6dIMDux.cjs.map +0 -1
  101. package/index-Bsyx9Sty.js.map +0 -1
  102. package/index-C8mGEf4P.js.map +0 -1
  103. package/index-CpIq4gOr.js +0 -93
  104. package/index-CpIq4gOr.js.map +0 -1
  105. package/index-CpyTnwZV.cjs.map +0 -1
  106. package/index-DqbJXpcT.cjs +0 -92
  107. package/index-DqbJXpcT.cjs.map +0 -1
  108. package/private/controller_factory.d.ts +0 -1
  109. package/private/utils/function_serializer.d.ts +0 -32
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const resourceful_error_middleware = require("../../resourceful_error_middleware-lXgefPIC.cjs");
3
+ const resourceful_error_middleware = require("../../resourceful_error_middleware-CnjbNoev.cjs");
4
4
  exports.default = resourceful_error_middleware.ResourcefulErrorMiddleware;
5
5
  //# sourceMappingURL=resourceful_error.cjs.map
@@ -3,5 +3,5 @@
3
3
  * formats the responses in a consistent manner meant to be easily consumed by clients.
4
4
  * @module @nhtio/lucid-resourceful/integration/middlewares/resourceful_error
5
5
  */
6
- import { ResourcefulErrorMiddleware } from '../../private/router_macro/middlewares/resourceful_error_middleware'
6
+ import { ResourcefulErrorMiddleware } from "../../private/router_macro/middlewares/resourceful_error_middleware";
7
7
  export default ResourcefulErrorMiddleware;
@@ -1,4 +1,4 @@
1
- import { R as ResourcefulErrorMiddleware } from "../../resourceful_error_middleware-CMSZGdoG.js";
1
+ import { R as ResourcefulErrorMiddleware } from "../../resourceful_error_middleware-Cb_eTzST.js";
2
2
  export {
3
3
  ResourcefulErrorMiddleware as default
4
4
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const http = require("@adonisjs/core/http");
4
- const index = require("../index-B6dIMDux.cjs");
4
+ const index = require("../index-BrGbuAtt.cjs");
5
5
  const odata_macro = require("../odata/macro.cjs");
6
6
  class LucidResourcefulProvider {
7
7
  async start() {
@@ -1,5 +1,5 @@
1
1
  import { Router, Response } from "@adonisjs/core/http";
2
- import { r as resourcefulRouterMacro, o as odataRouterMacro } from "../index-Bsyx9Sty.js";
2
+ import { r as resourcefulRouterMacro, o as odataRouterMacro } from "../index-B-5JiNqG.js";
3
3
  import { odataXmlResponseMacro } from "../odata/macro.mjs";
4
4
  class LucidResourcefulProvider {
5
5
  async start() {
package/joi.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * A modified version of the joi validation library which adds support for new custom schemas
3
3
  * @module @nhtio/lucid-resourceful/joi
4
4
  */
5
- export * from './private/joi'
5
+ export * from "./private/joi/index";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-B6dIMDux.cjs");
3
+ const index = require("./index-BrGbuAtt.cjs");
4
4
  const require$$0 = require("path");
5
5
  const promises = require("fs/promises");
6
6
  const utils = require("@poppinss/utils");
@@ -415,4 +415,4 @@ ${sources.join("\n")}`
415
415
  }
416
416
  };
417
417
  exports.StubsManager = StubsManager;
418
- //# sourceMappingURL=manager-OLS5T3G7-CJHhMwR7.cjs.map
418
+ //# sourceMappingURL=manager-OLS5T3G7-BPVI59Zw.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-OLS5T3G7-CJHhMwR7.cjs","sources":["../node_modules/.pnpm/tempura@0.4.1/node_modules/tempura/dist/index.mjs","../node_modules/.pnpm/@adonisjs+application@8.4.2_@adonisjs+config@5.0.3_@adonisjs+fold@10.2.1/node_modules/@adonisjs/application/build/manager-OLS5T3G7.js"],"sourcesContent":["const ESCAPE = /[&\"<]/g, CHARS = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt',\n};\n\nconst ENDLINES = /[\\r\\n]+$/g;\nconst CURLY = /{{{?\\s*([\\s\\S]*?)\\s*}}}?/g;\nconst VAR = /(?:^|[-*+^|%/&=\\s])([a-zA-Z$_][\\w$]*)(?:(?=$|[-*+^|%/&=\\s]))/g;\nconst ARGS = /([a-zA-Z$_][^\\s=]*)\\s*=\\s*(([\"`'])(?:(?=(\\\\?))\\4.)*?\\3|{[^}]*}|\\[[^\\]]*]|\\S+)/g;\n\n// $$1 = escape()\n// $$2 = extra blocks\n// $$3 = template values\nfunction gen(input, options) {\n\toptions = options || {};\n\n\tlet char, num, action, tmp;\n\tlet last = CURLY.lastIndex = 0;\n\tlet wip='', txt='', match, inner;\n\n\tlet extra=options.blocks||{}, stack=[];\n\tlet initials = new Set(options.props||[]);\n\n\tfunction close() {\n\t\tif (wip.length > 0) {\n\t\t\ttxt += (txt ? 'x+=' : '=') + '`' + wip + '`;';\n\t\t} else if (txt.length === 0) {\n\t\t\ttxt = '=\"\";'\n\t\t}\n\t\twip = '';\n\t}\n\n\twhile (match = CURLY.exec(input)) {\n\t\twip += input.substring(last, match.index).replace(ENDLINES, '');\n\t\tlast = match.index + match[0].length;\n\n\t\tinner = match[1].trim();\n\t\tchar = inner.charAt(0);\n\n\t\tif (char === '!') {\n\t\t\t// comment, continue\n\t\t} else if (char === '#') {\n\t\t\tclose();\n\t\t\t[, action, inner] = /^#\\s*(\\w[\\w\\d]+)\\s*([^]*)/.exec(inner);\n\n\t\t\tif (action === 'expect') {\n\t\t\t\tinner.split(/[\\n\\r\\s\\t]*,[\\n\\r\\s\\t]*/g).forEach(key => {\n\t\t\t\t\tinitials.add(key);\n\t\t\t\t});\n\t\t\t} else if (action === 'var') {\n\t\t\t\tnum = inner.indexOf('=');\n\t\t\t\ttmp = inner.substring(0, num++).trim();\n\t\t\t\tinner = inner.substring(num).trim().replace(/[;]$/, '');\n\t\t\t\ttxt += `var ${tmp}=${inner};`;\n\t\t\t} else if (action === 'each') {\n\t\t\t\tnum = inner.indexOf(' as ');\n\t\t\t\tstack.push(action);\n\t\t\t\tif (!~num) {\n\t\t\t\t\ttxt += `for(var i=0,$$a=${inner};i<$$a.length;i++){`;\n\t\t\t\t} else {\n\t\t\t\t\ttmp = inner.substring(0, num).trim();\n\t\t\t\t\tinner = inner.substring(num + 4).trim();\n\t\t\t\t\tlet [item, idx='i'] = inner.replace(/[()\\s]/g, '').split(','); // (item, idx?)\n\t\t\t\t\ttxt += `for(var ${idx}=0,${item},$$a=${tmp};${idx}<$$a.length;${idx}++){${item}=$$a[${idx}];`;\n\t\t\t\t}\n\t\t\t} else if (action === 'if') {\n\t\t\t\ttxt += `if(${inner}){`;\n\t\t\t\tstack.push(action);\n\t\t\t} else if (action === 'elif') {\n\t\t\t\ttxt += `}else if(${inner}){`;\n\t\t\t} else if (action === 'else') {\n\t\t\t\ttxt += `}else{`;\n\t\t\t} else if (action in extra) {\n\t\t\t\tif (inner) {\n\t\t\t\t\ttmp = [];\n\t\t\t\t\t// parse arguments, `defer=true` -> `{ defer: true }`\n\t\t\t\t\twhile (match = ARGS.exec(inner)) tmp.push(match[1] + ':' + match[2]);\n\t\t\t\t\tinner = tmp.length ? '{' + tmp.join() + '}' : '';\n\t\t\t\t}\n\t\t\t\tinner = inner || '{}';\n\t\t\t\ttmp = options.async ? 'await ' : '';\n\t\t\t\twip += '${' + tmp + '$$2.' + action + '(' + inner + ',$$2)}';\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Unknown \"${action}\" block`);\n\t\t\t}\n\t\t} else if (char === '/') {\n\t\t\taction = inner.substring(1);\n\t\t\tinner = stack.pop();\n\t\t\tclose();\n\t\t\tif (action === inner) txt += '}';\n\t\t\telse throw new Error(`Expected to close \"${inner}\" block; closed \"${action}\" instead`);\n\t\t} else {\n\t\t\tif (match[0].charAt(2) === '{') wip += '${' + inner + '}'; // {{{ raw }}}\n\t\t\telse wip += '${$$1(' + inner + ')}';\n\t\t\tif (options.loose) {\n\t\t\t\twhile (tmp = VAR.exec(inner)) {\n\t\t\t\t\tinitials.add(tmp[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (stack.length > 0) {\n\t\tthrow new Error(`Unterminated \"${stack.pop()}\" block`);\n\t}\n\n\tif (last < input.length) {\n\t\twip += input.substring(last).replace(ENDLINES, '');\n\t}\n\n\tclose();\n\n\ttmp = initials.size ? `{${ [...initials].join() }}=$$3,x` : ' x';\n\treturn `var${tmp + txt}return x`;\n}\n\nexport function esc(value) {\n\tvalue = (value == null) ? '' : '' + value;\n\tlet last=ESCAPE.lastIndex=0, tmp=0, out='';\n\twhile (ESCAPE.test(value)) {\n\t\ttmp = ESCAPE.lastIndex - 1;\n\t\tout += value.substring(last, tmp) + CHARS[value[tmp]];\n\t\tlast = tmp + 1;\n\t}\n\treturn out + value.substring(last);\n}\n\nexport function compile(input, options={}) {\n\treturn new (options.async ? (async()=>{}).constructor : Function)(\n\t\t'$$1', '$$2', '$$3', gen(input, options)\n\t).bind(0, options.escape || esc, options.blocks);\n}\n\nexport function transform(input, options={}) {\n\treturn (\n\t\toptions.format === 'cjs'\n\t\t? 'var $$1=require(\"tempura\").esc;module.exports='\n\t\t: 'import{esc as $$1}from\"tempura\";export default '\n\t) + (\n\t\toptions.async ? 'async ' : ''\n\t) + 'function($$3,$$2){'+gen(input, options)+'}';\n}\n","import {\n debug_default\n} from \"./chunk-OVQD25FW.js\";\n\n// src/stubs/manager.ts\nimport { join as join2 } from \"path\";\nimport { cp } from \"fs/promises\";\nimport { RuntimeException as RuntimeException2, fsReadAll } from \"@poppinss/utils\";\n\n// src/stubs/stub.ts\nimport * as tempura from \"tempura\";\nimport string from \"@poppinss/utils/string\";\nimport { dirname, isAbsolute } from \"path\";\nimport { RuntimeException } from \"@poppinss/utils\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport stringHelpers from \"@poppinss/utils/string\";\nimport StringBuilder from \"@poppinss/utils/string_builder\";\n\n// src/helpers.ts\nimport { join } from \"path\";\nimport { access, readFile } from \"fs/promises\";\nasync function readFileFromSources(fileName, sources) {\n for (let source of sources) {\n const filePath = join(source, fileName);\n const contents = await readFileOptional(filePath);\n if (contents !== null) {\n return {\n contents,\n filePath,\n fileName,\n source\n };\n }\n }\n return null;\n}\nasync function readFileOptional(filePath) {\n try {\n return await readFile(filePath, \"utf-8\");\n } catch (error) {\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n return null;\n }\n}\nasync function pathExists(path) {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\nfunction parseStubExports(contents) {\n const chunks = contents.split(/\\r\\n|\\n/);\n const body = [];\n const exportedBlocks = [];\n chunks.forEach((line) => {\n if (line.includes(\"<!--EXPORT_START-->\")) {\n let [inital, rest] = line.split(\"<!--EXPORT_START-->\");\n let [exports, remaining] = rest.split(\"<!--EXPORT_END-->\");\n inital = inital.trim();\n remaining = remaining.trim();\n const remainingContents = inital && remaining ? `${inital}\n${remaining}` : inital || remaining || \"\";\n exportedBlocks.push(exports);\n if (remainingContents) {\n body.push(remainingContents);\n }\n } else {\n body.push(line);\n }\n });\n const attributes = exportedBlocks.reduce(\n (result, block) => {\n Object.assign(result, JSON.parse(block));\n return result;\n },\n {}\n );\n return { attributes, body: body.join(\"\\n\") };\n}\n\n// src/stubs/stub.ts\nfunction stubStringBuilder(value) {\n return new StringBuilder(value);\n}\nObject.assign(stubStringBuilder, stringHelpers);\nvar Stub = class {\n /**\n * The absolute path to the stub file. Need it for reporting\n * errors\n */\n #stubPath;\n /**\n * The contents of the stub to process\n */\n #stubContents;\n /**\n * Application class reference\n */\n #app;\n constructor(app, stubContents, stubPath) {\n this.#app = app;\n this.#stubPath = stubPath;\n this.#stubContents = stubContents;\n }\n /**\n * Patch error stack and point it to the stub file\n */\n #patchErrorStack(error) {\n const stack = error.stack.split(\"\\n\");\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Patch tempura error stack and point it to the stub file\n */\n #patchTempuraStack(error) {\n const stack = error.stack.split(\"\\n\");\n const templateErrorLine = stack[1].match(/<anonymous>:(\\d+):\\d+\\)$/);\n if (!templateErrorLine) {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n } else {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:${templateErrorLine[1]}:0)`);\n }\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Validates the \"to\" attribute\n */\n #validateToAttribute(attributes) {\n if (!attributes.to) {\n const error = new RuntimeException(`Missing \"to\" attribute in stub exports`);\n throw error;\n }\n if (!isAbsolute(attributes.to)) {\n const error = new RuntimeException(\n `The value for \"to\" attribute must be an absolute file path`\n );\n throw error;\n }\n }\n /**\n * Returns the default state for the stub\n */\n #getStubDefaults() {\n return {\n app: this.#app,\n randomString: string.random,\n generators: this.#app.generators,\n exports: (value) => {\n return `<!--EXPORT_START-->${JSON.stringify(value)}<!--EXPORT_END-->`;\n },\n string: stubStringBuilder\n };\n }\n /**\n * Renders stub using tempura templating syntax.\n */\n async #renderStub(data) {\n try {\n const render = tempura.compile(this.#stubContents, {\n props: Object.keys(data)\n });\n return render(data).trim();\n } catch (error) {\n this.#patchTempuraStack(error);\n throw error;\n }\n }\n /**\n * Parsers the stub exports\n */\n #parseExports(stubOutput) {\n try {\n const { body, attributes } = parseStubExports(stubOutput);\n this.#validateToAttribute(attributes);\n return { attributes, body };\n } catch (error) {\n this.#patchErrorStack(error);\n throw error;\n }\n }\n /**\n * Prepare stub to be written to the disk\n */\n async prepare(stubData) {\n const data = {\n ...this.#getStubDefaults(),\n ...stubData\n };\n const { attributes, body } = this.#parseExports(await this.#renderStub(data));\n debug_default(\"prepared stub %s\", body);\n debug_default(\"stub attributes %O\", attributes);\n return {\n contents: body,\n destination: attributes.to,\n force: stubData.force !== void 0 ? stubData.force : !!attributes.force,\n attributes\n };\n }\n /**\n * Generate resource for the stub. Writes file to the disk\n */\n async generate(stubData) {\n const { force, ...stub } = await this.prepare(stubData);\n const hasFile = await pathExists(stub.destination);\n const directory = dirname(stub.destination);\n if (!hasFile) {\n debug_default(\"writing file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"created\",\n skipReason: null,\n ...stub\n };\n }\n if (hasFile && force) {\n debug_default(\"overwriting file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"force_created\",\n skipReason: null,\n ...stub\n };\n }\n return {\n status: \"skipped\",\n skipReason: \"File already exists\",\n ...stub\n };\n }\n};\n\n// src/stubs/manager.ts\nvar StubsManager = class {\n #app;\n /**\n * Absolute path to the directory where stubs should\n * be published or read from with priority\n */\n #publishTarget;\n constructor(app, publishTarget) {\n this.#app = app;\n this.#publishTarget = publishTarget;\n }\n /**\n * Returns the path to the stubs source directory of a package\n */\n async #getPackageSource(packageName) {\n const pkgMainExports = await this.#app.import(packageName);\n if (!pkgMainExports.stubsRoot) {\n throw new RuntimeException2(\n `Cannot resolve stubs from package \"${packageName}\". Make sure the package entrypoint exports \"stubsRoot\" variable`\n );\n }\n return pkgMainExports.stubsRoot;\n }\n /**\n * Creates an instance of stub by its name. The lookup is performed inside\n * the publishTarget and the optional source or pkg destination.\n */\n async build(stubName, options) {\n const sources = [this.#publishTarget];\n if (options?.source) {\n sources.push(options.source);\n }\n if (options?.pkg) {\n sources.push(await this.#getPackageSource(options.pkg));\n }\n debug_default('finding stub \"%s\" in sources \"%O\"', stubName, sources);\n const file = await readFileFromSources(stubName, sources);\n if (!file) {\n throw new RuntimeException2(`Unable to find stub \"${stubName}\"`, {\n cause: `Scanned locations: \n${sources.join(\"\\n\")}`\n });\n }\n debug_default('building stub \"%s\"', file.filePath);\n return new Stub(this.#app, file.contents, file.filePath);\n }\n /**\n * Copy one or more stub files from a custom location to publish\n * target.\n */\n async copy(stubPath, options) {\n const filesCopied = [];\n const copyOptions = {\n recursive: true,\n force: options.overwrite === true ? true : false\n };\n const source = \"source\" in options ? join2(options.source, stubPath) : join2(await this.#getPackageSource(options.pkg), stubPath);\n try {\n const files = await fsReadAll(source, {\n filter: (path) => path === \"\" || path.endsWith(\".stub\")\n });\n debug_default('copying stubs from \"%s\" with options %O', source, copyOptions);\n debug_default('preparing to copy stubs \"%s\"', files);\n for (let filePath of files) {\n const sourcePath = join2(source, filePath);\n const destinationPath = join2(this.#publishTarget, stubPath, filePath);\n await cp(sourcePath, destinationPath, copyOptions);\n filesCopied.push(destinationPath);\n }\n return filesCopied;\n } catch (error) {\n if (error.code === \"ENOENT\") {\n const readingSource = \"source\" in options ? options.source : options.pkg;\n throw new Error(`Cannot find \"${stubPath}\" stub in \"${readingSource}\" destination`);\n }\n throw error;\n }\n }\n};\nexport {\n StubsManager\n};\n"],"names":["join","readFile","access","exports","StringBuilder","stringHelpers","RuntimeException","isAbsolute","string","tempura.compile","debug_default","dirname","mkdir","writeFile","RuntimeException2","join2","fsReadAll","cp"],"mappings":";;;;;;AAAA,MAAM,SAAS,UAAU,QAAQ;AAAA,EAChC,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAEA,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AAKb,SAAS,IAAI,OAAO,SAAS;AAC5B,YAAU,WAAW,CAAA;AAErB,MAAI,MAAM,KAAK,QAAQ;AACvB,MAAI,OAAO,MAAM,YAAY;AAC7B,MAAI,MAAI,IAAI,MAAI,IAAI,OAAO;AAE3B,MAAI,QAAM,QAAQ,UAAQ,CAAA,GAAI,QAAM,CAAA;AACpC,MAAI,WAAW,IAAI,IAAI,QAAQ,SAAO,CAAA,CAAE;AAExC,WAAS,QAAQ;AAChB,QAAI,IAAI,SAAS,GAAG;AACnB,cAAQ,MAAM,QAAQ,OAAO,MAAM,MAAM;AAAA,IAC1C,WAAW,IAAI,WAAW,GAAG;AAC5B,YAAM;AAAA,IACP;AACA,UAAM;AAAA,EACP;AAEA,SAAO,QAAQ,MAAM,KAAK,KAAK,GAAG;AACjC,WAAO,MAAM,UAAU,MAAM,MAAM,KAAK,EAAE,QAAQ,UAAU,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c;AAAA,MAClB,WAAW;AAAA,MACX,OAAO,QAAQ,cAAc,OAAO,OAAO;AAAA,IACjD;AACI,UAAM,SAAS,YAAY,UAAUK,WAAAA,KAAM,QAAQ,QAAQ,QAAQ,IAAIA,WAAAA,KAAM,MAAM,KAAK,kBAAkB,QAAQ,GAAG,GAAG,QAAQ;AAChI,QAAI;AACF,YAAM,QAAQ,MAAMC,MAAAA,UAAU,QAAQ;AAAA,QACpC,QAAQ,CAAC,SAAS,SAAS,MAAM,KAAK,SAAS,OAAO;AAAA,MAC9D,CAAO;AACDN,0BAAc,2CAA2C,QAAQ,WAAW;AAC5EA,YAAAA,cAAc,gCAAgC,KAAK;AACnD,eAAS,YAAY,OAAO;AAC1B,cAAM,aAAaK,WAAAA,KAAM,QAAQ,QAAQ;AACzC,cAAM,kBAAkBA,WAAAA,KAAM,KAAK,gBAAgB,UAAU,QAAQ;AACrE,cAAME,YAAG,YAAY,iBAAiB,WAAW;AACjD,oBAAY,KAAK,eAAe;AAAA,MAClC;AACA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,MAAM,SAAS,UAAU;AAC3B,cAAM,gBAAgB,YAAY,UAAU,QAAQ,SAAS,QAAQ;AACrE,cAAM,IAAI,MAAM,gBAAgB,QAAQ,cAAc,aAAa,eAAe;AAAA,MACpF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"manager-OLS5T3G7-BPVI59Zw.cjs","sources":["../node_modules/.pnpm/tempura@0.4.1/node_modules/tempura/dist/index.mjs","../node_modules/.pnpm/@adonisjs+application@8.4.2_@adonisjs+config@5.0.3_@adonisjs+fold@10.2.1/node_modules/@adonisjs/application/build/manager-OLS5T3G7.js"],"sourcesContent":["const ESCAPE = /[&\"<]/g, CHARS = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt',\n};\n\nconst ENDLINES = /[\\r\\n]+$/g;\nconst CURLY = /{{{?\\s*([\\s\\S]*?)\\s*}}}?/g;\nconst VAR = /(?:^|[-*+^|%/&=\\s])([a-zA-Z$_][\\w$]*)(?:(?=$|[-*+^|%/&=\\s]))/g;\nconst ARGS = /([a-zA-Z$_][^\\s=]*)\\s*=\\s*(([\"`'])(?:(?=(\\\\?))\\4.)*?\\3|{[^}]*}|\\[[^\\]]*]|\\S+)/g;\n\n// $$1 = escape()\n// $$2 = extra blocks\n// $$3 = template values\nfunction gen(input, options) {\n\toptions = options || {};\n\n\tlet char, num, action, tmp;\n\tlet last = CURLY.lastIndex = 0;\n\tlet wip='', txt='', match, inner;\n\n\tlet extra=options.blocks||{}, stack=[];\n\tlet initials = new Set(options.props||[]);\n\n\tfunction close() {\n\t\tif (wip.length > 0) {\n\t\t\ttxt += (txt ? 'x+=' : '=') + '`' + wip + '`;';\n\t\t} else if (txt.length === 0) {\n\t\t\ttxt = '=\"\";'\n\t\t}\n\t\twip = '';\n\t}\n\n\twhile (match = CURLY.exec(input)) {\n\t\twip += input.substring(last, match.index).replace(ENDLINES, '');\n\t\tlast = match.index + match[0].length;\n\n\t\tinner = match[1].trim();\n\t\tchar = inner.charAt(0);\n\n\t\tif (char === '!') {\n\t\t\t// comment, continue\n\t\t} else if (char === '#') {\n\t\t\tclose();\n\t\t\t[, action, inner] = /^#\\s*(\\w[\\w\\d]+)\\s*([^]*)/.exec(inner);\n\n\t\t\tif (action === 'expect') {\n\t\t\t\tinner.split(/[\\n\\r\\s\\t]*,[\\n\\r\\s\\t]*/g).forEach(key => {\n\t\t\t\t\tinitials.add(key);\n\t\t\t\t});\n\t\t\t} else if (action === 'var') {\n\t\t\t\tnum = inner.indexOf('=');\n\t\t\t\ttmp = inner.substring(0, num++).trim();\n\t\t\t\tinner = inner.substring(num).trim().replace(/[;]$/, '');\n\t\t\t\ttxt += `var ${tmp}=${inner};`;\n\t\t\t} else if (action === 'each') {\n\t\t\t\tnum = inner.indexOf(' as ');\n\t\t\t\tstack.push(action);\n\t\t\t\tif (!~num) {\n\t\t\t\t\ttxt += `for(var i=0,$$a=${inner};i<$$a.length;i++){`;\n\t\t\t\t} else {\n\t\t\t\t\ttmp = inner.substring(0, num).trim();\n\t\t\t\t\tinner = inner.substring(num + 4).trim();\n\t\t\t\t\tlet [item, idx='i'] = inner.replace(/[()\\s]/g, '').split(','); // (item, idx?)\n\t\t\t\t\ttxt += `for(var ${idx}=0,${item},$$a=${tmp};${idx}<$$a.length;${idx}++){${item}=$$a[${idx}];`;\n\t\t\t\t}\n\t\t\t} else if (action === 'if') {\n\t\t\t\ttxt += `if(${inner}){`;\n\t\t\t\tstack.push(action);\n\t\t\t} else if (action === 'elif') {\n\t\t\t\ttxt += `}else if(${inner}){`;\n\t\t\t} else if (action === 'else') {\n\t\t\t\ttxt += `}else{`;\n\t\t\t} else if (action in extra) {\n\t\t\t\tif (inner) {\n\t\t\t\t\ttmp = [];\n\t\t\t\t\t// parse arguments, `defer=true` -> `{ defer: true }`\n\t\t\t\t\twhile (match = ARGS.exec(inner)) tmp.push(match[1] + ':' + match[2]);\n\t\t\t\t\tinner = tmp.length ? '{' + tmp.join() + '}' : '';\n\t\t\t\t}\n\t\t\t\tinner = inner || '{}';\n\t\t\t\ttmp = options.async ? 'await ' : '';\n\t\t\t\twip += '${' + tmp + '$$2.' + action + '(' + inner + ',$$2)}';\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Unknown \"${action}\" block`);\n\t\t\t}\n\t\t} else if (char === '/') {\n\t\t\taction = inner.substring(1);\n\t\t\tinner = stack.pop();\n\t\t\tclose();\n\t\t\tif (action === inner) txt += '}';\n\t\t\telse throw new Error(`Expected to close \"${inner}\" block; closed \"${action}\" instead`);\n\t\t} else {\n\t\t\tif (match[0].charAt(2) === '{') wip += '${' + inner + '}'; // {{{ raw }}}\n\t\t\telse wip += '${$$1(' + inner + ')}';\n\t\t\tif (options.loose) {\n\t\t\t\twhile (tmp = VAR.exec(inner)) {\n\t\t\t\t\tinitials.add(tmp[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (stack.length > 0) {\n\t\tthrow new Error(`Unterminated \"${stack.pop()}\" block`);\n\t}\n\n\tif (last < input.length) {\n\t\twip += input.substring(last).replace(ENDLINES, '');\n\t}\n\n\tclose();\n\n\ttmp = initials.size ? `{${ [...initials].join() }}=$$3,x` : ' x';\n\treturn `var${tmp + txt}return x`;\n}\n\nexport function esc(value) {\n\tvalue = (value == null) ? '' : '' + value;\n\tlet last=ESCAPE.lastIndex=0, tmp=0, out='';\n\twhile (ESCAPE.test(value)) {\n\t\ttmp = ESCAPE.lastIndex - 1;\n\t\tout += value.substring(last, tmp) + CHARS[value[tmp]];\n\t\tlast = tmp + 1;\n\t}\n\treturn out + value.substring(last);\n}\n\nexport function compile(input, options={}) {\n\treturn new (options.async ? (async()=>{}).constructor : Function)(\n\t\t'$$1', '$$2', '$$3', gen(input, options)\n\t).bind(0, options.escape || esc, options.blocks);\n}\n\nexport function transform(input, options={}) {\n\treturn (\n\t\toptions.format === 'cjs'\n\t\t? 'var $$1=require(\"tempura\").esc;module.exports='\n\t\t: 'import{esc as $$1}from\"tempura\";export default '\n\t) + (\n\t\toptions.async ? 'async ' : ''\n\t) + 'function($$3,$$2){'+gen(input, options)+'}';\n}\n","import {\n debug_default\n} from \"./chunk-OVQD25FW.js\";\n\n// src/stubs/manager.ts\nimport { join as join2 } from \"path\";\nimport { cp } from \"fs/promises\";\nimport { RuntimeException as RuntimeException2, fsReadAll } from \"@poppinss/utils\";\n\n// src/stubs/stub.ts\nimport * as tempura from \"tempura\";\nimport string from \"@poppinss/utils/string\";\nimport { dirname, isAbsolute } from \"path\";\nimport { RuntimeException } from \"@poppinss/utils\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport stringHelpers from \"@poppinss/utils/string\";\nimport StringBuilder from \"@poppinss/utils/string_builder\";\n\n// src/helpers.ts\nimport { join } from \"path\";\nimport { access, readFile } from \"fs/promises\";\nasync function readFileFromSources(fileName, sources) {\n for (let source of sources) {\n const filePath = join(source, fileName);\n const contents = await readFileOptional(filePath);\n if (contents !== null) {\n return {\n contents,\n filePath,\n fileName,\n source\n };\n }\n }\n return null;\n}\nasync function readFileOptional(filePath) {\n try {\n return await readFile(filePath, \"utf-8\");\n } catch (error) {\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n return null;\n }\n}\nasync function pathExists(path) {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\nfunction parseStubExports(contents) {\n const chunks = contents.split(/\\r\\n|\\n/);\n const body = [];\n const exportedBlocks = [];\n chunks.forEach((line) => {\n if (line.includes(\"<!--EXPORT_START-->\")) {\n let [inital, rest] = line.split(\"<!--EXPORT_START-->\");\n let [exports, remaining] = rest.split(\"<!--EXPORT_END-->\");\n inital = inital.trim();\n remaining = remaining.trim();\n const remainingContents = inital && remaining ? `${inital}\n${remaining}` : inital || remaining || \"\";\n exportedBlocks.push(exports);\n if (remainingContents) {\n body.push(remainingContents);\n }\n } else {\n body.push(line);\n }\n });\n const attributes = exportedBlocks.reduce(\n (result, block) => {\n Object.assign(result, JSON.parse(block));\n return result;\n },\n {}\n );\n return { attributes, body: body.join(\"\\n\") };\n}\n\n// src/stubs/stub.ts\nfunction stubStringBuilder(value) {\n return new StringBuilder(value);\n}\nObject.assign(stubStringBuilder, stringHelpers);\nvar Stub = class {\n /**\n * The absolute path to the stub file. Need it for reporting\n * errors\n */\n #stubPath;\n /**\n * The contents of the stub to process\n */\n #stubContents;\n /**\n * Application class reference\n */\n #app;\n constructor(app, stubContents, stubPath) {\n this.#app = app;\n this.#stubPath = stubPath;\n this.#stubContents = stubContents;\n }\n /**\n * Patch error stack and point it to the stub file\n */\n #patchErrorStack(error) {\n const stack = error.stack.split(\"\\n\");\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Patch tempura error stack and point it to the stub file\n */\n #patchTempuraStack(error) {\n const stack = error.stack.split(\"\\n\");\n const templateErrorLine = stack[1].match(/<anonymous>:(\\d+):\\d+\\)$/);\n if (!templateErrorLine) {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n } else {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:${templateErrorLine[1]}:0)`);\n }\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Validates the \"to\" attribute\n */\n #validateToAttribute(attributes) {\n if (!attributes.to) {\n const error = new RuntimeException(`Missing \"to\" attribute in stub exports`);\n throw error;\n }\n if (!isAbsolute(attributes.to)) {\n const error = new RuntimeException(\n `The value for \"to\" attribute must be an absolute file path`\n );\n throw error;\n }\n }\n /**\n * Returns the default state for the stub\n */\n #getStubDefaults() {\n return {\n app: this.#app,\n randomString: string.random,\n generators: this.#app.generators,\n exports: (value) => {\n return `<!--EXPORT_START-->${JSON.stringify(value)}<!--EXPORT_END-->`;\n },\n string: stubStringBuilder\n };\n }\n /**\n * Renders stub using tempura templating syntax.\n */\n async #renderStub(data) {\n try {\n const render = tempura.compile(this.#stubContents, {\n props: Object.keys(data)\n });\n return render(data).trim();\n } catch (error) {\n this.#patchTempuraStack(error);\n throw error;\n }\n }\n /**\n * Parsers the stub exports\n */\n #parseExports(stubOutput) {\n try {\n const { body, attributes } = parseStubExports(stubOutput);\n this.#validateToAttribute(attributes);\n return { attributes, body };\n } catch (error) {\n this.#patchErrorStack(error);\n throw error;\n }\n }\n /**\n * Prepare stub to be written to the disk\n */\n async prepare(stubData) {\n const data = {\n ...this.#getStubDefaults(),\n ...stubData\n };\n const { attributes, body } = this.#parseExports(await this.#renderStub(data));\n debug_default(\"prepared stub %s\", body);\n debug_default(\"stub attributes %O\", attributes);\n return {\n contents: body,\n destination: attributes.to,\n force: stubData.force !== void 0 ? stubData.force : !!attributes.force,\n attributes\n };\n }\n /**\n * Generate resource for the stub. Writes file to the disk\n */\n async generate(stubData) {\n const { force, ...stub } = await this.prepare(stubData);\n const hasFile = await pathExists(stub.destination);\n const directory = dirname(stub.destination);\n if (!hasFile) {\n debug_default(\"writing file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"created\",\n skipReason: null,\n ...stub\n };\n }\n if (hasFile && force) {\n debug_default(\"overwriting file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"force_created\",\n skipReason: null,\n ...stub\n };\n }\n return {\n status: \"skipped\",\n skipReason: \"File already exists\",\n ...stub\n };\n }\n};\n\n// src/stubs/manager.ts\nvar StubsManager = class {\n #app;\n /**\n * Absolute path to the directory where stubs should\n * be published or read from with priority\n */\n #publishTarget;\n constructor(app, publishTarget) {\n this.#app = app;\n this.#publishTarget = publishTarget;\n }\n /**\n * Returns the path to the stubs source directory of a package\n */\n async #getPackageSource(packageName) {\n const pkgMainExports = await this.#app.import(packageName);\n if (!pkgMainExports.stubsRoot) {\n throw new RuntimeException2(\n `Cannot resolve stubs from package \"${packageName}\". Make sure the package entrypoint exports \"stubsRoot\" variable`\n );\n }\n return pkgMainExports.stubsRoot;\n }\n /**\n * Creates an instance of stub by its name. The lookup is performed inside\n * the publishTarget and the optional source or pkg destination.\n */\n async build(stubName, options) {\n const sources = [this.#publishTarget];\n if (options?.source) {\n sources.push(options.source);\n }\n if (options?.pkg) {\n sources.push(await this.#getPackageSource(options.pkg));\n }\n debug_default('finding stub \"%s\" in sources \"%O\"', stubName, sources);\n const file = await readFileFromSources(stubName, sources);\n if (!file) {\n throw new RuntimeException2(`Unable to find stub \"${stubName}\"`, {\n cause: `Scanned locations: \n${sources.join(\"\\n\")}`\n });\n }\n debug_default('building stub \"%s\"', file.filePath);\n return new Stub(this.#app, file.contents, file.filePath);\n }\n /**\n * Copy one or more stub files from a custom location to publish\n * target.\n */\n async copy(stubPath, options) {\n const filesCopied = [];\n const copyOptions = {\n recursive: true,\n force: options.overwrite === true ? true : false\n };\n const source = \"source\" in options ? join2(options.source, stubPath) : join2(await this.#getPackageSource(options.pkg), stubPath);\n try {\n const files = await fsReadAll(source, {\n filter: (path) => path === \"\" || path.endsWith(\".stub\")\n });\n debug_default('copying stubs from \"%s\" with options %O', source, copyOptions);\n debug_default('preparing to copy stubs \"%s\"', files);\n for (let filePath of files) {\n const sourcePath = join2(source, filePath);\n const destinationPath = join2(this.#publishTarget, stubPath, filePath);\n await cp(sourcePath, destinationPath, copyOptions);\n filesCopied.push(destinationPath);\n }\n return filesCopied;\n } catch (error) {\n if (error.code === \"ENOENT\") {\n const readingSource = \"source\" in options ? options.source : options.pkg;\n throw new Error(`Cannot find \"${stubPath}\" stub in \"${readingSource}\" destination`);\n }\n throw error;\n }\n }\n};\nexport {\n StubsManager\n};\n"],"names":["join","readFile","access","exports","StringBuilder","stringHelpers","RuntimeException","isAbsolute","string","tempura.compile","debug_default","dirname","mkdir","writeFile","RuntimeException2","join2","fsReadAll","cp"],"mappings":";;;;;;AAAA,MAAM,SAAS,UAAU,QAAQ;AAAA,EAChC,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAEA,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AAKb,SAAS,IAAI,OAAO,SAAS;AAC5B,YAAU,WAAW,CAAA;AAErB,MAAI,MAAM,KAAK,QAAQ;AACvB,MAAI,OAAO,MAAM,YAAY;AAC7B,MAAI,MAAI,IAAI,MAAI,IAAI,OAAO;AAE3B,MAAI,QAAM,QAAQ,UAAQ,CAAA,GAAI,QAAM,CAAA;AACpC,MAAI,WAAW,IAAI,IAAI,QAAQ,SAAO,CAAA,CAAE;AAExC,WAAS,QAAQ;AAChB,QAAI,IAAI,SAAS,GAAG;AACnB,cAAQ,MAAM,QAAQ,OAAO,MAAM,MAAM;AAAA,IAC1C,WAAW,IAAI,WAAW,GAAG;AAC5B,YAAM;AAAA,IACP;AACA,UAAM;AAAA,EACP;AAEA,SAAO,QAAQ,MAAM,KAAK,KAAK,GAAG;AACjC,WAAO,MAAM,UAAU,MAAM,MAAM,KAAK,EAAE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ACpB,UAAM,cAAc;AAAA,MAClB,WAAW;AAAA,MACX,OAAO,QAAQ,cAAc,OAAO,OAAO;AAAA,IACjD;AACI,UAAM,SAAS,YAAY,UAAUK,WAAAA,KAAM,QAAQ,QAAQ,QAAQ,IAAIA,WAAAA,KAAM,MAAM,KAAK,kBAAkB,QAAQ,GAAG,GAAG,QAAQ;AAChI,QAAI;AACF,YAAM,QAAQ,MAAMC,MAAAA,UAAU,QAAQ;AAAA,QACpC,QAAQ,CAAC,SAAS,SAAS,MAAM,KAAK,SAAS,OAAO;AAAA,MAC9D,CAAO;AACDN,0BAAc,2CAA2C,QAAQ,WAAW;AAC5EA,YAAAA,cAAc,gCAAgC,KAAK;AACnD,eAAS,YAAY,OAAO;AAC1B,cAAM,aAAaK,WAAAA,KAAM,QAAQ,QAAQ;AACzC,cAAM,kBAAkBA,WAAAA,KAAM,KAAK,gBAAgB,UAAU,QAAQ;AACrE,cAAME,YAAG,YAAY,iBAAiB,WAAW;AACjD,oBAAY,KAAK,eAAe;AAAA,MAClC;AACA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,MAAM,SAAS,UAAU;AAC3B,cAAM,gBAAgB,YAAY,UAAU,QAAQ,SAAS,QAAQ;AACrE,cAAM,IAAI,MAAM,gBAAgB,QAAQ,cAAc,aAAa,eAAe;AAAA,MACpF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;;","x_google_ignoreList":[0,1]}
@@ -1,4 +1,4 @@
1
- import { d as debug_default, m as main_default, s as string_builder_default } from "./index-Bsyx9Sty.js";
1
+ import { d as debug_default, m as main_default, s as string_builder_default } from "./index-B-5JiNqG.js";
2
2
  import { join, isAbsolute, dirname } from "path";
3
3
  import { cp, mkdir, writeFile, readFile, access } from "fs/promises";
4
4
  import { RuntimeException, fsReadAll } from "@poppinss/utils";
@@ -415,4 +415,4 @@ ${sources.join("\n")}`
415
415
  export {
416
416
  StubsManager
417
417
  };
418
- //# sourceMappingURL=manager-OLS5T3G7-C-NS6lhx.js.map
418
+ //# sourceMappingURL=manager-OLS5T3G7-DzVckqOB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-OLS5T3G7-C-NS6lhx.js","sources":["../node_modules/.pnpm/tempura@0.4.1/node_modules/tempura/dist/index.mjs","../node_modules/.pnpm/@adonisjs+application@8.4.2_@adonisjs+config@5.0.3_@adonisjs+fold@10.2.1/node_modules/@adonisjs/application/build/manager-OLS5T3G7.js"],"sourcesContent":["const ESCAPE = /[&\"<]/g, CHARS = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt',\n};\n\nconst ENDLINES = /[\\r\\n]+$/g;\nconst CURLY = /{{{?\\s*([\\s\\S]*?)\\s*}}}?/g;\nconst VAR = /(?:^|[-*+^|%/&=\\s])([a-zA-Z$_][\\w$]*)(?:(?=$|[-*+^|%/&=\\s]))/g;\nconst ARGS = /([a-zA-Z$_][^\\s=]*)\\s*=\\s*(([\"`'])(?:(?=(\\\\?))\\4.)*?\\3|{[^}]*}|\\[[^\\]]*]|\\S+)/g;\n\n// $$1 = escape()\n// $$2 = extra blocks\n// $$3 = template values\nfunction gen(input, options) {\n\toptions = options || {};\n\n\tlet char, num, action, tmp;\n\tlet last = CURLY.lastIndex = 0;\n\tlet wip='', txt='', match, inner;\n\n\tlet extra=options.blocks||{}, stack=[];\n\tlet initials = new Set(options.props||[]);\n\n\tfunction close() {\n\t\tif (wip.length > 0) {\n\t\t\ttxt += (txt ? 'x+=' : '=') + '`' + wip + '`;';\n\t\t} else if (txt.length === 0) {\n\t\t\ttxt = '=\"\";'\n\t\t}\n\t\twip = '';\n\t}\n\n\twhile (match = CURLY.exec(input)) {\n\t\twip += input.substring(last, match.index).replace(ENDLINES, '');\n\t\tlast = match.index + match[0].length;\n\n\t\tinner = match[1].trim();\n\t\tchar = inner.charAt(0);\n\n\t\tif (char === '!') {\n\t\t\t// comment, continue\n\t\t} else if (char === '#') {\n\t\t\tclose();\n\t\t\t[, action, inner] = /^#\\s*(\\w[\\w\\d]+)\\s*([^]*)/.exec(inner);\n\n\t\t\tif (action === 'expect') {\n\t\t\t\tinner.split(/[\\n\\r\\s\\t]*,[\\n\\r\\s\\t]*/g).forEach(key => {\n\t\t\t\t\tinitials.add(key);\n\t\t\t\t});\n\t\t\t} else if (action === 'var') {\n\t\t\t\tnum = inner.indexOf('=');\n\t\t\t\ttmp = inner.substring(0, num++).trim();\n\t\t\t\tinner = inner.substring(num).trim().replace(/[;]$/, '');\n\t\t\t\ttxt += `var ${tmp}=${inner};`;\n\t\t\t} else if (action === 'each') {\n\t\t\t\tnum = inner.indexOf(' as ');\n\t\t\t\tstack.push(action);\n\t\t\t\tif (!~num) {\n\t\t\t\t\ttxt += `for(var i=0,$$a=${inner};i<$$a.length;i++){`;\n\t\t\t\t} else {\n\t\t\t\t\ttmp = inner.substring(0, num).trim();\n\t\t\t\t\tinner = inner.substring(num + 4).trim();\n\t\t\t\t\tlet [item, idx='i'] = inner.replace(/[()\\s]/g, '').split(','); // (item, idx?)\n\t\t\t\t\ttxt += `for(var ${idx}=0,${item},$$a=${tmp};${idx}<$$a.length;${idx}++){${item}=$$a[${idx}];`;\n\t\t\t\t}\n\t\t\t} else if (action === 'if') {\n\t\t\t\ttxt += `if(${inner}){`;\n\t\t\t\tstack.push(action);\n\t\t\t} else if (action === 'elif') {\n\t\t\t\ttxt += `}else if(${inner}){`;\n\t\t\t} else if (action === 'else') {\n\t\t\t\ttxt += `}else{`;\n\t\t\t} else if (action in extra) {\n\t\t\t\tif (inner) {\n\t\t\t\t\ttmp = [];\n\t\t\t\t\t// parse arguments, `defer=true` -> `{ defer: true }`\n\t\t\t\t\twhile (match = ARGS.exec(inner)) tmp.push(match[1] + ':' + match[2]);\n\t\t\t\t\tinner = tmp.length ? '{' + tmp.join() + '}' : '';\n\t\t\t\t}\n\t\t\t\tinner = inner || '{}';\n\t\t\t\ttmp = options.async ? 'await ' : '';\n\t\t\t\twip += '${' + tmp + '$$2.' + action + '(' + inner + ',$$2)}';\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Unknown \"${action}\" block`);\n\t\t\t}\n\t\t} else if (char === '/') {\n\t\t\taction = inner.substring(1);\n\t\t\tinner = stack.pop();\n\t\t\tclose();\n\t\t\tif (action === inner) txt += '}';\n\t\t\telse throw new Error(`Expected to close \"${inner}\" block; closed \"${action}\" instead`);\n\t\t} else {\n\t\t\tif (match[0].charAt(2) === '{') wip += '${' + inner + '}'; // {{{ raw }}}\n\t\t\telse wip += '${$$1(' + inner + ')}';\n\t\t\tif (options.loose) {\n\t\t\t\twhile (tmp = VAR.exec(inner)) {\n\t\t\t\t\tinitials.add(tmp[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (stack.length > 0) {\n\t\tthrow new Error(`Unterminated \"${stack.pop()}\" block`);\n\t}\n\n\tif (last < input.length) {\n\t\twip += input.substring(last).replace(ENDLINES, '');\n\t}\n\n\tclose();\n\n\ttmp = initials.size ? `{${ [...initials].join() }}=$$3,x` : ' x';\n\treturn `var${tmp + txt}return x`;\n}\n\nexport function esc(value) {\n\tvalue = (value == null) ? '' : '' + value;\n\tlet last=ESCAPE.lastIndex=0, tmp=0, out='';\n\twhile (ESCAPE.test(value)) {\n\t\ttmp = ESCAPE.lastIndex - 1;\n\t\tout += value.substring(last, tmp) + CHARS[value[tmp]];\n\t\tlast = tmp + 1;\n\t}\n\treturn out + value.substring(last);\n}\n\nexport function compile(input, options={}) {\n\treturn new (options.async ? (async()=>{}).constructor : Function)(\n\t\t'$$1', '$$2', '$$3', gen(input, options)\n\t).bind(0, options.escape || esc, options.blocks);\n}\n\nexport function transform(input, options={}) {\n\treturn (\n\t\toptions.format === 'cjs'\n\t\t? 'var $$1=require(\"tempura\").esc;module.exports='\n\t\t: 'import{esc as $$1}from\"tempura\";export default '\n\t) + (\n\t\toptions.async ? 'async ' : ''\n\t) + 'function($$3,$$2){'+gen(input, options)+'}';\n}\n","import {\n debug_default\n} from \"./chunk-OVQD25FW.js\";\n\n// src/stubs/manager.ts\nimport { join as join2 } from \"path\";\nimport { cp } from \"fs/promises\";\nimport { RuntimeException as RuntimeException2, fsReadAll } from \"@poppinss/utils\";\n\n// src/stubs/stub.ts\nimport * as tempura from \"tempura\";\nimport string from \"@poppinss/utils/string\";\nimport { dirname, isAbsolute } from \"path\";\nimport { RuntimeException } from \"@poppinss/utils\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport stringHelpers from \"@poppinss/utils/string\";\nimport StringBuilder from \"@poppinss/utils/string_builder\";\n\n// src/helpers.ts\nimport { join } from \"path\";\nimport { access, readFile } from \"fs/promises\";\nasync function readFileFromSources(fileName, sources) {\n for (let source of sources) {\n const filePath = join(source, fileName);\n const contents = await readFileOptional(filePath);\n if (contents !== null) {\n return {\n contents,\n filePath,\n fileName,\n source\n };\n }\n }\n return null;\n}\nasync function readFileOptional(filePath) {\n try {\n return await readFile(filePath, \"utf-8\");\n } catch (error) {\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n return null;\n }\n}\nasync function pathExists(path) {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\nfunction parseStubExports(contents) {\n const chunks = contents.split(/\\r\\n|\\n/);\n const body = [];\n const exportedBlocks = [];\n chunks.forEach((line) => {\n if (line.includes(\"<!--EXPORT_START-->\")) {\n let [inital, rest] = line.split(\"<!--EXPORT_START-->\");\n let [exports, remaining] = rest.split(\"<!--EXPORT_END-->\");\n inital = inital.trim();\n remaining = remaining.trim();\n const remainingContents = inital && remaining ? `${inital}\n${remaining}` : inital || remaining || \"\";\n exportedBlocks.push(exports);\n if (remainingContents) {\n body.push(remainingContents);\n }\n } else {\n body.push(line);\n }\n });\n const attributes = exportedBlocks.reduce(\n (result, block) => {\n Object.assign(result, JSON.parse(block));\n return result;\n },\n {}\n );\n return { attributes, body: body.join(\"\\n\") };\n}\n\n// src/stubs/stub.ts\nfunction stubStringBuilder(value) {\n return new StringBuilder(value);\n}\nObject.assign(stubStringBuilder, stringHelpers);\nvar Stub = class {\n /**\n * The absolute path to the stub file. Need it for reporting\n * errors\n */\n #stubPath;\n /**\n * The contents of the stub to process\n */\n #stubContents;\n /**\n * Application class reference\n */\n #app;\n constructor(app, stubContents, stubPath) {\n this.#app = app;\n this.#stubPath = stubPath;\n this.#stubContents = stubContents;\n }\n /**\n * Patch error stack and point it to the stub file\n */\n #patchErrorStack(error) {\n const stack = error.stack.split(\"\\n\");\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Patch tempura error stack and point it to the stub file\n */\n #patchTempuraStack(error) {\n const stack = error.stack.split(\"\\n\");\n const templateErrorLine = stack[1].match(/<anonymous>:(\\d+):\\d+\\)$/);\n if (!templateErrorLine) {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n } else {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:${templateErrorLine[1]}:0)`);\n }\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Validates the \"to\" attribute\n */\n #validateToAttribute(attributes) {\n if (!attributes.to) {\n const error = new RuntimeException(`Missing \"to\" attribute in stub exports`);\n throw error;\n }\n if (!isAbsolute(attributes.to)) {\n const error = new RuntimeException(\n `The value for \"to\" attribute must be an absolute file path`\n );\n throw error;\n }\n }\n /**\n * Returns the default state for the stub\n */\n #getStubDefaults() {\n return {\n app: this.#app,\n randomString: string.random,\n generators: this.#app.generators,\n exports: (value) => {\n return `<!--EXPORT_START-->${JSON.stringify(value)}<!--EXPORT_END-->`;\n },\n string: stubStringBuilder\n };\n }\n /**\n * Renders stub using tempura templating syntax.\n */\n async #renderStub(data) {\n try {\n const render = tempura.compile(this.#stubContents, {\n props: Object.keys(data)\n });\n return render(data).trim();\n } catch (error) {\n this.#patchTempuraStack(error);\n throw error;\n }\n }\n /**\n * Parsers the stub exports\n */\n #parseExports(stubOutput) {\n try {\n const { body, attributes } = parseStubExports(stubOutput);\n this.#validateToAttribute(attributes);\n return { attributes, body };\n } catch (error) {\n this.#patchErrorStack(error);\n throw error;\n }\n }\n /**\n * Prepare stub to be written to the disk\n */\n async prepare(stubData) {\n const data = {\n ...this.#getStubDefaults(),\n ...stubData\n };\n const { attributes, body } = this.#parseExports(await this.#renderStub(data));\n debug_default(\"prepared stub %s\", body);\n debug_default(\"stub attributes %O\", attributes);\n return {\n contents: body,\n destination: attributes.to,\n force: stubData.force !== void 0 ? stubData.force : !!attributes.force,\n attributes\n };\n }\n /**\n * Generate resource for the stub. Writes file to the disk\n */\n async generate(stubData) {\n const { force, ...stub } = await this.prepare(stubData);\n const hasFile = await pathExists(stub.destination);\n const directory = dirname(stub.destination);\n if (!hasFile) {\n debug_default(\"writing file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"created\",\n skipReason: null,\n ...stub\n };\n }\n if (hasFile && force) {\n debug_default(\"overwriting file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"force_created\",\n skipReason: null,\n ...stub\n };\n }\n return {\n status: \"skipped\",\n skipReason: \"File already exists\",\n ...stub\n };\n }\n};\n\n// src/stubs/manager.ts\nvar StubsManager = class {\n #app;\n /**\n * Absolute path to the directory where stubs should\n * be published or read from with priority\n */\n #publishTarget;\n constructor(app, publishTarget) {\n this.#app = app;\n this.#publishTarget = publishTarget;\n }\n /**\n * Returns the path to the stubs source directory of a package\n */\n async #getPackageSource(packageName) {\n const pkgMainExports = await this.#app.import(packageName);\n if (!pkgMainExports.stubsRoot) {\n throw new RuntimeException2(\n `Cannot resolve stubs from package \"${packageName}\". Make sure the package entrypoint exports \"stubsRoot\" variable`\n );\n }\n return pkgMainExports.stubsRoot;\n }\n /**\n * Creates an instance of stub by its name. The lookup is performed inside\n * the publishTarget and the optional source or pkg destination.\n */\n async build(stubName, options) {\n const sources = [this.#publishTarget];\n if (options?.source) {\n sources.push(options.source);\n }\n if (options?.pkg) {\n sources.push(await this.#getPackageSource(options.pkg));\n }\n debug_default('finding stub \"%s\" in sources \"%O\"', stubName, sources);\n const file = await readFileFromSources(stubName, sources);\n if (!file) {\n throw new RuntimeException2(`Unable to find stub \"${stubName}\"`, {\n cause: `Scanned locations: \n${sources.join(\"\\n\")}`\n });\n }\n debug_default('building stub \"%s\"', file.filePath);\n return new Stub(this.#app, file.contents, file.filePath);\n }\n /**\n * Copy one or more stub files from a custom location to publish\n * target.\n */\n async copy(stubPath, options) {\n const filesCopied = [];\n const copyOptions = {\n recursive: true,\n force: options.overwrite === true ? true : false\n };\n const source = \"source\" in options ? join2(options.source, stubPath) : join2(await this.#getPackageSource(options.pkg), stubPath);\n try {\n const files = await fsReadAll(source, {\n filter: (path) => path === \"\" || path.endsWith(\".stub\")\n });\n debug_default('copying stubs from \"%s\" with options %O', source, copyOptions);\n debug_default('preparing to copy stubs \"%s\"', files);\n for (let filePath of files) {\n const sourcePath = join2(source, filePath);\n const destinationPath = join2(this.#publishTarget, stubPath, filePath);\n await cp(sourcePath, destinationPath, copyOptions);\n filesCopied.push(destinationPath);\n }\n return filesCopied;\n } catch (error) {\n if (error.code === \"ENOENT\") {\n const readingSource = \"source\" in options ? options.source : options.pkg;\n throw new Error(`Cannot find \"${stubPath}\" stub in \"${readingSource}\" destination`);\n }\n throw error;\n }\n }\n};\nexport {\n StubsManager\n};\n"],"names":["exports","StringBuilder","stringHelpers","string","tempura.compile","RuntimeException2","join2"],"mappings":";;;;AAAA,MAAM,SAAS,UAAU,QAAQ;AAAA,EAChC,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAEA,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AAKb,SAAS,IAAI,OAAO,SAAS;AAC5B,YAAU,WAAW,CAAA;AAErB,MAAI,MAAM,KAAK,QAAQ;AACvB,MAAI,OAAO,MAAM,YAAY;AAC7B,MAAI,MAAI,IAAI,MAAI,IAAI,OAAO;AAE3B,MAAI,QAAM,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,CAAC;AAAA,MACpB,CAAO;AAAA,IACH;AACA,kBAAc,sBAAsB,KAAK,QAAQ;AACjD,WAAO,IAAI,KAAK,KAAK,MAAM,KAAK,UAAU,KAAK,QAAQ;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,UAAU,SAAS;AAC5B,UAAM,cAAc,CAAA;AACpB,UAAM,cAAc;AAAA,MAClB,WAAW;AAAA,MACX,OAAO,QAAQ,cAAc,OAAO,OAAO;AAAA,IACjD;AACI,UAAM,SAAS,YAAY,UAAUC,KAAM,QAAQ,QAAQ,QAAQ,IAAIA,KAAM,MAAM,KAAK,kBAAkB,QAAQ,GAAG,GAAG,QAAQ;AAChI,QAAI;AACF,YAAM,QAAQ,MAAM,UAAU,QAAQ;AAAA,QACpC,QAAQ,CAAC,SAAS,SAAS,MAAM,KAAK,SAAS,OAAO;AAAA,MAC9D,CAAO;AACD,oBAAc,2CAA2C,QAAQ,WAAW;AAC5E,oBAAc,gCAAgC,KAAK;AACnD,eAAS,YAAY,OAAO;AAC1B,cAAM,aAAaA,KAAM,QAAQ,QAAQ;AACzC,cAAM,kBAAkBA,KAAM,KAAK,gBAAgB,UAAU,QAAQ;AACrE,cAAM,GAAG,YAAY,iBAAiB,WAAW;AACjD,oBAAY,KAAK,eAAe;AAAA,MAClC;AACA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,MAAM,SAAS,UAAU;AAC3B,cAAM,gBAAgB,YAAY,UAAU,QAAQ,SAAS,QAAQ;AACrE,cAAM,IAAI,MAAM,gBAAgB,QAAQ,cAAc,aAAa,eAAe;AAAA,MACpF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"manager-OLS5T3G7-DzVckqOB.js","sources":["../node_modules/.pnpm/tempura@0.4.1/node_modules/tempura/dist/index.mjs","../node_modules/.pnpm/@adonisjs+application@8.4.2_@adonisjs+config@5.0.3_@adonisjs+fold@10.2.1/node_modules/@adonisjs/application/build/manager-OLS5T3G7.js"],"sourcesContent":["const ESCAPE = /[&\"<]/g, CHARS = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt',\n};\n\nconst ENDLINES = /[\\r\\n]+$/g;\nconst CURLY = /{{{?\\s*([\\s\\S]*?)\\s*}}}?/g;\nconst VAR = /(?:^|[-*+^|%/&=\\s])([a-zA-Z$_][\\w$]*)(?:(?=$|[-*+^|%/&=\\s]))/g;\nconst ARGS = /([a-zA-Z$_][^\\s=]*)\\s*=\\s*(([\"`'])(?:(?=(\\\\?))\\4.)*?\\3|{[^}]*}|\\[[^\\]]*]|\\S+)/g;\n\n// $$1 = escape()\n// $$2 = extra blocks\n// $$3 = template values\nfunction gen(input, options) {\n\toptions = options || {};\n\n\tlet char, num, action, tmp;\n\tlet last = CURLY.lastIndex = 0;\n\tlet wip='', txt='', match, inner;\n\n\tlet extra=options.blocks||{}, stack=[];\n\tlet initials = new Set(options.props||[]);\n\n\tfunction close() {\n\t\tif (wip.length > 0) {\n\t\t\ttxt += (txt ? 'x+=' : '=') + '`' + wip + '`;';\n\t\t} else if (txt.length === 0) {\n\t\t\ttxt = '=\"\";'\n\t\t}\n\t\twip = '';\n\t}\n\n\twhile (match = CURLY.exec(input)) {\n\t\twip += input.substring(last, match.index).replace(ENDLINES, '');\n\t\tlast = match.index + match[0].length;\n\n\t\tinner = match[1].trim();\n\t\tchar = inner.charAt(0);\n\n\t\tif (char === '!') {\n\t\t\t// comment, continue\n\t\t} else if (char === '#') {\n\t\t\tclose();\n\t\t\t[, action, inner] = /^#\\s*(\\w[\\w\\d]+)\\s*([^]*)/.exec(inner);\n\n\t\t\tif (action === 'expect') {\n\t\t\t\tinner.split(/[\\n\\r\\s\\t]*,[\\n\\r\\s\\t]*/g).forEach(key => {\n\t\t\t\t\tinitials.add(key);\n\t\t\t\t});\n\t\t\t} else if (action === 'var') {\n\t\t\t\tnum = inner.indexOf('=');\n\t\t\t\ttmp = inner.substring(0, num++).trim();\n\t\t\t\tinner = inner.substring(num).trim().replace(/[;]$/, '');\n\t\t\t\ttxt += `var ${tmp}=${inner};`;\n\t\t\t} else if (action === 'each') {\n\t\t\t\tnum = inner.indexOf(' as ');\n\t\t\t\tstack.push(action);\n\t\t\t\tif (!~num) {\n\t\t\t\t\ttxt += `for(var i=0,$$a=${inner};i<$$a.length;i++){`;\n\t\t\t\t} else {\n\t\t\t\t\ttmp = inner.substring(0, num).trim();\n\t\t\t\t\tinner = inner.substring(num + 4).trim();\n\t\t\t\t\tlet [item, idx='i'] = inner.replace(/[()\\s]/g, '').split(','); // (item, idx?)\n\t\t\t\t\ttxt += `for(var ${idx}=0,${item},$$a=${tmp};${idx}<$$a.length;${idx}++){${item}=$$a[${idx}];`;\n\t\t\t\t}\n\t\t\t} else if (action === 'if') {\n\t\t\t\ttxt += `if(${inner}){`;\n\t\t\t\tstack.push(action);\n\t\t\t} else if (action === 'elif') {\n\t\t\t\ttxt += `}else if(${inner}){`;\n\t\t\t} else if (action === 'else') {\n\t\t\t\ttxt += `}else{`;\n\t\t\t} else if (action in extra) {\n\t\t\t\tif (inner) {\n\t\t\t\t\ttmp = [];\n\t\t\t\t\t// parse arguments, `defer=true` -> `{ defer: true }`\n\t\t\t\t\twhile (match = ARGS.exec(inner)) tmp.push(match[1] + ':' + match[2]);\n\t\t\t\t\tinner = tmp.length ? '{' + tmp.join() + '}' : '';\n\t\t\t\t}\n\t\t\t\tinner = inner || '{}';\n\t\t\t\ttmp = options.async ? 'await ' : '';\n\t\t\t\twip += '${' + tmp + '$$2.' + action + '(' + inner + ',$$2)}';\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Unknown \"${action}\" block`);\n\t\t\t}\n\t\t} else if (char === '/') {\n\t\t\taction = inner.substring(1);\n\t\t\tinner = stack.pop();\n\t\t\tclose();\n\t\t\tif (action === inner) txt += '}';\n\t\t\telse throw new Error(`Expected to close \"${inner}\" block; closed \"${action}\" instead`);\n\t\t} else {\n\t\t\tif (match[0].charAt(2) === '{') wip += '${' + inner + '}'; // {{{ raw }}}\n\t\t\telse wip += '${$$1(' + inner + ')}';\n\t\t\tif (options.loose) {\n\t\t\t\twhile (tmp = VAR.exec(inner)) {\n\t\t\t\t\tinitials.add(tmp[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (stack.length > 0) {\n\t\tthrow new Error(`Unterminated \"${stack.pop()}\" block`);\n\t}\n\n\tif (last < input.length) {\n\t\twip += input.substring(last).replace(ENDLINES, '');\n\t}\n\n\tclose();\n\n\ttmp = initials.size ? `{${ [...initials].join() }}=$$3,x` : ' x';\n\treturn `var${tmp + txt}return x`;\n}\n\nexport function esc(value) {\n\tvalue = (value == null) ? '' : '' + value;\n\tlet last=ESCAPE.lastIndex=0, tmp=0, out='';\n\twhile (ESCAPE.test(value)) {\n\t\ttmp = ESCAPE.lastIndex - 1;\n\t\tout += value.substring(last, tmp) + CHARS[value[tmp]];\n\t\tlast = tmp + 1;\n\t}\n\treturn out + value.substring(last);\n}\n\nexport function compile(input, options={}) {\n\treturn new (options.async ? (async()=>{}).constructor : Function)(\n\t\t'$$1', '$$2', '$$3', gen(input, options)\n\t).bind(0, options.escape || esc, options.blocks);\n}\n\nexport function transform(input, options={}) {\n\treturn (\n\t\toptions.format === 'cjs'\n\t\t? 'var $$1=require(\"tempura\").esc;module.exports='\n\t\t: 'import{esc as $$1}from\"tempura\";export default '\n\t) + (\n\t\toptions.async ? 'async ' : ''\n\t) + 'function($$3,$$2){'+gen(input, options)+'}';\n}\n","import {\n debug_default\n} from \"./chunk-OVQD25FW.js\";\n\n// src/stubs/manager.ts\nimport { join as join2 } from \"path\";\nimport { cp } from \"fs/promises\";\nimport { RuntimeException as RuntimeException2, fsReadAll } from \"@poppinss/utils\";\n\n// src/stubs/stub.ts\nimport * as tempura from \"tempura\";\nimport string from \"@poppinss/utils/string\";\nimport { dirname, isAbsolute } from \"path\";\nimport { RuntimeException } from \"@poppinss/utils\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport stringHelpers from \"@poppinss/utils/string\";\nimport StringBuilder from \"@poppinss/utils/string_builder\";\n\n// src/helpers.ts\nimport { join } from \"path\";\nimport { access, readFile } from \"fs/promises\";\nasync function readFileFromSources(fileName, sources) {\n for (let source of sources) {\n const filePath = join(source, fileName);\n const contents = await readFileOptional(filePath);\n if (contents !== null) {\n return {\n contents,\n filePath,\n fileName,\n source\n };\n }\n }\n return null;\n}\nasync function readFileOptional(filePath) {\n try {\n return await readFile(filePath, \"utf-8\");\n } catch (error) {\n if (error.code !== \"ENOENT\") {\n throw error;\n }\n return null;\n }\n}\nasync function pathExists(path) {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\nfunction parseStubExports(contents) {\n const chunks = contents.split(/\\r\\n|\\n/);\n const body = [];\n const exportedBlocks = [];\n chunks.forEach((line) => {\n if (line.includes(\"<!--EXPORT_START-->\")) {\n let [inital, rest] = line.split(\"<!--EXPORT_START-->\");\n let [exports, remaining] = rest.split(\"<!--EXPORT_END-->\");\n inital = inital.trim();\n remaining = remaining.trim();\n const remainingContents = inital && remaining ? `${inital}\n${remaining}` : inital || remaining || \"\";\n exportedBlocks.push(exports);\n if (remainingContents) {\n body.push(remainingContents);\n }\n } else {\n body.push(line);\n }\n });\n const attributes = exportedBlocks.reduce(\n (result, block) => {\n Object.assign(result, JSON.parse(block));\n return result;\n },\n {}\n );\n return { attributes, body: body.join(\"\\n\") };\n}\n\n// src/stubs/stub.ts\nfunction stubStringBuilder(value) {\n return new StringBuilder(value);\n}\nObject.assign(stubStringBuilder, stringHelpers);\nvar Stub = class {\n /**\n * The absolute path to the stub file. Need it for reporting\n * errors\n */\n #stubPath;\n /**\n * The contents of the stub to process\n */\n #stubContents;\n /**\n * Application class reference\n */\n #app;\n constructor(app, stubContents, stubPath) {\n this.#app = app;\n this.#stubPath = stubPath;\n this.#stubContents = stubContents;\n }\n /**\n * Patch error stack and point it to the stub file\n */\n #patchErrorStack(error) {\n const stack = error.stack.split(\"\\n\");\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Patch tempura error stack and point it to the stub file\n */\n #patchTempuraStack(error) {\n const stack = error.stack.split(\"\\n\");\n const templateErrorLine = stack[1].match(/<anonymous>:(\\d+):\\d+\\)$/);\n if (!templateErrorLine) {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:0:0)`);\n } else {\n stack.splice(1, 0, ` at anonymous (${this.#stubPath}:${templateErrorLine[1]}:0)`);\n }\n error.stack = stack.join(\"\\n\");\n }\n /**\n * Validates the \"to\" attribute\n */\n #validateToAttribute(attributes) {\n if (!attributes.to) {\n const error = new RuntimeException(`Missing \"to\" attribute in stub exports`);\n throw error;\n }\n if (!isAbsolute(attributes.to)) {\n const error = new RuntimeException(\n `The value for \"to\" attribute must be an absolute file path`\n );\n throw error;\n }\n }\n /**\n * Returns the default state for the stub\n */\n #getStubDefaults() {\n return {\n app: this.#app,\n randomString: string.random,\n generators: this.#app.generators,\n exports: (value) => {\n return `<!--EXPORT_START-->${JSON.stringify(value)}<!--EXPORT_END-->`;\n },\n string: stubStringBuilder\n };\n }\n /**\n * Renders stub using tempura templating syntax.\n */\n async #renderStub(data) {\n try {\n const render = tempura.compile(this.#stubContents, {\n props: Object.keys(data)\n });\n return render(data).trim();\n } catch (error) {\n this.#patchTempuraStack(error);\n throw error;\n }\n }\n /**\n * Parsers the stub exports\n */\n #parseExports(stubOutput) {\n try {\n const { body, attributes } = parseStubExports(stubOutput);\n this.#validateToAttribute(attributes);\n return { attributes, body };\n } catch (error) {\n this.#patchErrorStack(error);\n throw error;\n }\n }\n /**\n * Prepare stub to be written to the disk\n */\n async prepare(stubData) {\n const data = {\n ...this.#getStubDefaults(),\n ...stubData\n };\n const { attributes, body } = this.#parseExports(await this.#renderStub(data));\n debug_default(\"prepared stub %s\", body);\n debug_default(\"stub attributes %O\", attributes);\n return {\n contents: body,\n destination: attributes.to,\n force: stubData.force !== void 0 ? stubData.force : !!attributes.force,\n attributes\n };\n }\n /**\n * Generate resource for the stub. Writes file to the disk\n */\n async generate(stubData) {\n const { force, ...stub } = await this.prepare(stubData);\n const hasFile = await pathExists(stub.destination);\n const directory = dirname(stub.destination);\n if (!hasFile) {\n debug_default(\"writing file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"created\",\n skipReason: null,\n ...stub\n };\n }\n if (hasFile && force) {\n debug_default(\"overwriting file to %s\", stub.destination);\n await mkdir(directory, { recursive: true });\n await writeFile(stub.destination, stub.contents);\n return {\n status: \"force_created\",\n skipReason: null,\n ...stub\n };\n }\n return {\n status: \"skipped\",\n skipReason: \"File already exists\",\n ...stub\n };\n }\n};\n\n// src/stubs/manager.ts\nvar StubsManager = class {\n #app;\n /**\n * Absolute path to the directory where stubs should\n * be published or read from with priority\n */\n #publishTarget;\n constructor(app, publishTarget) {\n this.#app = app;\n this.#publishTarget = publishTarget;\n }\n /**\n * Returns the path to the stubs source directory of a package\n */\n async #getPackageSource(packageName) {\n const pkgMainExports = await this.#app.import(packageName);\n if (!pkgMainExports.stubsRoot) {\n throw new RuntimeException2(\n `Cannot resolve stubs from package \"${packageName}\". Make sure the package entrypoint exports \"stubsRoot\" variable`\n );\n }\n return pkgMainExports.stubsRoot;\n }\n /**\n * Creates an instance of stub by its name. The lookup is performed inside\n * the publishTarget and the optional source or pkg destination.\n */\n async build(stubName, options) {\n const sources = [this.#publishTarget];\n if (options?.source) {\n sources.push(options.source);\n }\n if (options?.pkg) {\n sources.push(await this.#getPackageSource(options.pkg));\n }\n debug_default('finding stub \"%s\" in sources \"%O\"', stubName, sources);\n const file = await readFileFromSources(stubName, sources);\n if (!file) {\n throw new RuntimeException2(`Unable to find stub \"${stubName}\"`, {\n cause: `Scanned locations: \n${sources.join(\"\\n\")}`\n });\n }\n debug_default('building stub \"%s\"', file.filePath);\n return new Stub(this.#app, file.contents, file.filePath);\n }\n /**\n * Copy one or more stub files from a custom location to publish\n * target.\n */\n async copy(stubPath, options) {\n const filesCopied = [];\n const copyOptions = {\n recursive: true,\n force: options.overwrite === true ? true : false\n };\n const source = \"source\" in options ? join2(options.source, stubPath) : join2(await this.#getPackageSource(options.pkg), stubPath);\n try {\n const files = await fsReadAll(source, {\n filter: (path) => path === \"\" || path.endsWith(\".stub\")\n });\n debug_default('copying stubs from \"%s\" with options %O', source, copyOptions);\n debug_default('preparing to copy stubs \"%s\"', files);\n for (let filePath of files) {\n const sourcePath = join2(source, filePath);\n const destinationPath = join2(this.#publishTarget, stubPath, filePath);\n await cp(sourcePath, destinationPath, copyOptions);\n filesCopied.push(destinationPath);\n }\n return filesCopied;\n } catch (error) {\n if (error.code === \"ENOENT\") {\n const readingSource = \"source\" in options ? options.source : options.pkg;\n throw new Error(`Cannot find \"${stubPath}\" stub in \"${readingSource}\" destination`);\n }\n throw error;\n }\n }\n};\nexport {\n StubsManager\n};\n"],"names":["exports","StringBuilder","stringHelpers","string","tempura.compile","RuntimeException2","join2"],"mappings":";;;;AAAA,MAAM,SAAS,UAAU,QAAQ;AAAA,EAChC,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAEA,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AAKb,SAAS,IAAI,OAAO,SAAS;AAC5B,YAAU,WAAW,CAAA;AAErB,MAAI,MAAM,KAAK,QAAQ;AACvB,MAAI,OAAO,MAAM,YAAY;AAC7B,MAAI,MAAI,IAAI,MAAI,IAAI,OAAO;AAE3B,MAAI,QAAM,QAAQ,UAAQ,CAAA,GAAI,QAAM,CAAA;AACpC,MAAI,WAAW,IAAI,IAAI,QAAQ,SAAO,CAAA,CAAE;AAExC,WAAS,QAAQ;AAChB,QAAI,IAAI,SAAS,GAAG;AACnB,cAAQ,MAAM,QAAQ,OAAO,MAAM,MAAM;AAAA,IAC1C,WAAW,IAAI,WAAW,GAAG;AAC5B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pB,UAAM,cAAc;AAAA,MAClB,WAAW;AAAA,MACX,OAAO,QAAQ,cAAc,OAAO,OAAO;AAAA,IACjD;AACI,UAAM,SAAS,YAAY,UAAUC,KAAM,QAAQ,QAAQ,QAAQ,IAAIA,KAAM,MAAM,KAAK,kBAAkB,QAAQ,GAAG,GAAG,QAAQ;AAChI,QAAI;AACF,YAAM,QAAQ,MAAM,UAAU,QAAQ;AAAA,QACpC,QAAQ,CAAC,SAAS,SAAS,MAAM,KAAK,SAAS,OAAO;AAAA,MAC9D,CAAO;AACD,oBAAc,2CAA2C,QAAQ,WAAW;AAC5E,oBAAc,gCAAgC,KAAK;AACnD,eAAS,YAAY,OAAO;AAC1B,cAAM,aAAaA,KAAM,QAAQ,QAAQ;AACzC,cAAM,kBAAkBA,KAAM,KAAK,gBAAgB,UAAU,QAAQ;AACrE,cAAM,GAAG,YAAY,iBAAiB,WAAW;AACjD,oBAAY,KAAK,eAAe;AAAA,MAClC;AACA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,MAAM,SAAS,UAAU;AAC3B,cAAM,gBAAgB,YAAY,UAAU,QAAQ,SAAS,QAAQ;AACrE,cAAM,IAAI,MAAM,gBAAgB,QAAQ,cAAc,aAAa,eAAe;AAAA,MACpF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","x_google_ignoreList":[0,1]}
@@ -1,3 +1,3 @@
1
- import type { ResolvedODataContext } from '../private/odata_macro/services/odata_context_service'
1
+ import type { ResolvedODataContext } from "../private/odata_macro/services/odata_context_service";
2
2
  export declare const useODataContext: () => Promise<ResolvedODataContext>;
3
3
  export type { ResolvedODataContext };
package/odata/macro.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  * @module @nhtio/lucid-resourceful/odata/macro
4
4
  */
5
5
  import type { Response } from '@adonisjs/core/http';
6
- import type { Element, ElementCompact, Options } from '../bundled_xml_js';
6
+ import type { Element, ElementCompact, Options } from "../bundled_xml_js";
7
7
  export declare function odataXmlResponseMacro(this: Response, status: number, payload: Element | ElementCompact, options?: Options.JS2XML, xmlContentType?: string): Response;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const index = require("./index-ClMDgRfH.cjs");
3
- const index$1 = require("./index-CpyTnwZV.cjs");
3
+ const index$1 = require("./index-CQApAM0M.cjs");
4
4
  const errors = require("./errors-jr8bQS6M.cjs");
5
5
  const ODataResponseFormat = ["xml", "json"];
6
6
  const negotiateContent = (ctx, fallback = "json") => {
@@ -244,7 +244,7 @@ class ODataErrorMiddleware {
244
244
  const help = "help" in error && "string" === typeof error.help ? error.help : void 0;
245
245
  let details = Array.isArray(error.messages) ? error.messages.map((m) => {
246
246
  return errors.stripUndefinedValuesFromObject({
247
- code: m.rule ? index$1.index_default.snakeCase(m.rule).toUpperCase() : "E_VALIDATION_ERROR",
247
+ code: m.rule ? index$1.string_default.snakeCase(m.rule).toUpperCase() : "E_VALIDATION_ERROR",
248
248
  message: m.message || "Validation error",
249
249
  target: m.field
250
250
  });
@@ -274,7 +274,7 @@ class ODataErrorMiddleware {
274
274
  const help = "help" in error && "string" === typeof error.help ? error.help : void 0;
275
275
  let details = Array.isArray(error.details) ? error.details.map((d) => {
276
276
  return errors.stripUndefinedValuesFromObject({
277
- code: index$1.index_default.snakeCase(d.type).toUpperCase(),
277
+ code: index$1.string_default.snakeCase(d.type).toUpperCase(),
278
278
  message: d.message || "Validation error",
279
279
  target: d.path.length > 0 ? d.path.join(".") : void 0,
280
280
  context: d.context || void 0
@@ -363,4 +363,4 @@ exports.ODataErrorMiddleware = ODataErrorMiddleware;
363
363
  exports.negotiateContent = negotiateContent;
364
364
  exports.negotiateMetadata = negotiateMetadata;
365
365
  exports.negotiatePreference = negotiatePreference;
366
- //# sourceMappingURL=odata_error_middleware-BWfOpQZV.cjs.map
366
+ //# sourceMappingURL=odata_error_middleware-DhLzccN7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"odata_error_middleware-BWfOpQZV.cjs","sources":["../src/private/odata_macro/utils/http.ts","../src/private/odata_macro/middlewares/odata_error_middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http'\n\nexport const ODataResponseFormat = ['xml' as 'xml', 'json' as 'json']\nexport type ODataResponseFormat = (typeof ODataResponseFormat)[number]\n\nexport const negotiateContent = (\n ctx: HttpContext,\n fallback: ODataResponseFormat = 'json'\n): ODataResponseFormat => {\n for (const acceptable of ODataResponseFormat) {\n const query = ctx.request.qs()\n if ('string' === typeof query['$format'] && query['$format'].includes(acceptable)) {\n return acceptable\n }\n if (ctx.request.header('accept')?.includes(acceptable)) {\n return acceptable\n }\n }\n return fallback\n}\n\nexport const ODataMetadataLevel = ['full' as 'full', 'minimal' as 'minimal', 'none' as 'none']\nexport type ODataMetadataLevel = (typeof ODataMetadataLevel)[number]\n\nexport const negotiateMetadata = (\n ctx: HttpContext,\n fallback: ODataMetadataLevel = 'minimal'\n): ODataMetadataLevel => {\n for (const acceptable of ODataMetadataLevel) {\n const query = ctx.request.qs()\n if (\n 'string' === typeof query['$format'] &&\n query['$format'].includes(`metadata=${acceptable}`)\n ) {\n return acceptable\n }\n if (ctx.request.header('accept')?.includes(`metadata=${acceptable}`)) {\n return acceptable\n }\n }\n return fallback\n}\n\nexport const ODataPreference = ['representation' as 'representation', 'minimal' as 'minimal']\nexport type ODataPreference = (typeof ODataPreference)[number]\n\nexport const negotiatePreference = (\n ctx: HttpContext,\n fallback: ODataPreference = 'representation'\n): ODataPreference => {\n const prefer = ctx.request.header('prefer')\n if (prefer) {\n for (const acceptable of ODataPreference) {\n if (prefer.includes(acceptable)) {\n return acceptable\n }\n }\n }\n return fallback\n}\n","/*\n|--------------------------------------------------------------------------\n| Resourceful Error Middleware\n|--------------------------------------------------------------------------\n|\n| Intercepts errors thrown during http requests and formats the responses\n| in a consistent manner meant to be easily consumed by clients.\n|\n| While designed specifically to work with Lucid Resourceful, there is no\n| reason it cannot be applied to non-resourceful routes as well.\n*/\nimport { js2xml } from 'xml-js'\nimport { errors } from '@vinejs/vine'\nimport { Exception } from '@poppinss/utils'\nimport { negotiateContent } from '../utils/http'\nimport { default as string } from '@poppinss/string'\nimport { TypedEventEmitter } from '@nhtio/tiny-typed-emitter'\nimport { isObject, stripUndefinedValuesFromObject } from '../../utils'\nimport { ValidationError as JoiValidationError } from '@nhtio/lucid-resourceful/joi'\nimport {\n isError,\n isException,\n isJoiValidationError,\n isVineValidationError,\n isNotImplementedError,\n} from '../../router_macro/utils/errors'\nimport type { JsonObject } from 'type-fest'\nimport type { ElementCompact } from 'xml-js'\nimport type { HttpContext } from '@adonisjs/core/http'\nimport type { NextFn } from '@adonisjs/core/types/http'\nimport type { EventMap } from '@nhtio/tiny-typed-emitter'\n/**\n * Type alias for Vine validation errors thrown by the VineJS validation library.\n *\n * @example\n * ```typescript\n * try {\n * await vine.validate(schema, data)\n * } catch (error) {\n * if (isVineValidationError(error)) {\n * // Handle Vine validation error\n * }\n * }\n * ```\n */\nexport type VineValidationError = InstanceType<typeof errors.E_VALIDATION_ERROR>\n\n/**\n * Event map defining the types of errors that can be emitted by the ODataErrorMiddleware.\n * Each event type maps to the specific error instance that will be passed to event handlers.\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error)\n * })\n * ```\n */\nexport type ODataErrorMiddlewareEvents = EventMap<{\n vineValidationError: [VineValidationError]\n joiValidationError: [JoiValidationError]\n exception: [Exception]\n error: [Error]\n unknown: [unknown]\n any: [unknown]\n}>\n\nclass ODataErrorMiddlewareEmitter extends TypedEventEmitter<ODataErrorMiddlewareEvents> {}\n\n/**\n * Configuration object for custom HTTP headers to be included in error responses.\n * Allows for CORS headers, security headers, API versioning, or any custom headers\n * that should be consistently applied to all error responses.\n *\n * @example\n * ```typescript\n * const headers: ODataErrorMiddlewareHeaders = {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*',\n * 'X-RateLimit-Remaining': '100'\n * }\n * ```\n */\nexport interface ODataErrorMiddlewareHeaders {\n [key: string]: string\n}\n\n/**\n * Configuration options for the ODataErrorMiddleware class.\n * Defines event handlers for different error types and response formatting options.\n *\n * @example\n * ```typescript\n * const options: ODataErrorMiddlewareOptions = {\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error),\n * asYaml: true,\n * headers: {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * }\n * ```\n */\nexport interface ODataErrorMiddlewareOptions {\n /** Event handler called when a Vine validation error is encountered */\n onVineValidationError?: (error: VineValidationError) => void\n /** Event handler called when a Joi validation error is encountered */\n onJoiValidationError?: (error: JoiValidationError) => void\n /** Event handler called when a framework Exception is encountered */\n onException?: (error: Exception) => void\n /** Event handler called when a generic Error is encountered */\n onError?: (error: Error) => void\n /** Event handler called when an unknown error type is encountered */\n onUnknown?: (error: unknown) => void\n /** Event handler called for any error that occurs, regardless of type */\n onAny?: (error: unknown) => void\n /** Whether to support YAML response format. Defaults to true */\n asYaml?: boolean\n /** Custom headers to include in all error responses */\n headers?: ODataErrorMiddlewareHeaders\n}\n\n/**\n * Individual error detail within a formatted error response.\n * Provides field-level information for validation errors or error chain details.\n *\n * @example\n * ```typescript\n * const detail: ResourcefulFormattedErrorDetails = {\n * code: 'E_REQUIRED',\n * message: 'The email field is required',\n * target: 'email',\n * context: { field: 'email', value: null }\n * }\n * ```\n */\nexport interface ResourcefulFormattedErrorDetails {\n /** Machine-readable error code (e.g., 'E_REQUIRED', 'E_INVALID_FORMAT') */\n code: string\n /** Human-readable error message */\n message: string\n /** The field or property that caused the error (for validation errors) */\n target?: string\n /** Additional context information about the error */\n context?: JsonObject\n}\n\n/**\n * Standardized error response format used by the ODataErrorMiddleware.\n * Provides consistent structure for all API error responses with support for\n * field-level validation details and error chaining.\n *\n * @example\n * ```typescript\n * const formattedError: ResourcefulFormattedError = {\n * status: 422,\n * code: 'E_VALIDATION_ERROR',\n * message: 'Validation failed',\n * help: 'Check the provided field values',\n * details: [\n * {\n * code: 'E_REQUIRED',\n * message: 'The email field is required',\n * target: 'email'\n * }\n * ]\n * }\n * ```\n */\nexport interface ResourcefulFormattedError {\n /** HTTP status code for the error response */\n status: number\n /** Machine-readable error code */\n code: string\n /** Human-readable error message */\n message: string\n /** Optional help text providing guidance on how to resolve the error */\n help?: string\n /** Array of detailed error information, typically for validation errors */\n details?: ResourcefulFormattedErrorDetails[]\n}\n\n/**\n * AdonisJS middleware that intercepts errors thrown during HTTP requests and formats\n * the responses in a consistent, client-friendly manner. Supports multiple error types\n * including Vine validation errors, Joi validation errors, framework exceptions, and\n * generic errors.\n *\n * The middleware provides:\n * - Consistent error response formatting across all error types\n * - Event-driven error handling for monitoring and logging\n * - Content negotiation supporting JSON and YAML responses\n * - Recursive error cause handling to preserve error chains\n * - Configurable headers for CORS, security, and custom requirements\n *\n * @example\n * ```typescript\n * // Basic usage with default configuration\n * const middleware = new ODataErrorMiddleware({})\n * router.use(middleware.handle)\n *\n * // Advanced usage with event handlers and custom headers\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error),\n * headers: {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * })\n * router.use(middleware.handle)\n * ```\n *\n * @example\n * ```typescript\n * // Standalone usage outside of resourceful routes\n * import ODataErrorMiddleware from '@nhtio/lucid-resourceful/middlewares/resourceful_error'\n *\n * const errorHandler = new ODataErrorMiddleware({\n * onException: (error) => logger.error(error),\n * headers: { 'X-Error-Handler': 'resourceful' }\n * })\n *\n * router.use(errorHandler.handle)\n * ```\n */\nexport class ODataErrorMiddleware {\n /**\n * Creates a usable middleware function that can be applied directly to AdonisJS routes.\n * @param opts - Configuration options for the middleware\n * @returns A middleware function that can be used in AdonisJS routes\n */\n public static usable(opts: ODataErrorMiddlewareOptions = {}) {\n const instance = new ODataErrorMiddleware(opts)\n return (ctx: HttpContext, next: NextFn) => instance.handle(ctx, next)\n }\n\n /**\n * Handles errors thrown during request processing. This method is meant to be integrated with the AdonisJS HttpExceptionHandler\n * @param error - The error that was thrown\n * @param ctx - The HTTP context object\n * @param opts - Configuration options for the middleware\n * @returns A Promise that resolves to the error response\n */\n public static handle(error: unknown, ctx: HttpContext, opts: ODataErrorMiddlewareOptions = {}) {\n const instance = new ODataErrorMiddleware(opts)\n return instance.onError(ctx, error)\n }\n\n /**\n * Determines if the middleware should handle the request based on the desired response format.\n * If the desired format is HTML, it returns false to allow other handlers to process the request.\n * Otherwise, it returns true to indicate that this middleware should handle the error response.\n *\n * @param ctx - The HTTP context object containing request and response information\n * @returns A boolean indicating whether this middleware should handle the request\n */\n public static shouldHandle(_ctx: HttpContext): boolean {\n return true\n }\n\n readonly #emitter: ODataErrorMiddlewareEmitter\n readonly #asYaml: boolean\n readonly #headers: ODataErrorMiddlewareHeaders\n\n /**\n * Creates a new instance of ODataErrorMiddleware with the specified configuration.\n *\n * @param opts - Configuration options for the middleware\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => console.error('Validation:', error),\n * onException: (error) => monitoring.captureException(error),\n * asYaml: true,\n * headers: { 'X-API-Version': '1.0' }\n * })\n * ```\n */\n constructor(opts: ODataErrorMiddlewareOptions) {\n this.#emitter = new ODataErrorMiddlewareEmitter()\n // asYaml defaults to `true`\n this.#asYaml = false !== opts.asYaml\n // headers defaults to an empty object\n this.#headers = isObject(opts.headers) ? opts.headers : {}\n if ('function' === typeof opts.onVineValidationError) {\n this.#emitter.once('vineValidationError', opts.onVineValidationError)\n }\n if ('function' === typeof opts.onJoiValidationError) {\n this.#emitter.once('joiValidationError', opts.onJoiValidationError)\n }\n if ('function' === typeof opts.onException) {\n this.#emitter.once('exception', opts.onException)\n }\n if ('function' === typeof opts.onError) {\n this.#emitter.once('error', opts.onError)\n }\n if ('function' === typeof opts.onUnknown) {\n this.#emitter.once('unknown', opts.onUnknown)\n }\n if ('function' === typeof opts.onAny) {\n this.#emitter.once('any', opts.onAny)\n }\n }\n\n /**\n * AdonisJS middleware handler that intercepts and processes errors during request execution.\n * This method should be used as middleware in your route definitions.\n *\n * @param ctx - The HTTP context object containing request and response information\n * @param next - The next function to call in the middleware chain\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({})\n * router.use(middleware.handle)\n *\n * // Or bind it to specific routes\n * router.get('/api/users', UserController.index).use([middleware.handle])\n * ```\n */\n async handle(ctx: HttpContext, next: NextFn) {\n try {\n await next()\n } catch (error) {\n return this.onError(ctx, error)\n }\n }\n\n /**\n * Processes a caught error, emits appropriate events, and sends a formatted response.\n * This method handles error classification, event emission, content negotiation,\n * and response formatting.\n *\n * @param ctx - The HTTP context object\n * @param error - The error that was caught during request processing\n *\n * @example\n * ```typescript\n * // Typically called automatically by the handle method, but can be used directly\n * try {\n * // Some operation that might throw\n * } catch (error) {\n * middleware.onError(ctx, error)\n * }\n * ```\n */\n onError(ctx: HttpContext, error: unknown) {\n this.#emitter.emit('any', error)\n switch (true) {\n case isVineValidationError(error):\n this.#emitter.emit('vineValidationError', error)\n break\n\n case isJoiValidationError(error):\n this.#emitter.emit('joiValidationError', error)\n break\n\n case isException(error):\n this.#emitter.emit('exception', error)\n break\n\n case isError(error):\n this.#emitter.emit('error', error)\n break\n\n default:\n this.#emitter.emit('unknown', error)\n break\n }\n const format = negotiateContent(ctx)\n // if the desired format is HTML, break early since that needs to be handled elsewhere\n const formattedError = this.#getFormattedError(error)\n ctx.response.status(formattedError.status)\n Object.entries(this.#headers).forEach(([key, value]) => {\n ctx.response.header(key, value)\n })\n switch (true) {\n case 'xml' === format && this.#asYaml:\n return this.#sendAsXml(ctx, formattedError)\n\n default:\n return this.#sendAsJson(ctx, formattedError)\n }\n }\n\n #sendAsJson(ctx: HttpContext, formattedError: ResourcefulFormattedError) {\n ctx.response.header('Content-Type', 'application/json')\n ctx.response.send(\n JSON.stringify({\n error: stripUndefinedValuesFromObject({\n ...formattedError,\n status: undefined,\n }),\n })\n )\n }\n\n #sendAsXml(ctx: HttpContext, formattedError: ResourcefulFormattedError) {\n const payload: ElementCompact = {\n '_declaration': { _attributes: { version: '1.0', encoding: 'UTF-8' } },\n 'm:error': {\n '_attributes': {\n 'xmlns:m': 'http://docs.oasis-open.org/odata/ns/metadata',\n },\n 'm:code': { _text: formattedError.code },\n 'm:message': { _text: formattedError.message },\n ...(formattedError.details &&\n formattedError.details.length > 0 && {\n 'm:details': formattedError.details.map((detail) => ({\n 'm:detail': {\n 'm:code': { _text: detail.code },\n 'm:message': { _text: detail.message },\n ...(detail.target && { 'm:target': { _text: detail.target } }),\n },\n })),\n }),\n },\n }\n\n ctx.response.header('Content-Type', 'application/xml')\n ctx.response.header('OData-Version', '4.0')\n ctx.response.send(js2xml(payload, { compact: true, spaces: 2 }))\n }\n\n #getFormattedError(error: unknown): ResourcefulFormattedError {\n switch (true) {\n case isVineValidationError(error):\n return this.#formatVineValidationError(error)\n\n case isJoiValidationError(error):\n return this.#formatJoiValidationError(error)\n\n case isException(error):\n return this.#formatException(error)\n\n case isError(error):\n return this.#formatError(error)\n\n default:\n return this.#formatUnknown(error)\n }\n }\n\n #formatVineValidationError(error: VineValidationError): ResourcefulFormattedError {\n const status: number = error.status || 422\n const code: string = error.code || 'E_VALIDATION_ERROR'\n const message: string = error.messages || 'Validation failed'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n let details: ResourcefulFormattedErrorDetails[] | undefined = Array.isArray(error.messages)\n ? error.messages.map((m) => {\n return stripUndefinedValuesFromObject({\n code: m.rule ? string.snakeCase(m.rule).toUpperCase() : 'E_VALIDATION_ERROR',\n message: m.message || 'Validation error',\n target: m.field,\n })\n })\n : undefined\n if (error.cause) {\n if (!details) {\n details = []\n }\n const formattedCause = this.#getFormattedError(error.cause)\n details.push({\n code: formattedCause.code,\n message: formattedCause.message,\n })\n }\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatJoiValidationError(error: JoiValidationError): ResourcefulFormattedError {\n const status: number = 422\n const code: string = 'E_VALIDATION_ERROR'\n const message: string = error.message || 'Validation failed'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n let details: ResourcefulFormattedErrorDetails[] | undefined = Array.isArray(error.details)\n ? error.details.map((d) => {\n return stripUndefinedValuesFromObject({\n code: string.snakeCase(d.type).toUpperCase(),\n message: d.message || 'Validation error',\n target: d.path.length > 0 ? d.path.join('.') : undefined,\n context: d.context || undefined,\n })\n })\n : undefined\n if (error.cause) {\n if (!details) {\n details = []\n }\n const formattedCause = this.#getFormattedError(error.cause)\n details.push({\n code: formattedCause.code,\n message: formattedCause.message,\n })\n }\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatException(error: Exception): ResourcefulFormattedError {\n const status: number = error.status || 500\n const code: string = error.code || 'E_EXCEPTION'\n const message: string = error.message || 'An exception occurred'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause = error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatError(error: Error): ResourcefulFormattedError {\n const status: number = isNotImplementedError(error) ? 501 : 500\n const code: string = 'E_ERROR'\n const message: string = error.message || 'An error occurred'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause = error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatUnknown(error: unknown): ResourcefulFormattedError {\n const status: number = 500\n const code: string = 'E_UNKNOWN_ERROR'\n const message: string = 'An unknown error occurred'\n const help: string | undefined =\n isObject(error) && 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause =\n isObject(error) && error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n}\n"],"names":["TypedEventEmitter","isObject","isVineValidationError","isJoiValidationError","isException","isError","stripUndefinedValuesFromObject","js2xml","string","isNotImplementedError"],"mappings":";;;;AAEO,MAAM,sBAAsB,CAAC,OAAgB,MAAgB;AAG7D,MAAM,mBAAmB,CAC9B,KACA,WAAgC,WACR;AACxB,aAAW,cAAc,qBAAqB;AAC5C,UAAM,QAAQ,IAAI,QAAQ,GAAA;AAC1B,QAAI,aAAa,OAAO,MAAM,SAAS,KAAK,MAAM,SAAS,EAAE,SAAS,UAAU,GAAG;AACjF,aAAO;AAAA,IACT;AACA,QAAI,IAAI,QAAQ,OAAO,QAAQ,GAAG,SAAS,UAAU,GAAG;AACtD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,QAAkB,WAAwB,MAAgB;AAGtF,MAAM,oBAAoB,CAC/B,KACA,WAA+B,cACR;AACvB,aAAW,cAAc,oBAAoB;AAC3C,UAAM,QAAQ,IAAI,QAAQ,GAAA;AAC1B,QACE,aAAa,OAAO,MAAM,SAAS,KACnC,MAAM,SAAS,EAAE,SAAS,YAAY,UAAU,EAAE,GAClD;AACA,aAAO;AAAA,IACT;AACA,QAAI,IAAI,QAAQ,OAAO,QAAQ,GAAG,SAAS,YAA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AAe;AAAA,MAAA,CACzB;AAAA,IAAA,IAEH;AACJ,WAAOA,sCAA+B;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AACF;;;;;"}
1
+ {"version":3,"file":"odata_error_middleware-DhLzccN7.cjs","sources":["../src/private/odata_macro/utils/http.ts","../src/private/odata_macro/middlewares/odata_error_middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http'\n\nexport const ODataResponseFormat = ['xml' as 'xml', 'json' as 'json']\nexport type ODataResponseFormat = (typeof ODataResponseFormat)[number]\n\nexport const negotiateContent = (\n ctx: HttpContext,\n fallback: ODataResponseFormat = 'json'\n): ODataResponseFormat => {\n for (const acceptable of ODataResponseFormat) {\n const query = ctx.request.qs()\n if ('string' === typeof query['$format'] && query['$format'].includes(acceptable)) {\n return acceptable\n }\n if (ctx.request.header('accept')?.includes(acceptable)) {\n return acceptable\n }\n }\n return fallback\n}\n\nexport const ODataMetadataLevel = ['full' as 'full', 'minimal' as 'minimal', 'none' as 'none']\nexport type ODataMetadataLevel = (typeof ODataMetadataLevel)[number]\n\nexport const negotiateMetadata = (\n ctx: HttpContext,\n fallback: ODataMetadataLevel = 'minimal'\n): ODataMetadataLevel => {\n for (const acceptable of ODataMetadataLevel) {\n const query = ctx.request.qs()\n if (\n 'string' === typeof query['$format'] &&\n query['$format'].includes(`metadata=${acceptable}`)\n ) {\n return acceptable\n }\n if (ctx.request.header('accept')?.includes(`metadata=${acceptable}`)) {\n return acceptable\n }\n }\n return fallback\n}\n\nexport const ODataPreference = ['representation' as 'representation', 'minimal' as 'minimal']\nexport type ODataPreference = (typeof ODataPreference)[number]\n\nexport const negotiatePreference = (\n ctx: HttpContext,\n fallback: ODataPreference = 'representation'\n): ODataPreference => {\n const prefer = ctx.request.header('prefer')\n if (prefer) {\n for (const acceptable of ODataPreference) {\n if (prefer.includes(acceptable)) {\n return acceptable\n }\n }\n }\n return fallback\n}\n","/*\n|--------------------------------------------------------------------------\n| Resourceful Error Middleware\n|--------------------------------------------------------------------------\n|\n| Intercepts errors thrown during http requests and formats the responses\n| in a consistent manner meant to be easily consumed by clients.\n|\n| While designed specifically to work with Lucid Resourceful, there is no\n| reason it cannot be applied to non-resourceful routes as well.\n*/\nimport { js2xml } from 'xml-js'\nimport { errors } from '@vinejs/vine'\nimport { Exception } from '@poppinss/utils'\nimport { negotiateContent } from '../utils/http'\nimport { default as string } from '@poppinss/string'\nimport { TypedEventEmitter } from '@nhtio/tiny-typed-emitter'\nimport { isObject, stripUndefinedValuesFromObject } from '../../utils'\nimport { ValidationError as JoiValidationError } from '@nhtio/lucid-resourceful/joi'\nimport {\n isError,\n isException,\n isJoiValidationError,\n isVineValidationError,\n isNotImplementedError,\n} from '../../router_macro/utils/errors'\nimport type { JsonObject } from 'type-fest'\nimport type { ElementCompact } from 'xml-js'\nimport type { HttpContext } from '@adonisjs/core/http'\nimport type { NextFn } from '@adonisjs/core/types/http'\nimport type { EventMap } from '@nhtio/tiny-typed-emitter'\n/**\n * Type alias for Vine validation errors thrown by the VineJS validation library.\n *\n * @example\n * ```typescript\n * try {\n * await vine.validate(schema, data)\n * } catch (error) {\n * if (isVineValidationError(error)) {\n * // Handle Vine validation error\n * }\n * }\n * ```\n */\nexport type VineValidationError = InstanceType<typeof errors.E_VALIDATION_ERROR>\n\n/**\n * Event map defining the types of errors that can be emitted by the ODataErrorMiddleware.\n * Each event type maps to the specific error instance that will be passed to event handlers.\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error)\n * })\n * ```\n */\nexport type ODataErrorMiddlewareEvents = EventMap<{\n vineValidationError: [VineValidationError]\n joiValidationError: [JoiValidationError]\n exception: [Exception]\n error: [Error]\n unknown: [unknown]\n any: [unknown]\n}>\n\nclass ODataErrorMiddlewareEmitter extends TypedEventEmitter<ODataErrorMiddlewareEvents> {}\n\n/**\n * Configuration object for custom HTTP headers to be included in error responses.\n * Allows for CORS headers, security headers, API versioning, or any custom headers\n * that should be consistently applied to all error responses.\n *\n * @example\n * ```typescript\n * const headers: ODataErrorMiddlewareHeaders = {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*',\n * 'X-RateLimit-Remaining': '100'\n * }\n * ```\n */\nexport interface ODataErrorMiddlewareHeaders {\n [key: string]: string\n}\n\n/**\n * Configuration options for the ODataErrorMiddleware class.\n * Defines event handlers for different error types and response formatting options.\n *\n * @example\n * ```typescript\n * const options: ODataErrorMiddlewareOptions = {\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error),\n * asYaml: true,\n * headers: {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * }\n * ```\n */\nexport interface ODataErrorMiddlewareOptions {\n /** Event handler called when a Vine validation error is encountered */\n onVineValidationError?: (error: VineValidationError) => void\n /** Event handler called when a Joi validation error is encountered */\n onJoiValidationError?: (error: JoiValidationError) => void\n /** Event handler called when a framework Exception is encountered */\n onException?: (error: Exception) => void\n /** Event handler called when a generic Error is encountered */\n onError?: (error: Error) => void\n /** Event handler called when an unknown error type is encountered */\n onUnknown?: (error: unknown) => void\n /** Event handler called for any error that occurs, regardless of type */\n onAny?: (error: unknown) => void\n /** Whether to support YAML response format. Defaults to true */\n asYaml?: boolean\n /** Custom headers to include in all error responses */\n headers?: ODataErrorMiddlewareHeaders\n}\n\n/**\n * Individual error detail within a formatted error response.\n * Provides field-level information for validation errors or error chain details.\n *\n * @example\n * ```typescript\n * const detail: ResourcefulFormattedErrorDetails = {\n * code: 'E_REQUIRED',\n * message: 'The email field is required',\n * target: 'email',\n * context: { field: 'email', value: null }\n * }\n * ```\n */\nexport interface ResourcefulFormattedErrorDetails {\n /** Machine-readable error code (e.g., 'E_REQUIRED', 'E_INVALID_FORMAT') */\n code: string\n /** Human-readable error message */\n message: string\n /** The field or property that caused the error (for validation errors) */\n target?: string\n /** Additional context information about the error */\n context?: JsonObject\n}\n\n/**\n * Standardized error response format used by the ODataErrorMiddleware.\n * Provides consistent structure for all API error responses with support for\n * field-level validation details and error chaining.\n *\n * @example\n * ```typescript\n * const formattedError: ResourcefulFormattedError = {\n * status: 422,\n * code: 'E_VALIDATION_ERROR',\n * message: 'Validation failed',\n * help: 'Check the provided field values',\n * details: [\n * {\n * code: 'E_REQUIRED',\n * message: 'The email field is required',\n * target: 'email'\n * }\n * ]\n * }\n * ```\n */\nexport interface ResourcefulFormattedError {\n /** HTTP status code for the error response */\n status: number\n /** Machine-readable error code */\n code: string\n /** Human-readable error message */\n message: string\n /** Optional help text providing guidance on how to resolve the error */\n help?: string\n /** Array of detailed error information, typically for validation errors */\n details?: ResourcefulFormattedErrorDetails[]\n}\n\n/**\n * AdonisJS middleware that intercepts errors thrown during HTTP requests and formats\n * the responses in a consistent, client-friendly manner. Supports multiple error types\n * including Vine validation errors, Joi validation errors, framework exceptions, and\n * generic errors.\n *\n * The middleware provides:\n * - Consistent error response formatting across all error types\n * - Event-driven error handling for monitoring and logging\n * - Content negotiation supporting JSON and YAML responses\n * - Recursive error cause handling to preserve error chains\n * - Configurable headers for CORS, security, and custom requirements\n *\n * @example\n * ```typescript\n * // Basic usage with default configuration\n * const middleware = new ODataErrorMiddleware({})\n * router.use(middleware.handle)\n *\n * // Advanced usage with event handlers and custom headers\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => logger.warn('Validation failed', error),\n * onException: (error) => monitoring.captureException(error),\n * onAny: (error) => analytics.trackError(error),\n * headers: {\n * 'X-API-Version': '1.0',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * })\n * router.use(middleware.handle)\n * ```\n *\n * @example\n * ```typescript\n * // Standalone usage outside of resourceful routes\n * import ODataErrorMiddleware from '@nhtio/lucid-resourceful/middlewares/resourceful_error'\n *\n * const errorHandler = new ODataErrorMiddleware({\n * onException: (error) => logger.error(error),\n * headers: { 'X-Error-Handler': 'resourceful' }\n * })\n *\n * router.use(errorHandler.handle)\n * ```\n */\nexport class ODataErrorMiddleware {\n /**\n * Creates a usable middleware function that can be applied directly to AdonisJS routes.\n * @param opts - Configuration options for the middleware\n * @returns A middleware function that can be used in AdonisJS routes\n */\n public static usable(opts: ODataErrorMiddlewareOptions = {}) {\n const instance = new ODataErrorMiddleware(opts)\n return (ctx: HttpContext, next: NextFn) => instance.handle(ctx, next)\n }\n\n /**\n * Handles errors thrown during request processing. This method is meant to be integrated with the AdonisJS HttpExceptionHandler\n * @param error - The error that was thrown\n * @param ctx - The HTTP context object\n * @param opts - Configuration options for the middleware\n * @returns A Promise that resolves to the error response\n */\n public static handle(error: unknown, ctx: HttpContext, opts: ODataErrorMiddlewareOptions = {}) {\n const instance = new ODataErrorMiddleware(opts)\n return instance.onError(ctx, error)\n }\n\n /**\n * Determines if the middleware should handle the request based on the desired response format.\n * If the desired format is HTML, it returns false to allow other handlers to process the request.\n * Otherwise, it returns true to indicate that this middleware should handle the error response.\n *\n * @param ctx - The HTTP context object containing request and response information\n * @returns A boolean indicating whether this middleware should handle the request\n */\n public static shouldHandle(_ctx: HttpContext): boolean {\n return true\n }\n\n readonly #emitter: ODataErrorMiddlewareEmitter\n readonly #asYaml: boolean\n readonly #headers: ODataErrorMiddlewareHeaders\n\n /**\n * Creates a new instance of ODataErrorMiddleware with the specified configuration.\n *\n * @param opts - Configuration options for the middleware\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({\n * onVineValidationError: (error) => console.error('Validation:', error),\n * onException: (error) => monitoring.captureException(error),\n * asYaml: true,\n * headers: { 'X-API-Version': '1.0' }\n * })\n * ```\n */\n constructor(opts: ODataErrorMiddlewareOptions) {\n this.#emitter = new ODataErrorMiddlewareEmitter()\n // asYaml defaults to `true`\n this.#asYaml = false !== opts.asYaml\n // headers defaults to an empty object\n this.#headers = isObject(opts.headers) ? opts.headers : {}\n if ('function' === typeof opts.onVineValidationError) {\n this.#emitter.once('vineValidationError', opts.onVineValidationError)\n }\n if ('function' === typeof opts.onJoiValidationError) {\n this.#emitter.once('joiValidationError', opts.onJoiValidationError)\n }\n if ('function' === typeof opts.onException) {\n this.#emitter.once('exception', opts.onException)\n }\n if ('function' === typeof opts.onError) {\n this.#emitter.once('error', opts.onError)\n }\n if ('function' === typeof opts.onUnknown) {\n this.#emitter.once('unknown', opts.onUnknown)\n }\n if ('function' === typeof opts.onAny) {\n this.#emitter.once('any', opts.onAny)\n }\n }\n\n /**\n * AdonisJS middleware handler that intercepts and processes errors during request execution.\n * This method should be used as middleware in your route definitions.\n *\n * @param ctx - The HTTP context object containing request and response information\n * @param next - The next function to call in the middleware chain\n *\n * @example\n * ```typescript\n * const middleware = new ODataErrorMiddleware({})\n * router.use(middleware.handle)\n *\n * // Or bind it to specific routes\n * router.get('/api/users', UserController.index).use([middleware.handle])\n * ```\n */\n async handle(ctx: HttpContext, next: NextFn) {\n try {\n await next()\n } catch (error) {\n return this.onError(ctx, error)\n }\n }\n\n /**\n * Processes a caught error, emits appropriate events, and sends a formatted response.\n * This method handles error classification, event emission, content negotiation,\n * and response formatting.\n *\n * @param ctx - The HTTP context object\n * @param error - The error that was caught during request processing\n *\n * @example\n * ```typescript\n * // Typically called automatically by the handle method, but can be used directly\n * try {\n * // Some operation that might throw\n * } catch (error) {\n * middleware.onError(ctx, error)\n * }\n * ```\n */\n onError(ctx: HttpContext, error: unknown) {\n this.#emitter.emit('any', error)\n switch (true) {\n case isVineValidationError(error):\n this.#emitter.emit('vineValidationError', error)\n break\n\n case isJoiValidationError(error):\n this.#emitter.emit('joiValidationError', error)\n break\n\n case isException(error):\n this.#emitter.emit('exception', error)\n break\n\n case isError(error):\n this.#emitter.emit('error', error)\n break\n\n default:\n this.#emitter.emit('unknown', error)\n break\n }\n const format = negotiateContent(ctx)\n // if the desired format is HTML, break early since that needs to be handled elsewhere\n const formattedError = this.#getFormattedError(error)\n ctx.response.status(formattedError.status)\n Object.entries(this.#headers).forEach(([key, value]) => {\n ctx.response.header(key, value)\n })\n switch (true) {\n case 'xml' === format && this.#asYaml:\n return this.#sendAsXml(ctx, formattedError)\n\n default:\n return this.#sendAsJson(ctx, formattedError)\n }\n }\n\n #sendAsJson(ctx: HttpContext, formattedError: ResourcefulFormattedError) {\n ctx.response.header('Content-Type', 'application/json')\n ctx.response.send(\n JSON.stringify({\n error: stripUndefinedValuesFromObject({\n ...formattedError,\n status: undefined,\n }),\n })\n )\n }\n\n #sendAsXml(ctx: HttpContext, formattedError: ResourcefulFormattedError) {\n const payload: ElementCompact = {\n '_declaration': { _attributes: { version: '1.0', encoding: 'UTF-8' } },\n 'm:error': {\n '_attributes': {\n 'xmlns:m': 'http://docs.oasis-open.org/odata/ns/metadata',\n },\n 'm:code': { _text: formattedError.code },\n 'm:message': { _text: formattedError.message },\n ...(formattedError.details &&\n formattedError.details.length > 0 && {\n 'm:details': formattedError.details.map((detail) => ({\n 'm:detail': {\n 'm:code': { _text: detail.code },\n 'm:message': { _text: detail.message },\n ...(detail.target && { 'm:target': { _text: detail.target } }),\n },\n })),\n }),\n },\n }\n\n ctx.response.header('Content-Type', 'application/xml')\n ctx.response.header('OData-Version', '4.0')\n ctx.response.send(js2xml(payload, { compact: true, spaces: 2 }))\n }\n\n #getFormattedError(error: unknown): ResourcefulFormattedError {\n switch (true) {\n case isVineValidationError(error):\n return this.#formatVineValidationError(error)\n\n case isJoiValidationError(error):\n return this.#formatJoiValidationError(error)\n\n case isException(error):\n return this.#formatException(error)\n\n case isError(error):\n return this.#formatError(error)\n\n default:\n return this.#formatUnknown(error)\n }\n }\n\n #formatVineValidationError(error: VineValidationError): ResourcefulFormattedError {\n const status: number = error.status || 422\n const code: string = error.code || 'E_VALIDATION_ERROR'\n const message: string = error.messages || 'Validation failed'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n let details: ResourcefulFormattedErrorDetails[] | undefined = Array.isArray(error.messages)\n ? error.messages.map((m) => {\n return stripUndefinedValuesFromObject({\n code: m.rule ? string.snakeCase(m.rule).toUpperCase() : 'E_VALIDATION_ERROR',\n message: m.message || 'Validation error',\n target: m.field,\n })\n })\n : undefined\n if (error.cause) {\n if (!details) {\n details = []\n }\n const formattedCause = this.#getFormattedError(error.cause)\n details.push({\n code: formattedCause.code,\n message: formattedCause.message,\n })\n }\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatJoiValidationError(error: JoiValidationError): ResourcefulFormattedError {\n const status: number = 422\n const code: string = 'E_VALIDATION_ERROR'\n const message: string = error.message || 'Validation failed'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n let details: ResourcefulFormattedErrorDetails[] | undefined = Array.isArray(error.details)\n ? error.details.map((d) => {\n return stripUndefinedValuesFromObject({\n code: string.snakeCase(d.type).toUpperCase(),\n message: d.message || 'Validation error',\n target: d.path.length > 0 ? d.path.join('.') : undefined,\n context: d.context || undefined,\n })\n })\n : undefined\n if (error.cause) {\n if (!details) {\n details = []\n }\n const formattedCause = this.#getFormattedError(error.cause)\n details.push({\n code: formattedCause.code,\n message: formattedCause.message,\n })\n }\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatException(error: Exception): ResourcefulFormattedError {\n const status: number = error.status || 500\n const code: string = error.code || 'E_EXCEPTION'\n const message: string = error.message || 'An exception occurred'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause = error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatError(error: Error): ResourcefulFormattedError {\n const status: number = isNotImplementedError(error) ? 501 : 500\n const code: string = 'E_ERROR'\n const message: string = error.message || 'An error occurred'\n const help: string | undefined =\n 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause = error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n\n #formatUnknown(error: unknown): ResourcefulFormattedError {\n const status: number = 500\n const code: string = 'E_UNKNOWN_ERROR'\n const message: string = 'An unknown error occurred'\n const help: string | undefined =\n isObject(error) && 'help' in error && 'string' === typeof error.help ? error.help : undefined\n const formattedCause =\n isObject(error) && error.cause ? this.#getFormattedError(error.cause) : undefined\n const details: ResourcefulFormattedErrorDetails[] | undefined = formattedCause\n ? [\n stripUndefinedValuesFromObject({\n code: formattedCause.code,\n message: formattedCause.message,\n }),\n ]\n : undefined\n return stripUndefinedValuesFromObject({\n status,\n code,\n message,\n help,\n details,\n })\n }\n}\n"],"names":["TypedEventEmitter","isObject","isVineValidationError","isJoiValidationError","isException","isError","stripUndefinedValuesFromObject","js2xml","string","isNotImplementedError"],"mappings":";;;;AAEO,MAAM,sBAAsB,CAAC,OAAgB,MAAgB;AAG7D,MAAM,mBAAmB,CAC9B,KACA,WAAgC,WACR;AACxB,aAAW,cAAc,qBAAqB;AAC5C,UAAM,QAAQ,IAAI,QAAQ,GAAA;AAC1B,QAAI,aAAa,OAAO,MAAM,SAAS,KAAK,MAAM,SAAS,EAAE,SAAS,UAAU,GAAG;AACjF,aAAO;AAAA,IACT;AACA,QAAI,IAAI,QAAQ,OAAO,QAAQ,GAAG,SAAS,UAAU,GAAG;AACtD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,QAAkB,WAAwB,MAAgB;AAGtF,MAAM,oBAAoB,CAC/B,KACA,WAA+B,cACR;AACv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,SAAS,aAAa,OAAO,MAAM,OAAO,MAAM,OAAO;AACtF,UAAM,iBACJA,OAAAA,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,mBAAmB,MAAM,KAAK,IAAI;AAC1E,UAAM,UAA0D,iBAC5D;AAAA,MACEK,sCAA+B;AAAA,QAC7B,MAAM,eAAe;AAAA,QACrB,SAAS,eAAe;AAAA,MAAA,CACzB;AAAA,IAAA,IAEH;AACJ,WAAOA,sCAA+B;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AACF;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { l as libExports } from "./index-C54FDYOJ.js";
2
- import { i as index_default, l } from "./index-C8mGEf4P.js";
2
+ import { s as string_default, l } from "./index-DLVvkVxI.js";
3
3
  import { i as isObject, c as isError, d as isException, e as isJoiValidationError, f as isVineValidationError, s as stripUndefinedValuesFromObject, g as isNotImplementedError } from "./errors-b4tqg-tH.js";
4
4
  const ODataResponseFormat = ["xml", "json"];
5
5
  const negotiateContent = (ctx, fallback = "json") => {
@@ -243,7 +243,7 @@ class ODataErrorMiddleware {
243
243
  const help = "help" in error && "string" === typeof error.help ? error.help : void 0;
244
244
  let details = Array.isArray(error.messages) ? error.messages.map((m) => {
245
245
  return stripUndefinedValuesFromObject({
246
- code: m.rule ? index_default.snakeCase(m.rule).toUpperCase() : "E_VALIDATION_ERROR",
246
+ code: m.rule ? string_default.snakeCase(m.rule).toUpperCase() : "E_VALIDATION_ERROR",
247
247
  message: m.message || "Validation error",
248
248
  target: m.field
249
249
  });
@@ -273,7 +273,7 @@ class ODataErrorMiddleware {
273
273
  const help = "help" in error && "string" === typeof error.help ? error.help : void 0;
274
274
  let details = Array.isArray(error.details) ? error.details.map((d) => {
275
275
  return stripUndefinedValuesFromObject({
276
- code: index_default.snakeCase(d.type).toUpperCase(),
276
+ code: string_default.snakeCase(d.type).toUpperCase(),
277
277
  message: d.message || "Validation error",
278
278
  target: d.path.length > 0 ? d.path.join(".") : void 0,
279
279
  context: d.context || void 0
@@ -364,4 +364,4 @@ export {
364
364
  negotiatePreference as b,
365
365
  negotiateContent as n
366
366
  };
367
- //# sourceMappingURL=odata_error_middleware-CWYqZMez.js.map
367
+ //# sourceMappingURL=odata_error_middleware-Dspi8bct.js.map