codify-plugin-lib 1.0.182-beta43 → 1.0.182-beta44

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.
@@ -55,7 +55,7 @@ export class Plugin {
55
55
  throw new Error(`Cannot get info for resource ${data.type}, resource doesn't exist`);
56
56
  }
57
57
  const resource = this.resourceControllers.get(data.type);
58
- const schema = resource.parsedSettings.schema;
58
+ const schema = resource.settings.schema;
59
59
  const requiredPropertyNames = (resource.settings.importAndDestroy?.requiredParameters
60
60
  ?? (typeof resource.settings.allowMultiple === 'object' ? resource.settings.allowMultiple.identifyingParameters : null)
61
61
  ?? schema?.required
@@ -18,12 +18,10 @@ export type ParsedParameterSetting = {
18
18
  export declare class ParsedResourceSettings<T extends StringIndexedObject> implements ResourceSettings<T> {
19
19
  private cache;
20
20
  id: string;
21
- description?: string;
22
21
  schema?: Partial<JSONSchemaType<T | any>>;
23
22
  allowMultiple?: {
24
- identifyingParameters?: string[];
25
23
  matcher?: (desired: Partial<T>, current: Partial<T>) => boolean;
26
- findAllParameters?: () => Promise<Array<Partial<T>>>;
24
+ requiredParameters?: string[];
27
25
  } | boolean;
28
26
  removeStatefulParametersBeforeDestroy?: boolean | undefined;
29
27
  dependencies?: string[] | undefined;
@@ -1,10 +1,8 @@
1
- import { ZodObject, z } from 'zod';
2
1
  import { StatefulParameterController } from '../stateful-parameter/stateful-parameter-controller.js';
3
2
  import { resolveElementEqualsFn, resolveEqualsFn, resolveMatcher, resolveParameterTransformFn } from './resource-settings.js';
4
3
  export class ParsedResourceSettings {
5
4
  cache = new Map();
6
5
  id;
7
- description;
8
6
  schema;
9
7
  allowMultiple;
10
8
  removeStatefulParametersBeforeDestroy;
@@ -15,19 +13,8 @@ export class ParsedResourceSettings {
15
13
  settings;
16
14
  constructor(settings) {
17
15
  this.settings = settings;
18
- const { parameterSettings, schema, ...rest } = settings;
16
+ const { parameterSettings, ...rest } = settings;
19
17
  Object.assign(this, rest);
20
- if (schema) {
21
- this.schema = schema instanceof ZodObject
22
- ? z.toJSONSchema(schema.strict(), {
23
- target: 'draft-7',
24
- override(ctx) {
25
- ctx.jsonSchema.title = settings.id;
26
- ctx.jsonSchema.description = settings.description ?? `${settings.id} resource. Can be used to manage ${settings.id}`;
27
- }
28
- })
29
- : schema;
30
- }
31
18
  this.validateSettings();
32
19
  }
33
20
  get typeId() {
@@ -131,7 +118,7 @@ export class ParsedResourceSettings {
131
118
  && typeof this.settings.allowMultiple === 'object' && this.settings.allowMultiple?.identifyingParameters?.includes(k))) {
132
119
  throw new Error(`Resource: ${this.id}. Stateful parameters are not allowed to be identifying parameters for allowMultiple.`);
133
120
  }
134
- const schema = this.schema;
121
+ const schema = this.settings.schema;
135
122
  if (!this.settings.importAndDestroy && (schema?.oneOf
136
123
  && Array.isArray(schema.oneOf)
137
124
  && schema.oneOf.some((s) => s.required))
@@ -17,16 +17,16 @@ export class ResourceController {
17
17
  this.settings = resource.getSettings();
18
18
  this.typeId = this.settings.id;
19
19
  this.dependencies = this.settings.dependencies ?? [];
20
- this.parsedSettings = new ParsedResourceSettings(this.settings);
21
- if (this.parsedSettings.schema) {
20
+ if (this.settings.schema) {
22
21
  this.ajv = new Ajv({
23
22
  allErrors: true,
24
23
  strict: true,
25
24
  strictRequired: false,
26
25
  allowUnionTypes: true
27
26
  });
28
- this.schemaValidator = this.ajv.compile(this.parsedSettings.schema);
27
+ this.schemaValidator = this.ajv.compile(this.settings.schema);
29
28
  }
29
+ this.parsedSettings = new ParsedResourceSettings(this.settings);
30
30
  }
31
31
  async initialize() {
32
32
  return this.resource.initialize();
@@ -374,8 +374,8 @@ ${JSON.stringify(refresh, null, 2)}
374
374
  .sort((a, b) => this.parsedSettings.statefulParameterOrder.get(a.name) - this.parsedSettings.statefulParameterOrder.get(b.name));
375
375
  }
376
376
  getAllParameterKeys() {
377
- return this.parsedSettings.schema
378
- ? Object.keys(this.parsedSettings.schema?.properties)
377
+ return this.settings.schema
378
+ ? Object.keys(this.settings.schema?.properties)
379
379
  : Object.keys(this.parsedSettings.parameterSettings);
380
380
  }
381
381
  getParametersToRefreshForImport(parameters, context) {
@@ -1,8 +1,6 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
  import { OS, StringIndexedObject } from 'codify-schemas';
3
- import { ZodObject } from 'zod';
4
3
  import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
5
- import { ParsedResourceSettings } from './parsed-resource-settings.js';
6
4
  import { RefreshContext } from './resource.js';
7
5
  export interface InputTransformation {
8
6
  to: (input: any) => Promise<any> | any;
@@ -23,16 +21,12 @@ export interface ResourceSettings<T extends StringIndexedObject> {
23
21
  /**
24
22
  * Schema to validate user configs with. Must be in the format JSON Schema draft07
25
23
  */
26
- schema?: Partial<JSONSchemaType<T | any>> | ZodObject;
24
+ schema?: Partial<JSONSchemaType<T | any>>;
27
25
  /**
28
26
  * Mark the resource as sensitive. Defaults to false. This prevents the resource from automatically being imported by init and import.
29
27
  * This differs from the parameter level sensitivity which also prevents the parameter value from being displayed in the plan.
30
28
  */
31
29
  isSensitive?: boolean;
32
- /**
33
- * An optional description of the resource. This does not affect the behavior of the resource.
34
- */
35
- description?: string;
36
30
  /**
37
31
  * Allow multiple of the same resource to unique. Set truthy if
38
32
  * multiples are allowed, for example for applications, there can be multiple copy of the same application installed
@@ -296,4 +290,4 @@ export declare function resolveEqualsFn(parameter: ParameterSetting): (desired:
296
290
  export declare function resolveElementEqualsFn(parameter: ArrayParameterSetting): (desired: unknown, current: unknown) => boolean;
297
291
  export declare function resolveFnFromEqualsFnOrString(fnOrString: ((a: unknown, b: unknown) => boolean) | ParameterSettingType | undefined): ((a: unknown, b: unknown) => boolean) | undefined;
298
292
  export declare function resolveParameterTransformFn(parameter: ParameterSetting): InputTransformation | undefined;
299
- export declare function resolveMatcher<T extends StringIndexedObject>(settings: ParsedResourceSettings<T>): (desired: Partial<T>, current: Partial<T>) => boolean;
293
+ export declare function resolveMatcher<T extends StringIndexedObject>(settings: ResourceSettings<T>): (desired: Partial<T>, current: Partial<T>) => boolean;
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { addVariablesToPath, areArraysEqual, resolvePathWithVariables, tildify, untildify } from '../utils/functions.js';
4
4
  const ParameterEqualsDefaults = {
5
5
  'boolean': (a, b) => Boolean(a) === Boolean(b),
6
- 'directory'(a, b) {
6
+ 'directory': (a, b) => {
7
7
  let transformedA = resolvePathWithVariables(untildify(String(a)));
8
8
  let transformedB = resolvePathWithVariables(untildify(String(b)));
9
9
  if (transformedA.startsWith('.')) { // Only relative paths start with '.'
@@ -65,7 +65,7 @@ export function resolveFnFromEqualsFnOrString(fnOrString) {
65
65
  const ParameterTransformationDefaults = {
66
66
  'directory': {
67
67
  to: (a) => resolvePathWithVariables((untildify(String(a)))),
68
- from(a, original) {
68
+ from: (a, original) => {
69
69
  if (ParameterEqualsDefaults.directory(a, original)) {
70
70
  return original;
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta43",
3
+ "version": "1.0.182-beta44",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -26,8 +26,7 @@
26
26
  "lodash.isequal": "^4.5.0",
27
27
  "nanoid": "^5.0.9",
28
28
  "strip-ansi": "^7.1.0",
29
- "uuid": "^10.0.0",
30
- "zod": "4.1.13"
29
+ "uuid": "^10.0.0"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@apidevtools/json-schema-ref-parser": "^11.7.2",
@@ -7,7 +7,6 @@ import { spy } from 'sinon';
7
7
  import { ResourceSettings } from '../resource/resource-settings.js';
8
8
  import { TestConfig, TestStatefulParameter } from '../utils/test-utils.test.js';
9
9
  import { getPty } from '../pty/index.js';
10
- import { z } from 'zod';
11
10
 
12
11
  interface TestConfig extends StringIndexedObject {
13
12
  propA: string;
@@ -171,36 +170,6 @@ describe('Plugin tests', () => {
171
170
  })
172
171
  })
173
172
 
174
- it('Can get resource info (zod schema)', async () => {
175
- const schema = z
176
- .object({
177
- plugins: z
178
- .array(z.string())
179
- .describe(
180
- 'Asdf plugins to install. See: https://github.com/asdf-community for a full list'
181
- )
182
- })
183
- .strict()
184
-
185
- const resource = new class extends TestResource {
186
- getSettings(): ResourceSettings<TestConfig> {
187
- return {
188
- id: 'typeId',
189
- operatingSystems: [OS.Darwin],
190
- schema,
191
- }
192
- }
193
- }
194
- const testPlugin = Plugin.create('testPlugin', [resource as any])
195
-
196
- const resourceInfo = await testPlugin.getResourceInfo({ type: 'typeId' })
197
- expect(resourceInfo.import).toMatchObject({
198
- requiredParameters: [
199
- 'plugins'
200
- ]
201
- })
202
- })
203
-
204
173
  it('Get resource info to default import to the one specified in the resource settings', async () => {
205
174
  const schema = {
206
175
  '$schema': 'http://json-schema.org/draft-07/schema',
@@ -89,7 +89,7 @@ export class Plugin {
89
89
 
90
90
  const resource = this.resourceControllers.get(data.type)!;
91
91
 
92
- const schema = resource.parsedSettings.schema as JSONSchemaType<any> | undefined;
92
+ const schema = resource.settings.schema as JSONSchemaType<any> | undefined;
93
93
  const requiredPropertyNames = (
94
94
  resource.settings.importAndDestroy?.requiredParameters
95
95
  ?? (typeof resource.settings.allowMultiple === 'object' ? resource.settings.allowMultiple.identifyingParameters : null)
@@ -2,8 +2,6 @@ import { describe, expect, it } from 'vitest';
2
2
  import { ResourceSettings } from './resource-settings.js';
3
3
  import { ParsedResourceSettings } from './parsed-resource-settings.js';
4
4
  import { TestConfig } from '../utils/test-utils.test.js';
5
- import { z } from 'zod';
6
- import { OS } from 'codify-schemas';
7
5
 
8
6
  describe('Resource options parser tests', () => {
9
7
  it('Parses default values from options', () => {
@@ -161,26 +159,4 @@ describe('Resource options parser tests', () => {
161
159
 
162
160
  expect(() => new ParsedResourceSettings(option)).toThrowError()
163
161
  })
164
-
165
- it('Can handle a zod schema', () => {
166
-
167
- const schema = z.object({
168
- propA: z.string(),
169
- repository: z.string(),
170
- })
171
-
172
- const option: ResourceSettings<z.infer<typeof schema>> = {
173
- id: 'typeId',
174
- operatingSystems: [OS.Darwin],
175
- schema,
176
- importAndDestroy: {
177
- defaultRefreshValues: {
178
- repository: 'abc'
179
- }
180
- }
181
- }
182
-
183
- console.log(new ParsedResourceSettings(option))
184
-
185
- })
186
162
  })
@@ -1,6 +1,5 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
  import { OS, StringIndexedObject } from 'codify-schemas';
3
- import { ZodObject, z } from 'zod';
4
3
 
5
4
  import { StatefulParameterController } from '../stateful-parameter/stateful-parameter-controller.js';
6
5
  import {
@@ -8,12 +7,12 @@ import {
8
7
  DefaultParameterSetting,
9
8
  InputTransformation,
10
9
  ParameterSetting,
11
- ResourceSettings,
12
- StatefulParameterSetting,
13
10
  resolveElementEqualsFn,
14
11
  resolveEqualsFn,
15
12
  resolveMatcher,
16
- resolveParameterTransformFn
13
+ resolveParameterTransformFn,
14
+ ResourceSettings,
15
+ StatefulParameterSetting
17
16
  } from './resource-settings.js';
18
17
 
19
18
  export interface ParsedStatefulParameterSetting extends DefaultParameterSetting {
@@ -30,7 +29,7 @@ export type ParsedArrayParameterSetting = {
30
29
 
31
30
  export type ParsedParameterSetting =
32
31
  {
33
- isEqual: (desired: unknown, current: unknown) => boolean;
32
+ isEqual: (desired: unknown, current: unknown) => boolean;
34
33
  } & (DefaultParameterSetting
35
34
  | ParsedArrayParameterSetting
36
35
  | ParsedStatefulParameterSetting)
@@ -38,13 +37,10 @@ export type ParsedParameterSetting =
38
37
  export class ParsedResourceSettings<T extends StringIndexedObject> implements ResourceSettings<T> {
39
38
  private cache = new Map<string, unknown>();
40
39
  id!: string;
41
- description?: string;
42
-
43
40
  schema?: Partial<JSONSchemaType<T | any>>;
44
41
  allowMultiple?: {
45
- identifyingParameters?: string[];
46
42
  matcher?: (desired: Partial<T>, current: Partial<T>) => boolean;
47
- findAllParameters?: () => Promise<Array<Partial<T>>>
43
+ requiredParameters?: string[]
48
44
  } | boolean;
49
45
 
50
46
  removeStatefulParametersBeforeDestroy?: boolean | undefined;
@@ -58,22 +54,10 @@ export class ParsedResourceSettings<T extends StringIndexedObject> implements Re
58
54
 
59
55
  constructor(settings: ResourceSettings<T>) {
60
56
  this.settings = settings;
61
- const { parameterSettings, schema, ...rest } = settings;
62
57
 
58
+ const { parameterSettings, ...rest } = settings;
63
59
  Object.assign(this, rest);
64
60
 
65
- if (schema) {
66
- this.schema = schema instanceof ZodObject
67
- ? z.toJSONSchema(schema.strict(), {
68
- target: 'draft-7',
69
- override(ctx) {
70
- ctx.jsonSchema.title = settings.id;
71
- ctx.jsonSchema.description = settings.description ?? `${settings.id} resource. Can be used to manage ${settings.id}`;
72
- }
73
- }) as JSONSchemaType<T>
74
- : schema;
75
- }
76
-
77
61
  this.validateSettings();
78
62
  }
79
63
 
@@ -215,7 +199,7 @@ export class ParsedResourceSettings<T extends StringIndexedObject> implements Re
215
199
  throw new Error(`Resource: ${this.id}. Stateful parameters are not allowed to be identifying parameters for allowMultiple.`)
216
200
  }
217
201
 
218
- const schema = this.schema as JSONSchemaType<any>;
202
+ const schema = this.settings.schema as JSONSchemaType<any>;
219
203
  if (!this.settings.importAndDestroy && (schema?.oneOf
220
204
  && Array.isArray(schema.oneOf)
221
205
  && schema.oneOf.some((s) => s.required)
@@ -11,7 +11,6 @@ import { tildify, untildify } from '../utils/functions.js';
11
11
  import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
12
12
  import { Plan } from '../plan/plan.js';
13
13
  import os from 'node:os';
14
- import { z } from 'zod';
15
14
 
16
15
  describe('Resource tests', () => {
17
16
 
@@ -953,129 +952,4 @@ describe('Resource tests', () => {
953
952
 
954
953
  process.env = oldProcessEnv;
955
954
  })
956
-
957
- it('Can import and return all of the imported parameters (zod schema)', async () => {
958
- const schema = z.object({
959
- path: z
960
- .string()
961
- .describe(
962
- 'A list of paths to add to the PATH environment variable'
963
- ),
964
- paths: z
965
- .array(z.string())
966
- .describe(
967
- 'A list of paths to add to the PATH environment variable'
968
- ),
969
- prepend: z
970
- .boolean()
971
- .describe(
972
- 'Whether to prepend the paths to the PATH environment variable'
973
- ),
974
- declarationsOnly: z
975
- .boolean()
976
- .describe(
977
- 'Whether to only declare the paths in the PATH environment variable'
978
- ),
979
- })
980
-
981
- const resource = new class extends TestResource {
982
- getSettings(): ResourceSettings<any> {
983
- return {
984
- id: 'path',
985
- schema,
986
- operatingSystems: [OS.Darwin],
987
- parameterSettings: {
988
- path: { type: 'directory' },
989
- paths: { canModify: true, type: 'array', itemType: 'directory' },
990
- prepend: { default: false, setting: true },
991
- declarationsOnly: { default: false, setting: true },
992
- },
993
- importAndDestroy: {
994
- refreshMapper: (input, context) => {
995
- if (Object.keys(input).length === 0) {
996
- return { paths: [], declarationsOnly: true };
997
- }
998
-
999
- return input;
1000
- }
1001
- },
1002
- allowMultiple: {
1003
- matcher: (desired, current) => {
1004
- if (desired.path) {
1005
- return desired.path === current.path;
1006
- }
1007
-
1008
- const currentPaths = new Set(current.paths)
1009
- return desired.paths?.some((p) => currentPaths.has(p));
1010
- }
1011
- }
1012
- }
1013
- }
1014
-
1015
- async refresh(parameters: Partial<TestConfig>): Promise<Partial<TestConfig> | null> {
1016
- return {
1017
- paths: [
1018
- `${os.homedir()}/.pyenv/bin`,
1019
- `${os.homedir()}/.bun/bin`,
1020
- `${os.homedir()}/.deno/bin`,
1021
- `${os.homedir()}/.jenv/bin`,
1022
- `${os.homedir()}/a/random/path`,
1023
- `${os.homedir()}/.nvm/.bin/2`,
1024
- `${os.homedir()}/.nvm/.bin/3`
1025
- ]
1026
- }
1027
- }
1028
- }
1029
-
1030
- const oldProcessEnv = structuredClone(process.env);
1031
-
1032
- process.env['PYENV_ROOT'] = `${os.homedir()}/.pyenv`
1033
- process.env['BUN_INSTALL'] = `${os.homedir()}/.bun`
1034
- process.env['DENO_INSTALL'] = `${os.homedir()}/.deno`
1035
- process.env['JENV'] = `${os.homedir()}/.jenv`
1036
- process.env['NVM_DIR'] = `${os.homedir()}/.nvm`
1037
-
1038
- const controller = new ResourceController(resource);
1039
- const importResult1 = await controller.import({ type: 'path' }, {});
1040
- expect(importResult1).toMatchObject([
1041
- {
1042
- 'core': {
1043
- 'type': 'path'
1044
- },
1045
- 'parameters': {
1046
- 'paths': [
1047
- '$PYENV_ROOT/bin',
1048
- '$BUN_INSTALL/bin',
1049
- '$DENO_INSTALL/bin',
1050
- '$JENV/bin',
1051
- '~/a/random/path',
1052
- '$NVM_DIR/.bin/2',
1053
- '$NVM_DIR/.bin/3'
1054
- ]
1055
- }
1056
- }
1057
- ])
1058
-
1059
- const importResult2 = await controller.import({ type: 'path' }, { paths: ['$PYENV_ROOT/bin', '$BUN_INSTALL/bin'] });
1060
- expect(importResult2).toMatchObject([
1061
- {
1062
- 'core': {
1063
- 'type': 'path'
1064
- },
1065
- 'parameters': {
1066
- 'paths': [
1067
- '$PYENV_ROOT/bin',
1068
- '$BUN_INSTALL/bin',
1069
- '$DENO_INSTALL/bin',
1070
- '$JENV/bin',
1071
- '~/a/random/path',
1072
- '$NVM_DIR/.bin/2',
1073
- '$NVM_DIR/.bin/3'
1074
- ]
1075
- }
1076
- }
1077
- ])
1078
-
1079
- process.env = oldProcessEnv;
1080
- })
1081
955
  });
@@ -36,17 +36,18 @@ export class ResourceController<T extends StringIndexedObject> {
36
36
 
37
37
  this.typeId = this.settings.id;
38
38
  this.dependencies = this.settings.dependencies ?? [];
39
- this.parsedSettings = new ParsedResourceSettings<T>(this.settings);
40
39
 
41
- if (this.parsedSettings.schema) {
40
+ if (this.settings.schema) {
42
41
  this.ajv = new Ajv({
43
42
  allErrors: true,
44
43
  strict: true,
45
44
  strictRequired: false,
46
45
  allowUnionTypes: true
47
46
  })
48
- this.schemaValidator = this.ajv.compile(this.parsedSettings.schema);
47
+ this.schemaValidator = this.ajv.compile(this.settings.schema);
49
48
  }
49
+
50
+ this.parsedSettings = new ParsedResourceSettings<T>(this.settings);
50
51
  }
51
52
 
52
53
  async initialize(): Promise<void> {
@@ -525,8 +526,8 @@ ${JSON.stringify(refresh, null, 2)}
525
526
  }
526
527
 
527
528
  private getAllParameterKeys(): string[] {
528
- return this.parsedSettings.schema
529
- ? Object.keys((this.parsedSettings.schema as any)?.properties)
529
+ return this.settings.schema
530
+ ? Object.keys((this.settings.schema as any)?.properties)
530
531
  : Object.keys(this.parsedSettings.parameterSettings);
531
532
  }
532
533
 
@@ -13,7 +13,6 @@ import { ArrayParameterSetting, ParameterSetting, ResourceSettings } from './res
13
13
  import { ResourceController } from './resource-controller.js';
14
14
  import os from 'node:os';
15
15
  import path from 'node:path';
16
- import { z } from 'zod';
17
16
 
18
17
  describe('Resource parameter tests', () => {
19
18
  it('Generates a resource plan that includes stateful parameters (create)', async () => {
@@ -1175,39 +1174,4 @@ describe('Resource parameter tests', () => {
1175
1174
  expect(from2).to.eq('$HOME/abc/def')
1176
1175
 
1177
1176
  })
1178
-
1179
- it('Can match directories 2', async () => {
1180
-
1181
- const schema = z.object({
1182
- propA: z.string(),
1183
- propB: z.number(),
1184
- });
1185
-
1186
- const resource = new class extends TestResource {
1187
- getSettings(): ResourceSettings<z.infer<typeof schema>> {
1188
- return {
1189
- id: 'resourceType',
1190
- schema,
1191
- operatingSystems: [OS.Darwin],
1192
- parameterSettings: {
1193
- propA: { type: 'directory' }
1194
- },
1195
- }
1196
- }
1197
- };
1198
-
1199
- const controller = new ResourceController(resource);
1200
- const transformations = controller.parsedSettings.inputTransformations.propA;
1201
-
1202
- const to = transformations!.to('$HOME/abc/def')
1203
- expect(to).to.eq(os.homedir() + '/abc/def')
1204
-
1205
- const from = transformations!.from(os.homedir() + '/abc/def')
1206
- expect(from).to.eq('~/abc/def')
1207
-
1208
- const from2 = transformations!.from(os.homedir() + '/abc/def', '$HOME/abc/def')
1209
- expect(from2).to.eq('$HOME/abc/def')
1210
-
1211
- })
1212
-
1213
1177
  })
@@ -2,7 +2,6 @@ import { JSONSchemaType } from 'ajv';
2
2
  import { OS, StringIndexedObject } from 'codify-schemas';
3
3
  import isObjectsEqual from 'lodash.isequal'
4
4
  import path from 'node:path';
5
- import { ZodObject } from 'zod';
6
5
 
7
6
  import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
8
7
  import {
@@ -12,7 +11,6 @@ import {
12
11
  tildify,
13
12
  untildify
14
13
  } from '../utils/functions.js';
15
- import { ParsedResourceSettings } from './parsed-resource-settings.js';
16
14
  import { RefreshContext } from './resource.js';
17
15
 
18
16
  export interface InputTransformation {
@@ -38,7 +36,7 @@ export interface ResourceSettings<T extends StringIndexedObject> {
38
36
  /**
39
37
  * Schema to validate user configs with. Must be in the format JSON Schema draft07
40
38
  */
41
- schema?: Partial<JSONSchemaType<T | any>> | ZodObject;
39
+ schema?: Partial<JSONSchemaType<T | any>>;
42
40
 
43
41
  /**
44
42
  * Mark the resource as sensitive. Defaults to false. This prevents the resource from automatically being imported by init and import.
@@ -46,11 +44,6 @@ export interface ResourceSettings<T extends StringIndexedObject> {
46
44
  */
47
45
  isSensitive?: boolean;
48
46
 
49
- /**
50
- * An optional description of the resource. This does not affect the behavior of the resource.
51
- */
52
- description?: string;
53
-
54
47
  /**
55
48
  * Allow multiple of the same resource to unique. Set truthy if
56
49
  * multiples are allowed, for example for applications, there can be multiple copy of the same application installed
@@ -356,7 +349,7 @@ export interface StatefulParameterSetting extends DefaultParameterSetting {
356
349
 
357
350
  const ParameterEqualsDefaults: Partial<Record<ParameterSettingType, (a: unknown, b: unknown) => boolean>> = {
358
351
  'boolean': (a: unknown, b: unknown) => Boolean(a) === Boolean(b),
359
- 'directory'(a: unknown, b: unknown) {
352
+ 'directory': (a: unknown, b: unknown) => {
360
353
  let transformedA = resolvePathWithVariables(untildify(String(a)))
361
354
  let transformedB = resolvePathWithVariables(untildify(String(b)))
362
355
 
@@ -437,7 +430,7 @@ export function resolveFnFromEqualsFnOrString(
437
430
  const ParameterTransformationDefaults: Partial<Record<ParameterSettingType, InputTransformation>> = {
438
431
  'directory': {
439
432
  to: (a: unknown) => resolvePathWithVariables((untildify(String(a)))),
440
- from(a: unknown, original) {
433
+ from: (a: unknown, original) => {
441
434
  if (ParameterEqualsDefaults.directory!(a, original)) {
442
435
  return original;
443
436
  }
@@ -496,7 +489,7 @@ export function resolveParameterTransformFn(
496
489
  }
497
490
 
498
491
  export function resolveMatcher<T extends StringIndexedObject>(
499
- settings: ParsedResourceSettings<T>
492
+ settings: ResourceSettings<T>
500
493
  ): (desired: Partial<T>, current: Partial<T>) => boolean {
501
494
  return typeof settings.allowMultiple === 'boolean' || !settings.allowMultiple?.matcher
502
495
  ? ((desired: Partial<T>, current: Partial<T>) => {