@powerlines/plugin-hey-api 0.1.315 → 0.1.317
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/package.json +4 -4
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
- package/dist/helpers/create-operation-id.cjs +0 -17
- package/dist/helpers/create-operation-id.d.cts +0 -11
- package/dist/helpers/create-operation-id.d.cts.map +0 -1
- package/dist/helpers/create-operation-id.d.mts +0 -11
- package/dist/helpers/create-operation-id.d.mts.map +0 -1
- package/dist/helpers/create-operation-id.mjs +0 -16
- package/dist/helpers/create-operation-id.mjs.map +0 -1
- package/dist/helpers/index.cjs +0 -4
- package/dist/helpers/index.d.cts +0 -2
- package/dist/helpers/index.d.mts +0 -2
- package/dist/helpers/index.mjs +0 -3
- package/dist/index.cjs +0 -91
- package/dist/index.d.cts +0 -22
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -22
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -87
- package/dist/index.mjs.map +0 -1
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +0 -2
- package/dist/types/index.d.mts +0 -2
- package/dist/types/index.mjs +0 -1
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +0 -47
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts +0 -47
- package/dist/types/plugin.d.mts.map +0 -1
- package/dist/types/plugin.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-hey-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.317",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to generate project code using Hey API.",
|
|
6
6
|
"repository": {
|
|
@@ -124,13 +124,13 @@
|
|
|
124
124
|
"@stryke/types": "^0.11.1",
|
|
125
125
|
"defu": "^6.1.4",
|
|
126
126
|
"jiti": "^2.6.1",
|
|
127
|
-
"powerlines": "^0.42.
|
|
127
|
+
"powerlines": "^0.42.4"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
130
|
+
"@powerlines/plugin-plugin": "^0.12.314",
|
|
131
131
|
"@types/node": "^25.5.0"
|
|
132
132
|
},
|
|
133
133
|
"publishConfig": { "access": "public" },
|
|
134
134
|
"types": "./dist/index.d.cts",
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "c3243c1ec0fbacb4afd4bd3db20432f443334076"
|
|
136
136
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/create-operation-id.ts
|
|
6
|
-
/**
|
|
7
|
-
* Create an Operation Id from a summary string
|
|
8
|
-
*
|
|
9
|
-
* @param summary - The summary string from the specification
|
|
10
|
-
* @returns The generated operation ID
|
|
11
|
-
*/
|
|
12
|
-
function createOperationId(summary) {
|
|
13
|
-
return (0, _stryke_string_format_camel_case.camelCase)(summary.replace(/\b(?:a|from|to|the|given|of|an)\b/gi, "").replace("Get list", "list"));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
exports.createOperationId = createOperationId;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/helpers/create-operation-id.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create an Operation Id from a summary string
|
|
4
|
-
*
|
|
5
|
-
* @param summary - The summary string from the specification
|
|
6
|
-
* @returns The generated operation ID
|
|
7
|
-
*/
|
|
8
|
-
declare function createOperationId(summary: string): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { createOperationId };
|
|
11
|
-
//# sourceMappingURL=create-operation-id.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-operation-id.d.cts","names":[],"sources":["../../src/helpers/create-operation-id.ts"],"mappings":";;AA0BA;;;;;iBAAgB,iBAAA,CAAkB,OAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/helpers/create-operation-id.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create an Operation Id from a summary string
|
|
4
|
-
*
|
|
5
|
-
* @param summary - The summary string from the specification
|
|
6
|
-
* @returns The generated operation ID
|
|
7
|
-
*/
|
|
8
|
-
declare function createOperationId(summary: string): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { createOperationId };
|
|
11
|
-
//# sourceMappingURL=create-operation-id.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-operation-id.d.mts","names":[],"sources":["../../src/helpers/create-operation-id.ts"],"mappings":";;AA0BA;;;;;iBAAgB,iBAAA,CAAkB,OAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/create-operation-id.ts
|
|
4
|
-
/**
|
|
5
|
-
* Create an Operation Id from a summary string
|
|
6
|
-
*
|
|
7
|
-
* @param summary - The summary string from the specification
|
|
8
|
-
* @returns The generated operation ID
|
|
9
|
-
*/
|
|
10
|
-
function createOperationId(summary) {
|
|
11
|
-
return camelCase(summary.replace(/\b(?:a|from|to|the|given|of|an)\b/gi, "").replace("Get list", "list"));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { createOperationId };
|
|
16
|
-
//# sourceMappingURL=create-operation-id.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-operation-id.mjs","names":[],"sources":["../../src/helpers/create-operation-id.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { camelCase } from \"@stryke/string-format/camel-case\";\n\n/**\n * Create an Operation Id from a summary string\n *\n * @param summary - The summary string from the specification\n * @returns The generated operation ID\n */\nexport function createOperationId(summary: string) {\n return camelCase(\n summary\n .replace(/\\b(?:a|from|to|the|given|of|an)\\b/gi, \"\")\n .replace(\"Get list\", \"list\")\n );\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,kBAAkB,SAAiB;AACjD,QAAO,UACL,QACG,QAAQ,uCAAuC,GAAG,CAClD,QAAQ,YAAY,OAAO,CAC/B"}
|
package/dist/helpers/index.cjs
DELETED
package/dist/helpers/index.d.cts
DELETED
package/dist/helpers/index.d.mts
DELETED
package/dist/helpers/index.mjs
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_helpers_create_operation_id = require('./helpers/create-operation-id.cjs');
|
|
4
|
-
require('./helpers/index.cjs');
|
|
5
|
-
let _hey_api_openapi_ts = require("@hey-api/openapi-ts");
|
|
6
|
-
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
7
|
-
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
8
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
9
|
-
let defu = require("defu");
|
|
10
|
-
defu = require_runtime.__toESM(defu);
|
|
11
|
-
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
12
|
-
|
|
13
|
-
//#region src/index.ts
|
|
14
|
-
/**
|
|
15
|
-
* A Powerlines plugin to integrate Hey API for code generation.
|
|
16
|
-
*
|
|
17
|
-
* @see https://heyapi.dev/
|
|
18
|
-
*
|
|
19
|
-
* @param options - The plugin options.
|
|
20
|
-
* @returns A Powerlines plugin instance.
|
|
21
|
-
*/
|
|
22
|
-
const plugin = (options = {}) => {
|
|
23
|
-
return {
|
|
24
|
-
name: "hey-api",
|
|
25
|
-
config() {
|
|
26
|
-
return { heyApi: {
|
|
27
|
-
plugins: [
|
|
28
|
-
{
|
|
29
|
-
name: "@hey-api/typescript",
|
|
30
|
-
exportFromIndex: false
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "@hey-api/sdk",
|
|
34
|
-
instance: "PrismaClient",
|
|
35
|
-
exportFromIndex: false,
|
|
36
|
-
auth: false
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "@hey-api/client-fetch",
|
|
40
|
-
throwOnError: true
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
...(0, defu.default)(options, {
|
|
44
|
-
schema: (0, _stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.root, "schema.yaml"),
|
|
45
|
-
output: { path: (0, _stryke_path_join_paths.joinPaths)("{builtinPath}", "api") },
|
|
46
|
-
logs: this.envPaths.log
|
|
47
|
-
})
|
|
48
|
-
} };
|
|
49
|
-
},
|
|
50
|
-
async configResolved() {
|
|
51
|
-
this.config.heyApi.output ??= {};
|
|
52
|
-
this.config.heyApi.output.path = (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.heyApi.output.path);
|
|
53
|
-
if (!this.config.heyApi.schema) throw new Error("The `schema` option is required by the Hey API plugin.");
|
|
54
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.heyApi.schema)) {
|
|
55
|
-
const result = await this.fetch(this.config.heyApi.schema);
|
|
56
|
-
this.config.heyApi.schema = await result.json();
|
|
57
|
-
}
|
|
58
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(this.config.heyApi.schema) && this.config.heyApi.schema.paths) {
|
|
59
|
-
const schema = this.config.heyApi.schema;
|
|
60
|
-
for (const pathItem of Object.values(schema.paths)) {
|
|
61
|
-
if (!pathItem || "$ref" in pathItem) continue;
|
|
62
|
-
for (const method of [
|
|
63
|
-
"get",
|
|
64
|
-
"put",
|
|
65
|
-
"post",
|
|
66
|
-
"delete",
|
|
67
|
-
"options",
|
|
68
|
-
"head",
|
|
69
|
-
"patch",
|
|
70
|
-
"trace"
|
|
71
|
-
]) {
|
|
72
|
-
const operation = pathItem[method];
|
|
73
|
-
if (!(0, _stryke_type_checks_is_set_string.isSetString)(operation?.summary)) continue;
|
|
74
|
-
operation.operationId = require_helpers_create_operation_id.createOperationId(operation.summary);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
async prepare() {
|
|
80
|
-
await (0, _hey_api_openapi_ts.createClient)({
|
|
81
|
-
...this.config.heyApi,
|
|
82
|
-
input: this.config.heyApi.schema
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
exports.createOperationId = require_helpers_create_operation_id.createOperationId;
|
|
90
|
-
exports.default = plugin;
|
|
91
|
-
exports.plugin = plugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createOperationId } from "./helpers/create-operation-id.cjs";
|
|
2
|
-
import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig } from "./types/plugin.cjs";
|
|
3
|
-
import { Plugin } from "powerlines";
|
|
4
|
-
|
|
5
|
-
//#region src/index.d.ts
|
|
6
|
-
declare module "powerlines" {
|
|
7
|
-
interface Config {
|
|
8
|
-
heyApi?: HeyAPIPluginOptions;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A Powerlines plugin to integrate Hey API for code generation.
|
|
13
|
-
*
|
|
14
|
-
* @see https://heyapi.dev/
|
|
15
|
-
*
|
|
16
|
-
* @param options - The plugin options.
|
|
17
|
-
* @returns A Powerlines plugin instance.
|
|
18
|
-
*/
|
|
19
|
-
declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
|
|
22
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAsCY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;;;;;AAYb;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createOperationId } from "./helpers/create-operation-id.mjs";
|
|
2
|
-
import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig } from "./types/plugin.mjs";
|
|
3
|
-
import { Plugin } from "powerlines";
|
|
4
|
-
|
|
5
|
-
//#region src/index.d.ts
|
|
6
|
-
declare module "powerlines" {
|
|
7
|
-
interface Config {
|
|
8
|
-
heyApi?: HeyAPIPluginOptions;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A Powerlines plugin to integrate Hey API for code generation.
|
|
13
|
-
*
|
|
14
|
-
* @see https://heyapi.dev/
|
|
15
|
-
*
|
|
16
|
-
* @param options - The plugin options.
|
|
17
|
-
* @returns A Powerlines plugin instance.
|
|
18
|
-
*/
|
|
19
|
-
declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
|
|
22
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAsCY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;;;;;AAYb;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { createOperationId } from "./helpers/create-operation-id.mjs";
|
|
2
|
-
import "./helpers/index.mjs";
|
|
3
|
-
import { createClient } from "@hey-api/openapi-ts";
|
|
4
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
6
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
7
|
-
import defu from "defu";
|
|
8
|
-
import { replacePathTokens } from "powerlines/plugin-utils";
|
|
9
|
-
|
|
10
|
-
//#region src/index.ts
|
|
11
|
-
/**
|
|
12
|
-
* A Powerlines plugin to integrate Hey API for code generation.
|
|
13
|
-
*
|
|
14
|
-
* @see https://heyapi.dev/
|
|
15
|
-
*
|
|
16
|
-
* @param options - The plugin options.
|
|
17
|
-
* @returns A Powerlines plugin instance.
|
|
18
|
-
*/
|
|
19
|
-
const plugin = (options = {}) => {
|
|
20
|
-
return {
|
|
21
|
-
name: "hey-api",
|
|
22
|
-
config() {
|
|
23
|
-
return { heyApi: {
|
|
24
|
-
plugins: [
|
|
25
|
-
{
|
|
26
|
-
name: "@hey-api/typescript",
|
|
27
|
-
exportFromIndex: false
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "@hey-api/sdk",
|
|
31
|
-
instance: "PrismaClient",
|
|
32
|
-
exportFromIndex: false,
|
|
33
|
-
auth: false
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "@hey-api/client-fetch",
|
|
37
|
-
throwOnError: true
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
...defu(options, {
|
|
41
|
-
schema: joinPaths(this.workspaceConfig.workspaceRoot, this.config.root, "schema.yaml"),
|
|
42
|
-
output: { path: joinPaths("{builtinPath}", "api") },
|
|
43
|
-
logs: this.envPaths.log
|
|
44
|
-
})
|
|
45
|
-
} };
|
|
46
|
-
},
|
|
47
|
-
async configResolved() {
|
|
48
|
-
this.config.heyApi.output ??= {};
|
|
49
|
-
this.config.heyApi.output.path = replacePathTokens(this, this.config.heyApi.output.path);
|
|
50
|
-
if (!this.config.heyApi.schema) throw new Error("The `schema` option is required by the Hey API plugin.");
|
|
51
|
-
if (isSetString(this.config.heyApi.schema)) {
|
|
52
|
-
const result = await this.fetch(this.config.heyApi.schema);
|
|
53
|
-
this.config.heyApi.schema = await result.json();
|
|
54
|
-
}
|
|
55
|
-
if (isSetObject(this.config.heyApi.schema) && this.config.heyApi.schema.paths) {
|
|
56
|
-
const schema = this.config.heyApi.schema;
|
|
57
|
-
for (const pathItem of Object.values(schema.paths)) {
|
|
58
|
-
if (!pathItem || "$ref" in pathItem) continue;
|
|
59
|
-
for (const method of [
|
|
60
|
-
"get",
|
|
61
|
-
"put",
|
|
62
|
-
"post",
|
|
63
|
-
"delete",
|
|
64
|
-
"options",
|
|
65
|
-
"head",
|
|
66
|
-
"patch",
|
|
67
|
-
"trace"
|
|
68
|
-
]) {
|
|
69
|
-
const operation = pathItem[method];
|
|
70
|
-
if (!isSetString(operation?.summary)) continue;
|
|
71
|
-
operation.operationId = createOperationId(operation.summary);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
async prepare() {
|
|
77
|
-
await createClient({
|
|
78
|
-
...this.config.heyApi,
|
|
79
|
-
input: this.config.heyApi.schema
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
export { createOperationId, plugin as default, plugin };
|
|
87
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { UserConfig } from \"@hey-api/openapi-ts\";\nimport { createClient, OpenApi } from \"@hey-api/openapi-ts\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { createOperationId } from \"./helpers/create-operation-id\";\nimport {\n HeyAPIPluginContext,\n HeyAPIPluginOptions,\n HeyAPIPluginOutputOptions,\n HeyAPIPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n heyApi?: HeyAPIPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Hey API for code generation.\n *\n * @see https://heyapi.dev/\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends HeyAPIPluginContext = HeyAPIPluginContext\n>(\n options: HeyAPIPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"hey-api\",\n config() {\n return {\n heyApi: {\n plugins: [\n {\n name: \"@hey-api/typescript\",\n exportFromIndex: false\n },\n {\n name: \"@hey-api/sdk\",\n instance: \"PrismaClient\",\n exportFromIndex: false,\n auth: false\n },\n {\n name: \"@hey-api/client-fetch\",\n throwOnError: true\n }\n ],\n ...defu(options, {\n schema: joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.root,\n \"schema.yaml\"\n ),\n output: {\n path: joinPaths(\"{builtinPath}\", \"api\")\n },\n logs: this.envPaths.log\n })\n }\n } as Partial<HeyAPIPluginUserConfig>;\n },\n async configResolved() {\n this.config.heyApi.output ??= {} as HeyAPIPluginOutputOptions;\n this.config.heyApi.output.path = replacePathTokens(\n this,\n this.config.heyApi.output.path\n );\n\n if (!this.config.heyApi.schema) {\n throw new Error(\n \"The `schema` option is required by the Hey API plugin.\"\n );\n }\n\n if (isSetString(this.config.heyApi.schema)) {\n const result = await this.fetch(this.config.heyApi.schema);\n this.config.heyApi.schema =\n (await result.json()) as HeyAPIPluginOptions[\"schema\"];\n }\n\n if (\n isSetObject(this.config.heyApi.schema) &&\n (this.config.heyApi.schema as OpenApi.V3_0_X).paths\n ) {\n const schema = this.config.heyApi.schema as OpenApi.V3_0_X;\n for (const pathItem of Object.values(schema.paths)) {\n if (!pathItem || \"$ref\" in pathItem) {\n continue;\n }\n\n for (const method of [\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"options\",\n \"head\",\n \"patch\",\n \"trace\"\n ] as const) {\n const operation = pathItem[method];\n if (!isSetString(operation?.summary)) {\n continue;\n }\n\n operation.operationId = createOperationId(operation.summary);\n }\n }\n }\n },\n async prepare() {\n await createClient({\n ...this.config.heyApi,\n input: this.config.heyApi.schema!\n } as UserConfig);\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmDA,MAAa,UAGX,UAA+B,EAAE,KACZ;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO,EACL,QAAQ;IACN,SAAS;KACP;MACE,MAAM;MACN,iBAAiB;MAClB;KACD;MACE,MAAM;MACN,UAAU;MACV,iBAAiB;MACjB,MAAM;MACP;KACD;MACE,MAAM;MACN,cAAc;MACf;KACF;IACD,GAAG,KAAK,SAAS;KACf,QAAQ,UACN,KAAK,gBAAgB,eACrB,KAAK,OAAO,MACZ,cACD;KACD,QAAQ,EACN,MAAM,UAAU,iBAAiB,MAAM,EACxC;KACD,MAAM,KAAK,SAAS;KACrB,CAAC;IACH,EACF;;EAEH,MAAM,iBAAiB;AACrB,QAAK,OAAO,OAAO,WAAW,EAAE;AAChC,QAAK,OAAO,OAAO,OAAO,OAAO,kBAC/B,MACA,KAAK,OAAO,OAAO,OAAO,KAC3B;AAED,OAAI,CAAC,KAAK,OAAO,OAAO,OACtB,OAAM,IAAI,MACR,yDACD;AAGH,OAAI,YAAY,KAAK,OAAO,OAAO,OAAO,EAAE;IAC1C,MAAM,SAAS,MAAM,KAAK,MAAM,KAAK,OAAO,OAAO,OAAO;AAC1D,SAAK,OAAO,OAAO,SAChB,MAAM,OAAO,MAAM;;AAGxB,OACE,YAAY,KAAK,OAAO,OAAO,OAAO,IACrC,KAAK,OAAO,OAAO,OAA0B,OAC9C;IACA,MAAM,SAAS,KAAK,OAAO,OAAO;AAClC,SAAK,MAAM,YAAY,OAAO,OAAO,OAAO,MAAM,EAAE;AAClD,SAAI,CAAC,YAAY,UAAU,SACzB;AAGF,UAAK,MAAM,UAAU;MACnB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD,EAAW;MACV,MAAM,YAAY,SAAS;AAC3B,UAAI,CAAC,YAAY,WAAW,QAAQ,CAClC;AAGF,gBAAU,cAAc,kBAAkB,UAAU,QAAQ;;;;;EAKpE,MAAM,UAAU;AACd,SAAM,aAAa;IACjB,GAAG,KAAK,OAAO;IACf,OAAO,KAAK,OAAO,OAAO;IAC3B,CAAe;;EAEnB"}
|
package/dist/types/index.cjs
DELETED
|
File without changes
|
package/dist/types/index.d.cts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig } from "./plugin.cjs";
|
|
2
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig };
|
package/dist/types/index.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig } from "./plugin.mjs";
|
|
2
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig };
|
package/dist/types/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/types/plugin.cjs
DELETED
|
File without changes
|
package/dist/types/plugin.d.cts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
-
import { OpenApi, UserConfig as UserConfig$1 } from "@hey-api/openapi-ts";
|
|
3
|
-
|
|
4
|
-
//#region src/types/plugin.d.ts
|
|
5
|
-
type HeyAPIPluginOutputOptions = UserConfig$1["output"] & {
|
|
6
|
-
/**
|
|
7
|
-
* The path to the output file generated by the plugin.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* If using the default value, the file can be imported from "powerlines:api". This field allows the use of the "\{builtinPath\}" token to refer to the built-in Powerlines plugins directory - the value will be replaced with the correct file path by the plugin.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue "\{builtinPath\}/api"
|
|
13
|
-
*/
|
|
14
|
-
path?: string;
|
|
15
|
-
};
|
|
16
|
-
type HeyAPIPluginOptions = Omit<UserConfig$1, "input" | "output" | "schema"> & {
|
|
17
|
-
/**
|
|
18
|
-
* The path to the Hey API schema file.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* This can be a string path, URL, HeyAPI3 object, Buffer, or Readable stream.
|
|
22
|
-
*
|
|
23
|
-
* @defaultValue "\{root\}/schema.yaml"
|
|
24
|
-
*/
|
|
25
|
-
schema?: UserConfig$1["input"];
|
|
26
|
-
/**
|
|
27
|
-
* The output details of the Hey API generation
|
|
28
|
-
*/
|
|
29
|
-
output?: HeyAPIPluginOutputOptions;
|
|
30
|
-
};
|
|
31
|
-
type HeyAPIPluginUserConfig = UserConfig & {
|
|
32
|
-
heyApi?: HeyAPIPluginOptions;
|
|
33
|
-
};
|
|
34
|
-
type HeyAPIPluginResolvedConfig = ResolvedConfig & {
|
|
35
|
-
heyApi: Omit<HeyAPIPluginOptions, "schema"> & {
|
|
36
|
-
schema: HeyAPIPluginOptions["schema"] | OpenApi.V3_0_X;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
40
|
-
declare type __ΩHeyAPIPluginOutputOptions = any[];
|
|
41
|
-
declare type __ΩHeyAPIPluginOptions = any[];
|
|
42
|
-
declare type __ΩHeyAPIPluginUserConfig = any[];
|
|
43
|
-
declare type __ΩHeyAPIPluginResolvedConfig = any[];
|
|
44
|
-
declare type __ΩHeyAPIPluginContext = any[];
|
|
45
|
-
//#endregion
|
|
46
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig };
|
|
47
|
-
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAsBY,yBAAA,GAA4B,YAAA;EAA5B;;;;;AAYZ;;;EAHE,IAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,IAAA,CAChC,YAAA;EAgBS;;;;;;;;EALT,MAAA,GAAS,YAAA;EAKyB;;AAGpC;EAHE,MAAA,GAAS,yBAAA;AAAA;AAAA,KAGC,sBAAA,GAAyB,UAAA;EACnC,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,0BAAA,GAA6B,cAAA;EACvC,MAAA,EAAQ,IAAA,CAAK,mBAAA;IACX,MAAA,EAAQ,mBAAA,aAAgC,OAAA,CAAQ,MAAA;EAAA;AAAA;AAAA,KAIxC,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
|
package/dist/types/plugin.d.mts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { OpenApi, UserConfig } from "@hey-api/openapi-ts";
|
|
2
|
-
import { PluginContext, ResolvedConfig, UserConfig as UserConfig$1 } from "powerlines";
|
|
3
|
-
|
|
4
|
-
//#region src/types/plugin.d.ts
|
|
5
|
-
type HeyAPIPluginOutputOptions = UserConfig["output"] & {
|
|
6
|
-
/**
|
|
7
|
-
* The path to the output file generated by the plugin.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* If using the default value, the file can be imported from "powerlines:api". This field allows the use of the "\{builtinPath\}" token to refer to the built-in Powerlines plugins directory - the value will be replaced with the correct file path by the plugin.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue "\{builtinPath\}/api"
|
|
13
|
-
*/
|
|
14
|
-
path?: string;
|
|
15
|
-
};
|
|
16
|
-
type HeyAPIPluginOptions = Omit<UserConfig, "input" | "output" | "schema"> & {
|
|
17
|
-
/**
|
|
18
|
-
* The path to the Hey API schema file.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* This can be a string path, URL, HeyAPI3 object, Buffer, or Readable stream.
|
|
22
|
-
*
|
|
23
|
-
* @defaultValue "\{root\}/schema.yaml"
|
|
24
|
-
*/
|
|
25
|
-
schema?: UserConfig["input"];
|
|
26
|
-
/**
|
|
27
|
-
* The output details of the Hey API generation
|
|
28
|
-
*/
|
|
29
|
-
output?: HeyAPIPluginOutputOptions;
|
|
30
|
-
};
|
|
31
|
-
type HeyAPIPluginUserConfig = UserConfig$1 & {
|
|
32
|
-
heyApi?: HeyAPIPluginOptions;
|
|
33
|
-
};
|
|
34
|
-
type HeyAPIPluginResolvedConfig = ResolvedConfig & {
|
|
35
|
-
heyApi: Omit<HeyAPIPluginOptions, "schema"> & {
|
|
36
|
-
schema: HeyAPIPluginOptions["schema"] | OpenApi.V3_0_X;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
40
|
-
declare type __ΩHeyAPIPluginOutputOptions = any[];
|
|
41
|
-
declare type __ΩHeyAPIPluginOptions = any[];
|
|
42
|
-
declare type __ΩHeyAPIPluginUserConfig = any[];
|
|
43
|
-
declare type __ΩHeyAPIPluginResolvedConfig = any[];
|
|
44
|
-
declare type __ΩHeyAPIPluginContext = any[];
|
|
45
|
-
//#endregion
|
|
46
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig };
|
|
47
|
-
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAsBY,yBAAA,GAA4B,UAAA;EAA5B;;;;;AAYZ;;;EAHE,IAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,IAAA,CAChC,UAAA;EAgBS;;;;;;;;EALT,MAAA,GAAS,UAAA;EAKyB;;AAGpC;EAHE,MAAA,GAAS,yBAAA;AAAA;AAAA,KAGC,sBAAA,GAAyB,YAAA;EACnC,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,0BAAA,GAA6B,cAAA;EACvC,MAAA,EAAQ,IAAA,CAAK,mBAAA;IACX,MAAA,EAAQ,mBAAA,aAAgC,OAAA,CAAQ,MAAA;EAAA;AAAA;AAAA,KAIxC,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
|
package/dist/types/plugin.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|