@pixldocs/canvas-renderer 0.5.54 → 0.5.55

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
@@ -482,16 +482,29 @@ export declare function resolveFromForm(options: ResolveFromFormOptions): Promis
482
482
  export declare interface ResolveFromFormOptions {
483
483
  /** Template UUID */
484
484
  templateId: string;
485
- /** Form schema UUID */
486
- formSchemaId: string;
487
- /** V2 section state (same shape sent to /render-from-form) */
488
- sectionState: SectionFormState;
485
+ /**
486
+ * Form schema UUID. Optional — omit for templates with manual `dynamicFields`
487
+ * that are not bound to a saved form schema.
488
+ */
489
+ formSchemaId?: string;
490
+ /**
491
+ * V2 section state (same shape sent to /render-from-form). Optional when
492
+ * `flatFormData` is provided (manual-fields path).
493
+ */
494
+ sectionState?: SectionFormState;
495
+ /**
496
+ * Flat key/value map of dynamic-field values, keyed by `dynamicField.id`.
497
+ * Use this for manual-fields templates with no `formSchemaId` — values
498
+ * are applied directly through `applyFormDataToConfig` without going
499
+ * through the section-state flatten step.
500
+ */
501
+ flatFormData?: Record<string, unknown>;
489
502
  /** Optional theme variant ID (default: 'default') */
490
503
  themeId?: string;
491
504
  /** Supabase project URL */
492
- supabaseUrl: string;
505
+ supabaseUrl?: string;
493
506
  /** Supabase anon key */
494
- supabaseAnonKey: string;
507
+ supabaseAnonKey?: string;
495
508
  /** Optional prefetched rows from a trusted server so browser-side package resolution can skip REST fetches entirely. */
496
509
  prefetched?: {
497
510
  templateRow?: {
@@ -530,9 +543,24 @@ export declare interface ResolveOptions {
530
543
  /** Optional flat formData (legacy, simple fields only) */
531
544
  formData?: Record<string, any>;
532
545
  /** Supabase project URL */
533
- supabaseUrl: string;
546
+ supabaseUrl?: string;
534
547
  /** Supabase anon key */
535
- supabaseAnonKey: string;
548
+ supabaseAnonKey?: string;
549
+ /**
550
+ * Optional prefetched template row from a trusted server. When provided
551
+ * the resolver skips the REST fetch — useful for the EC2 v2 pipeline where
552
+ * the server already has the row in memory.
553
+ */
554
+ prefetched?: {
555
+ templateRow?: {
556
+ id?: string;
557
+ name?: string;
558
+ price?: number;
559
+ config: TemplateConfig;
560
+ form_schema?: unknown;
561
+ default_data?: unknown;
562
+ };
563
+ };
536
564
  }
537
565
 
538
566
  export declare function resolveTemplateData(options: ResolveOptions): Promise<ResolvedTemplate>;
package/dist/index.js CHANGED
@@ -11674,8 +11674,8 @@ function deriveRepeatablePagesFromTemplate(config, inlineFormSchema, formData) {
11674
11674
  return out;
11675
11675
  }
11676
11676
  async function resolveTemplateData(options) {
11677
- const { templateId, formData, supabaseUrl, supabaseAnonKey } = options;
11678
- const template = await fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId);
11677
+ const { templateId, formData, supabaseUrl, supabaseAnonKey, prefetched } = options;
11678
+ const template = (prefetched == null ? void 0 : prefetched.templateRow) ? prefetched.templateRow : await fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId);
11679
11679
  let config = template.config;
11680
11680
  const inlineFormSchema = template.form_schema;
11681
11681
  const defaultData = template.default_data;
@@ -11742,7 +11742,16 @@ async function resolveTemplateData(options) {
11742
11742
  }
11743
11743
  async function resolveFromForm(options) {
11744
11744
  var _a, _b, _c;
11745
- const { templateId, formSchemaId, sectionState, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
11745
+ const { templateId, formSchemaId, sectionState, flatFormData: directFlatFormData, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
11746
+ if (!formSchemaId) {
11747
+ return resolveTemplateData({
11748
+ templateId,
11749
+ formData: directFlatFormData ?? sectionState ?? {},
11750
+ supabaseUrl,
11751
+ supabaseAnonKey,
11752
+ prefetched: (prefetched == null ? void 0 : prefetched.templateRow) ? { templateRow: prefetched.templateRow } : void 0
11753
+ });
11754
+ }
11746
11755
  const [templateRow, formSchemaRow, defaultForm] = await Promise.all([
11747
11756
  (prefetched == null ? void 0 : prefetched.templateRow) ? Promise.resolve(prefetched.templateRow) : fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
11748
11757
  (prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),