@powerlines/plugin-hey-api 0.1.559 → 0.1.561

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/dist/index.cjs CHANGED
@@ -2,7 +2,10 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_helpers_create_operation_id = require('./helpers/create-operation-id.cjs');
4
4
  require('./helpers/index.cjs');
5
- let _hey_api_openapi_ts = require("@hey-api/openapi-ts");
5
+ let _power_plant_hey_api = require("@power-plant/hey-api");
6
+ _power_plant_hey_api = require_runtime.__toESM(_power_plant_hey_api, 1);
7
+ let _powerlines_plugin_power_plant = require("@powerlines/plugin-power-plant");
8
+ _powerlines_plugin_power_plant = require_runtime.__toESM(_powerlines_plugin_power_plant, 1);
6
9
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
7
10
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
8
11
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
@@ -11,16 +14,20 @@ defu = require_runtime.__toESM(defu, 1);
11
14
  let powerlines_plugin_utils = require("powerlines/plugin-utils");
12
15
 
13
16
  //#region src/index.ts
17
+ function isLoadedDocument(value) {
18
+ return typeof value === "object" && value !== null && !(value instanceof URL);
19
+ }
14
20
  /**
15
- * A Powerlines plugin to integrate Hey API for code generation.
21
+ * A Powerlines plugin to integrate Hey API for code generation via Power Plant.
16
22
  *
17
23
  * @see https://heyapi.dev/
18
24
  *
19
25
  * @param options - The plugin options.
20
- * @returns A Powerlines plugin instance.
26
+ * @returns Powerlines plugin instances.
21
27
  */
22
28
  const plugin = (options = {}) => {
23
- return {
29
+ const generatorConfig = { ..._power_plant_hey_api.default };
30
+ return [(0, _powerlines_plugin_power_plant.default)(generatorConfig), {
24
31
  name: "hey-api",
25
32
  config() {
26
33
  return { heyApi: {
@@ -51,12 +58,12 @@ const plugin = (options = {}) => {
51
58
  this.config.heyApi.output ??= {};
52
59
  this.config.heyApi.output.path = (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.heyApi.output.path);
53
60
  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;
61
+ let document;
62
+ if (isLoadedDocument(this.config.heyApi.schema)) document = this.config.heyApi.schema;
63
+ else if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.heyApi.schema)) document = await (await this.fetch(this.config.heyApi.schema)).json();
64
+ if (!document) throw new Error("Failed to resolve Hey API schema. Provide a loaded OpenAPI document or a fetchable schema URL.");
65
+ if ((0, _stryke_type_checks_is_set_object.isSetObject)(document) && document.paths) {
66
+ const schema = document;
60
67
  for (const pathItem of Object.values(schema.paths)) {
61
68
  if (!pathItem || "$ref" in pathItem) continue;
62
69
  for (const method of [
@@ -75,14 +82,18 @@ const plugin = (options = {}) => {
75
82
  }
76
83
  }
77
84
  }
78
- },
79
- async prepare() {
80
- await (0, _hey_api_openapi_ts.createClient)({
81
- ...this.config.heyApi,
82
- input: this.config.heyApi.schema
83
- });
85
+ this.config.heyApi.schema = document;
86
+ const { schema: _schema, output, ...rest } = this.config.heyApi;
87
+ this.config.powerplant = {
88
+ ...generatorConfig,
89
+ input: document
90
+ };
91
+ this.powerplant.options = {
92
+ ...rest,
93
+ output
94
+ };
84
95
  }
85
- };
96
+ }];
86
97
  };
87
98
 
88
99
  //#endregion
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createOperationId } from "./helpers/create-operation-id.cjs";
2
- import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig } from "./types/plugin.cjs";
2
+ import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions } from "./types/plugin.cjs";
3
3
  import "./types/index.cjs";
4
4
  import { Plugin } from "powerlines";
5
5
  //#region src/index.d.ts
@@ -9,14 +9,14 @@ declare module "powerlines" {
9
9
  }
10
10
  }
11
11
  /**
12
- * A Powerlines plugin to integrate Hey API for code generation.
12
+ * A Powerlines plugin to integrate Hey API for code generation via Power Plant.
13
13
  *
14
14
  * @see https://heyapi.dev/
15
15
  *
16
16
  * @param options - The plugin options.
17
- * @returns A Powerlines plugin instance.
17
+ * @returns Powerlines plugin instances.
18
18
  */
19
- declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
19
+ declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>[];
20
20
  //#endregion
21
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
21
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions, createOperationId, plugin as default, plugin };
22
22
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAqCY;IACR,SAAS;;;;;;;;;;;cAYA,SACX,iBAAiB,sBAAsB,qBAEvC,UAAS,wBACR,OAAO"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAwCY;IACR,SAAS;;;;;;;;;;;cAgBA,SACX,iBAAiB,sBAAsB,qBAEvC,UAAS,wBACR,OAAO"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createOperationId } from "./helpers/create-operation-id.mjs";
2
- import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig } from "./types/plugin.mjs";
2
+ import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions } from "./types/plugin.mjs";
3
3
  import "./types/index.mjs";
4
4
  import { Plugin } from "powerlines";
5
5
  //#region src/index.d.ts
@@ -9,14 +9,14 @@ declare module "powerlines" {
9
9
  }
10
10
  }
11
11
  /**
12
- * A Powerlines plugin to integrate Hey API for code generation.
12
+ * A Powerlines plugin to integrate Hey API for code generation via Power Plant.
13
13
  *
14
14
  * @see https://heyapi.dev/
15
15
  *
16
16
  * @param options - The plugin options.
17
- * @returns A Powerlines plugin instance.
17
+ * @returns Powerlines plugin instances.
18
18
  */
19
- declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>;
19
+ declare const plugin: <TContext extends HeyAPIPluginContext = HeyAPIPluginContext>(options?: HeyAPIPluginOptions) => Plugin<TContext>[];
20
20
  //#endregion
21
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, createOperationId, plugin as default, plugin };
21
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions, createOperationId, plugin as default, plugin };
22
22
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createOperationId } from "./helpers/create-operation-id.mjs";
2
2
  import "./helpers/index.mjs";
3
- import { createClient } from "@hey-api/openapi-ts";
3
+ import heyApiGenerator from "@power-plant/hey-api";
4
+ import powerPlant from "@powerlines/plugin-power-plant";
4
5
  import { joinPaths } from "@stryke/path/join-paths";
5
6
  import { isSetObject } from "@stryke/type-checks/is-set-object";
6
7
  import { isSetString } from "@stryke/type-checks/is-set-string";
@@ -8,16 +9,20 @@ import defu from "defu";
8
9
  import { replacePathTokens } from "powerlines/plugin-utils";
9
10
 
10
11
  //#region src/index.ts
12
+ function isLoadedDocument(value) {
13
+ return typeof value === "object" && value !== null && !(value instanceof URL);
14
+ }
11
15
  /**
12
- * A Powerlines plugin to integrate Hey API for code generation.
16
+ * A Powerlines plugin to integrate Hey API for code generation via Power Plant.
13
17
  *
14
18
  * @see https://heyapi.dev/
15
19
  *
16
20
  * @param options - The plugin options.
17
- * @returns A Powerlines plugin instance.
21
+ * @returns Powerlines plugin instances.
18
22
  */
19
23
  const plugin = (options = {}) => {
20
- return {
24
+ const generatorConfig = { ...heyApiGenerator };
25
+ return [powerPlant(generatorConfig), {
21
26
  name: "hey-api",
22
27
  config() {
23
28
  return { heyApi: {
@@ -48,12 +53,12 @@ const plugin = (options = {}) => {
48
53
  this.config.heyApi.output ??= {};
49
54
  this.config.heyApi.output.path = replacePathTokens(this, this.config.heyApi.output.path);
50
55
  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;
56
+ let document;
57
+ if (isLoadedDocument(this.config.heyApi.schema)) document = this.config.heyApi.schema;
58
+ else if (isSetString(this.config.heyApi.schema)) document = await (await this.fetch(this.config.heyApi.schema)).json();
59
+ if (!document) throw new Error("Failed to resolve Hey API schema. Provide a loaded OpenAPI document or a fetchable schema URL.");
60
+ if (isSetObject(document) && document.paths) {
61
+ const schema = document;
57
62
  for (const pathItem of Object.values(schema.paths)) {
58
63
  if (!pathItem || "$ref" in pathItem) continue;
59
64
  for (const method of [
@@ -72,14 +77,18 @@ const plugin = (options = {}) => {
72
77
  }
73
78
  }
74
79
  }
75
- },
76
- async prepare() {
77
- await createClient({
78
- ...this.config.heyApi,
79
- input: this.config.heyApi.schema
80
- });
80
+ this.config.heyApi.schema = document;
81
+ const { schema: _schema, output, ...rest } = this.config.heyApi;
82
+ this.config.powerplant = {
83
+ ...generatorConfig,
84
+ input: document
85
+ };
86
+ this.powerplant.options = {
87
+ ...rest,
88
+ output
89
+ };
81
90
  }
82
- };
91
+ }];
83
92
  };
84
93
 
85
94
  //#endregion
@@ -1,2 +1,2 @@
1
- import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig } from "./plugin.cjs";
2
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig };
1
+ import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions } from "./plugin.cjs";
2
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions };
@@ -1,2 +1,2 @@
1
- import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig } from "./plugin.mjs";
2
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig };
1
+ import { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions } from "./plugin.mjs";
2
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions };
@@ -1,6 +1,9 @@
1
- import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
1
+ import { ResolvedConfig, UserConfig } from "powerlines";
2
2
  import { OpenApi, UserConfig as UserConfig$1 } from "@hey-api/openapi-ts";
3
+ import { PowerPlantPluginContext, PowerPlantPluginResolvedConfig } from "@powerlines/plugin-power-plant/types/plugin";
4
+ import { Arrayable } from "@stryke/types/array";
3
5
  //#region src/types/plugin.d.ts
6
+ type PowerPlantHeyAPIOptions = Arrayable<Omit<UserConfig$1, "input">>;
4
7
  type HeyAPIPluginOutputOptions = UserConfig$1["output"] & {
5
8
  /**
6
9
  * The path to the output file generated by the plugin.
@@ -30,12 +33,12 @@ type HeyAPIPluginOptions = Omit<UserConfig$1, "input" | "output" | "schema"> & {
30
33
  type HeyAPIPluginUserConfig = UserConfig & {
31
34
  heyApi?: HeyAPIPluginOptions;
32
35
  };
33
- type HeyAPIPluginResolvedConfig = ResolvedConfig & {
36
+ type HeyAPIPluginResolvedConfig = ResolvedConfig & PowerPlantPluginResolvedConfig<Record<string, unknown>, PowerPlantHeyAPIOptions> & {
34
37
  heyApi: Omit<HeyAPIPluginOptions, "schema"> & {
35
38
  schema: HeyAPIPluginOptions["schema"] | OpenApi.V3_0_X;
36
39
  };
37
40
  };
38
- type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PluginContext<TResolvedConfig>;
41
+ type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PowerPlantPluginContext<Record<string, unknown>, PowerPlantHeyAPIOptions, TResolvedConfig>;
39
42
  //#endregion
40
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig };
43
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions };
41
44
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;KAsBY,4BAA4B;;;;;;;;;EAStC;;KAGU,sBAAsB,KAChC;;;;;;;;;EAWA,SAAS;;;;EAKT,SAAS;;KAGC,yBAAyB;EACnC,SAAS;;KAGC,6BAA6B;EACvC,QAAQ,KAAK;IACX,QAAQ,gCAAgC,QAAQ;;;KAIxC,oBACV,wBAAwB,6BACtB,8BACA,cAAc"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;KA2BY,0BAA0B,UACpC,KAAK;KAGK,4BAA4B;;;;;;;;;EAStC;;KAGU,sBAAsB,KAChC;;;;;;;;;EAWA,SAAS;;;;EAKT,SAAS;;KAGC,yBAAyB;EACnC,SAAS;;KAGC,6BAA6B,iBACvC,+BACE,yBACA;EAEA,QAAQ,KAAK;IACX,QAAQ,gCAAgC,QAAQ;;;KAI1C,oBACV,wBAAwB,6BACtB,8BACA,wBACF,yBACA,yBACA"}
@@ -1,7 +1,10 @@
1
- import { OpenApi, UserConfig } from "@hey-api/openapi-ts";
2
- import { PluginContext, ResolvedConfig, UserConfig as UserConfig$1 } from "powerlines";
1
+ import { ResolvedConfig, UserConfig } from "powerlines";
2
+ import { OpenApi, UserConfig as UserConfig$1 } from "@hey-api/openapi-ts";
3
+ import { PowerPlantPluginContext, PowerPlantPluginResolvedConfig } from "@powerlines/plugin-power-plant/types/plugin";
4
+ import { Arrayable } from "@stryke/types/array";
3
5
  //#region src/types/plugin.d.ts
4
- type HeyAPIPluginOutputOptions = UserConfig["output"] & {
6
+ type PowerPlantHeyAPIOptions = Arrayable<Omit<UserConfig$1, "input">>;
7
+ type HeyAPIPluginOutputOptions = UserConfig$1["output"] & {
5
8
  /**
6
9
  * The path to the output file generated by the plugin.
7
10
  *
@@ -12,7 +15,7 @@ type HeyAPIPluginOutputOptions = UserConfig["output"] & {
12
15
  */
13
16
  path?: string;
14
17
  };
15
- type HeyAPIPluginOptions = Omit<UserConfig, "input" | "output" | "schema"> & {
18
+ type HeyAPIPluginOptions = Omit<UserConfig$1, "input" | "output" | "schema"> & {
16
19
  /**
17
20
  * The path to the Hey API schema file.
18
21
  *
@@ -21,21 +24,21 @@ type HeyAPIPluginOptions = Omit<UserConfig, "input" | "output" | "schema"> & {
21
24
  *
22
25
  * @defaultValue "\{root\}/schema.yaml"
23
26
  */
24
- schema?: UserConfig["input"];
27
+ schema?: UserConfig$1["input"];
25
28
  /**
26
29
  * The output details of the Hey API generation
27
30
  */
28
31
  output?: HeyAPIPluginOutputOptions;
29
32
  };
30
- type HeyAPIPluginUserConfig = UserConfig$1 & {
33
+ type HeyAPIPluginUserConfig = UserConfig & {
31
34
  heyApi?: HeyAPIPluginOptions;
32
35
  };
33
- type HeyAPIPluginResolvedConfig = ResolvedConfig & {
36
+ type HeyAPIPluginResolvedConfig = ResolvedConfig & PowerPlantPluginResolvedConfig<Record<string, unknown>, PowerPlantHeyAPIOptions> & {
34
37
  heyApi: Omit<HeyAPIPluginOptions, "schema"> & {
35
38
  schema: HeyAPIPluginOptions["schema"] | OpenApi.V3_0_X;
36
39
  };
37
40
  };
38
- type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PluginContext<TResolvedConfig>;
41
+ type HeyAPIPluginContext<TResolvedConfig extends HeyAPIPluginResolvedConfig = HeyAPIPluginResolvedConfig> = PowerPlantPluginContext<Record<string, unknown>, PowerPlantHeyAPIOptions, TResolvedConfig>;
39
42
  //#endregion
40
- export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig };
43
+ export { HeyAPIPluginContext, HeyAPIPluginOptions, HeyAPIPluginOutputOptions, HeyAPIPluginResolvedConfig, HeyAPIPluginUserConfig, PowerPlantHeyAPIOptions };
41
44
  //# sourceMappingURL=plugin.d.mts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-hey-api",
3
- "version": "0.1.559",
3
+ "version": "0.1.561",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to generate project code using Hey API.",
6
6
  "repository": {
@@ -118,19 +118,22 @@
118
118
  "keywords": ["hey-api", "powerlines", "storm-software", "powerlines-plugin"],
119
119
  "dependencies": {
120
120
  "@hey-api/openapi-ts": "^0.88.2",
121
- "@stryke/path": "^0.29.22",
122
- "@stryke/string-format": "^0.17.37",
123
- "@stryke/type-checks": "^0.6.28",
124
- "@stryke/types": "^0.12.23",
121
+ "@power-plant/core": "^0.0.23",
122
+ "@power-plant/hey-api": "^0.0.19",
123
+ "@powerlines/plugin-power-plant": "^0.1.2",
124
+ "@stryke/path": "^0.29.23",
125
+ "@stryke/string-format": "^0.17.38",
126
+ "@stryke/type-checks": "^0.6.29",
127
+ "@stryke/types": "^0.12.24",
125
128
  "defu": "^6.1.7",
126
129
  "jiti": "^2.7.0",
127
- "powerlines": "^0.47.144"
130
+ "powerlines": "^0.47.146"
128
131
  },
129
132
  "devDependencies": {
130
- "@powerlines/plugin-plugin": "^0.12.556",
133
+ "@powerlines/plugin-plugin": "^0.12.558",
131
134
  "@types/node": "^25.9.5"
132
135
  },
133
136
  "publishConfig": { "access": "public" },
134
137
  "types": "./dist/index.d.cts",
135
- "gitHead": "cf8953be1a53bac9ad8c227195a662cbb422d43c"
138
+ "gitHead": "e86d6fab3bd4d2e2f9f6d05df8df7a07d399857e"
136
139
  }