@powerlines/plugin-open-feature 0.1.7 → 0.1.8

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.
@@ -68,6 +68,22 @@ function FeaturesBuiltin(props) {
68
68
  children: _alloy_js_core.code`OpenFeature.getClient(); `
69
69
  }),
70
70
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
71
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
72
+ name: "feature",
73
+ "export": true,
74
+ async: true,
75
+ parameters: [{
76
+ name: "featureId",
77
+ type: "string"
78
+ }],
79
+ returnType: "Promise<boolean>",
80
+ children: _alloy_js_core.code`try {
81
+ return client.getBooleanValue(featureId);
82
+ } catch (error) {
83
+ console.error('Failed to initialize provider:', error);
84
+ } `
85
+ }),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
71
87
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
72
88
  get when() {
73
89
  return Boolean(children);
@@ -65,6 +65,22 @@ function FeaturesBuiltin(props) {
65
65
  children: code`OpenFeature.getClient(); `
66
66
  }),
67
67
  createComponent(Spacing, {}),
68
+ createComponent(FunctionDeclaration, {
69
+ name: "feature",
70
+ "export": true,
71
+ async: true,
72
+ parameters: [{
73
+ name: "featureId",
74
+ type: "string"
75
+ }],
76
+ returnType: "Promise<boolean>",
77
+ children: code`try {
78
+ return client.getBooleanValue(featureId);
79
+ } catch (error) {
80
+ console.error('Failed to initialize provider:', error);
81
+ } `
82
+ }),
83
+ createComponent(Spacing, {}),
68
84
  createComponent(Show, {
69
85
  get when() {
70
86
  return Boolean(children);
@@ -1 +1 @@
1
- {"version":3,"file":"features-builtin.mjs","names":[],"sources":["../../src/components/features-builtin.tsx"],"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 { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration, VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface FeaturesBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {}\n\n/**\n * Generates the feature flags module for the Powerlines project.\n */\nexport function FeaturesBuiltin(props: FeaturesBuiltinProps) {\n const [{ children, imports }, rest] = splitProps(props, [\n \"children\",\n \"imports\"\n ]);\n\n // const context = usePowerlines<OpenFeaturePluginContext>();\n\n return (\n <BuiltinFile\n id=\"features\"\n description=\"The runtime feature flags module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@openfeature/server-sdk\": [\n { name: \"OpenFeature\" },\n { name: \"Provider\", type: true },\n { name: \"ProviderWrapper\", type: true },\n { name: \"ServerProviderStatus\", type: true }\n ]\n },\n imports ?? {}\n )}>\n <TSDoc>\n {code`A function to set the OpenFeature providers to be used in the application. This function should be called at the entry point of the application to ensure that the providers are registered before any feature flag evaluations occur.`}\n\n <TSDocParam name=\"provider\">\n {`The provider wrapper containing the OpenFeature provider to set. The provider should be an instance of a class that implements the OpenFeature Provider interface, wrapped in a ProviderWrapper to include any necessary metadata about the provider's status.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"setFeatureProvider\"\n export\n async\n parameters={[\n {\n name: \"provider\",\n type: \"ProviderWrapper<Provider, ServerProviderStatus>\"\n }\n ]}>\n {code`try {\n await OpenFeature.setProviderAndWait(provider);\n } catch (error) {\n console.error('Failed to initialize provider:', error);\n } `}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n name=\"client\"\n export={true}\n const={true}\n doc=\"The Open Feature runtime client to provide feature flag evaluations.\"\n type=\"ReturnType<typeof OpenFeature.getClient>\">\n {code`OpenFeature.getClient(); `}\n </VarDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;CA+BA,MAAO,CAAA,YAEL,WACC,QAAU,WAAW,OAAO,CAAA,YAAW,UAAI,CAAA;AAI5C,QAAG,gBAAS,aAAA,WAAA;EACV,IAAC;EACD,aAAA;;EAEA,IAAC,UAAa;iBAEV,2BAAC;IAAA,EACJ,MAAA,eACI;IAAC;KACJ,MAAA;KACI,MAAI;KACR;IAAA;KACE,MAAA;KACE,MAAE;KACH;IAAE;KACD,MAAI;KACJ,MAAI;KACL;IAAC,EACH,EAAE,WAAC,EAAA,CAAA;;EAEN,IAAI,WAAW;AACb,UAAE;IAAA,gBAAA,OAAA,EACD,IAAK,WAAA;AACH,YAAO,CAAA,IAAA,0OAAqO,gBAAA,YAAA;;MAE5O,UAAW;MACT,CAAC,CAAA;OAEL,CAAC;IAAA,gBAAK,qBAAA;KACN,MAAA;KACC,UAAM;KACN,OAAA;KACA,YAAA,CAAA;MACA,MAAA;MACE,MAAA;MACD,CAAC;KACF,UAAU,IAAC;;;;;KAKZ,CAAC;IAAE,gBAAc,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KAChB,MAAE;KACF,UAAG;KACH,SAAA;KACD,KAAA;KACA,MAAA;KACC,UAAM,IAAM;KACb,CAAC;IAAA,gBAAY,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACZ,IAAA,OAAW;AACX,aAAS,QAAK,SAAQ;;KAEhB;KACP,CAAC;IAAA;;EAEL,CAAC,CAAC"}
1
+ {"version":3,"file":"features-builtin.mjs","names":[],"sources":["../../src/components/features-builtin.tsx"],"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 { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration, VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface FeaturesBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {}\n\n/**\n * Generates the feature flags module for the Powerlines project.\n */\nexport function FeaturesBuiltin(props: FeaturesBuiltinProps) {\n const [{ children, imports }, rest] = splitProps(props, [\n \"children\",\n \"imports\"\n ]);\n\n // const context = usePowerlines<OpenFeaturePluginContext>();\n\n return (\n <BuiltinFile\n id=\"features\"\n description=\"The runtime feature flags module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@openfeature/server-sdk\": [\n { name: \"OpenFeature\" },\n { name: \"Provider\", type: true },\n { name: \"ProviderWrapper\", type: true },\n { name: \"ServerProviderStatus\", type: true }\n ]\n },\n imports ?? {}\n )}>\n <TSDoc>\n {code`A function to set the OpenFeature providers to be used in the application. This function should be called at the entry point of the application to ensure that the providers are registered before any feature flag evaluations occur.`}\n\n <TSDocParam name=\"provider\">\n {`The provider wrapper containing the OpenFeature provider to set. The provider should be an instance of a class that implements the OpenFeature Provider interface, wrapped in a ProviderWrapper to include any necessary metadata about the provider's status.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"setFeatureProvider\"\n export\n async\n parameters={[\n {\n name: \"provider\",\n type: \"ProviderWrapper<Provider, ServerProviderStatus>\"\n }\n ]}>\n {code`try {\n await OpenFeature.setProviderAndWait(provider);\n } catch (error) {\n console.error('Failed to initialize provider:', error);\n } `}\n </FunctionDeclaration>\n <Spacing />\n <VarDeclaration\n name=\"client\"\n export\n const\n doc=\"The Open Feature runtime client to provide feature flag evaluations.\"\n type=\"ReturnType<typeof OpenFeature.getClient>\">\n {code`OpenFeature.getClient(); `}\n </VarDeclaration>\n <Spacing />\n <FunctionDeclaration\n name=\"feature\"\n export\n async\n parameters={[\n {\n name: \"featureId\",\n type: \"string\"\n }\n ]}\n returnType=\"Promise<boolean>\">\n {code`try {\n return client.getBooleanValue(featureId);\n } catch (error) {\n console.error('Failed to initialize provider:', error);\n } `}\n </FunctionDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;CA+BA,MAAO,CAAA,YAEL,WACC,QAAU,WAAW,OAAO,CAAA,YAAW,UAAI,CAAA;AAI5C,QAAG,gBAAS,aAAA,WAAA;EACV,IAAC;EACD,aAAA;;EAEA,IAAC,UAAa;iBAEV,2BAAC;IAAA,EACJ,MAAA,eACI;IAAC;KACJ,MAAA;KACI,MAAI;KACR;IAAA;KACE,MAAA;KACE,MAAE;KACH;IAAE;KACD,MAAI;KACJ,MAAI;KACL;IAAC,EACH,EAAE,WAAC,EAAA,CAAA;;EAEN,IAAI,WAAW;AACb,UAAE;IAAA,gBAAA,OAAA,EACD,IAAK,WAAA;AACH,YAAO,CAAA,IAAA,0OAAqO,gBAAA,YAAA;;MAE5O,UAAW;MACT,CAAC,CAAA;OAEL,CAAC;IAAA,gBAAK,qBAAA;KACN,MAAA;KACC,UAAM;KACN,OAAA;KACA,YAAA,CAAA;MACA,MAAA;MACE,MAAA;MACD,CAAC;KACF,UAAU,IAAC;;;;;KAKZ,CAAC;IAAE,gBAAc,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KAChB,MAAE;KACF,UAAG;KACH,SAAA;KACD,KAAA;KACA,MAAA;KACC,UAAM,IAAM;KACb,CAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,qBAAA;KACA,MAAA;KACA,UAAS;KACT,OAAM;KACN,YAAM,CAAA;MACN,MAAA;MACD,MAAS;MACT,CAAA;KACC,YAAM;KACN,UAAA,IAAA;;;;;KAKD,CAAC;IAAE,gBAAe,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACjB,IAAE,OAAA;AACD,aAAA,QAAA,SAAA;;KAES;KACX,CAAC;IAAC;;EAEN,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-open-feature",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "description": "A package containing a Powerlines plugin for managing Open Feature feature flags at runtime.",
6
6
  "keywords": [
@@ -171,9 +171,9 @@
171
171
  "@alloy-js/typescript": "0.23.0-dev.4",
172
172
  "@openfeature/core": "^1.9.2",
173
173
  "@openfeature/server-sdk": "^1.20.2",
174
- "@powerlines/plugin-alloy": "^0.26.2",
175
- "@powerlines/plugin-automd": "^0.1.386",
176
- "@powerlines/plugin-plugin": "^0.12.337",
174
+ "@powerlines/plugin-alloy": "^0.26.3",
175
+ "@powerlines/plugin-automd": "^0.1.387",
176
+ "@powerlines/plugin-plugin": "^0.12.338",
177
177
  "@storm-software/config-tools": "^1.189.72",
178
178
  "@stryke/convert": "^0.6.57",
179
179
  "@stryke/env": "^0.20.81",
@@ -185,15 +185,15 @@
185
185
  "@stryke/types": "^0.11.2",
186
186
  "automd": "^0.4.3",
187
187
  "defu": "^6.1.6",
188
- "powerlines": "^0.42.27",
188
+ "powerlines": "^0.42.28",
189
189
  "c12": "^3.3.4"
190
190
  },
191
191
  "devDependencies": {
192
192
  "@openfeature/flagd-provider": "^0.14.0",
193
193
  "@openfeature/server-sdk": "^1.20.2",
194
- "@types/node": "^25.5.0",
194
+ "@types/node": "^25.5.2",
195
195
  "vite": "^8.0.3"
196
196
  },
197
197
  "publishConfig": { "access": "public" },
198
- "gitHead": "36659bb9272f4247dca475613e45451f0adedcfa"
198
+ "gitHead": "9e3382219bcbd57edea2a23e1e421a44b5acdd58"
199
199
  }