@formfeed/mcp 0.3.11 → 0.3.12
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/bin/formfeed-mcp.mjs +887 -307
- package/package.json +1 -1
package/bin/formfeed-mcp.mjs
CHANGED
|
@@ -914,7 +914,7 @@ var require_version_check = __commonJS({
|
|
|
914
914
|
var require_regex = __commonJS({
|
|
915
915
|
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(exports) {
|
|
916
916
|
"use strict";
|
|
917
|
-
var
|
|
917
|
+
var numeric2 = "[0-9]+";
|
|
918
918
|
var alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
919
919
|
var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
920
920
|
kanji = kanji.replace(/u/g, "\\u");
|
|
@@ -922,10 +922,10 @@ var require_regex = __commonJS({
|
|
|
922
922
|
exports.KANJI = new RegExp(kanji, "g");
|
|
923
923
|
exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
924
924
|
exports.BYTE = new RegExp(byte, "g");
|
|
925
|
-
exports.NUMERIC = new RegExp(
|
|
925
|
+
exports.NUMERIC = new RegExp(numeric2, "g");
|
|
926
926
|
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
927
927
|
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
928
|
-
var TEST_NUMERIC = new RegExp("^" +
|
|
928
|
+
var TEST_NUMERIC = new RegExp("^" + numeric2 + "$");
|
|
929
929
|
var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
930
930
|
exports.testKanji = function testKanji(str2) {
|
|
931
931
|
return TEST_KANJI.test(str2);
|
|
@@ -4409,7 +4409,7 @@ var require_browser = __commonJS({
|
|
|
4409
4409
|
var QRCode = require_qrcode();
|
|
4410
4410
|
var CanvasRenderer = require_canvas();
|
|
4411
4411
|
var SvgRenderer = require_svg_tag();
|
|
4412
|
-
function renderCanvas(renderFunc, canvas,
|
|
4412
|
+
function renderCanvas(renderFunc, canvas, text4, opts, cb) {
|
|
4413
4413
|
const args2 = [].slice.call(arguments, 1);
|
|
4414
4414
|
const argsNum = args2.length;
|
|
4415
4415
|
const isLastArgCb = typeof args2[argsNum - 1] === "function";
|
|
@@ -4421,8 +4421,8 @@ var require_browser = __commonJS({
|
|
|
4421
4421
|
throw new Error("Too few arguments provided");
|
|
4422
4422
|
}
|
|
4423
4423
|
if (argsNum === 2) {
|
|
4424
|
-
cb =
|
|
4425
|
-
|
|
4424
|
+
cb = text4;
|
|
4425
|
+
text4 = canvas;
|
|
4426
4426
|
canvas = opts = void 0;
|
|
4427
4427
|
} else if (argsNum === 3) {
|
|
4428
4428
|
if (canvas.getContext && typeof cb === "undefined") {
|
|
@@ -4430,8 +4430,8 @@ var require_browser = __commonJS({
|
|
|
4430
4430
|
opts = void 0;
|
|
4431
4431
|
} else {
|
|
4432
4432
|
cb = opts;
|
|
4433
|
-
opts =
|
|
4434
|
-
|
|
4433
|
+
opts = text4;
|
|
4434
|
+
text4 = canvas;
|
|
4435
4435
|
canvas = void 0;
|
|
4436
4436
|
}
|
|
4437
4437
|
}
|
|
@@ -4440,16 +4440,16 @@ var require_browser = __commonJS({
|
|
|
4440
4440
|
throw new Error("Too few arguments provided");
|
|
4441
4441
|
}
|
|
4442
4442
|
if (argsNum === 1) {
|
|
4443
|
-
|
|
4443
|
+
text4 = canvas;
|
|
4444
4444
|
canvas = opts = void 0;
|
|
4445
4445
|
} else if (argsNum === 2 && !canvas.getContext) {
|
|
4446
|
-
opts =
|
|
4447
|
-
|
|
4446
|
+
opts = text4;
|
|
4447
|
+
text4 = canvas;
|
|
4448
4448
|
canvas = void 0;
|
|
4449
4449
|
}
|
|
4450
4450
|
return new Promise(function(resolve2, reject) {
|
|
4451
4451
|
try {
|
|
4452
|
-
const data = QRCode.create(
|
|
4452
|
+
const data = QRCode.create(text4, opts);
|
|
4453
4453
|
resolve2(renderFunc(data, canvas, opts));
|
|
4454
4454
|
} catch (e) {
|
|
4455
4455
|
reject(e);
|
|
@@ -4457,7 +4457,7 @@ var require_browser = __commonJS({
|
|
|
4457
4457
|
});
|
|
4458
4458
|
}
|
|
4459
4459
|
try {
|
|
4460
|
-
const data = QRCode.create(
|
|
4460
|
+
const data = QRCode.create(text4, opts);
|
|
4461
4461
|
cb(null, renderFunc(data, canvas, opts));
|
|
4462
4462
|
} catch (e) {
|
|
4463
4463
|
cb(e);
|
|
@@ -4482,8 +4482,8 @@ var require_server = __commonJS({
|
|
|
4482
4482
|
var Utf8Renderer = require_utf8();
|
|
4483
4483
|
var TerminalRenderer = require_terminal2();
|
|
4484
4484
|
var SvgRenderer = require_svg();
|
|
4485
|
-
function checkParams(
|
|
4486
|
-
if (typeof
|
|
4485
|
+
function checkParams(text4, opts, cb) {
|
|
4486
|
+
if (typeof text4 === "undefined") {
|
|
4487
4487
|
throw new Error("String required as first argument");
|
|
4488
4488
|
}
|
|
4489
4489
|
if (typeof cb === "undefined") {
|
|
@@ -4530,11 +4530,11 @@ var require_server = __commonJS({
|
|
|
4530
4530
|
return Utf8Renderer;
|
|
4531
4531
|
}
|
|
4532
4532
|
}
|
|
4533
|
-
function render(renderFunc,
|
|
4533
|
+
function render(renderFunc, text4, params) {
|
|
4534
4534
|
if (!params.cb) {
|
|
4535
4535
|
return new Promise(function(resolve2, reject) {
|
|
4536
4536
|
try {
|
|
4537
|
-
const data = QRCode.create(
|
|
4537
|
+
const data = QRCode.create(text4, params.opts);
|
|
4538
4538
|
return renderFunc(data, params.opts, function(err, data2) {
|
|
4539
4539
|
return err ? reject(err) : resolve2(data2);
|
|
4540
4540
|
});
|
|
@@ -4544,7 +4544,7 @@ var require_server = __commonJS({
|
|
|
4544
4544
|
});
|
|
4545
4545
|
}
|
|
4546
4546
|
try {
|
|
4547
|
-
const data = QRCode.create(
|
|
4547
|
+
const data = QRCode.create(text4, params.opts);
|
|
4548
4548
|
return renderFunc(data, params.opts, params.cb);
|
|
4549
4549
|
} catch (e) {
|
|
4550
4550
|
params.cb(e);
|
|
@@ -4552,43 +4552,43 @@ var require_server = __commonJS({
|
|
|
4552
4552
|
}
|
|
4553
4553
|
exports.create = QRCode.create;
|
|
4554
4554
|
exports.toCanvas = require_browser().toCanvas;
|
|
4555
|
-
exports.toString = function toString2(
|
|
4556
|
-
const params = checkParams(
|
|
4555
|
+
exports.toString = function toString2(text4, opts, cb) {
|
|
4556
|
+
const params = checkParams(text4, opts, cb);
|
|
4557
4557
|
const type = params.opts ? params.opts.type : void 0;
|
|
4558
4558
|
const renderer = getStringRendererFromType(type);
|
|
4559
|
-
return render(renderer.render,
|
|
4559
|
+
return render(renderer.render, text4, params);
|
|
4560
4560
|
};
|
|
4561
|
-
exports.toDataURL = function toDataURL(
|
|
4562
|
-
const params = checkParams(
|
|
4561
|
+
exports.toDataURL = function toDataURL(text4, opts, cb) {
|
|
4562
|
+
const params = checkParams(text4, opts, cb);
|
|
4563
4563
|
const renderer = getRendererFromType(params.opts.type);
|
|
4564
|
-
return render(renderer.renderToDataURL,
|
|
4564
|
+
return render(renderer.renderToDataURL, text4, params);
|
|
4565
4565
|
};
|
|
4566
|
-
exports.toBuffer = function toBuffer(
|
|
4567
|
-
const params = checkParams(
|
|
4566
|
+
exports.toBuffer = function toBuffer(text4, opts, cb) {
|
|
4567
|
+
const params = checkParams(text4, opts, cb);
|
|
4568
4568
|
const renderer = getRendererFromType(params.opts.type);
|
|
4569
|
-
return render(renderer.renderToBuffer,
|
|
4569
|
+
return render(renderer.renderToBuffer, text4, params);
|
|
4570
4570
|
};
|
|
4571
|
-
exports.toFile = function toFile(path,
|
|
4572
|
-
if (typeof path !== "string" || !(typeof
|
|
4571
|
+
exports.toFile = function toFile(path, text4, opts, cb) {
|
|
4572
|
+
if (typeof path !== "string" || !(typeof text4 === "string" || typeof text4 === "object")) {
|
|
4573
4573
|
throw new Error("Invalid argument");
|
|
4574
4574
|
}
|
|
4575
4575
|
if (arguments.length < 3 && !canPromise()) {
|
|
4576
4576
|
throw new Error("Too few arguments provided");
|
|
4577
4577
|
}
|
|
4578
|
-
const params = checkParams(
|
|
4578
|
+
const params = checkParams(text4, opts, cb);
|
|
4579
4579
|
const type = params.opts.type || getTypeFromFilename(path);
|
|
4580
4580
|
const renderer = getRendererFromType(type);
|
|
4581
4581
|
const renderToFile = renderer.renderToFile.bind(null, path);
|
|
4582
|
-
return render(renderToFile,
|
|
4582
|
+
return render(renderToFile, text4, params);
|
|
4583
4583
|
};
|
|
4584
|
-
exports.toFileStream = function toFileStream(stream,
|
|
4584
|
+
exports.toFileStream = function toFileStream(stream, text4, opts) {
|
|
4585
4585
|
if (arguments.length < 2) {
|
|
4586
4586
|
throw new Error("Too few arguments provided");
|
|
4587
4587
|
}
|
|
4588
|
-
const params = checkParams(
|
|
4588
|
+
const params = checkParams(text4, opts, stream.emit.bind(stream, "error"));
|
|
4589
4589
|
const renderer = getRendererFromType("png");
|
|
4590
4590
|
const renderToFileStream = renderer.renderToFileStream.bind(null, stream);
|
|
4591
|
-
render(renderToFileStream,
|
|
4591
|
+
render(renderToFileStream, text4, params);
|
|
4592
4592
|
};
|
|
4593
4593
|
}
|
|
4594
4594
|
});
|
|
@@ -4707,13 +4707,13 @@ var require_exception = __commonJS({
|
|
|
4707
4707
|
exports.__esModule = true;
|
|
4708
4708
|
var errorProps = ["description", "fileName", "lineNumber", "endLineNumber", "message", "name", "number", "stack"];
|
|
4709
4709
|
function Exception(message2, node) {
|
|
4710
|
-
var loc = node && node.loc,
|
|
4710
|
+
var loc = node && node.loc, line2 = void 0, endLineNumber = void 0, column = void 0, endColumn = void 0;
|
|
4711
4711
|
if (loc) {
|
|
4712
|
-
|
|
4712
|
+
line2 = loc.start.line;
|
|
4713
4713
|
endLineNumber = loc.end.line;
|
|
4714
4714
|
column = loc.start.column;
|
|
4715
4715
|
endColumn = loc.end.column;
|
|
4716
|
-
message2 += " - " +
|
|
4716
|
+
message2 += " - " + line2 + ":" + column;
|
|
4717
4717
|
}
|
|
4718
4718
|
var tmp = Error.prototype.constructor.call(this, message2);
|
|
4719
4719
|
for (var idx = 0; idx < errorProps.length; idx++) {
|
|
@@ -4724,7 +4724,7 @@ var require_exception = __commonJS({
|
|
|
4724
4724
|
}
|
|
4725
4725
|
try {
|
|
4726
4726
|
if (loc) {
|
|
4727
|
-
this.lineNumber =
|
|
4727
|
+
this.lineNumber = line2;
|
|
4728
4728
|
this.endLineNumber = endLineNumber;
|
|
4729
4729
|
if (Object.defineProperty) {
|
|
4730
4730
|
Object.defineProperty(this, "column", {
|
|
@@ -8428,10 +8428,10 @@ var require_source_map_consumer = __commonJS({
|
|
|
8428
8428
|
}, this).forEach(aCallback, context);
|
|
8429
8429
|
};
|
|
8430
8430
|
SourceMapConsumer.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
|
|
8431
|
-
var
|
|
8431
|
+
var line2 = util.getArg(aArgs, "line");
|
|
8432
8432
|
var needle = {
|
|
8433
8433
|
source: util.getArg(aArgs, "source"),
|
|
8434
|
-
originalLine:
|
|
8434
|
+
originalLine: line2,
|
|
8435
8435
|
originalColumn: util.getArg(aArgs, "column", 0)
|
|
8436
8436
|
};
|
|
8437
8437
|
needle.source = this._findSourceIndex(needle.source);
|
|
@@ -8461,7 +8461,7 @@ var require_source_map_consumer = __commonJS({
|
|
|
8461
8461
|
}
|
|
8462
8462
|
} else {
|
|
8463
8463
|
var originalColumn = mapping.originalColumn;
|
|
8464
|
-
while (mapping && mapping.originalLine ===
|
|
8464
|
+
while (mapping && mapping.originalLine === line2 && mapping.originalColumn == originalColumn) {
|
|
8465
8465
|
mappings.push({
|
|
8466
8466
|
line: util.getArg(mapping, "generatedLine", null),
|
|
8467
8467
|
column: util.getArg(mapping, "generatedColumn", null),
|
|
@@ -9240,7 +9240,7 @@ var require_code_gen = __commonJS({
|
|
|
9240
9240
|
}
|
|
9241
9241
|
var SourceMap;
|
|
9242
9242
|
if (!SourceNode) {
|
|
9243
|
-
SourceNode = function(
|
|
9243
|
+
SourceNode = function(line2, column, srcFile, chunks) {
|
|
9244
9244
|
this.src = "";
|
|
9245
9245
|
if (chunks) {
|
|
9246
9246
|
this.add(chunks);
|
|
@@ -9295,8 +9295,8 @@ var require_code_gen = __commonJS({
|
|
|
9295
9295
|
},
|
|
9296
9296
|
merge: function merge2() {
|
|
9297
9297
|
var source = this.empty();
|
|
9298
|
-
this.each(function(
|
|
9299
|
-
source.add([" ",
|
|
9298
|
+
this.each(function(line2) {
|
|
9299
|
+
source.add([" ", line2, "\n"]);
|
|
9300
9300
|
});
|
|
9301
9301
|
return source;
|
|
9302
9302
|
},
|
|
@@ -9559,14 +9559,14 @@ var require_javascript_compiler = __commonJS({
|
|
|
9559
9559
|
},
|
|
9560
9560
|
mergeSource: function mergeSource(varDeclarations) {
|
|
9561
9561
|
var isSimple = this.environment.isSimple, appendOnly = !this.forceBuffer, appendFirst = void 0, sourceSeen = void 0, bufferStart = void 0, bufferEnd = void 0;
|
|
9562
|
-
this.source.each(function(
|
|
9563
|
-
if (
|
|
9562
|
+
this.source.each(function(line2) {
|
|
9563
|
+
if (line2.appendToBuffer) {
|
|
9564
9564
|
if (bufferStart) {
|
|
9565
|
-
|
|
9565
|
+
line2.prepend(" + ");
|
|
9566
9566
|
} else {
|
|
9567
|
-
bufferStart =
|
|
9567
|
+
bufferStart = line2;
|
|
9568
9568
|
}
|
|
9569
|
-
bufferEnd =
|
|
9569
|
+
bufferEnd = line2;
|
|
9570
9570
|
} else {
|
|
9571
9571
|
if (bufferStart) {
|
|
9572
9572
|
if (!sourceSeen) {
|
|
@@ -11590,12 +11590,12 @@ var require_nunjucks = __commonJS({
|
|
|
11590
11590
|
var CallExtensionAsync = CallExtension.extend("CallExtensionAsync");
|
|
11591
11591
|
function print(str2, indent, inline) {
|
|
11592
11592
|
var lines = str2.split("\n");
|
|
11593
|
-
lines.forEach(function(
|
|
11594
|
-
if (
|
|
11593
|
+
lines.forEach(function(line2, i) {
|
|
11594
|
+
if (line2 && (inline && i > 0 || !inline)) {
|
|
11595
11595
|
process.stdout.write(" ".repeat(indent));
|
|
11596
11596
|
}
|
|
11597
11597
|
var nl3 = i === lines.length - 1 ? "" : "\n";
|
|
11598
|
-
process.stdout.write("" +
|
|
11598
|
+
process.stdout.write("" + line2 + nl3);
|
|
11599
11599
|
});
|
|
11600
11600
|
}
|
|
11601
11601
|
function printNodes(node, indent) {
|
|
@@ -11780,8 +11780,8 @@ var require_nunjucks = __commonJS({
|
|
|
11780
11780
|
for (var _len = arguments.length, lines = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11781
11781
|
lines[_key] = arguments[_key];
|
|
11782
11782
|
}
|
|
11783
|
-
lines.forEach(function(
|
|
11784
|
-
return _this._emitLine(
|
|
11783
|
+
lines.forEach(function(line2) {
|
|
11784
|
+
return _this._emitLine(line2);
|
|
11785
11785
|
});
|
|
11786
11786
|
};
|
|
11787
11787
|
_proto._emitFuncBegin = function _emitFuncBegin(node, name) {
|
|
@@ -15081,27 +15081,27 @@ var require_nunjucks = __commonJS({
|
|
|
15081
15081
|
return this;
|
|
15082
15082
|
};
|
|
15083
15083
|
EventEmitter.prototype.removeListener = function removeListener(type, listener) {
|
|
15084
|
-
var
|
|
15084
|
+
var list3, events, position, i, originalListener;
|
|
15085
15085
|
checkListener(listener);
|
|
15086
15086
|
events = this._events;
|
|
15087
15087
|
if (events === void 0)
|
|
15088
15088
|
return this;
|
|
15089
|
-
|
|
15090
|
-
if (
|
|
15089
|
+
list3 = events[type];
|
|
15090
|
+
if (list3 === void 0)
|
|
15091
15091
|
return this;
|
|
15092
|
-
if (
|
|
15092
|
+
if (list3 === listener || list3.listener === listener) {
|
|
15093
15093
|
if (--this._eventsCount === 0)
|
|
15094
15094
|
this._events = /* @__PURE__ */ Object.create(null);
|
|
15095
15095
|
else {
|
|
15096
15096
|
delete events[type];
|
|
15097
15097
|
if (events.removeListener)
|
|
15098
|
-
this.emit("removeListener", type,
|
|
15098
|
+
this.emit("removeListener", type, list3.listener || listener);
|
|
15099
15099
|
}
|
|
15100
|
-
} else if (typeof
|
|
15100
|
+
} else if (typeof list3 !== "function") {
|
|
15101
15101
|
position = -1;
|
|
15102
|
-
for (i =
|
|
15103
|
-
if (
|
|
15104
|
-
originalListener =
|
|
15102
|
+
for (i = list3.length - 1; i >= 0; i--) {
|
|
15103
|
+
if (list3[i] === listener || list3[i].listener === listener) {
|
|
15104
|
+
originalListener = list3[i].listener;
|
|
15105
15105
|
position = i;
|
|
15106
15106
|
break;
|
|
15107
15107
|
}
|
|
@@ -15109,12 +15109,12 @@ var require_nunjucks = __commonJS({
|
|
|
15109
15109
|
if (position < 0)
|
|
15110
15110
|
return this;
|
|
15111
15111
|
if (position === 0)
|
|
15112
|
-
|
|
15112
|
+
list3.shift();
|
|
15113
15113
|
else {
|
|
15114
|
-
spliceOne(
|
|
15114
|
+
spliceOne(list3, position);
|
|
15115
15115
|
}
|
|
15116
|
-
if (
|
|
15117
|
-
events[type] =
|
|
15116
|
+
if (list3.length === 1)
|
|
15117
|
+
events[type] = list3[0];
|
|
15118
15118
|
if (events.removeListener !== void 0)
|
|
15119
15119
|
this.emit("removeListener", type, originalListener || listener);
|
|
15120
15120
|
}
|
|
@@ -15207,10 +15207,10 @@ var require_nunjucks = __commonJS({
|
|
|
15207
15207
|
copy[i] = arr[i];
|
|
15208
15208
|
return copy;
|
|
15209
15209
|
}
|
|
15210
|
-
function spliceOne(
|
|
15211
|
-
for (; index + 1 <
|
|
15212
|
-
|
|
15213
|
-
|
|
15210
|
+
function spliceOne(list3, index) {
|
|
15211
|
+
for (; index + 1 < list3.length; index++)
|
|
15212
|
+
list3[index] = list3[index + 1];
|
|
15213
|
+
list3.pop();
|
|
15214
15214
|
}
|
|
15215
15215
|
function unwrapListeners(arr) {
|
|
15216
15216
|
var ret = new Array(arr.length);
|
|
@@ -15593,7 +15593,7 @@ var require_nunjucks = __commonJS({
|
|
|
15593
15593
|
return 0;
|
|
15594
15594
|
}
|
|
15595
15595
|
exports2.length = lengthFilter;
|
|
15596
|
-
function
|
|
15596
|
+
function list3(val2) {
|
|
15597
15597
|
if (lib.isString(val2)) {
|
|
15598
15598
|
return val2.split("");
|
|
15599
15599
|
} else if (lib.isObject(val2)) {
|
|
@@ -15610,7 +15610,7 @@ var require_nunjucks = __commonJS({
|
|
|
15610
15610
|
throw new lib.TemplateError("list filter: type not iterable");
|
|
15611
15611
|
}
|
|
15612
15612
|
}
|
|
15613
|
-
exports2.list =
|
|
15613
|
+
exports2.list = list3;
|
|
15614
15614
|
function lower(str2) {
|
|
15615
15615
|
str2 = normalize(str2, "");
|
|
15616
15616
|
return str2.toLowerCase();
|
|
@@ -15699,7 +15699,7 @@ var require_nunjucks = __commonJS({
|
|
|
15699
15699
|
function reverse(val2) {
|
|
15700
15700
|
var arr;
|
|
15701
15701
|
if (lib.isString(val2)) {
|
|
15702
|
-
arr =
|
|
15702
|
+
arr = list3(val2);
|
|
15703
15703
|
} else {
|
|
15704
15704
|
arr = lib.map(val2, function(v2) {
|
|
15705
15705
|
return v2;
|
|
@@ -16850,26 +16850,26 @@ var require_liquid_node = __commonJS({
|
|
|
16850
16850
|
}
|
|
16851
16851
|
};
|
|
16852
16852
|
function mkContext(token) {
|
|
16853
|
-
const [
|
|
16853
|
+
const [line2, col] = token.getPosition();
|
|
16854
16854
|
const lines = token.input.split("\n");
|
|
16855
|
-
const begin = Math.max(
|
|
16856
|
-
const end = Math.min(
|
|
16855
|
+
const begin = Math.max(line2 - 2, 1);
|
|
16856
|
+
const end = Math.min(line2 + 3, lines.length);
|
|
16857
16857
|
const context = range2(begin, end + 1).map((lineNumber) => {
|
|
16858
|
-
const rowIndicator = lineNumber ===
|
|
16858
|
+
const rowIndicator = lineNumber === line2 ? ">> " : " ";
|
|
16859
16859
|
const num = padStart(String(lineNumber), String(end).length);
|
|
16860
|
-
let
|
|
16861
|
-
const colIndicator = lineNumber ===
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
return
|
|
16860
|
+
let text4 = `${rowIndicator}${num}| `;
|
|
16861
|
+
const colIndicator = lineNumber === line2 ? "\n" + padStart("^", col + text4.length) : "";
|
|
16862
|
+
text4 += lines[lineNumber - 1];
|
|
16863
|
+
text4 += colIndicator;
|
|
16864
|
+
return text4;
|
|
16865
16865
|
}).join("\n");
|
|
16866
16866
|
return context;
|
|
16867
16867
|
}
|
|
16868
16868
|
function mkMessage(msg, token) {
|
|
16869
16869
|
if (token.file)
|
|
16870
16870
|
msg += `, file:${token.file}`;
|
|
16871
|
-
const [
|
|
16872
|
-
msg += `, line:${
|
|
16871
|
+
const [line2, col] = token.getPosition();
|
|
16872
|
+
msg += `, line:${line2}, col:${col}`;
|
|
16873
16873
|
return msg;
|
|
16874
16874
|
}
|
|
16875
16875
|
var TYPES = [0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 4, 4, 4, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 8, 0, 0, 0, 0, 8, 0, 0, 0, 64, 0, 65, 0, 0, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, 0, 2, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
|
|
@@ -18291,12 +18291,12 @@ var require_liquid_node = __commonJS({
|
|
|
18291
18291
|
return nameOrFunction;
|
|
18292
18292
|
}
|
|
18293
18293
|
function normalizeDirectoryList(value) {
|
|
18294
|
-
let
|
|
18294
|
+
let list3 = [];
|
|
18295
18295
|
if (isArray(value))
|
|
18296
|
-
|
|
18296
|
+
list3 = value;
|
|
18297
18297
|
if (isString(value))
|
|
18298
|
-
|
|
18299
|
-
return
|
|
18298
|
+
list3 = [value];
|
|
18299
|
+
return list3;
|
|
18300
18300
|
}
|
|
18301
18301
|
function whiteSpaceCtrl(tokens, options) {
|
|
18302
18302
|
let inRaw = false;
|
|
@@ -19597,7 +19597,7 @@ var require_liquid_node = __commonJS({
|
|
|
19597
19597
|
BlockMode2[BlockMode2["OUTPUT"] = 0] = "OUTPUT";
|
|
19598
19598
|
BlockMode2[BlockMode2["STORE"] = 1] = "STORE";
|
|
19599
19599
|
})(BlockMode || (BlockMode = {}));
|
|
19600
|
-
var
|
|
19600
|
+
var abs2 = argumentsToNumber(Math.abs);
|
|
19601
19601
|
var at_least = argumentsToNumber(Math.max);
|
|
19602
19602
|
var at_most = argumentsToNumber(Math.min);
|
|
19603
19603
|
var ceil = argumentsToNumber(Math.ceil);
|
|
@@ -19616,7 +19616,7 @@ var require_liquid_node = __commonJS({
|
|
|
19616
19616
|
}
|
|
19617
19617
|
var mathFilters = /* @__PURE__ */ Object.freeze({
|
|
19618
19618
|
__proto__: null,
|
|
19619
|
-
abs,
|
|
19619
|
+
abs: abs2,
|
|
19620
19620
|
at_least,
|
|
19621
19621
|
at_most,
|
|
19622
19622
|
ceil,
|
|
@@ -21416,10 +21416,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
21416
21416
|
|
|
21417
21417
|
// packages/engine/src/lib/errors.ts
|
|
21418
21418
|
var EngineSyntaxError = class extends Error {
|
|
21419
|
-
constructor(engine, message2,
|
|
21419
|
+
constructor(engine, message2, line2, column) {
|
|
21420
21420
|
super(message2);
|
|
21421
21421
|
this.engine = engine;
|
|
21422
|
-
this.line =
|
|
21422
|
+
this.line = line2;
|
|
21423
21423
|
this.column = column;
|
|
21424
21424
|
}
|
|
21425
21425
|
name = "EngineSyntaxError";
|
|
@@ -21435,10 +21435,10 @@ var RenderLimitError = class extends Error {
|
|
|
21435
21435
|
name = "RenderLimitError";
|
|
21436
21436
|
};
|
|
21437
21437
|
var RenderError = class extends Error {
|
|
21438
|
-
constructor(engine, message2,
|
|
21438
|
+
constructor(engine, message2, line2, column) {
|
|
21439
21439
|
super(message2);
|
|
21440
21440
|
this.engine = engine;
|
|
21441
|
-
this.line =
|
|
21441
|
+
this.line = line2;
|
|
21442
21442
|
this.column = column;
|
|
21443
21443
|
}
|
|
21444
21444
|
name = "RenderError";
|
|
@@ -67329,9 +67329,9 @@ function bwipp_validatetext() {
|
|
|
67329
67329
|
}
|
|
67330
67330
|
$_ = $__;
|
|
67331
67331
|
}
|
|
67332
|
-
function bwipp_encode(bwipjs, encoder3,
|
|
67333
|
-
if (typeof
|
|
67334
|
-
throw new Error("bwipp.typeError: barcode text not a string (" +
|
|
67332
|
+
function bwipp_encode(bwipjs, encoder3, text4, opts, dontdraw) {
|
|
67333
|
+
if (typeof text4 !== "string") {
|
|
67334
|
+
throw new Error("bwipp.typeError: barcode text not a string (" + text4 + ")");
|
|
67335
67335
|
}
|
|
67336
67336
|
opts = opts || {};
|
|
67337
67337
|
if (typeof opts === "string") {
|
|
@@ -67356,11 +67356,11 @@ function bwipp_encode(bwipjs, encoder3, text3, opts, dontdraw) {
|
|
|
67356
67356
|
throw new Error("bwipp.typeError: options not an object");
|
|
67357
67357
|
}
|
|
67358
67358
|
if (opts.binarytext) {
|
|
67359
|
-
if (/[\u0100-\uffff]/.test(
|
|
67359
|
+
if (/[\u0100-\uffff]/.test(text4)) {
|
|
67360
67360
|
throw new Error("bwip-js: 16-bit chars not allowed with binarytext");
|
|
67361
67361
|
}
|
|
67362
|
-
} else if (/[\u0080-\uffff]/.test(
|
|
67363
|
-
|
|
67362
|
+
} else if (/[\u0080-\uffff]/.test(text4)) {
|
|
67363
|
+
text4 = unescape(encodeURIComponent(text4));
|
|
67364
67364
|
}
|
|
67365
67365
|
if (opts.dontdraw) {
|
|
67366
67366
|
dontdraw = true;
|
|
@@ -67372,7 +67372,7 @@ function bwipp_encode(bwipjs, encoder3, text3, opts, dontdraw) {
|
|
|
67372
67372
|
}
|
|
67373
67373
|
}
|
|
67374
67374
|
$$ = bwipjs;
|
|
67375
|
-
$k = [
|
|
67375
|
+
$k = [text4, map];
|
|
67376
67376
|
$j = 2;
|
|
67377
67377
|
$_ = {
|
|
67378
67378
|
bwipjs_rawstack: dontdraw ? [] : false
|
|
@@ -67683,8 +67683,8 @@ var BWIPJS_OPTIONS = {
|
|
|
67683
67683
|
backgroundcolor: 1
|
|
67684
67684
|
};
|
|
67685
67685
|
function _Render(encoder3, options, drawing) {
|
|
67686
|
-
var
|
|
67687
|
-
if (!
|
|
67686
|
+
var text4 = options.text;
|
|
67687
|
+
if (!text4) {
|
|
67688
67688
|
throw new ReferenceError("bwip-js: bar code text not specified.");
|
|
67689
67689
|
}
|
|
67690
67690
|
FixupOptions(options);
|
|
@@ -67709,7 +67709,7 @@ function _Render(encoder3, options, drawing) {
|
|
|
67709
67709
|
bwippopts.width = bwippopts.width / 25.4 || 0;
|
|
67710
67710
|
}
|
|
67711
67711
|
bw.scale(scaleX, scaleY);
|
|
67712
|
-
bwipp_encode(bw, encoder3,
|
|
67712
|
+
bwipp_encode(bw, encoder3, text4, bwippopts);
|
|
67713
67713
|
return bw.render();
|
|
67714
67714
|
}
|
|
67715
67715
|
var BWIPJS = (function() {
|
|
@@ -67831,8 +67831,8 @@ var BWIPJS = (function() {
|
|
|
67831
67831
|
BWIPJS2.prototype.setlinewidth = function(w) {
|
|
67832
67832
|
this.g_penw = w;
|
|
67833
67833
|
};
|
|
67834
|
-
BWIPJS2.prototype.selectfont = function(f2,
|
|
67835
|
-
this.g_font = { FontName: this.jsstring(f2), FontSize: +
|
|
67834
|
+
BWIPJS2.prototype.selectfont = function(f2, z4) {
|
|
67835
|
+
this.g_font = { FontName: this.jsstring(f2), FontSize: +z4 };
|
|
67836
67836
|
};
|
|
67837
67837
|
BWIPJS2.prototype.getfont = function() {
|
|
67838
67838
|
return this.g_font.FontName;
|
|
@@ -68937,7 +68937,7 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
68937
68937
|
var floor = Math.floor;
|
|
68938
68938
|
var ceil = Math.ceil;
|
|
68939
68939
|
var sqrt = Math.sqrt;
|
|
68940
|
-
var
|
|
68940
|
+
var abs2 = Math.abs;
|
|
68941
68941
|
function oalloc(n) {
|
|
68942
68942
|
var o = [];
|
|
68943
68943
|
for (var i = 0; i < n; i++) {
|
|
@@ -69948,7 +69948,7 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
69948
69948
|
dx6 = dy6 = s[10];
|
|
69949
69949
|
dx = dx1 + dx2 + dx3 + dx4 + dx5;
|
|
69950
69950
|
dy = dy1 + dy2 + dy3 + dy4 + dy5;
|
|
69951
|
-
if (
|
|
69951
|
+
if (abs2(dx) > abs2(dy)) {
|
|
69952
69952
|
dy6 = -dy;
|
|
69953
69953
|
} else {
|
|
69954
69954
|
dx6 = -dx;
|
|
@@ -70201,7 +70201,7 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
70201
70201
|
}
|
|
70202
70202
|
function stbtt__rasterize_sorted_edges(result, edges, nedges, vsubsample, off_x, off_y) {
|
|
70203
70203
|
vsubsample |= 0, off_x |= 0, off_y |= 0;
|
|
70204
|
-
var active = null,
|
|
70204
|
+
var active = null, z4;
|
|
70205
70205
|
var y2 = off_y, j2 = 0, i;
|
|
70206
70206
|
var scanline = new Float32Array(result.w * 2 + 1);
|
|
70207
70207
|
var scanline2 = scanline.subarray(result.w);
|
|
@@ -70215,18 +70215,18 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
70215
70215
|
for (var $i = 0, $l = scanline.length; $i < $l; $i++) scanline[$i] = 0;
|
|
70216
70216
|
}
|
|
70217
70217
|
while (step) {
|
|
70218
|
-
|
|
70219
|
-
step =
|
|
70220
|
-
if (
|
|
70221
|
-
|
|
70218
|
+
z4 = step;
|
|
70219
|
+
step = z4.next;
|
|
70220
|
+
if (z4.ey <= scan_y_top) {
|
|
70221
|
+
z4.direction = 0;
|
|
70222
70222
|
} else {
|
|
70223
70223
|
}
|
|
70224
70224
|
}
|
|
70225
70225
|
while (edges[eoff].y0 <= scan_y_bottom) {
|
|
70226
70226
|
if (edges[eoff].y0 != edges[eoff].y1) {
|
|
70227
|
-
|
|
70228
|
-
|
|
70229
|
-
active =
|
|
70227
|
+
z4 = stbtt__new_active(edges[eoff], off_x, scan_y_top);
|
|
70228
|
+
z4.next = active;
|
|
70229
|
+
active = z4;
|
|
70230
70230
|
}
|
|
70231
70231
|
++eoff;
|
|
70232
70232
|
}
|
|
@@ -70237,7 +70237,7 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
70237
70237
|
var k2, m2;
|
|
70238
70238
|
sum += scanline2[i];
|
|
70239
70239
|
k2 = scanline[i] + sum;
|
|
70240
|
-
k2 =
|
|
70240
|
+
k2 = abs2(k2) * 255 + 0.5;
|
|
70241
70241
|
m2 = k2 >>> 0;
|
|
70242
70242
|
if (m2 > 255) {
|
|
70243
70243
|
m2 = 255;
|
|
@@ -70246,9 +70246,9 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
70246
70246
|
}
|
|
70247
70247
|
step = active;
|
|
70248
70248
|
while (step) {
|
|
70249
|
-
|
|
70250
|
-
|
|
70251
|
-
step =
|
|
70249
|
+
z4 = step;
|
|
70250
|
+
z4.fx += z4.fdx;
|
|
70251
|
+
step = z4.next;
|
|
70252
70252
|
}
|
|
70253
70253
|
++y2;
|
|
70254
70254
|
++j2;
|
|
@@ -70268,12 +70268,12 @@ var STBTT = /* @__PURE__ */ (function() {
|
|
|
70268
70268
|
}
|
|
70269
70269
|
function stbtt__sort_edges_quicksort(p, o, n) {
|
|
70270
70270
|
while (n > 12) {
|
|
70271
|
-
var t, c, i, j2,
|
|
70271
|
+
var t, c, i, j2, z4, m2 = n >> 1, c01 = p[o].y0 < p[o + m2].y0, c12 = p[o + m2].y0 < p[o + n - 1].y0;
|
|
70272
70272
|
if (c01 != c12) {
|
|
70273
70273
|
c = p[o].y0 < p[o + n - 11].y0;
|
|
70274
|
-
|
|
70275
|
-
t = p[o +
|
|
70276
|
-
p[o +
|
|
70274
|
+
z4 = c == c12 ? 0 : n - 1;
|
|
70275
|
+
t = p[o + z4];
|
|
70276
|
+
p[o + z4] = p[o + m2];
|
|
70277
70277
|
p[o + m2] = t;
|
|
70278
70278
|
}
|
|
70279
70279
|
t = p[o];
|
|
@@ -70688,9 +70688,9 @@ var barcodeTypes = {
|
|
|
70688
70688
|
};
|
|
70689
70689
|
var ownTextLayout = /* @__PURE__ */ new Set(["ean13", "ean8", "upca"]);
|
|
70690
70690
|
function codeText(helper, value) {
|
|
70691
|
-
const
|
|
70692
|
-
if (
|
|
70693
|
-
return
|
|
70691
|
+
const text4 = value === void 0 || value === null ? "" : String(value);
|
|
70692
|
+
if (text4 === "") throw new Error(`${helper}: nothing to encode, the value is empty or missing from the data`);
|
|
70693
|
+
return text4;
|
|
70694
70694
|
}
|
|
70695
70695
|
var codeHelpers = [
|
|
70696
70696
|
{
|
|
@@ -70728,17 +70728,17 @@ var codeHelpers = [
|
|
|
70728
70728
|
fn: (ctx, value, options) => {
|
|
70729
70729
|
const o = options ?? {};
|
|
70730
70730
|
const bcid = barcodeTypes[String(o.type ?? "code128").toLowerCase()] ?? "code128";
|
|
70731
|
-
const
|
|
70731
|
+
const text4 = codeText("barcode", value);
|
|
70732
70732
|
const svg = ToSVG({
|
|
70733
70733
|
bcid,
|
|
70734
|
-
text:
|
|
70734
|
+
text: text4,
|
|
70735
70735
|
height: o.height ?? 12,
|
|
70736
70736
|
...o.width === void 0 ? {} : { width: o.width },
|
|
70737
70737
|
scale: o.scale ?? 2,
|
|
70738
70738
|
includetext: o.text !== false,
|
|
70739
70739
|
...ownTextLayout.has(bcid) ? {} : { textxalign: "center" }
|
|
70740
70740
|
});
|
|
70741
|
-
if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, alt: `Barcode ${
|
|
70741
|
+
if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, alt: `Barcode ${text4}` });
|
|
70742
70742
|
return svgDataUri(svg);
|
|
70743
70743
|
}
|
|
70744
70744
|
},
|
|
@@ -70764,12 +70764,12 @@ var codeHelpers = [
|
|
|
70764
70764
|
...input && typeof input === "object" ? input : typeof input === "string" && input ? { iban: input } : {},
|
|
70765
70765
|
...options ?? {}
|
|
70766
70766
|
};
|
|
70767
|
-
const
|
|
70767
|
+
const payment2 = {};
|
|
70768
70768
|
const qr = {};
|
|
70769
70769
|
for (const [key, value] of Object.entries(fields))
|
|
70770
|
-
(EPC_FIELDS.has(key) ?
|
|
70770
|
+
(EPC_FIELDS.has(key) ? payment2 : qr)[key] = value;
|
|
70771
70771
|
const o = { ecc: "M", ...qr };
|
|
70772
|
-
const svg = qrSvg(epcPayload(
|
|
70772
|
+
const svg = qrSvg(epcPayload(payment2), o);
|
|
70773
70773
|
if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, width: o.size, height: o.size, alt: "GiroCode" });
|
|
70774
70774
|
return svgDataUri(svg);
|
|
70775
70775
|
}
|
|
@@ -77605,8 +77605,8 @@ var currencyValues6 = { currency: (
|
|
|
77605
77605
|
function resolveTranslation(dictionaries, locale, key) {
|
|
77606
77606
|
const lang = locale.split("-")[0] ?? locale;
|
|
77607
77607
|
for (const candidate of [locale, lang, "en"]) {
|
|
77608
|
-
const
|
|
77609
|
-
if (typeof
|
|
77608
|
+
const text4 = dictionaries?.[candidate]?.[key];
|
|
77609
|
+
if (typeof text4 === "string") return { text: text4, from: candidate };
|
|
77610
77610
|
}
|
|
77611
77611
|
return { text: key, from: null };
|
|
77612
77612
|
}
|
|
@@ -78079,9 +78079,9 @@ var formatHelpers = [
|
|
|
78079
78079
|
category: "text"
|
|
78080
78080
|
},
|
|
78081
78081
|
fn: (ctx, key, params) => {
|
|
78082
|
-
const { text:
|
|
78082
|
+
const { text: text4 } = resolveTranslation(ctx.i18n, ctx.locale, str(key));
|
|
78083
78083
|
const p = params ?? {};
|
|
78084
|
-
return
|
|
78084
|
+
return text4.replace(/\{(\w+)\}/g, (_2, name) => str(p[name]));
|
|
78085
78085
|
}
|
|
78086
78086
|
},
|
|
78087
78087
|
{
|
|
@@ -78603,22 +78603,22 @@ function unavailableHelper(name) {
|
|
|
78603
78603
|
}
|
|
78604
78604
|
|
|
78605
78605
|
// packages/engine/src/lib/analysis/tags.ts
|
|
78606
|
-
function rangeAt(
|
|
78606
|
+
function rangeAt(line2, column, length) {
|
|
78607
78607
|
return {
|
|
78608
|
-
start: { line, column },
|
|
78609
|
-
end: { line, column: column + Math.max(1, length) }
|
|
78608
|
+
start: { line: line2, column },
|
|
78609
|
+
end: { line: line2, column: column + Math.max(1, length) }
|
|
78610
78610
|
};
|
|
78611
78611
|
}
|
|
78612
78612
|
function positionOf(source, offset) {
|
|
78613
|
-
let
|
|
78613
|
+
let line2 = 1;
|
|
78614
78614
|
let last = -1;
|
|
78615
78615
|
for (let i = 0; i < offset && i < source.length; i++) {
|
|
78616
78616
|
if (source.charCodeAt(i) === 10) {
|
|
78617
|
-
|
|
78617
|
+
line2++;
|
|
78618
78618
|
last = i;
|
|
78619
78619
|
}
|
|
78620
78620
|
}
|
|
78621
|
-
return { line, column: offset - last };
|
|
78621
|
+
return { line: line2, column: offset - last };
|
|
78622
78622
|
}
|
|
78623
78623
|
function rangeOf(source, start, end) {
|
|
78624
78624
|
return { start: positionOf(source, start), end: positionOf(source, end) };
|
|
@@ -78864,12 +78864,12 @@ function toSyntaxError(e) {
|
|
|
78864
78864
|
const err = e;
|
|
78865
78865
|
const message2 = String(err.message ?? e);
|
|
78866
78866
|
const m2 = /Parse error on line (\d+)/.exec(message2);
|
|
78867
|
-
const
|
|
78867
|
+
const line2 = err.lineNumber ?? (m2 ? Number(m2[1]) : 1);
|
|
78868
78868
|
const column = typeof err.column === "number" ? err.column + 1 : 1;
|
|
78869
78869
|
return new EngineSyntaxError(
|
|
78870
78870
|
"handlebars",
|
|
78871
78871
|
message2.split("\n")[0] ?? message2,
|
|
78872
|
-
|
|
78872
|
+
line2,
|
|
78873
78873
|
column
|
|
78874
78874
|
);
|
|
78875
78875
|
}
|
|
@@ -79179,48 +79179,48 @@ var SPEC = /^(?:([\s\S])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?([,_])?(?:\.(\d+))?([b
|
|
|
79179
79179
|
function group(digits, separator) {
|
|
79180
79180
|
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
79181
79181
|
}
|
|
79182
|
-
function pythonExponent(
|
|
79183
|
-
return
|
|
79182
|
+
function pythonExponent(text4) {
|
|
79183
|
+
return text4.replace(/e([+-])(\d)$/i, (m2, sign, digit) => `${m2[0]}${sign}0${digit}`);
|
|
79184
79184
|
}
|
|
79185
79185
|
function formatNumber(value, type, precision, alternate) {
|
|
79186
79186
|
if (!Number.isFinite(value)) return Number.isNaN(value) ? "nan" : "inf";
|
|
79187
|
-
const
|
|
79187
|
+
const abs2 = Math.abs(value);
|
|
79188
79188
|
switch (type) {
|
|
79189
79189
|
case "f":
|
|
79190
79190
|
case "F":
|
|
79191
|
-
return
|
|
79191
|
+
return abs2.toFixed(precision ?? 6);
|
|
79192
79192
|
case "%":
|
|
79193
|
-
return `${(
|
|
79193
|
+
return `${(abs2 * 100).toFixed(precision ?? 6)}%`;
|
|
79194
79194
|
case "e":
|
|
79195
79195
|
case "E": {
|
|
79196
|
-
const
|
|
79197
|
-
return type === "E" ?
|
|
79196
|
+
const text4 = pythonExponent(abs2.toExponential(precision ?? 6));
|
|
79197
|
+
return type === "E" ? text4.toUpperCase() : text4;
|
|
79198
79198
|
}
|
|
79199
79199
|
case "g":
|
|
79200
79200
|
case "G": {
|
|
79201
79201
|
const p = precision === 0 ? 1 : precision ?? 6;
|
|
79202
|
-
const exp =
|
|
79203
|
-
let
|
|
79202
|
+
const exp = abs2 === 0 ? 0 : Math.floor(Math.log10(abs2));
|
|
79203
|
+
let text4 = exp < -4 || exp >= p ? pythonExponent(abs2.toExponential(p - 1)) : abs2.toFixed(Math.max(0, p - 1 - exp));
|
|
79204
79204
|
if (!alternate) {
|
|
79205
|
-
const [mantissa = "", exponent] =
|
|
79205
|
+
const [mantissa = "", exponent] = text4.split("e");
|
|
79206
79206
|
const trimmed = mantissa.includes(".") ? mantissa.replace(/0+$/, "").replace(/\.$/, "") : mantissa;
|
|
79207
|
-
|
|
79207
|
+
text4 = exponent === void 0 ? trimmed : `${trimmed}e${exponent}`;
|
|
79208
79208
|
}
|
|
79209
|
-
return type === "G" ?
|
|
79209
|
+
return type === "G" ? text4.toUpperCase() : text4;
|
|
79210
79210
|
}
|
|
79211
79211
|
case "d":
|
|
79212
79212
|
case "n":
|
|
79213
|
-
return String(Math.trunc(
|
|
79213
|
+
return String(Math.trunc(abs2));
|
|
79214
79214
|
case "b":
|
|
79215
|
-
return (alternate ? "0b" : "") + Math.trunc(
|
|
79215
|
+
return (alternate ? "0b" : "") + Math.trunc(abs2).toString(2);
|
|
79216
79216
|
case "o":
|
|
79217
|
-
return (alternate ? "0o" : "") + Math.trunc(
|
|
79217
|
+
return (alternate ? "0o" : "") + Math.trunc(abs2).toString(8);
|
|
79218
79218
|
case "x":
|
|
79219
|
-
return (alternate ? "0x" : "") + Math.trunc(
|
|
79219
|
+
return (alternate ? "0x" : "") + Math.trunc(abs2).toString(16);
|
|
79220
79220
|
case "X":
|
|
79221
|
-
return (alternate ? "0X" : "") + Math.trunc(
|
|
79221
|
+
return (alternate ? "0X" : "") + Math.trunc(abs2).toString(16).toUpperCase();
|
|
79222
79222
|
default:
|
|
79223
|
-
return precision === void 0 ? String(
|
|
79223
|
+
return precision === void 0 ? String(abs2) : formatNumber(abs2, "g", precision, alternate);
|
|
79224
79224
|
}
|
|
79225
79225
|
}
|
|
79226
79226
|
function formatValue(value, spec) {
|
|
@@ -79275,35 +79275,35 @@ function lookupField(name, positional, named, next) {
|
|
|
79275
79275
|
function pythonFormat(template, positional, named = {}) {
|
|
79276
79276
|
let auto = 0;
|
|
79277
79277
|
const next = () => auto++;
|
|
79278
|
-
const render = (
|
|
79278
|
+
const render = (text4) => {
|
|
79279
79279
|
let out = "";
|
|
79280
|
-
for (let i = 0; i <
|
|
79281
|
-
const ch =
|
|
79280
|
+
for (let i = 0; i < text4.length; i++) {
|
|
79281
|
+
const ch = text4[i];
|
|
79282
79282
|
if (ch === "}") {
|
|
79283
79283
|
out += "}";
|
|
79284
|
-
if (
|
|
79284
|
+
if (text4[i + 1] === "}") i++;
|
|
79285
79285
|
continue;
|
|
79286
79286
|
}
|
|
79287
79287
|
if (ch !== "{") {
|
|
79288
79288
|
out += ch;
|
|
79289
79289
|
continue;
|
|
79290
79290
|
}
|
|
79291
|
-
if (
|
|
79291
|
+
if (text4[i + 1] === "{") {
|
|
79292
79292
|
out += "{";
|
|
79293
79293
|
i++;
|
|
79294
79294
|
continue;
|
|
79295
79295
|
}
|
|
79296
79296
|
let depth = 1;
|
|
79297
79297
|
let j2 = i + 1;
|
|
79298
|
-
for (; j2 <
|
|
79299
|
-
if (
|
|
79300
|
-
else if (
|
|
79298
|
+
for (; j2 < text4.length && depth > 0; j2++) {
|
|
79299
|
+
if (text4[j2] === "{") depth++;
|
|
79300
|
+
else if (text4[j2] === "}") depth--;
|
|
79301
79301
|
}
|
|
79302
79302
|
if (depth > 0) {
|
|
79303
|
-
out +=
|
|
79303
|
+
out += text4.slice(i);
|
|
79304
79304
|
break;
|
|
79305
79305
|
}
|
|
79306
|
-
const field =
|
|
79306
|
+
const field = text4.slice(i + 1, j2 - 1);
|
|
79307
79307
|
const colon = field.indexOf(":");
|
|
79308
79308
|
const head = colon < 0 ? field : field.slice(0, colon);
|
|
79309
79309
|
const name = head.replace(/![rsa]$/, "");
|
|
@@ -79407,7 +79407,7 @@ var stringMethods = {
|
|
|
79407
79407
|
return out;
|
|
79408
79408
|
},
|
|
79409
79409
|
split: (s, sep, max) => sep === void 0 || sep === null ? s.trim().split(/\s+/) : s.split(String(sep), max === void 0 ? void 0 : Number(max) + 1),
|
|
79410
|
-
join: (s,
|
|
79410
|
+
join: (s, list3) => Array.isArray(list3) ? list3.join(s) : String(list3),
|
|
79411
79411
|
format: (s, ...args2) => {
|
|
79412
79412
|
const named = keywordArgs(args2);
|
|
79413
79413
|
return pythonFormat(s, named ? args2.slice(0, -1) : args2, named ?? {});
|
|
@@ -79641,9 +79641,9 @@ function toSyntaxError2(e, fallbackLine = 1) {
|
|
|
79641
79641
|
const fromMessage = /\[Line (\d+), Column (\d+)\]/.exec(
|
|
79642
79642
|
String(err.message ?? "")
|
|
79643
79643
|
);
|
|
79644
|
-
const
|
|
79644
|
+
const line2 = typeof err.lineno === "number" ? err.lineno + 1 : fromMessage ? Number(fromMessage[1]) : fallbackLine;
|
|
79645
79645
|
const column = typeof err.colno === "number" ? err.colno + 1 : fromMessage ? Number(fromMessage[2]) : 1;
|
|
79646
|
-
return new EngineSyntaxError("jinja2", message2,
|
|
79646
|
+
return new EngineSyntaxError("jinja2", message2, line2, column);
|
|
79647
79647
|
}
|
|
79648
79648
|
function nodeRange(node, length = 1) {
|
|
79649
79649
|
return rangeAt(node.lineno + 1, node.colno + 1, length);
|
|
@@ -80138,12 +80138,12 @@ var validationContext3 = {
|
|
|
80138
80138
|
};
|
|
80139
80139
|
function toSyntaxError3(e) {
|
|
80140
80140
|
const err = e;
|
|
80141
|
-
let
|
|
80141
|
+
let line2 = err.line ?? 1;
|
|
80142
80142
|
let column = err.col ?? 1;
|
|
80143
80143
|
const pos = err.token?.getPosition?.();
|
|
80144
|
-
if (pos) [
|
|
80144
|
+
if (pos) [line2, column] = pos;
|
|
80145
80145
|
const message2 = String(err.message ?? e).replace(/,\s*line:\d+,\s*col:\d+/, "").trim();
|
|
80146
|
-
return new EngineSyntaxError("liquid", message2,
|
|
80146
|
+
return new EngineSyntaxError("liquid", message2, line2, column);
|
|
80147
80147
|
}
|
|
80148
80148
|
var identifier = /(?<![\w."'])([A-Za-z_][\w]*)((?:\.[A-Za-z_]\w*|\[\d+\])*)/g;
|
|
80149
80149
|
function pathsIn(expression, base, source, out, scopes) {
|
|
@@ -80432,8 +80432,8 @@ function unionTypes(a, b2) {
|
|
|
80432
80432
|
...Array.isArray(b2) ? b2 : b2 ? [b2] : []
|
|
80433
80433
|
]);
|
|
80434
80434
|
if (set.has("number")) set.delete("integer");
|
|
80435
|
-
const
|
|
80436
|
-
return
|
|
80435
|
+
const list3 = [...set];
|
|
80436
|
+
return list3.length === 1 ? list3[0] : list3;
|
|
80437
80437
|
}
|
|
80438
80438
|
function merge(a, b2) {
|
|
80439
80439
|
if (!a) return b2;
|
|
@@ -80501,9 +80501,9 @@ function inferSchema(sample) {
|
|
|
80501
80501
|
var outputFormats = ["pdf", "png", "jpg", "webp", "docx", "pptx"];
|
|
80502
80502
|
|
|
80503
80503
|
// packages/engine/src/lib/dialect.ts
|
|
80504
|
-
var loop = (engine, item,
|
|
80504
|
+
var loop = (engine, item, list3, body) => engine === "handlebars" ? `{{#each ${list3}}}
|
|
80505
80505
|
${body.replace(new RegExp(`(?<![\\w.])${item}\\.`, "g"), "")}
|
|
80506
|
-
{{/each}}` : `{% for ${item} in ${
|
|
80506
|
+
{{/each}}` : `{% for ${item} in ${list3} %}
|
|
80507
80507
|
${body}
|
|
80508
80508
|
{% endfor %}`;
|
|
80509
80509
|
var val = (engine, expr, filter) => {
|
|
@@ -81040,7 +81040,7 @@ var ASSET_NAME_PATTERN = new RegExp(`^${SEGMENT}(?:/${SEGMENT})*$`);
|
|
|
81040
81040
|
var ASSET_MAX_BYTES = 10 * 1024 * 1024;
|
|
81041
81041
|
|
|
81042
81042
|
// packages/engine/src/lib/generated/frames.ts
|
|
81043
|
-
var textEditRuntime = '"use strict";(()=>{var
|
|
81043
|
+
var textEditRuntime = '"use strict";(()=>{var O=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit="t"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function F(l,d={}){let m=d.clicks!==!1,g=d.live===!0,o=l.document,i=null,s=null,f=e=>{try{l.parent.postMessage(e,"*")}catch{}},v=m?o.querySelector(\'meta[name="formfeed:document"]\')?.getAttribute("content")??null:null,h=!1;l.addEventListener("blur",()=>{h=!0}),l.addEventListener("focus",()=>{h=!1});let y=o.createElement("style");y.setAttribute("data-formfeed","edit"),y.setAttribute("data-pagedjs-ignore",""),y.textContent=O,(o.head??o.documentElement).appendChild(y),m&&o.documentElement.classList.add("ff-edit-mode");let M=e=>(e&&typeof e.closest=="function"?e:null)?.closest("[data-ff-edit]")??null;o.addEventListener("click",e=>{if(!m)return;if(i&&!i.done&&i.element.contains(e.target)){e.stopImmediatePropagation();return}let t=M(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),C(t,{x:e.clientX,y:e.clientY}))},!0);function C(e,t){i&&!i.done&&x();let n=e.getAttribute("data-ff-src")??"",r=e.getBoundingClientRect(),u=Array.from(o.querySelectorAll(`[data-ff-src="${n.replace(/"/g,"")}"]`));s={src:n,element:e,point:t},f({type:"formfeed:edit-request",src:n,doc:v,edit:e.getAttribute("data-ff-edit"),text:e.textContent??"",elements:e.childElementCount,count:u.length,index:Math.max(0,u.indexOf(e)),split:e.hasAttribute("data-split-from")||e.hasAttribute("data-split-to"),rect:{left:r.left,top:r.top,width:r.width,height:r.height}})}o.addEventListener("keydown",e=>{if(!m||i&&!i.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t==="z"||t==="y")&&(e.preventDefault(),f({type:t==="y"||e.shiftKey?"formfeed:redo":"formfeed:undo"}))}),l.addEventListener("message",e=>{if(e.source!==l.parent)return;let t=e.data;!t||typeof t.type!="string"||(t.type==="formfeed:edit-begin"?P(t):t.type==="formfeed:edit-refuse"||t.type==="formfeed:edit-end"?(s=null,i&&!i.done&&E(!1)):t.type==="formfeed:edit-open"&&B(t))});function B(e){if(!m||typeof e.src!="string"||i&&!i.done)return;let t=Array.from(o.querySelectorAll(`[data-ff-src="${e.src.replace(/"/g,"")}"][data-ff-edit]`)),n=Number.isInteger(e.index)?Number(e.index):0,r=t[n]??t[0];r&&C(r,null)}if(m){let e=()=>f({type:"formfeed:edit-ready",doc:v}),t=l;t.PagedConfig?t.formfeedEditReady=e:o.readyState==="loading"?o.addEventListener("DOMContentLoaded",e):e()}function P(e){i&&!i.done&&E(!1);let t=e.layer?o.querySelector(`[data-ff-layer="${String(e.layer).replace(/"/g,"")}"] > .ff-text`):s&&s.src===e.src?s.element:o.querySelector(`[data-ff-src="${String(e.src).replace(/"/g,"")}"]`),n=e.at,r=e.layer?n&&Number.isFinite(n.x)&&Number.isFinite(n.y)?{x:Number(n.x),y:Number(n.y)}:null:s&&s.src===e.src?s.point:null;s=null;let u=h&&!o.hasFocus();if(!t||!Array.isArray(e.items)||u){f({type:"formfeed:edit-cancel",token:String(e.token)});return}let c=Array.from(t.childNodes),b=o.createDocumentFragment();for(let a of e.items)if(a.kind==="text")b.appendChild(o.createTextNode(String(a.text)));else if(a.kind==="break")b.appendChild(o.createElement("br"));else if(a.kind==="chip"){let p=o.createElement("span");p.className="ff-chip",p.setAttribute("data-ff-chip",String(a.index)),p.setAttribute("contenteditable","false"),a.title&&(p.title=String(a.title)),p.textContent=String(a.text),b.appendChild(p)}for(let a of c)t.removeChild(a);t.appendChild(b),t.contentEditable="true",t.classList.add("ff-editing"),t.setAttribute("role","textbox"),e.label&&t.setAttribute("aria-label",String(e.label)),t.spellcheck=!0,i={token:String(e.token),element:t,saved:c,allowBreaks:e.allowBreaks===!0,badge:e.note?H(t,String(e.note)):null,done:!1},t.addEventListener("keydown",A),t.addEventListener("beforeinput",T),t.addEventListener("paste",S),t.addEventListener("drop",N),t.addEventListener("focusout",R),g&&t.addEventListener("input",k),t.focus(),e.select==="all"?I(t):K(t,r),f({type:"formfeed:edit-started",token:i.token}),typeof e.insert=="string"&&e.insert&&L(e.insert.replace(/\\r\\n?|\\n/g," "))}function L(e){if(typeof o.execCommand=="function"&&o.execCommand("insertText",!1,e))return;let t=l.getSelection(),n=t&&t.rangeCount?t.getRangeAt(0):null;n&&(n.deleteContents(),n.insertNode(o.createTextNode(e)),n.collapse(!1),g&&k())}function k(){i&&!i.done&&f({type:"formfeed:edit-input",token:i.token,items:D(i.element)})}function H(e,t){let n=o.createElement("div");n.className="ff-edit-badge",n.textContent=t;let r=e.getBoundingClientRect();return n.style.left=`${r.left+l.scrollX}px`,n.style.top=`${Math.max(0,r.top+l.scrollY-22)}px`,o.body.appendChild(n),n}function I(e){let t=l.getSelection();if(!t)return;let n=o.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function K(e,t){let n=l.getSelection();if(!n)return;let r=null,u=o;if(t){if(u.caretRangeFromPoint)r=u.caretRangeFromPoint(t.x,t.y);else if(u.caretPositionFromPoint){let c=u.caretPositionFromPoint(t.x,t.y);c&&(r=o.createRange(),r.setStart(c.offsetNode,c.offset))}}if(!r||!e.contains(r.startContainer))r=o.createRange(),r.selectNodeContents(e),r.collapse(!1);else if(t){let c=r.startContainer,a=(c.nodeType===1?c:c.parentElement)?.closest("[data-ff-chip]")??null;if(a&&a!==e&&e.contains(a)){let p=a.getBoundingClientRect();r=o.createRange(),t.x<p.left+p.width/2?r.setStartBefore(a):r.setStartAfter(a),r.collapse(!0)}}n.removeAllRanges(),n.addRange(r)}function A(e){let t=e.key;t==="Escape"?(e.preventDefault(),E(!0)):t==="Enter"&&!e.shiftKey?(e.preventDefault(),x()):t==="Enter"?(e.preventDefault(),i?.allowBreaks&&q()):t==="Tab"?(e.preventDefault(),x()):(e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t.toLowerCase())&&(e.preventDefault(),g&&i&&!e.altKey&&f({type:"formfeed:edit-style",token:i.token,key:t.toLowerCase()}))}function T(e){let t=e.inputType??"";(t.startsWith("format")||t==="insertFromDrop"||t==="insertParagraph"||t==="insertLineBreak")&&e.preventDefault()}function S(e){e.preventDefault(),L((e.clipboardData?.getData("text/plain")??"").replace(/\\r\\n?|\\n/g," "))}function N(e){e.preventDefault()}function R(){l.setTimeout(()=>{i&&!i.done&&(!o.hasFocus()||!i.element.contains(o.activeElement))&&x()},0)}function q(){let e=l.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let n=o.createElement("br");t.insertNode(n),n.nextSibling||n.parentNode?.appendChild(o.createElement("br"));let r=o.createRange();r.setStartAfter(n),r.collapse(!0),e.removeAllRanges(),e.addRange(r)}function w(e){e.done=!0;let t=e.element;t.removeEventListener("keydown",A),t.removeEventListener("beforeinput",T),t.removeEventListener("paste",S),t.removeEventListener("drop",N),t.removeEventListener("focusout",R),t.removeEventListener("input",k),t.removeAttribute("contenteditable"),t.removeAttribute("role"),t.removeAttribute("aria-label"),t.classList.remove("ff-editing"),e.badge?.remove(),i===e&&(i=null)}function x(){let e=i;if(!e||e.done)return;let t=D(e.element);w(e),f({type:"formfeed:edit-commit",token:e.token,items:t})}function E(e){let t=i;if(!t||t.done)return;let n=t.element;for(;n.firstChild;)n.removeChild(n.firstChild);for(let r of t.saved)n.appendChild(r);w(t),e&&f({type:"formfeed:edit-cancel",token:t.token})}}function D(l){let d=[],m=o=>{let i=d[d.length-1];i?.kind==="text"?i.text+=o:o&&d.push({kind:"text",text:o})},g=o=>{for(let i of Array.from(o.childNodes))if(i.nodeType===3)m(i.data);else if(i.nodeType===1){let s=i,f=s.getAttribute("data-ff-chip");f!==null?d.push({kind:"chip",index:Number(f)}):s.tagName==="BR"?d.push({kind:"break"}):((s.tagName==="DIV"||s.tagName==="P")&&d.length&&d.push({kind:"break"}),g(s))}};for(g(l);d[d.length-1]?.kind==="break";)d.pop();return d}F(window);})();';
|
|
81044
81044
|
|
|
81045
81045
|
// packages/engine/src/lib/preview.ts
|
|
81046
81046
|
var textEditScript = `<script>${textEditRuntime.replace(/<\/script/gi, "<\\/script")}</script>`;
|
|
@@ -81585,6 +81585,199 @@ var designStarters = [
|
|
|
81585
81585
|
}
|
|
81586
81586
|
];
|
|
81587
81587
|
|
|
81588
|
+
// packages/engine/src/lib/einvoice/codes.generated.ts
|
|
81589
|
+
var list2 = (codes) => new Set(codes.split(" "));
|
|
81590
|
+
var documentTypeCodes = list2(
|
|
81591
|
+
"71 80 81 82 83 84 102 130 202 203 204 211 218 219 261 262 295 296 308 325 326 331 380 381 382 383 384 385 386 387 388 389 390 393 394 395 396 420 456 457 458 471 472 473 500 501 502 503 527 532 553 575 623 633 751 780 817 870 875 876 877 935"
|
|
81592
|
+
);
|
|
81593
|
+
var countryCodes = list2(
|
|
81594
|
+
"1A AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XI YE YT ZA ZM ZW 1A XI"
|
|
81595
|
+
);
|
|
81596
|
+
var unitCodes = list2(
|
|
81597
|
+
"10 11 13 14 15 20 21 22 23 24 25 27 28 33 34 35 37 38 40 41 56 57 58 59 60 61 74 77 80 81 85 87 89 91 1I 2A 2B 2C 2G 2H 2I 2J 2K 2L 2M 2N 2P 2Q 2R 2U 2X 2Y 2Z 3B 3C 4C 4G 4H 4K 4L 4M 4N 4O 4P 4Q 4R 4T 4U 4W 4X 5A 5B 5E 5J A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A2 A20 A21 A22 A23 A24 A26 A27 A28 A29 A3 A30 A31 A32 A33 A34 A35 A36 A37 A38 A39 A4 A40 A41 A42 A43 A44 A45 A47 A48 A49 A5 A53 A54 A55 A56 A59 A6 A68 A69 A7 A70 A71 A73 A74 A75 A76 A8 A84 A85 A86 A87 A88 A89 A9 A90 A91 A93 A94 A95 A96 A97 A98 A99 AA AB ACR ACT AD AE AH AI AK AL AMH AMP ANN APZ AQ AS ASM ASU ATM AWG AY AZ B1 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B3 B30 B31 B32 B33 B34 B35 B4 B41 B42 B43 B44 B45 B46 B47 B48 B49 B50 B52 B53 B54 B55 B56 B57 B58 B59 B60 B61 B62 B63 B64 B66 B67 B68 B69 B7 B70 B71 B72 B73 B74 B75 B76 B77 B78 B79 B8 B80 B81 B82 B83 B84 B85 B86 B87 B88 B89 B90 B91 B92 B93 B94 B95 B96 B97 B98 B99 BAR BB BFT BHP BIL BLD BLL BP BPM BQL BTU BUA BUI C0 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C3 C30 C31 C32 C33 C34 C35 C36 C37 C38 C39 C40 C41 C42 C43 C44 C45 C46 C47 C48 C49 C50 C51 C52 C53 C54 C55 C56 C57 C58 C59 C60 C61 C62 C63 C64 C65 C66 C67 C68 C69 C7 C70 C71 C72 C73 C74 C75 C76 C78 C79 C8 C80 C81 C82 C83 C84 C85 C86 C87 C88 C89 C9 C90 C91 C92 C93 C94 C95 C96 C97 C99 CCT CDL CEL CEN CG CGM CKG CLF CLT CMK CMQ CMT CNP CNT COU CTG CTM CTN CUR CWA CWI D03 D04 D1 D10 D11 D12 D13 D15 D16 D17 D18 D19 D2 D20 D21 D22 D23 D24 D25 D26 D27 D29 D30 D31 D32 D33 D34 D36 D41 D42 D43 D44 D45 D46 D47 D48 D49 D5 D50 D51 D52 D53 D54 D55 D56 D57 D58 D59 D6 D60 D61 D62 D63 D65 D68 D69 D73 D74 D77 D78 D80 D81 D82 D83 D85 D86 D87 D88 D89 D91 D93 D94 D95 DAA DAD DAY DB DBM DBW DD DEC DG DJ DLT DMA DMK DMO DMQ DMT DN DPC DPR DPT DRA DRI DRL DT DTN DWT DZN DZP E01 E07 E08 E09 E10 E12 E14 E15 E16 E17 E18 E19 E20 E21 E22 E23 E25 E27 E28 E30 E31 E32 E33 E34 E35 E36 E37 E38 E39 E4 E40 E41 E42 E43 E44 E45 E46 E47 E48 E49 E50 E51 E52 E53 E54 E55 E56 E57 E58 E59 E60 E61 E62 E63 E64 E65 E66 E67 E68 E69 E70 E71 E72 E73 E74 E75 E76 E77 E78 E79 E80 E81 E82 E83 E84 E85 E86 E87 E88 E89 E90 E91 E92 E93 E94 E95 E96 E97 E98 E99 EA EB EQ F01 F02 F03 F04 F05 F06 F07 F08 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 F32 F33 F34 F35 F36 F37 F38 F39 F40 F41 F42 F43 F44 F45 F46 F47 F48 F49 F50 F51 F52 F53 F54 F55 F56 F57 F58 F59 F60 F61 F62 F63 F64 F65 F66 F67 F68 F69 F70 F71 F72 F73 F74 F75 F76 F77 F78 F79 F80 F81 F82 F83 F84 F85 F86 F87 F88 F89 F90 F91 F92 F93 F94 F95 F96 F97 F98 F99 FAH FAR FBM FC FF FH FIT FL FNU FOT FP FR FS FTK FTQ G01 G04 G05 G06 G08 G09 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G2 G20 G21 G23 G24 G25 G26 G27 G28 G29 G3 G30 G31 G32 G33 G34 G35 G36 G37 G38 G39 G40 G41 G42 G43 G44 G45 G46 G47 G48 G49 G50 G51 G52 G53 G54 G55 G56 G57 G58 G59 G60 G61 G62 G63 G64 G65 G66 G67 G68 G69 G70 G71 G72 G73 G74 G75 G76 G77 G78 G79 G80 G81 G82 G83 G84 G85 G86 G87 G88 G89 G90 G91 G92 G93 G94 G95 G96 G97 G98 G99 GB GBQ GDW GE GF GFI GGR GIA GIC GII GIP GJ GL GLD GLI GLL GM GO GP GQ GRM GRN GRO GV GWH H03 H04 H05 H06 H07 H08 H09 H10 H11 H12 H13 H14 H15 H16 H18 H19 H20 H21 H22 H23 H24 H25 H26 H27 H28 H29 H30 H31 H32 H33 H34 H35 H36 H37 H38 H39 H40 H41 H42 H43 H44 H45 H46 H47 H48 H49 H50 H51 H52 H53 H54 H55 H56 H57 H58 H59 H60 H61 H62 H63 H64 H65 H66 H67 H68 H69 H70 H71 H72 H73 H74 H75 H76 H77 H79 H80 H81 H82 H83 H84 H85 H87 H88 H89 H90 H91 H92 H93 H94 H95 H96 H98 H99 HA HAD HBA HBX HC HDW HEA HGM HH HIU HKM HLT HM HMO HMQ HMT HPA HTZ HUR HWE IA IE INH INK INQ ISD IU IUG IV J10 J12 J13 J14 J15 J16 J17 J18 J19 J2 J20 J21 J22 J23 J24 J25 J26 J27 J28 J29 J30 J31 J32 J33 J34 J35 J36 J38 J39 J40 J41 J42 J43 J44 J45 J46 J47 J48 J49 J50 J51 J52 J53 J54 J55 J56 J57 J58 J59 J60 J61 J62 J63 J64 J65 J66 J67 J68 J69 J70 J71 J72 J73 J74 J75 J76 J78 J79 J81 J82 J83 J84 J85 J87 J90 J91 J92 J93 J95 J96 J97 J98 J99 JE JK JM JNT JOU JPS JWL K1 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K2 K20 K21 K22 K23 K26 K27 K28 K3 K30 K31 K32 K33 K34 K35 K36 K37 K38 K39 K40 K41 K42 K43 K45 K46 K47 K48 K49 K50 K51 K52 K53 K54 K55 K58 K59 K6 K60 K61 K62 K63 K64 K65 K66 K67 K68 K69 K70 K71 K73 K74 K75 K76 K77 K78 K79 K80 K81 K82 K83 K84 K85 K86 K87 K88 K89 K90 K91 K92 K93 K94 K95 K96 K97 K98 K99 KA KAT KB KBA KCC KDW KEL KGM KGS KHY KHZ KI KIC KIP KJ KJO KL KLK KLX KMA KMH KMK KMQ KMT KNI KNM KNS KNT KO KPA KPH KPO KPP KR KSD KSH KT KTN KUR KVA KVR KVT KW KWH KWN KWO KWS KWT KWY KX L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L2 L20 L21 L23 L24 L25 L26 L27 L28 L29 L30 L31 L32 L33 L34 L35 L36 L37 L38 L39 L40 L41 L42 L43 L44 L45 L46 L47 L48 L49 L50 L51 L52 L53 L54 L55 L56 L57 L58 L59 L60 L63 L64 L65 L66 L67 L68 L69 L70 L71 L72 L73 L74 L75 L76 L77 L78 L79 L80 L81 L82 L83 L84 L85 L86 L87 L88 L89 L90 L91 L92 L93 L94 L95 L96 L98 L99 LA LAC LBR LBT LD LEF LF LH LK LM LN LO LP LPA LR LS LTN LTR LUB LUM LUX LY M1 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20 M21 M22 M23 M24 M25 M26 M27 M29 M30 M31 M32 M33 M34 M35 M36 M37 M38 M39 M4 M40 M41 M42 M43 M44 M45 M46 M47 M48 M49 M5 M50 M51 M52 M53 M55 M56 M57 M58 M59 M60 M61 M62 M63 M64 M65 M66 M67 M68 M69 M7 M70 M71 M72 M73 M74 M75 M76 M77 M78 M79 M80 M81 M82 M83 M84 M85 M86 M87 M88 M89 M9 M90 M91 M92 M93 M94 M95 M96 M97 M98 M99 MAH MAL MAM MAR MAW MBE MBF MBR MC MCU MD MGM MHZ MIK MIL MIN MIO MIU MKD MKM MKW MLD MLT MMK MMQ MMT MND MNJ MON MPA MQD MQH MQM MQS MQW MRD MRM MRW MSK MTK MTQ MTR MTS MTZ MVA MWH N1 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N20 N21 N22 N23 N24 N25 N26 N27 N28 N29 N3 N30 N31 N32 N33 N34 N35 N36 N37 N38 N39 N40 N41 N42 N43 N44 N45 N46 N47 N48 N49 N50 N51 N52 N53 N54 N55 N56 N57 N58 N59 N60 N61 N62 N63 N64 N65 N66 N67 N68 N69 N70 N71 N72 N73 N74 N75 N76 N77 N78 N79 N80 N81 N82 N83 N84 N85 N86 N87 N88 N89 N90 N91 N92 N93 N94 N95 N96 N97 N98 N99 NA NAR NCL NEW NF NIL NIU NL NM3 NMI NMP NPT NT NTU NU NX OA ODE ODG ODK ODM OHM ON ONZ OPM OT OZA OZI P1 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P2 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P32 P33 P34 P35 P36 P37 P38 P39 P40 P41 P42 P43 P44 P45 P46 P47 P48 P49 P5 P50 P51 P52 P53 P54 P55 P56 P57 P58 P59 P60 P61 P62 P63 P64 P65 P66 P67 P68 P69 P70 P71 P72 P73 P74 P75 P76 P77 P78 P79 P80 P81 P82 P83 P84 P85 P86 P87 P88 P89 P90 P91 P92 P93 P94 P95 P96 P97 P98 P99 PAL PD PFL PGL PI PLA PO PQ PR PS PTD PTI PTL PTN Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 Q25 Q26 Q27 Q28 Q29 Q3 Q30 Q31 Q32 Q33 Q34 Q35 Q36 Q37 Q38 Q39 Q40 Q41 Q42 QA QAN QB QR QTD QTI QTL QTR R1 R9 RH RM ROM RP RPM RPS RT S3 S4 SAN SCO SCR SEC SET SG SIE SM3 SMI SQ SQR SR STC STI STK STL STN STW SW SX SYR T0 T3 TAH TAN TI TIC TIP TKM TMS TNE TP TPI TPR TQD TRL TST TTS U1 U2 UB UC VA VLT VP W2 WA WB WCD WE WEB WEE WG WHR WM WSD WTT X1 X1A X1B X1D X1F X1G X1W X2C X3A X3H X43 X44 X4A X4B X4C X4D X4F X4G X4H X5H X5L X5M X6H X6P X7A X7B X8A X8B X8C XAA XAB XAC XAD XAE XAF XAG XAH XAI XAJ XAL XAM XAP XAT XAV XB4 XBA XBB XBC XBD XBE XBF XBG XBH XBI XBJ XBK XBL XBM XBN XBO XBP XBQ XBR XBS XBT XBU XBV XBW XBX XBY XBZ XCA XCB XCC XCD XCE XCF XCG XCH XCI XCJ XCK XCL XCM XCN XCO XCP XCQ XCR XCS XCT XCU XCV XCW XCX XCY XCZ XDA XDB XDC XDG XDH XDI XDJ XDK XDL XDM XDN XDP XDR XDS XDT XDU XDV XDW XDX XDY XEC XED XEE XEF XEG XEH XEI XEN XFB XFC XFD XFE XFI XFL XFO XFP XFR XFT XFW XFX XGB XGI XGL XGR XGU XGY XGZ XHA XHB XHC XHG XHN XHR XIA XIB XIC XID XIE XIF XIG XIH XIK XIL XIN XIZ XJB XJC XJG XJR XJT XJY XKG XKI XLE XLG XLT XLU XLV XLZ XMA XMB XMC XME XMR XMS XMT XMW XMX XNA XNE XNF XNG XNS XNT XNU XNV XO1 XO2 XO3 XO4 XO5 XO6 XO7 XO8 XO9 XOA XOB XOC XOD XOE XOF XOG XOH XOI XOJ XOK XOL XOM XON XOP XOQ XOR XOS XOT XOU XOV XOW XOX XOY XOZ XP1 XP2 XP3 XP4 XPA XPB XPC XPD XPE XPF XPG XPH XPI XPJ XPK XPL XPN XPO XPP XPR XPT XPU XPV XPX XPY XPZ XQA XQB XQC XQD XQF XQG XQH XQJ XQK XQL XQM XQN XQP XQQ XQR XQS XRD XRG XRJ XRK XRL XRO XRT XRZ XSA XSB XSC XSD XSE XSH XSI XSK XSL XSM XSO XSP XSS XST XSU XSV XSW XSX XSY XSZ XT1 XTB XTC XTD XTE XTG XTI XTK XTL XTN XTO XTR XTS XTT XTU XTV XTW XTY XTZ XUC XUN XVA XVG XVI XVK XVL XVN XVO XVP XVQ XVR XVS XVY XWA XWB XWC XWD XWF XWG XWH XWJ XWK XWL XWM XWN XWP XWQ XWR XWS XWT XWU XWV XWW XWX XWY XWZ XXA XXB XXC XXD XXF XXG XXH XXJ XXK XYA XYB XYC XYD XYF XYG XYH XYJ XYK XYL XYM XYN XYP XYQ XYR XYS XYT XYV XYW XYX XYY XYZ XZA XZB XZC XZD XZF XZG XZH XZJ XZK XZL XZM XZN XZP XZQ XZR XZS XZT XZU XZV XZW XZX XZY XZZ YDK YDQ YRD Z11 Z9 ZP ZZ"
|
|
81598
|
+
);
|
|
81599
|
+
var electronicAddressSchemes = list2(
|
|
81600
|
+
"0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0154 0158 0170 0177 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0221 0225 0230 0235 0240 0242 0244 0245 0246 0248 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM"
|
|
81601
|
+
);
|
|
81602
|
+
var currencyCodes = list2(
|
|
81603
|
+
"AED AFN ALL AMD AOA ARS AUD AWG AZN BAM BBD BDT BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYN BZD CAD CDF CHE CHF CHW CLF CLP CNH CNY COP COU CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP STN SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UYW UZS VED VES VND VUV WST XAF XAG XAU XBA XBB XBC XBD XCD XCG XDR XOF XPD XPF XPT XSU XTS XUA XXX YER ZAR ZMW ZWG"
|
|
81604
|
+
);
|
|
81605
|
+
var paymentMeansCodes = list2(
|
|
81606
|
+
"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 74 75 76 77 78 91 92 93 94 95 96 97 98 ZZZ"
|
|
81607
|
+
);
|
|
81608
|
+
|
|
81609
|
+
// packages/engine/src/lib/einvoice/schema.ts
|
|
81610
|
+
import { z as z2 } from "zod";
|
|
81611
|
+
var numeric = z2.union([z2.number(), z2.string()]);
|
|
81612
|
+
var text2 = z2.string().trim().min(1);
|
|
81613
|
+
var isoDate2 = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected a date as YYYY-MM-DD");
|
|
81614
|
+
var identifier2 = z2.union([
|
|
81615
|
+
text2,
|
|
81616
|
+
z2.object({ value: text2, scheme: text2.optional() })
|
|
81617
|
+
]);
|
|
81618
|
+
var address = z2.object({
|
|
81619
|
+
street: text2.optional(),
|
|
81620
|
+
street2: text2.optional(),
|
|
81621
|
+
street3: text2.optional(),
|
|
81622
|
+
postcode: text2.optional(),
|
|
81623
|
+
city: text2.optional(),
|
|
81624
|
+
/** ISO 3166-1 alpha-2 (BT-40, BT-55, BT-80). */
|
|
81625
|
+
country: text2,
|
|
81626
|
+
/** Region or province (BT-39, BT-54, BT-79). */
|
|
81627
|
+
subdivision: text2.optional()
|
|
81628
|
+
});
|
|
81629
|
+
var contact = z2.object({
|
|
81630
|
+
name: text2.optional(),
|
|
81631
|
+
phone: text2.optional(),
|
|
81632
|
+
email: text2.optional()
|
|
81633
|
+
});
|
|
81634
|
+
var party = z2.object({
|
|
81635
|
+
name: text2,
|
|
81636
|
+
/** The name the business trades under, where it differs (BT-28, BT-45). */
|
|
81637
|
+
trading_name: text2.optional(),
|
|
81638
|
+
/** An identifier of the party (BT-29, BT-46). */
|
|
81639
|
+
id: identifier2.optional(),
|
|
81640
|
+
/** The register entry (BT-30, BT-47): a SIREN, a company number. */
|
|
81641
|
+
legal_registration: identifier2.optional(),
|
|
81642
|
+
vat_id: text2.optional(),
|
|
81643
|
+
address,
|
|
81644
|
+
contact: contact.optional(),
|
|
81645
|
+
/** Where the party receives electronic invoices (BT-34, BT-49); a bare e-mail address is scheme EM. */
|
|
81646
|
+
electronic_address: identifier2.optional()
|
|
81647
|
+
});
|
|
81648
|
+
var period = z2.object({ start: isoDate2.optional(), end: isoDate2.optional() });
|
|
81649
|
+
var VAT_CATEGORIES = ["S", "Z", "E", "AE", "K", "G", "O"];
|
|
81650
|
+
var vatCategory = z2.enum(VAT_CATEGORIES);
|
|
81651
|
+
var lineTax = z2.object({
|
|
81652
|
+
category: vatCategory,
|
|
81653
|
+
/** Percent, `19` for 19 %. Left out for category O only. */
|
|
81654
|
+
rate: numeric.optional()
|
|
81655
|
+
});
|
|
81656
|
+
var allowanceOrCharge = z2.object({
|
|
81657
|
+
amount: numeric,
|
|
81658
|
+
reason: text2.optional(),
|
|
81659
|
+
/** UNTDID 5189 for an allowance, UNTDID 7161 for a charge. */
|
|
81660
|
+
reason_code: text2.optional(),
|
|
81661
|
+
base_amount: numeric.optional(),
|
|
81662
|
+
percent: numeric.optional()
|
|
81663
|
+
});
|
|
81664
|
+
var line = z2.object({
|
|
81665
|
+
id: z2.union([text2, z2.number()]),
|
|
81666
|
+
name: text2,
|
|
81667
|
+
description: text2.optional(),
|
|
81668
|
+
quantity: numeric,
|
|
81669
|
+
/** UN/ECE Recommendation 20: C62 a piece, HUR an hour, DAY a day, KGM a kilogram. */
|
|
81670
|
+
unit_code: text2.default("C62"),
|
|
81671
|
+
net_price: numeric,
|
|
81672
|
+
/** The quantity the price is for, where it is not one unit (BT-149). */
|
|
81673
|
+
price_base_quantity: numeric.optional(),
|
|
81674
|
+
net_amount: numeric,
|
|
81675
|
+
tax: lineTax,
|
|
81676
|
+
period: period.optional(),
|
|
81677
|
+
allowances: z2.array(allowanceOrCharge).optional(),
|
|
81678
|
+
charges: z2.array(allowanceOrCharge).optional(),
|
|
81679
|
+
buyer_accounting_reference: text2.optional(),
|
|
81680
|
+
note: text2.optional(),
|
|
81681
|
+
/** The seller's and the buyer's article numbers (BT-155, BT-156), a GTIN and the like (BT-157). */
|
|
81682
|
+
seller_item_id: text2.optional(),
|
|
81683
|
+
buyer_item_id: text2.optional(),
|
|
81684
|
+
standard_item_id: identifier2.optional(),
|
|
81685
|
+
/** The line of the buyer's order this one answers (BT-132). */
|
|
81686
|
+
order_line_reference: text2.optional()
|
|
81687
|
+
});
|
|
81688
|
+
var breakdown = z2.object({
|
|
81689
|
+
category: vatCategory,
|
|
81690
|
+
rate: numeric.optional(),
|
|
81691
|
+
basis: numeric,
|
|
81692
|
+
amount: numeric,
|
|
81693
|
+
exemption_reason: text2.optional(),
|
|
81694
|
+
/** A VATEX code (BT-121), for example VATEX-EU-AE for reverse charge. */
|
|
81695
|
+
exemption_reason_code: text2.optional()
|
|
81696
|
+
});
|
|
81697
|
+
var totals = z2.object({
|
|
81698
|
+
line_net: numeric,
|
|
81699
|
+
allowances: numeric.optional(),
|
|
81700
|
+
charges: numeric.optional(),
|
|
81701
|
+
tax_basis: numeric,
|
|
81702
|
+
tax_total: numeric,
|
|
81703
|
+
/** The VAT total in the accounting currency (BT-111). */
|
|
81704
|
+
tax_total_accounting: numeric.optional(),
|
|
81705
|
+
grand: numeric,
|
|
81706
|
+
prepaid: numeric.optional(),
|
|
81707
|
+
rounding: numeric.optional(),
|
|
81708
|
+
due: numeric
|
|
81709
|
+
});
|
|
81710
|
+
var payment = z2.object({
|
|
81711
|
+
/** UNTDID 4461: 58 SEPA credit transfer, 59 SEPA direct debit, 30 credit transfer, 48 card. */
|
|
81712
|
+
means_code: z2.union([text2, z2.number()]).optional(),
|
|
81713
|
+
iban: text2.optional(),
|
|
81714
|
+
bic: text2.optional(),
|
|
81715
|
+
account_name: text2.optional(),
|
|
81716
|
+
/** What the payer quotes with the payment (BT-83). */
|
|
81717
|
+
reference: text2.optional(),
|
|
81718
|
+
terms: text2.optional(),
|
|
81719
|
+
due_date: isoDate2.optional(),
|
|
81720
|
+
/** Direct debit: the mandate (BT-89), the creditor's identifier (BT-90), the account debited (BT-91). */
|
|
81721
|
+
mandate_id: text2.optional(),
|
|
81722
|
+
creditor_id: text2.optional(),
|
|
81723
|
+
debited_iban: text2.optional()
|
|
81724
|
+
});
|
|
81725
|
+
var note = z2.object({
|
|
81726
|
+
text: text2,
|
|
81727
|
+
/** UNTDID 4451, which French invoices use for their statutory mentions (PMT, PMD, AAB). */
|
|
81728
|
+
subject_code: text2.optional()
|
|
81729
|
+
});
|
|
81730
|
+
var invoiceSchema = z2.object({
|
|
81731
|
+
number: text2,
|
|
81732
|
+
issue_date: isoDate2,
|
|
81733
|
+
/** UNTDID 1001: 380 invoice, 381 credit note, 384 corrected invoice, 389 self-billed. */
|
|
81734
|
+
type_code: z2.union([text2, z2.number()]).default("380"),
|
|
81735
|
+
currency: text2,
|
|
81736
|
+
/** The currency the VAT is accounted in, where the invoice is in another (BT-6); goes with `totals.tax_total_accounting`. */
|
|
81737
|
+
accounting_currency: text2.optional(),
|
|
81738
|
+
/** The buyer's routing reference (BT-10); a German authority's Leitweg-ID goes here. */
|
|
81739
|
+
buyer_reference: text2.optional(),
|
|
81740
|
+
order_reference: text2.optional(),
|
|
81741
|
+
contract_reference: text2.optional(),
|
|
81742
|
+
note: text2.optional(),
|
|
81743
|
+
notes: z2.array(note).optional(),
|
|
81744
|
+
period: period.optional(),
|
|
81745
|
+
/** The invoices a credit note or a correction refers to (BG-3). */
|
|
81746
|
+
preceding_invoices: z2.array(z2.object({ number: text2, issue_date: isoDate2.optional() })).optional(),
|
|
81747
|
+
/** France (spec 17 §4.4): what was sold, and the billing framework's code where the plain case does not fit. */
|
|
81748
|
+
operation: z2.enum(["goods", "services", "mixed"]).optional(),
|
|
81749
|
+
operation_code: text2.optional(),
|
|
81750
|
+
seller: party.extend({
|
|
81751
|
+
tax_number: text2.optional(),
|
|
81752
|
+
/** Further legal information the invoice must state (BT-33): register court, capital. */
|
|
81753
|
+
legal_info: text2.optional(),
|
|
81754
|
+
/** France: VAT is owed when the invoice is issued, not when it is paid. */
|
|
81755
|
+
vat_on_debits: z2.boolean().optional()
|
|
81756
|
+
}),
|
|
81757
|
+
buyer: party.extend({
|
|
81758
|
+
/** France: the buyer's SIREN, nine digits. */
|
|
81759
|
+
siren: text2.optional()
|
|
81760
|
+
}),
|
|
81761
|
+
delivery: z2.object({
|
|
81762
|
+
name: text2.optional(),
|
|
81763
|
+
date: isoDate2.optional(),
|
|
81764
|
+
address: address.optional()
|
|
81765
|
+
}).optional(),
|
|
81766
|
+
lines: z2.array(line).min(1),
|
|
81767
|
+
/** Allowances and charges on the whole document (BG-20, BG-21), each with the VAT it falls under. */
|
|
81768
|
+
allowances: z2.array(allowanceOrCharge.extend({ tax: lineTax })).optional(),
|
|
81769
|
+
charges: z2.array(allowanceOrCharge.extend({ tax: lineTax })).optional(),
|
|
81770
|
+
tax: z2.object({ breakdown: z2.array(breakdown).min(1) }),
|
|
81771
|
+
totals,
|
|
81772
|
+
payment: payment.optional()
|
|
81773
|
+
});
|
|
81774
|
+
var einvoiceOptionsSchema = z2.object({
|
|
81775
|
+
profile: z2.string().optional(),
|
|
81776
|
+
flavour: z2.string().optional(),
|
|
81777
|
+
xml: z2.enum(["embedded", "both"]).optional(),
|
|
81778
|
+
display_check: z2.enum(["warn", "strict"]).optional()
|
|
81779
|
+
}).strict();
|
|
81780
|
+
|
|
81588
81781
|
// packages/engine/src/lib/office/errors.ts
|
|
81589
81782
|
var officeLimits = {
|
|
81590
81783
|
/** Entries in one container. */
|
|
@@ -81625,7 +81818,10 @@ function multipart(fields, file) {
|
|
|
81625
81818
|
form.set("file", blob, name);
|
|
81626
81819
|
for (const [key, value] of Object.entries(fields)) {
|
|
81627
81820
|
if (value === void 0) continue;
|
|
81628
|
-
form.set(
|
|
81821
|
+
form.set(
|
|
81822
|
+
key,
|
|
81823
|
+
typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value)
|
|
81824
|
+
);
|
|
81629
81825
|
}
|
|
81630
81826
|
return form;
|
|
81631
81827
|
}
|
|
@@ -81655,7 +81851,10 @@ function randomKey() {
|
|
|
81655
81851
|
if (c?.randomUUID) return c.randomUUID();
|
|
81656
81852
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
81657
81853
|
}
|
|
81658
|
-
var withKey = (options) => ({
|
|
81854
|
+
var withKey = (options) => ({
|
|
81855
|
+
...options,
|
|
81856
|
+
idempotencyKey: options.idempotencyKey ?? randomKey()
|
|
81857
|
+
});
|
|
81659
81858
|
var idOf = (source) => typeof source === "string" ? source : source.id;
|
|
81660
81859
|
var Formfeed = class {
|
|
81661
81860
|
baseUrl;
|
|
@@ -81665,14 +81864,28 @@ var Formfeed = class {
|
|
|
81665
81864
|
timeoutMs;
|
|
81666
81865
|
extraHeaders;
|
|
81667
81866
|
constructor(options) {
|
|
81668
|
-
if (!options.apiKey)
|
|
81867
|
+
if (!options.apiKey)
|
|
81868
|
+
throw new FormfeedError("invalid_request", "apiKey is required", 0);
|
|
81669
81869
|
this.apiKey = options.apiKey;
|
|
81670
|
-
this.baseUrl = (options.baseUrl ?? hosts[options.region ?? "eu"]).replace(
|
|
81870
|
+
this.baseUrl = (options.baseUrl ?? hosts[options.region ?? "eu"]).replace(
|
|
81871
|
+
/\/$/,
|
|
81872
|
+
""
|
|
81873
|
+
);
|
|
81671
81874
|
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
81672
81875
|
this.maxRetries = options.maxRetries ?? 3;
|
|
81673
81876
|
this.timeoutMs = options.timeoutMs ?? 12e4;
|
|
81674
|
-
this.extraHeaders = Object.fromEntries(
|
|
81675
|
-
|
|
81877
|
+
this.extraHeaders = Object.fromEntries(
|
|
81878
|
+
Object.entries(options.headers ?? {}).map(([name, value]) => [
|
|
81879
|
+
name.toLowerCase(),
|
|
81880
|
+
value
|
|
81881
|
+
])
|
|
81882
|
+
);
|
|
81883
|
+
if (!this.fetchImpl)
|
|
81884
|
+
throw new FormfeedError(
|
|
81885
|
+
"invalid_request",
|
|
81886
|
+
"fetch is not available; pass options.fetch",
|
|
81887
|
+
0
|
|
81888
|
+
);
|
|
81676
81889
|
}
|
|
81677
81890
|
renders = {
|
|
81678
81891
|
/** Renders a template, HTML or URL. Sync by default; `mode: 'async'` returns a queued render. */
|
|
@@ -81680,16 +81893,26 @@ var Formfeed = class {
|
|
|
81680
81893
|
...options,
|
|
81681
81894
|
idempotencyKey: options.idempotencyKey ?? randomKey()
|
|
81682
81895
|
}),
|
|
81683
|
-
get: (id, options = {}) => this.request(
|
|
81896
|
+
get: (id, options = {}) => this.request(
|
|
81897
|
+
"GET",
|
|
81898
|
+
`/renders/${encodeURIComponent(id)}`,
|
|
81899
|
+
void 0,
|
|
81900
|
+
options
|
|
81901
|
+
),
|
|
81684
81902
|
/** Polls until the render succeeded or failed (async renders). */
|
|
81685
81903
|
waitFor: async (id, options = {}) => {
|
|
81686
81904
|
const deadline = Date.now() + (options.timeoutMs ?? 12e4);
|
|
81687
81905
|
const interval = options.intervalMs ?? 1e3;
|
|
81688
81906
|
for (; ; ) {
|
|
81689
81907
|
const render = await this.renders.get(id, { signal: options.signal });
|
|
81690
|
-
if (render.status === "succeeded" || render.status === "failed")
|
|
81908
|
+
if (render.status === "succeeded" || render.status === "failed")
|
|
81909
|
+
return render;
|
|
81691
81910
|
if (Date.now() + interval > deadline)
|
|
81692
|
-
throw new FormfeedError(
|
|
81911
|
+
throw new FormfeedError(
|
|
81912
|
+
"timeout",
|
|
81913
|
+
`render ${id} did not finish within the wait time`,
|
|
81914
|
+
0
|
|
81915
|
+
);
|
|
81693
81916
|
await sleep(interval, options.signal);
|
|
81694
81917
|
}
|
|
81695
81918
|
},
|
|
@@ -81697,17 +81920,34 @@ var Formfeed = class {
|
|
|
81697
81920
|
download: async (render, options = {}) => {
|
|
81698
81921
|
const target = typeof render === "string" ? await this.renders.get(render, options) : render;
|
|
81699
81922
|
if (!target.download_url)
|
|
81700
|
-
throw new FormfeedError(
|
|
81701
|
-
|
|
81702
|
-
|
|
81923
|
+
throw new FormfeedError(
|
|
81924
|
+
"not_ready",
|
|
81925
|
+
`render ${target.id} has no output (${target.status})`,
|
|
81926
|
+
0
|
|
81927
|
+
);
|
|
81928
|
+
const res = await this.fetchImpl(target.download_url, {
|
|
81929
|
+
signal: options.signal
|
|
81930
|
+
});
|
|
81931
|
+
if (!res.ok)
|
|
81932
|
+
throw new FormfeedError(
|
|
81933
|
+
"download_failed",
|
|
81934
|
+
`download answered HTTP ${res.status}`,
|
|
81935
|
+
res.status
|
|
81936
|
+
);
|
|
81703
81937
|
return new Uint8Array(await res.arrayBuffer());
|
|
81704
81938
|
},
|
|
81705
81939
|
/** Page of renders, newest first. */
|
|
81706
81940
|
list: (query = {}, options = {}) => {
|
|
81707
81941
|
const params = new URLSearchParams();
|
|
81708
|
-
for (const [k2, v2] of Object.entries(query))
|
|
81942
|
+
for (const [k2, v2] of Object.entries(query))
|
|
81943
|
+
if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
|
|
81709
81944
|
const qs = params.toString();
|
|
81710
|
-
return this.request(
|
|
81945
|
+
return this.request(
|
|
81946
|
+
"GET",
|
|
81947
|
+
`/renders${qs ? `?${qs}` : ""}`,
|
|
81948
|
+
void 0,
|
|
81949
|
+
options
|
|
81950
|
+
);
|
|
81711
81951
|
},
|
|
81712
81952
|
/** Every render matching the query, following the cursor. */
|
|
81713
81953
|
all: async (query = {}, options = {}) => {
|
|
@@ -81721,12 +81961,22 @@ var Formfeed = class {
|
|
|
81721
81961
|
return out;
|
|
81722
81962
|
},
|
|
81723
81963
|
/** Removes the stored files of a render before they expire. Needs the `file:delete` scope. */
|
|
81724
|
-
deleteOutputs: (id, options = {}) => this.request(
|
|
81964
|
+
deleteOutputs: (id, options = {}) => this.request(
|
|
81965
|
+
"DELETE",
|
|
81966
|
+
`/renders/${encodeURIComponent(id)}/outputs`,
|
|
81967
|
+
void 0,
|
|
81968
|
+
options
|
|
81969
|
+
),
|
|
81725
81970
|
/**
|
|
81726
81971
|
* The stored request of a render, to render it again. Needs `render:input`; throws
|
|
81727
81972
|
* `render_input_expired` (410) when the workspace keeps no requests or the period ended.
|
|
81728
81973
|
*/
|
|
81729
|
-
input: (id, options = {}) => this.request(
|
|
81974
|
+
input: (id, options = {}) => this.request(
|
|
81975
|
+
"GET",
|
|
81976
|
+
`/renders/${encodeURIComponent(id)}/input`,
|
|
81977
|
+
void 0,
|
|
81978
|
+
options
|
|
81979
|
+
),
|
|
81730
81980
|
batch: (request, options = {}) => this.request("POST", "/renders/batch", request, {
|
|
81731
81981
|
...options,
|
|
81732
81982
|
idempotencyKey: options.idempotencyKey ?? randomKey()
|
|
@@ -81738,10 +81988,30 @@ var Formfeed = class {
|
|
|
81738
81988
|
* 0.5 units each on live keys; info is free.
|
|
81739
81989
|
*/
|
|
81740
81990
|
pdf = {
|
|
81741
|
-
merge: (sources, output = {}, options = {}) => this.request(
|
|
81742
|
-
|
|
81743
|
-
|
|
81744
|
-
|
|
81991
|
+
merge: (sources, output = {}, options = {}) => this.request(
|
|
81992
|
+
"POST",
|
|
81993
|
+
"/pdf/merge",
|
|
81994
|
+
{ ...output, sources: sources.map(idOf) },
|
|
81995
|
+
withKey(options)
|
|
81996
|
+
),
|
|
81997
|
+
protect: (source, protect, options = {}) => this.request(
|
|
81998
|
+
"POST",
|
|
81999
|
+
"/pdf/protect",
|
|
82000
|
+
{ ...protect, source: idOf(source) },
|
|
82001
|
+
withKey(options)
|
|
82002
|
+
),
|
|
82003
|
+
watermark: (source, watermark, options = {}) => this.request(
|
|
82004
|
+
"POST",
|
|
82005
|
+
"/pdf/watermark",
|
|
82006
|
+
{ ...watermark, source: idOf(source) },
|
|
82007
|
+
withKey(options)
|
|
82008
|
+
),
|
|
82009
|
+
info: (source, options = {}) => this.request(
|
|
82010
|
+
"POST",
|
|
82011
|
+
"/pdf/info",
|
|
82012
|
+
{ source: idOf(source) },
|
|
82013
|
+
options
|
|
82014
|
+
),
|
|
81745
82015
|
/**
|
|
81746
82016
|
* Converts an office document to a PDF render (Starter plan and above): an uploaded file (Word,
|
|
81747
82017
|
* Excel, PowerPoint, OpenDocument, RTF or HTML, up to 20 MB, not kept), or the output of a Word or
|
|
@@ -81750,8 +82020,18 @@ var Formfeed = class {
|
|
|
81750
82020
|
*/
|
|
81751
82021
|
convert: (source, convert = {}, options = {}) => {
|
|
81752
82022
|
if (typeof source === "object" && "file" in source)
|
|
81753
|
-
return this.request(
|
|
81754
|
-
|
|
82023
|
+
return this.request(
|
|
82024
|
+
"POST",
|
|
82025
|
+
"/pdf/convert",
|
|
82026
|
+
multipart({ ...convert }, source.file),
|
|
82027
|
+
withKey(options)
|
|
82028
|
+
);
|
|
82029
|
+
return this.request(
|
|
82030
|
+
"POST",
|
|
82031
|
+
"/pdf/convert",
|
|
82032
|
+
{ ...convert, source: idOf(source) },
|
|
82033
|
+
withKey(options)
|
|
82034
|
+
);
|
|
81755
82035
|
}
|
|
81756
82036
|
};
|
|
81757
82037
|
/**
|
|
@@ -81763,7 +82043,10 @@ var Formfeed = class {
|
|
|
81763
82043
|
files = {
|
|
81764
82044
|
/** Uploads a file; the same name replaces the existing file in place and keeps its URL. */
|
|
81765
82045
|
upload: (file, options = {}) => {
|
|
81766
|
-
const blob = file.data instanceof Blob ? file.data : new Blob(
|
|
82046
|
+
const blob = file.data instanceof Blob ? file.data : new Blob(
|
|
82047
|
+
[file.data],
|
|
82048
|
+
file.contentType ? { type: file.contentType } : {}
|
|
82049
|
+
);
|
|
81767
82050
|
const form = new FormData();
|
|
81768
82051
|
form.set("file", blob, file.name);
|
|
81769
82052
|
form.set("name", file.name);
|
|
@@ -81772,9 +82055,15 @@ var Formfeed = class {
|
|
|
81772
82055
|
/** Page of files, newest first. */
|
|
81773
82056
|
list: (query = {}, options = {}) => {
|
|
81774
82057
|
const params = new URLSearchParams();
|
|
81775
|
-
for (const [k2, v2] of Object.entries(query))
|
|
82058
|
+
for (const [k2, v2] of Object.entries(query))
|
|
82059
|
+
if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
|
|
81776
82060
|
const qs = params.toString();
|
|
81777
|
-
return this.request(
|
|
82061
|
+
return this.request(
|
|
82062
|
+
"GET",
|
|
82063
|
+
`/files${qs ? `?${qs}` : ""}`,
|
|
82064
|
+
void 0,
|
|
82065
|
+
options
|
|
82066
|
+
);
|
|
81778
82067
|
},
|
|
81779
82068
|
/** Every file matching the query, following the cursor. */
|
|
81780
82069
|
all: async (query = {}, options = {}) => {
|
|
@@ -81787,9 +82076,19 @@ var Formfeed = class {
|
|
|
81787
82076
|
} while (cursor);
|
|
81788
82077
|
return out;
|
|
81789
82078
|
},
|
|
81790
|
-
get: (id, options = {}) => this.request(
|
|
82079
|
+
get: (id, options = {}) => this.request(
|
|
82080
|
+
"GET",
|
|
82081
|
+
`/files/${encodeURIComponent(id)}`,
|
|
82082
|
+
void 0,
|
|
82083
|
+
options
|
|
82084
|
+
),
|
|
81791
82085
|
/** Removes the file and its bytes; templates that name it render a missing image afterwards. */
|
|
81792
|
-
delete: (file, options = {}) => this.request(
|
|
82086
|
+
delete: (file, options = {}) => this.request(
|
|
82087
|
+
"DELETE",
|
|
82088
|
+
`/files/${encodeURIComponent(idOf(file))}`,
|
|
82089
|
+
void 0,
|
|
82090
|
+
options
|
|
82091
|
+
)
|
|
81793
82092
|
};
|
|
81794
82093
|
/** The organisation's brand kit, read-only through the API (it is edited in the app). Needs `template:read`. */
|
|
81795
82094
|
brand = {
|
|
@@ -81801,19 +82100,44 @@ var Formfeed = class {
|
|
|
81801
82100
|
*/
|
|
81802
82101
|
partials = {
|
|
81803
82102
|
/** Every shared partial, without its source. */
|
|
81804
|
-
list: async (options = {}) => (await this.request(
|
|
82103
|
+
list: async (options = {}) => (await this.request(
|
|
82104
|
+
"GET",
|
|
82105
|
+
"/partials",
|
|
82106
|
+
void 0,
|
|
82107
|
+
options
|
|
82108
|
+
)).data,
|
|
81805
82109
|
/** One partial with its source. */
|
|
81806
|
-
get: (name, options = {}) => this.request(
|
|
82110
|
+
get: (name, options = {}) => this.request(
|
|
82111
|
+
"GET",
|
|
82112
|
+
`/partials/${encodeURIComponent(name)}`,
|
|
82113
|
+
void 0,
|
|
82114
|
+
options
|
|
82115
|
+
),
|
|
81807
82116
|
/** Creates or replaces a partial; pass `base_version` to fail with 409 when it changed since you read it. */
|
|
81808
82117
|
put: async (name, input, options = {}) => {
|
|
81809
|
-
const { status, body } = await this.send(
|
|
82118
|
+
const { status, body } = await this.send(
|
|
82119
|
+
"PUT",
|
|
82120
|
+
`/partials/${encodeURIComponent(name)}`,
|
|
82121
|
+
input,
|
|
82122
|
+
options
|
|
82123
|
+
);
|
|
81810
82124
|
return { partial: body, created: status === 201 };
|
|
81811
82125
|
},
|
|
81812
82126
|
/** Removes a partial; templates that still include it fail to render afterwards. */
|
|
81813
|
-
delete: (name, options = {}) => this.request(
|
|
82127
|
+
delete: (name, options = {}) => this.request(
|
|
82128
|
+
"DELETE",
|
|
82129
|
+
`/partials/${encodeURIComponent(name)}`,
|
|
82130
|
+
void 0,
|
|
82131
|
+
options
|
|
82132
|
+
)
|
|
81814
82133
|
};
|
|
81815
82134
|
jobs = {
|
|
81816
|
-
get: (id, options = {}) => this.request(
|
|
82135
|
+
get: (id, options = {}) => this.request(
|
|
82136
|
+
"GET",
|
|
82137
|
+
`/jobs/${encodeURIComponent(id)}`,
|
|
82138
|
+
void 0,
|
|
82139
|
+
options
|
|
82140
|
+
),
|
|
81817
82141
|
waitFor: async (id, options = {}) => {
|
|
81818
82142
|
const deadline = Date.now() + (options.timeoutMs ?? 6e5);
|
|
81819
82143
|
const interval = options.intervalMs ?? 2e3;
|
|
@@ -81821,37 +82145,77 @@ var Formfeed = class {
|
|
|
81821
82145
|
const job = await this.jobs.get(id, { signal: options.signal });
|
|
81822
82146
|
if (job.status !== "queued" && job.status !== "processing") return job;
|
|
81823
82147
|
if (Date.now() + interval > deadline)
|
|
81824
|
-
throw new FormfeedError(
|
|
82148
|
+
throw new FormfeedError(
|
|
82149
|
+
"timeout",
|
|
82150
|
+
`job ${id} did not finish within the wait time`,
|
|
82151
|
+
0
|
|
82152
|
+
);
|
|
81825
82153
|
await sleep(interval, options.signal);
|
|
81826
82154
|
}
|
|
81827
82155
|
}
|
|
81828
82156
|
};
|
|
81829
82157
|
webhooks = {
|
|
81830
|
-
list: async (options = {}) => (await this.request(
|
|
82158
|
+
list: async (options = {}) => (await this.request(
|
|
82159
|
+
"GET",
|
|
82160
|
+
"/webhooks",
|
|
82161
|
+
void 0,
|
|
82162
|
+
options
|
|
82163
|
+
)).data,
|
|
81831
82164
|
create: (input, options = {}) => this.request("POST", "/webhooks", input, options),
|
|
81832
|
-
update: (id, patch, options = {}) => this.request(
|
|
81833
|
-
|
|
81834
|
-
|
|
82165
|
+
update: (id, patch, options = {}) => this.request(
|
|
82166
|
+
"PUT",
|
|
82167
|
+
`/webhooks/${encodeURIComponent(id)}`,
|
|
82168
|
+
patch,
|
|
82169
|
+
options
|
|
82170
|
+
),
|
|
82171
|
+
delete: (id, options = {}) => this.request(
|
|
82172
|
+
"DELETE",
|
|
82173
|
+
`/webhooks/${encodeURIComponent(id)}`,
|
|
82174
|
+
void 0,
|
|
82175
|
+
options
|
|
82176
|
+
),
|
|
82177
|
+
test: (id, options = {}) => this.request(
|
|
82178
|
+
"POST",
|
|
82179
|
+
`/webhooks/${encodeURIComponent(id)}/test`,
|
|
82180
|
+
void 0,
|
|
82181
|
+
options
|
|
82182
|
+
),
|
|
81835
82183
|
/**
|
|
81836
82184
|
* Sends a stored event (`evt_…`) again as a new delivery to a registered endpoint (`webhook:manage`)
|
|
81837
82185
|
* or a running listen session (`webhook:listen`).
|
|
81838
82186
|
*/
|
|
81839
|
-
resend: (eventId, endpointId, options = {}) => this.request(
|
|
82187
|
+
resend: (eventId, endpointId, options = {}) => this.request(
|
|
82188
|
+
"POST",
|
|
82189
|
+
`/webhooks/events/${encodeURIComponent(eventId)}/resend`,
|
|
82190
|
+
{ endpoint_id: endpointId },
|
|
82191
|
+
options
|
|
82192
|
+
),
|
|
81840
82193
|
/**
|
|
81841
82194
|
* Listen sessions, what `formfeed listen` uses. Needs `webhook:listen`. Starting a session ends the
|
|
81842
82195
|
* previous one of the same key; the WebSocket itself is up to the caller.
|
|
81843
82196
|
*/
|
|
81844
82197
|
listen: {
|
|
81845
82198
|
start: (input = {}, options = {}) => this.request("POST", "/webhooks/listen", input, options),
|
|
81846
|
-
end: (id, options = {}) => this.request(
|
|
82199
|
+
end: (id, options = {}) => this.request(
|
|
82200
|
+
"DELETE",
|
|
82201
|
+
`/webhooks/listen/${encodeURIComponent(id)}`,
|
|
82202
|
+
void 0,
|
|
82203
|
+
options
|
|
82204
|
+
)
|
|
81847
82205
|
}
|
|
81848
82206
|
};
|
|
81849
82207
|
templates = {
|
|
81850
82208
|
list: (query = {}, options = {}) => {
|
|
81851
82209
|
const params = new URLSearchParams();
|
|
81852
|
-
for (const [k2, v2] of Object.entries(query))
|
|
82210
|
+
for (const [k2, v2] of Object.entries(query))
|
|
82211
|
+
if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
|
|
81853
82212
|
const qs = params.toString();
|
|
81854
|
-
return this.request(
|
|
82213
|
+
return this.request(
|
|
82214
|
+
"GET",
|
|
82215
|
+
`/templates${qs ? `?${qs}` : ""}`,
|
|
82216
|
+
void 0,
|
|
82217
|
+
options
|
|
82218
|
+
);
|
|
81855
82219
|
},
|
|
81856
82220
|
/** Every template of the workspace, following the cursor. */
|
|
81857
82221
|
all: async (query = {}, options = {}) => {
|
|
@@ -81864,27 +82228,63 @@ var Formfeed = class {
|
|
|
81864
82228
|
} while (cursor);
|
|
81865
82229
|
return out;
|
|
81866
82230
|
},
|
|
81867
|
-
get: (idOrSlug, options = {}) => this.request(
|
|
82231
|
+
get: (idOrSlug, options = {}) => this.request(
|
|
82232
|
+
"GET",
|
|
82233
|
+
`/templates/${encodeURIComponent(idOrSlug)}`,
|
|
82234
|
+
void 0,
|
|
82235
|
+
options
|
|
82236
|
+
),
|
|
81868
82237
|
/** A Word or PowerPoint template (`kind` `docx` or `pptx`) is created from its `file`, sent as multipart. */
|
|
81869
82238
|
create: (input, options = {}) => {
|
|
81870
82239
|
if (isOfficeInput(input) && input.file) {
|
|
81871
82240
|
const { file, ...fields } = input;
|
|
81872
|
-
return this.request(
|
|
82241
|
+
return this.request(
|
|
82242
|
+
"POST",
|
|
82243
|
+
"/templates",
|
|
82244
|
+
multipart(fields, file),
|
|
82245
|
+
options
|
|
82246
|
+
);
|
|
81873
82247
|
}
|
|
81874
82248
|
return this.request("POST", "/templates", input, options);
|
|
81875
82249
|
},
|
|
81876
|
-
update: (idOrSlug, patch, options = {}) => this.request(
|
|
81877
|
-
|
|
82250
|
+
update: (idOrSlug, patch, options = {}) => this.request(
|
|
82251
|
+
"PUT",
|
|
82252
|
+
`/templates/${encodeURIComponent(idOrSlug)}`,
|
|
82253
|
+
patch,
|
|
82254
|
+
options
|
|
82255
|
+
),
|
|
82256
|
+
archive: (idOrSlug, options = {}) => this.request(
|
|
82257
|
+
"DELETE",
|
|
82258
|
+
`/templates/${encodeURIComponent(idOrSlug)}`,
|
|
82259
|
+
void 0,
|
|
82260
|
+
options
|
|
82261
|
+
),
|
|
81878
82262
|
versions: {
|
|
81879
|
-
list: async (idOrSlug, options = {}) => (await this.request(
|
|
82263
|
+
list: async (idOrSlug, options = {}) => (await this.request(
|
|
82264
|
+
"GET",
|
|
82265
|
+
`/templates/${encodeURIComponent(idOrSlug)}/versions`,
|
|
82266
|
+
void 0,
|
|
82267
|
+
options
|
|
82268
|
+
)).data,
|
|
81880
82269
|
/** `which`: 'published', 'latest', a version number or a channel name (its main version). Carries the files. */
|
|
81881
|
-
get: (idOrSlug, which = "published", options = {}) => this.request(
|
|
82270
|
+
get: (idOrSlug, which = "published", options = {}) => this.request(
|
|
82271
|
+
"GET",
|
|
82272
|
+
`/templates/${encodeURIComponent(idOrSlug)}/versions/${encodeURIComponent(String(which))}`,
|
|
82273
|
+
void 0,
|
|
82274
|
+
options
|
|
82275
|
+
),
|
|
81882
82276
|
/** For a Word or PowerPoint template, pass `file` to replace the document; without it the latest file is kept. */
|
|
81883
82277
|
create: (idOrSlug, input, options = {}) => {
|
|
81884
82278
|
const path = `/templates/${encodeURIComponent(idOrSlug)}/versions`;
|
|
81885
82279
|
if (isOfficeInput(input)) {
|
|
81886
82280
|
const { file, ...fields } = input;
|
|
81887
|
-
if (file)
|
|
82281
|
+
if (file)
|
|
82282
|
+
return this.request(
|
|
82283
|
+
"POST",
|
|
82284
|
+
path,
|
|
82285
|
+
multipart(fields, file),
|
|
82286
|
+
options
|
|
82287
|
+
);
|
|
81888
82288
|
return this.request("POST", path, fields, options);
|
|
81889
82289
|
}
|
|
81890
82290
|
return this.request("POST", path, input, options);
|
|
@@ -81913,7 +82313,12 @@ var Formfeed = class {
|
|
|
81913
82313
|
* uses the version the channel points at. Moves reach renders within a minute.
|
|
81914
82314
|
*/
|
|
81915
82315
|
channels: {
|
|
81916
|
-
list: (idOrSlug, options = {}) => this.request(
|
|
82316
|
+
list: (idOrSlug, options = {}) => this.request(
|
|
82317
|
+
"GET",
|
|
82318
|
+
`/templates/${encodeURIComponent(idOrSlug)}/channels`,
|
|
82319
|
+
void 0,
|
|
82320
|
+
options
|
|
82321
|
+
),
|
|
81917
82322
|
/** Creates or moves a channel; on `published` this publishes. */
|
|
81918
82323
|
set: (idOrSlug, name, move, options = {}) => {
|
|
81919
82324
|
const { allowBreaking, ...rest } = options;
|
|
@@ -81947,19 +82352,39 @@ var Formfeed = class {
|
|
|
81947
82352
|
schema: (idOrSlug, options = {}) => {
|
|
81948
82353
|
const { version, ...rest } = options;
|
|
81949
82354
|
const query = version === void 0 ? "" : `?version=${encodeURIComponent(String(version))}`;
|
|
81950
|
-
return this.request(
|
|
82355
|
+
return this.request(
|
|
82356
|
+
"GET",
|
|
82357
|
+
`/templates/${encodeURIComponent(idOrSlug)}/schema${query}`,
|
|
82358
|
+
void 0,
|
|
82359
|
+
rest
|
|
82360
|
+
);
|
|
81951
82361
|
},
|
|
81952
82362
|
/**
|
|
81953
82363
|
* Checks a version with data without rendering: syntax, header and footer, missing partials,
|
|
81954
82364
|
* runtime errors and the data against the stored schema. Free. Without `data`, the version's
|
|
81955
82365
|
* sample data is checked. `version` takes a channel name too.
|
|
81956
82366
|
*/
|
|
81957
|
-
validate: (idOrSlug, input = {}, options = {}) => this.request(
|
|
82367
|
+
validate: (idOrSlug, input = {}, options = {}) => this.request(
|
|
82368
|
+
"POST",
|
|
82369
|
+
`/templates/${encodeURIComponent(idOrSlug)}/validate`,
|
|
82370
|
+
input,
|
|
82371
|
+
options
|
|
82372
|
+
)
|
|
81958
82373
|
};
|
|
81959
82374
|
account = {
|
|
81960
|
-
get: (options = {}) => this.request(
|
|
82375
|
+
get: (options = {}) => this.request(
|
|
82376
|
+
"GET",
|
|
82377
|
+
"/account",
|
|
82378
|
+
void 0,
|
|
82379
|
+
options
|
|
82380
|
+
),
|
|
81961
82381
|
/** Units of the current period, or of `YYYY-MM`, with a daily series and a breakdown per template. */
|
|
81962
|
-
usage: (
|
|
82382
|
+
usage: (period2 = "current", options = {}) => this.request(
|
|
82383
|
+
"GET",
|
|
82384
|
+
`/usage?period=${encodeURIComponent(period2)}`,
|
|
82385
|
+
void 0,
|
|
82386
|
+
options
|
|
82387
|
+
)
|
|
81963
82388
|
};
|
|
81964
82389
|
/** Workspaces of the key's organisation. Needs `workspace:delete`, which no key has by default. */
|
|
81965
82390
|
workspaces = {
|
|
@@ -81967,7 +82392,12 @@ var Formfeed = class {
|
|
|
81967
82392
|
* Deletes a workspace: it leaves the app and the API at once, its keys are revoked and its content
|
|
81968
82393
|
* is removed after 30 days. The organisation's last workspace is refused with `last_workspace`.
|
|
81969
82394
|
*/
|
|
81970
|
-
delete: (id, options = {}) => this.request(
|
|
82395
|
+
delete: (id, options = {}) => this.request(
|
|
82396
|
+
"DELETE",
|
|
82397
|
+
`/workspaces/${encodeURIComponent(id)}`,
|
|
82398
|
+
void 0,
|
|
82399
|
+
options
|
|
82400
|
+
)
|
|
81971
82401
|
};
|
|
81972
82402
|
channelAction(idOrSlug, name, action, options) {
|
|
81973
82403
|
const { allowBreaking, ...rest } = options;
|
|
@@ -81995,13 +82425,21 @@ var Formfeed = class {
|
|
|
81995
82425
|
...this.extraHeaders
|
|
81996
82426
|
};
|
|
81997
82427
|
const isForm = typeof FormData !== "undefined" && body instanceof FormData;
|
|
81998
|
-
if (body !== void 0 && !isForm)
|
|
81999
|
-
|
|
82428
|
+
if (body !== void 0 && !isForm)
|
|
82429
|
+
headers["content-type"] = "application/json";
|
|
82430
|
+
if (options.idempotencyKey)
|
|
82431
|
+
headers["idempotency-key"] = options.idempotencyKey;
|
|
82000
82432
|
let attempt = 0;
|
|
82001
82433
|
for (; ; ) {
|
|
82002
82434
|
const controller = new AbortController();
|
|
82003
|
-
const timer = setTimeout(
|
|
82004
|
-
|
|
82435
|
+
const timer = setTimeout(
|
|
82436
|
+
() => controller.abort(new Error("request timed out")),
|
|
82437
|
+
this.timeoutMs
|
|
82438
|
+
);
|
|
82439
|
+
options.signal?.addEventListener(
|
|
82440
|
+
"abort",
|
|
82441
|
+
() => controller.abort(options.signal?.reason)
|
|
82442
|
+
);
|
|
82005
82443
|
let res;
|
|
82006
82444
|
try {
|
|
82007
82445
|
res = await this.fetchImpl(url, {
|
|
@@ -82017,22 +82455,38 @@ var Formfeed = class {
|
|
|
82017
82455
|
await sleep(this.backoff(attempt, null), options.signal);
|
|
82018
82456
|
continue;
|
|
82019
82457
|
}
|
|
82020
|
-
throw new FormfeedError(
|
|
82458
|
+
throw new FormfeedError(
|
|
82459
|
+
"network_error",
|
|
82460
|
+
e instanceof Error ? e.message : String(e),
|
|
82461
|
+
0
|
|
82462
|
+
);
|
|
82021
82463
|
}
|
|
82022
82464
|
clearTimeout(timer);
|
|
82023
82465
|
if ((res.status === 429 || res.status === 503) && attempt < this.maxRetries) {
|
|
82024
82466
|
attempt++;
|
|
82025
|
-
await sleep(
|
|
82467
|
+
await sleep(
|
|
82468
|
+
this.backoff(attempt, res.headers.get("retry-after")),
|
|
82469
|
+
options.signal
|
|
82470
|
+
);
|
|
82026
82471
|
continue;
|
|
82027
82472
|
}
|
|
82028
82473
|
if (res.status === 204) return { status: 204, body: void 0 };
|
|
82029
|
-
if (as === "bytes" && res.ok)
|
|
82030
|
-
|
|
82474
|
+
if (as === "bytes" && res.ok)
|
|
82475
|
+
return {
|
|
82476
|
+
status: res.status,
|
|
82477
|
+
body: new Uint8Array(await res.arrayBuffer())
|
|
82478
|
+
};
|
|
82479
|
+
const text4 = await res.text();
|
|
82031
82480
|
let json2 = null;
|
|
82032
82481
|
try {
|
|
82033
|
-
json2 =
|
|
82482
|
+
json2 = text4 ? JSON.parse(text4) : null;
|
|
82034
82483
|
} catch {
|
|
82035
|
-
if (res.ok)
|
|
82484
|
+
if (res.ok)
|
|
82485
|
+
throw new FormfeedError(
|
|
82486
|
+
"invalid_response",
|
|
82487
|
+
`the API answered HTTP ${res.status} with a body that is not JSON`,
|
|
82488
|
+
res.status
|
|
82489
|
+
);
|
|
82036
82490
|
}
|
|
82037
82491
|
if (!res.ok) {
|
|
82038
82492
|
const problem = json2 ?? {};
|
|
@@ -82058,14 +82512,23 @@ var Formfeed = class {
|
|
|
82058
82512
|
var encoder2 = new TextEncoder();
|
|
82059
82513
|
|
|
82060
82514
|
// packages/mcp/src/lib/server.ts
|
|
82061
|
-
import { z as
|
|
82515
|
+
import { z as z3 } from "zod";
|
|
82062
82516
|
var CONVERT_LIMIT_BYTES = 20 * 1024 * 1024;
|
|
82063
|
-
var SERVER_INFO = { name: "formfeed", version: "0.3.
|
|
82064
|
-
var READS = {
|
|
82065
|
-
|
|
82066
|
-
|
|
82067
|
-
|
|
82068
|
-
|
|
82517
|
+
var SERVER_INFO = { name: "formfeed", version: "0.3.12" };
|
|
82518
|
+
var READS = {
|
|
82519
|
+
readOnlyHint: true,
|
|
82520
|
+
destructiveHint: false,
|
|
82521
|
+
openWorldHint: false
|
|
82522
|
+
};
|
|
82523
|
+
var CREATES = {
|
|
82524
|
+
readOnlyHint: false,
|
|
82525
|
+
destructiveHint: false,
|
|
82526
|
+
idempotentHint: false,
|
|
82527
|
+
openWorldHint: false
|
|
82528
|
+
};
|
|
82529
|
+
var engineSchema = z3.enum(["jinja2", "liquid", "handlebars"]);
|
|
82530
|
+
var outputSchema = z3.enum(outputFormats);
|
|
82531
|
+
var kindSchema = z3.enum(["pdf", "image", "docx", "pptx"]);
|
|
82069
82532
|
var templateSummary = (t) => ({
|
|
82070
82533
|
id: t.id,
|
|
82071
82534
|
slug: t.slug,
|
|
@@ -82088,17 +82551,26 @@ var renderSummary = (r) => ({
|
|
|
82088
82551
|
template: r.template,
|
|
82089
82552
|
error: r.error
|
|
82090
82553
|
});
|
|
82091
|
-
function
|
|
82092
|
-
return {
|
|
82554
|
+
function text3(data) {
|
|
82555
|
+
return {
|
|
82556
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
82557
|
+
structuredContent: data
|
|
82558
|
+
};
|
|
82093
82559
|
}
|
|
82094
82560
|
function failure(e) {
|
|
82095
82561
|
const message2 = e instanceof FormfeedError ? `${e.code}: ${e.message}` : e instanceof Error ? e.message : String(e);
|
|
82096
|
-
return {
|
|
82562
|
+
return {
|
|
82563
|
+
content: [{ type: "text", text: message2 }],
|
|
82564
|
+
isError: true
|
|
82565
|
+
};
|
|
82097
82566
|
}
|
|
82098
82567
|
function createFormfeedServer(options) {
|
|
82099
82568
|
const client = new Formfeed({
|
|
82100
82569
|
apiKey: options.apiKey,
|
|
82101
|
-
headers: {
|
|
82570
|
+
headers: {
|
|
82571
|
+
"user-agent": `formfeed-mcp/${SERVER_INFO.version}`,
|
|
82572
|
+
...options.workspaceId ? { "x-formfeed-workspace": options.workspaceId } : {}
|
|
82573
|
+
},
|
|
82102
82574
|
...options.region ? { region: options.region } : {},
|
|
82103
82575
|
...options.baseUrl ? { baseUrl: options.baseUrl } : {},
|
|
82104
82576
|
...options.fetch ? { fetch: options.fetch } : {}
|
|
@@ -82114,15 +82586,19 @@ function createFormfeedServer(options) {
|
|
|
82114
82586
|
inputSchema: {
|
|
82115
82587
|
kind: kindSchema.optional().describe("Only templates that produce this kind of document"),
|
|
82116
82588
|
engine: engineSchema.optional().describe("Only templates written in this template language"),
|
|
82117
|
-
tag:
|
|
82118
|
-
|
|
82589
|
+
tag: z3.string().optional().describe(
|
|
82590
|
+
"Only templates with this tag; exact match, tags are lowercase with dashes (e.g. billing)"
|
|
82591
|
+
),
|
|
82592
|
+
q: z3.string().optional().describe(
|
|
82593
|
+
"Text to find in the name or slug, case-insensitive (e.g. invoice)"
|
|
82594
|
+
)
|
|
82119
82595
|
},
|
|
82120
82596
|
annotations: READS
|
|
82121
82597
|
},
|
|
82122
82598
|
async (args2) => {
|
|
82123
82599
|
try {
|
|
82124
82600
|
const templates = await client.templates.all(args2);
|
|
82125
|
-
return
|
|
82601
|
+
return text3({ templates: templates.map(templateSummary) });
|
|
82126
82602
|
} catch (e) {
|
|
82127
82603
|
return failure(e);
|
|
82128
82604
|
}
|
|
@@ -82133,17 +82609,28 @@ function createFormfeedServer(options) {
|
|
|
82133
82609
|
{
|
|
82134
82610
|
title: "Get the data schema of a template",
|
|
82135
82611
|
description: "Returns the JSON Schema of the `data` object a template expects and the sample data it was designed with, from its published version, else its latest draft. Call it after list_templates and before render or validate_template, to build data that fits; ad-hoc html has no stored schema to read. When the template stores no schema, one is inferred from the sample data: treat that as a guide, not a contract. Read-only and free; an unknown slug returns an error.",
|
|
82136
|
-
inputSchema: {
|
|
82612
|
+
inputSchema: {
|
|
82613
|
+
template: z3.string().describe(
|
|
82614
|
+
"Slug (e.g. invoice) or tpl_ id, as list_templates returns them"
|
|
82615
|
+
)
|
|
82616
|
+
},
|
|
82137
82617
|
annotations: READS
|
|
82138
82618
|
},
|
|
82139
82619
|
async ({ template }) => {
|
|
82140
82620
|
try {
|
|
82141
82621
|
const version = await client.templates.versions.get(template, "published").catch(async (e) => {
|
|
82142
|
-
if (e.status === 404)
|
|
82622
|
+
if (e.status === 404)
|
|
82623
|
+
return client.templates.versions.get(template, "latest");
|
|
82143
82624
|
throw e;
|
|
82144
82625
|
});
|
|
82145
82626
|
const schema = version.data_schema ?? inferSchema(version.sample_data ?? {});
|
|
82146
|
-
return
|
|
82627
|
+
return text3({
|
|
82628
|
+
template,
|
|
82629
|
+
version: version.number,
|
|
82630
|
+
status: version.status,
|
|
82631
|
+
schema,
|
|
82632
|
+
sample_data: version.sample_data ?? {}
|
|
82633
|
+
});
|
|
82147
82634
|
} catch (e) {
|
|
82148
82635
|
return failure(e);
|
|
82149
82636
|
}
|
|
@@ -82155,22 +82642,29 @@ function createFormfeedServer(options) {
|
|
|
82155
82642
|
title: "Validate a template with data",
|
|
82156
82643
|
description: "Checks a template and its data without rendering: free, no units, nothing stored, no document produced. Call it before render when you assembled the data yourself, or after writing ad-hoc html. With template, the API checks the published version (else the latest) as a render would: syntax, header and footer, errors only this data triggers, and the data against the stored JSON Schema (a wrong type or a missing required field is an error). With html and engine it compiles offline and reports syntax errors, unknown filters and variables missing from data. Returns ok and diagnostics (severity, code, message, plus path, line and column, or part and paragraph for Word and PowerPoint). Warnings leave ok true: settle each before rendering.",
|
|
82157
82644
|
inputSchema: {
|
|
82158
|
-
template:
|
|
82159
|
-
html:
|
|
82645
|
+
template: z3.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
|
|
82646
|
+
html: z3.string().optional().describe(
|
|
82647
|
+
"Template source to check offline, when there is no stored template; pass this or template"
|
|
82648
|
+
),
|
|
82160
82649
|
engine: engineSchema.optional().describe("Template language of html; required with html"),
|
|
82161
|
-
data:
|
|
82650
|
+
data: z3.record(z3.string(), z3.unknown()).optional().describe(
|
|
82651
|
+
"The data the document will be rendered with, shaped as get_template_schema describes. Left out, a stored template is checked with its sample data"
|
|
82652
|
+
)
|
|
82162
82653
|
},
|
|
82163
82654
|
annotations: READS
|
|
82164
82655
|
},
|
|
82165
82656
|
async ({ template, html, engine, data }) => {
|
|
82166
82657
|
try {
|
|
82167
82658
|
if (template) {
|
|
82168
|
-
const check = (version) => client.templates.validate(template, {
|
|
82659
|
+
const check = (version) => client.templates.validate(template, {
|
|
82660
|
+
version,
|
|
82661
|
+
...data ? { data } : {}
|
|
82662
|
+
});
|
|
82169
82663
|
const result = await check("published").catch((e) => {
|
|
82170
82664
|
if (e.status === 404) return check("latest");
|
|
82171
82665
|
throw e;
|
|
82172
82666
|
});
|
|
82173
|
-
return
|
|
82667
|
+
return text3({
|
|
82174
82668
|
ok: result.ok,
|
|
82175
82669
|
template: result.template,
|
|
82176
82670
|
diagnostics: result.diagnostics.map((d) => ({
|
|
@@ -82183,18 +82677,35 @@ function createFormfeedServer(options) {
|
|
|
82183
82677
|
}))
|
|
82184
82678
|
});
|
|
82185
82679
|
}
|
|
82186
|
-
if (!html || !engine)
|
|
82680
|
+
if (!html || !engine)
|
|
82681
|
+
return failure(new Error("Pass a template slug, or html and engine"));
|
|
82187
82682
|
const eng = getEngine(engine);
|
|
82188
82683
|
const diagnostics = [];
|
|
82189
82684
|
try {
|
|
82190
82685
|
eng.compile(html, { name: "ad-hoc" });
|
|
82191
82686
|
} catch (e) {
|
|
82192
|
-
diagnostics.push({
|
|
82687
|
+
diagnostics.push({
|
|
82688
|
+
severity: "error",
|
|
82689
|
+
code: "syntax-error",
|
|
82690
|
+
message: e instanceof Error ? e.message : String(e),
|
|
82691
|
+
range: {
|
|
82692
|
+
start: { line: 1, column: 1 },
|
|
82693
|
+
end: { line: 1, column: 2 }
|
|
82694
|
+
}
|
|
82695
|
+
});
|
|
82193
82696
|
}
|
|
82194
|
-
diagnostics.push(
|
|
82195
|
-
|
|
82697
|
+
diagnostics.push(
|
|
82698
|
+
...eng.analyze(html, { sampleData: data ?? {} }).diagnostics
|
|
82699
|
+
);
|
|
82700
|
+
return text3({
|
|
82196
82701
|
ok: !diagnostics.some((d) => d.severity === "error"),
|
|
82197
|
-
diagnostics: diagnostics.map((d) => ({
|
|
82702
|
+
diagnostics: diagnostics.map((d) => ({
|
|
82703
|
+
severity: d.severity,
|
|
82704
|
+
code: d.code,
|
|
82705
|
+
message: d.message,
|
|
82706
|
+
line: d.range.start.line,
|
|
82707
|
+
column: d.range.start.column
|
|
82708
|
+
}))
|
|
82198
82709
|
});
|
|
82199
82710
|
} catch (e) {
|
|
82200
82711
|
return failure(e);
|
|
@@ -82207,22 +82718,42 @@ function createFormfeedServer(options) {
|
|
|
82207
82718
|
title: "Render a document",
|
|
82208
82719
|
description: "Creates a document by filling a stored template, or ad-hoc html, with data: a PDF or image, or DOCX, PPTX or PDF from Word and PowerPoint templates. Returns the render with status and download_url. Use it to make a document from data; to turn an existing office file into a PDF, use convert_to_pdf. Stored templates render their published version, so one whose published_version is null fails with template_not_found. Every call is a new render: a live key consumes units, a test key is free (watermarked on the Free plan). A render that fails returns status failed and an error with code and message; validate_template finds most causes beforehand. The link expires at expires_at; get_render issues a fresh one.",
|
|
82209
82720
|
inputSchema: {
|
|
82210
|
-
template:
|
|
82211
|
-
html:
|
|
82212
|
-
|
|
82213
|
-
|
|
82721
|
+
template: z3.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
|
|
82722
|
+
html: z3.string().optional().describe(
|
|
82723
|
+
"A complete HTML document to render instead of a stored template, up to 5 MB"
|
|
82724
|
+
),
|
|
82725
|
+
engine: engineSchema.optional().describe(
|
|
82726
|
+
"Template language of html, when it contains expressions to fill from data"
|
|
82727
|
+
),
|
|
82728
|
+
data: z3.record(z3.string(), z3.unknown()).optional().describe(
|
|
82729
|
+
"Values for the template, shaped as get_template_schema describes; leave out when it needs none"
|
|
82730
|
+
),
|
|
82214
82731
|
output: outputSchema.optional().describe(
|
|
82215
82732
|
"Left out, the template decides: PDF for PDF templates and html, its image format for image templates, its default output for Word and PowerPoint templates. Word templates render docx or pdf, PowerPoint templates pptx or pdf"
|
|
82216
82733
|
),
|
|
82217
|
-
filename:
|
|
82218
|
-
|
|
82219
|
-
|
|
82734
|
+
filename: z3.string().optional().describe(
|
|
82735
|
+
"Name of the file behind download_url, e.g. invoice-2026-0042.pdf"
|
|
82736
|
+
),
|
|
82737
|
+
locale: z3.string().optional().describe("BCP 47 tag for helpers and translations, e.g. de-DE"),
|
|
82738
|
+
wait: z3.boolean().default(true).describe(
|
|
82739
|
+
"Most renders are finished when the call returns; true also waits for one that continues in the background, false returns it as it is (queued or rendering) to check later with get_render"
|
|
82740
|
+
)
|
|
82220
82741
|
},
|
|
82221
82742
|
annotations: CREATES
|
|
82222
82743
|
},
|
|
82223
|
-
async ({
|
|
82744
|
+
async ({
|
|
82745
|
+
template,
|
|
82746
|
+
html,
|
|
82747
|
+
engine,
|
|
82748
|
+
data,
|
|
82749
|
+
output,
|
|
82750
|
+
filename,
|
|
82751
|
+
locale,
|
|
82752
|
+
wait
|
|
82753
|
+
}) => {
|
|
82224
82754
|
try {
|
|
82225
|
-
if (!template && !html)
|
|
82755
|
+
if (!template && !html)
|
|
82756
|
+
return failure(new Error("Pass template or html"));
|
|
82226
82757
|
let render = await client.renders.create({
|
|
82227
82758
|
...template ? { template } : {},
|
|
82228
82759
|
...html ? { html } : {},
|
|
@@ -82233,8 +82764,9 @@ function createFormfeedServer(options) {
|
|
|
82233
82764
|
...locale ? { locale } : {},
|
|
82234
82765
|
meta: { source: "mcp" }
|
|
82235
82766
|
});
|
|
82236
|
-
if (wait && render.status !== "succeeded" && render.status !== "failed")
|
|
82237
|
-
|
|
82767
|
+
if (wait && render.status !== "succeeded" && render.status !== "failed")
|
|
82768
|
+
render = await client.renders.waitFor(render.id);
|
|
82769
|
+
return text3(renderSummary(render));
|
|
82238
82770
|
} catch (e) {
|
|
82239
82771
|
return failure(e);
|
|
82240
82772
|
}
|
|
@@ -82252,23 +82784,46 @@ function createFormfeedServer(options) {
|
|
|
82252
82784
|
"Every call is a new render that counts units like a PDF; the Free plan cannot convert (Starter and above). The document is converted and not kept."
|
|
82253
82785
|
].join(" "),
|
|
82254
82786
|
inputSchema: {
|
|
82255
|
-
render_id:
|
|
82256
|
-
|
|
82257
|
-
|
|
82258
|
-
|
|
82259
|
-
|
|
82260
|
-
|
|
82261
|
-
|
|
82262
|
-
|
|
82787
|
+
render_id: z3.string().optional().describe(
|
|
82788
|
+
"rnd_ id of a render whose output is docx or pptx, to get that document as a PDF"
|
|
82789
|
+
),
|
|
82790
|
+
...options.localFiles ? {
|
|
82791
|
+
path: z3.string().optional().describe("Absolute path of the document on this machine")
|
|
82792
|
+
} : {},
|
|
82793
|
+
file_base64: z3.string().optional().describe("The document to convert, base64 encoded; needs file_name"),
|
|
82794
|
+
file_name: z3.string().optional().describe(
|
|
82795
|
+
"Name of the document, e.g. report.xlsx; the type is read from the content"
|
|
82796
|
+
),
|
|
82797
|
+
page_ranges: z3.string().regex(/^\d+(-\d+)?(,\d+(-\d+)?)*$/).optional().describe("Pages to convert, e.g. 1-3,5; all pages when left out"),
|
|
82798
|
+
landscape: z3.boolean().optional().describe(
|
|
82799
|
+
"Landscape for spreadsheets and documents without their own page setup"
|
|
82800
|
+
),
|
|
82801
|
+
single_page_sheets: z3.boolean().optional().describe("Each spreadsheet sheet on one page"),
|
|
82802
|
+
filename: z3.string().optional().describe("Name of the PDF behind download_url, e.g. report.pdf")
|
|
82263
82803
|
},
|
|
82264
82804
|
annotations: CREATES
|
|
82265
82805
|
},
|
|
82266
82806
|
async (args2) => {
|
|
82267
82807
|
try {
|
|
82268
|
-
const {
|
|
82808
|
+
const {
|
|
82809
|
+
render_id,
|
|
82810
|
+
file_base64,
|
|
82811
|
+
file_name,
|
|
82812
|
+
page_ranges,
|
|
82813
|
+
landscape,
|
|
82814
|
+
single_page_sheets,
|
|
82815
|
+
filename
|
|
82816
|
+
} = args2;
|
|
82269
82817
|
const path = args2.path;
|
|
82270
|
-
const sources = [render_id, file_base64, path].filter(
|
|
82271
|
-
|
|
82818
|
+
const sources = [render_id, file_base64, path].filter(
|
|
82819
|
+
(s) => s !== void 0 && s !== ""
|
|
82820
|
+
);
|
|
82821
|
+
if (sources.length !== 1)
|
|
82822
|
+
return failure(
|
|
82823
|
+
new Error(
|
|
82824
|
+
"Pass exactly one of render_id, file_base64" + (options.localFiles ? " or path" : "")
|
|
82825
|
+
)
|
|
82826
|
+
);
|
|
82272
82827
|
const convert = {
|
|
82273
82828
|
meta: { source: "mcp" },
|
|
82274
82829
|
...page_ranges ? { page_ranges } : {},
|
|
@@ -82285,20 +82840,41 @@ function createFormfeedServer(options) {
|
|
|
82285
82840
|
if (path) {
|
|
82286
82841
|
const { readFile, stat } = await import("node:fs/promises");
|
|
82287
82842
|
const { basename } = await import("node:path");
|
|
82288
|
-
if ((await stat(path)).size > CONVERT_LIMIT_BYTES)
|
|
82843
|
+
if ((await stat(path)).size > CONVERT_LIMIT_BYTES)
|
|
82844
|
+
return failure(
|
|
82845
|
+
new Error(
|
|
82846
|
+
`${path} is larger than 20 MB, the limit for conversions`
|
|
82847
|
+
)
|
|
82848
|
+
);
|
|
82289
82849
|
data = new Uint8Array(await readFile(path));
|
|
82290
82850
|
name = file_name ?? basename(path);
|
|
82291
82851
|
} else {
|
|
82292
|
-
if (!file_name)
|
|
82852
|
+
if (!file_name)
|
|
82853
|
+
return failure(
|
|
82854
|
+
new Error("file_name is required with file_base64")
|
|
82855
|
+
);
|
|
82293
82856
|
data = Uint8Array.from(Buffer.from(file_base64, "base64"));
|
|
82294
|
-
if (data.length === 0)
|
|
82295
|
-
|
|
82857
|
+
if (data.length === 0)
|
|
82858
|
+
return failure(new Error("file_base64 is empty or not base64"));
|
|
82859
|
+
if (data.length > CONVERT_LIMIT_BYTES)
|
|
82860
|
+
return failure(
|
|
82861
|
+
new Error(
|
|
82862
|
+
"The document is larger than 20 MB, the limit for conversions"
|
|
82863
|
+
)
|
|
82864
|
+
);
|
|
82296
82865
|
name = file_name;
|
|
82297
82866
|
}
|
|
82298
|
-
render = await client.pdf.convert(
|
|
82867
|
+
render = await client.pdf.convert(
|
|
82868
|
+
{ file: { data, name } },
|
|
82869
|
+
{
|
|
82870
|
+
...convert,
|
|
82871
|
+
...filename ? {} : { filename: `${name.replace(/\.[^.]+$/, "")}.pdf` }
|
|
82872
|
+
}
|
|
82873
|
+
);
|
|
82299
82874
|
}
|
|
82300
|
-
if (render.status !== "succeeded" && render.status !== "failed")
|
|
82301
|
-
|
|
82875
|
+
if (render.status !== "succeeded" && render.status !== "failed")
|
|
82876
|
+
render = await client.renders.waitFor(render.id);
|
|
82877
|
+
return text3(renderSummary(render));
|
|
82302
82878
|
} catch (e) {
|
|
82303
82879
|
return failure(e);
|
|
82304
82880
|
}
|
|
@@ -82309,12 +82885,16 @@ function createFormfeedServer(options) {
|
|
|
82309
82885
|
{
|
|
82310
82886
|
title: "Get a render",
|
|
82311
82887
|
description: "Returns the current state of a render: status (queued, rendering, succeeded or failed), download_url with expires_at, page_count, units and error. Use it to follow a render started with wait false, or to get a fresh link once the old one has expired; render and convert_to_pdf already return this for the render they just made. Read-only and free; an unknown id returns an error.",
|
|
82312
|
-
inputSchema: {
|
|
82888
|
+
inputSchema: {
|
|
82889
|
+
id: z3.string().describe(
|
|
82890
|
+
"rnd_ id of the render, as render or convert_to_pdf returned it"
|
|
82891
|
+
)
|
|
82892
|
+
},
|
|
82313
82893
|
annotations: READS
|
|
82314
82894
|
},
|
|
82315
82895
|
async ({ id }) => {
|
|
82316
82896
|
try {
|
|
82317
|
-
return
|
|
82897
|
+
return text3(renderSummary(await client.renders.get(id)));
|
|
82318
82898
|
} catch (e) {
|
|
82319
82899
|
return failure(e);
|
|
82320
82900
|
}
|