ogi-addon 3.1.0 → 4.0.0

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,8 +1,23 @@
1
+ import type {
2
+ ActionConfigurationOption,
3
+ BooleanConfigurationOption,
4
+ ConfigurationFile,
5
+ ConfigurationOptionType,
6
+ ConfigurationOptionWire,
7
+ NumberConfigurationOption,
8
+ StringConfigurationOption,
9
+ } from '@ogi-sdk/connect';
1
10
  import z, { ZodError } from 'zod';
2
11
 
3
- export interface ConfigurationFile {
4
- [key: string]: ConfigurationOption<string>;
5
- }
12
+ export type {
13
+ ActionConfigurationOption,
14
+ BooleanConfigurationOption,
15
+ ConfigurationFile,
16
+ ConfigurationOptionType,
17
+ ConfigurationOptionWire,
18
+ NumberConfigurationOption,
19
+ StringConfigurationOption,
20
+ } from '@ogi-sdk/connect';
6
21
 
7
22
  const configValidation = z.object({
8
23
  name: z.string().min(1),
@@ -10,27 +25,27 @@ const configValidation = z.object({
10
25
  description: z.string().min(1),
11
26
  });
12
27
 
13
- export function isStringOption<N extends string = string>(
14
- option: ConfigurationOption<N>
15
- ): option is StringOption<N> {
28
+ export function isStringOption(
29
+ option: ConfigurationOptionWire
30
+ ): option is StringConfigurationOption {
16
31
  return option.type === 'string';
17
32
  }
18
33
 
19
- export function isNumberOption<N extends string = string>(
20
- option: ConfigurationOption<N>
21
- ): option is NumberOption<N> {
34
+ export function isNumberOption(
35
+ option: ConfigurationOptionWire
36
+ ): option is NumberConfigurationOption {
22
37
  return option.type === 'number';
23
38
  }
24
39
 
25
- export function isBooleanOption<N extends string = string>(
26
- option: ConfigurationOption<N>
27
- ): option is BooleanOption<N> {
40
+ export function isBooleanOption(
41
+ option: ConfigurationOptionWire
42
+ ): option is BooleanConfigurationOption {
28
43
  return option.type === 'boolean';
29
44
  }
30
45
 
31
- export function isActionOption<N extends string = string>(
32
- option: ConfigurationOption<N>
33
- ): option is ActionOption<N> {
46
+ export function isActionOption(
47
+ option: ConfigurationOptionWire
48
+ ): option is ActionConfigurationOption {
34
49
  return option.type === 'action';
35
50
  }
36
51
 
@@ -115,21 +130,15 @@ export class ConfigurationBuilder<
115
130
  throw new ZodError(optionData.error.errors);
116
131
  }
117
132
 
118
- config[option.name] = option;
133
+ config[option.name] = option as unknown as ConfigurationFile[string];
119
134
  } else {
120
- config[option.name] = option;
135
+ config[option.name] = option as unknown as ConfigurationFile[string];
121
136
  }
122
137
  });
123
138
  return config;
124
139
  }
125
140
  }
126
141
 
127
- export type ConfigurationOptionType =
128
- | 'string'
129
- | 'number'
130
- | 'boolean'
131
- | 'action'
132
- | 'unset';
133
142
  export class ConfigurationOption<N extends string = string> {
134
143
  public name: N = '' as N;
135
144
  public defaultValue: unknown = '';