@funnelsgrove/cli 0.1.281 → 0.1.283

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/cli.js CHANGED
@@ -19,7 +19,7 @@ import { pullEnvFile } from './envSync.js';
19
19
  import { executeFastDraftPatchSync, uploadDirectAssetWithFetch } from './draftPatchSync.js';
20
20
  import { updateCliInstallations } from './selfUpdate.js';
21
21
  import { executeExpensePublish, executeExpensePull } from './expenseCommands.js';
22
- import { executeEmailPull, executeEmailPush, executeEmailSend, executeEmailUpdateVariables, executeEmailSequenceAddStep, executeEmailSequenceCancel, executeEmailSequenceCreate, executeEmailSequencePublish, executeEmailSequenceSetActive, executeEmailTemplatePublish, executeEmailValidate, parseEmailVariablesJson, } from './emailCommands.js';
22
+ import { executeEmailPull, executeEmailPush, executeEmailSend, executeEmailUpdateVariables, executeEmailSequenceAddStep, executeEmailSequenceCancel, executeEmailSequenceCreate, executeEmailSequencePublish, executeEmailSequenceSetActive, executeEmailLibraryAdd, executeEmailLibraryList, executeEmailTemplatePublish, executeEmailValidate, parseEmailVariablesJson, } from './emailCommands.js';
23
23
  import { formatGitHubConnectRows, formatGitHubJobRows, formatGitHubStatusRows, } from './githubOutput.js';
24
24
  import { GitHubSyncTimeoutError, syncGitHubDraftIfConnected, } from './githubSyncFlow.js';
25
25
  import { reskinFunnel } from './reskin.js';
@@ -1800,6 +1800,8 @@ const emailCommand = addExamples(program.command('email').description('Manage pr
1800
1800
  'fgrove email push',
1801
1801
  'fgrove email send --template welcome --to delivered@example.com',
1802
1802
  'fgrove email template publish welcome',
1803
+ 'fgrove email library list',
1804
+ 'fgrove email library add subscription-receipt --app-name "Lumen" --manage-url https://lumen.example.com/manage',
1803
1805
  ]);
1804
1806
  emailCommand
1805
1807
  .command('send')
@@ -1890,6 +1892,51 @@ addEmailScopeOptions(emailTemplateCommand
1890
1892
  });
1891
1893
  console.log(`Published email template ${slug}.`);
1892
1894
  });
1895
+ const emailLibraryCommand = emailCommand.command('library').description('Browse and copy shared email templates');
1896
+ addEmailScopeOptions(emailLibraryCommand
1897
+ .command('list')
1898
+ .description('List shared templates, their variables and the project footer defaults'))
1899
+ .option('--json', 'Print the full library response as JSON')
1900
+ .action(async (options) => {
1901
+ const library = await executeEmailLibraryList(await resolveEmailCommandScope(options));
1902
+ if (options.json) {
1903
+ console.log(JSON.stringify(library, null, 2));
1904
+ return;
1905
+ }
1906
+ for (const template of library.templates) {
1907
+ console.log(`${template.slug}\t${template.name}\t${template.summary}`);
1908
+ for (const [name, type] of Object.entries(template.variables)) {
1909
+ console.log(` ${name} (${type})\t${template.variableDescriptions[name] || ''}`);
1910
+ }
1911
+ }
1912
+ console.log(`defaults\tsupportEmail=${library.defaults.supportEmail || '-'}\ttermsUrl=${library.defaults.termsUrl || '-'}\tprivacyUrl=${library.defaults.privacyUrl || '-'}`);
1913
+ });
1914
+ addEmailScopeOptions(emailLibraryCommand
1915
+ .command('add <library-slug>')
1916
+ .description('Copy a shared template into the project as a draft and write it locally'))
1917
+ .requiredOption('--app-name <name>', 'App name shown in the email')
1918
+ .requiredOption('--manage-url <url>', 'HTTPS page where customers change or cancel their subscription')
1919
+ .option('--icon-url <url>', 'HTTPS URL of a square app icon (PNG, at least 176x176), ideally hosted on the domain you send email from. Omit to use a generic app icon')
1920
+ .option('--support-email <email>', 'Support email in the footer (defaults to the project support email)')
1921
+ .option('--terms-url <url>', 'Terms of Service URL (defaults to the project setting)')
1922
+ .option('--privacy-url <url>', 'Privacy Policy URL (defaults to the project setting)')
1923
+ .option('--slug <slug>', 'Project template slug (defaults to the library slug)')
1924
+ .action(async (librarySlug, options) => {
1925
+ const template = await executeEmailLibraryAdd({
1926
+ ...await resolveEmailCommandScope(options),
1927
+ librarySlug,
1928
+ slug: options.slug,
1929
+ settings: {
1930
+ appName: options.appName,
1931
+ manageSubscriptionUrl: options.manageUrl,
1932
+ ...(options.iconUrl ? { appIconUrl: options.iconUrl } : {}),
1933
+ ...(options.supportEmail ? { supportEmail: options.supportEmail } : {}),
1934
+ ...(options.termsUrl ? { termsUrl: options.termsUrl } : {}),
1935
+ ...(options.privacyUrl ? { privacyUrl: options.privacyUrl } : {}),
1936
+ },
1937
+ });
1938
+ console.log(`Added email template ${template.slug} as a draft. Review ${path.join(options.dir, 'emails', 'templates', template.slug)}, then run fgrove email template publish ${template.slug}.`);
1939
+ });
1893
1940
  const emailSequenceCommand = emailCommand.command('sequence').description('Manage email sequences');
1894
1941
  const parseEmailSequenceDelay = (options) => {
1895
1942
  const hasHours = options.delayHours !== undefined;
@@ -1,4 +1,4 @@
1
- import { type EmailFilesResult, type EmailEventType } from './emailFiles.js';
1
+ import { type EmailFilesResult, type EmailEventType, type EmailTemplateFile } from './emailFiles.js';
2
2
  export type EmailCallApi = <T>(input: {
3
3
  path: string;
4
4
  type: 'query' | 'mutation';
@@ -94,6 +94,33 @@ export declare function executeEmailSequenceSetActive(input: EmailCommandScope &
94
94
  slug: string;
95
95
  active: boolean;
96
96
  }): Promise<void>;
97
+ export type EmailLibraryList = {
98
+ defaults: {
99
+ supportEmail: string | null;
100
+ termsUrl: string | null;
101
+ privacyUrl: string | null;
102
+ };
103
+ templates: Array<{
104
+ slug: string;
105
+ name: string;
106
+ summary: string;
107
+ variables: Record<string, string>;
108
+ variableDescriptions: Record<string, string>;
109
+ }>;
110
+ };
111
+ export declare const executeEmailLibraryList: (scope: EmailCommandScope) => Promise<EmailLibraryList>;
112
+ export declare function executeEmailLibraryAdd(input: EmailCommandScope & {
113
+ librarySlug: string;
114
+ slug?: string;
115
+ settings: {
116
+ appName: string;
117
+ appIconUrl?: string;
118
+ manageSubscriptionUrl: string;
119
+ supportEmail?: string;
120
+ termsUrl?: string;
121
+ privacyUrl?: string;
122
+ };
123
+ }): Promise<EmailTemplateFile>;
97
124
  export declare function executeEmailTemplatePublish(scope: EmailCommandScope & {
98
125
  slug: string;
99
126
  }): Promise<unknown>;
@@ -199,6 +199,7 @@ const assertRemoteIdentities = async (scope, input) => {
199
199
  const canonicalResource = (kind, value) => {
200
200
  if (kind === 'template') {
201
201
  const variables = isRecord(value.draft.variables) ? value.draft.variables : {};
202
+ const variableDescriptions = isRecord(value.draft.variableDescriptions) ? value.draft.variableDescriptions : {};
202
203
  return JSON.stringify({
203
204
  name: value.name,
204
205
  subject: value.draft.subject,
@@ -206,6 +207,7 @@ const canonicalResource = (kind, value) => {
206
207
  html: value.draft.html,
207
208
  text: value.draft.text,
208
209
  variables: Object.fromEntries(Object.entries(variables).sort(([left], [right]) => left.localeCompare(right))),
210
+ variableDescriptions: Object.fromEntries(Object.entries(variableDescriptions).sort(([left], [right]) => left.localeCompare(right))),
209
211
  });
210
212
  }
211
213
  const steps = Array.isArray(value.draft.steps) ? value.draft.steps : [];
@@ -301,7 +303,7 @@ export async function executeEmailPush(scope) {
301
303
  ...projectData(scope),
302
304
  templateId: template.id,
303
305
  name: template.name,
304
- draft: template.draft,
306
+ draft: { ...template.draft, variableDescriptions: template.draft.variableDescriptions ?? {} },
305
307
  },
306
308
  });
307
309
  continue;
@@ -314,7 +316,7 @@ export async function executeEmailPush(scope) {
314
316
  ...projectData(scope),
315
317
  slug: template.slug,
316
318
  name: template.name,
317
- draft: template.draft,
319
+ draft: { ...template.draft, variableDescriptions: template.draft.variableDescriptions ?? {} },
318
320
  },
319
321
  });
320
322
  template.id = assertCreatedId(created, 'email template');
@@ -471,6 +473,39 @@ export async function executeEmailSequenceSetActive(input) {
471
473
  },
472
474
  });
473
475
  }
476
+ export const executeEmailLibraryList = (scope) => (scope.callApi({
477
+ path: 'emailTemplates.library',
478
+ type: 'query',
479
+ token: scope.token,
480
+ data: projectData(scope),
481
+ }));
482
+ export async function executeEmailLibraryAdd(input) {
483
+ const files = await readEmailFiles(input.sourceDir);
484
+ assertValidFiles(files);
485
+ const slug = input.slug || input.librarySlug;
486
+ if (files.templates.some((item) => item.slug === slug)) {
487
+ throw new Error(`Email template "${slug}" already exists locally.`);
488
+ }
489
+ const created = await input.callApi({
490
+ path: 'emailTemplates.copyFromLibrary',
491
+ type: 'mutation',
492
+ token: input.token,
493
+ data: {
494
+ ...projectData(input),
495
+ librarySlug: input.librarySlug,
496
+ ...(input.slug ? { slug: input.slug } : {}),
497
+ settings: input.settings,
498
+ },
499
+ });
500
+ const template = {
501
+ id: assertCreatedId(created, 'email template'),
502
+ slug: created.slug,
503
+ name: created.name,
504
+ draft: created.draft,
505
+ };
506
+ await writeEmailTemplateFile(input.sourceDir, template);
507
+ return template;
508
+ }
474
509
  export async function executeEmailTemplatePublish(scope) {
475
510
  return executeEmailPublish(scope, {
476
511
  kind: 'template',
@@ -8,6 +8,7 @@ export type EmailTemplateDraft = {
8
8
  html: string;
9
9
  text: string;
10
10
  variables: Record<string, EmailTemplateVariableType>;
11
+ variableDescriptions?: Record<string, string>;
11
12
  };
12
13
  export type EmailTemplateFile = {
13
14
  id: string | null;
@@ -24,6 +24,7 @@ const TEMPLATE_METADATA_KEYS = new Set([
24
24
  'subject',
25
25
  'previewText',
26
26
  'variables',
27
+ 'variableDescriptions',
27
28
  ]);
28
29
  const SEQUENCE_KEYS = new Set([
29
30
  'id',
@@ -219,9 +220,37 @@ const validateTemplateMetadata = (value, pathSlug, file, diagnostics) => {
219
220
  }
220
221
  }
221
222
  }
223
+ const variableDescriptions = {};
224
+ if (value.variableDescriptions !== undefined) {
225
+ if (!isRecord(value.variableDescriptions) || Object.getPrototypeOf(value.variableDescriptions) !== Object.prototype) {
226
+ diagnostics.push(schemaDiagnostic(file, 'variableDescriptions', 'object', value.variableDescriptions));
227
+ }
228
+ else {
229
+ for (const [name, description] of Object.entries(value.variableDescriptions)) {
230
+ if (!isRecord(value.variables) || !Object.hasOwn(value.variables, name)) {
231
+ diagnostics.push(schemaDiagnostic(file, `variableDescriptions.${name}`, 'declared variable name', name));
232
+ }
233
+ else if (typeof description !== 'string'
234
+ || !description.trim()
235
+ || Buffer.byteLength(description.trim(), 'utf8') > 500
236
+ || [...description].some((character) => {
237
+ const code = character.codePointAt(0);
238
+ return code <= 0x1f || (code >= 0x7f && code <= 0x9f);
239
+ })) {
240
+ diagnostics.push(schemaDiagnostic(file, `variableDescriptions.${name}`, 'non-empty string up to 500 UTF-8 bytes without control characters', description));
241
+ }
242
+ else {
243
+ variableDescriptions[name] = description.trim();
244
+ }
245
+ }
246
+ }
247
+ }
222
248
  if (diagnostics.length !== initialCount)
223
249
  return null;
224
- return value;
250
+ return {
251
+ ...value,
252
+ ...(value.variableDescriptions === undefined ? {} : { variableDescriptions }),
253
+ };
225
254
  };
226
255
  const validateSequence = (value, pathSlug, file, diagnostics) => {
227
256
  if (!isRecord(value)) {
@@ -442,6 +471,7 @@ export async function readEmailFiles(sourceDir) {
442
471
  html,
443
472
  text,
444
473
  variables: metadata.variables,
474
+ ...(metadata.variableDescriptions === undefined ? {} : { variableDescriptions: metadata.variableDescriptions }),
445
475
  },
446
476
  });
447
477
  }
@@ -486,6 +516,9 @@ export async function writeEmailTemplateFile(sourceDir, template) {
486
516
  subject: template.draft.subject,
487
517
  previewText: template.draft.previewText,
488
518
  variables: sortedVariables(template.draft.variables),
519
+ ...(Object.keys(template.draft.variableDescriptions ?? {}).length === 0 ? {} : {
520
+ variableDescriptions: sortedVariables(template.draft.variableDescriptions),
521
+ }),
489
522
  };
490
523
  await writeAtomic(path.join(directory, 'template.json'), `${JSON.stringify(metadata, null, 2)}\n`);
491
524
  await Promise.all([
@@ -4,10 +4,10 @@
4
4
  "minimumCliVersion": "0.1.20",
5
5
  "entries": [
6
6
  {
7
- "repositoryCliVersion": "0.1.281",
7
+ "repositoryCliVersion": "0.1.283",
8
8
  "manifest": {
9
9
  "schemaVersion": 1,
10
- "bundleVersion": "2.0.274",
10
+ "bundleVersion": "2.0.276",
11
11
  "stepContractVersion": 3,
12
12
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
13
13
  "managedFiles": [
@@ -45,7 +45,7 @@
45
45
  },
46
46
  {
47
47
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
48
- "sha256": "3d6d1dc040dc64ba2b0d99d568d161efb621ddfc8e03b79e5fea72eb407cc086"
48
+ "sha256": "57e1c0b45e30abe00ae6a1809d8dd4bd2589d4fe74ec21772c186860f13d48ef"
49
49
  },
50
50
  {
51
51
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -145,16 +145,16 @@
145
145
  },
146
146
  {
147
147
  "path": "funnel-docs.config.json",
148
- "sha256": "9f2c2f20da1c0e9cc714a563041e01a3bd80d416a3965be6237c6036a6ab1f4d"
148
+ "sha256": "32f6697d21d89786ee7ef42d9baa86ddfa7b50fbd8726f781708050e2c2085bc"
149
149
  }
150
150
  ]
151
151
  }
152
152
  },
153
153
  {
154
- "repositoryCliVersion": "0.1.280",
154
+ "repositoryCliVersion": "0.1.282",
155
155
  "manifest": {
156
156
  "schemaVersion": 1,
157
- "bundleVersion": "2.0.273",
157
+ "bundleVersion": "2.0.275",
158
158
  "stepContractVersion": 3,
159
159
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
160
160
  "managedFiles": [
@@ -192,7 +192,7 @@
192
192
  },
193
193
  {
194
194
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
195
- "sha256": "0d5fc0fbb91286906cdfe5edd317ce970cd20b9210cea694d6b5ed630b2f8a3e"
195
+ "sha256": "291485278a2071a4e73422412e8f81e6ef64bc8b5aa3837b5a9e6dec54501607"
196
196
  },
197
197
  {
198
198
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -292,16 +292,16 @@
292
292
  },
293
293
  {
294
294
  "path": "funnel-docs.config.json",
295
- "sha256": "ca45c7be882af24d09999ab0ee7130645f9bfe4fb56addd2f7966bb31807e610"
295
+ "sha256": "b1ed6276f1565a432a9f48036669b15ed4edfb7c955bf74b312a2b5502f128eb"
296
296
  }
297
297
  ]
298
298
  }
299
299
  },
300
300
  {
301
- "repositoryCliVersion": "0.1.279",
301
+ "repositoryCliVersion": "0.1.281",
302
302
  "manifest": {
303
303
  "schemaVersion": 1,
304
- "bundleVersion": "2.0.272",
304
+ "bundleVersion": "2.0.274",
305
305
  "stepContractVersion": 3,
306
306
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
307
307
  "managedFiles": [
@@ -339,7 +339,7 @@
339
339
  },
340
340
  {
341
341
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
342
- "sha256": "038a83e26aa4d24ad4ad6ec78a548cc7a2f2bc84d67adde6e9cc03bc11795a09"
342
+ "sha256": "3d6d1dc040dc64ba2b0d99d568d161efb621ddfc8e03b79e5fea72eb407cc086"
343
343
  },
344
344
  {
345
345
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -439,22 +439,22 @@
439
439
  },
440
440
  {
441
441
  "path": "funnel-docs.config.json",
442
- "sha256": "3eacc262001aadac7bdc68e58d69fa8a102ef919cbdd09178f5be90812468747"
442
+ "sha256": "9f2c2f20da1c0e9cc714a563041e01a3bd80d416a3965be6237c6036a6ab1f4d"
443
443
  }
444
444
  ]
445
445
  }
446
446
  },
447
447
  {
448
- "repositoryCliVersion": "0.1.278",
448
+ "repositoryCliVersion": "0.1.280",
449
449
  "manifest": {
450
450
  "schemaVersion": 1,
451
- "bundleVersion": "2.0.271",
451
+ "bundleVersion": "2.0.273",
452
452
  "stepContractVersion": 3,
453
453
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
454
454
  "managedFiles": [
455
455
  {
456
456
  "path": "AGENTS.md",
457
- "sha256": "3860d21f4a3f9b0c25ca54f7a87762d801f14b82a181b4c0b941c57187908f99"
457
+ "sha256": "b7dc496d1dcfea176fb5a57e6d17f64abdcff77afeccfcecbbe1790d11da7386"
458
458
  },
459
459
  {
460
460
  "path": "CLAUDE.md",
@@ -462,7 +462,7 @@
462
462
  },
463
463
  {
464
464
  "path": "docs/funnelsgrove/START-HERE.md",
465
- "sha256": "ef7525739aa0cd5ea42906fca2ae6ca0327465e6939956f9567e3029148a0bd5"
465
+ "sha256": "5442274f8ca7ddded834147a693677e203a9c223e1db4260e56bf498ec06a362"
466
466
  },
467
467
  {
468
468
  "path": "docs/funnelsgrove/contracts/analytics-events.md",
@@ -470,7 +470,7 @@
470
470
  },
471
471
  {
472
472
  "path": "docs/funnelsgrove/contracts/content-answers.md",
473
- "sha256": "38cd477fa65cb00718c6609ede520bc5b7538f331072c888a6cc32e8d0130d27"
473
+ "sha256": "efd912eb405e4c64b33becb1cf9a397ba5fe9afc2d4e2aea115a0f5e0703ca87"
474
474
  },
475
475
  {
476
476
  "path": "docs/funnelsgrove/contracts/flow-routing.md",
@@ -486,7 +486,7 @@
486
486
  },
487
487
  {
488
488
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
489
- "sha256": "012ef8788fdb0b5f7b8acc283ee9d0c3c9e23f68d944327ed8c2d9378de94585"
489
+ "sha256": "0d5fc0fbb91286906cdfe5edd317ce970cd20b9210cea694d6b5ed630b2f8a3e"
490
490
  },
491
491
  {
492
492
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -586,22 +586,22 @@
586
586
  },
587
587
  {
588
588
  "path": "funnel-docs.config.json",
589
- "sha256": "580a792c8650972c8016c0052bec88f7a5331445a8a039bb35912c2da4c645a0"
589
+ "sha256": "ca45c7be882af24d09999ab0ee7130645f9bfe4fb56addd2f7966bb31807e610"
590
590
  }
591
591
  ]
592
592
  }
593
593
  },
594
594
  {
595
- "repositoryCliVersion": "0.1.277",
595
+ "repositoryCliVersion": "0.1.279",
596
596
  "manifest": {
597
597
  "schemaVersion": 1,
598
- "bundleVersion": "2.0.270",
598
+ "bundleVersion": "2.0.272",
599
599
  "stepContractVersion": 3,
600
600
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
601
601
  "managedFiles": [
602
602
  {
603
603
  "path": "AGENTS.md",
604
- "sha256": "3860d21f4a3f9b0c25ca54f7a87762d801f14b82a181b4c0b941c57187908f99"
604
+ "sha256": "b7dc496d1dcfea176fb5a57e6d17f64abdcff77afeccfcecbbe1790d11da7386"
605
605
  },
606
606
  {
607
607
  "path": "CLAUDE.md",
@@ -609,7 +609,7 @@
609
609
  },
610
610
  {
611
611
  "path": "docs/funnelsgrove/START-HERE.md",
612
- "sha256": "ef7525739aa0cd5ea42906fca2ae6ca0327465e6939956f9567e3029148a0bd5"
612
+ "sha256": "5442274f8ca7ddded834147a693677e203a9c223e1db4260e56bf498ec06a362"
613
613
  },
614
614
  {
615
615
  "path": "docs/funnelsgrove/contracts/analytics-events.md",
@@ -617,7 +617,7 @@
617
617
  },
618
618
  {
619
619
  "path": "docs/funnelsgrove/contracts/content-answers.md",
620
- "sha256": "38cd477fa65cb00718c6609ede520bc5b7538f331072c888a6cc32e8d0130d27"
620
+ "sha256": "efd912eb405e4c64b33becb1cf9a397ba5fe9afc2d4e2aea115a0f5e0703ca87"
621
621
  },
622
622
  {
623
623
  "path": "docs/funnelsgrove/contracts/flow-routing.md",
@@ -633,7 +633,7 @@
633
633
  },
634
634
  {
635
635
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
636
- "sha256": "b15776c8ec0ecbc1f9369ccd56daee4160c533f7b34285cd1c5013db38fd411f"
636
+ "sha256": "038a83e26aa4d24ad4ad6ec78a548cc7a2f2bc84d67adde6e9cc03bc11795a09"
637
637
  },
638
638
  {
639
639
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -733,16 +733,16 @@
733
733
  },
734
734
  {
735
735
  "path": "funnel-docs.config.json",
736
- "sha256": "bdc9354312747f58fa96e201ec2b69b289dfbb21452f33866b3b7d2628490cd6"
736
+ "sha256": "3eacc262001aadac7bdc68e58d69fa8a102ef919cbdd09178f5be90812468747"
737
737
  }
738
738
  ]
739
739
  }
740
740
  },
741
741
  {
742
- "repositoryCliVersion": "0.1.276",
742
+ "repositoryCliVersion": "0.1.278",
743
743
  "manifest": {
744
744
  "schemaVersion": 1,
745
- "bundleVersion": "2.0.269",
745
+ "bundleVersion": "2.0.271",
746
746
  "stepContractVersion": 3,
747
747
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
748
748
  "managedFiles": [
@@ -780,7 +780,7 @@
780
780
  },
781
781
  {
782
782
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
783
- "sha256": "fbff72ea55bddc1e2e58a66bfbf15677574868bfed25538507d169fd820f0202"
783
+ "sha256": "012ef8788fdb0b5f7b8acc283ee9d0c3c9e23f68d944327ed8c2d9378de94585"
784
784
  },
785
785
  {
786
786
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -880,16 +880,16 @@
880
880
  },
881
881
  {
882
882
  "path": "funnel-docs.config.json",
883
- "sha256": "2415311f4118e042c33855343708800e74c9f2433443f61ec4a44325f9a4dbc2"
883
+ "sha256": "580a792c8650972c8016c0052bec88f7a5331445a8a039bb35912c2da4c645a0"
884
884
  }
885
885
  ]
886
886
  }
887
887
  },
888
888
  {
889
- "repositoryCliVersion": "0.1.275",
889
+ "repositoryCliVersion": "0.1.277",
890
890
  "manifest": {
891
891
  "schemaVersion": 1,
892
- "bundleVersion": "2.0.268",
892
+ "bundleVersion": "2.0.270",
893
893
  "stepContractVersion": 3,
894
894
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
895
895
  "managedFiles": [
@@ -927,7 +927,7 @@
927
927
  },
928
928
  {
929
929
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
930
- "sha256": "63b9bffafc0e408b769ce39764c84a45f55218e890782496f6b6aceed18e1569"
930
+ "sha256": "b15776c8ec0ecbc1f9369ccd56daee4160c533f7b34285cd1c5013db38fd411f"
931
931
  },
932
932
  {
933
933
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -1027,7 +1027,7 @@
1027
1027
  },
1028
1028
  {
1029
1029
  "path": "funnel-docs.config.json",
1030
- "sha256": "1fcfbd34138904d3ef4213e7950e2c1b124289d1a95fb42c29075ca7512db676"
1030
+ "sha256": "bdc9354312747f58fa96e201ec2b69b289dfbb21452f33866b3b7d2628490cd6"
1031
1031
  }
1032
1032
  ]
1033
1033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/cli",
3
- "version": "0.1.281",
3
+ "version": "0.1.283",
4
4
  "description": "FunnelsGrove command-line tools for editing, syncing, and publishing funnels",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.274",
3
+ "bundleVersion": "2.0.276",
4
4
  "stepContractVersion": 3,
5
5
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
6
6
  "managedFiles": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  {
40
40
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
41
- "sha256": "3d6d1dc040dc64ba2b0d99d568d161efb621ddfc8e03b79e5fea72eb407cc086"
41
+ "sha256": "57e1c0b45e30abe00ae6a1809d8dd4bd2589d4fe74ec21772c186860f13d48ef"
42
42
  },
43
43
  {
44
44
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "path": "funnel-docs.config.json",
141
- "sha256": "9f2c2f20da1c0e9cc714a563041e01a3bd80d416a3965be6237c6036a6ab1f4d"
141
+ "sha256": "32f6697d21d89786ee7ef42d9baa86ddfa7b50fbd8726f781708050e2c2085bc"
142
142
  }
143
143
  ]
144
144
  }
@@ -17,7 +17,7 @@ Supported read versions: `1`, `2`, `3`. Authoring and publish target version `3`
17
17
 
18
18
  ### Package release order
19
19
 
20
- Release `@funnelsgrove/sdk` `0.4.0` first, then `@funnelsgrove/runtime` `0.30.0`, then `@funnelsgrove/analytics` `0.12.0`, then `@funnelsgrove/payments` `0.37.0`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.281`, and only then promotes the candidate to production traffic. The serving API must never advertise an unpublished preferred CLI. Publishing packages and deploying production remain separately approved operational actions.
20
+ Release `@funnelsgrove/sdk` `0.4.0` first, then `@funnelsgrove/runtime` `0.30.0`, then `@funnelsgrove/analytics` `0.12.0`, then `@funnelsgrove/payments` `0.37.0`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.283`, and only then promotes the candidate to production traffic. The serving API must never advertise an unpublished preferred CLI. Publishing packages and deploying production remain separately approved operational actions.
21
21
  <!-- funnelsgrove:generated:end contract-v3/migration/step-contract-v3 -->
22
22
 
23
23
  ## Version-last policy
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.274",
3
+ "bundleVersion": "2.0.276",
4
4
  "contractSource": "funnelsgrove-repository://apps/funnel-runtime/contracts/step-contract-v2.json",
5
5
  "fullyGenerated": [
6
6
  ".funnelsgrove-docs.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.274",
3
+ "bundleVersion": "2.0.276",
4
4
  "stepContractVersion": 3,
5
5
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
6
6
  "managedFiles": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  {
40
40
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
41
- "sha256": "3d6d1dc040dc64ba2b0d99d568d161efb621ddfc8e03b79e5fea72eb407cc086"
41
+ "sha256": "57e1c0b45e30abe00ae6a1809d8dd4bd2589d4fe74ec21772c186860f13d48ef"
42
42
  },
43
43
  {
44
44
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "path": "funnel-docs.config.json",
141
- "sha256": "9f2c2f20da1c0e9cc714a563041e01a3bd80d416a3965be6237c6036a6ab1f4d"
141
+ "sha256": "32f6697d21d89786ee7ef42d9baa86ddfa7b50fbd8726f781708050e2c2085bc"
142
142
  }
143
143
  ]
144
144
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sourceTreeHash": "bae1fcbf1c3de232b11630821c7d06db629c3b58b850657746029e69b8b66bf7",
3
+ "sourceTreeHash": "f1a57f68ef0db46b56cab67f945cbff7056769e722cfc4a0f322ddfe03d434d2",
4
4
  "stepContractVersion": 3,
5
- "docsBundleVersion": "2.0.274",
5
+ "docsBundleVersion": "2.0.276",
6
6
  "files": [
7
7
  {
8
8
  "path": ".env.example",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  {
18
18
  "path": ".funnelsgrove-docs.json",
19
- "sha256": "77a5ba3f7f89c781d812a8cecbd0e3142b9d5ba8c57fa5bb2017a1578e8ae865",
19
+ "sha256": "f2893f6ea08ac5831b616e0f1f6a11fb56d17c9c23984be827175ebd7e2ee862",
20
20
  "mode": "100644"
21
21
  },
22
22
  {
@@ -76,7 +76,7 @@
76
76
  },
77
77
  {
78
78
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
79
- "sha256": "3d6d1dc040dc64ba2b0d99d568d161efb621ddfc8e03b79e5fea72eb407cc086",
79
+ "sha256": "57e1c0b45e30abe00ae6a1809d8dd4bd2589d4fe74ec21772c186860f13d48ef",
80
80
  "mode": "100644"
81
81
  },
82
82
  {
@@ -206,7 +206,7 @@
206
206
  },
207
207
  {
208
208
  "path": "funnel-docs.config.json",
209
- "sha256": "9f2c2f20da1c0e9cc714a563041e01a3bd80d416a3965be6237c6036a6ab1f4d",
209
+ "sha256": "32f6697d21d89786ee7ef42d9baa86ddfa7b50fbd8726f781708050e2c2085bc",
210
210
  "mode": "100644"
211
211
  },
212
212
  {
@@ -216,7 +216,7 @@
216
216
  },
217
217
  {
218
218
  "path": "funnel.runtime-capabilities.json",
219
- "sha256": "3d74683170fced7afa9badfdf837706aac9c3d554690708b3ba31b009028a069",
219
+ "sha256": "50024a9d997506468094a938db5b34ed8d4c6d27e44de76b3417363c51b2c042",
220
220
  "mode": "100644"
221
221
  },
222
222
  {
@@ -551,7 +551,7 @@
551
551
  },
552
552
  {
553
553
  "path": "src/steps/step-32-paywall.tsx",
554
- "sha256": "43789583e91269b5427dbe5a054aafbe7cafac2a40d9a26f1c9414f1ae458b5c",
554
+ "sha256": "8a2903926e6476eef4901b240f7b6d054eb782292d72e84b1a11dcda65b200c4",
555
555
  "mode": "100644"
556
556
  },
557
557
  {
@@ -17,7 +17,7 @@ Supported read versions: `1`, `2`, `3`. Authoring and publish target version `3`
17
17
 
18
18
  ### Package release order
19
19
 
20
- Release `@funnelsgrove/sdk` `0.4.0` first, then `@funnelsgrove/runtime` `0.30.0`, then `@funnelsgrove/analytics` `0.12.0`, then `@funnelsgrove/payments` `0.37.0`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.281`, and only then promotes the candidate to production traffic. The serving API must never advertise an unpublished preferred CLI. Publishing packages and deploying production remain separately approved operational actions.
20
+ Release `@funnelsgrove/sdk` `0.4.0` first, then `@funnelsgrove/runtime` `0.30.0`, then `@funnelsgrove/analytics` `0.12.0`, then `@funnelsgrove/payments` `0.37.0`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.283`, and only then promotes the candidate to production traffic. The serving API must never advertise an unpublished preferred CLI. Publishing packages and deploying production remain separately approved operational actions.
21
21
  <!-- funnelsgrove:generated:end contract-v3/migration/step-contract-v3 -->
22
22
 
23
23
  ## Version-last policy
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.274",
3
+ "bundleVersion": "2.0.276",
4
4
  "contractSource": "funnelsgrove-repository://apps/funnel-runtime/contracts/step-contract-v2.json",
5
5
  "fullyGenerated": [
6
6
  ".funnelsgrove-docs.json",
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "moneyContractVersion": 1,
3
- "localeContractVersion": 1
3
+ "localeContractVersion": 1,
4
+ "paypalCheckoutVersion": 1
4
5
  }
@@ -33,6 +33,9 @@ import { getPathForStep } from '@/runtime/funnel-runtime';
33
33
  import {
34
34
  SharedCheckoutSpecialOfferDialog,
35
35
  SolidgateCheckoutDialog,
36
+ PayPalCheckout,
37
+ PayPalCheckoutDialog,
38
+ readPendingPayPalCheckout,
36
39
  SharedStripeCheckoutV2Dialog,
37
40
  StripeSubscriptionWalletSurface,
38
41
  activateSecondPaywallDiscount,
@@ -140,7 +143,7 @@ function StepPaywallRuntime({
140
143
  }: StepPaywallProps = {}) {
141
144
  const [runtimeMode] = useRuntimeMode();
142
145
  const checkoutMode = runtimeMode;
143
- const { user, setUser, attributes, featureFlags, completeStep, userBootstrapped } = useFunnel();
146
+ const { user, setUser, attributes, featureFlags, completeStep, goNext, userBootstrapped } = useFunnel();
144
147
  const publishedRuntime = useFunnelRuntimeConfig();
145
148
  const browserLocale = useBrowserOfferLocale();
146
149
  const content = usePreviewStepLocalizedContent(
@@ -179,7 +182,7 @@ function StepPaywallRuntime({
179
182
  activeBillingRuntime.sourceVersionId,
180
183
  ]);
181
184
  const activeBillingDiscounts = useMemo(
182
- () => activeBillingRuntime.discounts ?? (
185
+ () => activeBillingRuntime.provider === 'paypal' ? inactiveBillingDiscounts : activeBillingRuntime.discounts ?? (
183
186
  activeBillingRuntime.provider === 'stripe'
184
187
  ? buildBillingDiscountCatalog(billingDiscountList)
185
188
  : inactiveBillingDiscounts
@@ -217,10 +220,16 @@ function StepPaywallRuntime({
217
220
  null,
218
221
  [activeBillingRuntime.defaultPlanKey, availablePlans],
219
222
  );
220
- const [selectedPlanId, setSelectedPlanId] = useState<string | null>(
223
+ const [requestedPlanId, setSelectedPlanId] = useState<string | null>(
221
224
  initialPlanId,
222
225
  );
223
- const [checkoutDialogOpen, setCheckoutDialogOpen] = useState(false);
226
+ const pendingPayPal = readPendingPayPalCheckout({ environment: checkoutMode, funnelEndUserId: user.id, runtimeConfig: activeCheckoutRuntimeConfig });
227
+ const hasPendingPayPal = Boolean(pendingPayPal);
228
+ const selectedPlanId = pendingPayPal
229
+ ? availablePlans.find(plan => plan.funnelPlanKey === pendingPayPal.funnelPlanKey)?.id ?? null
230
+ : requestedPlanId;
231
+ const [checkoutDialogOpen, setCheckoutDialogOpen] = useState(Boolean(pendingPayPal));
232
+ const [paypalPending, setPayPalPending] = useState(false);
224
233
  const [solidgateAttemptKey, setSolidgateAttemptKey] = useState<string | null>(null);
225
234
  const [specialOfferDialogOpen, setSpecialOfferDialogOpen] = useState(() => {
226
235
  if (typeof window === 'undefined') {
@@ -287,6 +296,7 @@ function StepPaywallRuntime({
287
296
  const checkoutSummaryLabel =
288
297
  selectedDisplayPlan?.checkoutSummaryLabel?.trim() || selectedDisplayPlan?.title || content.selectedPlanLabel;
289
298
  const checkoutProvider = activeBillingRuntime.provider;
299
+ const paypalOption = pendingPayPal?.option || (selectedPlan?.funnelPlanKey ? activeBillingRuntime.paypalOptionsByPlanKey?.[selectedPlan.funnelPlanKey] : null);
290
300
  const storyOptions = useMemo<readonly StoryOption[]>(
291
301
  () =>
292
302
  content.stories.items.map((item, index) => ({
@@ -390,7 +400,7 @@ function StepPaywallRuntime({
390
400
  }
391
401
  successUrl.searchParams.set(
392
402
  'source',
393
- checkoutProvider === 'solidgate' ? 'solidgate' : 'stripe-elements',
403
+ checkoutProvider === 'stripe' ? 'stripe-elements' : checkoutProvider,
394
404
  );
395
405
 
396
406
  return successUrl.toString();
@@ -483,10 +493,10 @@ function StepPaywallRuntime({
483
493
  && activeBillingRuntime.offerSetId.trim()
484
494
  && selectedPlan?.funnelPlanKey?.trim(),
485
495
  );
486
- const checkoutDisabled = !checkoutSelectionReady || !userBootstrapped || !selectedPlan || !selectedDisplayPlan || (
496
+ const checkoutDisabled = Boolean(pendingPayPal) || paypalPending || !checkoutSelectionReady || !userBootstrapped || !selectedPlan || !selectedDisplayPlan || (
487
497
  checkoutProvider === 'solidgate'
488
498
  ? !solidgateCheckoutConfigured
489
- : !checkoutSession.configured
499
+ : checkoutProvider === 'paypal' ? !paypalOption : !checkoutSession.configured
490
500
  );
491
501
  const checkoutDialogReady =
492
502
  checkoutProvider === 'stripe' &&
@@ -539,10 +549,10 @@ function StepPaywallRuntime({
539
549
  }, [user.email]);
540
550
 
541
551
  useEffect(() => {
542
- setCheckoutDialogOpen(false);
552
+ setCheckoutDialogOpen(hasPendingPayPal);
543
553
  setSolidgateAttemptKey(null);
544
554
  setError(null);
545
- }, [selectedPlanId]);
555
+ }, [selectedPlanId, hasPendingPayPal]);
546
556
 
547
557
  useEffect(() => {
548
558
  if (
@@ -633,6 +643,7 @@ function StepPaywallRuntime({
633
643
  paywallWalletMethodWrapperClassNames[method];
634
644
 
635
645
  const startCheckout = async () => {
646
+ if (pendingPayPal || paypalPending) { setCheckoutDialogOpen(true); return; }
636
647
  if (checkoutDisabled) {
637
648
  return;
638
649
  }
@@ -642,6 +653,8 @@ function StepPaywallRuntime({
642
653
  return;
643
654
  }
644
655
 
656
+ if (checkoutProvider === 'paypal') { setCheckoutDialogOpen(true); return; }
657
+
645
658
  if (checkoutProvider === 'solidgate') {
646
659
  setSolidgateAttemptKey(crypto.randomUUID());
647
660
  setCheckoutDialogOpen(true);
@@ -684,6 +697,7 @@ function StepPaywallRuntime({
684
697
  };
685
698
 
686
699
  const openCardCheckoutFromUnavailableWallet = async () => {
700
+ if (pendingPayPal || paypalPending) { setCheckoutDialogOpen(true); return; }
687
701
  if (checkoutDisabled) {
688
702
  return;
689
703
  }
@@ -754,6 +768,27 @@ function StepPaywallRuntime({
754
768
  setCheckoutEmailPromptError(null);
755
769
  };
756
770
 
771
+ const paypalCheckout = (checkoutSelectionReady || pendingPayPal) && userBootstrapped && paypalOption && (selectedPlan?.funnelPlanKey || pendingPayPal) ? (
772
+ <PayPalCheckout
773
+ key={`${paypalOption.paymentProfileId}:${paypalOption.providerPlanId}:${checkoutMode}:${pendingPayPal?.funnelPlanKey || selectedPlan?.funnelPlanKey}`}
774
+ option={paypalOption}
775
+ environment={checkoutMode}
776
+ funnelEndUserId={user.id}
777
+ offerSetId={pendingPayPal?.offerSetId || activeBillingRuntime.offerSetId}
778
+ funnelPlanKey={pendingPayPal?.funnelPlanKey || selectedPlan?.funnelPlanKey || ''}
779
+ runtimeConfig={activeCheckoutRuntimeConfig}
780
+ onPreparationStart={billingSelection.pin}
781
+ onPendingChange={pending => {
782
+ setPayPalPending(pending);
783
+ if (!pending) billingSelection.reset();
784
+ }}
785
+ onSuccess={() => {
786
+ completeStep(analyticsStepId, { planId: selectedDisplayPlan?.id ?? pendingPayPal?.funnelPlanKey });
787
+ goNext();
788
+ }}
789
+ />
790
+ ) : undefined;
791
+
757
792
  const closeCheckoutDialog = () => {
758
793
  if (checkoutProvider === 'stripe') checkoutSession.reset();
759
794
  else billingSelection.reset();
@@ -903,6 +938,11 @@ function StepPaywallRuntime({
903
938
  />
904
939
  ) : null}
905
940
 
941
+ {checkoutDialogOpen && paypalCheckout && (checkoutProvider === 'paypal' || !checkoutSession.activeClientSecret) ? (
942
+ <PayPalCheckoutDialog title={content.checkout.title} closeAriaLabel={content.checkout.closeAriaLabel}
943
+ onClose={() => setCheckoutDialogOpen(false)}>{paypalCheckout}</PayPalCheckoutDialog>
944
+ ) : null}
945
+
906
946
  {checkoutDialogOpen &&
907
947
  checkoutProvider === 'stripe' &&
908
948
  checkoutSession.activeClientSecret &&
@@ -933,6 +973,8 @@ function StepPaywallRuntime({
933
973
  onError={checkoutSession.setError}
934
974
  onSuccess={handleCheckoutCompleted}
935
975
  paymentMethodLabels={content.checkout.paymentMethodLabels}
976
+ paypalCheckout={paypalCheckout}
977
+ paypalPending={paypalPending || Boolean(pendingPayPal)}
936
978
  paypalButtonLabel={content.checkout.paypalButtonLabel}
937
979
  paypalLabel={content.checkout.paypalLabel}
938
980
  promoActive={checkoutPromoActive}
@@ -1099,6 +1141,7 @@ function StepPaywallRuntime({
1099
1141
  ]
1100
1142
  .filter(Boolean)
1101
1143
  .join(' ')}
1144
+ disabled={paypalPending || Boolean(pendingPayPal)}
1102
1145
  onClick={() => setSelectedPlanId(plan.id)}
1103
1146
  >
1104
1147
  {plan.featuredTag ? <span className='paywall-v2-plan-tag'>{plan.featuredTag}</span> : null}
@@ -1169,12 +1212,17 @@ function StepPaywallRuntime({
1169
1212
  type='button'
1170
1213
  className='paywall-v2-card-button paywall-v2-vibe-cta'
1171
1214
  onClick={() => void startCheckout()}
1172
- disabled={checkoutDisabled}
1215
+ disabled={checkoutDisabled && !pendingPayPal && !paypalPending}
1173
1216
  >
1174
1217
  {content.plans.cardButtonLabel}
1175
1218
  </button>
1176
- <p className='paywall-v2-alt-meta'>{content.plans.metaLabels.join(' · ')}</p>
1219
+ {checkoutProvider !== 'paypal' && !pendingPayPal ? (
1220
+ <div aria-label='Card and wallet billing terms'>
1221
+ {paypalOption ? <p className='paywall-v2-alt-meta'>Card and wallet terms</p> : null}
1177
1222
  <PaywallRenewalDisclaimer plan={selectedPlan} hasActiveDiscount={Boolean(activeCouponId)} copy={content.checkout} catalogLabels={content.catalogLabels} />
1223
+ </div>
1224
+ ) : null}
1225
+ <p className='paywall-v2-alt-meta'>{content.plans.metaLabels.join(' · ')}</p>
1178
1226
  <p className='paywall-v2-support'>
1179
1227
  {content.checkout.supportText}{' '}
1180
1228
  <a href={`mailto:${supportEmail}`}>{supportEmail}</a>