@powerlines/plugin-hey-api 0.1.411 → 0.1.412

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.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
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 +1,17 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@stryke/string-format/camel-case`);function t(t){return(0,e.camelCase)(t.replace(/\b(?:a|from|to|the|given|of|an)\b/gi,``).replace(`Get list`,`list`))}exports.createOperationId=t;
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,2 +1,16 @@
1
- import{camelCase as e}from"@stryke/string-format/camel-case";function t(t){return e(t.replace(/\b(?:a|from|to|the|given|of|an)\b/gi,``).replace(`Get list`,`list`))}export{t as createOperationId};
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 };
2
16
  //# sourceMappingURL=create-operation-id.mjs.map
@@ -1 +1 @@
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":"6DA0BA,SAAgB,EAAkB,EAAiB,CACjD,OAAO,EACL,EACG,QAAQ,sCAAuC,GAAG,CAClD,QAAQ,WAAY,OAAO,CAC/B"}
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"}
@@ -1 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./create-operation-id.cjs`);exports.createOperationId=e.createOperationId;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_helpers_create_operation_id = require('./create-operation-id.cjs');
3
+
4
+ exports.createOperationId = require_helpers_create_operation_id.createOperationId;
@@ -1 +1,3 @@
1
- import{createOperationId as e}from"./create-operation-id.mjs";export{e as createOperationId};
1
+ import { createOperationId } from "./create-operation-id.mjs";
2
+
3
+ export { createOperationId };
package/dist/index.cjs CHANGED
@@ -1 +1,91 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./helpers/create-operation-id.cjs`);require(`./helpers/index.cjs`);let n=require(`@hey-api/openapi-ts`),r=require(`@stryke/path/join-paths`),i=require(`@stryke/type-checks/is-set-object`),a=require(`@stryke/type-checks/is-set-string`),o=require(`defu`);o=e.__toESM(o,1);let s=require(`powerlines/plugin-utils`);const c=(e={})=>({name:`hey-api`,config(){return{heyApi:{plugins:[{name:`@hey-api/typescript`,exportFromIndex:!1},{name:`@hey-api/sdk`,instance:`PrismaClient`,exportFromIndex:!1,auth:!1},{name:`@hey-api/client-fetch`,throwOnError:!0}],...(0,o.default)(e,{schema:(0,r.joinPaths)(this.config.cwd??`./`,this.config.root,`schema.yaml`),output:{path:(0,r.joinPaths)(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=(0,s.replacePathTokens)(this,this.config.heyApi.output.path),!this.config.heyApi.schema)throw Error("The `schema` option is required by the Hey API plugin.");if((0,a.isSetString)(this.config.heyApi.schema)){let e=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await e.json()}if((0,i.isSetObject)(this.config.heyApi.schema)&&this.config.heyApi.schema.paths){let e=this.config.heyApi.schema;for(let n of Object.values(e.paths))if(!(!n||`$ref`in n))for(let e of[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`]){let r=n[e];(0,a.isSetString)(r?.summary)&&(r.operationId=t.createOperationId(r.summary))}}},async prepare(){await(0,n.createClient)({...this.config.heyApi,input:this.config.heyApi.schema})}});exports.createOperationId=t.createOperationId,exports.default=c,exports.plugin=c;
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, 1);
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.config.cwd ?? "./", 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.mjs CHANGED
@@ -1,2 +1,87 @@
1
- import{createOperationId as e}from"./helpers/create-operation-id.mjs";import"./helpers/index.mjs";import{createClient as t}from"@hey-api/openapi-ts";import{joinPaths as n}from"@stryke/path/join-paths";import{isSetObject as r}from"@stryke/type-checks/is-set-object";import{isSetString as i}from"@stryke/type-checks/is-set-string";import a from"defu";import{replacePathTokens as o}from"powerlines/plugin-utils";const s=(s={})=>({name:`hey-api`,config(){return{heyApi:{plugins:[{name:`@hey-api/typescript`,exportFromIndex:!1},{name:`@hey-api/sdk`,instance:`PrismaClient`,exportFromIndex:!1,auth:!1},{name:`@hey-api/client-fetch`,throwOnError:!0}],...a(s,{schema:n(this.config.cwd??`./`,this.config.root,`schema.yaml`),output:{path:n(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=o(this,this.config.heyApi.output.path),!this.config.heyApi.schema)throw Error("The `schema` option is required by the Hey API plugin.");if(i(this.config.heyApi.schema)){let e=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await e.json()}if(r(this.config.heyApi.schema)&&this.config.heyApi.schema.paths){let t=this.config.heyApi.schema;for(let n of Object.values(t.paths))if(!(!n||`$ref`in n))for(let t of[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`]){let r=n[t];i(r?.summary)&&(r.operationId=e(r.summary))}}},async prepare(){await t({...this.config.heyApi,input:this.config.heyApi.schema})}});export{e as createOperationId,s as default,s as plugin};
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.config.cwd ?? "./", 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 };
2
87
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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} 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.config.cwd ?? \"./\",\n this.config.root,\n \"schema.yaml\"\n ),\n output: {\n path: joinPaths(\"{builtinPath}\", \"api\")\n },\n logs: this.envPaths.log\n })\n }\n };\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":"yZAkDA,MAAa,GAGX,EAA+B,EAAE,IAE1B,CACL,KAAM,UACN,QAAS,CACP,MAAO,CACL,OAAQ,CACN,QAAS,CACP,CACE,KAAM,sBACN,gBAAiB,GAClB,CACD,CACE,KAAM,eACN,SAAU,eACV,gBAAiB,GACjB,KAAM,GACP,CACD,CACE,KAAM,wBACN,aAAc,GACf,CACF,CACD,GAAG,EAAK,EAAS,CACf,OAAQ,EACN,KAAK,OAAO,KAAO,KACnB,KAAK,OAAO,KACZ,cACD,CACD,OAAQ,CACN,KAAM,EAAU,gBAAiB,MAAM,CACxC,CACD,KAAM,KAAK,SAAS,IACrB,CAAC,CACH,CACF,EAEH,MAAM,gBAAiB,CAOrB,GANA,KAAK,OAAO,OAAO,SAAW,EAAE,CAChC,KAAK,OAAO,OAAO,OAAO,KAAO,EAC/B,KACA,KAAK,OAAO,OAAO,OAAO,KAC3B,CAEG,CAAC,KAAK,OAAO,OAAO,OACtB,MAAU,MACR,yDACD,CAGH,GAAI,EAAY,KAAK,OAAO,OAAO,OAAO,CAAE,CAC1C,IAAM,EAAS,MAAM,KAAK,MAAM,KAAK,OAAO,OAAO,OAAO,CAC1D,KAAK,OAAO,OAAO,OAChB,MAAM,EAAO,MAAM,CAGxB,GACE,EAAY,KAAK,OAAO,OAAO,OAAO,EACrC,KAAK,OAAO,OAAO,OAA0B,MAC9C,CACA,IAAM,EAAS,KAAK,OAAO,OAAO,OAClC,IAAK,IAAM,KAAY,OAAO,OAAO,EAAO,MAAM,CAC5C,MAAC,GAAY,SAAU,GAI3B,IAAK,IAAM,IAAU,CACnB,MACA,MACA,OACA,SACA,UACA,OACA,QACA,QACD,CAAW,CACV,IAAM,EAAY,EAAS,GACtB,EAAY,GAAW,QAAQ,GAIpC,EAAU,YAAc,EAAkB,EAAU,QAAQ,KAKpE,MAAM,SAAU,CACd,MAAM,EAAa,CACjB,GAAG,KAAK,OAAO,OACf,MAAO,KAAK,OAAO,OAAO,OAC3B,CAAe,EAEnB"}
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} 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.config.cwd ?? \"./\",\n this.config.root,\n \"schema.yaml\"\n ),\n output: {\n path: joinPaths(\"{builtinPath}\", \"api\")\n },\n logs: this.envPaths.log\n })\n }\n };\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":";;;;;;;;;;;;;;;;;;AAkDA,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,OAAO,OAAO,MACnB,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"}
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-hey-api",
3
- "version": "0.1.411",
3
+ "version": "0.1.412",
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.12.0",
125
125
  "defu": "^6.1.7",
126
126
  "jiti": "^2.6.1",
127
- "powerlines": "^0.46.4"
127
+ "powerlines": "^0.46.5"
128
128
  },
129
129
  "devDependencies": {
130
- "@powerlines/plugin-plugin": "^0.12.408",
130
+ "@powerlines/plugin-plugin": "^0.12.409",
131
131
  "@types/node": "^25.6.0"
132
132
  },
133
133
  "publishConfig": { "access": "public" },
134
134
  "types": "./dist/index.d.cts",
135
- "gitHead": "2e5eff0d36cb4a1a54242017a16c5af5d9ce2cc3"
135
+ "gitHead": "9af888c54e58a82744cc334a6b80da52429fa0ac"
136
136
  }