Skip to content

Commit fd581f0

Browse files
committed
fix: Added example and default configs
1 parent 6a0ce13 commit fd581f0

5 files changed

Lines changed: 41 additions & 10 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codifycli/plugin-core",
3-
"version": "1.0.1",
3+
"version": "1.1.0-beta5",
44
"description": "TypeScript library for building Codify plugins to manage system resources (applications, CLI tools, settings) through infrastructure-as-code",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
@@ -35,7 +35,7 @@
3535
},
3636
"license": "ISC",
3737
"dependencies": {
38-
"@codifycli/schemas": "1.0.0",
38+
"@codifycli/schemas": "1.1.0-beta3",
3939
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
4040
"ajv": "^8.18.0",
4141
"ajv-formats": "^2.1.1",

src/plugin/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
PlanRequestData,
1212
PlanResponseData,
1313
ResourceConfig,
14-
ResourceJson, SetVerbosityRequestData,
14+
ResourceJson,
15+
SetVerbosityRequestData,
1516
ValidateRequestData,
1617
ValidateResponseData
1718
} from '@codifycli/schemas';
@@ -127,7 +128,9 @@ export class Plugin {
127128
operatingSystems: resource.settings.operatingSystems,
128129
linuxDistros: resource.settings.linuxDistros,
129130
sensitiveParameters,
130-
allowMultiple
131+
allowMultiple,
132+
defaultConfig: resource.settings.defaultConfig,
133+
exampleConfigs: resource.settings.exampleConfigs,
131134
}
132135
}
133136

src/resource/parsed-resource-settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { StatefulParameterController } from '../stateful-parameter/stateful-para
66
import {
77
ArrayParameterSetting,
88
DefaultParameterSetting,
9+
ExampleConfigs,
910
InputTransformation,
1011
ParameterSetting,
1112
resolveElementEqualsFn,
@@ -56,6 +57,9 @@ export class ParsedResourceSettings<T extends StringIndexedObject> implements Re
5657

5758
isSensitive?: boolean;
5859

60+
defaultConfig!: Partial<T>;
61+
exampleConfigs!: ExampleConfigs;
62+
5963
private settings: ResourceSettings<T>;
6064

6165
constructor(settings: ResourceSettings<T>) {

src/resource/resource-settings.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ import {
1515
import { ParsedResourceSettings } from './parsed-resource-settings.js';
1616
import { RefreshContext } from './resource.js';
1717

18+
export interface ExampleConfig extends Record<string, unknown> {
19+
title: string;
20+
configs: Array<Record<string, unknown>>;
21+
description?: string;
22+
}
23+
24+
export interface ExampleConfigs {
25+
example1?: ExampleConfig;
26+
example2?: ExampleConfig;
27+
}
28+
1829
export interface InputTransformation {
1930
to: (input: any) => Promise<any> | any;
2031
from: (current: any, original: any) => Promise<any> | any;
@@ -194,6 +205,19 @@ export interface ResourceSettings<T extends StringIndexedObject> {
194205
*/
195206
refreshMapper?: (input: Partial<T>, context: RefreshContext<T>) => Partial<T>;
196207
}
208+
209+
/**
210+
* Represents the default config that is added to the editor with prefilled properties. For some resources
211+
*
212+
* @type {Partial<T>}
213+
*/
214+
defaultConfig?: Partial<T>
215+
216+
/**
217+
* A collection of example configs used to give users an idea on how to use this specific resource. These examples
218+
* don't need to be limited to just the current resource. They can include other resources as well
219+
*/
220+
exampleConfigs?: ExampleConfigs
197221
}
198222

199223
/**

0 commit comments

Comments
 (0)