@keq-request/cli 5.0.0-alpha.12 → 5.0.0-alpha.14
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/CHANGELOG.md +17 -0
- package/dist/cli.cjs +94 -52
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +94 -52
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +94 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -50
- package/dist/index.js.map +1 -1
- package/dist/plugins/body-fallback/index.d.ts.map +1 -1
- package/dist/plugins/eslint/index.d.ts.map +1 -1
- package/dist/plugins/prettier/index.d.ts.map +1 -1
- package/dist/plugins.cjs +13 -21
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +13 -21
- package/dist/plugins.js.map +1 -1
- package/dist/renderer/operation-request/error-to-comment.d.ts +2 -0
- package/dist/renderer/operation-request/error-to-comment.d.ts.map +1 -0
- package/dist/renderer/operation-request/index.d.ts.map +1 -1
- package/dist/renderer/operation-request/request-body.d.ts +4 -0
- package/dist/renderer/operation-request/request-body.d.ts.map +1 -0
- package/dist/renderer/request/index.d.ts.map +1 -1
- package/dist/renderer/utils/generate-schema.d.ts.map +1 -1
- package/dist/tasks/compile/index.d.ts.map +1 -1
- package/dist/tasks/compile/utils/compile-operation-definition.d.ts.map +1 -1
- package/dist/tasks/compile/utils/compile-schema-definition.d.ts.map +1 -1
- package/dist/tasks/persist/index.d.ts.map +1 -1
- package/dist/tasks/utils/dependency.d.ts +3 -1
- package/dist/tasks/utils/dependency.d.ts.map +1 -1
- package/dist/types/runtime-config.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { defineKeqConfig } from './define-keq-config.js';
|
|
2
2
|
export { RuntimeConfig } from './types/runtime-config.js';
|
|
3
3
|
export { FileNamingStyle } from './constants/file-naming-style.js';
|
|
4
|
+
export { QsArrayFormat } from './constants/qs-array-format.js';
|
|
4
5
|
export { Compiler } from './compiler/compiler.js';
|
|
5
6
|
export { Plugin } from './types/plugin.js';
|
|
6
7
|
export { Artifact } from './tasks/utils/artifact.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1076,7 +1076,10 @@ function createPersistArtifactTask() {
|
|
|
1076
1076
|
title: "Write files",
|
|
1077
1077
|
task: async (context, task) => {
|
|
1078
1078
|
if (!context.setup) throw new Error("Please run setup task first.");
|
|
1079
|
-
if (!context.compiled)
|
|
1079
|
+
if (!context.compiled) {
|
|
1080
|
+
task.skip("No compiled artifacts to persist.");
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1080
1083
|
const rc = context.setup.rc;
|
|
1081
1084
|
const artifacts = context.compiled.artifacts;
|
|
1082
1085
|
for (const artifact of artifacts) {
|
|
@@ -1207,11 +1210,12 @@ function generateArray(schema, alias) {
|
|
|
1207
1210
|
return "any[]";
|
|
1208
1211
|
}
|
|
1209
1212
|
function indent(space, text) {
|
|
1213
|
+
if (text === "") return "";
|
|
1210
1214
|
const indentation = " ".repeat(space);
|
|
1211
1215
|
return text.split("\n").map((line) => `${indentation}${line}`).join("\n");
|
|
1212
1216
|
}
|
|
1213
1217
|
function generateObject(schema, alias) {
|
|
1214
|
-
if (!schema.properties ||
|
|
1218
|
+
if ((!schema.properties || R11.isEmpty(schema.properties)) && (!schema.additionalProperties || R11.isEmpty(schema.additionalProperties))) {
|
|
1215
1219
|
return "object";
|
|
1216
1220
|
}
|
|
1217
1221
|
const $properties = Object.entries(schema.properties || {}).map(([propertyName, propertySchema]) => {
|
|
@@ -1381,15 +1385,17 @@ function toComment(msg) {
|
|
|
1381
1385
|
|
|
1382
1386
|
// src/tasks/utils/dependency.ts
|
|
1383
1387
|
var DependencyIdentifier = class {
|
|
1384
|
-
constructor(name, alias) {
|
|
1388
|
+
constructor(name, alias, type = false) {
|
|
1385
1389
|
this.name = name;
|
|
1386
1390
|
this.alias = alias;
|
|
1391
|
+
this.type = type;
|
|
1387
1392
|
}
|
|
1388
1393
|
toCode() {
|
|
1394
|
+
const $type = this.type ? "type " : "";
|
|
1389
1395
|
if (this.alias) {
|
|
1390
|
-
return `${this.name} as ${this.alias}`;
|
|
1396
|
+
return `${$type}${this.name} as ${this.alias}`;
|
|
1391
1397
|
}
|
|
1392
|
-
return this.name
|
|
1398
|
+
return `${$type}${this.name}`;
|
|
1393
1399
|
}
|
|
1394
1400
|
};
|
|
1395
1401
|
var Dependency = class {
|
|
@@ -1400,6 +1406,11 @@ var Dependency = class {
|
|
|
1400
1406
|
constructor(source, identifiers, belongTo, options) {
|
|
1401
1407
|
this.source = source;
|
|
1402
1408
|
this.identifiers = identifiers.map((i) => typeof i === "string" ? new DependencyIdentifier(i) : i);
|
|
1409
|
+
if (options?.type) {
|
|
1410
|
+
for (const identifier of this.identifiers) {
|
|
1411
|
+
identifier.type = true;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1403
1414
|
this.export = !!options?.export;
|
|
1404
1415
|
this.belongTo = belongTo;
|
|
1405
1416
|
}
|
|
@@ -1571,7 +1582,10 @@ async function compileSchemaDefinition(options) {
|
|
|
1571
1582
|
const artifact = new Artifact({
|
|
1572
1583
|
id: filepath,
|
|
1573
1584
|
filepath,
|
|
1574
|
-
content:
|
|
1585
|
+
content: [
|
|
1586
|
+
"/* @anchor:file:start */",
|
|
1587
|
+
"/* @anchor:file:end */"
|
|
1588
|
+
].join("\n")
|
|
1575
1589
|
});
|
|
1576
1590
|
for (const schemaDefinition of schemaDefinitions2 || []) {
|
|
1577
1591
|
const dependentArtifact = artifacts.find(isArtifactCompiledBy(schemaDefinition));
|
|
@@ -1587,7 +1601,7 @@ async function compileSchemaDefinition(options) {
|
|
|
1587
1601
|
}
|
|
1588
1602
|
|
|
1589
1603
|
// src/tasks/compile/utils/compile-operation-definition.ts
|
|
1590
|
-
import * as
|
|
1604
|
+
import * as R18 from "ramda";
|
|
1591
1605
|
|
|
1592
1606
|
// src/renderer/operation-type/index.ts
|
|
1593
1607
|
import * as R15 from "ramda";
|
|
@@ -1684,7 +1698,7 @@ async function operationTypeRenderer(operationDefinition, alias = R15.identity)
|
|
|
1684
1698
|
$parameterBodies || void 0,
|
|
1685
1699
|
$requestParameters,
|
|
1686
1700
|
"",
|
|
1687
|
-
`export interface Operation<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends keyof ${typeName("ParameterBodies")}> extends KeqOperation {`,
|
|
1701
|
+
`export interface Operation<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${$parameterBodies ? `keyof ${typeName("ParameterBodies")}` : "string"} > extends KeqOperation {`,
|
|
1688
1702
|
` requestParams: ${typeName("RouteParameters")} & { [key: string]: KeqPathParameterInit }`,
|
|
1689
1703
|
` requestQuery: ${typeName("RequestQuery")} & { [key: string]: KeqQueryInit }`,
|
|
1690
1704
|
` requestHeaders: ${typeName("RequestHeaders")} & { [key: string]: string | number }`,
|
|
@@ -1713,7 +1727,12 @@ function generateParameters(name, parameters, alias) {
|
|
|
1713
1727
|
}
|
|
1714
1728
|
|
|
1715
1729
|
// src/renderer/operation-request/index.ts
|
|
1730
|
+
import * as R17 from "ramda";
|
|
1731
|
+
|
|
1732
|
+
// src/renderer/operation-request/request-body.ts
|
|
1716
1733
|
import * as R16 from "ramda";
|
|
1734
|
+
|
|
1735
|
+
// src/renderer/operation-request/error-to-comment.ts
|
|
1717
1736
|
function errorToComment(err, mediaType) {
|
|
1718
1737
|
const $err = String(err).split("\n").map(((line) => ` * ${line}`)).join("\n");
|
|
1719
1738
|
return [
|
|
@@ -1723,6 +1742,34 @@ function errorToComment(err, mediaType) {
|
|
|
1723
1742
|
" */"
|
|
1724
1743
|
].join("\n");
|
|
1725
1744
|
}
|
|
1745
|
+
|
|
1746
|
+
// src/renderer/operation-request/request-body.ts
|
|
1747
|
+
function requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType, operationDefinition) {
|
|
1748
|
+
try {
|
|
1749
|
+
const $propertyName = JSON.stringify(propertyName);
|
|
1750
|
+
const schema = JsonSchemaUtils.isRef(propertySchema) ? SwaggerUtils.dereferenceDeep(propertySchema.$ref, operationDefinition.document.swagger) : propertySchema;
|
|
1751
|
+
if (schema.type === "string" && schema.format === "binary" || schema.contentMediaType === "application/octet-stream") {
|
|
1752
|
+
return `if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`;
|
|
1753
|
+
} else if (schema.type === "string" || schema.type === "array" && schema.items && schema.items.type === "string") {
|
|
1754
|
+
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`;
|
|
1755
|
+
} else if (schema.type === "number" || schema.type === "integer") {
|
|
1756
|
+
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]))`;
|
|
1757
|
+
}
|
|
1758
|
+
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]) /* type is non-string in schema; triggers type coercion here */)`;
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
return errorToComment(err, mediaType);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
function requestBodyPropertyRenderer(propertyName, propertySchema, mediaType, operationDefinition) {
|
|
1764
|
+
if (mediaType === "application/json") {
|
|
1765
|
+
const $propertyName = JSON.stringify(propertyName);
|
|
1766
|
+
return `if (args && ${$propertyName} in args) req.send({ ${$propertyName}: args[${$propertyName}] })`;
|
|
1767
|
+
} else if (mediaType === "multipart/form-data") {
|
|
1768
|
+
return requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType, operationDefinition);
|
|
1769
|
+
} else {
|
|
1770
|
+
throw new Error(`Unsupported media type: ${mediaType}`);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1726
1773
|
function requestBodyRenderer(operationDefinition, typeName) {
|
|
1727
1774
|
const { operation } = operationDefinition;
|
|
1728
1775
|
const requestBodyContent = operation.requestBody?.content || {};
|
|
@@ -1733,22 +1780,10 @@ function requestBodyRenderer(operationDefinition, typeName) {
|
|
|
1733
1780
|
if (schema.type !== "object") return;
|
|
1734
1781
|
const properties = schema.properties || {};
|
|
1735
1782
|
return Object.entries(properties).map(([propertyName, propertySchema]) => {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
try {
|
|
1741
|
-
const schema2 = JsonSchemaUtils.isRef(propertySchema) ? SwaggerUtils.dereferenceDeep(propertySchema.$ref, operationDefinition.document.swagger) : propertySchema;
|
|
1742
|
-
if (schema2.type === "string" && schema2.format === "binary" || schema2.contentMediaType === "application/octet-stream") {
|
|
1743
|
-
return ` if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`;
|
|
1744
|
-
}
|
|
1745
|
-
return ` if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`;
|
|
1746
|
-
} catch (err) {
|
|
1747
|
-
return indent(2, errorToComment(err, mediaType));
|
|
1748
|
-
}
|
|
1749
|
-
} else {
|
|
1750
|
-
throw new Error(`Unsupported media type: ${mediaType}`);
|
|
1751
|
-
}
|
|
1783
|
+
return indent(
|
|
1784
|
+
2,
|
|
1785
|
+
requestBodyPropertyRenderer(propertyName, propertySchema, mediaType, operationDefinition)
|
|
1786
|
+
);
|
|
1752
1787
|
}).join("\n");
|
|
1753
1788
|
} catch (err) {
|
|
1754
1789
|
return indent(2, errorToComment(err, mediaType));
|
|
@@ -1756,6 +1791,8 @@ function requestBodyRenderer(operationDefinition, typeName) {
|
|
|
1756
1791
|
}).filter(R16.isNotNil).join("\n");
|
|
1757
1792
|
return $requestBody;
|
|
1758
1793
|
}
|
|
1794
|
+
|
|
1795
|
+
// src/renderer/operation-request/index.ts
|
|
1759
1796
|
function requestHeadersRenderer(operationDefinition, typeName) {
|
|
1760
1797
|
const { operation } = operationDefinition;
|
|
1761
1798
|
const $headers = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "header").map((p) => ` if (args && ${JSON.stringify(p.name)} in args) req.header(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`).concat("").join("\n");
|
|
@@ -1765,7 +1802,7 @@ function requestQueryRenderer(operationDefinition, qs, typeName) {
|
|
|
1765
1802
|
const { operation } = operationDefinition;
|
|
1766
1803
|
const $query = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "query").map((p) => {
|
|
1767
1804
|
const option = qs(p);
|
|
1768
|
-
const $option = !option ||
|
|
1805
|
+
const $option = !option || R17.isEmpty(option) ? "" : `, ${JSON.stringify(option)}`;
|
|
1769
1806
|
return ` if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`;
|
|
1770
1807
|
}).concat("").join("\n");
|
|
1771
1808
|
return $query;
|
|
@@ -1797,9 +1834,9 @@ function operationDeclarationRenderer(operationDefinition, typeName) {
|
|
|
1797
1834
|
const { operationId } = operationDefinition;
|
|
1798
1835
|
const mediaTypes = getRequestMediaTypes(operationDefinition);
|
|
1799
1836
|
if (mediaTypes.length === 0) {
|
|
1800
|
-
return `function ${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}>(args?: ${typeName("RequestParameters")}): Keq<Operation<STATUS,
|
|
1837
|
+
return `function ${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends never = never>(args?: ${typeName("RequestParameters")}): Keq<Operation<STATUS, CONTENT_TYPE>>`;
|
|
1801
1838
|
} else if (mediaTypes.length === 1) {
|
|
1802
|
-
return `function ${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}>(args?: ${typeName("RequestParameters")}): Keq<Operation<STATUS,
|
|
1839
|
+
return `function ${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${typeName("RequestParameters")}): Keq<Operation<STATUS, CONTENT_TYPE>>`;
|
|
1803
1840
|
} else if (mediaTypes.length > 1) {
|
|
1804
1841
|
return `function ${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${typeName("RequestParameters")}["content-type"]>(args?: Extract<${typeName("RequestParameters")}, { "content-type": CONTENT_TYPE }>): Keq<Operation<STATUS, CONTENT_TYPE>>`;
|
|
1805
1842
|
}
|
|
@@ -1811,6 +1848,7 @@ async function operationRequestRenderer(operationDefinition, options) {
|
|
|
1811
1848
|
if (!operation.responses) return "";
|
|
1812
1849
|
const typeName = typeNameFactory(operationDefinition);
|
|
1813
1850
|
const moduleName = operationDefinition.module.name;
|
|
1851
|
+
const $method = method.toLowerCase();
|
|
1814
1852
|
const $queryParameters = requestQueryRenderer(operationDefinition, qs, typeName);
|
|
1815
1853
|
const $headerParameters = requestHeadersRenderer(operationDefinition, typeName);
|
|
1816
1854
|
const $pathParameters = requestPathParametersRenderer(operationDefinition, typeName);
|
|
@@ -1826,7 +1864,7 @@ async function operationRequestRenderer(operationDefinition, options) {
|
|
|
1826
1864
|
"",
|
|
1827
1865
|
"/* @anchor:operation-declaration */",
|
|
1828
1866
|
`export ${$operationDeclaration} {`,
|
|
1829
|
-
` const req = request
|
|
1867
|
+
` const req = request.${$method}<${typeName("ResponseBodies")}[STATUS]>("${pathname}")`,
|
|
1830
1868
|
" .option('module', { name: moduleName, pathname, method })",
|
|
1831
1869
|
"",
|
|
1832
1870
|
$mediaType || void 0,
|
|
@@ -1847,13 +1885,13 @@ async function operationRequestRenderer(operationDefinition, options) {
|
|
|
1847
1885
|
" /* @anchor:body:end */",
|
|
1848
1886
|
"",
|
|
1849
1887
|
" /* @anchor:operation-return */",
|
|
1850
|
-
` return req as ReturnType<typeof ${operationId}
|
|
1888
|
+
` return req as ReturnType<typeof ${operationId}<STATUS${$operationDeclaration.includes("CONTENT_TYPE") ? ", CONTENT_TYPE" : ""}>>`,
|
|
1851
1889
|
"}",
|
|
1852
1890
|
"",
|
|
1853
1891
|
`${operationId}.pathname = pathname`,
|
|
1854
1892
|
`${operationId}.method = method`,
|
|
1855
1893
|
"/* @anchor:file:end */"
|
|
1856
|
-
].filter(
|
|
1894
|
+
].filter(R17.isNotNil).join("\n");
|
|
1857
1895
|
}
|
|
1858
1896
|
|
|
1859
1897
|
// src/tasks/compile/utils/compile-operation-definition.ts
|
|
@@ -1950,7 +1988,8 @@ async function compileOperationDefinition(options) {
|
|
|
1950
1988
|
"Operation",
|
|
1951
1989
|
typeName("ResponseBodies"),
|
|
1952
1990
|
typeName("RequestParameters")
|
|
1953
|
-
]
|
|
1991
|
+
],
|
|
1992
|
+
{ type: true }
|
|
1954
1993
|
);
|
|
1955
1994
|
artifact.addDependence(
|
|
1956
1995
|
typeArtifact,
|
|
@@ -1959,11 +1998,11 @@ async function compileOperationDefinition(options) {
|
|
|
1959
1998
|
`${typeName("RequestHeaders")}`,
|
|
1960
1999
|
`${typeName("RequestBodies")}`
|
|
1961
2000
|
],
|
|
1962
|
-
{ export: true }
|
|
2001
|
+
{ export: true, type: true }
|
|
1963
2002
|
);
|
|
1964
2003
|
return await compiler.hooks.afterCompileOperationRequest.promise(artifact, operationDefinition, task);
|
|
1965
2004
|
}
|
|
1966
|
-
const artifacts =
|
|
2005
|
+
const artifacts = R18.unnest(
|
|
1967
2006
|
await Promise.all(
|
|
1968
2007
|
operationDefinitions.map(async (operationDefinition) => {
|
|
1969
2008
|
const typeArtifact = await createTypeArtifact(operationDefinition);
|
|
@@ -1972,7 +2011,7 @@ async function compileOperationDefinition(options) {
|
|
|
1972
2011
|
})
|
|
1973
2012
|
)
|
|
1974
2013
|
);
|
|
1975
|
-
const operationDefinitionsGroupByModuleName =
|
|
2014
|
+
const operationDefinitionsGroupByModuleName = R18.groupBy(
|
|
1976
2015
|
(operationDefinition) => operationDefinition.module.name,
|
|
1977
2016
|
operationDefinitions
|
|
1978
2017
|
);
|
|
@@ -1981,7 +2020,10 @@ async function compileOperationDefinition(options) {
|
|
|
1981
2020
|
const artifact = new Artifact({
|
|
1982
2021
|
id: filepath,
|
|
1983
2022
|
filepath,
|
|
1984
|
-
content:
|
|
2023
|
+
content: [
|
|
2024
|
+
"/* @anchor:file:start */",
|
|
2025
|
+
"/* @anchor:file:end */"
|
|
2026
|
+
].join("\n")
|
|
1985
2027
|
});
|
|
1986
2028
|
for (const operationDefinition of operationDefinitions2 || []) {
|
|
1987
2029
|
const dependentArtifact = artifacts.find((artifact2) => artifact2.filepath === genOperationRequestFilepath(operationDefinition));
|
|
@@ -1999,14 +2041,12 @@ async function compileOperationDefinition(options) {
|
|
|
1999
2041
|
// src/renderer/request/index.ts
|
|
2000
2042
|
async function requestRenderer() {
|
|
2001
2043
|
return [
|
|
2002
|
-
"import { KeqRequest } from 'keq'",
|
|
2003
|
-
"",
|
|
2004
2044
|
"/* @anchor:file:start */",
|
|
2005
2045
|
"",
|
|
2006
2046
|
"/* @anchor:request-declaration */",
|
|
2007
2047
|
"export const request = new KeqRequest()",
|
|
2008
2048
|
"",
|
|
2009
|
-
"/* @anchor:file:end"
|
|
2049
|
+
"/* @anchor:file:end */"
|
|
2010
2050
|
].join("\n");
|
|
2011
2051
|
}
|
|
2012
2052
|
|
|
@@ -2019,13 +2059,15 @@ function main6(compiler) {
|
|
|
2019
2059
|
const rc = context.setup.rc;
|
|
2020
2060
|
const matcher = context.setup.matcher;
|
|
2021
2061
|
const documents = context.shaken.documents.filter((document) => !matcher.isModuleIgnored(document.module));
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2062
|
+
let requestArtifact = new Artifact({
|
|
2063
|
+
id: "request",
|
|
2064
|
+
filepath: "request",
|
|
2065
|
+
content: await requestRenderer(),
|
|
2066
|
+
extensionName: ".ts"
|
|
2067
|
+
});
|
|
2068
|
+
requestArtifact.addDependence("keq", ["KeqRequest"]);
|
|
2069
|
+
requestArtifact = await compiler.hooks.afterCompileKeqRequest.promise(
|
|
2070
|
+
requestArtifact,
|
|
2029
2071
|
task
|
|
2030
2072
|
);
|
|
2031
2073
|
const schemaDefinitions = documents.flatMap((document) => document.schemas);
|
|
@@ -2116,7 +2158,7 @@ function createInteractiveTask(options) {
|
|
|
2116
2158
|
}
|
|
2117
2159
|
|
|
2118
2160
|
// src/compiler/intercepter/perfect-error-message.ts
|
|
2119
|
-
import * as
|
|
2161
|
+
import * as R19 from "ramda";
|
|
2120
2162
|
function perfectErrorMessage() {
|
|
2121
2163
|
return {
|
|
2122
2164
|
register: (tap) => {
|
|
@@ -2148,8 +2190,8 @@ function perfectErrorMessage() {
|
|
|
2148
2190
|
}
|
|
2149
2191
|
if (tap.type === "async") {
|
|
2150
2192
|
tap.fn = (...args) => {
|
|
2151
|
-
const callback =
|
|
2152
|
-
return fn(...
|
|
2193
|
+
const callback = R19.last(args);
|
|
2194
|
+
return fn(...R19.init(args), (err, result) => {
|
|
2153
2195
|
prefix(err);
|
|
2154
2196
|
return callback(err, result);
|
|
2155
2197
|
});
|
|
@@ -2240,11 +2282,11 @@ var Compiler = class {
|
|
|
2240
2282
|
[
|
|
2241
2283
|
createSetupTask(this, options),
|
|
2242
2284
|
createDownloadTask(this, { skipIgnoredModules: !options.interactive }),
|
|
2243
|
-
createValidateTask(this
|
|
2285
|
+
createValidateTask(this),
|
|
2244
2286
|
createInteractiveTask({ enabled: !!options.interactive, ...typeof options.interactive === "object" ? options.interactive : { mode: "except" } }),
|
|
2245
2287
|
createShakingTask(this, { enabled: !!options.build, ...typeof options.build === "object" ? options.build.shaking : void 0 }),
|
|
2246
2288
|
createCompileTask(this, { enabled: !!options.build }),
|
|
2247
|
-
createPersistTask(this
|
|
2289
|
+
createPersistTask(this)
|
|
2248
2290
|
],
|
|
2249
2291
|
{
|
|
2250
2292
|
concurrent: false,
|
|
@@ -2268,6 +2310,7 @@ export {
|
|
|
2268
2310
|
FileNamingStyle,
|
|
2269
2311
|
ModuleDefinition,
|
|
2270
2312
|
OperationDefinition,
|
|
2313
|
+
QsArrayFormat,
|
|
2271
2314
|
RuntimeConfig,
|
|
2272
2315
|
SchemaDefinition,
|
|
2273
2316
|
defineKeqConfig
|