@oneclick.dev/cms-kit 0.0.104 → 0.0.106

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.
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare interface BaseSetting<T> {
12
12
  description?: string;
13
13
  type: SettingType;
14
14
  default?: T;
15
+ required?: boolean;
15
16
  valuesFrom?: string;
16
17
  visibility?: {
17
18
  dependsOn: string[];
@@ -43,6 +44,16 @@ export declare type CmsRouterLocation = string | {
43
44
  query?: Record<string, any>;
44
45
  };
45
46
 
47
+ /** ----------------- config groups ----------------- **/
48
+ export declare type ConditionOperator = 'isNotEmpty' | 'isEmpty' | 'equals' | 'notEquals';
49
+
50
+ export declare function configGroup<const F extends ModuleSettingsSchema>(opts: {
51
+ label?: string;
52
+ description?: string;
53
+ visibleWhen: GroupConditions;
54
+ fields: F & ValidateSettingDefaults<F>;
55
+ }): SettingGroup<F>;
56
+
46
57
  declare interface CustomDialogState {
47
58
  id: number;
48
59
  show: boolean;
@@ -57,7 +68,15 @@ export declare interface DataQuerySetting extends BaseSetting<string> {
57
68
  integrationKey?: string;
58
69
  }
59
70
 
60
- export declare function defineModuleConfig<const S extends ModuleSettingsSchema>(schema: S & ValidateDefaults<S>): S & ValidateDefaults<S>;
71
+ export declare function defineModuleConfig<const S extends ModuleConfigSchema>(schema: S & ValidateDefaults<S>): S & ValidateDefaults<S>;
72
+
73
+ /** Evaluate group conditions against current config values */
74
+ export declare function evaluateGroupConditions(conditions: GroupConditions, configValues: Record<string, any>): boolean;
75
+
76
+ export declare interface FieldCondition {
77
+ operator: ConditionOperator;
78
+ value?: any;
79
+ }
61
80
 
62
81
  export declare interface FirestoreQueryParamFilter {
63
82
  field: string;
@@ -78,6 +97,9 @@ export declare interface FirestoreQueryParamSort {
78
97
  direction: 'asc' | 'desc';
79
98
  }
80
99
 
100
+ /** Flatten a ModuleConfigSchema (with possible groups) into a flat settings map */
101
+ export declare function flattenConfigSchema(schema: ModuleConfigSchema): ModuleSettingsSchema;
102
+
81
103
  declare interface FlowBuilderState {
82
104
  id: number;
83
105
  show: boolean;
@@ -94,6 +116,14 @@ export declare interface FormSetting extends BaseSetting<any> {
94
116
  type: 'form';
95
117
  }
96
118
 
119
+ export declare type GroupConditions = Record<string, ConditionOperator | FieldCondition>;
120
+
121
+ declare type GroupFieldValues<TSchema extends ModuleConfigSchema> = {
122
+ [K in keyof TSchema]: TSchema[K] extends SettingGroup<infer F> ? {
123
+ [FK in keyof F]: ValueTypeFromSetting<F[FK]>;
124
+ } : {};
125
+ }[keyof TSchema];
126
+
97
127
  export declare interface InputSetting extends BaseSetting<string> {
98
128
  type: 'input' | 'textarea' | 'color';
99
129
  }
@@ -117,6 +147,8 @@ declare interface MediaSourceUpdateParams {
117
147
  allowUserFolders?: boolean;
118
148
  }
119
149
 
150
+ export declare type ModuleConfigSchema = Record<string, ModuleSetting | SettingGroup>;
151
+
120
152
  export declare interface ModuleMetadata {
121
153
  name: string;
122
154
  description: string;
@@ -141,9 +173,7 @@ declare interface OverlayState {
141
173
  params: Record<string, string>;
142
174
  }
143
175
 
144
- export declare type ResolveConfig<TSchema extends ModuleSettingsSchema> = {
145
- [K in keyof TSchema]: ValueTypeFromSetting<TSchema[K]>;
146
- };
176
+ export declare type ResolveConfig<TSchema extends ModuleConfigSchema> = Simplify<TopLevelValues<TSchema> & UnionToIntersection<GroupFieldValues<TSchema>>>;
147
177
 
148
178
  export declare interface ResourceSetting extends BaseSetting<string> {
149
179
  type: 'resource';
@@ -169,8 +199,36 @@ export declare interface SendMailParams {
169
199
  body: string;
170
200
  }
171
201
 
202
+ export declare interface SettingGroup<F extends ModuleSettingsSchema = ModuleSettingsSchema> {
203
+ _group: true;
204
+ label?: string;
205
+ description?: string;
206
+ visibleWhen: GroupConditions;
207
+ fields: F;
208
+ }
209
+
172
210
  export declare type SettingType = 'checkbox' | 'input' | 'textarea' | 'select' | 'radio' | 'number' | 'color' | 'resource' | 'mediaSource' | 'dataQuery' | 'flow' | 'form';
173
211
 
212
+ declare type Simplify<T> = {
213
+ [K in keyof T]: T[K];
214
+ };
215
+
216
+ declare type TopLevelValues<TSchema extends ModuleConfigSchema> = {
217
+ [K in keyof TSchema as TSchema[K] extends ModuleSetting ? K : never]: TSchema[K] extends ModuleSetting ? ValueTypeFromSetting<TSchema[K]> : never;
218
+ };
219
+
220
+ declare type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
221
+
222
+ export declare type UseAgencyIntegrations = () => {
223
+ getAgencyIntegrations: () => Promise<any>;
224
+ getAgencyIntegration: (integrationId: string) => Promise<any>;
225
+ };
226
+
227
+ export declare const useAgencyIntegrations: () => {
228
+ getAgencyIntegrations: () => Promise<any>;
229
+ getAgencyIntegration: (integrationId: string) => Promise<any>;
230
+ };
231
+
174
232
  export declare function useCms(): {
175
233
  breadcrumbs: {};
176
234
  project: {};
@@ -475,7 +533,13 @@ export declare type UseUtilsService = () => {
475
533
 
476
534
  export declare const useUtilsService: () => ReturnType<UseUtilsService>;
477
535
 
478
- declare type ValidateDefaults<TSchema extends ModuleSettingsSchema> = {
536
+ declare type ValidateDefaults<TSchema extends ModuleConfigSchema> = {
537
+ [K in keyof TSchema]: TSchema[K] extends SettingGroup ? TSchema[K] : TSchema[K] extends ModuleSetting ? TSchema[K] extends {
538
+ default: infer D;
539
+ } ? (D extends ValueTypeFromSetting<TSchema[K]> ? TSchema[K] : never) : TSchema[K] : TSchema[K];
540
+ };
541
+
542
+ declare type ValidateSettingDefaults<TSchema extends ModuleSettingsSchema> = {
479
543
  [K in keyof TSchema]: TSchema[K] extends {
480
544
  default: infer D;
481
545
  } ? (D extends ValueTypeFromSetting<TSchema[K]> ? TSchema[K] : never) : TSchema[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneclick.dev/cms-kit",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "type": "module",
5
5
  "main": "./dist/cms-kit.cjs",
6
6
  "module": "./dist/cms-kit.js",