directus-extension-beliq 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/api.js +1 -0
- package/dist/app.js +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 beliq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# directus-extension-beliq
|
|
2
|
+
|
|
3
|
+
A [Directus](https://directus.io) Flow **operation** for [beliq](https://beliq.eu), a REST API that generates, validates, parses, and converts EU-compliant e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS) against authority-pinned, drift-checked rules.
|
|
4
|
+
|
|
5
|
+
One operation, four use cases:
|
|
6
|
+
|
|
7
|
+
- **Generate** an invoice from a structured EN 16931 object, as XML or a hybrid PDF/A-3.
|
|
8
|
+
- **Validate** a document against the pinned rule set and return the compliance verdict.
|
|
9
|
+
- **Parse** a document into a structured invoice.
|
|
10
|
+
- **Convert** a document between formats (CII, UBL, ZUGFeRD, Factur-X, XRechnung, Peppol BIS).
|
|
11
|
+
|
|
12
|
+
By default the bytes an operation produces (a generated PDF, a converted document) are saved **straight into Directus Files** and the operation returns the new file's `fileId`, so a following operation can attach it to a record. You can also return them as **base64**. Generate as XML and validate/parse return their JSON straight into the flow data chain.
|
|
13
|
+
|
|
14
|
+
Backed by the published [`@beliq/sdk`](https://www.npmjs.com/package/@beliq/sdk).
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
This is a standard (non-sandboxed) API extension, so it installs on self-hosted Directus:
|
|
19
|
+
|
|
20
|
+
- **Marketplace** (self-hosted with `MARKETPLACE_TRUST=all`): search for `directus-extension-beliq`.
|
|
21
|
+
- **Manual**: `npm install directus-extension-beliq` into your project, or drop the built `dist/` into your `extensions/` directory, then restart Directus.
|
|
22
|
+
|
|
23
|
+
It is not installable on Directus Cloud (which only runs sandboxed extensions; the sandbox has no access to the Files service or binary responses).
|
|
24
|
+
|
|
25
|
+
## Use it in a Flow
|
|
26
|
+
|
|
27
|
+
Add the **beliq** operation to a Flow and pick an operation.
|
|
28
|
+
|
|
29
|
+
- **API Key**: paste a key from [dashboard.beliq.eu](https://dashboard.beliq.eu), or leave it blank to read the `BELIQ_API_KEY` environment variable (recommended, keeps the key out of the flow definition).
|
|
30
|
+
- **Delivery** (Generate as PDF, and Convert):
|
|
31
|
+
- **Save to Directus File** (default) returns `{ fileId, filename, contentType, sizeBytes, ... }`.
|
|
32
|
+
- **Base64** returns `{ base64, ... }`.
|
|
33
|
+
- **Generate** as XML returns `{ xml, contentType, ... }`; **Validate** and **Parse** return their JSON result.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
`examples/` holds three ready-to-load Flow definitions, one per angle:
|
|
38
|
+
|
|
39
|
+
- `generate-xrechnung-from-record.flow.json` - turn a new invoice record into an XRechnung XML invoice.
|
|
40
|
+
- `validate-uploaded-file.flow.json` - validate an invoice document and return the verdict.
|
|
41
|
+
- `convert-format.flow.json` - convert a document to a Factur-X hybrid PDF and store it.
|
|
42
|
+
|
|
43
|
+
Directus has no one-click Flow import, so `examples/import.mjs` (zero dependencies) POSTs a chosen example to your instance through the Flows API and wires it up:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
DIRECTUS_URL=https://directus.example.com \
|
|
47
|
+
DIRECTUS_TOKEN=<admin static token> \
|
|
48
|
+
node examples/import.mjs validate-uploaded-file.flow.json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
It prints the flow's admin URL when done. Open it, set your API key (or the `BELIQ_API_KEY` env var), and run.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install
|
|
57
|
+
npm run build # @directus/extensions-sdk -> dist/app.js + dist/api.js
|
|
58
|
+
npm run validate # SDK conformance check
|
|
59
|
+
npm test # unit tests (operation mapping)
|
|
60
|
+
npm run scrub:check
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Live smoke test against the real API:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
BELIQ_API_KEY=beliq_xxx npm run test:integration
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
[MIT](./LICENSE)
|
package/dist/api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Readable as e}from"node:stream";const t=["interface","display","layout","module","panel","theme"],n=["hook","endpoint"],r=["operation"];function o(e,t,n){function r(n,r){var o;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(o=n._zod).traits??(o.traits=new Set),n._zod.traits.add(e),t(n,r);for(const e in s.prototype)e in n||Object.defineProperty(n,e,{value:s.prototype[e].bind(n)});n._zod.constr=s,n._zod.def=r}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class i extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class s extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const a={};function c(e){return a}function u(e,t){return"bigint"==typeof t?t.toString():t}function d(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function p(e){return null==e}function l(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const f=Symbol("evaluating");function h(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==f)return void 0===r&&(r=f,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function m(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function v(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function y(e){return JSON.stringify(e)}const g="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const w=d(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function z(e){if(!1===_(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!1!==_(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return z(e)?{...e}:Array.isArray(e)?[...e]:e}const k=new Set(["string","number","symbol"]);function $(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function Z(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function x(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function P(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function E(e){return"string"==typeof e?e:e?.message}function A(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=E(e.inst?._zod.def?.error?.(e))??E(t?.error?.(e))??E(n.customError?.(e))??E(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function O(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function j(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const S=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,u,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},I=o("$ZodError",S),F=o("$ZodError",S,{Parent:Error});const C=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new i;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>A(e,s,c())));throw g(t,o?.callee),t}return a.value},U=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>A(e,i,c())));throw g(t,o?.callee),t}return s.value},D=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new i;return s.issues.length?{success:!1,error:new(e??I)(s.issues.map(e=>A(e,o,c())))}:{success:!0,data:s.value}},R=D(F),N=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>A(e,o,c())))}:{success:!0,data:i.value}},B=N(F),L=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return C(e)(t,n,o)},K=e=>(t,n,r)=>C(e)(t,n,r),q=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return U(e)(t,n,o)},V=e=>async(t,n,r)=>U(e)(t,n,r),J=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return D(e)(t,n,o)},W=e=>(t,n,r)=>D(e)(t,n,r),M=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return N(e)(t,n,o)},G=e=>async(t,n,r)=>N(e)(t,n,r),Y=/^[cC][^\s-]{8,}$/,H=/^[0-9a-z]+$/,X=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Q=/^[0-9a-vA-V]{20}$/,ee=/^[A-Za-z0-9]{27}$/,te=/^[a-zA-Z0-9_-]{21}$/,ne=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,re=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,oe=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ie=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ae=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ce=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ue=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,de=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pe=/^[A-Za-z0-9_-]*$/,le=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,fe=/^\+(?:[0-9]){6,14}[0-9]$/,he="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",me=new RegExp(`^${he}$`);function ve(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ye=/^(?:true|false)$/i,ge=/^[^A-Z]*$/,_e=/^[^a-z]*$/,we=o("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ze=o("$ZodCheckMaxLength",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=O(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),be=o("$ZodCheckMinLength",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=O(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ke=o("$ZodCheckLengthEquals",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=O(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$e=o("$ZodCheckStringFormat",(e,t)=>{var n,r;we.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Te=o("$ZodCheckRegex",(e,t)=>{$e.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ze=o("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ge),$e.init(e,t)}),xe=o("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_e),$e.init(e,t)}),Pe=o("$ZodCheckIncludes",(e,t)=>{we.init(e,t);const n=$(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ee=o("$ZodCheckStartsWith",(e,t)=>{we.init(e,t);const n=new RegExp(`^${$(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ae=o("$ZodCheckEndsWith",(e,t)=>{we.init(e,t);const n=new RegExp(`.*${$(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Oe=o("$ZodCheckOverwrite",(e,t)=>{we.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class je{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Se={major:4,minor:1,patch:12},Ie=o("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Se;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,o=x(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new i;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(o||(o=x(e,t)))});else{if(e.issues.length===t)continue;o||(o=x(e,t))}}return r?r.then(()=>e):e},n=(n,o,s)=>{if(x(n))return n.aborted=!0,n;const a=t(o,r,s);if(a instanceof Promise){if(!1===s.async)throw new i;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if("backward"===s.direction){const t=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,s)):n(t,o,s)}const a=e._zod.parse(o,s);if(a instanceof Promise){if(!1===s.async)throw new i;return a.then(e=>t(e,r,s))}return t(a,r,s)}}e["~standard"]={validate:t=>{try{const n=R(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return B(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Fe=o("$ZodString",(e,t)=>{var n;Ie.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ce=o("$ZodStringFormat",(e,t)=>{$e.init(e,t),Fe.init(e,t)}),Ue=o("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=re),Ce.init(e,t)}),De=o("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=oe(e))}else t.pattern??(t.pattern=oe());Ce.init(e,t)}),Re=o("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ie),Ce.init(e,t)}),Ne=o("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:le.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Be=o("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ce.init(e,t)}),Le=o("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=te),Ce.init(e,t)}),Ke=o("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Y),Ce.init(e,t)}),qe=o("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=H),Ce.init(e,t)}),Ve=o("$ZodULID",(e,t)=>{t.pattern??(t.pattern=X),Ce.init(e,t)}),Je=o("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Q),Ce.init(e,t)}),We=o("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ee),Ce.init(e,t)}),Me=o("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=ve({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${he}T(?:${r})$`)}(t)),Ce.init(e,t)}),Ge=o("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=me),Ce.init(e,t)}),Ye=o("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ve(t)}$`)),Ce.init(e,t)}),He=o("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ne),Ce.init(e,t)}),Xe=o("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=se),Ce.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),Qe=o("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ae),Ce.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),et=o("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ce),Ce.init(e,t)}),tt=o("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ue),Ce.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function nt(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const rt=o("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=de),Ce.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{nt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ot=o("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=pe),Ce.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{(function(e){if(!pe.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return nt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),it=o("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fe),Ce.init(e,t)});const st=o("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),at=o("$ZodBoolean",(e,t)=>{Ie.init(e,t),e._zod.pattern=ye,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),ct=o("$ZodUnknown",(e,t)=>{Ie.init(e,t),e._zod.parse=e=>e}),ut=o("$ZodNever",(e,t)=>{Ie.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function dt(e,t,n){e.issues.length&&t.issues.push(...P(n,e.issues)),t.value[n]=e.value}const pt=o("$ZodArray",(e,t)=>{Ie.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then(t=>dt(t,n,e))):dt(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function lt(e,t,n,r){e.issues.length&&t.issues.push(...P(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ft(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ht(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type;for(const o of Object.keys(t)){if(a.has(o))continue;if("never"===u){s.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>lt(e,n,o,t))):lt(i,n,o,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const mt=o("$ZodObject",(e,t)=>{Ie.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=d(()=>ft(t));h(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n});const o=_,i=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e]._zod.run({value:a[e],issues:[]},n);r instanceof Promise?c.push(r.then(n=>lt(n,t,e,a))):lt(r,t,e,a)}return i?ht(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),vt=o("$ZodObjectJIT",(e,t)=>{mt.init(e,t);const n=e._zod.parse,r=d(()=>ft(t));let o;const i=_,s=!a.jitless,c=s&&w.value,u=t.catchall;let p;e._zod.parse=(a,d)=>{p??(p=r.value);const l=a.value;return i(l)?s&&c&&!1===d?.async&&!0!==d.jitless?(o||(o=(e=>{const t=new je(["shape","payload","ctx"]),n=r.value,o=e=>{const t=y(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const e of n.keys)i[e]="key_"+s++;t.write("const newResult = {};");for(const e of n.keys){const n=i[e],r=y(e);t.write(`const ${n} = ${o(e)};`),t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${r}, ...iss.path] : [${r}]\n })));\n }\n \n \n if (${n}.value === undefined) {\n if (${r} in input) {\n newResult[${r}] = undefined;\n }\n } else {\n newResult[${r}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),a=o(a,d),u?ht([],l,a,d,p,e):a):n(a,d):(a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a)}});function yt(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!x(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>A(e,r,c())))}),t)}const gt=o("$ZodUnion",(e,t)=>{Ie.init(e,t),h(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),h(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),h(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),h(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>l(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>yt(t,o,e,i)):yt(a,o,e,i)}}),_t=o("$ZodIntersection",(e,t)=>{Ie.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>zt(e,t,n)):zt(e,o,i)}});function wt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(z(e)&&z(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=wt(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=wt(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function zt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),x(e))return e;const r=wt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const bt=o("$ZodRecord",(e,t)=>{Ie.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!z(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[];if(t.keyType._zod.values){const s=t.keyType._zod.values;n.value={};for(const e of s)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const s=t.valueType._zod.run({value:o[e],issues:[]},r);s instanceof Promise?i.push(s.then(t=>{t.issues.length&&n.issues.push(...P(e,t.issues)),n.value[e]=t.value})):(s.issues.length&&n.issues.push(...P(e,s.issues)),n.value[e]=s.value)}let a;for(const e in o)s.has(e)||(a=a??[],a.push(e));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;const a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>A(e,r,c())),input:s,path:[s],inst:e}),n.value[a.value]=a.value;continue}const u=t.valueType._zod.run({value:o[s],issues:[]},r);u instanceof Promise?i.push(u.then(e=>{e.issues.length&&n.issues.push(...P(s,e.issues)),n.value[a.value]=e.value})):(u.issues.length&&n.issues.push(...P(s,u.issues)),n.value[a.value]=u.value)}}return i.length?Promise.all(i).then(()=>n):n}}),kt=o("$ZodEnum",(e,t)=>{Ie.init(e,t);const n=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>k.has(typeof e)).map(e=>"string"==typeof e?$(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),$t=o("$ZodLiteral",(e,t)=>{if(Ie.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?$(e):e?$(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),Tt=o("$ZodTransform",(e,t)=>{Ie.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new s(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n))}if(o instanceof Promise)throw new i;return n.value=o,n}});function Zt(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const xt=o("$ZodOptional",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",e._zod.optout="optional",h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${l(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Zt(t,e.value)):Zt(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Pt=o("$ZodNullable",(e,t)=>{Ie.init(e,t),h(e._zod,"optin",()=>t.innerType._zod.optin),h(e._zod,"optout",()=>t.innerType._zod.optout),h(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${l(e.source)}|null)$`):void 0}),h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Et=o("$ZodDefault",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",h(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>At(e,t)):At(r,t)}});function At(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Ot=o("$ZodPrefault",(e,t)=>{Ie.init(e,t),e._zod.optin="optional",h(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),jt=o("$ZodNonOptional",(e,t)=>{Ie.init(e,t),h(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>St(t,e)):St(o,e)}});function St(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const It=o("$ZodCatch",(e,t)=>{Ie.init(e,t),h(e._zod,"optin",()=>t.innerType._zod.optin),h(e._zod,"optout",()=>t.innerType._zod.optout),h(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>A(e,n,c()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>A(e,n,c()))},input:e.value}),e.issues=[]),e)}}),Ft=o("$ZodPipe",(e,t)=>{Ie.init(e,t),h(e._zod,"values",()=>t.in._zod.values),h(e._zod,"optin",()=>t.in._zod.optin),h(e._zod,"optout",()=>t.out._zod.optout),h(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ct(e,t.in,n)):Ct(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ct(e,t.out,n)):Ct(r,t.out,n)}});function Ct(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ut=o("$ZodReadonly",(e,t)=>{Ie.init(e,t),h(e._zod,"propValues",()=>t.innerType._zod.propValues),h(e._zod,"values",()=>t.innerType._zod.values),h(e._zod,"optin",()=>t.innerType._zod.optin),h(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Dt):Dt(r)}});function Dt(e){return e.value=Object.freeze(e.value),e}const Rt=o("$ZodCustom",(e,t)=>{we.init(e,t),Ie.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>Nt(t,n,r,e));Nt(o,n,r,e)}});function Nt(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(j(e))}}class Bt{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Lt(){return new Bt}const Kt=Lt();function qt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Z(t)})}function Vt(e,t){return new ze({check:"max_length",...Z(t),maximum:e})}function Jt(e,t){return new be({check:"min_length",...Z(t),minimum:e})}function Wt(e,t){return new ke({check:"length_equals",...Z(t),length:e})}function Mt(e){return new Oe({check:"overwrite",tx:e})}function Gt(e){const t=function(e,t){const n=new we({check:"custom",...Z(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(j(e,n.value,t._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(j(r))}},e(n.value,n)));return t}const Yt=o("ZodISODateTime",(e,t)=>{Me.init(e,t),bn.init(e,t)});function Ht(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Z(t)})}(Yt,e)}const Xt=o("ZodISODate",(e,t)=>{Ge.init(e,t),bn.init(e,t)});function Qt(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Z(t)})}(Xt,e)}const en=o("ZodISOTime",(e,t)=>{Ye.init(e,t),bn.init(e,t)});function tn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Z(t)})}(en,e)}const nn=o("ZodISODuration",(e,t)=>{He.init(e,t),bn.init(e,t)});function rn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Z(t)})}(nn,e)}const on=o("ZodError",(e,t)=>{I.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=e=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e}));else if("invalid_key"===o.code)r({issues:o.issues});else if("invalid_element"===o.code)r({issues:o.issues});else if(0===o.path.length)n._errors.push(t(o));else{let e=n,r=0;for(;r<o.path.length;){const n=o.path[r];r===o.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(o))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,u,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,u,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),sn=C(on),an=U(on),cn=D(on),un=N(on),dn=L(on),pn=K(on),ln=q(on),fn=V(on),hn=J(on),mn=W(on),vn=M(on),yn=G(on),gn=o("ZodType",(e,t)=>(Ie.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(v(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]})),e.clone=(t,n)=>T(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>sn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>cn(e,t,n),e.parseAsync=async(t,n)=>an(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>un(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>dn(e,t,n),e.decode=(t,n)=>pn(e,t,n),e.encodeAsync=async(t,n)=>ln(e,t,n),e.decodeAsync=async(t,n)=>fn(e,t,n),e.safeEncode=(t,n)=>hn(e,t,n),e.safeDecode=(t,n)=>mn(e,t,n),e.safeEncodeAsync=async(t,n)=>vn(e,t,n),e.safeDecodeAsync=async(t,n)=>yn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Z(n)})}(_r,e,t)}(t,n)),e.superRefine=t=>e.check(Gt(t)),e.overwrite=t=>e.check(Mt(t)),e.optional=()=>ur(e),e.nullable=()=>pr(e),e.nullish=()=>ur(pr(e)),e.nonoptional=t=>function(e,t){return new hr({type:"nonoptional",innerType:e,...Z(t)})}(e,t),e.array=()=>Gn(e),e.or=t=>Qn([e,t]),e.and=t=>new er({type:"intersection",left:e,right:t}),e.transform=t=>yr(e,new ar({type:"transform",transform:t})),e.default=t=>{return n=t,new lr({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.prefault=t=>{return n=t,new fr({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.catch=t=>{return new mr({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>yr(e,t),e.readonly=()=>new gr({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Kt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Kt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Kt.get(e);const n=e.clone();return Kt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_n=o("_ZodString",(e,t)=>{Fe.init(e,t),gn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Te({check:"string_format",format:"regex",...Z(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Pe({check:"string_format",format:"includes",...Z(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Ee({check:"string_format",format:"starts_with",...Z(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ae({check:"string_format",format:"ends_with",...Z(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Jt(...t)),e.max=(...t)=>e.check(Vt(...t)),e.length=(...t)=>e.check(Wt(...t)),e.nonempty=(...t)=>e.check(Jt(1,...t)),e.lowercase=t=>e.check(function(e){return new Ze({check:"string_format",format:"lowercase",...Z(e)})}(t)),e.uppercase=t=>e.check(function(e){return new xe({check:"string_format",format:"uppercase",...Z(e)})}(t)),e.trim=()=>e.check(Mt(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return Mt(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(Mt(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(Mt(e=>e.toUpperCase()))}),wn=o("ZodString",(e,t)=>{Fe.init(e,t),_n.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Z(t)})}(kn,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Z(t)})}(Zn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Z(t)})}(Bn,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Z(t)})}(xn,t)),e.guid=t=>e.check(qt($n,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Z(t)})}(Tn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Z(t)})}(Tn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Z(t)})}(Tn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Z(t)})}(Tn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Z(t)})}(Pn,t)),e.guid=t=>e.check(qt($n,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Z(t)})}(En,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Z(t)})}(An,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Z(t)})}(On,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Z(t)})}(Dn,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Z(t)})}(Rn,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Z(t)})}(jn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Z(t)})}(Sn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Z(t)})}(In,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Z(t)})}(Fn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Z(t)})}(Cn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Z(t)})}(Un,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Z(t)})}(Nn,t)),e.datetime=t=>e.check(Ht(t)),e.date=t=>e.check(Qt(t)),e.time=t=>e.check(tn(t)),e.duration=t=>e.check(rn(t))});function zn(e){return function(e,t){return new e({type:"string",...Z(t)})}(wn,e)}const bn=o("ZodStringFormat",(e,t)=>{Ce.init(e,t),_n.init(e,t)}),kn=o("ZodEmail",(e,t)=>{Re.init(e,t),bn.init(e,t)}),$n=o("ZodGUID",(e,t)=>{Ue.init(e,t),bn.init(e,t)}),Tn=o("ZodUUID",(e,t)=>{De.init(e,t),bn.init(e,t)}),Zn=o("ZodURL",(e,t)=>{Ne.init(e,t),bn.init(e,t)}),xn=o("ZodEmoji",(e,t)=>{Be.init(e,t),bn.init(e,t)}),Pn=o("ZodNanoID",(e,t)=>{Le.init(e,t),bn.init(e,t)}),En=o("ZodCUID",(e,t)=>{Ke.init(e,t),bn.init(e,t)}),An=o("ZodCUID2",(e,t)=>{qe.init(e,t),bn.init(e,t)}),On=o("ZodULID",(e,t)=>{Ve.init(e,t),bn.init(e,t)}),jn=o("ZodXID",(e,t)=>{Je.init(e,t),bn.init(e,t)}),Sn=o("ZodKSUID",(e,t)=>{We.init(e,t),bn.init(e,t)}),In=o("ZodIPv4",(e,t)=>{Xe.init(e,t),bn.init(e,t)}),Fn=o("ZodIPv6",(e,t)=>{Qe.init(e,t),bn.init(e,t)}),Cn=o("ZodCIDRv4",(e,t)=>{et.init(e,t),bn.init(e,t)}),Un=o("ZodCIDRv6",(e,t)=>{tt.init(e,t),bn.init(e,t)}),Dn=o("ZodBase64",(e,t)=>{rt.init(e,t),bn.init(e,t)}),Rn=o("ZodBase64URL",(e,t)=>{ot.init(e,t),bn.init(e,t)}),Nn=o("ZodE164",(e,t)=>{it.init(e,t),bn.init(e,t)}),Bn=o("ZodJWT",(e,t)=>{st.init(e,t),bn.init(e,t)}),Ln=o("ZodBoolean",(e,t)=>{at.init(e,t),gn.init(e,t)});function Kn(e){return function(e,t){return new e({type:"boolean",...Z(t)})}(Ln,e)}const qn=o("ZodUnknown",(e,t)=>{ct.init(e,t),gn.init(e,t)});function Vn(){return new qn({type:"unknown"})}const Jn=o("ZodNever",(e,t)=>{ut.init(e,t),gn.init(e,t)});function Wn(e){return function(e,t){return new e({type:"never",...Z(t)})}(Jn,e)}const Mn=o("ZodArray",(e,t)=>{pt.init(e,t),gn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Jt(t,n)),e.nonempty=t=>e.check(Jt(1,t)),e.max=(t,n)=>e.check(Vt(t,n)),e.length=(t,n)=>e.check(Wt(t,n)),e.unwrap=()=>e.element});function Gn(e,t){return function(e,t,n){return new e({type:"array",element:t,...Z(n)})}(Mn,e,t)}const Yn=o("ZodObject",(e,t)=>{vt.init(e,t),gn.init(e,t),h(e,"shape",()=>t.shape),e.keyof=()=>or(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Vn()}),e.loose=()=>e.clone({...e._zod.def,catchall:Vn()}),e.strict=()=>e.clone({...e._zod.def,catchall:Wn()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!z(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=v(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return m(this,"shape",n),n},checks:[]});return T(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!z(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return m(this,"shape",n),n},checks:e._zod.def.checks};return T(e,n)}(e,t),e.merge=t=>function(e,t){const n=v(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return m(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return T(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def;return T(e,v(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return m(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=v(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return m(this,"shape",r),r},checks:[]});return T(e,r)}(e,t),e.partial=(...t)=>function(e,t,n){const r=v(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return m(this,"shape",o),o},checks:[]});return T(t,r)}(cr,e,t[0]),e.required=(...t)=>function(e,t,n){const r=v(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return m(this,"shape",o),o},checks:[]});return T(t,r)}(hr,e,t[0])});function Hn(e,t){const n={type:"object",shape:e??{},...Z(t)};return new Yn(n)}const Xn=o("ZodUnion",(e,t)=>{gt.init(e,t),gn.init(e,t),e.options=t.options});function Qn(e,t){return new Xn({type:"union",options:e,...Z(t)})}const er=o("ZodIntersection",(e,t)=>{_t.init(e,t),gn.init(e,t)});const tr=o("ZodRecord",(e,t)=>{bt.init(e,t),gn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function nr(e,t,n){return new tr({type:"record",keyType:e,valueType:t,...Z(n)})}const rr=o("ZodEnum",(e,t)=>{kt.init(e,t),gn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new rr({...t,checks:[],...Z(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new rr({...t,checks:[],...Z(r),entries:o})}});function or(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new rr({type:"enum",entries:n,...Z(t)})}const ir=o("ZodLiteral",(e,t)=>{$t.init(e,t),gn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function sr(e,t){return new ir({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}const ar=o("ZodTransform",(e,t)=>{Tt.init(e,t),gn.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new s(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(j(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(j(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n)):(n.value=o,n)}});const cr=o("ZodOptional",(e,t)=>{xt.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ur(e){return new cr({type:"optional",innerType:e})}const dr=o("ZodNullable",(e,t)=>{Pt.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function pr(e){return new dr({type:"nullable",innerType:e})}const lr=o("ZodDefault",(e,t)=>{Et.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const fr=o("ZodPrefault",(e,t)=>{Ot.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const hr=o("ZodNonOptional",(e,t)=>{jt.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const mr=o("ZodCatch",(e,t)=>{It.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const vr=o("ZodPipe",(e,t)=>{Ft.init(e,t),gn.init(e,t),e.in=t.in,e.out=t.out});function yr(e,t){return new vr({type:"pipe",in:e,out:t})}const gr=o("ZodReadonly",(e,t)=>{Ut.init(e,t),gn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const _r=o("ZodCustom",(e,t)=>{Rt.init(e,t),gn.init(e,t)});const wr="directus:extension",zr=Hn({app:zn(),api:zn()}),br=Hn({request:ur(Hn({urls:Gn(zn()),methods:Gn(Qn([sr("GET"),sr("POST"),sr("PATCH"),sr("PUT"),sr("DELETE")]))})),log:ur(Hn({})),sleep:ur(Hn({}))}),kr=ur(Hn({enabled:Kn(),requestedScopes:br})),$r=Qn([Hn({type:or(n),name:zn(),source:zn()}),Hn({type:or(t),name:zn(),source:zn()}),Hn({type:or(r),name:zn(),source:zr})]),Tr=Hn({host:zn(),hidden:Kn().optional()}),Zr=Hn({type:or(t),path:zn(),source:zn()}),xr=Hn({type:or(n),path:zn(),source:zn(),sandbox:kr}),Pr=Hn({type:or(r),path:zr,source:zr,sandbox:kr}),Er=Hn({type:sr("bundle"),partial:Kn().optional(),path:zr,entries:Gn($r)});Gn($r);const Ar=Tr.and(Qn([Zr,xr,Pr,Er]));function Or(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function jr(e,t){const n={...e};for(const[e,r]of Object.entries(t))"__proto__"!==e&&"constructor"!==e&&"prototype"!==e&&(Or(r)&&Or(n[e])?n[e]=jr(n[e],r):n[e]=r);return n}function Sr(e){return new TextDecoder("utf-8").decode(e)}Hn({name:zn(),version:zn(),type:Qn([sr("module"),sr("commonjs")]).optional(),description:zn().optional(),icon:zn().optional(),dependencies:nr(zn(),zn()).optional(),devDependencies:nr(zn(),zn()).optional(),[wr]:Ar});var Ir=[37,80,68,70,45];function Fr(e){return"facturx"===e||"zugferd"===e}function Cr(e,t){const n=function(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&""!==r&&(t[n]=r);return t}(e);return t&&Object.keys(t).length>0?jr(n,t):n}function Ur(e){switch(e.operation){case"me":return{method:"GET",path:"/v1/me",outputKind:"json"};case"generate":{const t={standard:e.standard,output:e.output??"xml",invoice:e.invoice??{}};e.profile&&(t.profile=e.profile),e.facturxProfile&&Fr(e.standard)&&(t.facturxProfile=e.facturxProfile),"boolean"==typeof e.verify&&(t.verify=e.verify),e.template&&(t.template=e.template),e.pdfTemplateId&&(t.pdfTemplateId=e.pdfTemplateId);return{method:"POST",path:"/v1/generate",jsonBody:e.advanced&&Object.keys(e.advanced).length>0?jr(t,e.advanced):t,contentType:"application/json",outputKind:"binary"}}case"validate":{const t={format:e.validateFormat};return"boolean"==typeof e.franceCtc&&(t.franceCtc=e.franceCtc),{method:"POST",path:"/v1/validate",query:Cr(t,e.advanced),rawBody:e.rawBody,contentType:e.rawContentType??"application/xml",outputKind:"json"}}case"parse":return{method:"POST",path:"/v1/parse",query:Cr({format:e.parseFormat},e.advanced),rawBody:e.rawBody,contentType:e.rawContentType??"application/xml",outputKind:"json"};case"convert":{const t={sourceFormat:e.sourceFormat,targetFormat:e.targetFormat};return e.targetProfile&&Fr(e.targetFormat)&&(t.targetProfile=e.targetProfile),"boolean"==typeof e.dropFranceCtcOverlay&&(t.dropFranceCtcOverlay=e.dropFranceCtcOverlay),{method:"POST",path:"/v1/convert",query:Cr(t,e.advanced),rawBody:e.rawBody,contentType:e.rawContentType??"application/xml",outputKind:"binary"}}}}var Dr=class extends Error{code;status;details;constructor(e,t){super(e),this.name="BeliqApiError",this.code=t.code,this.status=t.status,this.details=t.details}};function Rr(e){let t;try{t=Sr(e)}catch{return null}if(!t.trim())return null;try{const e=JSON.parse(t);return Or(e)?e:null}catch{return null}}function Nr(e,t){const n=Rr(t),r=n?.error;return new Dr(r?.message??n?.message??`beliq request failed with status ${e}`,{code:r?.code,status:e,details:r?.details})}function Br(e){return"bearer"===e.auth?{Authorization:`Bearer ${e.apiKey}`}:{"X-API-Key":e.apiKey}}async function Lr(e,t){const n={...Br(e)};t.contentType&&(n["Content-Type"]=t.contentType);const r=void 0!==t.jsonBody?JSON.stringify(t.jsonBody):t.rawBody,o=await e.fetchImpl(function(e,t,n){if(!n)return`${e}${t}`;const r=new URLSearchParams;for(const[e,t]of Object.entries(n))void 0!==t&&r.set(e,String(t));const o=r.toString();return o?`${e}${t}?${o}`:`${e}${t}`}(e.baseUrl,t.path,t.query),{method:t.method,headers:n,body:r}),i=new Uint8Array(await o.arrayBuffer());if(!o.ok)throw Nr(o.status,i);return{status:o.status,headers:o.headers,bytes:i}}function Kr(e){let t;const n=e.get("x-lost-elements");if(n)try{const e=JSON.parse(n);Array.isArray(e)&&(t=e.map(String))}catch{}const r=e.get("x-lost-elements-count");return{sourceFormat:e.get("x-source-format")??void 0,targetFormat:e.get("x-target-format")??void 0,profileDetected:e.get("x-profile-detected")??void 0,lostElementsCount:null!=r?Number(r):void 0,lostElements:t,conversionTools:e.get("x-conversion-tools")??void 0}}var qr=class{#e;constructor(e){if(!e?.apiKey)throw new Error("beliq: apiKey is required");const t=e.fetch??globalThis.fetch;if("function"!=typeof t)throw new Error("beliq: no global fetch available; pass options.fetch");this.#e={apiKey:e.apiKey,baseUrl:(e.baseUrl??"https://api.beliq.eu").replace(/\/+$/,""),auth:e.auth??"header",fetchImpl:t}}async me(){return this.#t({operation:"me"})}async generate(e){const t=await Lr(this.#e,Ur({operation:"generate",...e})),n=t.headers.get("content-type")??"application/octet-stream",r=n.includes("xml");return{contentType:n,bytes:t.bytes,xml:r?Sr(t.bytes):void 0,meta:(o=t.headers,{schematronVersion:o.get("x-schematron-version")??void 0,pdfKind:o.get("x-pdf-kind")??void 0,outputEnvelope:o.get("x-output-envelope")??void 0})};var o}async validate(e,t={}){return this.#t({operation:"validate",...this.#n(e,t),validateFormat:t.format,franceCtc:t.franceCtc})}async parse(e,t={}){return this.#t({operation:"parse",...this.#n(e,t),parseFormat:t.format})}async convert(e,t){const n=await Lr(this.#e,Ur({operation:"convert",...this.#n(e,t),sourceFormat:t.sourceFormat,targetFormat:t.targetFormat,targetProfile:t.targetProfile,dropFranceCtcOverlay:t.dropFranceCtcOverlay}));return{contentType:n.headers.get("content-type")??"application/octet-stream",bytes:n.bytes,meta:Kr(n.headers)}}#n(e,t){const n=function(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("beliq: document must be a string, Uint8Array, ArrayBuffer, or typed array")}(e);return{rawBody:n,rawContentType:t.contentType??(r=n,r.length>=Ir.length&&Ir.every((e,t)=>r[t]===e)?"application/pdf":"application/xml"),advanced:t.advanced};var r}async#t(e){const t=await Lr(this.#e,Ur(e)),n=Rr(t.bytes);if(!1===n?.success)throw Nr(t.status,t.bytes);if(!n||void 0===n.data)throw new Dr("beliq: response was not a JSON envelope",{status:t.status});return n.data}};function Vr(e){let t=e;if("string"==typeof t){const e=t.trim();if(""===e)return;try{t=JSON.parse(e)}catch{return}}if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return Object.keys(e).length>0?e:void 0}}const Jr={"application/pdf":"pdf","application/xml":"xml","text/xml":"xml"};function Wr(e,t){const n=t.split(";")[0].trim().toLowerCase();return`${e}.${Jr[n]??"bin"}`}var Mr={id:"beliq",handler:async(e,t)=>{const{services:n,getSchema:r,database:o,accountability:i,env:s}=t,a=e.apiKey||s.BELIQ_API_KEY||"";if(!a)throw new Error("beliq: no API key. Set the API Key option or the BELIQ_API_KEY environment variable.");const c=function(e){return new qr({apiKey:e})}(a),u=e.operation??"generate",d=e.deliveryMode??"directusFile";try{if("validate"===u)return await c.validate(String(e.validateDocument??""),{format:e.validateFormat||void 0});if("parse"===u)return await c.parse(String(e.parseDocument??""),{format:e.parseFormat||void 0});if("generate"===u){const t=await c.generate({standard:e.standard,invoice:Vr(e.invoice)??{},output:e.output||"xml",profile:e.profile||void 0,pdfTemplateId:e.pdfTemplateId||void 0});return"pdf"!==e.output?{xml:t.xml,contentType:t.contentType,...t.meta}:await Gr({services:n,getSchema:r,database:o,accountability:i,env:s},d,{bytes:t.bytes,contentType:t.contentType,filename:Wr("invoice",t.contentType),folder:e.folder||null,meta:{...t.meta}})}if("convert"===u){const t=await c.convert(String(e.convertDocument??""),{targetFormat:e.targetFormat,targetProfile:e.convertProfile||void 0});return await Gr({services:n,getSchema:r,database:o,accountability:i,env:s},d,{bytes:t.bytes,contentType:t.contentType,filename:Wr("converted",t.contentType),folder:e.folder||null,meta:{lostElements:t.meta.lostElements,lostElementsCount:t.meta.lostElementsCount}})}throw new Error(`beliq: unknown operation "${u}".`)}catch(e){throw function(e){return e instanceof Dr?new Error(e.code?`${e.message} (${e.code})`:e.message):e instanceof Error?e:new Error(String(e))}(e)}}};async function Gr(t,n,r){const o=Buffer.from(r.bytes),i=o.length;if("base64"===n)return{base64:o.toString("base64"),filename:r.filename,contentType:r.contentType,sizeBytes:i,...r.meta};const s=await async function(t,n){const{services:r,getSchema:o,database:i,accountability:s,env:a}=t,{FilesService:c}=r,u=new c({schema:await o(),knex:i,accountability:s}),d=(a.STORAGE_LOCATIONS?String(a.STORAGE_LOCATIONS).split(",")[0].trim():"local")||"local";return u.uploadOne(e.from(n.buffer),{title:n.filename,filename_download:n.filename,type:n.contentType,storage:d,folder:n.folder??null})}(t,{buffer:o,filename:r.filename,contentType:r.contentType,folder:r.folder});return{fileId:s,filename:r.filename,contentType:r.contentType,sizeBytes:i,...r.meta}}export{Mr as default};
|
package/dist/app.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineOperationApp as e}from"@directus/extensions-sdk";const t={auto:"Auto-detect",cii:"CII",ubl:"UBL",xrechnung:"XRechnung",zugferd:"ZUGFeRD",facturx:"Factur-X","peppol-bis":"Peppol BIS",basicwl:"BASIC WL",en16931:"EN 16931",extended:"EXTENDED","extended-ctc-fr":"EXTENDED CTC FR"};function a(e){return e.map(e=>({text:t[e]??e,value:e}))}const o=a(["xrechnung","zugferd","facturx","peppol-bis"]),n=a(["basicwl","en16931","extended","extended-ctc-fr"]),i=a(["auto","cii","ubl"]),r=a(["auto","cii","ubl"]),l=a(["cii","ubl","zugferd","facturx","xrechnung","peppol-bis"]);function d(e){return{hidden:!0,conditions:[{name:"show",rule:e,hidden:!1}]}}var s=e({id:"beliq",name:"beliq",icon:"receipt_long",description:"Generate, validate, parse, and convert EU-compliant e-invoices with beliq.",overview:({operation:e,standard:t,deliveryMode:a})=>[{label:"Operation",text:String(e??"generate")},{label:"Standard",text:String(t??"-")},{label:"Delivery",text:String(a??"directusFile")}],options:[{field:"operation",name:"Operation",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Generate",value:"generate"},{text:"Validate",value:"validate"},{text:"Parse",value:"parse"},{text:"Convert",value:"convert"}]},note:"What beliq should do with the invoice."},schema:{default_value:"generate"}},{field:"standard",name:"Standard",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:o},note:"Target e-invoice standard.",...d({operation:{_eq:"generate"}})},schema:{default_value:"xrechnung"}},{field:"profile",name:"Profile",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:n},note:"EN 16931 data granularity profile (applies to Factur-X / ZUGFeRD).",...d({operation:{_eq:"generate"}})},schema:{default_value:"en16931"}},{field:"output",name:"Output",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"XML",value:"xml"},{text:"PDF (Hybrid)",value:"pdf"}]},note:"XML returns the raw invoice; PDF returns a hybrid PDF/A-3.",...d({operation:{_eq:"generate"}})},schema:{default_value:"xml"}},{field:"invoice",name:"Invoice Data",type:"json",meta:{width:"full",interface:"input-code",options:{language:"json"},note:"Structured invoice: seller, buyer, lines, totals (see docs.beliq.eu).",...d({operation:{_eq:"generate"}})},schema:{default_value:{number:"INV-001",issueDate:"2026-01-31",dueDate:"2026-03-02",currencyCode:"EUR",seller:{name:"Your Company GmbH",address:{line1:"Main St 1",city:"Berlin",postalCode:"10115",countryCode:"DE"},taxId:"DE123456789"},buyer:{name:"Customer SARL",address:{line1:"Rue 2",city:"Paris",postalCode:"75001",countryCode:"FR"}},lines:[{description:"Widget",quantity:2,unitPrice:10,lineTotal:20,vatRate:19,vatCategoryCode:"S"}],taxSummary:[{categoryCode:"S",rate:19,taxableAmount:20,taxAmount:3.8}],paymentTerms:"Net 30",totalNetAmount:20,totalTaxAmount:3.8,totalGrossAmount:23.8}}},{field:"pdfTemplateId",name:"PDF Template ID",type:"string",meta:{width:"half",interface:"input",note:"Optional. Render the PDF from a saved beliq dashboard template.",...d({operation:{_eq:"generate"}})}},{field:"validateFormat",name:"Format",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:i},note:"Input format hint; auto-detect works for most documents.",...d({operation:{_eq:"validate"}})},schema:{default_value:"auto"}},{field:"validateDocument",name:"Document",type:"text",meta:{width:"full",interface:"input-code",options:{language:"xml"},note:"Reference the XML from an earlier flow step, or paste it here.",...d({operation:{_eq:"validate"}})}},{field:"parseFormat",name:"Format",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:r},note:"Input format hint; auto-detect works for most documents.",...d({operation:{_eq:"parse"}})},schema:{default_value:"auto"}},{field:"parseDocument",name:"Document",type:"text",meta:{width:"full",interface:"input-code",options:{language:"xml"},note:"Reference the XML from an earlier flow step, or paste it here.",...d({operation:{_eq:"parse"}})}},{field:"targetFormat",name:"Target Format",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:l},note:"Format to convert the document into.",...d({operation:{_eq:"convert"}})},schema:{default_value:"ubl"}},{field:"convertProfile",name:"Target Profile",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:n},note:"Applies when the target is Factur-X or ZUGFeRD.",...d({operation:{_eq:"convert"}})}},{field:"convertDocument",name:"Document",type:"text",meta:{width:"full",interface:"input-code",options:{language:"xml"},note:"Reference the XML from an earlier flow step, or paste it here.",...d({operation:{_eq:"convert"}})}},{field:"deliveryMode",name:"Delivery",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Save to Directus File",value:"directusFile"},{text:"Base64 (return in output)",value:"base64"}]},note:"How the generated file is returned.",conditions:[{name:"show for byte-producing operations",rule:{operation:{_in:["generate","convert"]}},hidden:!1}],hidden:!0},schema:{default_value:"directusFile"}},{field:"folder",name:"Target Folder",type:"string",meta:{width:"half",interface:"system-folder",note:"Optional folder for the created file.",...d({deliveryMode:{_eq:"directusFile"}})}},{field:"apiKey",name:"API Key",type:"string",meta:{width:"full",interface:"input",options:{masked:!0},note:"beliq API key. Leave blank to use the BELIQ_API_KEY environment variable."}}]});export{s as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "directus-extension-beliq",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Directus Flow operation for beliq: generate, validate, parse, and convert EU-compliant e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS). Saves the result straight into Directus Files.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"directus",
|
|
7
|
+
"directus-extension",
|
|
8
|
+
"directus-custom-extension",
|
|
9
|
+
"directus-extension-operation",
|
|
10
|
+
"beliq",
|
|
11
|
+
"e-invoice",
|
|
12
|
+
"einvoice",
|
|
13
|
+
"xrechnung",
|
|
14
|
+
"zugferd",
|
|
15
|
+
"factur-x",
|
|
16
|
+
"peppol",
|
|
17
|
+
"en16931",
|
|
18
|
+
"compliance"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://beliq.eu",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "beliq",
|
|
24
|
+
"email": "hello@beliq.eu"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/beliq-eu/directus-extension-beliq.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/beliq-eu/directus-extension-beliq/issues"
|
|
32
|
+
},
|
|
33
|
+
"type": "module",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"provenance": true
|
|
42
|
+
},
|
|
43
|
+
"directus:extension": {
|
|
44
|
+
"type": "operation",
|
|
45
|
+
"path": {
|
|
46
|
+
"app": "dist/app.js",
|
|
47
|
+
"api": "dist/api.js"
|
|
48
|
+
},
|
|
49
|
+
"source": {
|
|
50
|
+
"app": "src/app.ts",
|
|
51
|
+
"api": "src/api.ts"
|
|
52
|
+
},
|
|
53
|
+
"host": "^11.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "directus-extension build",
|
|
57
|
+
"prepublishOnly": "directus-extension build",
|
|
58
|
+
"dev": "directus-extension dev",
|
|
59
|
+
"link": "directus-extension link",
|
|
60
|
+
"validate": "directus-extension validate",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest",
|
|
63
|
+
"test:integration": "vitest run test/integration.test.ts",
|
|
64
|
+
"scrub:check": "grep -rn $'\\u2014' src README.md examples && echo 'em-dash found' && exit 1 || echo 'no em-dash'"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@beliq/sdk": "^0.1.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@directus/extensions-sdk": "^17.1.4",
|
|
71
|
+
"@types/node": "^22.10.0",
|
|
72
|
+
"typescript": "^5.7.0",
|
|
73
|
+
"vitest": "^3.2.0"
|
|
74
|
+
}
|
|
75
|
+
}
|