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
|
|
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`);
|
package/dist/integration.js
CHANGED
package/package.json
CHANGED