@funnelsgrove/cli 0.1.139 → 0.1.142

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/README.md CHANGED
@@ -107,5 +107,18 @@ fgrove analytics conversions --project claimbee --funnel claimbee-ios --date 202
107
107
  `conversions` downloads the one-day conversion totals, primary conversion metrics, full funnel path rows, and step transitions. `funnel-path` focuses on the ordered path report. `transitions` focuses on step-by-step advanced/drop-off counts. `cohort` downloads synced marketing cohort economics for the day. If the requested day has no synced data, or cohort source data is incomplete, the CLI exits non-zero with a human-readable explanation.
108
108
 
109
109
  The package also keeps the longer `funnelsgrove` command as a compatibility alias.
110
+
111
+ Edit profitability expenses through a local JSON file:
112
+
113
+ ```bash
114
+ fgrove expenses pull --project claimbee --file expenses.json
115
+ # edit expenses.json; omit id and updatedAt for new expenses
116
+ fgrove expenses publish --project claimbee --file expenses.json
117
+ ```
118
+
119
+ Publishing creates new rows and updates rows already present in the file. It never
120
+ deletes remote expenses that are absent from the file, and it refuses to overwrite
121
+ rows changed since the last pull. Pull again to resolve a concurrent edit.
122
+
110
123
  Use `--api-url` or `FUNNELSGROVE_API_URL` for non-production APIs.
111
124
  Use `--config` or `FUNNELSGROVE_CONFIG` to keep test credentials separate from the default `~/.funnelsgrove/config.json`.
package/dist/cli.js CHANGED
@@ -15,6 +15,7 @@ import { buildCommittedSyncManifest, buildDownloadedSyncManifest, buildSourceCan
15
15
  import { mergeTextSourceWithGit } from './sourceRebase.js';
16
16
  import { executeExperimentCreate, formatExperimentCreateSuccess, recoverExperimentCreateTransaction, } from './experimentCreate.js';
17
17
  import { pullEnvFile } from './envSync.js';
18
+ import { executeExpensePublish, executeExpensePull } from './expenseCommands.js';
18
19
  import { executeEmailPull, executeEmailPush, executeEmailSend, executeEmailUpdateVariables, executeEmailSequenceAddStep, executeEmailSequenceCancel, executeEmailSequenceCreate, executeEmailSequencePublish, executeEmailSequenceSetActive, executeEmailTemplatePublish, executeEmailValidate, parseEmailVariablesJson, } from './emailCommands.js';
19
20
  import { formatGitHubConnectRows, formatGitHubJobRows, formatGitHubStatusRows, } from './githubOutput.js';
20
21
  import { GitHubSyncTimeoutError, syncGitHubDraftIfConnected, } from './githubSyncFlow.js';
@@ -1957,6 +1958,42 @@ addExamples(projectsCommand
1957
1958
  const projects = await listProjects(token, workspaceId);
1958
1959
  printRows(projects, ['id', 'name', 'slug']);
1959
1960
  });
1961
+ const addExpenseScopeOptions = (command) => command
1962
+ .option('--workspace <id-or-slug-or-name>', 'Workspace id, slug, or name')
1963
+ .option('--project <id-or-slug-or-name>', 'Project id, slug, or name')
1964
+ .option('--file <path>', 'Expense JSON file', 'expenses.json');
1965
+ const resolveExpenseCommandScope = async (options) => {
1966
+ const token = await readAuthToken();
1967
+ const workspaceId = await resolveWorkspaceId(token, options.workspace);
1968
+ const project = await resolveAnalyticsProject({ token, workspaceId, project: options.project });
1969
+ return {
1970
+ callApi,
1971
+ token,
1972
+ workspaceId,
1973
+ projectId: project.id,
1974
+ filePath: path.resolve(process.cwd(), options.file),
1975
+ };
1976
+ };
1977
+ const expensesCommand = addExamples(program.command('expenses').description('Edit project profitability expenses'), [
1978
+ 'fgrove expenses pull --project claimbee',
1979
+ 'fgrove expenses publish --project claimbee',
1980
+ ]);
1981
+ addExpenseScopeOptions(expensesCommand
1982
+ .command('pull')
1983
+ .description('Download profitability expenses to an editable JSON file'))
1984
+ .action(async (options) => {
1985
+ const scope = await resolveExpenseCommandScope(options);
1986
+ const count = await executeExpensePull(scope);
1987
+ console.log(`Pulled ${count} expense${count === 1 ? '' : 's'} to ${scope.filePath}.`);
1988
+ });
1989
+ addExpenseScopeOptions(expensesCommand
1990
+ .command('publish')
1991
+ .description('Create and update expenses from an edited JSON file'))
1992
+ .action(async (options) => {
1993
+ const scope = await resolveExpenseCommandScope(options);
1994
+ const result = await executeExpensePublish(scope);
1995
+ console.log(`Published expenses: ${result.created} created, ${result.updated} updated.`);
1996
+ });
1960
1997
  const funnelsCommand = addExamples(program.command('funnels').description('Manage funnels'), [
1961
1998
  'fgrove funnels list',
1962
1999
  'fgrove funnels clone --funnel claimbee --name claimbee-ios',
@@ -0,0 +1,51 @@
1
+ type CallApi = <T>(input: {
2
+ path: string;
3
+ type: 'query' | 'mutation';
4
+ data?: unknown;
5
+ token?: string | null;
6
+ }) => Promise<T>;
7
+ export type ExpenseApiRow = {
8
+ id: string;
9
+ project_id: string;
10
+ expense_date: string | null;
11
+ expense_month: string;
12
+ category: string;
13
+ vendor: string | null;
14
+ description: string | null;
15
+ amount_minor: number;
16
+ currency: string;
17
+ updated_at: string;
18
+ };
19
+ export type ExpenseFileItem = {
20
+ id?: string;
21
+ updatedAt?: string;
22
+ date: string;
23
+ category: string;
24
+ vendor: string | null;
25
+ description: string | null;
26
+ amount: string;
27
+ currency: string;
28
+ };
29
+ export type ExpenseFile = {
30
+ schemaVersion: 1;
31
+ projectId: string;
32
+ expenses: ExpenseFileItem[];
33
+ };
34
+ type ExpenseCommandScope = {
35
+ callApi: CallApi;
36
+ token: string;
37
+ workspaceId: string;
38
+ projectId: string;
39
+ };
40
+ export declare const amountToMinor: (amount: string) => number;
41
+ export declare const parseExpenseFile: (contents: string, expectedProjectId: string) => ExpenseFile;
42
+ export declare const executeExpensePull: (input: ExpenseCommandScope & {
43
+ filePath: string;
44
+ }) => Promise<number>;
45
+ export declare const executeExpensePublish: (input: ExpenseCommandScope & {
46
+ filePath: string;
47
+ }) => Promise<{
48
+ created: number;
49
+ updated: number;
50
+ }>;
51
+ export {};
@@ -0,0 +1,183 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4
+ const MONEY_PATTERN = /^(0|[1-9]\d*)(\.\d{1,2})?$/;
5
+ const asObject = (value, label) => {
6
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
7
+ throw new Error(`${label} must be an object.`);
8
+ }
9
+ return value;
10
+ };
11
+ const requiredString = (value, label) => {
12
+ if (typeof value !== 'string' || !value.trim())
13
+ throw new Error(`${label} must be a non-empty string.`);
14
+ return value.trim();
15
+ };
16
+ const nullableString = (value, label) => {
17
+ if (value === null || value === undefined || value === '')
18
+ return null;
19
+ if (typeof value !== 'string')
20
+ throw new Error(`${label} must be a string or null.`);
21
+ return value.trim() || null;
22
+ };
23
+ export const amountToMinor = (amount) => {
24
+ if (!MONEY_PATTERN.test(amount))
25
+ throw new Error(`Invalid expense amount "${amount}". Use a non-negative value with at most two decimals.`);
26
+ const [whole, fraction = ''] = amount.split('.');
27
+ const minor = Number(whole) * 100 + Number(fraction.padEnd(2, '0'));
28
+ if (!Number.isSafeInteger(minor))
29
+ throw new Error(`Expense amount "${amount}" is too large.`);
30
+ return minor;
31
+ };
32
+ const formatAmount = (amountMinor) => {
33
+ const whole = Math.floor(amountMinor / 100);
34
+ return `${whole}.${String(amountMinor % 100).padStart(2, '0')}`;
35
+ };
36
+ const rowToFileItem = (row) => ({
37
+ id: row.id,
38
+ updatedAt: row.updated_at,
39
+ date: row.expense_date || row.expense_month,
40
+ category: row.category,
41
+ vendor: row.vendor,
42
+ description: row.description,
43
+ amount: formatAmount(row.amount_minor),
44
+ currency: row.currency,
45
+ });
46
+ export const parseExpenseFile = (contents, expectedProjectId) => {
47
+ let parsed;
48
+ try {
49
+ parsed = JSON.parse(contents);
50
+ }
51
+ catch {
52
+ throw new Error('Expense file is not valid JSON.');
53
+ }
54
+ const root = asObject(parsed, 'Expense file');
55
+ if (root.schemaVersion !== 1)
56
+ throw new Error('Expense file schemaVersion must be 1.');
57
+ const projectId = requiredString(root.projectId, 'projectId');
58
+ if (projectId !== expectedProjectId) {
59
+ throw new Error(`Expense file belongs to project ${projectId}, not ${expectedProjectId}.`);
60
+ }
61
+ if (!Array.isArray(root.expenses))
62
+ throw new Error('expenses must be an array.');
63
+ const seenIds = new Set();
64
+ const expenses = root.expenses.map((value, index) => {
65
+ const label = `expenses[${index}]`;
66
+ const item = asObject(value, label);
67
+ const id = item.id === undefined ? undefined : requiredString(item.id, `${label}.id`);
68
+ if (id && !UUID_PATTERN.test(id))
69
+ throw new Error(`${label}.id must be a UUID.`);
70
+ if (id && seenIds.has(id))
71
+ throw new Error(`Duplicate expense id ${id}.`);
72
+ if (id)
73
+ seenIds.add(id);
74
+ const updatedAt = item.updatedAt === undefined
75
+ ? undefined
76
+ : requiredString(item.updatedAt, `${label}.updatedAt`);
77
+ if (id && !updatedAt)
78
+ throw new Error(`${label}.updatedAt is required when id is present.`);
79
+ if (!id && updatedAt)
80
+ throw new Error(`${label}.updatedAt is only valid when id is present.`);
81
+ const date = requiredString(item.date, `${label}.date`);
82
+ if (!DATE_PATTERN.test(date))
83
+ throw new Error(`${label}.date must use YYYY-MM-DD.`);
84
+ const category = requiredString(item.category, `${label}.category`);
85
+ if (category.length > 80)
86
+ throw new Error(`${label}.category must be at most 80 characters.`);
87
+ const vendor = nullableString(item.vendor, `${label}.vendor`);
88
+ if (vendor && vendor.length > 160)
89
+ throw new Error(`${label}.vendor must be at most 160 characters.`);
90
+ const description = nullableString(item.description, `${label}.description`);
91
+ if (description && description.length > 500)
92
+ throw new Error(`${label}.description must be at most 500 characters.`);
93
+ const amount = requiredString(item.amount, `${label}.amount`);
94
+ amountToMinor(amount);
95
+ const currency = requiredString(item.currency, `${label}.currency`).toUpperCase();
96
+ if (!/^[A-Z]{3}$/.test(currency))
97
+ throw new Error(`${label}.currency must be a three-letter code.`);
98
+ return { id, updatedAt, date, category, vendor, description, amount, currency };
99
+ });
100
+ return { schemaVersion: 1, projectId, expenses };
101
+ };
102
+ const listExpenses = async (scope) => {
103
+ const result = await scope.callApi({
104
+ path: 'projects.profitabilityExpenses',
105
+ type: 'query',
106
+ token: scope.token,
107
+ data: { workspaceId: scope.workspaceId, projectId: scope.projectId },
108
+ });
109
+ return result.expenses;
110
+ };
111
+ const serializeExpenseFile = (file) => `${JSON.stringify(file, null, 2)}\n`;
112
+ export const executeExpensePull = async (input) => {
113
+ const expenses = await listExpenses(input);
114
+ await writeFile(input.filePath, serializeExpenseFile({
115
+ schemaVersion: 1,
116
+ projectId: input.projectId,
117
+ expenses: expenses.map(rowToFileItem),
118
+ }), 'utf8');
119
+ return expenses.length;
120
+ };
121
+ const writeInput = (scope, item) => ({
122
+ workspaceId: scope.workspaceId,
123
+ projectId: scope.projectId,
124
+ expenseDate: item.date,
125
+ expenseMonth: item.date.slice(0, 7),
126
+ category: item.category,
127
+ vendor: item.vendor,
128
+ description: item.description,
129
+ amountMinor: amountToMinor(item.amount),
130
+ currency: item.currency,
131
+ });
132
+ const matchesRemote = (item, row) => (item.date === (row.expense_date || row.expense_month)
133
+ && item.category === row.category
134
+ && item.vendor === row.vendor
135
+ && item.description === row.description
136
+ && amountToMinor(item.amount) === row.amount_minor
137
+ && item.currency === row.currency);
138
+ export const executeExpensePublish = async (input) => {
139
+ const file = parseExpenseFile(await readFile(input.filePath, 'utf8'), input.projectId);
140
+ const remote = await listExpenses(input);
141
+ const remoteById = new Map(remote.map((expense) => [expense.id, expense]));
142
+ for (const item of file.expenses) {
143
+ if (!item.id)
144
+ continue;
145
+ const current = remoteById.get(item.id);
146
+ if (!current)
147
+ throw new Error(`Expense ${item.id} no longer exists. Pull expenses again before publishing.`);
148
+ if (current.updated_at !== item.updatedAt) {
149
+ throw new Error(`Expense ${item.id} changed remotely. Pull expenses again before publishing.`);
150
+ }
151
+ }
152
+ let created = 0;
153
+ let updated = 0;
154
+ const published = [...file.expenses];
155
+ for (const [index, item] of file.expenses.entries()) {
156
+ const current = item.id ? remoteById.get(item.id) : undefined;
157
+ if (current && matchesRemote(item, current)) {
158
+ published[index] = rowToFileItem(current);
159
+ continue;
160
+ }
161
+ const common = writeInput(input, item);
162
+ const row = item.id
163
+ ? await input.callApi({
164
+ path: 'projects.updateProfitabilityExpense',
165
+ type: 'mutation',
166
+ token: input.token,
167
+ data: { ...common, id: item.id, expectedUpdatedAt: item.updatedAt },
168
+ })
169
+ : await input.callApi({
170
+ path: 'projects.createProfitabilityExpense',
171
+ type: 'mutation',
172
+ token: input.token,
173
+ data: common,
174
+ });
175
+ if (item.id)
176
+ updated += 1;
177
+ else
178
+ created += 1;
179
+ published[index] = rowToFileItem(row);
180
+ await writeFile(input.filePath, serializeExpenseFile({ ...file, expenses: published }), 'utf8');
181
+ }
182
+ return { created, updated };
183
+ };
@@ -4,10 +4,10 @@
4
4
  "minimumCliVersion": "0.1.20",
5
5
  "entries": [
6
6
  {
7
- "repositoryCliVersion": "0.1.139",
7
+ "repositoryCliVersion": "0.1.142",
8
8
  "manifest": {
9
9
  "schemaVersion": 1,
10
- "bundleVersion": "2.0.129",
10
+ "bundleVersion": "2.0.132",
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": "2a6ffbd2768cf73b049b4b067c003c81c2e3d3679fea6bf3f2865ddf419983f4"
48
+ "sha256": "33d225bcc4f6f7aaa473f3bebe81799b3ec4751c374a4c2d9159afc56415ba74"
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": "adda37f1991ccbb5e7abf2b9f1465688c116e6604b08a3d63f104b295a93140b"
148
+ "sha256": "ea5b05c7f28303245e358598f125a3a31c15175c2ef15ae8873b25be2ded133e"
149
149
  }
150
150
  ]
151
151
  }
152
152
  },
153
153
  {
154
- "repositoryCliVersion": "0.1.138",
154
+ "repositoryCliVersion": "0.1.141",
155
155
  "manifest": {
156
156
  "schemaVersion": 1,
157
- "bundleVersion": "2.0.128",
157
+ "bundleVersion": "2.0.131",
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": "ac3397d4724b3653080cb43f6b01bfc43e65da4acb867592974ef106d6833bcf"
195
+ "sha256": "015d013594cabb94c288bb39d7c717f531b68a1fe4754e6baefc0e08bbc5b872"
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": "793db126d3f299dfc98bd4dd715dfd5183d155557e32ec401491397364da5475"
295
+ "sha256": "7af952690a2b3c592ce6688b8524aa4c5fe111a0c798dc25106eb0d594c2452b"
296
296
  }
297
297
  ]
298
298
  }
299
299
  },
300
300
  {
301
- "repositoryCliVersion": "0.1.136",
301
+ "repositoryCliVersion": "0.1.140",
302
302
  "manifest": {
303
303
  "schemaVersion": 1,
304
- "bundleVersion": "2.0.126",
304
+ "bundleVersion": "2.0.130",
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": "6a7b8bea3fa6b4245307e96b51872fe04ab576c3a9161314f90c00cf6415465c"
342
+ "sha256": "9988e6f7b4ecf3f4a73ff83cf3f3613f82d765c59d09e55e86b0560d1e3eafa5"
343
343
  },
344
344
  {
345
345
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -439,16 +439,16 @@
439
439
  },
440
440
  {
441
441
  "path": "funnel-docs.config.json",
442
- "sha256": "8b1218c5e5343b2c3e00079170da131aff33f5a808365700f8eab62dbf7433b9"
442
+ "sha256": "4e81bd56071fa38708c7f18488420038339c8cc984062ffd7e8a4930ab6b06f0"
443
443
  }
444
444
  ]
445
445
  }
446
446
  },
447
447
  {
448
- "repositoryCliVersion": "0.1.135",
448
+ "repositoryCliVersion": "0.1.139",
449
449
  "manifest": {
450
450
  "schemaVersion": 1,
451
- "bundleVersion": "2.0.125",
451
+ "bundleVersion": "2.0.129",
452
452
  "stepContractVersion": 3,
453
453
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
454
454
  "managedFiles": [
@@ -486,7 +486,7 @@
486
486
  },
487
487
  {
488
488
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
489
- "sha256": "c7a266bb4f6614daa2a1adcfb3248f99330a8d4184866a4611268b93a4352203"
489
+ "sha256": "2a6ffbd2768cf73b049b4b067c003c81c2e3d3679fea6bf3f2865ddf419983f4"
490
490
  },
491
491
  {
492
492
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -586,16 +586,16 @@
586
586
  },
587
587
  {
588
588
  "path": "funnel-docs.config.json",
589
- "sha256": "ad9e79fd0ee9d6478567615d78e34efa272fc6a1c5f8016cd1aae64ba3e24679"
589
+ "sha256": "adda37f1991ccbb5e7abf2b9f1465688c116e6604b08a3d63f104b295a93140b"
590
590
  }
591
591
  ]
592
592
  }
593
593
  },
594
594
  {
595
- "repositoryCliVersion": "0.1.132",
595
+ "repositoryCliVersion": "0.1.138",
596
596
  "manifest": {
597
597
  "schemaVersion": 1,
598
- "bundleVersion": "2.0.122",
598
+ "bundleVersion": "2.0.128",
599
599
  "stepContractVersion": 3,
600
600
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
601
601
  "managedFiles": [
@@ -633,7 +633,7 @@
633
633
  },
634
634
  {
635
635
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
636
- "sha256": "46f46756190a6085c562b9ceb2fd4a0eac961ea4f985f85a1f6e715827e171a6"
636
+ "sha256": "ac3397d4724b3653080cb43f6b01bfc43e65da4acb867592974ef106d6833bcf"
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": "01ad9b12769dd8894b2aaeea0bf21e7b622c3e4ee4612987acdcb2ec5bf93d6f"
736
+ "sha256": "793db126d3f299dfc98bd4dd715dfd5183d155557e32ec401491397364da5475"
737
737
  }
738
738
  ]
739
739
  }
740
740
  },
741
741
  {
742
- "repositoryCliVersion": "0.1.131",
742
+ "repositoryCliVersion": "0.1.136",
743
743
  "manifest": {
744
744
  "schemaVersion": 1,
745
- "bundleVersion": "2.0.121",
745
+ "bundleVersion": "2.0.126",
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": "1a8d1f9bf73b24fc07d26b56fa4185fdc9183a45bcf98b9b1996d8e27792bd1e"
783
+ "sha256": "6a7b8bea3fa6b4245307e96b51872fe04ab576c3a9161314f90c00cf6415465c"
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": "de523557a1057d95aaaf9a535b518fb4d8ca6bd99eaafdd57aab56db17c7cf1e"
883
+ "sha256": "8b1218c5e5343b2c3e00079170da131aff33f5a808365700f8eab62dbf7433b9"
884
884
  }
885
885
  ]
886
886
  }
887
887
  },
888
888
  {
889
- "repositoryCliVersion": "0.1.130",
889
+ "repositoryCliVersion": "0.1.135",
890
890
  "manifest": {
891
891
  "schemaVersion": 1,
892
- "bundleVersion": "2.0.120",
892
+ "bundleVersion": "2.0.125",
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": "875b31938089b6c1542a3210c198e5ff8441d7f1c1b9c462fb9b7539a9b5914f"
930
+ "sha256": "c7a266bb4f6614daa2a1adcfb3248f99330a8d4184866a4611268b93a4352203"
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": "af6994cd686529a6ec4d1c52020a729196bd6d7722f404ea4d35e8fd1e187467"
1030
+ "sha256": "ad9e79fd0ee9d6478567615d78e34efa272fc6a1c5f8016cd1aae64ba3e24679"
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.139",
3
+ "version": "0.1.142",
4
4
  "description": "FunnelsGrove command-line tools for editing, syncing, and publishing funnels",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,12 +34,12 @@
34
34
  "test": "vitest run"
35
35
  },
36
36
  "dependencies": {
37
- "@funnelsgrove/runtime": "0.7.26",
37
+ "@funnelsgrove/runtime": "0.7.27",
38
38
  "commander": "^12.0.0",
39
39
  "typescript": "^5.8.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@funnelsgrove/analytics": "0.1.75",
42
+ "@funnelsgrove/analytics": "0.1.76",
43
43
  "@funnelsgrove/payments": "0.7.19",
44
44
  "vitest": "^3.0.0"
45
45
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.129",
3
+ "bundleVersion": "2.0.132",
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": "2a6ffbd2768cf73b049b4b067c003c81c2e3d3679fea6bf3f2865ddf419983f4"
41
+ "sha256": "33d225bcc4f6f7aaa473f3bebe81799b3ec4751c374a4c2d9159afc56415ba74"
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": "adda37f1991ccbb5e7abf2b9f1465688c116e6604b08a3d63f104b295a93140b"
141
+ "sha256": "ea5b05c7f28303245e358598f125a3a31c15175c2ef15ae8873b25be2ded133e"
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/runtime` `0.7.26` first, then `@funnelsgrove/analytics` `0.1.75`, then `@funnelsgrove/payments` `0.7.19`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.139`, 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/runtime` `0.7.27` first, then `@funnelsgrove/analytics` `0.1.76`, then `@funnelsgrove/payments` `0.7.19`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.142`, 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.129",
3
+ "bundleVersion": "2.0.132",
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.129",
3
+ "bundleVersion": "2.0.132",
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": "2a6ffbd2768cf73b049b4b067c003c81c2e3d3679fea6bf3f2865ddf419983f4"
41
+ "sha256": "33d225bcc4f6f7aaa473f3bebe81799b3ec4751c374a4c2d9159afc56415ba74"
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": "adda37f1991ccbb5e7abf2b9f1465688c116e6604b08a3d63f104b295a93140b"
141
+ "sha256": "ea5b05c7f28303245e358598f125a3a31c15175c2ef15ae8873b25be2ded133e"
142
142
  }
143
143
  ]
144
144
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sourceTreeHash": "1a0c798df5c5dead5025036f207f2b08a007662721a51530d73f2583face8fa9",
3
+ "sourceTreeHash": "17a2b4d922e272fe5b1097d38e22604cb9ea2418e9428c658c5c83f4ba095fd5",
4
4
  "stepContractVersion": 3,
5
- "docsBundleVersion": "2.0.129",
5
+ "docsBundleVersion": "2.0.132",
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": "4787e89c601c86fa74bbd5f28cfab16686c90ef58cdffe750847c3d1b7baafdd",
19
+ "sha256": "a651235159c3d3aba55878722394461a4e0b25da1e084841a3686b82bd59f71f",
20
20
  "mode": "100644"
21
21
  },
22
22
  {
@@ -101,7 +101,7 @@
101
101
  },
102
102
  {
103
103
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
104
- "sha256": "2a6ffbd2768cf73b049b4b067c003c81c2e3d3679fea6bf3f2865ddf419983f4",
104
+ "sha256": "33d225bcc4f6f7aaa473f3bebe81799b3ec4751c374a4c2d9159afc56415ba74",
105
105
  "mode": "100644"
106
106
  },
107
107
  {
@@ -236,7 +236,7 @@
236
236
  },
237
237
  {
238
238
  "path": "funnel-docs.config.json",
239
- "sha256": "adda37f1991ccbb5e7abf2b9f1465688c116e6604b08a3d63f104b295a93140b",
239
+ "sha256": "ea5b05c7f28303245e358598f125a3a31c15175c2ef15ae8873b25be2ded133e",
240
240
  "mode": "100644"
241
241
  },
242
242
  {
@@ -256,17 +256,17 @@
256
256
  },
257
257
  {
258
258
  "path": "next.config.ts",
259
- "sha256": "cd5ff10c989cf4ae5d54b78638843d56e32e3999f2334cb0cbc9277aae68356c",
259
+ "sha256": "9d2213c2270579568fa5ae409d5173594c08048bcaf91350b4d946293022ce74",
260
260
  "mode": "100644"
261
261
  },
262
262
  {
263
263
  "path": "package-lock.json",
264
- "sha256": "09e020ec8442cb7a0a87a1ffddec86d6caee3a54b494ed844407007063ff68a2",
264
+ "sha256": "8f60d0578889cf9433a5b383f9d243da0f36b22b50bc76354d44c35adf2eba56",
265
265
  "mode": "100644"
266
266
  },
267
267
  {
268
268
  "path": "package.json",
269
- "sha256": "a965a1abeef3d228a57be9f89275144d9530cafec0d85351cf541fdcc5b8d1ac",
269
+ "sha256": "931094eb8a5eb373bb956422ec4ba0d50abb25c4525867b22bad6b64ef034318",
270
270
  "mode": "100644"
271
271
  },
272
272
  {
@@ -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/runtime` `0.7.26` first, then `@funnelsgrove/analytics` `0.1.75`, then `@funnelsgrove/payments` `0.7.19`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.139`, 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/runtime` `0.7.27` first, then `@funnelsgrove/analytics` `0.1.76`, then `@funnelsgrove/payments` `0.7.19`. The production deploy verifies the zero-traffic API candidate, publishes and verifies `@funnelsgrove/cli` `0.1.142`, 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.129",
3
+ "bundleVersion": "2.0.132",
4
4
  "contractSource": "funnelsgrove-repository://apps/funnel-runtime/contracts/step-contract-v2.json",
5
5
  "fullyGenerated": [
6
6
  ".funnelsgrove-docs.json",
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import type { NextConfig } from 'next';
4
4
 
5
5
  const isStaticExportBuild = process.env.NEXT_EXPORT === '1';
6
+ const runtimeConfigOrigin = process.env.FUNNEL_RUNTIME_CONFIG_ORIGIN?.trim().replace(/\/+$/, '') || '';
6
7
 
7
8
  // Inside the funnelsgrove monorepo, alias @funnelsgrove/* to the package
8
9
  // sources so changes there rebuild live. Standalone copies (funnels created
@@ -31,6 +32,12 @@ const nextConfig: NextConfig = {
31
32
  ? { output: 'export' as const }
32
33
  : {
33
34
  rewrites: async () => [
35
+ ...(runtimeConfigOrigin
36
+ ? [{
37
+ source: '/api/funnel-config/:path*',
38
+ destination: `${runtimeConfigOrigin}/api/funnel-config/:path*`,
39
+ }]
40
+ : []),
34
41
  {
35
42
  source: '/ingest/static/:path*',
36
43
  destination: 'https://us-assets.i.posthog.com/static/:path*',
@@ -8,9 +8,9 @@
8
8
  "name": "funnel-template",
9
9
  "version": "0.1.0",
10
10
  "dependencies": {
11
- "@funnelsgrove/analytics": "^0.1.75",
11
+ "@funnelsgrove/analytics": "^0.1.76",
12
12
  "@funnelsgrove/payments": "^0.7.19",
13
- "@funnelsgrove/runtime": "^0.7.26",
13
+ "@funnelsgrove/runtime": "^0.7.27",
14
14
  "@stripe/react-stripe-js": "^5.6.0",
15
15
  "@stripe/stripe-js": "^8.7.0",
16
16
  "lucide-react": "^0.553.0",
@@ -938,11 +938,11 @@
938
938
  }
939
939
  },
940
940
  "node_modules/@funnelsgrove/analytics": {
941
- "version": "0.1.75",
942
- "resolved": "https://registry.npmjs.org/@funnelsgrove/analytics/-/analytics-0.1.75.tgz",
943
- "integrity": "sha512-q7hOSmSuyHQEN/95MBcgjAwWqewUTUlbH3BgaSaYBPabGZyZxMC3Zopmyva/OieXmQ0f3J8JQlpxhdEB7ssftA==",
941
+ "version": "0.1.76",
942
+ "resolved": "https://registry.npmjs.org/@funnelsgrove/analytics/-/analytics-0.1.76.tgz",
943
+ "integrity": "sha512-5Zf0zxZ4GXRpwfHTAcJX1sk07tiFrfC7TVB1dZueyNosFcKl6+o9omVE5/euoJ0uJsblPGTzJDW8+wdyK2MbzA==",
944
944
  "dependencies": {
945
- "@funnelsgrove/runtime": "0.7.26"
945
+ "@funnelsgrove/runtime": "0.7.27"
946
946
  }
947
947
  },
948
948
  "node_modules/@funnelsgrove/payments": {
@@ -961,9 +961,9 @@
961
961
  }
962
962
  },
963
963
  "node_modules/@funnelsgrove/runtime": {
964
- "version": "0.7.26",
965
- "resolved": "https://registry.npmjs.org/@funnelsgrove/runtime/-/runtime-0.7.26.tgz",
966
- "integrity": "sha512-PbdmEC23bJpGo/dRNhhHTbp2y8a/IZ3Ggs3746UwZQOxxzV9ImkNVeWQl0zlmnGvBLWGOWcpTW48nuneR0uwuw==",
964
+ "version": "0.7.27",
965
+ "resolved": "https://registry.npmjs.org/@funnelsgrove/runtime/-/runtime-0.7.27.tgz",
966
+ "integrity": "sha512-FiVI6rmV8BhtRowV46Cm4bqgr2UvYUCI/yyW41lhiYYcnolVxNYyaO++j8FlkqXn99JvPPauSHC6dtLvmojeEg==",
967
967
  "dependencies": {
968
968
  "posthog-js": "^1.369.2",
969
969
  "react": "19.2.3",
@@ -12,9 +12,9 @@
12
12
  "validate:funnel": "vite-node --config src/contract/funnel-validator.vite.config.ts src/contract/validate-funnel.cli.ts"
13
13
  },
14
14
  "dependencies": {
15
- "@funnelsgrove/analytics": "^0.1.75",
15
+ "@funnelsgrove/analytics": "^0.1.76",
16
16
  "@funnelsgrove/payments": "^0.7.19",
17
- "@funnelsgrove/runtime": "^0.7.26",
17
+ "@funnelsgrove/runtime": "^0.7.27",
18
18
  "@stripe/react-stripe-js": "^5.6.0",
19
19
  "@stripe/stripe-js": "^8.7.0",
20
20
  "lucide-react": "^0.553.0",