@powerlines/plugin-hey-api 0.1.71 → 0.1.72

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 rolldown:runtime
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,16 @@
1
- const e=require(`../_virtual/rolldown_runtime.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`))}exports.createOperationId=n;
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
3
+
4
+ //#region src/helpers/create-operation-id.ts
5
+ /**
6
+ * Create an Operation Id from a summary string
7
+ *
8
+ * @param summary - The summary string from the specification
9
+ * @returns The generated operation ID
10
+ */
11
+ function createOperationId(summary) {
12
+ return (0, __stryke_string_format_camel_case.camelCase)(summary.replace(/\b(?:a|from|to|the|given|of|an)\b/gi, "").replace("Get list", "list"));
13
+ }
14
+
15
+ //#endregion
16
+ exports.createOperationId = createOperationId;
@@ -1 +1,15 @@
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 };
@@ -1 +1,3 @@
1
- const e=require(`./create-operation-id.cjs`);exports.createOperationId=e.createOperationId;
1
+ const require_helpers_create_operation_id = require('./create-operation-id.cjs');
2
+
3
+ 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,92 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/plugin-utils/paths.cjs`),n=require(`./helpers/create-operation-id.cjs`);require(`./helpers/index.cjs`);let r=require(`@hey-api/openapi-ts`),i=require(`@stryke/path/join-paths`),a=require(`@stryke/type-checks/is-set-object`),o=require(`@stryke/type-checks/is-set-string`),s=require(`defu`);s=e.__toESM(s);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,s.default)(e,{schema:(0,i.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:{path:(0,i.joinPaths)(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=t.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,o.isSetString)(this.config.heyApi.schema)){let e=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await e.json()}if((0,a.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 r=t[e];(0,o.isSetString)(r?.summary)&&(r.operationId=n.createOperationId(r.summary))}}},async prepare(){await(0,r.createClient)({...this.config.heyApi,input:this.config.heyApi.schema})}});var l=c;exports.createOperationId=n.createOperationId,exports.default=l,exports.plugin=c;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
4
+ const require_helpers_create_operation_id = require('./helpers/create-operation-id.cjs');
5
+ require('./helpers/index.cjs');
6
+ let __hey_api_openapi_ts = require("@hey-api/openapi-ts");
7
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
8
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
9
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
10
+ let defu = require("defu");
11
+ defu = require_rolldown_runtime.__toESM(defu);
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.projectRoot, "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 = require_paths.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
+ var src_default = plugin;
88
+
89
+ //#endregion
90
+ exports.createOperationId = require_helpers_create_operation_id.createOperationId;
91
+ exports.default = src_default;
92
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,87 @@
1
- import{replacePathTokens as e}from"./powerlines/src/plugin-utils/paths.mjs";import{createOperationId as t}from"./helpers/create-operation-id.mjs";import"./helpers/index.mjs";import{createClient as n}from"@hey-api/openapi-ts";import{joinPaths as r}from"@stryke/path/join-paths";import{isSetObject as i}from"@stryke/type-checks/is-set-object";import{isSetString as a}from"@stryke/type-checks/is-set-string";import o from"defu";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}],...o(s,{schema:r(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:{path:r(`{builtinPath}`,`api`)},logs:this.envPaths.log})}}},async configResolved(){if(this.config.heyApi.output??={},this.config.heyApi.output.path=e(this,this.config.heyApi.output.path),!this.config.heyApi.schema)throw Error("The `schema` option is required by the Hey API plugin.");if(a(this.config.heyApi.schema)){let e=await this.fetch(this.config.heyApi.schema);this.config.heyApi.schema=await e.json()}if(i(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];a(r?.summary)&&(r.operationId=t(r.summary))}}},async prepare(){await n({...this.config.heyApi,input:this.config.heyApi.schema})}});var c=s;export{t as createOperationId,c as default,s as plugin};
1
+ import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
2
+ import { createOperationId } from "./helpers/create-operation-id.mjs";
3
+ import "./helpers/index.mjs";
4
+ import { createClient } from "@hey-api/openapi-ts";
5
+ import { joinPaths } from "@stryke/path/join-paths";
6
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
7
+ import { isSetString } from "@stryke/type-checks/is-set-string";
8
+ import defu from "defu";
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.projectRoot, "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
+ var src_default = plugin;
85
+
86
+ //#endregion
87
+ export { createOperationId, src_default as default, plugin };
@@ -1 +1,36 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/replace`);function n(e,n){return n&&n.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,t.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,t.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,t.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}exports.replacePathTokens=n;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_replace = require("@stryke/path/replace");
3
+
4
+ //#region ../powerlines/src/plugin-utils/paths.ts
5
+ /**
6
+ * Replaces tokens in the given path string with their corresponding values from the context.
7
+ *
8
+ * @remarks
9
+ * The following tokens are supported:
10
+ * - `{workspaceRoot}` - The root directory of the workspace.
11
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
12
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
13
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
14
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
15
+ * - `{cachePath}` - The environment's directory for cached files.
16
+ * - `{dataPath}` - The environment's directory for data files.
17
+ * - `{logPath}` - The environment's directory for log files.
18
+ * - `{tempPath}` - The environment's directory for temporary files.
19
+ * - `{configPath}` - The environment's directory for configuration files.
20
+ * - `{outputPath}` - The configured output directory for the project.
21
+ * - `{buildPath}` - The configured distribution directory for the project.
22
+ * - `{artifactsPath}` - The configured directory for build artifacts.
23
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
24
+ * - `{entryPath}` - The configured directory for generated entry files.
25
+ *
26
+ * @param context - The context containing the values for the path tokens.
27
+ * @param path - The path string with tokens to replace.
28
+ * @returns The path string with tokens replaced by their corresponding values from the context.
29
+ */
30
+ function replacePathTokens(context, path) {
31
+ if (!path) return path;
32
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
33
+ }
34
+
35
+ //#endregion
36
+ exports.replacePathTokens = replacePathTokens;
@@ -1 +1,35 @@
1
- import{replacePath as e}from"@stryke/path/replace";function t(t,n){return n&&n.replaceAll(`{workspaceRoot}`,t.workspaceConfig.workspaceRoot).replaceAll(`{root}`,t.config.projectRoot).replaceAll(`{projectRoot}`,t.config.projectRoot).replaceAll(`{sourceRoot}`,t.config.sourceRoot).replaceAll(`{powerlinesPath}`,t.powerlinesPath).replaceAll(`{cachePath}`,t.cachePath).replaceAll(`{dataPath}`,t.dataPath).replaceAll(`{logPath}`,t.envPaths.log).replaceAll(`{tempPath}`,t.envPaths.temp).replaceAll(`{configPath}`,t.envPaths.config).replaceAll(`{outputPath}`,t.config.output.outputPath).replaceAll(`{buildPath}`,t.config.output.buildPath).replaceAll(`{artifactsPath}`,e(t.artifactsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,e(t.builtinsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,e(t.entryPath,t.workspaceConfig.workspaceRoot))}export{t as replacePathTokens};
1
+ import { replacePath } from "@stryke/path/replace";
2
+
3
+ //#region ../powerlines/src/plugin-utils/paths.ts
4
+ /**
5
+ * Replaces tokens in the given path string with their corresponding values from the context.
6
+ *
7
+ * @remarks
8
+ * The following tokens are supported:
9
+ * - `{workspaceRoot}` - The root directory of the workspace.
10
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
11
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
12
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
13
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
14
+ * - `{cachePath}` - The environment's directory for cached files.
15
+ * - `{dataPath}` - The environment's directory for data files.
16
+ * - `{logPath}` - The environment's directory for log files.
17
+ * - `{tempPath}` - The environment's directory for temporary files.
18
+ * - `{configPath}` - The environment's directory for configuration files.
19
+ * - `{outputPath}` - The configured output directory for the project.
20
+ * - `{buildPath}` - The configured distribution directory for the project.
21
+ * - `{artifactsPath}` - The configured directory for build artifacts.
22
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
23
+ * - `{entryPath}` - The configured directory for generated entry files.
24
+ *
25
+ * @param context - The context containing the values for the path tokens.
26
+ * @param path - The path string with tokens to replace.
27
+ * @returns The path string with tokens replaced by their corresponding values from the context.
28
+ */
29
+ function replacePathTokens(context, path) {
30
+ if (!path) return path;
31
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
32
+ }
33
+
34
+ //#endregion
35
+ export { replacePathTokens };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
304
328
  /**
305
329
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
306
330
  *
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
333
  * @param path - An optional path to write the builtin file to
310
334
  * @param options - Additional options for writing the builtin file
311
335
  */
312
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
313
337
  /**
314
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
315
339
  *
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
304
328
  /**
305
329
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
306
330
  *
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
333
  * @param path - An optional path to write the builtin file to
310
334
  * @param options - Additional options for writing the builtin file
311
335
  */
312
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
313
337
  /**
314
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
315
339
  *
@@ -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.71",
3
+ "version": "0.1.72",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to generate project code using Hey API.",
6
6
  "repository": {
@@ -146,19 +146,19 @@
146
146
  "keywords": ["hey-api", "powerlines", "storm-software", "powerlines-plugin"],
147
147
  "dependencies": {
148
148
  "@hey-api/openapi-ts": "^0.88.2",
149
- "@stryke/path": "^0.24.0",
150
- "@stryke/string-format": "^0.12.29",
151
- "@stryke/type-checks": "^0.5.14",
152
- "@stryke/types": "^0.10.28",
149
+ "@stryke/path": "^0.24.1",
150
+ "@stryke/string-format": "^0.12.30",
151
+ "@stryke/type-checks": "^0.5.15",
152
+ "@stryke/types": "^0.10.29",
153
153
  "defu": "^6.1.4",
154
154
  "jiti": "^2.6.1",
155
- "powerlines": "^0.36.22"
155
+ "powerlines": "^0.36.23"
156
156
  },
157
157
  "devDependencies": {
158
- "@powerlines/nx": "^0.11.48",
159
- "@powerlines/plugin-plugin": "^0.12.69",
158
+ "@powerlines/nx": "^0.11.49",
159
+ "@powerlines/plugin-plugin": "^0.12.70",
160
160
  "@types/node": "^24.10.4"
161
161
  },
162
162
  "publishConfig": { "access": "public" },
163
- "gitHead": "f88fe8eb30f96536b83fc9af884972d48e31e63a"
163
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
164
164
  }