@powerlines/plugin-hey-api 0.1.0 → 0.1.2
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/README.md +8 -2
- package/dist/{helpers/create-operation-id.d.ts → create-operation-id-DDMlsM4b.d.cts} +4 -2
- package/dist/create-operation-id-DDMlsM4b.d.cts.map +1 -0
- package/dist/create-operation-id-Ev32XkjT.cjs +1 -0
- package/dist/create-operation-id-Pg4z72Yn.mjs +2 -0
- package/dist/create-operation-id-Pg4z72Yn.mjs.map +1 -0
- package/dist/create-operation-id-_82tqUNg.d.mts +11 -0
- package/dist/create-operation-id-_82tqUNg.d.mts.map +1 -0
- package/dist/helpers/create-operation-id.cjs +1 -7
- package/dist/helpers/create-operation-id.d.cts +2 -9
- package/dist/helpers/create-operation-id.d.mts +2 -0
- package/dist/helpers/create-operation-id.mjs +1 -0
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.d.cts +3 -1
- package/dist/helpers/index.d.mts +3 -0
- package/dist/helpers/index.mjs +1 -0
- package/dist/helpers-CRPRhztf.mjs +1 -0
- package/dist/index-9iG2qHLe.d.mts +1 -0
- package/dist/index-D-CYNcT9.d.mts +1 -0
- package/dist/index-D4ELpJXS.d.cts +1 -0
- package/dist/index-DLoAMD9J.d.cts +1 -0
- package/dist/index.cjs +1 -7
- package/dist/index.d.cts +9 -27
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin-BjiGfRHE.mjs +1 -0
- package/dist/plugin-BqyODGNU.d.mts +1683 -0
- package/dist/plugin-BqyODGNU.d.mts.map +1 -0
- package/dist/plugin-DV8Xp4rR.d.cts +1683 -0
- package/dist/plugin-DV8Xp4rR.d.cts.map +1 -0
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +3 -23
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +1 -1
- package/dist/types/plugin.d.cts +2 -23
- package/dist/types/plugin.d.mts +2 -0
- package/dist/types/plugin.mjs +1 -0
- package/dist/types-n6NgD0QK.mjs +1 -0
- package/dist/types-o3zWarRp.cjs +0 -0
- package/package.json +51 -33
- package/dist/chunk-FBBMZ4NC.cjs +0 -7
- package/dist/chunk-UCUR73HG.js +0 -7
- package/dist/helpers/create-operation-id.js +0 -7
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -1
- package/dist/index-D07O8wGD.d.cts +0 -1594
- package/dist/index-D07O8wGD.d.ts +0 -1594
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -7
- package/dist/types/index.d.ts +0 -23
- package/dist/types/index.js +0 -1
- package/dist/types/plugin.d.ts +0 -23
- /package/dist/{types/plugin.js → helpers-LF26RHol.cjs} +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
<div align="center"
|
|
6
|
+
<div align="center">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-light-optimized.gif">
|
|
10
|
+
<img src="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif" width="100%" alt="Powerlines" />
|
|
11
|
+
</picture>
|
|
12
|
+
</div>
|
|
7
13
|
<br />
|
|
8
14
|
|
|
9
15
|
<div align="center">
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
</div>
|
|
17
23
|
|
|
18
24
|
<br />
|
|
19
|
-
This package is part of the
|
|
25
|
+
This package is part of the 🔌 <b>Powerlines</b> monorepo. Powerlines packages include CLI utility applications, tools, and various libraries used to create modern, scalable web applications.
|
|
20
26
|
<br />
|
|
21
27
|
|
|
22
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/helpers/create-operation-id.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Create an Operation Id from a summary string
|
|
3
4
|
*
|
|
@@ -5,5 +6,6 @@
|
|
|
5
6
|
* @returns The generated operation ID
|
|
6
7
|
*/
|
|
7
8
|
declare function createOperationId(summary: string): string;
|
|
8
|
-
|
|
9
|
-
export { createOperationId };
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createOperationId as t };
|
|
11
|
+
//# sourceMappingURL=create-operation-id-DDMlsM4b.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-operation-id-DDMlsM4b.d.cts","names":[],"sources":["../src/helpers/create-operation-id.ts"],"sourcesContent":[],"mappings":";;AA0BA;;;;;iBAAgB,iBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./index.cjs`);let t=require(`@stryke/string-format/camel-case`);function n(e){return(0,t.camelCase)(e.replace(/\b(?:a|from|to|the|given|of|an)\b/gi,``).replace(`Get list`,`list`))}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-operation-id-Pg4z72Yn.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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 as t };
|
|
11
|
+
//# sourceMappingURL=create-operation-id-_82tqUNg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-operation-id-_82tqUNg.d.mts","names":[],"sources":["../src/helpers/create-operation-id.ts"],"sourcesContent":[],"mappings":";;AA0BA;;;;;iBAAgB,iBAAA"}
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
function o(t){return camelCase.camelCase(t.replace(/\b(?:a|from|to|the|given|of|an)\b/gi,"").replace("Get list","list"))}chunkFBBMZ4NC_cjs.a(o,"createOperationId");exports.createOperationId=o;
|
|
1
|
+
const e=require(`../create-operation-id-Ev32XkjT.cjs`);exports.createOperationId=e.t;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @param summary - The summary string from the specification
|
|
5
|
-
* @returns The generated operation ID
|
|
6
|
-
*/
|
|
7
|
-
declare function createOperationId(summary: string): string;
|
|
8
|
-
|
|
9
|
-
export { createOperationId };
|
|
1
|
+
import { t as createOperationId } from "../create-operation-id-DDMlsM4b.cjs";
|
|
2
|
+
export { createOperationId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../create-operation-id-Pg4z72Yn.mjs";export{e as createOperationId};
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../create-operation-id-Ev32XkjT.cjs`);require(`../helpers-LF26RHol.cjs`),exports.createOperationId=e.t;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../create-operation-id-Pg4z72Yn.mjs";import"../helpers-CRPRhztf.mjs";export{e as createOperationId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
const u=chunkFBBMZ4NC_cjs.a((s={})=>({name:"hey-api",config(){return {heyApi:{plugins:[{name:"@hey-api/typescript",exportFromIndex:false},{name:"@hey-api/sdk",instance:"PrismaClient",exportFromIndex:false,auth:false},{name:"@hey-api/client-fetch",throwOnError:true}],...c__default.default(s,{schema:joinPaths.joinPaths(this.workspaceConfig.workspaceRoot,this.config.projectRoot,"schema.yaml"),output:{path:joinPaths.joinPaths("{builtinPath}","api")},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=paths.replacePathTokens(this,this.config.heyApi.output.path),!this.config.heyApi.schema)throw new Error("The `schema` option is required by the Hey API plugin.");if(isSetString.isSetString(this.config.heyApi.schema)){const t=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await t.json();}if(isSetObject.isSetObject(this.config.heyApi.schema)&&this.config.heyApi.schema.paths){const t=this.config.heyApi.schema;for(const e of Object.values(t.paths))if(!(!e||"$ref"in e))for(const a of ["get","put","post","delete","options","head","patch","trace"]){const i=e[a];isSetString.isSetString(i?.summary)&&(i.operationId=createOperationId.createOperationId(i.summary));}}},async prepare(){await openapiTs.createClient({...this.config.heyApi,input:this.config.heyApi.schema});}}),"plugin");var T=u;exports.default=T;exports.plugin=u;Object.keys(helpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return helpers[k]}})});Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});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));const c=require(`./create-operation-id-Ev32XkjT.cjs`);require(`./helpers-LF26RHol.cjs`),require(`./plugin-pBKbb5K9.cjs`),require(`./types-o3zWarRp.cjs`);let l=require(`@hey-api/openapi-ts`),u=require(`@stryke/path/join-paths`),d=require(`@stryke/type-checks/is-set-object`),f=require(`@stryke/type-checks/is-set-string`),p=require(`defu`);p=s(p);let m=require(`@stryke/path/replace`);function h(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,m.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,m.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,m.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}const g=(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,p.default)(e,{schema:(0,u.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:{path:(0,u.joinPaths)(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=h(this,this.config.heyApi.output.path),!this.config.heyApi.schema)throw Error("The `schema` option is required by the Hey API plugin.");if((0,f.isSetString)(this.config.heyApi.schema)){let e=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await e.json()}if((0,d.isSetObject)(this.config.heyApi.schema)&&this.config.heyApi.schema.paths){let e=this.config.heyApi.schema;for(let t of Object.values(e.paths))if(!(!t||`$ref`in t))for(let e of[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`]){let n=t[e];(0,f.isSetString)(n?.summary)&&(n.operationId=c.t(n.summary))}}},async prepare(){await(0,l.createClient)({...this.config.heyApi,input:this.config.heyApi.schema})}});var _=g;exports.createOperationId=c.t,exports.default=_,exports.plugin=g,exports.t=s;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import '@storm-software/config/types';
|
|
8
|
-
import '@stryke/types/base';
|
|
9
|
-
import '@stryke/types/configuration';
|
|
10
|
-
import '@stryke/types/file';
|
|
11
|
-
import 'vite';
|
|
12
|
-
import '@stryke/env/get-env-paths';
|
|
13
|
-
import '@stryke/http/fetch';
|
|
14
|
-
import '@stryke/types/package-json';
|
|
15
|
-
import 'jiti';
|
|
16
|
-
import 'magic-string';
|
|
17
|
-
import 'oxc-parser';
|
|
18
|
-
import 'semver';
|
|
19
|
-
import 'ts-morph';
|
|
20
|
-
import 'undici';
|
|
21
|
-
import 'unplugin';
|
|
22
|
-
import '@stryke/fs/resolve';
|
|
23
|
-
import '@stryke/types/tsconfig';
|
|
24
|
-
import 'typescript';
|
|
25
|
-
import '@stryke/types/array';
|
|
1
|
+
import { t as createOperationId } from "./create-operation-id-DDMlsM4b.cjs";
|
|
2
|
+
import "./index-DLoAMD9J.cjs";
|
|
3
|
+
import { a as HeyAPIPluginUserConfig, c as __ΩHeyAPIPluginOutputOptions, d as Plugin, i as HeyAPIPluginResolvedConfig, l as __ΩHeyAPIPluginResolvedConfig, n as HeyAPIPluginOptions, o as __ΩHeyAPIPluginContext, r as HeyAPIPluginOutputOptions, s as __ΩHeyAPIPluginOptions, t as HeyAPIPluginContext, u as __ΩHeyAPIPluginUserConfig } from "./plugin-DV8Xp4rR.cjs";
|
|
4
|
+
import "./index-D4ELpJXS.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/index.d.ts
|
|
26
7
|
|
|
27
8
|
/**
|
|
28
9
|
* A Powerlines plugin to integrate Hey API for code generation.
|
|
@@ -33,5 +14,6 @@ import '@stryke/types/array';
|
|
|
33
14
|
* @returns A Powerlines plugin instance.
|
|
34
15
|
*/
|
|
35
16
|
declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
|
|
36
|
-
|
|
37
|
-
export { HeyAPIPluginContext, HeyAPIPluginOptions, plugin as default, plugin };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
|
|
19
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA6CA;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,mBAGV,GAHgC,mBAGhC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as createOperationId } from "./create-operation-id-_82tqUNg.mjs";
|
|
2
|
+
import "./index-D-CYNcT9.mjs";
|
|
3
|
+
import { a as HeyAPIPluginUserConfig, c as __ΩHeyAPIPluginOutputOptions, d as Plugin, i as HeyAPIPluginResolvedConfig, l as __ΩHeyAPIPluginResolvedConfig, n as HeyAPIPluginOptions, o as __ΩHeyAPIPluginContext, r as HeyAPIPluginOutputOptions, s as __ΩHeyAPIPluginOptions, t as HeyAPIPluginContext, u as __ΩHeyAPIPluginUserConfig } from "./plugin-BqyODGNU.mjs";
|
|
4
|
+
import "./index-9iG2qHLe.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/index.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A Powerlines plugin to integrate Hey API for code generation.
|
|
10
|
+
*
|
|
11
|
+
* @see https://heyapi.dev/
|
|
12
|
+
*
|
|
13
|
+
* @param options - The plugin options.
|
|
14
|
+
* @returns A Powerlines plugin instance.
|
|
15
|
+
*/
|
|
16
|
+
declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, __ΩHeyAPIPluginContext, __ΩHeyAPIPluginOptions, __ΩHeyAPIPluginOutputOptions, __ΩHeyAPIPluginResolvedConfig, __ΩHeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
|
|
19
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA6CA;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,mBAGV,GAHgC,mBAGhC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./create-operation-id-Pg4z72Yn.mjs";import"./helpers-CRPRhztf.mjs";import"./plugin-BjiGfRHE.mjs";import"./types-n6NgD0QK.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{replacePath as o}from"@stryke/path/replace";function s(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,o(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,o(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,o(e.entryPath,e.workspaceConfig.workspaceRoot))}const c=(o={})=>({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(o,{schema:n(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:{path:n(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=s(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})}});var l=c;export{e as createOperationId,l as default,c as plugin};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../powerlines/src/plugin-utils/paths.ts","../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 { replacePath } from \"@stryke/path/replace\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{workspaceRoot}` - The root directory of the workspace.\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `./src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{buildPath}` - The configured distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n return path\n .replaceAll(\"{workspaceRoot}\", context.workspaceConfig.workspaceRoot)\n .replaceAll(\"{root}\", context.config.projectRoot)\n .replaceAll(\"{projectRoot}\", context.config.projectRoot)\n .replaceAll(\"{sourceRoot}\", context.config.sourceRoot)\n .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\"{outputPath}\", context.config.output.outputPath)\n .replaceAll(\"{buildPath}\", context.config.output.buildPath)\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n );\n}\n","/* -------------------------------------------------------------------\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 { replacePathTokens } from \"powerlines/plugin-utils/paths\";\nimport { Plugin } from \"powerlines/types/plugin\";\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\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.projectRoot,\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 = (await result.json()) as OpenApi.V3_0_X;\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":"+bA+CA,SAAgB,EACd,EACA,EAC4D,CAK5D,OAJK,GAIE,EACJ,WAAW,kBAAmB,EAAQ,gBAAgB,cAAc,CACpE,WAAW,SAAU,EAAQ,OAAO,YAAY,CAChD,WAAW,gBAAiB,EAAQ,OAAO,YAAY,CACvD,WAAW,eAAgB,EAAQ,OAAO,WAAW,CACrD,WAAW,mBAAoB,EAAQ,eAAe,CACtD,WAAW,cAAe,EAAQ,UAAU,CAC5C,WAAW,aAAc,EAAQ,SAAS,CAC1C,WAAW,YAAa,EAAQ,SAAS,IAAI,CAC7C,WAAW,aAAc,EAAQ,SAAS,KAAK,CAC/C,WAAW,eAAgB,EAAQ,SAAS,OAAO,CACnD,WAAW,eAAgB,EAAQ,OAAO,OAAO,WAAW,CAC5D,WAAW,cAAe,EAAQ,OAAO,OAAO,UAAU,CAC1D,WACC,kBACA,EAAY,EAAQ,cAAe,EAAQ,gBAAgB,cAAc,CAC1E,CACA,WACC,gBACA,EAAY,EAAQ,aAAc,EAAQ,gBAAgB,cAAc,CACzE,CACA,WACC,cACA,EAAY,EAAQ,UAAW,EAAQ,gBAAgB,cAAc,CACtE,CClCL,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,gBAAgB,cACrB,KAAK,OAAO,YACZ,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,OAAU,MAAM,EAAO,MAAM,CAGlD,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,EAGH,IAAA,EAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|