nextpress-core 1.0.0 → 1.0.1

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 (182) hide show
  1. package/dist/acf-functions/core/acf-builder.d.ts +50 -0
  2. package/{lib/acf-functions/core/acf-builder.ts → dist/acf-functions/core/acf-builder.js} +17 -41
  3. package/dist/acf-functions/core/acf-component-autoloader.d.ts +11 -0
  4. package/{lib/acf-functions/core/acf-component-autoloader.ts → dist/acf-functions/core/acf-component-autoloader.js} +7 -13
  5. package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +9 -0
  6. package/{lib/acf-functions/core/acf-field-group-autoloader.ts → dist/acf-functions/core/acf-field-group-autoloader.js} +4 -9
  7. package/dist/acf-functions/services/define-field-group.d.ts +8 -0
  8. package/{lib/acf-functions/services/define-field-group.ts → dist/acf-functions/services/define-field-group.js} +1 -1
  9. package/dist/acf-functions/services/define-layout.d.ts +8 -0
  10. package/{lib/acf-functions/services/define-layout.ts → dist/acf-functions/services/define-layout.js} +1 -1
  11. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +2 -0
  12. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.js +18 -0
  13. package/dist/acf-functions/services/map-fields/map-fields.d.ts +18 -0
  14. package/{lib/acf-functions/services/map-fields/map-fields.ts → dist/acf-functions/services/map-fields/map-fields.js} +88 -124
  15. package/dist/entities/option/option.d.ts +19 -0
  16. package/{lib/entities/option/option.ts → dist/entities/option/option.js} +13 -20
  17. package/dist/entities/post/post.d.ts +50 -0
  18. package/dist/entities/post/post.js +184 -0
  19. package/dist/entities/term/term.d.ts +28 -0
  20. package/dist/entities/term/term.js +67 -0
  21. package/dist/entities/user/user.d.ts +27 -0
  22. package/dist/entities/user/user.js +74 -0
  23. package/dist/globals/entity-loader/entity-loader-base.d.ts +65 -0
  24. package/{lib/globals/entity-loader/entity-loader-base.ts → dist/globals/entity-loader/entity-loader-base.js} +10 -64
  25. package/dist/globals/entity-loader/option-loader.d.ts +15 -0
  26. package/dist/globals/entity-loader/option-loader.js +31 -0
  27. package/dist/globals/entity-loader/post-loader.d.ts +21 -0
  28. package/dist/globals/entity-loader/post-loader.js +28 -0
  29. package/dist/globals/entity-loader/term-loader.d.ts +21 -0
  30. package/dist/globals/entity-loader/term-loader.js +28 -0
  31. package/dist/globals/entity-loader/user-loader.d.ts +21 -0
  32. package/dist/globals/entity-loader/user-loader.js +28 -0
  33. package/dist/globals/get-field/get-field.d.ts +17 -0
  34. package/dist/globals/get-field/get-field.js +44 -0
  35. package/dist/globals/globals.d.ts +18 -0
  36. package/{lib/globals/globals.ts → dist/globals/globals.js} +3 -8
  37. package/dist/globals/nextpress-config/nextpress-config.d.ts +4 -0
  38. package/{lib/globals/nextpress-config/nextpress-config.ts → dist/globals/nextpress-config/nextpress-config.js} +0 -5
  39. package/dist/globals/queried-object/queried-object.d.ts +62 -0
  40. package/dist/globals/queried-object/queried-object.js +56 -0
  41. package/dist/repository/optionquery/option-query.d.ts +12 -0
  42. package/dist/repository/optionquery/option-query.js +20 -0
  43. package/dist/repository/postquery/post-query.d.ts +12 -0
  44. package/dist/repository/postquery/post-query.js +272 -0
  45. package/dist/repository/termquery/term-query.d.ts +11 -0
  46. package/dist/repository/termquery/term-query.js +213 -0
  47. package/dist/repository/userquery/user-query.d.ts +12 -0
  48. package/{lib/repository/userquery/user-query.ts → dist/repository/userquery/user-query.js} +75 -91
  49. package/dist/router/helpers.d.ts +14 -0
  50. package/{lib/router/helpers.ts → dist/router/helpers.js} +4 -4
  51. package/dist/router/nextpress-layout.d.ts +11 -0
  52. package/{lib/router/nextpress-layout.tsx → dist/router/nextpress-layout.js} +6 -23
  53. package/dist/router/nextpress-proxy.d.ts +8 -0
  54. package/{lib/router/nextpress-proxy.ts → dist/router/nextpress-proxy.js} +3 -15
  55. package/dist/router/nextpress-static-params.d.ts +9 -0
  56. package/{lib/router/nextpress-static-params.ts → dist/router/nextpress-static-params.js} +5 -17
  57. package/dist/router/router.d.ts +23 -0
  58. package/{lib/router/router.tsx → dist/router/router.js} +21 -29
  59. package/dist/router/routes/api/api-get-admin-bar.d.ts +8 -0
  60. package/{lib/router/routes/api/api-get-admin-bar.ts → dist/router/routes/api/api-get-admin-bar.js} +6 -8
  61. package/dist/router/routes/api/api-get-draft-mode.d.ts +8 -0
  62. package/{lib/router/routes/api/api-get-draft-mode.ts → dist/router/routes/api/api-get-draft-mode.js} +6 -15
  63. package/dist/router/routes/api/api-get-field-groups.d.ts +7 -0
  64. package/{lib/router/routes/api/api-get-field-groups.ts → dist/router/routes/api/api-get-field-groups.js} +6 -11
  65. package/dist/router/routes/api/api-post-revalidate.d.ts +7 -0
  66. package/{lib/router/routes/api/api-post-revalidate.ts → dist/router/routes/api/api-post-revalidate.js} +4 -6
  67. package/dist/router/routes/api/helpers.d.ts +8 -0
  68. package/{lib/router/routes/api/helpers.ts → dist/router/routes/api/helpers.js} +3 -4
  69. package/dist/router/routes/author-archive.d.ts +25 -0
  70. package/{lib/router/routes/author-archive.tsx → dist/router/routes/author-archive.js} +11 -37
  71. package/dist/router/routes/not-found-page.d.ts +15 -0
  72. package/{lib/router/routes/not-found-page.tsx → dist/router/routes/not-found-page.js} +3 -5
  73. package/dist/router/routes/post-index-page.d.ts +25 -0
  74. package/dist/router/routes/post-index-page.js +33 -0
  75. package/dist/router/routes/singular-page.d.ts +29 -0
  76. package/dist/router/routes/singular-page.js +51 -0
  77. package/dist/router/routes/site-front-page.d.ts +27 -0
  78. package/dist/router/routes/site-front-page.js +26 -0
  79. package/dist/router/routes/term-archive.d.ts +29 -0
  80. package/{lib/router/routes/term-archive.tsx → dist/router/routes/term-archive.js} +17 -45
  81. package/dist/services/get-menu.d.ts +13 -0
  82. package/{lib/services/get-menu.ts → dist/services/get-menu.js} +32 -56
  83. package/dist/services/get-theme-mods.d.ts +7 -0
  84. package/{lib/services/get-theme-mods.ts → dist/services/get-theme-mods.js} +4 -6
  85. package/dist/services/metadata/get-blogname.d.ts +6 -0
  86. package/{lib/services/metadata/get-blogname.ts → dist/services/metadata/get-blogname.js} +2 -2
  87. package/dist/services/metadata/get-favicon-url.d.ts +6 -0
  88. package/{lib/services/metadata/get-favicon-url.ts → dist/services/metadata/get-favicon-url.js} +4 -5
  89. package/dist/services/metadata/get-language-attribute.d.ts +6 -0
  90. package/{lib/services/metadata/get-language-attribute.ts → dist/services/metadata/get-language-attribute.js} +1 -1
  91. package/{lib/services/services.ts → dist/services/services.d.ts} +1 -5
  92. package/dist/services/services.js +3 -0
  93. package/dist/services/utilities/capitalise-first-letter.d.ts +7 -0
  94. package/{lib/services/utilities/capitalise-first-letter.ts → dist/services/utilities/capitalise-first-letter.js} +3 -2
  95. package/dist/services/utilities/esc-html.d.ts +7 -0
  96. package/{lib/services/utilities/esc-html.ts → dist/services/utilities/esc-html.js} +1 -3
  97. package/dist/services/utilities/get-date-time-formatter.d.ts +6 -0
  98. package/{lib/services/utilities/get-date-time-formatter.ts → dist/services/utilities/get-date-time-formatter.js} +6 -16
  99. package/dist/services/utilities/index.js +1 -0
  100. package/dist/services/utilities/kses-post.d.ts +7 -0
  101. package/{lib/services/utilities/kses-post.ts → dist/services/utilities/kses-post.js} +1 -2
  102. package/dist/services/utilities/process-url.d.ts +7 -0
  103. package/{lib/services/utilities/process-url.ts → dist/services/utilities/process-url.js} +3 -4
  104. package/dist/template-heirarchy/_autoloader/template-autoloader.d.ts +9 -0
  105. package/{lib/template-heirarchy/_autoloader/template-autoloader.ts → dist/template-heirarchy/_autoloader/template-autoloader.js} +9 -18
  106. package/dist/template-heirarchy/archive/archive.d.ts +16 -0
  107. package/{lib/template-heirarchy/archive/archive.tsx → dist/template-heirarchy/archive/archive.js} +7 -10
  108. package/dist/template-heirarchy/archive/author.d.ts +16 -0
  109. package/{lib/template-heirarchy/archive/author.tsx → dist/template-heirarchy/archive/author.js} +7 -10
  110. package/dist/template-heirarchy/archive/category.d.ts +16 -0
  111. package/{lib/template-heirarchy/archive/category.tsx → dist/template-heirarchy/archive/category.js} +7 -11
  112. package/dist/template-heirarchy/archive/posttypearchive.d.ts +24 -0
  113. package/{lib/template-heirarchy/archive/posttypearchive.tsx → dist/template-heirarchy/archive/posttypearchive.js} +7 -10
  114. package/dist/template-heirarchy/archive/tag.d.ts +16 -0
  115. package/{lib/template-heirarchy/archive/tag.tsx → dist/template-heirarchy/archive/tag.js} +7 -12
  116. package/dist/template-heirarchy/archive/taxonomy.d.ts +16 -0
  117. package/{lib/template-heirarchy/archive/taxonomy.tsx → dist/template-heirarchy/archive/taxonomy.js} +7 -10
  118. package/dist/template-heirarchy/home/home.d.ts +16 -0
  119. package/{lib/template-heirarchy/home/home.tsx → dist/template-heirarchy/home/home.js} +7 -10
  120. package/dist/template-heirarchy/index.d.ts +17 -0
  121. package/{lib/template-heirarchy/index.tsx → dist/template-heirarchy/index.js} +5 -9
  122. package/dist/template-heirarchy/not-found.tsx/not-found.d.ts +16 -0
  123. package/{lib/template-heirarchy/not-found.tsx/not-found.tsx → dist/template-heirarchy/not-found.tsx/not-found.js} +7 -10
  124. package/dist/template-heirarchy/page/page.d.ts +16 -0
  125. package/{lib/template-heirarchy/page/page.tsx → dist/template-heirarchy/page/page.js} +7 -10
  126. package/dist/template-heirarchy/page/posttype.d.ts +24 -0
  127. package/{lib/template-heirarchy/page/posttype.tsx → dist/template-heirarchy/page/posttype.js} +7 -11
  128. package/dist/template-heirarchy/page/single.d.ts +16 -0
  129. package/{lib/template-heirarchy/page/single.tsx → dist/template-heirarchy/page/single.js} +7 -10
  130. package/dist/template-heirarchy/page/singular.d.ts +16 -0
  131. package/{lib/template-heirarchy/page/singular.tsx → dist/template-heirarchy/page/singular.js} +7 -10
  132. package/dist/ui/render-attachment-image.d.ts +12 -0
  133. package/dist/ui/render-attachment-image.js +24 -0
  134. package/{lib/ui/render-components.tsx → dist/ui/render-components.d.ts} +4 -7
  135. package/dist/ui/render-components.js +7 -0
  136. package/dist/ui/render-the-admin-bar.d.ts +8 -0
  137. package/dist/ui/render-the-admin-bar.js +36 -0
  138. package/dist/ui/render-the-logo.d.ts +10 -0
  139. package/dist/ui/render-the-logo.js +16 -0
  140. package/dist/wpdb/wpdb.d.ts +3 -0
  141. package/{lib/wpdb/wpdb.ts → dist/wpdb/wpdb.js} +5 -9
  142. package/package.json +7 -3
  143. package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +0 -20
  144. package/lib/acf-functions/types/acf-field-group.d.ts +0 -118
  145. package/lib/acf-functions/types/acf-field.d.ts +0 -2851
  146. package/lib/acf-functions/types/acf-layout.d.ts +0 -20
  147. package/lib/acf-functions/types/acf-values.d.ts +0 -4
  148. package/lib/acf-functions/types/components/field-props.d.ts +0 -189
  149. package/lib/acf-functions/types/components/nextpress-component.d.ts +0 -11
  150. package/lib/ambient.d.ts +0 -15
  151. package/lib/entities/common.d.ts +0 -30
  152. package/lib/entities/option/option.interface.d.ts +0 -8
  153. package/lib/entities/post/post.interface.d.ts +0 -72
  154. package/lib/entities/post/post.ts +0 -209
  155. package/lib/entities/term/term.interface.d.ts +0 -8
  156. package/lib/entities/term/term.ts +0 -82
  157. package/lib/entities/user/user.interface.d.ts +0 -10
  158. package/lib/entities/user/user.ts +0 -86
  159. package/lib/globals/entity-loader/entity-loader.d.ts +0 -50
  160. package/lib/globals/entity-loader/option-loader.ts +0 -56
  161. package/lib/globals/entity-loader/post-loader.ts +0 -59
  162. package/lib/globals/entity-loader/term-loader.ts +0 -59
  163. package/lib/globals/entity-loader/user-loader.ts +0 -60
  164. package/lib/globals/get-field/get-field.ts +0 -75
  165. package/lib/globals/nextpress-config/nextpress-config.interface.d.ts +0 -18
  166. package/lib/globals/queried-object/queried-object.ts +0 -124
  167. package/lib/repository/optionquery/option-query-args.d.ts +0 -21
  168. package/lib/repository/optionquery/option-query.ts +0 -29
  169. package/lib/repository/postquery/post-query-args.d.ts +0 -108
  170. package/lib/repository/postquery/post-query.ts +0 -281
  171. package/lib/repository/termquery/term-query-args.d.ts +0 -61
  172. package/lib/repository/termquery/term-query.ts +0 -243
  173. package/lib/repository/userquery/user-query-args.d.ts +0 -75
  174. package/lib/router/routes/post-index-page.tsx +0 -58
  175. package/lib/router/routes/singular-page.tsx +0 -78
  176. package/lib/router/routes/site-front-page.tsx +0 -51
  177. package/lib/router/types.d.ts +0 -9
  178. package/lib/ui/render-attachment-image.tsx +0 -29
  179. package/lib/ui/render-the-admin-bar.tsx +0 -79
  180. package/lib/ui/render-the-logo.tsx +0 -24
  181. package/lib/wpdb/wpdb.interface.d.ts +0 -171
  182. /package/{lib/services/utilities/index.ts → dist/services/utilities/index.d.ts} +0 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Class representing ACF builder.
3
+ */
4
+ export declare class ACFBuilder {
5
+ /** Array of ACF field groups. */
6
+ private fieldGroups;
7
+ constructor();
8
+ /**
9
+ * Gets built field groups.
10
+ *
11
+ * @returns {ACFFieldGroup[]} Array of field groups.
12
+ */
13
+ getFieldGroups(): ACFFieldGroup[];
14
+ /**
15
+ * Converts field groups to JSON string.
16
+ *
17
+ * @returns {string} JSON string representation of field groups.
18
+ */
19
+ toJSON(): string;
20
+ /**
21
+ * Registers and processes Nextpress field groups.
22
+ *
23
+ * @param {NextpressFieldGroup[]} fieldGroups - Array of field groups to register.
24
+ * @returns {this} Current instance.
25
+ */
26
+ registerFieldGroups(fieldGroups: NextpressFieldGroup[]): this;
27
+ /**
28
+ * Sets keys for fields based on parent name.
29
+ *
30
+ * @param {NextpressField[]} fields - Array of fields to process.
31
+ * @param {string} parentName - Parent string name.
32
+ * @returns {ACFField[]} Array of fields with generated keys.
33
+ */
34
+ private setFieldKeys;
35
+ /**
36
+ * Sets keys for layouts based on parent name.
37
+ *
38
+ * @param {NextpressLayout[]} layouts - Array of layouts to process.
39
+ * @param {string} parentName - Parent string name.
40
+ * @returns {ACFLayout[]} Array of layouts with generated keys.
41
+ */
42
+ private setLayoutKeys;
43
+ /**
44
+ * Formats suffix string.
45
+ *
46
+ * @param {string} suffix - Suffix to format.
47
+ * @returns {string} Formatted string.
48
+ */
49
+ private formatKeySuffix;
50
+ }
@@ -1,49 +1,39 @@
1
1
  /**
2
2
  * Class representing ACF builder.
3
3
  */
4
- export class ACFBuilder
5
- {
6
- /** Array of ACF field groups. */
7
- private fieldGroups: ACFFieldGroup[] = [];
8
-
9
- public constructor() {};
10
-
4
+ export class ACFBuilder {
5
+ constructor() {
6
+ /** Array of ACF field groups. */
7
+ this.fieldGroups = [];
8
+ }
9
+ ;
11
10
  /**
12
11
  * Gets built field groups.
13
12
  *
14
13
  * @returns {ACFFieldGroup[]} Array of field groups.
15
14
  */
16
- public getFieldGroups(): ACFFieldGroup[] {
15
+ getFieldGroups() {
17
16
  return this.fieldGroups;
18
17
  }
19
-
20
18
  /**
21
19
  * Converts field groups to JSON string.
22
20
  *
23
21
  * @returns {string} JSON string representation of field groups.
24
22
  */
25
- public toJSON(): string {
23
+ toJSON() {
26
24
  return JSON.stringify(this.fieldGroups);
27
25
  }
28
-
29
26
  /**
30
27
  * Registers and processes Nextpress field groups.
31
28
  *
32
29
  * @param {NextpressFieldGroup[]} fieldGroups - Array of field groups to register.
33
30
  * @returns {this} Current instance.
34
31
  */
35
- public registerFieldGroups(fieldGroups: NextpressFieldGroup[]): this {
36
- const keyedFieldGroups: ACFFieldGroup[] = fieldGroups.map(fieldGroup => ({
37
- ...fieldGroup,
38
- key: `group_${this.formatKeySuffix(fieldGroup.title)}`,
39
- fields: this.setFieldKeys(fieldGroup.fields, fieldGroup.title),
40
- }));
41
-
32
+ registerFieldGroups(fieldGroups) {
33
+ const keyedFieldGroups = fieldGroups.map(fieldGroup => (Object.assign(Object.assign({}, fieldGroup), { key: `group_${this.formatKeySuffix(fieldGroup.title)}`, fields: this.setFieldKeys(fieldGroup.fields, fieldGroup.title) })));
42
34
  this.fieldGroups = [...this.fieldGroups, ...keyedFieldGroups];
43
-
44
35
  return this;
45
36
  }
46
-
47
37
  /**
48
38
  * Sets keys for fields based on parent name.
49
39
  *
@@ -51,26 +41,18 @@ export class ACFBuilder
51
41
  * @param {string} parentName - Parent string name.
52
42
  * @returns {ACFField[]} Array of fields with generated keys.
53
43
  */
54
- private setFieldKeys(fields: NextpressField[], parentName: string): ACFField[] {
44
+ setFieldKeys(fields, parentName) {
55
45
  return fields.map(field => {
56
46
  const keySuffix = this.formatKeySuffix(`${parentName}_${field.name}`);
57
-
58
47
  const childFields = field.sub_fields
59
48
  ? this.setFieldKeys(field.sub_fields, keySuffix)
60
49
  : undefined;
61
-
62
50
  const childLayouts = field.layouts
63
51
  ? this.setLayoutKeys(field.layouts, keySuffix)
64
52
  : undefined;
65
-
66
- return {
67
- ...field,
68
- key: `field_${keySuffix}`,
69
- sub_fields: childFields,
70
- layouts: childLayouts
71
- }});
53
+ return Object.assign(Object.assign({}, field), { key: `field_${keySuffix}`, sub_fields: childFields, layouts: childLayouts });
54
+ });
72
55
  }
73
-
74
56
  /**
75
57
  * Sets keys for layouts based on parent name.
76
58
  *
@@ -78,28 +60,22 @@ export class ACFBuilder
78
60
  * @param {string} parentName - Parent string name.
79
61
  * @returns {ACFLayout[]} Array of layouts with generated keys.
80
62
  */
81
- private setLayoutKeys(layouts: NextpressLayout[], parentName: string): ACFLayout[] {
63
+ setLayoutKeys(layouts, parentName) {
82
64
  return layouts.map(layout => {
83
65
  const keySuffix = this.formatKeySuffix(`${parentName}_${layout.name}`);
84
-
85
66
  const childFields = layout.sub_fields
86
67
  ? this.setFieldKeys(layout.sub_fields, `${parentName}_${layout.name}`)
87
68
  : undefined;
88
-
89
- return {
90
- ...layout,
91
- key: `layout_${keySuffix}`,
92
- sub_fields: childFields || [],
93
- }})
69
+ return Object.assign(Object.assign({}, layout), { key: `layout_${keySuffix}`, sub_fields: childFields || [] });
70
+ });
94
71
  }
95
-
96
72
  /**
97
73
  * Formats suffix string.
98
74
  *
99
75
  * @param {string} suffix - Suffix to format.
100
76
  * @returns {string} Formatted string.
101
77
  */
102
- private formatKeySuffix(suffix: string): string {
78
+ formatKeySuffix(suffix) {
103
79
  return suffix.replace(/[\s-]+/g, '_').toLowerCase();
104
80
  }
105
81
  }
@@ -0,0 +1,11 @@
1
+ import { NextpressComponent } from '../types/components/nextpress-component';
2
+ /**
3
+ * Autoloads ACF components dynamically from the templates directory.
4
+ * * **Requirements for it to work:**
5
+ * Each `.tsx` file within the `src/app/_templates/components/` directory MUST export the following:
6
+ * 1. `layout` (Named Export): The configuration for the ACF layout, typically defined using the `defineLayout` function.
7
+ * 2. `default` (Default Export): The React component (JSX/TSX function) that renders the layout.
8
+ *
9
+ * @returns {Promise<NextpressComponent[]>} A promise resolving to an array of mapped layout configurations and their respective components.
10
+ */
11
+ export declare function acfComponentAutoloader(): Promise<NextpressComponent[]>;
@@ -1,7 +1,5 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { NextpressComponent } from '../types/components/nextpress-component';
4
-
5
3
  /**
6
4
  * Autoloads ACF components dynamically from the templates directory.
7
5
  * * **Requirements for it to work:**
@@ -11,23 +9,19 @@ import { NextpressComponent } from '../types/components/nextpress-component';
11
9
  *
12
10
  * @returns {Promise<NextpressComponent[]>} A promise resolving to an array of mapped layout configurations and their respective components.
13
11
  */
14
- export async function acfComponentAutoloader(): Promise<NextpressComponent[]> {
12
+ export async function acfComponentAutoloader() {
15
13
  const absolutePath = path.join(process.cwd(), 'src', 'app', '_templates', 'components');
16
14
  const files = fs.readdirSync(absolutePath);
17
-
18
- const layouts: NextpressComponent[] = [];
19
-
15
+ const layouts = [];
20
16
  for (const file of files) {
21
- if (!file.endsWith('.tsx')) continue;
22
-
17
+ if (!file.endsWith('.tsx'))
18
+ continue;
23
19
  const imported = await import(`@/app/_templates/components/${file}`);
24
-
25
20
  const layout = imported.layout;
26
21
  const component = imported.default;
27
- if (!layout || !component) continue;
28
-
29
- layouts.push({layout, Component: component});
22
+ if (!layout || !component)
23
+ continue;
24
+ layouts.push({ layout, Component: component });
30
25
  }
31
-
32
26
  return layouts;
33
27
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Autoloads ACF field groups dynamically from the field-groups directory.
3
+ * * **Requirements for it to work:**
4
+ * Each `.ts` file within the `src/app/_templates/components/field-groups/` directory MUST export the following:
5
+ * 1. `default` (Default Export): The configuration object for the ACF Field Group, typically defined using the `defineFieldGroup` function.
6
+ *
7
+ * @returns {Promise<NextpressFieldGroup[]>} A promise resolving to an array of loaded ACF field group configurations.
8
+ */
9
+ export declare function acfFieldGroupAutoloader(): Promise<NextpressFieldGroup[]>;
@@ -1,6 +1,5 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
-
4
3
  /**
5
4
  * Autoloads ACF field groups dynamically from the field-groups directory.
6
5
  * * **Requirements for it to work:**
@@ -9,20 +8,16 @@ import path from 'path';
9
8
  *
10
9
  * @returns {Promise<NextpressFieldGroup[]>} A promise resolving to an array of loaded ACF field group configurations.
11
10
  */
12
- export async function acfFieldGroupAutoloader(): Promise<NextpressFieldGroup[]> {
11
+ export async function acfFieldGroupAutoloader() {
13
12
  const absolutePath = path.join(process.cwd(), 'src', 'app', '_templates', 'components', 'field-groups');
14
13
  const files = fs.readdirSync(absolutePath);
15
-
16
- const fieldGroups: NextpressFieldGroup[] = [];
17
-
14
+ const fieldGroups = [];
18
15
  for (const file of files) {
19
- if (!file.endsWith('.ts')) continue;
20
-
16
+ if (!file.endsWith('.ts'))
17
+ continue;
21
18
  const imported = await import(`@/app/_templates/components/field-groups/${file}`);
22
19
  const fieldGroup = imported.default;
23
-
24
20
  fieldGroups.push(fieldGroup);
25
21
  }
26
-
27
22
  return fieldGroups;
28
23
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Defines field group configuration and applies typing.
3
+ *
4
+ * @template T - Field group type extending NextpressFieldGroup.
5
+ * @param {T} layout - Field group configuration object.
6
+ * @returns {T} Passed field group configuration object.
7
+ */
8
+ export declare function defineFieldGroup<const T extends NextpressFieldGroup>(layout: T): T;
@@ -5,6 +5,6 @@
5
5
  * @param {T} layout - Field group configuration object.
6
6
  * @returns {T} Passed field group configuration object.
7
7
  */
8
- export function defineFieldGroup<const T extends NextpressFieldGroup>(layout: T): T {
8
+ export function defineFieldGroup(layout) {
9
9
  return layout;
10
10
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Defines layout configuration and applies typing.
3
+ *
4
+ * @template T - Layout type extending NextpressLayout.
5
+ * @param {T} layout - Layout configuration object.
6
+ * @returns {T} Passed layout configuration object.
7
+ */
8
+ export declare function defineLayout<const T extends NextpressLayout>(layout: T): T;
@@ -5,6 +5,6 @@
5
5
  * @param {T} layout - Layout configuration object.
6
6
  * @returns {T} Passed layout configuration object.
7
7
  */
8
- export function defineLayout<const T extends NextpressLayout>(layout: T): T {
8
+ export function defineLayout(layout) {
9
9
  return layout;
10
10
  }
@@ -0,0 +1,2 @@
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;
@@ -0,0 +1,18 @@
1
+ export function mapChoiceObject(return_format, value, choices) {
2
+ if (return_format === 'value') {
3
+ return value;
4
+ }
5
+ if (!choices)
6
+ return;
7
+ const label = choices[value !== null && value !== void 0 ? value : ''];
8
+ if (return_format === 'array') {
9
+ const result = {
10
+ label: label,
11
+ value: value
12
+ };
13
+ return result;
14
+ }
15
+ else if (return_format === 'label') {
16
+ return label;
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Maps individual ACF field to corresponding value.
3
+ *
4
+ * @param {NextpressField} field - Field configuration.
5
+ * @param {ACFRawValues} rawValues - Raw values map.
6
+ * @returns {Promise<any>} Promise resolving to mapped value.
7
+ */
8
+ export declare function mapField(field: NextpressField, rawValues: ACFRawValues): Promise<any>;
9
+ /**
10
+ * Maps layout configuration to values object.
11
+ *
12
+ * @param {NextpressLayout} layout - Layout configuration.
13
+ * @param {ACFRawValues} rawValues - Raw values map.
14
+ * @returns {Promise<{ [key: string]: any }>} Promise resolving to layout values object.
15
+ */
16
+ export declare function mapLayout(layout: NextpressLayout, rawValues: ACFRawValues): Promise<{
17
+ [key: string]: any;
18
+ }>;