two-stroke 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/api-types.mjs +49 -0
- package/package.json +2 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import openapiTS from "openapi-typescript";
|
|
5
|
+
import prettier from "prettier";
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
|
|
8
|
+
const services = process.argv[2].split(",");
|
|
9
|
+
|
|
10
|
+
const UUID = ts.factory.createTypeReferenceNode(
|
|
11
|
+
ts.factory.createIdentifier("UUID"),
|
|
12
|
+
);
|
|
13
|
+
const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull());
|
|
14
|
+
|
|
15
|
+
await Promise.all(
|
|
16
|
+
services.map(async (service) => {
|
|
17
|
+
const output = await openapiTS(`https://${service}.changeengine.com/doc`, {
|
|
18
|
+
transform(schemaObject) {
|
|
19
|
+
if ("format" in schemaObject && schemaObject.format === "uuid") {
|
|
20
|
+
return schemaObject.nullable
|
|
21
|
+
? ts.factory.createUnionTypeNode([UUID, NULL])
|
|
22
|
+
: UUID;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const printer = ts.createPrinter({});
|
|
27
|
+
const resultFile = ts.createSourceFile(
|
|
28
|
+
`src/__definitions__/${service}-definitions.ts`,
|
|
29
|
+
"",
|
|
30
|
+
ts.ScriptTarget.Latest,
|
|
31
|
+
);
|
|
32
|
+
const result = printer.printNode(
|
|
33
|
+
ts.EmitHint.Unspecified,
|
|
34
|
+
output[0],
|
|
35
|
+
resultFile,
|
|
36
|
+
);
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
`src/__definitions__/${service}-definitions.ts`,
|
|
39
|
+
await prettier.format(
|
|
40
|
+
`// Autogenerated by two-stroke
|
|
41
|
+
|
|
42
|
+
${fs.readFileSync("src/__definitions__/type-definitions.ts", "utf-8")}
|
|
43
|
+
|
|
44
|
+
${result}`,
|
|
45
|
+
{ parser: "typescript", printWidth: 100 },
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
}),
|
|
49
|
+
);
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bin": {
|
|
3
|
+
"api-types": "./bin/api-types.mjs",
|
|
3
4
|
"bulk": "./bin/bulk.mjs",
|
|
4
5
|
"deploy": "./bin/deploy.mjs",
|
|
5
6
|
"dev": "./bin/dev.mjs",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"name": "two-stroke",
|
|
52
53
|
"packageManager": "yarn@4.6.0",
|
|
53
54
|
"type": "module",
|
|
54
|
-
"version": "5.
|
|
55
|
+
"version": "5.5.0",
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/eslint": "^9.6.1",
|
|
57
58
|
"eslint": "^9.32.0",
|