ayezee-astro-cms 1.9.0 → 1.9.2

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.
@@ -15,7 +15,22 @@
15
15
  * ```
16
16
  */
17
17
 
18
- import { getFormConfig } from '../cms-helper.js';
18
+ import fs from 'fs';
19
+ import path from 'path';
20
+ import { initCmsHelper, getFormConfig, type CMSCache } from '../cms-helper.js';
21
+
22
+ // Auto-initialize CMS helper if not already initialized
23
+ // This ensures the form component works even if the consuming project
24
+ // hasn't imported from the generated cms.ts wrapper yet
25
+ try {
26
+ getFormConfig('__test__');
27
+ } catch {
28
+ const cachePath = path.join(process.cwd(), 'src', 'data', 'cms-cache.json');
29
+ if (fs.existsSync(cachePath)) {
30
+ const cacheData = JSON.parse(fs.readFileSync(cachePath, 'utf-8')) as CMSCache;
31
+ initCmsHelper(cacheData);
32
+ }
33
+ }
19
34
 
20
35
  export interface Props {
21
36
  /** Module label, slug, or instance key to identify the form */
@@ -65,7 +80,11 @@ if (!moduleIdentifier) {
65
80
  throw new Error('AyezeeForm requires either "label" or "instanceKey" prop');
66
81
  }
67
82
 
68
- const formConfig = getFormConfig(moduleIdentifier);
83
+ const formConfig = getFormConfig(moduleIdentifier, {
84
+ apiKey: import.meta.env.PUBLIC_AYEZEE_API_KEY,
85
+ cmsDomain: import.meta.env.PUBLIC_CMS_DOMAIN,
86
+ projectSlug: import.meta.env.PUBLIC_PROJECT_SLUG,
87
+ });
69
88
 
70
89
  if (!formConfig.module) {
71
90
  throw new Error(`Form module "${moduleIdentifier}" not found`);
@@ -16,7 +16,7 @@
16
16
  import fs from 'fs';
17
17
  import path from 'path';
18
18
  // Package version - automatically updated during build
19
- const PACKAGE_VERSION = '1.7.0';
19
+ const PACKAGE_VERSION = '1.9.1';
20
20
  /**
21
21
  * Load environment variables from .env file
22
22
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ayezee-astro-cms",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "AyeZee CMS integration for Astro with automatic data fetching, form handling, validation, and analytics",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",