@tim-smart/openapi-gen 0.3.12 → 0.3.13
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/main.js +952 -568
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -68,8 +68,8 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
68
68
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
69
69
|
};
|
|
70
70
|
var __export = (target, all9) => {
|
|
71
|
-
for (var
|
|
72
|
-
__defProp(target,
|
|
71
|
+
for (var name2 in all9)
|
|
72
|
+
__defProp(target, name2, { get: all9[name2], enumerable: true });
|
|
73
73
|
};
|
|
74
74
|
var __copyProps = (to, from, except, desc) => {
|
|
75
75
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -330,16 +330,16 @@ var require_parser = __commonJS({
|
|
|
330
330
|
function parse8(input) {
|
|
331
331
|
var options3 = arguments.length > 1 ? arguments[1] : {}, peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c1 = function() {
|
|
332
332
|
return nodes;
|
|
333
|
-
}, peg$c2 = peg$FAILED, peg$c3 = "#", peg$c4 = { type: "literal", value: "#", description: '"#"' }, peg$c5 = void 0, peg$c6 = { type: "any", description: "any character" }, peg$c7 = "[", peg$c8 = { type: "literal", value: "[", description: '"["' }, peg$c9 = "]", peg$c10 = { type: "literal", value: "]", description: '"]"' }, peg$c11 = function(
|
|
334
|
-
addNode(node("ObjectPath",
|
|
335
|
-
}, peg$c12 = function(
|
|
336
|
-
addNode(node("ArrayPath",
|
|
337
|
-
}, peg$c13 = function(parts2,
|
|
338
|
-
return parts2.concat(
|
|
339
|
-
}, peg$c14 = function(
|
|
340
|
-
return [
|
|
341
|
-
}, peg$c15 = function(
|
|
342
|
-
return
|
|
333
|
+
}, peg$c2 = peg$FAILED, peg$c3 = "#", peg$c4 = { type: "literal", value: "#", description: '"#"' }, peg$c5 = void 0, peg$c6 = { type: "any", description: "any character" }, peg$c7 = "[", peg$c8 = { type: "literal", value: "[", description: '"["' }, peg$c9 = "]", peg$c10 = { type: "literal", value: "]", description: '"]"' }, peg$c11 = function(name2) {
|
|
334
|
+
addNode(node("ObjectPath", name2, line4, column3));
|
|
335
|
+
}, peg$c12 = function(name2) {
|
|
336
|
+
addNode(node("ArrayPath", name2, line4, column3));
|
|
337
|
+
}, peg$c13 = function(parts2, name2) {
|
|
338
|
+
return parts2.concat(name2);
|
|
339
|
+
}, peg$c14 = function(name2) {
|
|
340
|
+
return [name2];
|
|
341
|
+
}, peg$c15 = function(name2) {
|
|
342
|
+
return name2;
|
|
343
343
|
}, peg$c16 = ".", peg$c17 = { type: "literal", value: ".", description: '"."' }, peg$c18 = "=", peg$c19 = { type: "literal", value: "=", description: '"="' }, peg$c20 = function(key, value5) {
|
|
344
344
|
addNode(node("Assign", value5, line4, column3, key));
|
|
345
345
|
}, peg$c21 = function(chars) {
|
|
@@ -356,14 +356,14 @@ var require_parser = __commonJS({
|
|
|
356
356
|
return "";
|
|
357
357
|
}, peg$c38 = "e", peg$c39 = { type: "literal", value: "e", description: '"e"' }, peg$c40 = "E", peg$c41 = { type: "literal", value: "E", description: '"E"' }, peg$c42 = function(left3, right3) {
|
|
358
358
|
return node("Float", parseFloat(left3 + "e" + right3), line4, column3);
|
|
359
|
-
}, peg$c43 = function(
|
|
360
|
-
return node("Float", parseFloat(
|
|
359
|
+
}, peg$c43 = function(text10) {
|
|
360
|
+
return node("Float", parseFloat(text10), line4, column3);
|
|
361
361
|
}, peg$c44 = "+", peg$c45 = { type: "literal", value: "+", description: '"+"' }, peg$c46 = function(digits) {
|
|
362
362
|
return digits.join("");
|
|
363
363
|
}, peg$c47 = "-", peg$c48 = { type: "literal", value: "-", description: '"-"' }, peg$c49 = function(digits) {
|
|
364
364
|
return "-" + digits.join("");
|
|
365
|
-
}, peg$c50 = function(
|
|
366
|
-
return node("Integer", parseInt(
|
|
365
|
+
}, peg$c50 = function(text10) {
|
|
366
|
+
return node("Integer", parseInt(text10, 10), line4, column3);
|
|
367
367
|
}, peg$c51 = "true", peg$c52 = { type: "literal", value: "true", description: '"true"' }, peg$c53 = function() {
|
|
368
368
|
return node("Boolean", true, line4, column3);
|
|
369
369
|
}, peg$c54 = "false", peg$c55 = { type: "literal", value: "false", description: '"false"' }, peg$c56 = function() {
|
|
@@ -4116,13 +4116,13 @@ var require_utils = __commonJS({
|
|
|
4116
4116
|
}
|
|
4117
4117
|
};
|
|
4118
4118
|
var ERR_INVALID_ARG_TYPE = class extends TypeError {
|
|
4119
|
-
constructor(
|
|
4120
|
-
|
|
4119
|
+
constructor(name2, expected, actual) {
|
|
4120
|
+
name2.includes(".") ? "property" : "argument";
|
|
4121
4121
|
}
|
|
4122
4122
|
};
|
|
4123
|
-
function assertIsObject(value5,
|
|
4123
|
+
function assertIsObject(value5, name2, types = "Object") {
|
|
4124
4124
|
if (value5 !== void 0 && (value5 === null || typeof value5 !== "object" || Array.isArray(value5))) {
|
|
4125
|
-
const err = new ERR_INVALID_ARG_TYPE(
|
|
4125
|
+
const err = new ERR_INVALID_ARG_TYPE(name2, types, value5);
|
|
4126
4126
|
Error.captureStackTrace(err, assertIsObject);
|
|
4127
4127
|
throw err;
|
|
4128
4128
|
}
|
|
@@ -4182,11 +4182,11 @@ var require_request = __commonJS({
|
|
|
4182
4182
|
var { Stream: Stream2 } = __require("stream");
|
|
4183
4183
|
function addFunctions(container, obj) {
|
|
4184
4184
|
const proto25 = obj.prototype;
|
|
4185
|
-
Object.keys(proto25).forEach((
|
|
4186
|
-
if (container.indexOf(
|
|
4185
|
+
Object.keys(proto25).forEach((name2) => {
|
|
4186
|
+
if (container.indexOf(name2) != -1)
|
|
4187
4187
|
return;
|
|
4188
|
-
if (
|
|
4189
|
-
container.push(
|
|
4188
|
+
if (name2.indexOf("_") != 0 && typeof proto25[name2] == "function") {
|
|
4189
|
+
container.push(name2);
|
|
4190
4190
|
}
|
|
4191
4191
|
});
|
|
4192
4192
|
}
|
|
@@ -4206,10 +4206,10 @@ var require_request = __commonJS({
|
|
|
4206
4206
|
this.http2Mimic = true;
|
|
4207
4207
|
this[$stubs] = [];
|
|
4208
4208
|
for (var i = 0; i < STUBBED_METHODS_NAME.length; i++) {
|
|
4209
|
-
let
|
|
4210
|
-
if (!ClientRequest.prototype[
|
|
4211
|
-
this[
|
|
4212
|
-
return this.genericStubber(
|
|
4209
|
+
let name2 = STUBBED_METHODS_NAME[i];
|
|
4210
|
+
if (!ClientRequest.prototype[name2]) {
|
|
4211
|
+
this[name2] = function method() {
|
|
4212
|
+
return this.genericStubber(name2, arguments);
|
|
4213
4213
|
}.bind(this);
|
|
4214
4214
|
}
|
|
4215
4215
|
}
|
|
@@ -4316,9 +4316,9 @@ var require_request = __commonJS({
|
|
|
4316
4316
|
},
|
|
4317
4317
|
take(stream3) {
|
|
4318
4318
|
for (var i = 0; i < STUBBED_METHODS_NAME.length; i++) {
|
|
4319
|
-
let
|
|
4320
|
-
if (stream3[
|
|
4321
|
-
this[
|
|
4319
|
+
let name2 = STUBBED_METHODS_NAME[i];
|
|
4320
|
+
if (stream3[name2]) {
|
|
4321
|
+
this[name2] = stream3[name2].bind(stream3);
|
|
4322
4322
|
}
|
|
4323
4323
|
}
|
|
4324
4324
|
this._on = stream3.on.bind(stream3);
|
|
@@ -4347,18 +4347,18 @@ var require_request = __commonJS({
|
|
|
4347
4347
|
});
|
|
4348
4348
|
const properties = Object.getOwnPropertyDescriptors(http2Stream);
|
|
4349
4349
|
for (var i = 0; i < keysToProxy.length; i++) {
|
|
4350
|
-
let
|
|
4351
|
-
const propConfig = properties[
|
|
4350
|
+
let name2 = keysToProxy[i];
|
|
4351
|
+
const propConfig = properties[name2];
|
|
4352
4352
|
let shouldCopyValue;
|
|
4353
4353
|
if (!propConfig)
|
|
4354
4354
|
shouldCopyValue = true;
|
|
4355
4355
|
if (propConfig && (propConfig.writable || propConfig))
|
|
4356
4356
|
shouldCopyValue = true;
|
|
4357
4357
|
if (shouldCopyValue)
|
|
4358
|
-
http2Stream[
|
|
4359
|
-
Object.defineProperty(this,
|
|
4360
|
-
get: getter.bind(
|
|
4361
|
-
set: setter.bind(
|
|
4358
|
+
http2Stream[name2] = this[name2];
|
|
4359
|
+
Object.defineProperty(this, name2, {
|
|
4360
|
+
get: getter.bind(name2),
|
|
4361
|
+
set: setter.bind(name2)
|
|
4362
4362
|
});
|
|
4363
4363
|
}
|
|
4364
4364
|
}
|
|
@@ -4970,10 +4970,10 @@ function writeToStream(dest, instance) {
|
|
|
4970
4970
|
body.pipe(dest);
|
|
4971
4971
|
}
|
|
4972
4972
|
}
|
|
4973
|
-
function validateName(
|
|
4974
|
-
|
|
4975
|
-
if (invalidTokenRegex.test(
|
|
4976
|
-
throw new TypeError(`${
|
|
4973
|
+
function validateName(name2) {
|
|
4974
|
+
name2 = `${name2}`;
|
|
4975
|
+
if (invalidTokenRegex.test(name2)) {
|
|
4976
|
+
throw new TypeError(`${name2} is not a legal HTTP header name`);
|
|
4977
4977
|
}
|
|
4978
4978
|
}
|
|
4979
4979
|
function validateValue(value5) {
|
|
@@ -4982,10 +4982,10 @@ function validateValue(value5) {
|
|
|
4982
4982
|
throw new TypeError(`${value5} is not a legal HTTP header value`);
|
|
4983
4983
|
}
|
|
4984
4984
|
}
|
|
4985
|
-
function find3(map33,
|
|
4986
|
-
|
|
4985
|
+
function find3(map33, name2) {
|
|
4986
|
+
name2 = name2.toLowerCase();
|
|
4987
4987
|
for (const key in map33) {
|
|
4988
|
-
if (key.toLowerCase() ===
|
|
4988
|
+
if (key.toLowerCase() === name2) {
|
|
4989
4989
|
return key;
|
|
4990
4990
|
}
|
|
4991
4991
|
}
|
|
@@ -5021,23 +5021,23 @@ function exportNodeCompatibleHeaders(headers) {
|
|
|
5021
5021
|
}
|
|
5022
5022
|
function createHeadersLenient(obj) {
|
|
5023
5023
|
const headers = new Headers();
|
|
5024
|
-
for (const
|
|
5025
|
-
if (invalidTokenRegex.test(
|
|
5024
|
+
for (const name2 of Object.keys(obj)) {
|
|
5025
|
+
if (invalidTokenRegex.test(name2)) {
|
|
5026
5026
|
continue;
|
|
5027
5027
|
}
|
|
5028
|
-
if (Array.isArray(obj[
|
|
5029
|
-
for (const val of obj[
|
|
5028
|
+
if (Array.isArray(obj[name2])) {
|
|
5029
|
+
for (const val of obj[name2]) {
|
|
5030
5030
|
if (invalidHeaderCharRegex.test(val)) {
|
|
5031
5031
|
continue;
|
|
5032
5032
|
}
|
|
5033
|
-
if (headers[MAP][
|
|
5034
|
-
headers[MAP][
|
|
5033
|
+
if (headers[MAP][name2] === void 0) {
|
|
5034
|
+
headers[MAP][name2] = [val];
|
|
5035
5035
|
} else {
|
|
5036
|
-
headers[MAP][
|
|
5036
|
+
headers[MAP][name2].push(val);
|
|
5037
5037
|
}
|
|
5038
5038
|
}
|
|
5039
|
-
} else if (!invalidHeaderCharRegex.test(obj[
|
|
5040
|
-
headers[MAP][
|
|
5039
|
+
} else if (!invalidHeaderCharRegex.test(obj[name2])) {
|
|
5040
|
+
headers[MAP][name2] = [obj[name2]];
|
|
5041
5041
|
}
|
|
5042
5042
|
}
|
|
5043
5043
|
return headers;
|
|
@@ -5431,10 +5431,10 @@ var init_lib = __esm({
|
|
|
5431
5431
|
text: { enumerable: true }
|
|
5432
5432
|
});
|
|
5433
5433
|
Body.mixIn = function(proto25) {
|
|
5434
|
-
for (const
|
|
5435
|
-
if (!(
|
|
5436
|
-
const desc = Object.getOwnPropertyDescriptor(Body.prototype,
|
|
5437
|
-
Object.defineProperty(proto25,
|
|
5434
|
+
for (const name2 of Object.getOwnPropertyNames(Body.prototype)) {
|
|
5435
|
+
if (!(name2 in proto25)) {
|
|
5436
|
+
const desc = Object.getOwnPropertyDescriptor(Body.prototype, name2);
|
|
5437
|
+
Object.defineProperty(proto25, name2, desc);
|
|
5438
5438
|
}
|
|
5439
5439
|
}
|
|
5440
5440
|
};
|
|
@@ -5498,10 +5498,10 @@ var init_lib = __esm({
|
|
|
5498
5498
|
* @param String name Header name
|
|
5499
5499
|
* @return Mixed
|
|
5500
5500
|
*/
|
|
5501
|
-
get(
|
|
5502
|
-
|
|
5503
|
-
validateName(
|
|
5504
|
-
const key = find3(this[MAP],
|
|
5501
|
+
get(name2) {
|
|
5502
|
+
name2 = `${name2}`;
|
|
5503
|
+
validateName(name2);
|
|
5504
|
+
const key = find3(this[MAP], name2);
|
|
5505
5505
|
if (key === void 0) {
|
|
5506
5506
|
return null;
|
|
5507
5507
|
}
|
|
@@ -5520,8 +5520,8 @@ var init_lib = __esm({
|
|
|
5520
5520
|
let i = 0;
|
|
5521
5521
|
while (i < pairs.length) {
|
|
5522
5522
|
var _pairs$i = pairs[i];
|
|
5523
|
-
const
|
|
5524
|
-
callback.call(thisArg, value5,
|
|
5523
|
+
const name2 = _pairs$i[0], value5 = _pairs$i[1];
|
|
5524
|
+
callback.call(thisArg, value5, name2, this);
|
|
5525
5525
|
pairs = getHeaders(this);
|
|
5526
5526
|
i++;
|
|
5527
5527
|
}
|
|
@@ -5533,13 +5533,13 @@ var init_lib = __esm({
|
|
|
5533
5533
|
* @param String value Header value
|
|
5534
5534
|
* @return Void
|
|
5535
5535
|
*/
|
|
5536
|
-
set(
|
|
5537
|
-
|
|
5536
|
+
set(name2, value5) {
|
|
5537
|
+
name2 = `${name2}`;
|
|
5538
5538
|
value5 = `${value5}`;
|
|
5539
|
-
validateName(
|
|
5539
|
+
validateName(name2);
|
|
5540
5540
|
validateValue(value5);
|
|
5541
|
-
const key = find3(this[MAP],
|
|
5542
|
-
this[MAP][key !== void 0 ? key :
|
|
5541
|
+
const key = find3(this[MAP], name2);
|
|
5542
|
+
this[MAP][key !== void 0 ? key : name2] = [value5];
|
|
5543
5543
|
}
|
|
5544
5544
|
/**
|
|
5545
5545
|
* Append a value onto existing header
|
|
@@ -5548,16 +5548,16 @@ var init_lib = __esm({
|
|
|
5548
5548
|
* @param String value Header value
|
|
5549
5549
|
* @return Void
|
|
5550
5550
|
*/
|
|
5551
|
-
append(
|
|
5552
|
-
|
|
5551
|
+
append(name2, value5) {
|
|
5552
|
+
name2 = `${name2}`;
|
|
5553
5553
|
value5 = `${value5}`;
|
|
5554
|
-
validateName(
|
|
5554
|
+
validateName(name2);
|
|
5555
5555
|
validateValue(value5);
|
|
5556
|
-
const key = find3(this[MAP],
|
|
5556
|
+
const key = find3(this[MAP], name2);
|
|
5557
5557
|
if (key !== void 0) {
|
|
5558
5558
|
this[MAP][key].push(value5);
|
|
5559
5559
|
} else {
|
|
5560
|
-
this[MAP][
|
|
5560
|
+
this[MAP][name2] = [value5];
|
|
5561
5561
|
}
|
|
5562
5562
|
}
|
|
5563
5563
|
/**
|
|
@@ -5566,10 +5566,10 @@ var init_lib = __esm({
|
|
|
5566
5566
|
* @param String name Header name
|
|
5567
5567
|
* @return Boolean
|
|
5568
5568
|
*/
|
|
5569
|
-
has(
|
|
5570
|
-
|
|
5571
|
-
validateName(
|
|
5572
|
-
return find3(this[MAP],
|
|
5569
|
+
has(name2) {
|
|
5570
|
+
name2 = `${name2}`;
|
|
5571
|
+
validateName(name2);
|
|
5572
|
+
return find3(this[MAP], name2) !== void 0;
|
|
5573
5573
|
}
|
|
5574
5574
|
/**
|
|
5575
5575
|
* Delete all header values given name
|
|
@@ -5577,10 +5577,10 @@ var init_lib = __esm({
|
|
|
5577
5577
|
* @param String name Header name
|
|
5578
5578
|
* @return Void
|
|
5579
5579
|
*/
|
|
5580
|
-
delete(
|
|
5581
|
-
|
|
5582
|
-
validateName(
|
|
5583
|
-
const key = find3(this[MAP],
|
|
5580
|
+
delete(name2) {
|
|
5581
|
+
name2 = `${name2}`;
|
|
5582
|
+
validateName(name2);
|
|
5583
|
+
const key = find3(this[MAP], name2);
|
|
5584
5584
|
if (key !== void 0) {
|
|
5585
5585
|
delete this[MAP][key];
|
|
5586
5586
|
}
|
|
@@ -7716,7 +7716,7 @@ var require_swagger2openapi = __commonJS({
|
|
|
7716
7716
|
}
|
|
7717
7717
|
}
|
|
7718
7718
|
}
|
|
7719
|
-
function processResponse(response,
|
|
7719
|
+
function processResponse(response, name2, op, openapi, options3) {
|
|
7720
7720
|
if (!response) return false;
|
|
7721
7721
|
if (response.$ref && typeof response.$ref === "string") {
|
|
7722
7722
|
if (response.$ref.indexOf("#/definitions/") >= 0) {
|
|
@@ -14270,8 +14270,8 @@ var fromFlatLoop = (flat, prefix, config2, split2) => {
|
|
|
14270
14270
|
case OP_PRIMITIVE: {
|
|
14271
14271
|
return pipe(patch5(prefix, flat.patch), flatMap7((prefix2) => pipe(flat.load(prefix2, op, split2), flatMap7((values3) => {
|
|
14272
14272
|
if (values3.length === 0) {
|
|
14273
|
-
const
|
|
14274
|
-
return fail2(MissingData([], `Expected ${op.description} with name ${
|
|
14273
|
+
const name2 = pipe(last(prefix2), getOrElse(() => "<n/a>"));
|
|
14274
|
+
return fail2(MissingData([], `Expected ${op.description} with name ${name2}`));
|
|
14275
14275
|
}
|
|
14276
14276
|
return succeed(values3);
|
|
14277
14277
|
}))));
|
|
@@ -14323,18 +14323,18 @@ var fromFlatLoop = (flat, prefix, config2, split2) => {
|
|
|
14323
14323
|
}
|
|
14324
14324
|
};
|
|
14325
14325
|
var fromFlatLoopFail = (prefix, path2) => (index) => left2(MissingData(prefix, `The element at index ${index} in a sequence at path "${path2}" was missing`));
|
|
14326
|
-
var splitPathString = (
|
|
14327
|
-
const split2 =
|
|
14326
|
+
var splitPathString = (text9, delim) => {
|
|
14327
|
+
const split2 = text9.split(new RegExp(`\\s*${escape(delim)}\\s*`));
|
|
14328
14328
|
return split2;
|
|
14329
14329
|
};
|
|
14330
|
-
var parsePrimitive = (
|
|
14330
|
+
var parsePrimitive = (text9, path2, primitive2, delimiter, split2) => {
|
|
14331
14331
|
if (!split2) {
|
|
14332
|
-
return pipe(primitive2.parse(
|
|
14332
|
+
return pipe(primitive2.parse(text9), mapBoth2({
|
|
14333
14333
|
onFailure: prefixed(path2),
|
|
14334
14334
|
onSuccess: of
|
|
14335
14335
|
}));
|
|
14336
14336
|
}
|
|
14337
|
-
return pipe(splitPathString(
|
|
14337
|
+
return pipe(splitPathString(text9, delimiter), forEachSequential((char4) => primitive2.parse(char4.trim())), mapError(prefixed(path2)));
|
|
14338
14338
|
};
|
|
14339
14339
|
var transpose = (array7) => {
|
|
14340
14340
|
return Object.keys(array7[0]).map((column3) => array7.map((row) => row[column3]));
|
|
@@ -14515,7 +14515,7 @@ var randomHexString = /* @__PURE__ */ function() {
|
|
|
14515
14515
|
};
|
|
14516
14516
|
}();
|
|
14517
14517
|
var NativeSpan = class {
|
|
14518
|
-
constructor(
|
|
14518
|
+
constructor(name2, parent, context7, links, startTime, kind) {
|
|
14519
14519
|
__publicField(this, "name");
|
|
14520
14520
|
__publicField(this, "parent");
|
|
14521
14521
|
__publicField(this, "context");
|
|
@@ -14529,7 +14529,7 @@ var NativeSpan = class {
|
|
|
14529
14529
|
__publicField(this, "attributes");
|
|
14530
14530
|
__publicField(this, "events", []);
|
|
14531
14531
|
__publicField(this, "links");
|
|
14532
|
-
this.name =
|
|
14532
|
+
this.name = name2;
|
|
14533
14533
|
this.parent = parent;
|
|
14534
14534
|
this.context = context7;
|
|
14535
14535
|
this.startTime = startTime;
|
|
@@ -14554,15 +14554,15 @@ var NativeSpan = class {
|
|
|
14554
14554
|
attribute(key, value5) {
|
|
14555
14555
|
this.attributes.set(key, value5);
|
|
14556
14556
|
}
|
|
14557
|
-
event(
|
|
14558
|
-
this.events.push([
|
|
14557
|
+
event(name2, startTime, attributes) {
|
|
14558
|
+
this.events.push([name2, startTime, attributes ?? {}]);
|
|
14559
14559
|
}
|
|
14560
14560
|
addLinks(links) {
|
|
14561
14561
|
this.links.push(...links);
|
|
14562
14562
|
}
|
|
14563
14563
|
};
|
|
14564
14564
|
var nativeTracer = /* @__PURE__ */ make23({
|
|
14565
|
-
span: (
|
|
14565
|
+
span: (name2, parent, context7, links, startTime, kind) => new NativeSpan(name2, parent, context7, links, startTime, kind),
|
|
14566
14566
|
context: (f) => f()
|
|
14567
14567
|
});
|
|
14568
14568
|
var addSpanStackTrace = (options3) => {
|
|
@@ -14669,8 +14669,8 @@ var make25 = (bytes) => {
|
|
|
14669
14669
|
redactedRegistry.set(secret4, bytes.map((byte) => String.fromCharCode(byte)).join(""));
|
|
14670
14670
|
return secret4;
|
|
14671
14671
|
};
|
|
14672
|
-
var fromString = (
|
|
14673
|
-
return make25(
|
|
14672
|
+
var fromString = (text9) => {
|
|
14673
|
+
return make25(text9.split("").map((char4) => char4.charCodeAt(0)));
|
|
14674
14674
|
};
|
|
14675
14675
|
|
|
14676
14676
|
// node_modules/.pnpm/effect@3.15.0/node_modules/effect/dist/esm/internal/config.js
|
|
@@ -15103,18 +15103,18 @@ var _a18;
|
|
|
15103
15103
|
var MicroCauseImpl = class extends globalThis.Error {
|
|
15104
15104
|
constructor(_tag, originalError, traces) {
|
|
15105
15105
|
const causeName = `MicroCause.${_tag}`;
|
|
15106
|
-
let
|
|
15106
|
+
let name2;
|
|
15107
15107
|
let message;
|
|
15108
15108
|
let stack;
|
|
15109
15109
|
if (originalError instanceof globalThis.Error) {
|
|
15110
|
-
|
|
15110
|
+
name2 = `(${causeName}) ${originalError.name}`;
|
|
15111
15111
|
message = originalError.message;
|
|
15112
15112
|
const messageLines = message.split("\n").length;
|
|
15113
|
-
stack = originalError.stack ? `(${causeName}) ${originalError.stack.split("\n").slice(0, messageLines + 3).join("\n")}` : `${
|
|
15113
|
+
stack = originalError.stack ? `(${causeName}) ${originalError.stack.split("\n").slice(0, messageLines + 3).join("\n")}` : `${name2}: ${message}`;
|
|
15114
15114
|
} else {
|
|
15115
|
-
|
|
15115
|
+
name2 = causeName;
|
|
15116
15116
|
message = toStringUnknown(originalError, 0);
|
|
15117
|
-
stack = `${
|
|
15117
|
+
stack = `${name2}: ${message}`;
|
|
15118
15118
|
}
|
|
15119
15119
|
if (traces.length > 0) {
|
|
15120
15120
|
stack += `
|
|
@@ -15127,7 +15127,7 @@ var MicroCauseImpl = class extends globalThis.Error {
|
|
|
15127
15127
|
this._tag = _tag;
|
|
15128
15128
|
this.traces = traces;
|
|
15129
15129
|
this[MicroCauseTypeId] = microCauseVariance;
|
|
15130
|
-
this.name =
|
|
15130
|
+
this.name = name2;
|
|
15131
15131
|
this.stack = stack;
|
|
15132
15132
|
}
|
|
15133
15133
|
pipe() {
|
|
@@ -15940,14 +15940,14 @@ var when = /* @__PURE__ */ dual(2, (self, condition) => suspend(() => condition(
|
|
|
15940
15940
|
var serviceOption = (tag4) => map10(context(), getOption2(tag4));
|
|
15941
15941
|
var bigint02 = /* @__PURE__ */ BigInt(0);
|
|
15942
15942
|
var filterDisablePropagation = /* @__PURE__ */ flatMap((span2) => get5(span2.context, DisablePropagation) ? span2._tag === "Span" ? filterDisablePropagation(span2.parent) : none2() : some2(span2));
|
|
15943
|
-
var unsafeMakeSpan = (fiber,
|
|
15943
|
+
var unsafeMakeSpan = (fiber, name2, options3) => {
|
|
15944
15944
|
const disablePropagation = !fiber.getFiberRef(currentTracerEnabled) || options3.context && get5(options3.context, DisablePropagation);
|
|
15945
15945
|
const context7 = fiber.getFiberRef(currentContext);
|
|
15946
15946
|
const parent = options3.parent ? some2(options3.parent) : options3.root ? none2() : filterDisablePropagation(getOption2(context7, spanTag));
|
|
15947
15947
|
let span2;
|
|
15948
15948
|
if (disablePropagation) {
|
|
15949
15949
|
span2 = noopSpan({
|
|
15950
|
-
name,
|
|
15950
|
+
name: name2,
|
|
15951
15951
|
parent,
|
|
15952
15952
|
context: add4(options3.context ?? empty8(), DisablePropagation, true)
|
|
15953
15953
|
});
|
|
@@ -15960,7 +15960,7 @@ var unsafeMakeSpan = (fiber, name, options3) => {
|
|
|
15960
15960
|
const annotationsFromEnv = get9(fiberRefs3, currentTracerSpanAnnotations);
|
|
15961
15961
|
const linksFromEnv = get9(fiberRefs3, currentTracerSpanLinks);
|
|
15962
15962
|
const links = linksFromEnv._tag === "Some" ? options3.links !== void 0 ? [...toReadonlyArray(linksFromEnv.value), ...options3.links ?? []] : toReadonlyArray(linksFromEnv.value) : options3.links ?? empty2();
|
|
15963
|
-
span2 = tracer2.span(
|
|
15963
|
+
span2 = tracer2.span(name2, parent, options3.context ?? empty8(), links, timingEnabled ? clock3.unsafeCurrentTimeNanos() : bigint02, options3.kind ?? "internal");
|
|
15964
15964
|
if (annotationsFromEnv._tag === "Some") {
|
|
15965
15965
|
forEach3(annotationsFromEnv.value, (value5, key) => span2.attribute(key, value5));
|
|
15966
15966
|
}
|
|
@@ -15982,11 +15982,11 @@ var endSpan = (span2, exit4, clock3, timingEnabled) => sync(() => {
|
|
|
15982
15982
|
}
|
|
15983
15983
|
span2.end(timingEnabled ? clock3.unsafeCurrentTimeNanos() : bigint02, exit4);
|
|
15984
15984
|
});
|
|
15985
|
-
var useSpan = (
|
|
15985
|
+
var useSpan = (name2, ...args2) => {
|
|
15986
15986
|
const options3 = addSpanStackTrace(args2.length === 1 ? void 0 : args2[0]);
|
|
15987
15987
|
const evaluate2 = args2[args2.length - 1];
|
|
15988
15988
|
return withFiberRuntime((fiber) => {
|
|
15989
|
-
const span2 = unsafeMakeSpan(fiber,
|
|
15989
|
+
const span2 = unsafeMakeSpan(fiber, name2, options3);
|
|
15990
15990
|
const timingEnabled = fiber.getFiberRef(currentTracerTimingEnabled);
|
|
15991
15991
|
const clock3 = get5(fiber.getFiberRef(currentServices), clockTag);
|
|
15992
15992
|
return onExit(evaluate2(span2), (exit4) => endSpan(span2, exit4, clock3, timingEnabled));
|
|
@@ -15995,13 +15995,13 @@ var useSpan = (name, ...args2) => {
|
|
|
15995
15995
|
var withParentSpan = /* @__PURE__ */ dual(2, (self, span2) => provideService(self, spanTag, span2));
|
|
15996
15996
|
var withSpan = function() {
|
|
15997
15997
|
const dataFirst = typeof arguments[0] !== "string";
|
|
15998
|
-
const
|
|
15998
|
+
const name2 = dataFirst ? arguments[1] : arguments[0];
|
|
15999
15999
|
const options3 = addSpanStackTrace(dataFirst ? arguments[2] : arguments[1]);
|
|
16000
16000
|
if (dataFirst) {
|
|
16001
16001
|
const self = arguments[0];
|
|
16002
|
-
return useSpan(
|
|
16002
|
+
return useSpan(name2, options3, (span2) => withParentSpan(self, span2));
|
|
16003
16003
|
}
|
|
16004
|
-
return (self) => useSpan(
|
|
16004
|
+
return (self) => useSpan(name2, options3, (span2) => withParentSpan(self, span2));
|
|
16005
16005
|
};
|
|
16006
16006
|
|
|
16007
16007
|
// node_modules/.pnpm/effect@3.15.0/node_modules/effect/dist/esm/Exit.js
|
|
@@ -16163,14 +16163,14 @@ var structuredMessage = (u) => {
|
|
|
16163
16163
|
}
|
|
16164
16164
|
}
|
|
16165
16165
|
};
|
|
16166
|
-
var withColor = (
|
|
16166
|
+
var withColor = (text9, ...colors2) => {
|
|
16167
16167
|
let out = "";
|
|
16168
16168
|
for (let i = 0; i < colors2.length; i++) {
|
|
16169
16169
|
out += `\x1B[${colors2[i]}m`;
|
|
16170
16170
|
}
|
|
16171
|
-
return out +
|
|
16171
|
+
return out + text9 + "\x1B[0m";
|
|
16172
16172
|
};
|
|
16173
|
-
var withColorNoop = (
|
|
16173
|
+
var withColorNoop = (text9, ..._colors) => text9;
|
|
16174
16174
|
var colors = {
|
|
16175
16175
|
bold: "1",
|
|
16176
16176
|
red: "31",
|
|
@@ -16454,14 +16454,14 @@ var metricKeyVariance = {
|
|
|
16454
16454
|
var arrayEquivilence = /* @__PURE__ */ getEquivalence(equals);
|
|
16455
16455
|
var _a31;
|
|
16456
16456
|
var MetricKeyImpl = class {
|
|
16457
|
-
constructor(
|
|
16457
|
+
constructor(name2, keyType, description, tags2 = []) {
|
|
16458
16458
|
__publicField(this, "name");
|
|
16459
16459
|
__publicField(this, "keyType");
|
|
16460
16460
|
__publicField(this, "description");
|
|
16461
16461
|
__publicField(this, "tags");
|
|
16462
16462
|
__publicField(this, _a31, metricKeyVariance);
|
|
16463
16463
|
__publicField(this, "_hash");
|
|
16464
|
-
this.name =
|
|
16464
|
+
this.name = name2;
|
|
16465
16465
|
this.keyType = keyType;
|
|
16466
16466
|
this.description = description;
|
|
16467
16467
|
this.tags = tags2;
|
|
@@ -16478,8 +16478,8 @@ var MetricKeyImpl = class {
|
|
|
16478
16478
|
}
|
|
16479
16479
|
};
|
|
16480
16480
|
var isMetricKey = (u) => hasProperty(u, MetricKeyTypeId);
|
|
16481
|
-
var counter2 = (
|
|
16482
|
-
var histogram2 = (
|
|
16481
|
+
var counter2 = (name2, options3) => new MetricKeyImpl(name2, counter(options3), fromNullable(options3?.description));
|
|
16482
|
+
var histogram2 = (name2, boundaries, description) => new MetricKeyImpl(name2, histogram(boundaries), fromNullable(description));
|
|
16483
16483
|
var taggedWithLabels = /* @__PURE__ */ dual(2, (self, extraTags) => extraTags.length === 0 ? self : new MetricKeyImpl(self.name, self.keyType, self.description, union(self.tags, extraTags)));
|
|
16484
16484
|
|
|
16485
16485
|
// node_modules/.pnpm/effect@3.15.0/node_modules/effect/dist/esm/MutableHashMap.js
|
|
@@ -17195,7 +17195,7 @@ var make32 = function(keyType, unsafeUpdate, unsafeValue, unsafeModify) {
|
|
|
17195
17195
|
});
|
|
17196
17196
|
return metric;
|
|
17197
17197
|
};
|
|
17198
|
-
var counter5 = (
|
|
17198
|
+
var counter5 = (name2, options3) => fromMetricKey(counter2(name2, options3));
|
|
17199
17199
|
var fromMetricKey = (key) => {
|
|
17200
17200
|
let untaggedHook;
|
|
17201
17201
|
const hookCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -17217,7 +17217,7 @@ var fromMetricKey = (key) => {
|
|
|
17217
17217
|
};
|
|
17218
17218
|
return make32(key.keyType, (input, extraTags) => hook(extraTags).update(input), (extraTags) => hook(extraTags).get(), (input, extraTags) => hook(extraTags).modify(input));
|
|
17219
17219
|
};
|
|
17220
|
-
var histogram5 = (
|
|
17220
|
+
var histogram5 = (name2, boundaries, description) => fromMetricKey(histogram2(name2, boundaries, description));
|
|
17221
17221
|
var tagged = /* @__PURE__ */ dual(3, (self, key, value5) => taggedWithLabels2(self, [make29(key, value5)]));
|
|
17222
17222
|
var taggedWithLabels2 = /* @__PURE__ */ dual(2, (self, extraTags) => {
|
|
17223
17223
|
return make32(self.keyType, (input, extraTags1) => self.unsafeUpdate(input, union(extraTags, extraTags1)), (extraTags1) => self.unsafeValue(union(extraTags, extraTags1)), (input, extraTags1) => self.unsafeModify(input, union(extraTags, extraTags1)));
|
|
@@ -20057,6 +20057,12 @@ var suspend4 = (evaluate2) => {
|
|
|
20057
20057
|
suspend11.evaluate = evaluate2;
|
|
20058
20058
|
return suspend11;
|
|
20059
20059
|
};
|
|
20060
|
+
var sync4 = /* @__PURE__ */ dual(2, (a, b) => {
|
|
20061
|
+
const tagFirst = isTag2(a);
|
|
20062
|
+
const tag4 = tagFirst ? a : b;
|
|
20063
|
+
const evaluate2 = tagFirst ? b : a;
|
|
20064
|
+
return fromEffectContext(sync(() => make12(tag4, evaluate2())));
|
|
20065
|
+
});
|
|
20060
20066
|
var provide = /* @__PURE__ */ dual(2, (self, that) => suspend4(() => {
|
|
20061
20067
|
const provideTo = Object.create(proto5);
|
|
20062
20068
|
provideTo._op_layer = OP_PROVIDE;
|
|
@@ -20472,7 +20478,7 @@ var fn = function(nameOrBody, ...pipeables) {
|
|
|
20472
20478
|
Error.stackTraceLimit = 2;
|
|
20473
20479
|
const errorDef = new Error();
|
|
20474
20480
|
Error.stackTraceLimit = limit;
|
|
20475
|
-
const
|
|
20481
|
+
const name2 = nameOrBody;
|
|
20476
20482
|
const options3 = pipeables[0];
|
|
20477
20483
|
return (body, ...pipeables2) => defineLength(body.length, function(...args2) {
|
|
20478
20484
|
const limit2 = Error.stackTraceLimit;
|
|
@@ -20484,7 +20490,7 @@ var fn = function(nameOrBody, ...pipeables) {
|
|
|
20484
20490
|
body,
|
|
20485
20491
|
args: args2,
|
|
20486
20492
|
pipeables: pipeables2,
|
|
20487
|
-
spanName:
|
|
20493
|
+
spanName: name2,
|
|
20488
20494
|
spanOptions: options3,
|
|
20489
20495
|
errorDef,
|
|
20490
20496
|
errorCall
|
|
@@ -20607,13 +20613,13 @@ var formatUnknown = (u, checkCircular = true) => {
|
|
|
20607
20613
|
JSON.stringify(u);
|
|
20608
20614
|
}
|
|
20609
20615
|
const pojo = `{${ownKeys(u).map((k) => `${isString(k) ? JSON.stringify(k) : String(k)}:${formatUnknown(u[k], false)}`).join(",")}}`;
|
|
20610
|
-
const
|
|
20611
|
-
return u.constructor !== Object.prototype.constructor ? `${
|
|
20616
|
+
const name2 = u.constructor.name;
|
|
20617
|
+
return u.constructor !== Object.prototype.constructor ? `${name2}(${pojo})` : pojo;
|
|
20612
20618
|
} catch (e) {
|
|
20613
20619
|
return "<circular structure>";
|
|
20614
20620
|
}
|
|
20615
20621
|
};
|
|
20616
|
-
var formatPropertyKey = (
|
|
20622
|
+
var formatPropertyKey = (name2) => typeof name2 === "string" ? JSON.stringify(name2) : String(name2);
|
|
20617
20623
|
var isNonEmpty5 = (x) => Array.isArray(x);
|
|
20618
20624
|
var isSingle = (x) => !Array.isArray(x);
|
|
20619
20625
|
var formatPathKey = (key) => `[${formatPropertyKey(key)}]`;
|
|
@@ -21071,11 +21077,11 @@ var formatTuple = (ast) => {
|
|
|
21071
21077
|
});
|
|
21072
21078
|
};
|
|
21073
21079
|
var PropertySignature = class extends OptionalType {
|
|
21074
|
-
constructor(
|
|
21080
|
+
constructor(name2, type2, isOptional, isReadonly, annotations2) {
|
|
21075
21081
|
super(type2, isOptional, annotations2);
|
|
21076
21082
|
__publicField(this, "name");
|
|
21077
21083
|
__publicField(this, "isReadonly");
|
|
21078
|
-
this.name =
|
|
21084
|
+
this.name = name2;
|
|
21079
21085
|
this.isReadonly = isReadonly;
|
|
21080
21086
|
}
|
|
21081
21087
|
/**
|
|
@@ -21159,11 +21165,11 @@ var TypeLiteral = class {
|
|
|
21159
21165
|
this.annotations = annotations2;
|
|
21160
21166
|
const keys5 = {};
|
|
21161
21167
|
for (let i = 0; i < propertySignatures.length; i++) {
|
|
21162
|
-
const
|
|
21163
|
-
if (Object.prototype.hasOwnProperty.call(keys5,
|
|
21164
|
-
throw new Error(getASTDuplicatePropertySignatureErrorMessage(
|
|
21168
|
+
const name2 = propertySignatures[i].name;
|
|
21169
|
+
if (Object.prototype.hasOwnProperty.call(keys5, name2)) {
|
|
21170
|
+
throw new Error(getASTDuplicatePropertySignatureErrorMessage(name2));
|
|
21165
21171
|
}
|
|
21166
|
-
keys5[
|
|
21172
|
+
keys5[name2] = null;
|
|
21167
21173
|
}
|
|
21168
21174
|
const parameters = {
|
|
21169
21175
|
string: false,
|
|
@@ -21609,8 +21615,8 @@ var record = (key, value5) => {
|
|
|
21609
21615
|
}
|
|
21610
21616
|
break;
|
|
21611
21617
|
case "Enums": {
|
|
21612
|
-
for (const [_,
|
|
21613
|
-
propertySignatures.push(new PropertySignature(
|
|
21618
|
+
for (const [_, name2] of key2.enums) {
|
|
21619
|
+
propertySignatures.push(new PropertySignature(name2, value5, false, true));
|
|
21614
21620
|
}
|
|
21615
21621
|
break;
|
|
21616
21622
|
}
|
|
@@ -22345,13 +22351,13 @@ var go = (ast, isDecoding) => {
|
|
|
22345
22351
|
const isExact = options3?.exact === true;
|
|
22346
22352
|
for (let i = 0; i < propertySignatures.length; i++) {
|
|
22347
22353
|
const ps = propertySignatures[i][1];
|
|
22348
|
-
const
|
|
22349
|
-
const hasKey = Object.prototype.hasOwnProperty.call(input,
|
|
22354
|
+
const name2 = ps.name;
|
|
22355
|
+
const hasKey = Object.prototype.hasOwnProperty.call(input, name2);
|
|
22350
22356
|
if (!hasKey) {
|
|
22351
22357
|
if (ps.isOptional) {
|
|
22352
22358
|
continue;
|
|
22353
22359
|
} else if (isExact) {
|
|
22354
|
-
const e = new Pointer(
|
|
22360
|
+
const e = new Pointer(name2, input, new Missing(ps));
|
|
22355
22361
|
if (allErrors) {
|
|
22356
22362
|
es.push([stepKey++, e]);
|
|
22357
22363
|
continue;
|
|
@@ -22361,10 +22367,10 @@ var go = (ast, isDecoding) => {
|
|
|
22361
22367
|
}
|
|
22362
22368
|
}
|
|
22363
22369
|
const parser = propertySignatures[i][0];
|
|
22364
|
-
const te = parser(input[
|
|
22370
|
+
const te = parser(input[name2], options3);
|
|
22365
22371
|
if (isEither3(te)) {
|
|
22366
22372
|
if (isLeft2(te)) {
|
|
22367
|
-
const e = new Pointer(
|
|
22373
|
+
const e = new Pointer(name2, input, hasKey ? te.left : new Missing(ps));
|
|
22368
22374
|
if (allErrors) {
|
|
22369
22375
|
es.push([stepKey++, e]);
|
|
22370
22376
|
continue;
|
|
@@ -22372,10 +22378,10 @@ var go = (ast, isDecoding) => {
|
|
|
22372
22378
|
return left2(new Composite2(ast, input, e, output));
|
|
22373
22379
|
}
|
|
22374
22380
|
}
|
|
22375
|
-
output[
|
|
22381
|
+
output[name2] = te.right;
|
|
22376
22382
|
} else {
|
|
22377
22383
|
const nk = stepKey++;
|
|
22378
|
-
const index =
|
|
22384
|
+
const index = name2;
|
|
22379
22385
|
if (!queue) {
|
|
22380
22386
|
queue = [];
|
|
22381
22387
|
}
|
|
@@ -22458,9 +22464,9 @@ var go = (ast, isDecoding) => {
|
|
|
22458
22464
|
}
|
|
22459
22465
|
if (options3?.propertyOrder === "original") {
|
|
22460
22466
|
const keys5 = inputKeys || ownKeys(input);
|
|
22461
|
-
for (const
|
|
22462
|
-
if (keys5.indexOf(
|
|
22463
|
-
keys5.push(
|
|
22467
|
+
for (const name2 of expectedKeys) {
|
|
22468
|
+
if (keys5.indexOf(name2) === -1) {
|
|
22469
|
+
keys5.push(name2);
|
|
22464
22470
|
}
|
|
22465
22471
|
}
|
|
22466
22472
|
const out = {};
|
|
@@ -22511,29 +22517,29 @@ var go = (ast, isDecoding) => {
|
|
|
22511
22517
|
if (ownKeysLen > 0) {
|
|
22512
22518
|
if (isRecordOrArray(input)) {
|
|
22513
22519
|
for (let i = 0; i < ownKeysLen; i++) {
|
|
22514
|
-
const
|
|
22515
|
-
const buckets = searchTree.keys[
|
|
22516
|
-
if (Object.prototype.hasOwnProperty.call(input,
|
|
22517
|
-
const literal2 = String(input[
|
|
22520
|
+
const name2 = ownKeys2[i];
|
|
22521
|
+
const buckets = searchTree.keys[name2].buckets;
|
|
22522
|
+
if (Object.prototype.hasOwnProperty.call(input, name2)) {
|
|
22523
|
+
const literal2 = String(input[name2]);
|
|
22518
22524
|
if (Object.prototype.hasOwnProperty.call(buckets, literal2)) {
|
|
22519
22525
|
candidates = candidates.concat(buckets[literal2]);
|
|
22520
22526
|
} else {
|
|
22521
22527
|
const {
|
|
22522
22528
|
candidates: candidates2,
|
|
22523
22529
|
literals
|
|
22524
|
-
} = searchTree.keys[
|
|
22530
|
+
} = searchTree.keys[name2];
|
|
22525
22531
|
const literalsUnion = Union.make(literals);
|
|
22526
|
-
const errorAst = candidates2.length === astTypesLen ? new TypeLiteral([new PropertySignature(
|
|
22527
|
-
es.push([stepKey++, new Composite2(errorAst, input, new Pointer(
|
|
22532
|
+
const errorAst = candidates2.length === astTypesLen ? new TypeLiteral([new PropertySignature(name2, literalsUnion, false, true)], []) : Union.make(candidates2);
|
|
22533
|
+
es.push([stepKey++, new Composite2(errorAst, input, new Pointer(name2, input, new Type2(literalsUnion, input[name2])))]);
|
|
22528
22534
|
}
|
|
22529
22535
|
} else {
|
|
22530
22536
|
const {
|
|
22531
22537
|
candidates: candidates2,
|
|
22532
22538
|
literals
|
|
22533
|
-
} = searchTree.keys[
|
|
22534
|
-
const fakePropertySignature = new PropertySignature(
|
|
22539
|
+
} = searchTree.keys[name2];
|
|
22540
|
+
const fakePropertySignature = new PropertySignature(name2, Union.make(literals), false, true);
|
|
22535
22541
|
const errorAst = candidates2.length === astTypesLen ? new TypeLiteral([fakePropertySignature], []) : Union.make(candidates2);
|
|
22536
|
-
es.push([stepKey++, new Composite2(errorAst, input, new Pointer(
|
|
22542
|
+
es.push([stepKey++, new Composite2(errorAst, input, new Pointer(name2, input, new Missing(fakePropertySignature)))]);
|
|
22537
22543
|
}
|
|
22538
22544
|
}
|
|
22539
22545
|
} else {
|
|
@@ -22895,9 +22901,11 @@ var withMinimumLogLevel = /* @__PURE__ */ dual(2, (self, level) => fiberRefLocal
|
|
|
22895
22901
|
|
|
22896
22902
|
// node_modules/.pnpm/effect@3.15.0/node_modules/effect/dist/esm/Layer.js
|
|
22897
22903
|
var effect = fromEffect3;
|
|
22904
|
+
var merge7 = merge5;
|
|
22898
22905
|
var mergeAll4 = mergeAll2;
|
|
22899
22906
|
var scoped3 = scoped;
|
|
22900
22907
|
var succeed10 = succeed7;
|
|
22908
|
+
var sync6 = sync4;
|
|
22901
22909
|
var provide3 = provide;
|
|
22902
22910
|
var provideMerge2 = provideMerge;
|
|
22903
22911
|
|
|
@@ -22911,7 +22919,7 @@ var defaultConfig = {
|
|
|
22911
22919
|
showBuiltIns: true,
|
|
22912
22920
|
showTypes: true
|
|
22913
22921
|
};
|
|
22914
|
-
var normalizeCase = /* @__PURE__ */ dual(2, (self,
|
|
22922
|
+
var normalizeCase = /* @__PURE__ */ dual(2, (self, text9) => self.isCaseSensitive ? text9 : text9.toLowerCase());
|
|
22915
22923
|
|
|
22916
22924
|
// node_modules/.pnpm/@effect+cli@0.61.0_@effect+platform@0.82.0_effect@3.15.0__@effect+printer-ansi@0.43.0_@effect_47yie6mzjhwbbrbs5cq7mqvkpe/node_modules/@effect/cli/dist/esm/internal/autoCorrect.js
|
|
22917
22925
|
var levensteinDistance = (first3, second, config2) => {
|
|
@@ -23521,11 +23529,11 @@ var acquireReleaseOut = /* @__PURE__ */ dual(2, (self, release) => {
|
|
|
23521
23529
|
var collectElements = (self) => {
|
|
23522
23530
|
return suspend6(() => {
|
|
23523
23531
|
const builder = [];
|
|
23524
|
-
return flatMap12(pipeTo(self, collectElementsReader(builder)), (value5) =>
|
|
23532
|
+
return flatMap12(pipeTo(self, collectElementsReader(builder)), (value5) => sync7(() => [fromIterable2(builder), value5]));
|
|
23525
23533
|
});
|
|
23526
23534
|
};
|
|
23527
23535
|
var collectElementsReader = (builder) => readWith({
|
|
23528
|
-
onInput: (outElem) => flatMap12(
|
|
23536
|
+
onInput: (outElem) => flatMap12(sync7(() => {
|
|
23529
23537
|
builder.push(outElem);
|
|
23530
23538
|
}), () => collectElementsReader(builder)),
|
|
23531
23539
|
onFailure: fail11,
|
|
@@ -23610,7 +23618,7 @@ var readWithCause = (options3) => {
|
|
|
23610
23618
|
op.done = new ContinuationKImpl(options3.onDone, options3.onFailure);
|
|
23611
23619
|
return op;
|
|
23612
23620
|
};
|
|
23613
|
-
var succeed11 = (value5) =>
|
|
23621
|
+
var succeed11 = (value5) => sync7(() => value5);
|
|
23614
23622
|
var succeedNow = (result) => {
|
|
23615
23623
|
const op = Object.create(proto8);
|
|
23616
23624
|
op._tag = OP_SUCCEED_NOW;
|
|
@@ -23623,7 +23631,7 @@ var suspend6 = (evaluate2) => {
|
|
|
23623
23631
|
op.channel = evaluate2;
|
|
23624
23632
|
return op;
|
|
23625
23633
|
};
|
|
23626
|
-
var
|
|
23634
|
+
var sync7 = (evaluate2) => {
|
|
23627
23635
|
const op = Object.create(proto8);
|
|
23628
23636
|
op._tag = OP_SUCCEED;
|
|
23629
23637
|
op.evaluate = evaluate2;
|
|
@@ -24699,7 +24707,7 @@ var identityChannel = () => readWith({
|
|
|
24699
24707
|
onFailure: fail11,
|
|
24700
24708
|
onDone: succeedNow
|
|
24701
24709
|
});
|
|
24702
|
-
var map20 = /* @__PURE__ */ dual(2, (self, f) => flatMap12(self, (a) =>
|
|
24710
|
+
var map20 = /* @__PURE__ */ dual(2, (self, f) => flatMap12(self, (a) => sync7(() => f(a))));
|
|
24703
24711
|
var mapOut = /* @__PURE__ */ dual(2, (self, f) => {
|
|
24704
24712
|
const reader = readWith({
|
|
24705
24713
|
onInput: (outElem) => flatMap12(write(f(outElem)), () => reader),
|
|
@@ -25342,7 +25350,7 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => {
|
|
|
25342
25350
|
const upstreamMarker = readWith({
|
|
25343
25351
|
onInput: (input) => flatMap12(write(input), () => upstreamMarker),
|
|
25344
25352
|
onFailure: fail11,
|
|
25345
|
-
onDone: (done8) => zipRight4(
|
|
25353
|
+
onDone: (done8) => zipRight4(sync7(() => {
|
|
25346
25354
|
upstreamDone.ref = true;
|
|
25347
25355
|
}), succeedNow(done8))
|
|
25348
25356
|
});
|
|
@@ -25970,10 +25978,10 @@ var char = (char4) => {
|
|
|
25970
25978
|
op.char = char4;
|
|
25971
25979
|
return op;
|
|
25972
25980
|
};
|
|
25973
|
-
var text = (
|
|
25981
|
+
var text = (text9) => {
|
|
25974
25982
|
const op = Object.create(proto15);
|
|
25975
25983
|
op._tag = "Text";
|
|
25976
|
-
op.text =
|
|
25984
|
+
op.text = text9;
|
|
25977
25985
|
return op;
|
|
25978
25986
|
};
|
|
25979
25987
|
var flatAlt = /* @__PURE__ */ dual(2, (self, that) => {
|
|
@@ -26262,10 +26270,10 @@ var char2 = /* @__PURE__ */ dual(2, (self, char4) => {
|
|
|
26262
26270
|
op.stream = self;
|
|
26263
26271
|
return op;
|
|
26264
26272
|
});
|
|
26265
|
-
var text2 = /* @__PURE__ */ dual(2, (self,
|
|
26273
|
+
var text2 = /* @__PURE__ */ dual(2, (self, text9) => {
|
|
26266
26274
|
const op = Object.create(proto16);
|
|
26267
26275
|
op._tag = "TextStream";
|
|
26268
|
-
op.text =
|
|
26276
|
+
op.text = text9;
|
|
26269
26277
|
op.stream = self;
|
|
26270
26278
|
return op;
|
|
26271
26279
|
});
|
|
@@ -27423,8 +27431,8 @@ var intersectTypeLiterals = (x, y, path2) => {
|
|
|
27423
27431
|
if (isTypeLiteral(x) && isTypeLiteral(y)) {
|
|
27424
27432
|
const propertySignatures = [...x.propertySignatures];
|
|
27425
27433
|
for (const ps of y.propertySignatures) {
|
|
27426
|
-
const
|
|
27427
|
-
const i = propertySignatures.findIndex((ps2) => ps2.name ===
|
|
27434
|
+
const name2 = ps.name;
|
|
27435
|
+
const i = propertySignatures.findIndex((ps2) => ps2.name === name2);
|
|
27428
27436
|
if (i === -1) {
|
|
27429
27437
|
propertySignatures.push(ps);
|
|
27430
27438
|
} else {
|
|
@@ -27432,7 +27440,7 @@ var intersectTypeLiterals = (x, y, path2) => {
|
|
|
27432
27440
|
isOptional,
|
|
27433
27441
|
type: type2
|
|
27434
27442
|
} = propertySignatures[i];
|
|
27435
|
-
propertySignatures[i] = new PropertySignature(
|
|
27443
|
+
propertySignatures[i] = new PropertySignature(name2, extendAST(type2, ps.type, path2.concat(name2)), isOptional, true);
|
|
27436
27444
|
}
|
|
27437
27445
|
}
|
|
27438
27446
|
return new TypeLiteral(propertySignatures, x.indexSignatures.concat(y.indexSignatures));
|
|
@@ -28388,12 +28396,12 @@ var windowsFigures = {
|
|
|
28388
28396
|
pointer: /* @__PURE__ */ text3(">")
|
|
28389
28397
|
};
|
|
28390
28398
|
var figures = /* @__PURE__ */ map17(/* @__PURE__ */ sync5(() => process.platform === "win32"), (isWindows) => isWindows ? windowsFigures : defaultFigures);
|
|
28391
|
-
function eraseText(
|
|
28399
|
+
function eraseText(text9, columns) {
|
|
28392
28400
|
if (columns === 0) {
|
|
28393
28401
|
return cat2(eraseLine3, cursorTo3(0));
|
|
28394
28402
|
}
|
|
28395
28403
|
let rows = 0;
|
|
28396
|
-
const lines3 =
|
|
28404
|
+
const lines3 = text9.split(/\r?\n/);
|
|
28397
28405
|
for (const line4 of lines3) {
|
|
28398
28406
|
rows += 1 + Math.floor(Math.max(line4.length - 1, 0) / columns);
|
|
28399
28407
|
}
|
|
@@ -28947,12 +28955,12 @@ function handleClear2(options3) {
|
|
|
28947
28955
|
const terminal = yield* Terminal;
|
|
28948
28956
|
const columns = yield* terminal.columns;
|
|
28949
28957
|
const currentPath = yield* resolveCurrentPath(state.path, options3);
|
|
28950
|
-
const
|
|
28958
|
+
const text9 = "\n".repeat(Math.min(state.files.length, options3.maxPerPage));
|
|
28951
28959
|
const clearPath = eraseText(currentPath, columns);
|
|
28952
28960
|
const message = showConfirmation(state.confirm) ? CONFIRM_MESSAGE : options3.message;
|
|
28953
28961
|
const clearPrompt = eraseText(`
|
|
28954
28962
|
${message}`, columns);
|
|
28955
|
-
const clearOptions = eraseText(
|
|
28963
|
+
const clearOptions = eraseText(text9, columns);
|
|
28956
28964
|
return clearOptions.pipe(cat2(clearPath), cat2(clearPrompt), optimize3(Deep), render3({
|
|
28957
28965
|
style: "pretty",
|
|
28958
28966
|
options: {
|
|
@@ -29662,8 +29670,8 @@ function handleClear4(options3) {
|
|
|
29662
29670
|
const terminal = yield* Terminal;
|
|
29663
29671
|
const columns = yield* terminal.columns;
|
|
29664
29672
|
const clearPrompt = cat2(eraseLine3, cursorLeft3);
|
|
29665
|
-
const
|
|
29666
|
-
const clearOutput = eraseText(
|
|
29673
|
+
const text9 = "\n".repeat(Math.min(options3.choices.length, options3.maxPerPage)) + options3.message;
|
|
29674
|
+
const clearOutput = eraseText(text9, columns);
|
|
29667
29675
|
return clearOutput.pipe(cat2(clearPrompt), optimize3(Deep), render3({
|
|
29668
29676
|
style: "pretty",
|
|
29669
29677
|
options: {
|
|
@@ -29749,7 +29757,7 @@ ${error4}`, columns))
|
|
|
29749
29757
|
});
|
|
29750
29758
|
}
|
|
29751
29759
|
function renderInput2(nextState, options3, submitted) {
|
|
29752
|
-
const
|
|
29760
|
+
const text9 = getValue(nextState, options3);
|
|
29753
29761
|
const annotation = match2(nextState.error, {
|
|
29754
29762
|
onNone: () => {
|
|
29755
29763
|
if (submitted) {
|
|
@@ -29767,10 +29775,10 @@ function renderInput2(nextState, options3, submitted) {
|
|
|
29767
29775
|
return empty34;
|
|
29768
29776
|
}
|
|
29769
29777
|
case "password": {
|
|
29770
|
-
return annotate2(text3("*".repeat(
|
|
29778
|
+
return annotate2(text3("*".repeat(text9.length)), annotation);
|
|
29771
29779
|
}
|
|
29772
29780
|
case "text": {
|
|
29773
|
-
return annotate2(text3(
|
|
29781
|
+
return annotate2(text3(text9), annotation);
|
|
29774
29782
|
}
|
|
29775
29783
|
}
|
|
29776
29784
|
}
|
|
@@ -30154,6 +30162,11 @@ var path = (pathType, pathExists) => {
|
|
|
30154
30162
|
op.pathExists = pathExists;
|
|
30155
30163
|
return op;
|
|
30156
30164
|
};
|
|
30165
|
+
var text6 = /* @__PURE__ */ (() => {
|
|
30166
|
+
const op = /* @__PURE__ */ Object.create(proto19);
|
|
30167
|
+
op._tag = "Text";
|
|
30168
|
+
return op;
|
|
30169
|
+
})();
|
|
30157
30170
|
var getChoices = (self) => getChoicesInternal(self);
|
|
30158
30171
|
var getHelp = (self) => getHelpInternal(self);
|
|
30159
30172
|
var getTypeName = (self) => getTypeNameInternal(self);
|
|
@@ -30487,7 +30500,7 @@ var getZshCompletions = (self) => {
|
|
|
30487
30500
|
return "";
|
|
30488
30501
|
}
|
|
30489
30502
|
case "Choice": {
|
|
30490
|
-
const choices = pipe(map3(self.alternatives, ([
|
|
30503
|
+
const choices = pipe(map3(self.alternatives, ([name2]) => name2), join(" "));
|
|
30491
30504
|
return `:CHOICE:(${choices})`;
|
|
30492
30505
|
}
|
|
30493
30506
|
case "DateTime": {
|
|
@@ -30616,7 +30629,7 @@ var render4 = (self, config2) => {
|
|
|
30616
30629
|
onNone: () => empty35,
|
|
30617
30630
|
onSome: (s) => concat3(space3, text4(s))
|
|
30618
30631
|
}) : empty35;
|
|
30619
|
-
const namesToShow = config2.showAllNames ? self.names : self.names.length > 1 ? pipe(filter2(self.names, (
|
|
30632
|
+
const namesToShow = config2.showAllNames ? self.names : self.names.length > 1 ? pipe(filter2(self.names, (name2) => name2.startsWith("--")), head, map2(of), getOrElse(() => self.names)) : self.names;
|
|
30620
30633
|
const nameInfo = text4(join(namesToShow, ", "));
|
|
30621
30634
|
return config2.showAllNames && self.names.length > 1 ? of(spans([text4("("), nameInfo, typeInfo, text4(")")])) : of(concat3(nameInfo, typeInfo));
|
|
30622
30635
|
}
|
|
@@ -30755,7 +30768,7 @@ var defaultBooleanOptions = {
|
|
|
30755
30768
|
negationNames: [],
|
|
30756
30769
|
aliases: []
|
|
30757
30770
|
};
|
|
30758
|
-
var boolean4 = (
|
|
30771
|
+
var boolean4 = (name2, options3) => {
|
|
30759
30772
|
const {
|
|
30760
30773
|
aliases,
|
|
30761
30774
|
ifPresent,
|
|
@@ -30764,7 +30777,7 @@ var boolean4 = (name, options3) => {
|
|
|
30764
30777
|
...defaultBooleanOptions,
|
|
30765
30778
|
...options3
|
|
30766
30779
|
};
|
|
30767
|
-
const option4 = makeSingle(
|
|
30780
|
+
const option4 = makeSingle(name2, aliases, boolean3(some2(ifPresent)));
|
|
30768
30781
|
if (isNonEmptyReadonlyArray(negationNames)) {
|
|
30769
30782
|
const head5 = headNonEmpty(negationNames);
|
|
30770
30783
|
const tail = tailNonEmpty(negationNames);
|
|
@@ -30773,10 +30786,10 @@ var boolean4 = (name, options3) => {
|
|
|
30773
30786
|
}
|
|
30774
30787
|
return withDefault2(option4, !ifPresent);
|
|
30775
30788
|
};
|
|
30776
|
-
var choiceWithValue = (
|
|
30777
|
-
var file2 = (
|
|
30778
|
-
var fileParse = (
|
|
30779
|
-
var fileText = (
|
|
30789
|
+
var choiceWithValue = (name2, choices) => makeSingle(name2, empty2(), choice(choices));
|
|
30790
|
+
var file2 = (name2, config2) => makeSingle(name2, empty2(), path("file", config2?.exists));
|
|
30791
|
+
var fileParse = (name2, format6) => mapEffect5(fileText(name2), ([path2, content]) => mapError2(parse5(path2, content, format6), (error4) => invalidValue(p(error4))));
|
|
30792
|
+
var fileText = (name2) => mapEffect5(file2(name2, {
|
|
30780
30793
|
exists: "yes"
|
|
30781
30794
|
}), (path2) => mapError2(readString(path2), (error4) => invalidValue(p(error4))));
|
|
30782
30795
|
var none10 = /* @__PURE__ */ (() => {
|
|
@@ -30784,6 +30797,7 @@ var none10 = /* @__PURE__ */ (() => {
|
|
|
30784
30797
|
op._tag = "Empty";
|
|
30785
30798
|
return op;
|
|
30786
30799
|
})();
|
|
30800
|
+
var text7 = (name2) => makeSingle(name2, empty2(), text6);
|
|
30787
30801
|
var getHelp3 = (self) => getHelpInternal2(self);
|
|
30788
30802
|
var getUsage = (self) => getUsageInternal(self);
|
|
30789
30803
|
var map28 = /* @__PURE__ */ dual(2, (self, f) => makeMap(self, (a) => right2(f(a))));
|
|
@@ -31039,11 +31053,11 @@ var makeOrElse = (left3, right3) => {
|
|
|
31039
31053
|
op.right = right3;
|
|
31040
31054
|
return op;
|
|
31041
31055
|
};
|
|
31042
|
-
var makeSingle = (
|
|
31056
|
+
var makeSingle = (name2, aliases, primitiveType, description = empty36, pseudoName = none2()) => {
|
|
31043
31057
|
const op = Object.create(proto21);
|
|
31044
31058
|
op._tag = "Single";
|
|
31045
|
-
op.name =
|
|
31046
|
-
op.fullName = makeFullName(
|
|
31059
|
+
op.name = name2;
|
|
31060
|
+
op.fullName = makeFullName(name2)[1];
|
|
31047
31061
|
op.placeholder = `${getOrElse(pseudoName, () => getTypeName(primitiveType))}`;
|
|
31048
31062
|
op.aliases = aliases;
|
|
31049
31063
|
op.primitiveType = primitiveType;
|
|
@@ -31164,7 +31178,7 @@ var parseInternal = (self, args2, config2) => {
|
|
|
31164
31178
|
return _void;
|
|
31165
31179
|
}
|
|
31166
31180
|
case "Single": {
|
|
31167
|
-
const singleNames = filterMap2(getNames(self), (
|
|
31181
|
+
const singleNames = filterMap2(getNames(self), (name2) => get7(args2, name2));
|
|
31168
31182
|
if (isNonEmptyReadonlyArray(singleNames)) {
|
|
31169
31183
|
const head5 = headNonEmpty(singleNames);
|
|
31170
31184
|
const tail = tailNonEmpty(singleNames);
|
|
@@ -31233,16 +31247,16 @@ var parseInternal = (self, args2, config2) => {
|
|
|
31233
31247
|
case "Variadic": {
|
|
31234
31248
|
const min4 = getOrElse(self.min, () => 0);
|
|
31235
31249
|
const max6 = getOrElse(self.max, () => Number.MAX_SAFE_INTEGER);
|
|
31236
|
-
const matchedArgument = filterMap2(getNames(self), (
|
|
31250
|
+
const matchedArgument = filterMap2(getNames(self), (name2) => get7(args2, name2));
|
|
31237
31251
|
const validateMinMax = (values3) => {
|
|
31238
31252
|
if (values3.length < min4) {
|
|
31239
|
-
const
|
|
31240
|
-
const error4 = `Expected at least ${min4} value(s) for option: '${
|
|
31253
|
+
const name2 = self.argumentOption.fullName;
|
|
31254
|
+
const error4 = `Expected at least ${min4} value(s) for option: '${name2}'`;
|
|
31241
31255
|
return fail8(invalidValue(p(error4)));
|
|
31242
31256
|
}
|
|
31243
31257
|
if (values3.length > max6) {
|
|
31244
|
-
const
|
|
31245
|
-
const error4 = `Expected at most ${max6} value(s) for option: '${
|
|
31258
|
+
const name2 = self.argumentOption.fullName;
|
|
31259
|
+
const error4 = `Expected at most ${max6} value(s) for option: '${name2}'`;
|
|
31246
31260
|
return fail8(invalidValue(p(error4)));
|
|
31247
31261
|
}
|
|
31248
31262
|
const primitive2 = self.argumentOption.primitiveType;
|
|
@@ -31375,7 +31389,7 @@ var matchOptions = (input, options3, config2) => {
|
|
|
31375
31389
|
if (isEmpty3(map1)) {
|
|
31376
31390
|
return succeed8([none2(), input, map1]);
|
|
31377
31391
|
}
|
|
31378
|
-
return matchOptions(otherArgs, otherOptions, config2).pipe(map17(([error4, otherArgs2, map210]) => [error4, otherArgs2,
|
|
31392
|
+
return matchOptions(otherArgs, otherOptions, config2).pipe(map17(([error4, otherArgs2, map210]) => [error4, otherArgs2, merge9(map1, fromIterable(map210))]));
|
|
31379
31393
|
}), catchAll2((e) => succeed8([some2(e), input, empty9()])));
|
|
31380
31394
|
}
|
|
31381
31395
|
return isEmptyReadonlyArray(input) ? succeed8([none2(), empty2(), empty9()]) : succeed8([none2(), input, empty9()]);
|
|
@@ -31388,9 +31402,9 @@ var findOptions = (input, options3, config2) => matchLeft(options3, {
|
|
|
31388
31402
|
}) => match2(parsed, {
|
|
31389
31403
|
onNone: () => findOptions(leftover2, tail, config2).pipe(map17(([nextArgs, nextOptions, map33]) => [nextArgs, prepend(nextOptions, head5), map33])),
|
|
31390
31404
|
onSome: ({
|
|
31391
|
-
name,
|
|
31405
|
+
name: name2,
|
|
31392
31406
|
values: values3
|
|
31393
|
-
}) => succeed8([leftover2, tail, make16([
|
|
31407
|
+
}) => succeed8([leftover2, tail, make16([name2, values3])])
|
|
31394
31408
|
})), catchTags2({
|
|
31395
31409
|
CorrectedFlag: (e) => findOptions(input, tail, config2).pipe(catchSome2(() => some2(fail8(e))), flatMap9(([otherArgs, otherOptions, map33]) => fail8(e).pipe(when2(() => isEmpty3(map33)), as4([otherArgs, prepend(otherOptions, head5), map33])))),
|
|
31396
31410
|
MissingFlag: () => findOptions(input, tail, config2).pipe(map17(([otherArgs, otherOptions, map33]) => [otherArgs, prepend(otherOptions, head5), map33])),
|
|
@@ -31427,7 +31441,7 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31427
31441
|
onNonEmpty: (head5, tail) => {
|
|
31428
31442
|
const normalize = (value5) => normalizeCase(config2, value5);
|
|
31429
31443
|
const normalizedHead = normalize(head5);
|
|
31430
|
-
const normalizedNames = map3(getNames(self), (
|
|
31444
|
+
const normalizedNames = map3(getNames(self), (name2) => normalize(name2));
|
|
31431
31445
|
if (contains2(normalizedNames, normalizedHead)) {
|
|
31432
31446
|
if (isBool(self.primitiveType)) {
|
|
31433
31447
|
return matchLeft(tail, {
|
|
@@ -31500,7 +31514,7 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31500
31514
|
})));
|
|
31501
31515
|
}
|
|
31502
31516
|
case "KeyValueMap": {
|
|
31503
|
-
const normalizedNames = map3(getNames(self.argumentOption), (
|
|
31517
|
+
const normalizedNames = map3(getNames(self.argumentOption), (name2) => normalizeCase(config2, name2));
|
|
31504
31518
|
return matchLeft(args2, {
|
|
31505
31519
|
onEmpty: () => succeed8({
|
|
31506
31520
|
parsed: none2(),
|
|
@@ -31511,8 +31525,8 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31511
31525
|
let keyValues = empty2();
|
|
31512
31526
|
let leftover2 = args3;
|
|
31513
31527
|
while (isNonEmptyReadonlyArray(leftover2)) {
|
|
31514
|
-
const
|
|
31515
|
-
const normalizedName2 = normalizeCase(config2,
|
|
31528
|
+
const name2 = headNonEmpty(leftover2).trim();
|
|
31529
|
+
const normalizedName2 = normalizeCase(config2, name2);
|
|
31516
31530
|
if (leftover2.length >= 2 && contains2(normalizedNames, normalizedName2)) {
|
|
31517
31531
|
const keyValue = leftover2[1].trim();
|
|
31518
31532
|
const [key, value5] = keyValue.split("=");
|
|
@@ -31522,10 +31536,10 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31522
31536
|
continue;
|
|
31523
31537
|
}
|
|
31524
31538
|
}
|
|
31525
|
-
if (
|
|
31526
|
-
const [key, value5] =
|
|
31539
|
+
if (name2.includes("=")) {
|
|
31540
|
+
const [key, value5] = name2.split("=");
|
|
31527
31541
|
if (key !== void 0 && value5 !== void 0 && value5.length > 0) {
|
|
31528
|
-
keyValues = append(keyValues,
|
|
31542
|
+
keyValues = append(keyValues, name2);
|
|
31529
31543
|
leftover2 = leftover2.slice(1);
|
|
31530
31544
|
continue;
|
|
31531
31545
|
}
|
|
@@ -31553,17 +31567,17 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31553
31567
|
});
|
|
31554
31568
|
}
|
|
31555
31569
|
case "Variadic": {
|
|
31556
|
-
const normalizedNames = map3(getNames(self.argumentOption), (
|
|
31570
|
+
const normalizedNames = map3(getNames(self.argumentOption), (name2) => normalizeCase(config2, name2));
|
|
31557
31571
|
let optionName = void 0;
|
|
31558
31572
|
let values3 = empty2();
|
|
31559
31573
|
let unparsed = args2;
|
|
31560
31574
|
let leftover2 = empty2();
|
|
31561
31575
|
while (isNonEmptyReadonlyArray(unparsed)) {
|
|
31562
|
-
const
|
|
31563
|
-
const normalizedName = normalizeCase(config2,
|
|
31576
|
+
const name2 = headNonEmpty(unparsed);
|
|
31577
|
+
const normalizedName = normalizeCase(config2, name2);
|
|
31564
31578
|
if (contains2(normalizedNames, normalizedName)) {
|
|
31565
31579
|
if (optionName === void 0) {
|
|
31566
|
-
optionName =
|
|
31580
|
+
optionName = name2;
|
|
31567
31581
|
}
|
|
31568
31582
|
const value5 = unparsed[1];
|
|
31569
31583
|
if (value5 !== void 0 && value5.length > 0) {
|
|
@@ -31575,8 +31589,8 @@ var parseCommandLine = (self, args2, config2) => {
|
|
|
31575
31589
|
unparsed = unparsed.slice(1);
|
|
31576
31590
|
}
|
|
31577
31591
|
}
|
|
31578
|
-
const parsed = fromNullable(optionName).pipe(orElse(() => some2(self.argumentOption.fullName)), map2((
|
|
31579
|
-
name,
|
|
31592
|
+
const parsed = fromNullable(optionName).pipe(orElse(() => some2(self.argumentOption.fullName)), map2((name2) => ({
|
|
31593
|
+
name: name2,
|
|
31580
31594
|
values: values3
|
|
31581
31595
|
})));
|
|
31582
31596
|
return succeed8({
|
|
@@ -31594,12 +31608,12 @@ var matchUnclustered = (input, tail, options3, config2) => {
|
|
|
31594
31608
|
if (isEmpty3(map1)) {
|
|
31595
31609
|
return fail8(unclusteredFlag(empty36, empty2(), tail));
|
|
31596
31610
|
}
|
|
31597
|
-
return matchUnclustered(otherFlags, tail, opts1, config2).pipe(map17(([_2, opts2, map210]) => [tail, opts2,
|
|
31611
|
+
return matchUnclustered(otherFlags, tail, opts1, config2).pipe(map17(([_2, opts2, map210]) => [tail, opts2, merge9(map1, fromIterable(map210))]));
|
|
31598
31612
|
}));
|
|
31599
31613
|
}
|
|
31600
31614
|
return succeed8([tail, options3, empty9()]);
|
|
31601
31615
|
};
|
|
31602
|
-
var
|
|
31616
|
+
var merge9 = (map1, map210) => {
|
|
31603
31617
|
if (isNonEmptyReadonlyArray(map210)) {
|
|
31604
31618
|
const head5 = headNonEmpty(map210);
|
|
31605
31619
|
const tail = tailNonEmpty(map210);
|
|
@@ -31607,7 +31621,7 @@ var merge8 = (map1, map210) => {
|
|
|
31607
31621
|
onNone: () => set3(map1, head5[0], head5[1]),
|
|
31608
31622
|
onSome: (elems) => set3(map1, head5[0], appendAll(elems, head5[1]))
|
|
31609
31623
|
});
|
|
31610
|
-
return
|
|
31624
|
+
return merge9(newMap, tail);
|
|
31611
31625
|
}
|
|
31612
31626
|
return map1;
|
|
31613
31627
|
};
|
|
@@ -31669,7 +31683,7 @@ var getFishCompletions2 = (self) => {
|
|
|
31669
31683
|
case "Single": {
|
|
31670
31684
|
const description = getShortDescription(self);
|
|
31671
31685
|
const order = mapInput2(boolean, (tuple3) => !tuple3[0]);
|
|
31672
|
-
return pipe(prepend(self.aliases, self.name), map3((
|
|
31686
|
+
return pipe(prepend(self.aliases, self.name), map3((name2) => [name2.length === 1, name2]), sort(order), flatMap2(([isShort, name2]) => make4(isShort ? "-s" : "-l", name2)), appendAll(getFishCompletions(self.primitiveType)), appendAll(description.length === 0 ? empty2() : of(`-d '${description}'`)), join(" "), of);
|
|
31673
31687
|
}
|
|
31674
31688
|
case "KeyValueMap":
|
|
31675
31689
|
case "Variadic": {
|
|
@@ -31700,7 +31714,7 @@ var getZshCompletions2 = (self, state = {
|
|
|
31700
31714
|
const possibleValues = getZshCompletions(self.primitiveType);
|
|
31701
31715
|
const multiple = state.multiple ? "*" : "";
|
|
31702
31716
|
const conflicts = isNonEmptyReadonlyArray(state.conflicts) ? `(${join(state.conflicts, " ")})` : "";
|
|
31703
|
-
return map3(names, (
|
|
31717
|
+
return map3(names, (name2) => `${conflicts}${multiple}${name2}[${escape2(description)}]${possibleValues}`);
|
|
31704
31718
|
}
|
|
31705
31719
|
case "KeyValueMap": {
|
|
31706
31720
|
return getZshCompletions2(self.argumentOption, {
|
|
@@ -31744,7 +31758,9 @@ var getZshCompletions2 = (self, state = {
|
|
|
31744
31758
|
var all7 = all6;
|
|
31745
31759
|
var boolean5 = boolean4;
|
|
31746
31760
|
var fileParse2 = fileParse;
|
|
31761
|
+
var text8 = text7;
|
|
31747
31762
|
var withAlias2 = withAlias;
|
|
31763
|
+
var withDefault3 = withDefault2;
|
|
31748
31764
|
var withDescription3 = withDescription2;
|
|
31749
31765
|
|
|
31750
31766
|
// node_modules/.pnpm/@effect+platform@0.82.0_effect@3.15.0/node_modules/@effect/platform/dist/esm/internal/commandExecutor.js
|
|
@@ -33661,7 +33677,7 @@ var validateInternal2 = (self, args2, config2) => {
|
|
|
33661
33677
|
return fail8(missingValue(p(`Missing argument ${getTypeName(self.primitiveType)}`)));
|
|
33662
33678
|
},
|
|
33663
33679
|
onNonEmpty: (head5, tail) => validate4(self.primitiveType, some2(head5), config2).pipe(mapBoth4({
|
|
33664
|
-
onFailure: (
|
|
33680
|
+
onFailure: (text9) => invalidArgument(p(text9)),
|
|
33665
33681
|
onSuccess: (a) => [tail, a]
|
|
33666
33682
|
}))
|
|
33667
33683
|
});
|
|
@@ -33920,10 +33936,10 @@ var proto23 = {
|
|
|
33920
33936
|
};
|
|
33921
33937
|
var isCommand2 = (u) => typeof u === "object" && u != null && TypeId24 in u;
|
|
33922
33938
|
var isStandard = (self) => self._tag === "Standard";
|
|
33923
|
-
var make59 = (
|
|
33939
|
+
var make59 = (name2, options3 = none10, args2 = none11) => {
|
|
33924
33940
|
const op = Object.create(proto23);
|
|
33925
33941
|
op._tag = "Standard";
|
|
33926
|
-
op.name =
|
|
33942
|
+
op.name = name2;
|
|
33927
33943
|
op.description = empty36;
|
|
33928
33944
|
op.options = options3;
|
|
33929
33945
|
op.args = args2;
|
|
@@ -34138,7 +34154,7 @@ var parseInternal2 = (self, args2, config2) => {
|
|
|
34138
34154
|
case "Subcommands": {
|
|
34139
34155
|
const names = getNamesInternal(self);
|
|
34140
34156
|
const subcommands = getSubcommandsInternal(self);
|
|
34141
|
-
const [parentArgs, childArgs] = span(args2, (arg) => !some3(subcommands, ([
|
|
34157
|
+
const [parentArgs, childArgs] = span(args2, (arg) => !some3(subcommands, ([name2]) => name2 === arg));
|
|
34142
34158
|
const parseChildren = suspend5(() => {
|
|
34143
34159
|
const iterator = self.children[Symbol.iterator]();
|
|
34144
34160
|
const loop2 = (next) => {
|
|
@@ -34185,7 +34201,7 @@ var parseInternal2 = (self, args2, config2) => {
|
|
|
34185
34201
|
onFailure: (err) => {
|
|
34186
34202
|
if (isCommandMismatch(err)) {
|
|
34187
34203
|
const parentName = getOrElse(head(names), () => "");
|
|
34188
|
-
const childNames = map3(subcommands, ([
|
|
34204
|
+
const childNames = map3(subcommands, ([name2]) => `'${name2}'`);
|
|
34189
34205
|
const oneOf = childNames.length === 1 ? "" : " one of";
|
|
34190
34206
|
const error4 = p(`Invalid subcommand for ${parentName} - use${oneOf} ${join(childNames, ", ")}`);
|
|
34191
34207
|
return commandMismatch(error4);
|
|
@@ -34255,11 +34271,11 @@ var wizardInternal4 = (self, prefix, config2) => {
|
|
|
34255
34271
|
title,
|
|
34256
34272
|
value: [title, index]
|
|
34257
34273
|
});
|
|
34258
|
-
const choices = pipe(getSubcommandsInternal(self2), map3(([
|
|
34274
|
+
const choices = pipe(getSubcommandsInternal(self2), map3(([name2], index) => makeChoice(name2, index)));
|
|
34259
34275
|
return loop2(self2.parent, commandLineRef).pipe(zipRight3(select({
|
|
34260
34276
|
message,
|
|
34261
34277
|
choices
|
|
34262
|
-
}).pipe(tap2(([
|
|
34278
|
+
}).pipe(tap2(([name2]) => update3(commandLineRef, append(name2))), zipLeft2(log2()), flatMap9(([, nextIndex]) => loop2(self2.children[nextIndex], commandLineRef)))));
|
|
34263
34279
|
}
|
|
34264
34280
|
}
|
|
34265
34281
|
};
|
|
@@ -34326,7 +34342,7 @@ var getBashCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
34326
34342
|
const options3 = isStandard(info2.command) ? all7([info2.command.options, builtIns]) : builtIns;
|
|
34327
34343
|
const optionNames = getNames(options3);
|
|
34328
34344
|
const optionCases = isStandard(info2.command) ? getBashCompletions2(info2.command.options) : empty2();
|
|
34329
|
-
const subcommandNames = pipe(info2.subcommands, map3(([
|
|
34345
|
+
const subcommandNames = pipe(info2.subcommands, map3(([name2]) => name2), sort(string2));
|
|
34330
34346
|
const wordList = appendAll(optionNames, subcommandNames);
|
|
34331
34347
|
const preformatted = isEmptyReadonlyArray(info2.parentCommands) ? of(info2.command.name) : pipe(info2.parentCommands, append(info2.command.name), map3((command) => command.replace("-", "__")));
|
|
34332
34348
|
const caseName = join(preformatted, ",");
|
|
@@ -34348,9 +34364,9 @@ var getFishCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
34348
34364
|
const optionsCompletions = getFishCompletions2(options3);
|
|
34349
34365
|
const argsCompletions = isStandard(info2.command) ? getFishCompletions3(info2.command.args) : empty2();
|
|
34350
34366
|
const rootCompletions = (conditionals2) => pipe(map3(optionsCompletions, (option4) => pipe(baseTemplate, appendAll(conditionals2), append(option4), join(" "))), appendAll(map3(argsCompletions, (option4) => pipe(baseTemplate, appendAll(conditionals2), append(option4), join(" ")))));
|
|
34351
|
-
const subcommandCompletions = (conditionals2) => map3(info2.subcommands, ([
|
|
34367
|
+
const subcommandCompletions = (conditionals2) => map3(info2.subcommands, ([name2, subcommand]) => {
|
|
34352
34368
|
const description = getShortDescription3(subcommand);
|
|
34353
|
-
return pipe(baseTemplate, appendAll(conditionals2), appendAll(make4("-f", "-a", `"${
|
|
34369
|
+
return pipe(baseTemplate, appendAll(conditionals2), appendAll(make4("-f", "-a", `"${name2}"`)), appendAll(description.length === 0 ? empty2() : make4("-d", `'${description}'`)), join(" "));
|
|
34354
34370
|
});
|
|
34355
34371
|
if (isEmptyReadonlyArray(info2.parentCommands)) {
|
|
34356
34372
|
const conditionals2 = make4("-n", '"__fish_use_subcommand"');
|
|
@@ -34363,7 +34379,7 @@ var getFishCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
34363
34379
|
append(info2.command.name),
|
|
34364
34380
|
map3((command) => `__fish_seen_subcommand_from ${command}`)
|
|
34365
34381
|
);
|
|
34366
|
-
const subcommandConditionals = map3(info2.subcommands, ([
|
|
34382
|
+
const subcommandConditionals = map3(info2.subcommands, ([name2]) => `not __fish_seen_subcommand_from ${name2}`);
|
|
34367
34383
|
const baseConditionals = pipe(appendAll(parentConditionals, subcommandConditionals), join("; and "));
|
|
34368
34384
|
const conditionals = make4("-n", `"${baseConditionals}"`);
|
|
34369
34385
|
return succeed8(pipe(state, appendAll(rootCompletions(conditionals)), appendAll(subcommandCompletions(conditionals))));
|
|
@@ -34372,9 +34388,9 @@ var getZshCompletionsInternal = (self, executable) => traverseCommand(self, empt
|
|
|
34372
34388
|
const preformatted = isEmptyReadonlyArray(info2.parentCommands) ? of(info2.command.name) : pipe(info2.parentCommands, append(info2.command.name), map3((command) => command.replace("-", "__")));
|
|
34373
34389
|
const underscoreName = join(preformatted, "__");
|
|
34374
34390
|
const spaceName = join(preformatted, " ");
|
|
34375
|
-
const subcommands = pipe(info2.subcommands, map3(([
|
|
34391
|
+
const subcommands = pipe(info2.subcommands, map3(([name2, subcommand]) => {
|
|
34376
34392
|
const desc = getShortDescription3(subcommand);
|
|
34377
|
-
return `'${
|
|
34393
|
+
return `'${name2}:${desc}' \\`;
|
|
34378
34394
|
}));
|
|
34379
34395
|
const commands = isEmptyReadonlyArray(subcommands) ? `commands=()` : `commands=(
|
|
34380
34396
|
${join(indentAll(subcommands, 8), "\n")}
|
|
@@ -34518,10 +34534,10 @@ var handleBuiltInOption = (self, executable, args2, builtIn2, execute2, config2)
|
|
|
34518
34534
|
const description = descriptionList([[text4("Instructions"), instructions]]);
|
|
34519
34535
|
const header = h1(spans([code("Wizard Mode for CLI Application:"), space3, code(self.name), space3, code(`(${self.version})`), summary5]));
|
|
34520
34536
|
const help = sequence(header, description);
|
|
34521
|
-
const
|
|
34537
|
+
const text9 = toAnsiText(help);
|
|
34522
34538
|
const command = fromIterable(getNames2(self.command))[0];
|
|
34523
34539
|
const wizardPrefix = getWizardPrefix(builtIn2, command, args2);
|
|
34524
|
-
return log2(
|
|
34540
|
+
return log2(text9).pipe(zipRight3(wizard4(builtIn2.command, wizardPrefix, config2)), tap2((args3) => log2(toAnsiText(renderWizardArgs(args3)))), flatMap9((args3) => toggle2({
|
|
34525
34541
|
message: "Would you like to run the command?",
|
|
34526
34542
|
initial: true,
|
|
34527
34543
|
active: "yes",
|
|
@@ -34572,7 +34588,7 @@ var prefixCommand = (self) => {
|
|
|
34572
34588
|
};
|
|
34573
34589
|
var getWizardPrefix = (builtIn2, rootCommand, commandLineArgs) => {
|
|
34574
34590
|
const subcommands = getSubcommands(builtIn2.command);
|
|
34575
|
-
const [parentArgs, childArgs] = span(commandLineArgs, (
|
|
34591
|
+
const [parentArgs, childArgs] = span(commandLineArgs, (name2) => !has4(subcommands, name2));
|
|
34576
34592
|
const args2 = matchLeft(childArgs, {
|
|
34577
34593
|
onEmpty: () => filter2(parentArgs, (arg) => arg !== "--wizard"),
|
|
34578
34594
|
onNonEmpty: (head5) => append(parentArgs, head5)
|
|
@@ -34681,18 +34697,18 @@ var fromDescriptor = /* @__PURE__ */ dual((args2) => isCommand2(args2[0]), (desc
|
|
|
34681
34697
|
const self = makeProto(descriptor2, handler ?? ((_) => failSync2(() => helpRequested(getDescriptor(self)))), GenericTag(`@effect/cli/Command/(${fromIterable(getNames2(descriptor2)).join("|")})`));
|
|
34682
34698
|
return self;
|
|
34683
34699
|
});
|
|
34684
|
-
var makeDescriptor = (
|
|
34700
|
+
var makeDescriptor = (name2, config2) => {
|
|
34685
34701
|
const {
|
|
34686
34702
|
args: args2,
|
|
34687
34703
|
options: options3,
|
|
34688
34704
|
tree
|
|
34689
34705
|
} = parseConfig(config2);
|
|
34690
|
-
return map32(make59(
|
|
34706
|
+
return map32(make59(name2, all6(options3), all8(args2)), ({
|
|
34691
34707
|
args: args3,
|
|
34692
34708
|
options: options4
|
|
34693
34709
|
}) => reconstructConfigTree(tree, args3, options4));
|
|
34694
34710
|
};
|
|
34695
|
-
var make61 = (
|
|
34711
|
+
var make61 = (name2, config2 = {}, handler) => fromDescriptor(makeDescriptor(name2, config2), handler);
|
|
34696
34712
|
var withHandler = /* @__PURE__ */ dual(2, (self, handler) => makeDerive(self, {
|
|
34697
34713
|
handler,
|
|
34698
34714
|
transform: identity
|
|
@@ -34740,8 +34756,20 @@ var make63 = gen2(function* () {
|
|
|
34740
34756
|
const classes = /* @__PURE__ */ new Set();
|
|
34741
34757
|
const enums = /* @__PURE__ */ new Set();
|
|
34742
34758
|
const refStore = /* @__PURE__ */ new Map();
|
|
34743
|
-
|
|
34759
|
+
function cleanupSchema(schema) {
|
|
34760
|
+
if ("type" in schema && Array.isArray(schema.type) && schema.type.includes("null")) {
|
|
34761
|
+
schema.type = schema.type.filter((_) => _ !== "null")[0];
|
|
34762
|
+
schema.nullable = true;
|
|
34763
|
+
}
|
|
34764
|
+
if ("type" in schema && "oneOf" in schema && Array.isArray(schema.oneOf) && schema.oneOf.length === 0) {
|
|
34765
|
+
delete schema.oneOf;
|
|
34766
|
+
}
|
|
34767
|
+
return schema;
|
|
34768
|
+
}
|
|
34769
|
+
const addSchema = (name2, root2, context7, asStruct = false) => {
|
|
34770
|
+
cleanupSchema(root2);
|
|
34744
34771
|
function addRefs(schema, childName, asStruct2 = true) {
|
|
34772
|
+
cleanupSchema(schema);
|
|
34745
34773
|
if ("$ref" in schema) {
|
|
34746
34774
|
const resolved = resolveRef(schema, {
|
|
34747
34775
|
...root2,
|
|
@@ -34761,7 +34789,7 @@ var make63 = gen2(function* () {
|
|
|
34761
34789
|
}
|
|
34762
34790
|
} else if ("properties" in schema) {
|
|
34763
34791
|
Object.entries(schema.properties).forEach(
|
|
34764
|
-
([
|
|
34792
|
+
([name3, s]) => addRefs(s, childName ? childName + identifier2(name3) : void 0)
|
|
34765
34793
|
);
|
|
34766
34794
|
} else if ("type" in schema && schema.type === "array") {
|
|
34767
34795
|
if (Array.isArray(schema.items)) {
|
|
@@ -34805,25 +34833,28 @@ var make63 = gen2(function* () {
|
|
|
34805
34833
|
addRefs(root2, void 0, false);
|
|
34806
34834
|
return identifier2(root2.$ref.split("/").pop());
|
|
34807
34835
|
} else {
|
|
34808
|
-
addRefs(root2, "properties" in root2 ?
|
|
34809
|
-
store.set(
|
|
34836
|
+
addRefs(root2, "properties" in root2 ? name2 : void 0);
|
|
34837
|
+
store.set(name2, root2);
|
|
34810
34838
|
if (!asStruct) {
|
|
34811
|
-
classes.add(
|
|
34839
|
+
classes.add(name2);
|
|
34812
34840
|
}
|
|
34813
34841
|
}
|
|
34814
|
-
return
|
|
34842
|
+
return name2;
|
|
34815
34843
|
};
|
|
34816
|
-
const topLevelSource = (
|
|
34817
|
-
const isClass = classes.has(
|
|
34818
|
-
const isEnum = enums.has(
|
|
34819
|
-
return toSource(
|
|
34820
|
-
map2(
|
|
34821
|
-
|
|
34822
|
-
|
|
34823
|
-
|
|
34824
|
-
|
|
34825
|
-
|
|
34826
|
-
|
|
34844
|
+
const topLevelSource = (importName, name2, schema) => {
|
|
34845
|
+
const isClass = classes.has(name2);
|
|
34846
|
+
const isEnum = enums.has(name2);
|
|
34847
|
+
return toSource(importName, schema, name2, isClass || isEnum).pipe(
|
|
34848
|
+
map2(
|
|
34849
|
+
(source) => transformer.onTopLevel({
|
|
34850
|
+
importName,
|
|
34851
|
+
schema,
|
|
34852
|
+
name: name2,
|
|
34853
|
+
source,
|
|
34854
|
+
isClass,
|
|
34855
|
+
isEnum
|
|
34856
|
+
})
|
|
34857
|
+
)
|
|
34827
34858
|
);
|
|
34828
34859
|
};
|
|
34829
34860
|
const getSchema = (raw) => {
|
|
@@ -34846,7 +34877,8 @@ var make63 = gen2(function* () {
|
|
|
34846
34877
|
}
|
|
34847
34878
|
return getSchema(schema);
|
|
34848
34879
|
};
|
|
34849
|
-
const
|
|
34880
|
+
const transformer = yield* JsonSchemaTransformer;
|
|
34881
|
+
const toSource = (importName, schema, currentIdentifier, topLevel = false) => {
|
|
34850
34882
|
if ("properties" in schema) {
|
|
34851
34883
|
const obj = schema;
|
|
34852
34884
|
const required2 = obj.required ?? [];
|
|
@@ -34855,145 +34887,144 @@ var make63 = gen2(function* () {
|
|
|
34855
34887
|
filterMap2(([key, schema2]) => {
|
|
34856
34888
|
const fullSchema = getSchema(schema2);
|
|
34857
34889
|
const isOptional = !required2.includes(key);
|
|
34858
|
-
return toSource(
|
|
34890
|
+
return toSource(
|
|
34891
|
+
importName,
|
|
34892
|
+
schema2,
|
|
34893
|
+
currentIdentifier + identifier2(key)
|
|
34894
|
+
).pipe(
|
|
34859
34895
|
map2(
|
|
34860
|
-
|
|
34896
|
+
(source) => transformer.onProperty({
|
|
34897
|
+
importName,
|
|
34898
|
+
key,
|
|
34899
|
+
source,
|
|
34861
34900
|
isOptional,
|
|
34862
|
-
isNullable: "nullable" in fullSchema && fullSchema.nullable === true || "default" in fullSchema && fullSchema.default === null
|
|
34863
|
-
default: fullSchema.default
|
|
34901
|
+
isNullable: "nullable" in fullSchema && fullSchema.nullable === true || "default" in fullSchema && fullSchema.default === null
|
|
34864
34902
|
})
|
|
34865
|
-
)
|
|
34866
|
-
map2((source) => `"${key}": ${source}`)
|
|
34903
|
+
)
|
|
34867
34904
|
);
|
|
34868
34905
|
}),
|
|
34869
|
-
join(
|
|
34906
|
+
join(transformer.propertySeparator)
|
|
34870
34907
|
);
|
|
34871
34908
|
return some2(
|
|
34872
|
-
|
|
34873
|
-
${properties}
|
|
34874
|
-
}${topLevel ? "" : ")"}`
|
|
34909
|
+
transformer.onObject({ importName, properties, topLevel })
|
|
34875
34910
|
);
|
|
34876
34911
|
} else if ("type" in schema && schema.type === "null") {
|
|
34877
|
-
return some2(
|
|
34912
|
+
return some2(transformer.onNull({ importName }));
|
|
34878
34913
|
} else if ("type" in schema && schema.type === "object") {
|
|
34879
|
-
return some2(
|
|
34880
|
-
`${S}.Record({ key: ${S}.String, value: ${S}.Unknown })`
|
|
34881
|
-
);
|
|
34914
|
+
return some2(transformer.onRecord({ importName }));
|
|
34882
34915
|
} else if ("enum" in schema) {
|
|
34883
34916
|
if (!topLevel && enums.has(currentIdentifier)) {
|
|
34884
|
-
return some2(
|
|
34885
|
-
|
|
34886
|
-
|
|
34887
|
-
return some2(`${S}.Literal(${items})`);
|
|
34888
|
-
} else if ("type" in schema && schema.type) {
|
|
34889
|
-
switch (schema.type) {
|
|
34890
|
-
case "string": {
|
|
34891
|
-
const modifiers = [];
|
|
34892
|
-
if ("minLength" in schema) {
|
|
34893
|
-
modifiers.push(`${S}.minLength(${schema.minLength})`);
|
|
34894
|
-
}
|
|
34895
|
-
if ("maxLength" in schema) {
|
|
34896
|
-
modifiers.push(`${S}.maxLength(${schema.maxLength})`);
|
|
34897
|
-
}
|
|
34898
|
-
if ("pattern" in schema) {
|
|
34899
|
-
modifiers.push(
|
|
34900
|
-
`${S}.pattern(new RegExp(${JSON.stringify(schema.pattern)}))`
|
|
34901
|
-
);
|
|
34902
|
-
}
|
|
34903
|
-
return some2(`${S}.String${pipeSource(modifiers)}`);
|
|
34904
|
-
}
|
|
34905
|
-
case "integer":
|
|
34906
|
-
case "number": {
|
|
34907
|
-
const modifiers = [];
|
|
34908
|
-
const minimum = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.minimum;
|
|
34909
|
-
const exclusiveMinimum = typeof schema.exclusiveMinimum === "boolean" ? schema.exclusiveMinimum : typeof schema.exclusiveMinimum === "number";
|
|
34910
|
-
const maximum = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.maximum;
|
|
34911
|
-
const exclusiveMaximum = typeof schema.exclusiveMaximum === "boolean" ? schema.exclusiveMaximum : typeof schema.exclusiveMaximum === "number";
|
|
34912
|
-
if (minimum !== void 0) {
|
|
34913
|
-
modifiers.push(
|
|
34914
|
-
`${S}.greaterThan${exclusiveMinimum ? "" : "OrEqualTo"}(${schema.minimum})`
|
|
34915
|
-
);
|
|
34916
|
-
}
|
|
34917
|
-
if (maximum !== void 0) {
|
|
34918
|
-
modifiers.push(
|
|
34919
|
-
`${S}.lessThan${exclusiveMaximum ? "" : "OrEqualTo"}(${schema.maximum})`
|
|
34920
|
-
);
|
|
34921
|
-
}
|
|
34922
|
-
return some2(
|
|
34923
|
-
`${S}.${schema.type === "integer" ? "Int" : "Number"}${pipeSource(modifiers)}`
|
|
34924
|
-
);
|
|
34925
|
-
}
|
|
34926
|
-
case "boolean": {
|
|
34927
|
-
return some2(`${S}.Boolean`);
|
|
34928
|
-
}
|
|
34929
|
-
case "array": {
|
|
34930
|
-
const modifiers = [];
|
|
34931
|
-
const nonEmpty = typeof schema.minItems === "number" && schema.minItems === 1 && schema.maxItems === void 0;
|
|
34932
|
-
if ("minItems" in schema && !nonEmpty) {
|
|
34933
|
-
modifiers.push(`${S}.minItems(${schema.minItems})`);
|
|
34934
|
-
}
|
|
34935
|
-
if ("maxItems" in schema) {
|
|
34936
|
-
modifiers.push(`${S}.maxItems(${schema.maxItems})`);
|
|
34937
|
-
}
|
|
34938
|
-
return toSource(S, itemsSchema(schema.items), currentIdentifier).pipe(
|
|
34939
|
-
map2(
|
|
34940
|
-
(source) => `${S}.${nonEmpty ? "NonEmpty" : ""}Array(${source})${pipeSource(modifiers)}`
|
|
34941
|
-
)
|
|
34942
|
-
);
|
|
34943
|
-
}
|
|
34917
|
+
return some2(
|
|
34918
|
+
transformer.onRef({ importName, name: currentIdentifier })
|
|
34919
|
+
);
|
|
34944
34920
|
}
|
|
34921
|
+
const items = schema.enum.map((_) => JSON.stringify(_));
|
|
34922
|
+
return some2(
|
|
34923
|
+
transformer.onEnum({
|
|
34924
|
+
importName,
|
|
34925
|
+
items
|
|
34926
|
+
})
|
|
34927
|
+
);
|
|
34945
34928
|
} else if ("$ref" in schema) {
|
|
34946
34929
|
if (!schema.$ref.startsWith("#")) {
|
|
34947
34930
|
return none2();
|
|
34948
34931
|
}
|
|
34949
|
-
const
|
|
34950
|
-
return some2(name);
|
|
34932
|
+
const name2 = identifier2(schema.$ref.split("/").pop());
|
|
34933
|
+
return some2(transformer.onRef({ importName, name: name2 }));
|
|
34951
34934
|
} else if ("properties" in schema) {
|
|
34952
34935
|
return toSource(
|
|
34953
|
-
|
|
34936
|
+
importName,
|
|
34954
34937
|
{ type: "object", ...schema },
|
|
34955
34938
|
currentIdentifier,
|
|
34956
34939
|
topLevel
|
|
34957
34940
|
);
|
|
34958
34941
|
} else if ("allOf" in schema) {
|
|
34959
34942
|
if (store.has(currentIdentifier)) {
|
|
34960
|
-
return some2(
|
|
34943
|
+
return some2(
|
|
34944
|
+
transformer.onRef({ importName, name: currentIdentifier })
|
|
34945
|
+
);
|
|
34961
34946
|
}
|
|
34962
34947
|
const sources = schema.allOf;
|
|
34963
34948
|
if (sources.length === 0) {
|
|
34964
34949
|
return none2();
|
|
34965
34950
|
} else if (sources.length === 1) {
|
|
34966
|
-
return toSource(
|
|
34951
|
+
return toSource(
|
|
34952
|
+
importName,
|
|
34953
|
+
sources[0],
|
|
34954
|
+
currentIdentifier + "Enum",
|
|
34955
|
+
topLevel
|
|
34956
|
+
);
|
|
34967
34957
|
}
|
|
34968
34958
|
const flattened2 = flattenAllOf(schema);
|
|
34969
|
-
return toSource(
|
|
34959
|
+
return toSource(
|
|
34960
|
+
importName,
|
|
34961
|
+
flattened2,
|
|
34962
|
+
currentIdentifier + "Enum",
|
|
34963
|
+
topLevel
|
|
34964
|
+
);
|
|
34970
34965
|
} else if ("anyOf" in schema || "oneOf" in schema) {
|
|
34971
34966
|
const sources = pipe(
|
|
34972
34967
|
"anyOf" in schema ? schema.anyOf : schema.oneOf,
|
|
34973
|
-
filterMap2(
|
|
34968
|
+
filterMap2(
|
|
34969
|
+
(_) => toSource(importName, _, currentIdentifier + "Enum")
|
|
34970
|
+
)
|
|
34974
34971
|
);
|
|
34975
34972
|
if (sources.length === 0) return none2();
|
|
34976
34973
|
else if (sources.length === 1) return some2(sources[0]);
|
|
34977
|
-
return some2(
|
|
34974
|
+
return some2(transformer.onUnion({ importName, sources }));
|
|
34978
34975
|
} else if ("const" in schema) {
|
|
34979
|
-
return some2(
|
|
34976
|
+
return some2(
|
|
34977
|
+
transformer.onEnum({
|
|
34978
|
+
importName,
|
|
34979
|
+
items: [JSON.stringify(schema.const)]
|
|
34980
|
+
})
|
|
34981
|
+
);
|
|
34982
|
+
} else if ("type" in schema && schema.type) {
|
|
34983
|
+
switch (schema.type) {
|
|
34984
|
+
case "string": {
|
|
34985
|
+
return some2(transformer.onString({ importName, schema }));
|
|
34986
|
+
}
|
|
34987
|
+
case "integer":
|
|
34988
|
+
case "number": {
|
|
34989
|
+
const minimum = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.minimum;
|
|
34990
|
+
const exclusiveMinimum = typeof schema.exclusiveMinimum === "boolean" ? schema.exclusiveMinimum : typeof schema.exclusiveMinimum === "number";
|
|
34991
|
+
const maximum = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.maximum;
|
|
34992
|
+
const exclusiveMaximum = typeof schema.exclusiveMaximum === "boolean" ? schema.exclusiveMaximum : typeof schema.exclusiveMaximum === "number";
|
|
34993
|
+
return some2(
|
|
34994
|
+
transformer.onNumber({
|
|
34995
|
+
importName,
|
|
34996
|
+
schema,
|
|
34997
|
+
minimum,
|
|
34998
|
+
exclusiveMinimum,
|
|
34999
|
+
maximum,
|
|
35000
|
+
exclusiveMaximum
|
|
35001
|
+
})
|
|
35002
|
+
);
|
|
35003
|
+
}
|
|
35004
|
+
case "boolean": {
|
|
35005
|
+
return some2(transformer.onBoolean({ importName }));
|
|
35006
|
+
}
|
|
35007
|
+
case "array": {
|
|
35008
|
+
const nonEmpty = typeof schema.minItems === "number" && schema.minItems === 1 && schema.maxItems === void 0;
|
|
35009
|
+
return toSource(
|
|
35010
|
+
importName,
|
|
35011
|
+
itemsSchema(schema.items),
|
|
35012
|
+
currentIdentifier
|
|
35013
|
+
).pipe(
|
|
35014
|
+
map2(
|
|
35015
|
+
(item) => transformer.onArray({
|
|
35016
|
+
importName,
|
|
35017
|
+
schema,
|
|
35018
|
+
item,
|
|
35019
|
+
nonEmpty
|
|
35020
|
+
})
|
|
35021
|
+
)
|
|
35022
|
+
);
|
|
35023
|
+
}
|
|
35024
|
+
}
|
|
34980
35025
|
}
|
|
34981
35026
|
return none2();
|
|
34982
35027
|
};
|
|
34983
|
-
const applyAnnotations = (S, options3) => (source) => {
|
|
34984
|
-
if (options3.isNullable && options3.default === null) {
|
|
34985
|
-
return `${S}.optionalWith(${S}.NullOr(${source}), { default: () => null })`;
|
|
34986
|
-
}
|
|
34987
|
-
const defaultSource = options3.default !== void 0 && options3.default !== null ? `() => ${JSON.stringify(options3.default)} as const` : void 0;
|
|
34988
|
-
if (options3.isOptional) {
|
|
34989
|
-
return defaultSource ? `${S}.optionalWith(${source}, { nullable: true, default: ${defaultSource} })` : `${S}.optionalWith(${source}, { nullable: true })`;
|
|
34990
|
-
}
|
|
34991
|
-
const newSource = options3.isNullable ? `${S}.NullOr(${source})` : source;
|
|
34992
|
-
if (defaultSource) {
|
|
34993
|
-
return `${newSource}.pipe(${S}.propertySignature, ${S}.withConstructorDefault(${defaultSource}))`;
|
|
34994
|
-
}
|
|
34995
|
-
return newSource;
|
|
34996
|
-
};
|
|
34997
35028
|
const itemsSchema = (schema) => {
|
|
34998
35029
|
if (schema === void 0) {
|
|
34999
35030
|
return { $id: "/schemas/any" };
|
|
@@ -35002,22 +35033,169 @@ var make63 = gen2(function* () {
|
|
|
35002
35033
|
}
|
|
35003
35034
|
return schema;
|
|
35004
35035
|
};
|
|
35005
|
-
const pipeSource = (modifers) => modifers.length === 0 ? "" : `.pipe(${modifers.join(", ")})`;
|
|
35006
35036
|
const generate = (importName) => sync5(
|
|
35007
35037
|
() => pipe(
|
|
35008
35038
|
store.entries(),
|
|
35009
35039
|
filterMap2(
|
|
35010
|
-
([
|
|
35040
|
+
([name2, schema]) => topLevelSource(importName, name2, schema)
|
|
35011
35041
|
),
|
|
35012
35042
|
join("\n\n")
|
|
35013
35043
|
)
|
|
35014
35044
|
);
|
|
35015
35045
|
return { addSchema, generate };
|
|
35016
35046
|
});
|
|
35017
|
-
var
|
|
35047
|
+
var JsonSchemaGen = class extends Tag2("JsonSchemaGen")() {
|
|
35048
|
+
};
|
|
35049
|
+
var with_ = provideServiceEffect2(JsonSchemaGen, make63);
|
|
35050
|
+
var JsonSchemaTransformer = class extends Tag2("JsonSchemaTransformer")() {
|
|
35018
35051
|
};
|
|
35019
|
-
|
|
35020
|
-
|
|
35052
|
+
var layerTransformerSchema = sync6(JsonSchemaTransformer, () => {
|
|
35053
|
+
const applyAnnotations = (S, options3) => (source) => {
|
|
35054
|
+
if (options3.isNullable && options3.default === null) {
|
|
35055
|
+
return `${S}.optionalWith(${S}.NullOr(${source}), { default: () => null })`;
|
|
35056
|
+
}
|
|
35057
|
+
const defaultSource = options3.default !== void 0 && options3.default !== null ? `() => ${JSON.stringify(options3.default)} as const` : void 0;
|
|
35058
|
+
if (options3.isOptional) {
|
|
35059
|
+
return defaultSource ? `${S}.optionalWith(${source}, { nullable: true, default: ${defaultSource} })` : `${S}.optionalWith(${source}, { nullable: true })`;
|
|
35060
|
+
}
|
|
35061
|
+
const newSource = options3.isNullable ? `${S}.NullOr(${source})` : source;
|
|
35062
|
+
if (defaultSource) {
|
|
35063
|
+
return `${newSource}.pipe(${S}.propertySignature, ${S}.withConstructorDefault(${defaultSource}))`;
|
|
35064
|
+
}
|
|
35065
|
+
return newSource;
|
|
35066
|
+
};
|
|
35067
|
+
const pipeSource = (modifers) => modifers.length === 0 ? "" : `.pipe(${modifers.join(", ")})`;
|
|
35068
|
+
return JsonSchemaTransformer.of({
|
|
35069
|
+
onTopLevel({ importName, schema, name: name2, source, isClass }) {
|
|
35070
|
+
const isObject2 = "properties" in schema;
|
|
35071
|
+
if (!isObject2 || !isClass) {
|
|
35072
|
+
return `export class ${name2} extends ${source} {}`;
|
|
35073
|
+
}
|
|
35074
|
+
return `export class ${name2} extends ${importName}.Class<${name2}>("${name2}")(${source}) {}`;
|
|
35075
|
+
},
|
|
35076
|
+
propertySeparator: ",\n ",
|
|
35077
|
+
onProperty: (options3) => {
|
|
35078
|
+
const source = applyAnnotations(
|
|
35079
|
+
options3.importName,
|
|
35080
|
+
options3
|
|
35081
|
+
)(options3.source);
|
|
35082
|
+
return `"${options3.key}": ${source}`;
|
|
35083
|
+
},
|
|
35084
|
+
onRef({ name: name2 }) {
|
|
35085
|
+
return name2;
|
|
35086
|
+
},
|
|
35087
|
+
onObject({ importName, properties, topLevel }) {
|
|
35088
|
+
return `${topLevel ? "" : `${importName}.Struct(`}{
|
|
35089
|
+
${properties}
|
|
35090
|
+
}${topLevel ? "" : ")"}`;
|
|
35091
|
+
},
|
|
35092
|
+
onNull({ importName }) {
|
|
35093
|
+
return `${importName}.Null`;
|
|
35094
|
+
},
|
|
35095
|
+
onBoolean({ importName }) {
|
|
35096
|
+
return `${importName}.Boolean`;
|
|
35097
|
+
},
|
|
35098
|
+
onRecord({ importName }) {
|
|
35099
|
+
return `${importName}.Record({ key: ${importName}.String, value: ${importName}.Unknown })`;
|
|
35100
|
+
},
|
|
35101
|
+
onEnum({ importName, items }) {
|
|
35102
|
+
return `${importName}.Literal(${items.join(", ")})`;
|
|
35103
|
+
},
|
|
35104
|
+
onString({ importName, schema }) {
|
|
35105
|
+
const modifiers = [];
|
|
35106
|
+
if ("minLength" in schema) {
|
|
35107
|
+
modifiers.push(`${importName}.minLength(${schema.minLength})`);
|
|
35108
|
+
}
|
|
35109
|
+
if ("maxLength" in schema) {
|
|
35110
|
+
modifiers.push(`${importName}.maxLength(${schema.maxLength})`);
|
|
35111
|
+
}
|
|
35112
|
+
if ("pattern" in schema) {
|
|
35113
|
+
modifiers.push(
|
|
35114
|
+
`${importName}.pattern(new RegExp(${JSON.stringify(schema.pattern)}))`
|
|
35115
|
+
);
|
|
35116
|
+
}
|
|
35117
|
+
return `${importName}.String${pipeSource(modifiers)}`;
|
|
35118
|
+
},
|
|
35119
|
+
onNumber({
|
|
35120
|
+
importName,
|
|
35121
|
+
schema,
|
|
35122
|
+
minimum,
|
|
35123
|
+
exclusiveMinimum,
|
|
35124
|
+
maximum,
|
|
35125
|
+
exclusiveMaximum
|
|
35126
|
+
}) {
|
|
35127
|
+
const modifiers = [];
|
|
35128
|
+
if (minimum !== void 0) {
|
|
35129
|
+
modifiers.push(
|
|
35130
|
+
`${importName}.greaterThan${exclusiveMinimum ? "" : "OrEqualTo"}(${schema.minimum})`
|
|
35131
|
+
);
|
|
35132
|
+
}
|
|
35133
|
+
if (maximum !== void 0) {
|
|
35134
|
+
modifiers.push(
|
|
35135
|
+
`${importName}.lessThan${exclusiveMaximum ? "" : "OrEqualTo"}(${schema.maximum})`
|
|
35136
|
+
);
|
|
35137
|
+
}
|
|
35138
|
+
return `${importName}.${schema.type === "integer" ? "Int" : "Number"}${pipeSource(modifiers)}`;
|
|
35139
|
+
},
|
|
35140
|
+
onArray({ importName, schema, item, nonEmpty }) {
|
|
35141
|
+
const modifiers = [];
|
|
35142
|
+
if ("minItems" in schema && !nonEmpty) {
|
|
35143
|
+
modifiers.push(`${importName}.minItems(${schema.minItems})`);
|
|
35144
|
+
}
|
|
35145
|
+
if ("maxItems" in schema) {
|
|
35146
|
+
modifiers.push(`${importName}.maxItems(${schema.maxItems})`);
|
|
35147
|
+
}
|
|
35148
|
+
return `${importName}.${nonEmpty ? "NonEmpty" : ""}Array(${item})${pipeSource(modifiers)}`;
|
|
35149
|
+
},
|
|
35150
|
+
onUnion({ importName, sources }) {
|
|
35151
|
+
return `${importName}.Union(${sources.join(", ")})`;
|
|
35152
|
+
}
|
|
35153
|
+
});
|
|
35154
|
+
});
|
|
35155
|
+
var layerTransformerTs = succeed10(
|
|
35156
|
+
JsonSchemaTransformer,
|
|
35157
|
+
JsonSchemaTransformer.of({
|
|
35158
|
+
onTopLevel({ name: name2, source }) {
|
|
35159
|
+
return source[0] === "{" ? `export interface ${name2} ${source}` : `export type ${name2} = ${source}`;
|
|
35160
|
+
},
|
|
35161
|
+
propertySeparator: ";\n ",
|
|
35162
|
+
onProperty: (options3) => {
|
|
35163
|
+
return `readonly "${options3.key}"${options3.isOptional ? "?" : ""}: ${options3.source}${options3.isNullable ? " | null" : ""}`;
|
|
35164
|
+
},
|
|
35165
|
+
onRef({ name: name2 }) {
|
|
35166
|
+
return name2;
|
|
35167
|
+
},
|
|
35168
|
+
onObject({ properties }) {
|
|
35169
|
+
return `{
|
|
35170
|
+
${properties}
|
|
35171
|
+
}`;
|
|
35172
|
+
},
|
|
35173
|
+
onNull() {
|
|
35174
|
+
return "null";
|
|
35175
|
+
},
|
|
35176
|
+
onBoolean() {
|
|
35177
|
+
return "boolean";
|
|
35178
|
+
},
|
|
35179
|
+
onRecord() {
|
|
35180
|
+
return "Record<string, unknown>";
|
|
35181
|
+
},
|
|
35182
|
+
onEnum({ items }) {
|
|
35183
|
+
return items.join(" | ");
|
|
35184
|
+
},
|
|
35185
|
+
onString() {
|
|
35186
|
+
return "string";
|
|
35187
|
+
},
|
|
35188
|
+
onNumber() {
|
|
35189
|
+
return "number";
|
|
35190
|
+
},
|
|
35191
|
+
onArray({ item }) {
|
|
35192
|
+
return `ReadonlyArray<${item}>`;
|
|
35193
|
+
},
|
|
35194
|
+
onUnion({ sources }) {
|
|
35195
|
+
return sources.join(" | ");
|
|
35196
|
+
}
|
|
35197
|
+
})
|
|
35198
|
+
);
|
|
35021
35199
|
function mergeSchemas(self, other) {
|
|
35022
35200
|
if ("properties" in self && "properties" in other) {
|
|
35023
35201
|
return {
|
|
@@ -35071,13 +35249,13 @@ function resolveRef(schema, context7, recursive = false) {
|
|
|
35071
35249
|
return;
|
|
35072
35250
|
}
|
|
35073
35251
|
const path2 = schema.$ref.slice(2).split("/");
|
|
35074
|
-
const
|
|
35252
|
+
const name2 = identifier2(path2[path2.length - 1]);
|
|
35075
35253
|
let current = context7;
|
|
35076
35254
|
for (const key of path2) {
|
|
35077
35255
|
if (!current) return;
|
|
35078
35256
|
current = current[key];
|
|
35079
35257
|
}
|
|
35080
|
-
return { name, schema: resolveAllOf(current, context7, recursive) };
|
|
35258
|
+
return { name: name2, schema: resolveAllOf(current, context7, recursive) };
|
|
35081
35259
|
}
|
|
35082
35260
|
|
|
35083
35261
|
// src/OpenApi.ts
|
|
@@ -35104,198 +35282,190 @@ var make64 = gen2(function* () {
|
|
|
35104
35282
|
});
|
|
35105
35283
|
})
|
|
35106
35284
|
);
|
|
35107
|
-
const generate = fnUntraced2(
|
|
35108
|
-
|
|
35109
|
-
|
|
35110
|
-
|
|
35111
|
-
|
|
35112
|
-
|
|
35113
|
-
|
|
35114
|
-
|
|
35115
|
-
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
|
|
35119
|
-
|
|
35120
|
-
|
|
35121
|
-
const
|
|
35122
|
-
|
|
35123
|
-
|
|
35124
|
-
|
|
35125
|
-
method
|
|
35126
|
-
|
|
35127
|
-
|
|
35128
|
-
|
|
35129
|
-
|
|
35130
|
-
|
|
35131
|
-
|
|
35132
|
-
|
|
35133
|
-
|
|
35134
|
-
|
|
35135
|
-
|
|
35136
|
-
(_) => _.in !== "path" && _.in !== "cookie"
|
|
35137
|
-
) ?? [];
|
|
35138
|
-
if (validParameters.length > 0) {
|
|
35139
|
-
const schema = {
|
|
35140
|
-
type: "object",
|
|
35141
|
-
properties: {},
|
|
35142
|
-
required: []
|
|
35285
|
+
const generate = fnUntraced2(
|
|
35286
|
+
function* (spec2, options3) {
|
|
35287
|
+
const gen3 = yield* JsonSchemaGen;
|
|
35288
|
+
const components = spec2.components ? { ...spec2.components } : { schemas: {} };
|
|
35289
|
+
const context7 = { components };
|
|
35290
|
+
const operations = [];
|
|
35291
|
+
function resolveRef2(ref) {
|
|
35292
|
+
const parts2 = ref.split("/").slice(1);
|
|
35293
|
+
let current = spec2;
|
|
35294
|
+
for (const part of parts2) {
|
|
35295
|
+
current = current[part];
|
|
35296
|
+
}
|
|
35297
|
+
return current;
|
|
35298
|
+
}
|
|
35299
|
+
const handlePath = (path2, methods) => methodNames.filter(
|
|
35300
|
+
(method) => !!methods[method] && !!methods[method].operationId
|
|
35301
|
+
).forEach((method) => {
|
|
35302
|
+
const { ids: pathIds, path: pathTemplate } = processPath(path2);
|
|
35303
|
+
const operation = methods[method];
|
|
35304
|
+
const op = {
|
|
35305
|
+
id: camelize(operation.operationId),
|
|
35306
|
+
method,
|
|
35307
|
+
pathIds,
|
|
35308
|
+
pathTemplate,
|
|
35309
|
+
urlParams: [],
|
|
35310
|
+
headers: [],
|
|
35311
|
+
cookies: [],
|
|
35312
|
+
successSchemas: /* @__PURE__ */ new Map(),
|
|
35313
|
+
errorSchemas: /* @__PURE__ */ new Map()
|
|
35143
35314
|
};
|
|
35144
|
-
|
|
35145
|
-
|
|
35146
|
-
|
|
35147
|
-
|
|
35148
|
-
|
|
35149
|
-
|
|
35150
|
-
|
|
35151
|
-
|
|
35152
|
-
|
|
35153
|
-
|
|
35154
|
-
|
|
35155
|
-
|
|
35156
|
-
(
|
|
35157
|
-
|
|
35158
|
-
|
|
35159
|
-
|
|
35160
|
-
|
|
35315
|
+
const schemaId = identifier2(operation.operationId);
|
|
35316
|
+
const validParameters = operation.parameters?.filter(
|
|
35317
|
+
(_) => _.in !== "path" && _.in !== "cookie"
|
|
35318
|
+
) ?? [];
|
|
35319
|
+
if (validParameters.length > 0) {
|
|
35320
|
+
const schema = {
|
|
35321
|
+
type: "object",
|
|
35322
|
+
properties: {},
|
|
35323
|
+
required: []
|
|
35324
|
+
};
|
|
35325
|
+
validParameters.forEach((parameter) => {
|
|
35326
|
+
if ("$ref" in parameter) {
|
|
35327
|
+
parameter = resolveRef2(parameter.$ref);
|
|
35328
|
+
}
|
|
35329
|
+
if (parameter.in === "path") {
|
|
35330
|
+
return;
|
|
35331
|
+
}
|
|
35332
|
+
const paramSchema = parameter.schema;
|
|
35333
|
+
const added = [];
|
|
35334
|
+
if ("properties" in paramSchema) {
|
|
35335
|
+
const required2 = paramSchema.required ?? [];
|
|
35336
|
+
Object.entries(paramSchema.properties).forEach(
|
|
35337
|
+
([name2, propSchema]) => {
|
|
35338
|
+
const adjustedName = `${parameter.name}[${name2}]`;
|
|
35339
|
+
schema.properties[adjustedName] = propSchema;
|
|
35340
|
+
if (required2.includes(name2)) {
|
|
35341
|
+
schema.required.push(adjustedName);
|
|
35342
|
+
}
|
|
35343
|
+
added.push(adjustedName);
|
|
35161
35344
|
}
|
|
35162
|
-
|
|
35163
|
-
}
|
|
35164
|
-
);
|
|
35165
|
-
} else {
|
|
35166
|
-
schema.properties[parameter.name] = parameter.schema;
|
|
35167
|
-
parameter.required && schema.required.push(parameter.name);
|
|
35168
|
-
added.push(parameter.name);
|
|
35169
|
-
}
|
|
35170
|
-
if (parameter.in === "query") {
|
|
35171
|
-
op.urlParams.push(...added);
|
|
35172
|
-
} else if (parameter.in === "header") {
|
|
35173
|
-
op.headers.push(...added);
|
|
35174
|
-
} else if (parameter.in === "cookie") {
|
|
35175
|
-
op.cookies.push(...added);
|
|
35176
|
-
}
|
|
35177
|
-
});
|
|
35178
|
-
op.params = gen3.addSchema(
|
|
35179
|
-
`${schemaId}Params`,
|
|
35180
|
-
schema,
|
|
35181
|
-
context7,
|
|
35182
|
-
true
|
|
35183
|
-
);
|
|
35184
|
-
}
|
|
35185
|
-
if (operation.requestBody?.content?.["application/json"]?.schema) {
|
|
35186
|
-
op.payload = gen3.addSchema(
|
|
35187
|
-
`${schemaId}Request`,
|
|
35188
|
-
operation.requestBody.content["application/json"].schema,
|
|
35189
|
-
context7
|
|
35190
|
-
);
|
|
35191
|
-
} else if (operation.requestBody?.content?.["multipart/form-data"]) {
|
|
35192
|
-
op.payload = "FormData";
|
|
35193
|
-
}
|
|
35194
|
-
Object.entries(operation.responses ?? {}).forEach(
|
|
35195
|
-
([status2, response]) => {
|
|
35196
|
-
if (response.content?.["application/json"]?.schema) {
|
|
35197
|
-
const schemaName = gen3.addSchema(
|
|
35198
|
-
`${schemaId}${status2}`,
|
|
35199
|
-
response.content["application/json"].schema,
|
|
35200
|
-
context7,
|
|
35201
|
-
true
|
|
35202
|
-
);
|
|
35203
|
-
const statusLower = status2.toLowerCase();
|
|
35204
|
-
const statusMajorNumber = Number(status2[0]);
|
|
35205
|
-
if (statusMajorNumber < 4) {
|
|
35206
|
-
op.successSchemas.set(statusLower, schemaName);
|
|
35345
|
+
);
|
|
35207
35346
|
} else {
|
|
35208
|
-
|
|
35347
|
+
schema.properties[parameter.name] = parameter.schema;
|
|
35348
|
+
parameter.required && schema.required.push(parameter.name);
|
|
35349
|
+
added.push(parameter.name);
|
|
35209
35350
|
}
|
|
35210
|
-
|
|
35351
|
+
if (parameter.in === "query") {
|
|
35352
|
+
op.urlParams.push(...added);
|
|
35353
|
+
} else if (parameter.in === "header") {
|
|
35354
|
+
op.headers.push(...added);
|
|
35355
|
+
} else if (parameter.in === "cookie") {
|
|
35356
|
+
op.cookies.push(...added);
|
|
35357
|
+
}
|
|
35358
|
+
});
|
|
35359
|
+
op.params = gen3.addSchema(
|
|
35360
|
+
`${schemaId}Params`,
|
|
35361
|
+
schema,
|
|
35362
|
+
context7,
|
|
35363
|
+
true
|
|
35364
|
+
);
|
|
35211
35365
|
}
|
|
35366
|
+
if (operation.requestBody?.content?.["application/json"]?.schema) {
|
|
35367
|
+
op.payload = gen3.addSchema(
|
|
35368
|
+
`${schemaId}Request`,
|
|
35369
|
+
operation.requestBody.content["application/json"].schema,
|
|
35370
|
+
context7
|
|
35371
|
+
);
|
|
35372
|
+
} else if (operation.requestBody?.content?.["multipart/form-data"]) {
|
|
35373
|
+
op.payload = "FormData";
|
|
35374
|
+
}
|
|
35375
|
+
Object.entries(operation.responses ?? {}).forEach(
|
|
35376
|
+
([status2, response]) => {
|
|
35377
|
+
if (response.content?.["application/json"]?.schema) {
|
|
35378
|
+
const schemaName = gen3.addSchema(
|
|
35379
|
+
`${schemaId}${status2}`,
|
|
35380
|
+
response.content["application/json"].schema,
|
|
35381
|
+
context7,
|
|
35382
|
+
true
|
|
35383
|
+
);
|
|
35384
|
+
const statusLower = status2.toLowerCase();
|
|
35385
|
+
const statusMajorNumber = Number(status2[0]);
|
|
35386
|
+
if (statusMajorNumber < 4) {
|
|
35387
|
+
op.successSchemas.set(statusLower, schemaName);
|
|
35388
|
+
} else {
|
|
35389
|
+
op.errorSchemas.set(statusLower, schemaName);
|
|
35390
|
+
}
|
|
35391
|
+
}
|
|
35392
|
+
}
|
|
35393
|
+
);
|
|
35394
|
+
operations.push(op);
|
|
35395
|
+
});
|
|
35396
|
+
Object.entries(spec2.paths).forEach(
|
|
35397
|
+
([path2, methods]) => handlePath(path2, methods)
|
|
35212
35398
|
);
|
|
35213
|
-
|
|
35214
|
-
|
|
35215
|
-
|
|
35216
|
-
([path2, methods]) => handlePath(path2, methods)
|
|
35217
|
-
);
|
|
35218
|
-
const imports = [
|
|
35219
|
-
'import type * as HttpClient from "@effect/platform/HttpClient"',
|
|
35220
|
-
'import * as HttpClientError from "@effect/platform/HttpClientError"',
|
|
35221
|
-
'import * as HttpClientRequest from "@effect/platform/HttpClientRequest"',
|
|
35222
|
-
'import * as HttpClientResponse from "@effect/platform/HttpClientResponse"',
|
|
35223
|
-
'import * as UrlParams from "@effect/platform/UrlParams"',
|
|
35224
|
-
'import * as Effect from "effect/Effect"',
|
|
35225
|
-
'import type { ParseError } from "effect/ParseResult"',
|
|
35226
|
-
'import * as S from "effect/Schema"'
|
|
35227
|
-
].join("\n");
|
|
35228
|
-
const schemas = yield* gen3.generate("S");
|
|
35229
|
-
const clientInterface = operationsToInterface("Client", operations);
|
|
35230
|
-
const clientImpl = operationsToImpl("Client", operations);
|
|
35231
|
-
return `${imports}
|
|
35399
|
+
const transformer = yield* OpenApiTransformer;
|
|
35400
|
+
const schemas = yield* gen3.generate("S");
|
|
35401
|
+
return `${transformer.imports}
|
|
35232
35402
|
|
|
35233
35403
|
${schemas}
|
|
35234
35404
|
|
|
35235
|
-
${
|
|
35405
|
+
${transformer.toImplementation(options3.name, operations)}
|
|
35236
35406
|
|
|
35237
|
-
${
|
|
35238
|
-
|
|
35407
|
+
${transformer.toTypes(options3.name, operations)}`;
|
|
35408
|
+
},
|
|
35409
|
+
with_,
|
|
35410
|
+
(effect3, _, options3) => provide2(
|
|
35411
|
+
effect3,
|
|
35412
|
+
options3?.typeOnly ? layerTransformerTs2 : layerTransformerSchema2
|
|
35413
|
+
)
|
|
35414
|
+
);
|
|
35239
35415
|
return { convert: convert3, generate };
|
|
35240
35416
|
});
|
|
35241
35417
|
var _OpenApi = class _OpenApi extends Tag3("OpenApi")() {
|
|
35242
35418
|
};
|
|
35243
35419
|
_OpenApi.Live = effect(_OpenApi, make64);
|
|
35244
35420
|
var OpenApi = _OpenApi;
|
|
35245
|
-
var
|
|
35246
|
-
const ids3 = [];
|
|
35247
|
-
path2 = path2.replace(/{([^}]+)}/g, (_, name) => {
|
|
35248
|
-
const id2 = camelize(name);
|
|
35249
|
-
ids3.push(id2);
|
|
35250
|
-
return "${" + id2 + "}";
|
|
35251
|
-
});
|
|
35252
|
-
return { path: "`" + path2 + "`", ids: ids3 };
|
|
35421
|
+
var OpenApiTransformer = class extends Tag2("OpenApiTransformer")() {
|
|
35253
35422
|
};
|
|
35254
|
-
var
|
|
35423
|
+
var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
|
|
35424
|
+
const operationsToInterface = (name2, operations) => `export interface ${name2} {
|
|
35255
35425
|
${operations.map(operationToMethod).join("\n ")}
|
|
35256
35426
|
}`;
|
|
35257
|
-
|
|
35258
|
-
|
|
35259
|
-
|
|
35260
|
-
|
|
35261
|
-
|
|
35262
|
-
|
|
35263
|
-
|
|
35264
|
-
|
|
35265
|
-
|
|
35266
|
-
|
|
35267
|
-
|
|
35268
|
-
|
|
35269
|
-
|
|
35270
|
-
|
|
35271
|
-
|
|
35272
|
-
|
|
35273
|
-
|
|
35427
|
+
const operationToMethod = (operation) => {
|
|
35428
|
+
const args2 = [];
|
|
35429
|
+
if (operation.pathIds.length > 0) {
|
|
35430
|
+
args2.push(...operation.pathIds.map((id2) => `${id2}: string`));
|
|
35431
|
+
}
|
|
35432
|
+
let options3 = [];
|
|
35433
|
+
if (operation.params && !operation.payload) {
|
|
35434
|
+
args2.push(`options: typeof ${operation.params}.Encoded`);
|
|
35435
|
+
} else if (operation.params) {
|
|
35436
|
+
options3.push(`readonly params: typeof ${operation.params}.Encoded`);
|
|
35437
|
+
}
|
|
35438
|
+
if (operation.payload) {
|
|
35439
|
+
const type2 = operation.payload === "FormData" ? "globalThis.FormData" : `typeof ${operation.payload}.Encoded`;
|
|
35440
|
+
if (!operation.params) {
|
|
35441
|
+
args2.push(`options: ${type2}`);
|
|
35442
|
+
} else {
|
|
35443
|
+
options3.push(`readonly payload: ${type2}`);
|
|
35444
|
+
}
|
|
35274
35445
|
}
|
|
35275
|
-
|
|
35276
|
-
|
|
35277
|
-
|
|
35278
|
-
|
|
35279
|
-
|
|
35280
|
-
|
|
35281
|
-
|
|
35282
|
-
|
|
35283
|
-
|
|
35284
|
-
|
|
35285
|
-
|
|
35286
|
-
|
|
35287
|
-
|
|
35288
|
-
)
|
|
35289
|
-
|
|
35290
|
-
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
var operationsToImpl = (name, operations) => `export const make = (
|
|
35446
|
+
if (options3.length > 0) {
|
|
35447
|
+
args2.push(`options: { ${options3.join("; ")} }`);
|
|
35448
|
+
}
|
|
35449
|
+
let success = "void";
|
|
35450
|
+
if (operation.successSchemas.size > 0) {
|
|
35451
|
+
success = Array.from(operation.successSchemas.values()).map((schema) => `typeof ${schema}.Type`).join(" | ");
|
|
35452
|
+
}
|
|
35453
|
+
const errors = ["HttpClientError.HttpClientError", "ParseError"];
|
|
35454
|
+
if (operation.errorSchemas.size > 0) {
|
|
35455
|
+
errors.push(
|
|
35456
|
+
...Array.from(operation.errorSchemas.values()).map(
|
|
35457
|
+
(schema) => `typeof ${schema}.Type`
|
|
35458
|
+
)
|
|
35459
|
+
);
|
|
35460
|
+
}
|
|
35461
|
+
return `readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
|
|
35462
|
+
};
|
|
35463
|
+
const operationsToImpl = (name2, operations) => `export const make = (
|
|
35294
35464
|
httpClient: HttpClient.HttpClient,
|
|
35295
35465
|
options: {
|
|
35296
35466
|
readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect<HttpClient.HttpClient>) | undefined
|
|
35297
35467
|
} = {}
|
|
35298
|
-
): ${
|
|
35468
|
+
): ${name2} => {
|
|
35299
35469
|
const unexpectedStatus = (request: HttpClientRequest.HttpClientRequest, response: HttpClientResponse.HttpClientResponse) =>
|
|
35300
35470
|
Effect.flatMap(
|
|
35301
35471
|
Effect.orElseSucceed(response.text, () => "Unexpected status code"),
|
|
@@ -35314,58 +35484,263 @@ var operationsToImpl = (name, operations) => `export const make = (
|
|
|
35314
35484
|
${operations.map(operationToImpl).join(",\n ")}
|
|
35315
35485
|
}
|
|
35316
35486
|
}`;
|
|
35317
|
-
|
|
35318
|
-
|
|
35319
|
-
|
|
35320
|
-
|
|
35321
|
-
|
|
35322
|
-
|
|
35323
|
-
|
|
35324
|
-
|
|
35325
|
-
|
|
35326
|
-
|
|
35327
|
-
|
|
35328
|
-
|
|
35329
|
-
|
|
35487
|
+
const operationToImpl = (operation) => {
|
|
35488
|
+
const args2 = [...operation.pathIds];
|
|
35489
|
+
const hasOptions = operation.params || operation.payload;
|
|
35490
|
+
if (hasOptions) {
|
|
35491
|
+
args2.push("options");
|
|
35492
|
+
}
|
|
35493
|
+
const params = `${args2.join(", ")}`;
|
|
35494
|
+
const pipeline = [];
|
|
35495
|
+
if (operation.params) {
|
|
35496
|
+
const varName = operation.payload ? "options.params" : "options";
|
|
35497
|
+
if (operation.urlParams.length > 0) {
|
|
35498
|
+
const props = operation.urlParams.map(
|
|
35499
|
+
(param) => `"${param}": ${varName}["${param}"] as UrlParams.Coercible`
|
|
35500
|
+
);
|
|
35501
|
+
pipeline.push(`HttpClientRequest.setUrlParams({ ${props.join(", ")} })`);
|
|
35502
|
+
}
|
|
35503
|
+
if (operation.headers.length > 0) {
|
|
35504
|
+
const props = operation.headers.map(
|
|
35505
|
+
(param) => `"${param}": ${varName}["${param}"] ?? undefined`
|
|
35506
|
+
);
|
|
35507
|
+
pipeline.push(`HttpClientRequest.setHeaders({ ${props.join(", ")} })`);
|
|
35508
|
+
}
|
|
35509
|
+
}
|
|
35510
|
+
const payloadVarName = operation.params ? "options.payload" : "options";
|
|
35511
|
+
if (operation.payload === "FormData") {
|
|
35512
|
+
pipeline.push(
|
|
35513
|
+
`HttpClientRequest.bodyFormData(${payloadVarName})`,
|
|
35514
|
+
"Effect.succeed"
|
|
35515
|
+
);
|
|
35516
|
+
} else if (operation.payload) {
|
|
35517
|
+
pipeline.push(
|
|
35518
|
+
`(req) => Effect.orDie(HttpClientRequest.bodyJson(req, ${payloadVarName}))`
|
|
35330
35519
|
);
|
|
35331
|
-
|
|
35520
|
+
} else {
|
|
35521
|
+
pipeline.push("Effect.succeed");
|
|
35332
35522
|
}
|
|
35333
|
-
|
|
35334
|
-
|
|
35335
|
-
|
|
35523
|
+
const decodes = [];
|
|
35524
|
+
operation.successSchemas.forEach((schema, status2) => {
|
|
35525
|
+
decodes.push(
|
|
35526
|
+
`"${status2}": r => HttpClientResponse.schemaBodyJson(${schema})(r)`
|
|
35336
35527
|
);
|
|
35337
|
-
|
|
35528
|
+
});
|
|
35529
|
+
operation.errorSchemas.forEach((schema, status2) => {
|
|
35530
|
+
decodes.push(`"${status2}": r => decodeError(r, ${schema})`);
|
|
35531
|
+
});
|
|
35532
|
+
decodes.push(`orElse: (response) => unexpectedStatus(request, response)`);
|
|
35533
|
+
pipeline.push(`Effect.flatMap(request => Effect.flatMap(applyClientTransform(httpClient), (httpClient) => Effect.flatMap(httpClient.execute(request), HttpClientResponse.matchStatus({
|
|
35534
|
+
${decodes.join(",\n ")}
|
|
35535
|
+
}))))`);
|
|
35536
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
|
|
35537
|
+
${pipeline.join(",\n ")}
|
|
35538
|
+
)`;
|
|
35539
|
+
};
|
|
35540
|
+
return OpenApiTransformer.of({
|
|
35541
|
+
imports: [
|
|
35542
|
+
'import type * as HttpClient from "@effect/platform/HttpClient"',
|
|
35543
|
+
'import * as HttpClientError from "@effect/platform/HttpClientError"',
|
|
35544
|
+
'import * as HttpClientRequest from "@effect/platform/HttpClientRequest"',
|
|
35545
|
+
'import * as HttpClientResponse from "@effect/platform/HttpClientResponse"',
|
|
35546
|
+
'import * as UrlParams from "@effect/platform/UrlParams"',
|
|
35547
|
+
'import * as Effect from "effect/Effect"',
|
|
35548
|
+
'import type { ParseError } from "effect/ParseResult"',
|
|
35549
|
+
'import * as S from "effect/Schema"'
|
|
35550
|
+
].join("\n"),
|
|
35551
|
+
toTypes: operationsToInterface,
|
|
35552
|
+
toImplementation: operationsToImpl
|
|
35553
|
+
});
|
|
35554
|
+
}).pipe(merge7(layerTransformerSchema));
|
|
35555
|
+
var layerTransformerTs2 = sync6(OpenApiTransformer, () => {
|
|
35556
|
+
const operationsToInterface = (name2, operations) => `export interface ${name2} {
|
|
35557
|
+
${operations.map((s) => operationToMethod(name2, s)).join("\n ")}
|
|
35558
|
+
}
|
|
35559
|
+
|
|
35560
|
+
export interface ${name2}Error<Tag extends string, E> {
|
|
35561
|
+
readonly _tag: Tag
|
|
35562
|
+
readonly cause: E
|
|
35563
|
+
}
|
|
35564
|
+
|
|
35565
|
+
class ${name2}ErrorImpl extends Data.Error<{ _tag: string; cause: any }> {}
|
|
35566
|
+
|
|
35567
|
+
export const ${name2}Error = <Tag extends string, E>(
|
|
35568
|
+
tag: Tag,
|
|
35569
|
+
cause: E,
|
|
35570
|
+
): ${name2}Error<Tag, E> => new ${name2}ErrorImpl({ _tag: tag, cause }) as any`;
|
|
35571
|
+
const operationToMethod = (name2, operation) => {
|
|
35572
|
+
const args2 = [];
|
|
35573
|
+
if (operation.pathIds.length > 0) {
|
|
35574
|
+
args2.push(...operation.pathIds.map((id2) => `${id2}: string`));
|
|
35575
|
+
}
|
|
35576
|
+
let options3 = [];
|
|
35577
|
+
if (operation.params && !operation.payload) {
|
|
35578
|
+
args2.push(`options: ${operation.params}`);
|
|
35579
|
+
} else if (operation.params) {
|
|
35580
|
+
options3.push(`readonly params: ${operation.params}`);
|
|
35581
|
+
}
|
|
35582
|
+
if (operation.payload) {
|
|
35583
|
+
const type2 = operation.payload === "FormData" ? "globalThis.FormData" : operation.payload;
|
|
35584
|
+
if (!operation.params) {
|
|
35585
|
+
args2.push(`options: ${type2}`);
|
|
35586
|
+
} else {
|
|
35587
|
+
options3.push(`readonly payload: ${type2}`);
|
|
35588
|
+
}
|
|
35338
35589
|
}
|
|
35590
|
+
if (options3.length > 0) {
|
|
35591
|
+
args2.push(`options: { ${options3.join("; ")} }`);
|
|
35592
|
+
}
|
|
35593
|
+
let success = "void";
|
|
35594
|
+
if (operation.successSchemas.size > 0) {
|
|
35595
|
+
success = Array.from(operation.successSchemas.values()).join(" | ");
|
|
35596
|
+
}
|
|
35597
|
+
const errors = ["HttpClientError.HttpClientError"];
|
|
35598
|
+
if (operation.errorSchemas.size > 0) {
|
|
35599
|
+
for (const schema of operation.errorSchemas.values()) {
|
|
35600
|
+
errors.push(`${name2}Error<"${schema}", ${schema}>`);
|
|
35601
|
+
}
|
|
35602
|
+
}
|
|
35603
|
+
return `readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
|
|
35604
|
+
};
|
|
35605
|
+
const operationsToImpl = (name2, operations) => `export const make = (
|
|
35606
|
+
httpClient: HttpClient.HttpClient,
|
|
35607
|
+
options: {
|
|
35608
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect<HttpClient.HttpClient>) | undefined
|
|
35609
|
+
} = {}
|
|
35610
|
+
): ${name2} => {
|
|
35611
|
+
const unexpectedStatus = (response: HttpClientResponse.HttpClientResponse) =>
|
|
35612
|
+
Effect.flatMap(
|
|
35613
|
+
Effect.orElseSucceed(response.text, () => "Unexpected status code"),
|
|
35614
|
+
(description) =>
|
|
35615
|
+
Effect.fail(
|
|
35616
|
+
new HttpClientError.ResponseError({
|
|
35617
|
+
request: response.request,
|
|
35618
|
+
response,
|
|
35619
|
+
reason: "StatusCode",
|
|
35620
|
+
description,
|
|
35621
|
+
}),
|
|
35622
|
+
),
|
|
35623
|
+
)
|
|
35624
|
+
const applyClientTransform = (
|
|
35625
|
+
client: HttpClient.HttpClient,
|
|
35626
|
+
): Effect.Effect<HttpClient.HttpClient> =>
|
|
35627
|
+
options.transformClient
|
|
35628
|
+
? options.transformClient(client)
|
|
35629
|
+
: Effect.succeed(client)
|
|
35630
|
+
const decodeSuccess = <A>(response: HttpClientResponse.HttpClientResponse) =>
|
|
35631
|
+
response.json as Effect.Effect<A, HttpClientError.ResponseError>
|
|
35632
|
+
const decodeVoid = (_response: HttpClientResponse.HttpClientResponse) =>
|
|
35633
|
+
Effect.void
|
|
35634
|
+
const decodeError =
|
|
35635
|
+
<Tag extends string, E>(tag: Tag) =>
|
|
35636
|
+
(
|
|
35637
|
+
response: HttpClientResponse.HttpClientResponse,
|
|
35638
|
+
): Effect.Effect<
|
|
35639
|
+
never,
|
|
35640
|
+
${name2}Error<Tag, E> | HttpClientError.ResponseError
|
|
35641
|
+
> =>
|
|
35642
|
+
Effect.flatMap(
|
|
35643
|
+
response.json as Effect.Effect<E, HttpClientError.ResponseError>,
|
|
35644
|
+
(cause) => Effect.fail(${name2}Error(tag, cause)),
|
|
35645
|
+
)
|
|
35646
|
+
const onRequest = (
|
|
35647
|
+
successCodes: ReadonlyArray<string>,
|
|
35648
|
+
errorCodes: Record<string, string>,
|
|
35649
|
+
) => {
|
|
35650
|
+
const cases: any = { orElse: unexpectedStatus }
|
|
35651
|
+
for (const code of successCodes) {
|
|
35652
|
+
cases[code] = decodeSuccess
|
|
35653
|
+
}
|
|
35654
|
+
for (const [code, tag] of Object.entries(errorCodes)) {
|
|
35655
|
+
cases[code] = decodeError(tag)
|
|
35656
|
+
}
|
|
35657
|
+
if (successCodes.length === 0) {
|
|
35658
|
+
cases["2xx"] = decodeVoid
|
|
35659
|
+
}
|
|
35660
|
+
return (
|
|
35661
|
+
request: HttpClientRequest.HttpClientRequest,
|
|
35662
|
+
): Effect.Effect<any, any> =>
|
|
35663
|
+
Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
|
|
35664
|
+
Effect.flatMap(
|
|
35665
|
+
httpClient.execute(request),
|
|
35666
|
+
HttpClientResponse.matchStatus(cases) as any,
|
|
35667
|
+
),
|
|
35668
|
+
)
|
|
35339
35669
|
}
|
|
35340
|
-
|
|
35341
|
-
|
|
35342
|
-
pipeline.push(
|
|
35343
|
-
`HttpClientRequest.bodyFormData(${payloadVarName})`,
|
|
35344
|
-
"Effect.succeed"
|
|
35345
|
-
);
|
|
35346
|
-
} else if (operation.payload) {
|
|
35347
|
-
pipeline.push(
|
|
35348
|
-
`(req) => Effect.orDie(HttpClientRequest.bodyJson(req, ${payloadVarName}))`
|
|
35349
|
-
);
|
|
35350
|
-
} else {
|
|
35351
|
-
pipeline.push("Effect.succeed");
|
|
35670
|
+
return {
|
|
35671
|
+
${operations.map(operationToImpl).join(",\n ")}
|
|
35352
35672
|
}
|
|
35353
|
-
|
|
35354
|
-
operation
|
|
35355
|
-
|
|
35356
|
-
|
|
35673
|
+
}`;
|
|
35674
|
+
const operationToImpl = (operation) => {
|
|
35675
|
+
const args2 = [...operation.pathIds];
|
|
35676
|
+
const hasOptions = operation.params || operation.payload;
|
|
35677
|
+
if (hasOptions) {
|
|
35678
|
+
args2.push("options");
|
|
35679
|
+
}
|
|
35680
|
+
const params = `${args2.join(", ")}`;
|
|
35681
|
+
const pipeline = [];
|
|
35682
|
+
if (operation.params) {
|
|
35683
|
+
const varName = operation.payload ? "options.params" : "options";
|
|
35684
|
+
if (operation.urlParams.length > 0) {
|
|
35685
|
+
const props = operation.urlParams.map(
|
|
35686
|
+
(param) => `"${param}": ${varName}["${param}"] as UrlParams.Coercible`
|
|
35687
|
+
);
|
|
35688
|
+
pipeline.push(`HttpClientRequest.setUrlParams({ ${props.join(", ")} })`);
|
|
35689
|
+
}
|
|
35690
|
+
if (operation.headers.length > 0) {
|
|
35691
|
+
const props = operation.headers.map(
|
|
35692
|
+
(param) => `"${param}": ${varName}["${param}"] ?? undefined`
|
|
35693
|
+
);
|
|
35694
|
+
pipeline.push(`HttpClientRequest.setHeaders({ ${props.join(", ")} })`);
|
|
35695
|
+
}
|
|
35696
|
+
}
|
|
35697
|
+
const payloadVarName = operation.params ? "options.payload" : "options";
|
|
35698
|
+
if (operation.payload === "FormData") {
|
|
35699
|
+
pipeline.push(
|
|
35700
|
+
`HttpClientRequest.bodyFormData(${payloadVarName})`,
|
|
35701
|
+
"Effect.succeed"
|
|
35702
|
+
);
|
|
35703
|
+
} else if (operation.payload) {
|
|
35704
|
+
pipeline.push(
|
|
35705
|
+
`(req) => Effect.orDie(HttpClientRequest.bodyJson(req, ${payloadVarName}))`
|
|
35706
|
+
);
|
|
35707
|
+
} else {
|
|
35708
|
+
pipeline.push("Effect.succeed");
|
|
35709
|
+
}
|
|
35710
|
+
const successCodes = Array.from(
|
|
35711
|
+
operation.successSchemas.keys(),
|
|
35712
|
+
(_) => JSON.stringify(_)
|
|
35713
|
+
).join(", ");
|
|
35714
|
+
const errorCodes = Object.fromEntries(operation.errorSchemas.entries());
|
|
35715
|
+
pipeline.push(
|
|
35716
|
+
`Effect.flatMap(onRequest([${successCodes}], ${JSON.stringify(errorCodes)}))`
|
|
35357
35717
|
);
|
|
35358
|
-
|
|
35359
|
-
operation.errorSchemas.forEach((schema, status2) => {
|
|
35360
|
-
decodes.push(`"${status2}": r => decodeError(r, ${schema})`);
|
|
35361
|
-
});
|
|
35362
|
-
decodes.push(`orElse: (response) => unexpectedStatus(request, response)`);
|
|
35363
|
-
pipeline.push(`Effect.flatMap(request => Effect.flatMap(applyClientTransform(httpClient), (httpClient) => Effect.flatMap(httpClient.execute(request), HttpClientResponse.matchStatus({
|
|
35364
|
-
${decodes.join(",\n ")}
|
|
35365
|
-
}))))`);
|
|
35366
|
-
return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
|
|
35718
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
|
|
35367
35719
|
${pipeline.join(",\n ")}
|
|
35368
35720
|
)`;
|
|
35721
|
+
};
|
|
35722
|
+
return OpenApiTransformer.of({
|
|
35723
|
+
imports: [
|
|
35724
|
+
'import type * as HttpClient from "@effect/platform/HttpClient"',
|
|
35725
|
+
'import * as HttpClientError from "@effect/platform/HttpClientError"',
|
|
35726
|
+
'import * as HttpClientRequest from "@effect/platform/HttpClientRequest"',
|
|
35727
|
+
'import * as HttpClientResponse from "@effect/platform/HttpClientResponse"',
|
|
35728
|
+
'import * as UrlParams from "@effect/platform/UrlParams"',
|
|
35729
|
+
'import * as Data from "effect/Data"',
|
|
35730
|
+
'import * as Effect from "effect/Effect"'
|
|
35731
|
+
].join("\n"),
|
|
35732
|
+
toTypes: operationsToInterface,
|
|
35733
|
+
toImplementation: operationsToImpl
|
|
35734
|
+
});
|
|
35735
|
+
}).pipe(merge7(layerTransformerTs));
|
|
35736
|
+
var processPath = (path2) => {
|
|
35737
|
+
const ids3 = [];
|
|
35738
|
+
path2 = path2.replace(/{([^}]+)}/g, (_, name2) => {
|
|
35739
|
+
const id2 = camelize(name2);
|
|
35740
|
+
ids3.push(id2);
|
|
35741
|
+
return "${" + id2 + "}";
|
|
35742
|
+
});
|
|
35743
|
+
return { path: "`" + path2 + "`", ids: ids3 };
|
|
35369
35744
|
};
|
|
35370
35745
|
|
|
35371
35746
|
// src/main.ts
|
|
@@ -35373,17 +35748,26 @@ var spec = fileParse2("spec").pipe(
|
|
|
35373
35748
|
withAlias2("s"),
|
|
35374
35749
|
withDescription3("The OpenAPI spec file to generate the client from")
|
|
35375
35750
|
);
|
|
35751
|
+
var name = text8("name").pipe(
|
|
35752
|
+
withAlias2("n"),
|
|
35753
|
+
withDescription3("The name of the generated client"),
|
|
35754
|
+
withDefault3("Client")
|
|
35755
|
+
);
|
|
35376
35756
|
var convert2 = boolean5("convert").pipe(
|
|
35377
35757
|
withAlias2("c"),
|
|
35378
35758
|
withDescription3("Convert from OpenAPI 2 to OpenAPI 3 first")
|
|
35379
35759
|
);
|
|
35380
|
-
var
|
|
35760
|
+
var typeOnly = boolean5("type-only").pipe(
|
|
35761
|
+
withAlias2("t"),
|
|
35762
|
+
withDescription3("Generate a type-only client without schemas")
|
|
35763
|
+
);
|
|
35764
|
+
var root = make62("openapigen", { spec, convert: convert2, typeOnly, name }).pipe(
|
|
35381
35765
|
withHandler2(
|
|
35382
|
-
fnUntraced2(function* ({ spec: spec2, convert: convert3 }) {
|
|
35766
|
+
fnUntraced2(function* ({ spec: spec2, convert: convert3, typeOnly: typeOnly2, name: name2 }) {
|
|
35383
35767
|
if (convert3) {
|
|
35384
35768
|
spec2 = yield* OpenApi.convert(spec2);
|
|
35385
35769
|
}
|
|
35386
|
-
return yield* OpenApi.generate(spec2).pipe(
|
|
35770
|
+
return yield* OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
|
|
35387
35771
|
flatMap9(log2)
|
|
35388
35772
|
);
|
|
35389
35773
|
})
|