nextpress-core 1.0.1 → 1.0.3

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.
Files changed (58) hide show
  1. package/dist/acf-functions/core/acf-builder.d.ts +1 -0
  2. package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +1 -0
  3. package/dist/acf-functions/field-props.d.ts +196 -0
  4. package/dist/acf-functions/field-props.js +1 -0
  5. package/dist/acf-functions/services/define-field-group.d.ts +1 -0
  6. package/dist/acf-functions/services/define-layout.d.ts +1 -0
  7. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +1 -1
  8. package/dist/acf-functions/services/map-fields/map-fields.d.ts +3 -0
  9. package/dist/acf-functions/types/acf-field-group.d.ts +99 -0
  10. package/dist/acf-functions/types/acf-field-group.js +1 -0
  11. package/dist/acf-functions/types/acf-field.d.ts +2813 -0
  12. package/dist/acf-functions/types/acf-field.js +1 -0
  13. package/dist/acf-functions/types/acf-layout.d.ts +19 -0
  14. package/dist/acf-functions/types/acf-layout.js +1 -0
  15. package/dist/acf-functions/types/acf-values.d.ts +4 -0
  16. package/dist/acf-functions/types/acf-values.js +1 -0
  17. package/dist/acf-functions/types/components/field-props.d.ts +196 -0
  18. package/dist/acf-functions/types/components/field-props.js +1 -0
  19. package/dist/acf-functions/types/components/nextpress-component.d.ts +11 -0
  20. package/dist/acf-functions/types/components/nextpress-component.js +1 -0
  21. package/dist/entities/common.d.ts +28 -0
  22. package/dist/entities/common.js +1 -0
  23. package/dist/entities/option/option.interface.d.ts +7 -0
  24. package/dist/entities/option/option.interface.js +2 -0
  25. package/dist/entities/post/post.interface.d.ts +67 -0
  26. package/dist/entities/post/post.interface.js +2 -0
  27. package/dist/entities/term/term.interface.d.ts +8 -0
  28. package/dist/entities/term/term.interface.js +1 -0
  29. package/dist/entities/user/user.interface.d.ts +9 -0
  30. package/dist/entities/user/user.interface.js +1 -0
  31. package/dist/globals/entity-loader/entity-loader-base.d.ts +1 -1
  32. package/dist/globals/entity-loader/entity-loader.interface.d.ts +52 -0
  33. package/dist/globals/entity-loader/entity-loader.interface.js +1 -0
  34. package/dist/globals/entity-loader/option-loader.d.ts +1 -1
  35. package/dist/globals/entity-loader/post-loader.d.ts +1 -1
  36. package/dist/globals/entity-loader/term-loader.d.ts +1 -1
  37. package/dist/globals/entity-loader/user-loader.d.ts +1 -1
  38. package/dist/globals/get-field/get-field.d.ts +2 -1
  39. package/dist/globals/nextpress-config/nextpress-config.interface.d.ts +14 -0
  40. package/dist/globals/nextpress-config/nextpress-config.interface.js +1 -0
  41. package/dist/repository/optionquery/option-query-args.d.ts +19 -0
  42. package/dist/repository/optionquery/option-query-args.js +1 -0
  43. package/dist/repository/optionquery/option-query.d.ts +1 -1
  44. package/dist/repository/postquery/post-query-args.d.ts +104 -0
  45. package/dist/repository/postquery/post-query-args.js +1 -0
  46. package/dist/repository/postquery/post-query.d.ts +1 -1
  47. package/dist/repository/termquery/term-query-args.d.ts +51 -0
  48. package/dist/repository/termquery/term-query-args.js +1 -0
  49. package/dist/repository/termquery/term-query.d.ts +1 -1
  50. package/dist/repository/userquery/user-query-args.d.ts +63 -0
  51. package/dist/repository/userquery/user-query-args.js +1 -0
  52. package/dist/repository/userquery/user-query.d.ts +1 -1
  53. package/dist/router/types.d.ts +8 -0
  54. package/dist/router/types.js +1 -0
  55. package/dist/ui/render-components.d.ts +1 -1
  56. package/dist/wpdb/wpdb.interface.d.ts +152 -0
  57. package/dist/wpdb/wpdb.interface.js +5 -0
  58. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { ACFFieldGroup, NextpressFieldGroup } from "../types/acf-field-group";
1
2
  /**
2
3
  * Class representing ACF builder.
3
4
  */
@@ -1,3 +1,4 @@
1
+ import { NextpressFieldGroup } from '../types/acf-field-group';
1
2
  /**
2
3
  * Autoloads ACF field groups dynamically from the field-groups directory.
3
4
  * * **Requirements for it to work:**
@@ -0,0 +1,196 @@
1
+ import { IPost } from "@/entities/post/post.interface";
2
+ import { ITerm } from "@/entities/term/term.interface";
3
+ import { IUser } from "@/entities/user/user.interface";
4
+ import { JSX } from "react";
5
+ type GetFields<T> = T extends {
6
+ fields: readonly any[];
7
+ } ? T['fields'] : T extends {
8
+ sub_fields: readonly any[];
9
+ } ? T['sub_fields'] : never;
10
+ /**
11
+ * Represents the properties passed to a Nextpress ACF component.
12
+ *
13
+ * @template T - The expected type of the mapped ACF fields.
14
+ */
15
+ export type FieldProps<LayoutT> = LayoutT extends {
16
+ fields: readonly any[];
17
+ } | {
18
+ sub_fields: readonly any[];
19
+ } ? ResolvedFields<GetFields<LayoutT>> : never;
20
+ /**
21
+ * An array of ACF field configurations to a strongly-typed object representing the resolved data structure.
22
+ * It iterates over the array, using the `name` property of each field as the object key, and determines the expected value type using the `MapFieldType` utility.
23
+ *
24
+ * @template Fields - A readonly array of ACF field configuration objects.
25
+ */
26
+ type ResolvedFields<Fields extends readonly any[]> = {
27
+ [F in Fields[number] as F['name']]: MapFieldType<F>;
28
+ };
29
+ /**
30
+ * Maps an array of ACF Flexible Content layouts to a union type representing the resolved layout blocks.
31
+ * For each layout, it checks for the presence of `fields` or `sub_fields`, and resolves to a specific object
32
+ * structure containing the layout's React component and its deeply resolved field content.
33
+ *
34
+ * @template Layouts - A readonly array of ACF Flexible Content layout configuration objects.
35
+ */
36
+ type ResolvedFlexibleContent<Layouts extends readonly any[]> = {
37
+ [L in Layouts[number] as L['name']]: L extends {
38
+ name: infer Name;
39
+ } & ({
40
+ fields: readonly any[];
41
+ } | {
42
+ sub_fields: readonly any[];
43
+ }) ? {
44
+ Component: () => Promise<JSX.Element>;
45
+ content: ResolvedFields<GetFields<L>>;
46
+ }[] : never;
47
+ }[Layouts[number]['name']];
48
+ type MapFieldType<Field> = Field extends {
49
+ type: 'color_picker';
50
+ } ? string | null : Field extends {
51
+ type: 'date_picker';
52
+ } ? string | null : Field extends {
53
+ type: 'date_time_picker';
54
+ } ? string | null : Field extends {
55
+ type: 'google_map';
56
+ } ? ACFGoogleMapsObject | null : Field extends {
57
+ type: 'icon_picker';
58
+ } ? Field extends {
59
+ return_format: 'string';
60
+ } ? string | null : Field extends {
61
+ return_format: 'array';
62
+ } ? ACFIconObject | null : ACFIconObject | null : Field extends {
63
+ type: 'time_picker';
64
+ } ? string | null : Field extends {
65
+ type: 'email';
66
+ } ? string | null : Field extends {
67
+ type: 'number';
68
+ } ? number | null : Field extends {
69
+ type: 'password';
70
+ } ? string | null : Field extends {
71
+ type: 'range';
72
+ } ? number | null : Field extends {
73
+ type: 'text';
74
+ } ? string | null : Field extends {
75
+ type: 'textarea';
76
+ } ? string | null : Field extends {
77
+ type: 'button_group';
78
+ } ? Field extends {
79
+ return_format: 'array';
80
+ } ? ACFChoiceObject | null : string | null : Field extends {
81
+ type: 'checkbox';
82
+ } ? Field extends {
83
+ return_format: 'array';
84
+ } ? ACFChoiceObject[] : string[] : Field extends {
85
+ type: 'radio';
86
+ } ? Field extends {
87
+ return_format: 'array';
88
+ } ? ACFChoiceObject | null : string | null : Field extends {
89
+ type: 'select';
90
+ } ? Field extends {
91
+ multiple: 1;
92
+ } ? Field extends {
93
+ return_format: 'array';
94
+ } ? ACFChoiceObject[] : string[] : Field extends {
95
+ return_format: 'array';
96
+ } ? ACFChoiceObject | null : string | null : Field extends {
97
+ type: 'true_false';
98
+ } ? boolean : Field extends {
99
+ type: 'file';
100
+ } ? number | null : Field extends {
101
+ type: 'gallery';
102
+ } ? number[] : Field extends {
103
+ type: 'image';
104
+ } ? number | null : Field extends {
105
+ type: 'oembed';
106
+ } ? string | null : Field extends {
107
+ type: 'wysiwyg';
108
+ } ? string | null : Field extends {
109
+ type: 'link';
110
+ } ? Field extends {
111
+ return_format: 'url';
112
+ } ? string | null : Field extends {
113
+ return_format: 'array';
114
+ } ? ACFLinkObject | null : ACFLinkObject : Field extends {
115
+ type: 'page_link';
116
+ } ? Field extends {
117
+ multiple: 1;
118
+ } ? string[] : string | null : Field extends {
119
+ type: 'post_object';
120
+ } ? Field extends {
121
+ multiple: 1;
122
+ } ? Field extends {
123
+ return_format: 'object';
124
+ } ? IPost[] : number[] : Field extends {
125
+ return_format: 'object';
126
+ } ? IPost | null : number | null : Field extends {
127
+ type: 'relationship';
128
+ } ? Field extends {
129
+ return_format: 'object';
130
+ } ? IPost[] | null : number[] | null : Field extends {
131
+ type: 'taxonomy';
132
+ } ? Field extends {
133
+ multiple: 1;
134
+ } ? Field extends {
135
+ return_format: 'object';
136
+ } ? ITerm[] : number[] : Field extends {
137
+ return_format: 'object';
138
+ } ? ITerm | null : number | null : Field extends {
139
+ type: 'user';
140
+ } ? Field extends {
141
+ multiple: 1;
142
+ } ? Field extends {
143
+ return_format: 'object';
144
+ } ? IUser[] : number[] : Field extends {
145
+ return_format: 'object';
146
+ } ? IUser | null : number | null : Field extends {
147
+ type: 'group';
148
+ } & ({
149
+ fields: readonly any[];
150
+ } | {
151
+ sub_fields: readonly any[];
152
+ }) ? ResolvedFields<GetFields<Field>> | null : Field extends {
153
+ type: 'repeater';
154
+ } & ({
155
+ fields: readonly any[];
156
+ } | {
157
+ sub_fields: readonly any[];
158
+ }) ? ResolvedFields<GetFields<Field>>[] | null : Field extends {
159
+ type: 'flexible_content';
160
+ layouts: readonly any[];
161
+ } ? ResolvedFlexibleContent<Field['layouts']> | null : Field extends {
162
+ fields: readonly any[];
163
+ } | {
164
+ sub_fields: readonly any[];
165
+ } ? ResolvedFields<GetFields<Field>> : never;
166
+ type ACFIconObject = {
167
+ type: string;
168
+ value: string;
169
+ };
170
+ type ACFLinkObject = {
171
+ title: string;
172
+ url: string;
173
+ target: string;
174
+ };
175
+ type ACFChoiceObject = {
176
+ label?: string;
177
+ value?: string;
178
+ };
179
+ type ACFGoogleMapsObject = {
180
+ address: string;
181
+ lat: string | number;
182
+ lng: string | number;
183
+ zoom: string | number;
184
+ place_id: string;
185
+ name: string;
186
+ street_number: string | number;
187
+ street_name: string;
188
+ street_name_short: string;
189
+ city: string;
190
+ state: string;
191
+ state_short: string;
192
+ post_code: string | number;
193
+ country: string;
194
+ country_short: string;
195
+ };
196
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import { NextpressFieldGroup } from "../types/acf-field-group";
1
2
  /**
2
3
  * Defines field group configuration and applies typing.
3
4
  *
@@ -1,3 +1,4 @@
1
+ import { NextpressLayout } from "../types/acf-layout";
1
2
  /**
2
3
  * Defines layout configuration and applies typing.
3
4
  *
@@ -1,2 +1,2 @@
1
1
  import { ACFChoiceObject } from "@/acf-functions/types/components/field-props";
2
- export declare function mapChoiceObject(return_format: 'array' | 'label' | 'value', value?: string, choices?: Choices): ACFChoiceObject | string | undefined;
2
+ export declare function mapChoiceObject(return_format: 'array' | 'label' | 'value', value?: string, choices?: any): ACFChoiceObject | string | undefined;
@@ -1,3 +1,6 @@
1
+ import { NextpressField } from "@/acf-functions/types/acf-field";
2
+ import { NextpressLayout } from "@/acf-functions/types/acf-layout";
3
+ import { ACFRawValues } from "@/acf-functions/types/acf-values";
1
4
  /**
2
5
  * Maps individual ACF field to corresponding value.
3
6
  *
@@ -0,0 +1,99 @@
1
+ import { NextpressField, ACFField } from "./acf-field";
2
+ type TransformACFFieldGroup<T> = T extends any ? Omit<T, 'key' | 'fields'> & ('fields' extends keyof T ? {
3
+ fields: NextpressField[];
4
+ } : []) : never;
5
+ /** ACF Field Group without key constraints to allow key generation */
6
+ export type NextpressFieldGroup = TransformACFFieldGroup<ACFFieldGroup>;
7
+ /**
8
+ * Represents an Advanced Custom Fields (ACF) Field Group configuration.
9
+ */
10
+ export interface ACFFieldGroup {
11
+ /**
12
+ * Unique identifier for the field group with group_ prefix (e.g. 'group_abc123')
13
+ */
14
+ key: string;
15
+ /**
16
+ * The title/name of this entity
17
+ */
18
+ title: string;
19
+ /**
20
+ * Array of field definitions. If empty array, field group appears but contains no fields.
21
+ */
22
+ fields: ACFField[];
23
+ /**
24
+ * The order of this entity in the admin menu
25
+ */
26
+ menu_order?: number;
27
+ /**
28
+ * [ACF] Whether this entity is active
29
+ */
30
+ active?: boolean;
31
+ /**
32
+ * [ACF Export Only] Unix timestamp of last modification
33
+ */
34
+ modified?: number;
35
+ /**
36
+ * Location rules determining where this field group appears. Array of rule groups (OR logic between groups, AND logic within groups). If omitted or empty, field group won't appear on any edit screens.
37
+ */
38
+ location?: ACFLocationGroup[];
39
+ /**
40
+ * Position of the field group on the edit screen
41
+ */
42
+ position?: "normal" | "side" | "acf_after_title";
43
+ /**
44
+ * Visual style of the field group metabox
45
+ */
46
+ style?: "default" | "seamless";
47
+ /**
48
+ * Placement of field labels relative to fields
49
+ */
50
+ label_placement?: "top" | "left";
51
+ /**
52
+ * Placement of field instructions
53
+ */
54
+ instruction_placement?: "label" | "field";
55
+ /**
56
+ * Screen elements to hide when this field group is displayed
57
+ */
58
+ hide_on_screen?: ("permalink" | "the_content" | "excerpt" | "custom_fields" | "discussion" | "comments" | "revisions" | "slug" | "author" | "format" | "page_attributes" | "featured_image" | "categories" | "tags" | "send-trackbacks")[];
59
+ /**
60
+ * Description of the field group
61
+ */
62
+ description?: string;
63
+ /**
64
+ * Whether to expose this field group's fields in the REST API
65
+ */
66
+ show_in_rest?: boolean | number;
67
+ /**
68
+ * Whether to expose this field group to AI integrations
69
+ */
70
+ allow_ai_access?: boolean | number;
71
+ /**
72
+ * Description that helps AI integrations understand how to use this field group
73
+ */
74
+ ai_description?: string;
75
+ /**
76
+ * Alternative display title for the field group
77
+ */
78
+ display_title?: string;
79
+ }
80
+ /**
81
+ * Group of location rules (AND logic within group)
82
+ */
83
+ export type ACFLocationGroup = [ACFLocationRule, ...ACFLocationRule[]];
84
+ export interface ACFLocationRule {
85
+ /**
86
+ * The parameter to compare (e.g. 'post_type', 'page_template', 'user_role')
87
+ */
88
+ param: string;
89
+ /**
90
+ * Comparison operator
91
+ */
92
+ operator: "==" | "!=";
93
+ /**
94
+ * Value to compare against
95
+ */
96
+ value: string;
97
+ [k: string]: unknown;
98
+ }
99
+ export {};
@@ -0,0 +1 @@
1
+ export {};