@eide/foir-cli 0.18.0 → 0.19.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.
@@ -16,28 +16,57 @@
16
16
  * });
17
17
  * ```
18
18
  */
19
- interface SelectFieldConfig extends Record<string, unknown> {
19
+ /**
20
+ * `select` is record-backed: options come from records of `optionModelKey`.
21
+ * For inline `{label, value}` choices, declare `type: 'enum'` instead — the
22
+ * `options?: never` here forbids the legacy shape at the type level.
23
+ */
24
+ interface SelectFieldConfig {
20
25
  optionModelKey: string;
21
26
  multiple?: boolean;
27
+ options?: never;
28
+ }
29
+ interface EnumFieldOption {
30
+ label: string;
31
+ value: string;
32
+ }
33
+ /**
34
+ * `enum` is config-only: the storefront receives a typed string-literal
35
+ * union from inline `{label, value}` options. Variant overrides apply;
36
+ * locale overrides do not.
37
+ */
38
+ interface EnumFieldConfig {
39
+ options: EnumFieldOption[];
40
+ multiple?: boolean;
41
+ default?: string | string[];
22
42
  }
23
- type FieldDefinitionInput = {
43
+ interface BaseFieldDefinitionInput {
24
44
  key: string;
25
- type: string;
26
45
  label?: string;
27
46
  required?: boolean;
28
47
  helpText?: string;
29
48
  placeholder?: string;
30
49
  defaultValue?: unknown;
31
- config?: Record<string, unknown>;
32
50
  itemType?: string;
33
51
  storage?: string;
34
52
  templateZone?: string;
35
53
  zoneOrder?: number;
36
- };
37
- type SelectFieldDefinitionInput = Omit<FieldDefinitionInput, 'type' | 'config'> & {
54
+ }
55
+ type SelectFieldDefinitionInput = BaseFieldDefinitionInput & {
38
56
  type: 'select';
39
57
  config: SelectFieldConfig;
40
58
  };
59
+ type EnumFieldDefinitionInput = BaseFieldDefinitionInput & {
60
+ type: 'enum';
61
+ config: EnumFieldConfig;
62
+ };
63
+ type GenericFieldDefinitionInput = BaseFieldDefinitionInput & {
64
+ type: string;
65
+ config?: Record<string, unknown> & {
66
+ options?: never;
67
+ };
68
+ };
69
+ type FieldDefinitionInput = SelectFieldDefinitionInput | EnumFieldDefinitionInput | GenericFieldDefinitionInput;
41
70
  interface ApplyConfigModelInput {
42
71
  key: string;
43
72
  name: string;
@@ -342,6 +371,8 @@ declare function defineModel(model: ApplyConfigModelInput): ApplyConfigModelInpu
342
371
  declare function defineField(field: FieldDefinitionInput): FieldDefinitionInput;
343
372
  /** Define a select field — requires `optionModelKey` pointing to a model whose records become options. */
344
373
  declare function defineSelectField(field: SelectFieldDefinitionInput): FieldDefinitionInput;
374
+ /** Define an enum field — config-only choice from inline `{label, value}` options. */
375
+ declare function defineEnumField(field: EnumFieldDefinitionInput): FieldDefinitionInput;
345
376
  /** Define an operation with type safety. */
346
377
  declare function defineOperation(operation: ApplyConfigOperationInput): ApplyConfigOperationInput;
347
378
  /** Define a segment with type safety. */
@@ -388,4 +419,4 @@ interface FoirSecretsConfig {
388
419
  */
389
420
  declare function defineSecrets(config: FoirSecretsConfig): FoirSecretsConfig;
390
421
 
391
- export { type AppInput, type AppPlacementFieldChoiceInput, type AppSinkMappingInput, type AppSourceMappingInput, type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigProjectInput, type ApplyConfigProjectSettingsInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type ExpressionPrecondition, type FieldDefinitionInput, type FoirSecretsConfig, type Precondition, type QuotaRule, type SecretDeclaration, type SecretOwnerKind, type SegmentPrecondition, type SelectFieldConfig, type SelectFieldDefinitionInput, defineAuthProvider, defineConfig, defineField, defineHook, defineModel, defineOperation, definePlacement, defineSchedule, defineSecrets, defineSegment, defineSelectField };
422
+ export { type AppInput, type AppPlacementFieldChoiceInput, type AppSinkMappingInput, type AppSourceMappingInput, type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigProjectInput, type ApplyConfigProjectSettingsInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type EnumFieldConfig, type EnumFieldDefinitionInput, type EnumFieldOption, type ExpressionPrecondition, type FieldDefinitionInput, type FoirSecretsConfig, type Precondition, type QuotaRule, type SecretDeclaration, type SecretOwnerKind, type SegmentPrecondition, type SelectFieldConfig, type SelectFieldDefinitionInput, defineAuthProvider, defineConfig, defineEnumField, defineField, defineHook, defineModel, defineOperation, definePlacement, defineSchedule, defineSecrets, defineSegment, defineSelectField };
@@ -11,6 +11,9 @@ function defineField(field) {
11
11
  function defineSelectField(field) {
12
12
  return field;
13
13
  }
14
+ function defineEnumField(field) {
15
+ return field;
16
+ }
14
17
  function defineOperation(operation) {
15
18
  return operation;
16
19
  }
@@ -35,6 +38,7 @@ function defineSecrets(config) {
35
38
  export {
36
39
  defineAuthProvider,
37
40
  defineConfig,
41
+ defineEnumField,
38
42
  defineField,
39
43
  defineHook,
40
44
  defineModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {