@funnelsgrove/cli 0.1.75 → 0.1.76

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
@@ -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 { executeEmailPull, executeEmailPush, executeEmailSequencePublish, executeEmailTemplatePublish, executeEmailValidate, } from './emailCommands.js';
18
19
  import { formatGitHubConnectRows, formatGitHubJobRows, formatGitHubStatusRows, } from './githubOutput.js';
19
20
  import { GitHubSyncTimeoutError, syncGitHubDraftIfConnected, } from './githubSyncFlow.js';
20
21
  import { reskinFunnel } from './reskin.js';
@@ -1440,6 +1441,22 @@ const resolveAnalyticsProject = async (input) => {
1440
1441
  }
1441
1442
  return resolveProject(input.token, input.workspaceId, project);
1442
1443
  };
1444
+ const resolveEmailCommandScope = async (options) => {
1445
+ const token = await readAuthToken();
1446
+ const workspaceId = await resolveWorkspaceId(token, options.workspace);
1447
+ const project = await resolveAnalyticsProject({
1448
+ token,
1449
+ workspaceId,
1450
+ project: options.project,
1451
+ });
1452
+ return {
1453
+ callApi,
1454
+ token,
1455
+ workspaceId,
1456
+ projectId: project.id,
1457
+ sourceDir: path.resolve(process.cwd(), options.dir),
1458
+ };
1459
+ };
1443
1460
  const resolveAnalyticsFunnel = async (input) => {
1444
1461
  const active = await loadActiveContext(getConfigPath());
1445
1462
  const funnel = input.funnel || (active?.workspaceId === input.workspaceId ? active.funnelId : undefined);
@@ -1682,6 +1699,69 @@ addExamples(program
1682
1699
  console.log(`${legacyDiagnostic.code}\t${legacyDiagnostic.message}`);
1683
1700
  }
1684
1701
  });
1702
+ const addEmailScopeOptions = (command) => command
1703
+ .option('--workspace <id-or-slug-or-name>', 'Workspace id, slug, or name')
1704
+ .option('--project <id-or-slug-or-name>', 'Project id, slug, or name')
1705
+ .option('--dir <path>', 'Directory containing the emails folder', '.');
1706
+ const emailCommand = addExamples(program.command('email').description('Manage project email drafts'), [
1707
+ 'fgrove email pull',
1708
+ 'fgrove email validate',
1709
+ 'fgrove email push',
1710
+ 'fgrove email template publish welcome',
1711
+ ]);
1712
+ addEmailScopeOptions(emailCommand
1713
+ .command('pull')
1714
+ .description('Pull project email drafts into local files'))
1715
+ .action(async (options) => {
1716
+ const result = await executeEmailPull(await resolveEmailCommandScope(options));
1717
+ console.log(`Pulled ${result.templates} templates and ${result.sequences} sequences.`);
1718
+ });
1719
+ emailCommand
1720
+ .command('validate')
1721
+ .description('Validate local email draft files')
1722
+ .option('--dir <path>', 'Directory containing the emails folder', '.')
1723
+ .action(async (options) => {
1724
+ const result = await executeEmailValidate({
1725
+ sourceDir: path.resolve(process.cwd(), options.dir),
1726
+ });
1727
+ if (result.valid) {
1728
+ console.log('Email files are valid.');
1729
+ return;
1730
+ }
1731
+ for (const item of result.diagnostics) {
1732
+ console.error(`[${item.code}] ${item.file || 'emails'}: ${item.reason}`);
1733
+ }
1734
+ process.exitCode = 1;
1735
+ });
1736
+ addEmailScopeOptions(emailCommand
1737
+ .command('push')
1738
+ .description('Push local email drafts without publishing'))
1739
+ .action(async (options) => {
1740
+ const result = await executeEmailPush(await resolveEmailCommandScope(options));
1741
+ console.log(`Pushed ${result.templates} templates and ${result.sequences} sequences.`);
1742
+ });
1743
+ const emailTemplateCommand = emailCommand.command('template').description('Manage email templates');
1744
+ addEmailScopeOptions(emailTemplateCommand
1745
+ .command('publish <slug>')
1746
+ .description('Publish one email template explicitly'))
1747
+ .action(async (slug, options) => {
1748
+ await executeEmailTemplatePublish({
1749
+ ...await resolveEmailCommandScope(options),
1750
+ slug,
1751
+ });
1752
+ console.log(`Published email template ${slug}.`);
1753
+ });
1754
+ const emailSequenceCommand = emailCommand.command('sequence').description('Manage email sequences');
1755
+ addEmailScopeOptions(emailSequenceCommand
1756
+ .command('publish <slug>')
1757
+ .description('Publish one email sequence explicitly'))
1758
+ .action(async (slug, options) => {
1759
+ await executeEmailSequencePublish({
1760
+ ...await resolveEmailCommandScope(options),
1761
+ slug,
1762
+ });
1763
+ console.log(`Published email sequence ${slug}.`);
1764
+ });
1685
1765
  const projectsCommand = addExamples(program.command('projects').description('Manage projects'), [
1686
1766
  'fgrove projects list',
1687
1767
  'fgrove projects list --workspace acme',
@@ -0,0 +1,32 @@
1
+ import { type EmailFilesResult } from './emailFiles.js';
2
+ export type EmailCallApi = <T>(input: {
3
+ path: string;
4
+ type: 'query' | 'mutation';
5
+ data?: unknown;
6
+ token?: string | null;
7
+ }) => Promise<T>;
8
+ type EmailCommandScope = {
9
+ callApi: EmailCallApi;
10
+ token: string;
11
+ workspaceId: string;
12
+ projectId: string;
13
+ sourceDir: string;
14
+ };
15
+ export declare function executeEmailPull(scope: EmailCommandScope): Promise<{
16
+ templates: number;
17
+ sequences: number;
18
+ }>;
19
+ export declare const executeEmailValidate: (input: {
20
+ sourceDir: string;
21
+ }) => Promise<EmailFilesResult>;
22
+ export declare function executeEmailPush(scope: EmailCommandScope): Promise<{
23
+ templates: number;
24
+ sequences: number;
25
+ }>;
26
+ export declare function executeEmailTemplatePublish(scope: EmailCommandScope & {
27
+ slug: string;
28
+ }): Promise<unknown>;
29
+ export declare function executeEmailSequencePublish(scope: EmailCommandScope & {
30
+ slug: string;
31
+ }): Promise<unknown>;
32
+ export {};
@@ -0,0 +1,269 @@
1
+ import { readEmailFiles, replaceEmailFiles, writeEmailFiles, writeEmailSequenceFile, writeEmailTemplateFile, } from './emailFiles.js';
2
+ const isRecord = (value) => (typeof value === 'object' && value !== null && !Array.isArray(value));
3
+ const UUID = /^[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 hasDraft = (value) => (isRecord(value) && isRecord(value.draft));
5
+ const assertRemoteResource = (value, resource) => {
6
+ if (!isRecord(value)
7
+ || typeof value.id !== 'string'
8
+ || !UUID.test(value.id)
9
+ || typeof value.slug !== 'string'
10
+ || typeof value.name !== 'string'
11
+ || !hasDraft(value)) {
12
+ throw new Error(`Invalid remote ${resource} resource`);
13
+ }
14
+ return value;
15
+ };
16
+ const assertCreatedId = (value, resource) => {
17
+ if (!isRecord(value) || typeof value.id !== 'string' || !UUID.test(value.id)) {
18
+ throw new Error(`Invalid created ${resource} ID`);
19
+ }
20
+ return value.id;
21
+ };
22
+ const assertRemoteIdentity = (value, resource) => {
23
+ if (!isRecord(value)
24
+ || typeof value.id !== 'string'
25
+ || !UUID.test(value.id)
26
+ || typeof value.slug !== 'string') {
27
+ throw new Error(`Invalid remote ${resource} identity`);
28
+ }
29
+ return value;
30
+ };
31
+ const assertValidFiles = (result) => {
32
+ if (result.valid)
33
+ return;
34
+ const summary = result.diagnostics
35
+ .map((item) => `[${item.code}] ${item.file || 'emails'}: ${item.reason}`)
36
+ .join('\n');
37
+ throw new Error(`Email files are invalid. Run \`fgrove email validate\`.\n${summary}`);
38
+ };
39
+ const projectData = (scope) => ({
40
+ workspaceId: scope.workspaceId,
41
+ projectId: scope.projectId,
42
+ });
43
+ const assertRemoteIdentities = async (scope, input) => {
44
+ const localWithIds = input.local.filter((item) => item.id !== null);
45
+ if (localWithIds.length === 0)
46
+ return new Map();
47
+ const remote = await scope.callApi({
48
+ path: `${input.resource}.list`,
49
+ type: 'query',
50
+ token: scope.token,
51
+ data: projectData(scope),
52
+ });
53
+ const parsed = remote.map((item) => assertRemoteIdentity(item, input.resource));
54
+ const remoteSlugs = new Map(parsed.map((item) => [item.id, item.slug]));
55
+ for (const local of localWithIds) {
56
+ const remoteSlug = remoteSlugs.get(local.id);
57
+ if (remoteSlug !== local.slug) {
58
+ throw new Error(`Email identity mismatch: ID ${local.id} has local slug "${local.slug}" but remote slug ${remoteSlug ? `"${remoteSlug}"` : 'is missing'}.`);
59
+ }
60
+ }
61
+ return new Map(parsed.map((item) => [item.id, item]));
62
+ };
63
+ const canonicalResource = (kind, value) => {
64
+ if (kind === 'template') {
65
+ const variables = isRecord(value.draft.variables) ? value.draft.variables : {};
66
+ return JSON.stringify({
67
+ name: value.name,
68
+ subject: value.draft.subject,
69
+ previewText: value.draft.previewText,
70
+ html: value.draft.html,
71
+ text: value.draft.text,
72
+ variables: Object.fromEntries(Object.entries(variables).sort(([left], [right]) => left.localeCompare(right))),
73
+ });
74
+ }
75
+ const steps = Array.isArray(value.draft.steps) ? value.draft.steps : [];
76
+ return JSON.stringify({
77
+ name: value.name,
78
+ triggerEventType: value.draft.triggerEventType,
79
+ funnelIds: Array.isArray(value.draft.funnelIds) ? [...new Set(value.draft.funnelIds)].sort() : [],
80
+ steps: steps.map((step) => isRecord(step) ? {
81
+ key: step.key,
82
+ delaySeconds: step.delaySeconds,
83
+ templateVersionId: step.templateVersionId,
84
+ } : step),
85
+ exitEventTypes: Array.isArray(value.draft.exitEventTypes)
86
+ ? [...new Set(value.draft.exitEventTypes)].sort()
87
+ : [],
88
+ });
89
+ };
90
+ const loadCompleteItems = async (scope, input) => {
91
+ const listed = await scope.callApi({
92
+ path: `${input.resource}.list`,
93
+ type: 'query',
94
+ token: scope.token,
95
+ data: projectData(scope),
96
+ });
97
+ return Promise.all(listed.map(async (item) => {
98
+ if (hasDraft(item))
99
+ return assertRemoteResource(item, input.resource);
100
+ if (!isRecord(item) || typeof item.id !== 'string') {
101
+ throw new Error(`Invalid ${input.resource}.list response`);
102
+ }
103
+ const detail = await scope.callApi({
104
+ path: `${input.resource}.get`,
105
+ type: 'query',
106
+ token: scope.token,
107
+ data: {
108
+ ...projectData(scope),
109
+ [input.idKey]: item.id,
110
+ },
111
+ });
112
+ return assertRemoteResource(detail[input.detailKey], input.resource);
113
+ }));
114
+ };
115
+ export async function executeEmailPull(scope) {
116
+ const [templates, sequences] = await Promise.all([
117
+ loadCompleteItems(scope, {
118
+ resource: 'emailTemplates',
119
+ idKey: 'templateId',
120
+ detailKey: 'template',
121
+ }),
122
+ loadCompleteItems(scope, {
123
+ resource: 'emailSequences',
124
+ idKey: 'sequenceId',
125
+ detailKey: 'sequence',
126
+ }),
127
+ ]);
128
+ await replaceEmailFiles({
129
+ sourceDir: scope.sourceDir,
130
+ templates,
131
+ sequences,
132
+ });
133
+ return { templates: templates.length, sequences: sequences.length };
134
+ }
135
+ export const executeEmailValidate = (input) => readEmailFiles(input.sourceDir);
136
+ export async function executeEmailPush(scope) {
137
+ const files = await readEmailFiles(scope.sourceDir);
138
+ assertValidFiles(files);
139
+ await Promise.all([
140
+ assertRemoteIdentities(scope, {
141
+ resource: 'emailTemplates',
142
+ local: files.templates,
143
+ }),
144
+ assertRemoteIdentities(scope, {
145
+ resource: 'emailSequences',
146
+ local: files.sequences,
147
+ }),
148
+ ]);
149
+ for (const template of files.templates) {
150
+ if (template.id) {
151
+ await scope.callApi({
152
+ path: 'emailTemplates.updateDraft',
153
+ type: 'mutation',
154
+ token: scope.token,
155
+ data: {
156
+ ...projectData(scope),
157
+ templateId: template.id,
158
+ name: template.name,
159
+ draft: template.draft,
160
+ },
161
+ });
162
+ continue;
163
+ }
164
+ const created = await scope.callApi({
165
+ path: 'emailTemplates.create',
166
+ type: 'mutation',
167
+ token: scope.token,
168
+ data: {
169
+ ...projectData(scope),
170
+ slug: template.slug,
171
+ name: template.name,
172
+ draft: template.draft,
173
+ },
174
+ });
175
+ template.id = assertCreatedId(created, 'email template');
176
+ await writeEmailTemplateFile(scope.sourceDir, template);
177
+ }
178
+ for (const sequence of files.sequences) {
179
+ if (sequence.id) {
180
+ await scope.callApi({
181
+ path: 'emailSequences.updateDraft',
182
+ type: 'mutation',
183
+ token: scope.token,
184
+ data: {
185
+ ...projectData(scope),
186
+ sequenceId: sequence.id,
187
+ name: sequence.name,
188
+ draft: sequence.draft,
189
+ },
190
+ });
191
+ continue;
192
+ }
193
+ const created = await scope.callApi({
194
+ path: 'emailSequences.create',
195
+ type: 'mutation',
196
+ token: scope.token,
197
+ data: {
198
+ ...projectData(scope),
199
+ slug: sequence.slug,
200
+ name: sequence.name,
201
+ draft: sequence.draft,
202
+ },
203
+ });
204
+ sequence.id = assertCreatedId(created, 'email sequence');
205
+ await writeEmailSequenceFile(scope.sourceDir, sequence);
206
+ }
207
+ await writeEmailFiles({
208
+ sourceDir: scope.sourceDir,
209
+ templates: files.templates,
210
+ sequences: files.sequences,
211
+ });
212
+ return { templates: files.templates.length, sequences: files.sequences.length };
213
+ }
214
+ export async function executeEmailTemplatePublish(scope) {
215
+ return executeEmailPublish(scope, {
216
+ kind: 'template',
217
+ resource: 'emailTemplates',
218
+ idKey: 'templateId',
219
+ });
220
+ }
221
+ export async function executeEmailSequencePublish(scope) {
222
+ return executeEmailPublish(scope, {
223
+ kind: 'sequence',
224
+ resource: 'emailSequences',
225
+ idKey: 'sequenceId',
226
+ });
227
+ }
228
+ const executeEmailPublish = async (scope, input) => {
229
+ const files = await readEmailFiles(scope.sourceDir);
230
+ assertValidFiles(files);
231
+ const resources = input.kind === 'template' ? files.templates : files.sequences;
232
+ const resource = resources.find((item) => item.slug === scope.slug);
233
+ if (!resource)
234
+ throw new Error(`Email ${input.kind} "${scope.slug}" was not found locally.`);
235
+ if (!resource.id)
236
+ throw new Error(`Push email ${input.kind} "${scope.slug}" before publishing it.`);
237
+ const remote = await assertRemoteIdentities(scope, {
238
+ resource: input.resource,
239
+ local: [resource],
240
+ });
241
+ let remoteResource = remote.get(resource.id);
242
+ if (remoteResource && !hasDraft(remoteResource)) {
243
+ const detailKey = input.kind;
244
+ const detail = await scope.callApi({
245
+ path: `${input.resource}.get`,
246
+ type: 'query',
247
+ token: scope.token,
248
+ data: {
249
+ ...projectData(scope),
250
+ [input.idKey]: resource.id,
251
+ },
252
+ });
253
+ remoteResource = assertRemoteResource(detail[detailKey], input.resource);
254
+ }
255
+ if (!remoteResource
256
+ || canonicalResource(input.kind, resource)
257
+ !== canonicalResource(input.kind, remoteResource)) {
258
+ throw new Error(`Run \`fgrove email push\` before publishing ${input.kind} "${scope.slug}".`);
259
+ }
260
+ return scope.callApi({
261
+ path: `${input.resource}.publish`,
262
+ type: 'mutation',
263
+ token: scope.token,
264
+ data: {
265
+ ...projectData(scope),
266
+ [input.idKey]: resource.id,
267
+ },
268
+ });
269
+ };
@@ -0,0 +1,52 @@
1
+ import { type FunnelValidationDiagnostic } from './diagnosticOutput.js';
2
+ export type EmailTemplateVariableType = 'string' | 'number' | 'boolean';
3
+ export type EmailEventType = 'email_captured' | 'purchase_completed' | 'registration_completed';
4
+ export type EmailTemplateDraft = {
5
+ subject: string;
6
+ previewText: string | null;
7
+ html: string;
8
+ text: string;
9
+ variables: Record<string, EmailTemplateVariableType>;
10
+ };
11
+ export type EmailTemplateFile = {
12
+ id: string | null;
13
+ slug: string;
14
+ name: string;
15
+ draft: EmailTemplateDraft;
16
+ };
17
+ export type EmailSequenceStep = {
18
+ key: string;
19
+ delaySeconds: number;
20
+ templateVersionId: string;
21
+ };
22
+ export type EmailSequenceDraft = {
23
+ triggerEventType: EmailEventType;
24
+ funnelIds: string[];
25
+ steps: EmailSequenceStep[];
26
+ exitEventTypes: EmailEventType[];
27
+ };
28
+ export type EmailSequenceFile = {
29
+ id: string | null;
30
+ slug: string;
31
+ name: string;
32
+ draft: EmailSequenceDraft;
33
+ };
34
+ export type EmailFilesResult = {
35
+ valid: boolean;
36
+ diagnostics: FunnelValidationDiagnostic[];
37
+ templates: EmailTemplateFile[];
38
+ sequences: EmailSequenceFile[];
39
+ };
40
+ export declare function readEmailFiles(sourceDir: string): Promise<EmailFilesResult>;
41
+ export declare function writeEmailTemplateFile(sourceDir: string, template: EmailTemplateFile): Promise<void>;
42
+ export declare function writeEmailSequenceFile(sourceDir: string, sequence: EmailSequenceFile): Promise<void>;
43
+ export declare function writeEmailFiles(input: {
44
+ sourceDir: string;
45
+ templates: EmailTemplateFile[];
46
+ sequences: EmailSequenceFile[];
47
+ }): Promise<void>;
48
+ export declare function replaceEmailFiles(input: {
49
+ sourceDir: string;
50
+ templates: EmailTemplateFile[];
51
+ sequences: EmailSequenceFile[];
52
+ }): Promise<void>;
@@ -0,0 +1,517 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { createValidationDiagnostic, } from './diagnosticOutput.js';
5
+ const EMAIL_EVENTS = new Set([
6
+ 'email_captured',
7
+ 'purchase_completed',
8
+ 'registration_completed',
9
+ ]);
10
+ const VARIABLE_TYPES = new Set(['string', 'number', 'boolean']);
11
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
12
+ const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
13
+ const VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
14
+ const RESERVED_VARIABLE_NAMES = new Set(['__proto__', 'constructor', 'prototype']);
15
+ const STEP_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
16
+ const TEMPLATE_METADATA_KEYS = new Set([
17
+ 'id',
18
+ 'slug',
19
+ 'name',
20
+ 'subject',
21
+ 'previewText',
22
+ 'variables',
23
+ ]);
24
+ const SEQUENCE_KEYS = new Set([
25
+ 'id',
26
+ 'slug',
27
+ 'name',
28
+ 'triggerEventType',
29
+ 'funnelIds',
30
+ 'steps',
31
+ 'exitEventTypes',
32
+ ]);
33
+ const SEQUENCE_STEP_KEYS = new Set(['key', 'delaySeconds', 'templateVersionId']);
34
+ const isRecord = (value) => (typeof value === 'object' && value !== null && !Array.isArray(value));
35
+ const assertNoSymlinkPath = async (root, relativePath = '') => {
36
+ const parts = relativePath ? relativePath.split('/') : [];
37
+ let current = path.resolve(root);
38
+ for (const part of ['', ...parts]) {
39
+ if (part)
40
+ current = path.join(current, part);
41
+ try {
42
+ const metadata = await lstat(current);
43
+ if (metadata.isSymbolicLink()) {
44
+ throw new Error(`Managed email path cannot be a symlink: ${current}`);
45
+ }
46
+ }
47
+ catch (error) {
48
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
49
+ return;
50
+ throw error;
51
+ }
52
+ }
53
+ };
54
+ const assertWriterSlug = (slug) => {
55
+ if (slug.length > 80 || !SLUG.test(slug)) {
56
+ throw new Error(`Invalid email file slug: ${slug}`);
57
+ }
58
+ };
59
+ const writeAtomic = async (filePath, content) => {
60
+ const temporaryPath = `${filePath}.tmp-${randomUUID()}`;
61
+ try {
62
+ await writeFile(temporaryPath, content, { flag: 'wx' });
63
+ await rename(temporaryPath, filePath);
64
+ }
65
+ finally {
66
+ await rm(temporaryPath, { force: true });
67
+ }
68
+ };
69
+ const diagnostic = (input) => createValidationDiagnostic({
70
+ ...input,
71
+ stepId: null,
72
+ guide: 'Run `fgrove email validate` after repairing the file.',
73
+ });
74
+ const schemaDiagnostic = (file, field, expected, received) => diagnostic({
75
+ code: 'FG-EMAIL-002',
76
+ file,
77
+ reason: `Invalid email field: ${field}`,
78
+ expected,
79
+ received,
80
+ repair: `Set ${field} to the documented email file value.`,
81
+ });
82
+ const missingFileDiagnostic = (file) => diagnostic({
83
+ code: 'FG-EMAIL-001',
84
+ file,
85
+ reason: `Missing required email file: ${file}`,
86
+ expected: 'file',
87
+ received: null,
88
+ repair: `Create ${file}.`,
89
+ });
90
+ const readUtf8 = async (absolutePath, relativePath, diagnostics) => {
91
+ try {
92
+ return await readFile(absolutePath, 'utf8');
93
+ }
94
+ catch (error) {
95
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
96
+ diagnostics.push(missingFileDiagnostic(relativePath));
97
+ return null;
98
+ }
99
+ throw error;
100
+ }
101
+ };
102
+ const readJson = async (absolutePath, relativePath, diagnostics) => {
103
+ const source = await readUtf8(absolutePath, relativePath, diagnostics);
104
+ if (source === null)
105
+ return null;
106
+ try {
107
+ return JSON.parse(source);
108
+ }
109
+ catch {
110
+ diagnostics.push(diagnostic({
111
+ code: 'FG-EMAIL-001',
112
+ file: relativePath,
113
+ reason: 'Invalid JSON in email file',
114
+ expected: 'valid JSON',
115
+ received: source,
116
+ repair: `Repair the JSON syntax in ${relativePath}.`,
117
+ }));
118
+ return null;
119
+ }
120
+ };
121
+ const validateExactKeys = (value, allowed, file, diagnostics) => {
122
+ for (const key of Object.keys(value)) {
123
+ if (!allowed.has(key)) {
124
+ diagnostics.push(schemaDiagnostic(file, key, 'no unknown fields', value[key]));
125
+ }
126
+ }
127
+ };
128
+ const validateIdentity = (value, pathSlug, file, diagnostics) => {
129
+ let valid = true;
130
+ if (value.id !== null && (typeof value.id !== 'string' || !UUID.test(value.id))) {
131
+ diagnostics.push(schemaDiagnostic(file, 'id', 'UUID or null', value.id));
132
+ valid = false;
133
+ }
134
+ if (typeof value.slug !== 'string' || value.slug.length > 80 || !SLUG.test(value.slug)) {
135
+ diagnostics.push(schemaDiagnostic(file, 'slug', 'lowercase kebab-case slug', value.slug));
136
+ valid = false;
137
+ }
138
+ else if (value.slug !== pathSlug) {
139
+ diagnostics.push(diagnostic({
140
+ code: 'FG-EMAIL-003',
141
+ file,
142
+ reason: `Email slug ${value.slug} does not match path slug ${pathSlug}`,
143
+ expected: pathSlug,
144
+ received: value.slug,
145
+ repair: `Restore the path to ${value.slug} or restore slug to ${pathSlug}.`,
146
+ }));
147
+ valid = false;
148
+ }
149
+ if (typeof value.name !== 'string' || !value.name.trim() || value.name.length > 120) {
150
+ diagnostics.push(schemaDiagnostic(file, 'name', 'non-empty string up to 120 characters', value.name));
151
+ valid = false;
152
+ }
153
+ else if (value.name !== value.name.trim()) {
154
+ diagnostics.push(diagnostic({
155
+ code: 'FG-EMAIL-002',
156
+ file,
157
+ reason: 'Email name contains surrounding whitespace',
158
+ expected: value.name.trim(),
159
+ received: value.name,
160
+ repair: 'Remove surrounding whitespace from name.',
161
+ }));
162
+ valid = false;
163
+ }
164
+ return valid;
165
+ };
166
+ const validateTemplateMetadata = (value, pathSlug, file, diagnostics) => {
167
+ if (!isRecord(value)) {
168
+ diagnostics.push(schemaDiagnostic(file, 'root', 'object', value));
169
+ return null;
170
+ }
171
+ const initialCount = diagnostics.length;
172
+ validateExactKeys(value, TEMPLATE_METADATA_KEYS, file, diagnostics);
173
+ validateIdentity(value, pathSlug, file, diagnostics);
174
+ if (typeof value.subject !== 'string' || Buffer.byteLength(value.subject, 'utf8') > 998) {
175
+ diagnostics.push(schemaDiagnostic(file, 'subject', 'string up to 998 UTF-8 bytes', value.subject));
176
+ }
177
+ else if ([...value.subject].some((character) => {
178
+ const code = character.codePointAt(0);
179
+ return code <= 0x1f || (code >= 0x7f && code <= 0x9f);
180
+ })) {
181
+ diagnostics.push(diagnostic({
182
+ code: 'FG-EMAIL-002',
183
+ file,
184
+ reason: 'Email subject contains invalid control characters',
185
+ expected: 'subject without control characters',
186
+ received: value.subject,
187
+ repair: 'Remove control characters from subject.',
188
+ }));
189
+ }
190
+ if (value.previewText !== null
191
+ && (typeof value.previewText !== 'string' || Buffer.byteLength(value.previewText, 'utf8') > 500)) {
192
+ diagnostics.push(schemaDiagnostic(file, 'previewText', 'string up to 500 UTF-8 bytes or null', value.previewText));
193
+ }
194
+ if (!isRecord(value.variables)) {
195
+ diagnostics.push(schemaDiagnostic(file, 'variables', 'object', value.variables));
196
+ }
197
+ else {
198
+ const names = Object.keys(value.variables);
199
+ if (names.length > 50) {
200
+ diagnostics.push(schemaDiagnostic(file, 'variables', 'at most 50 variables', names.length));
201
+ }
202
+ for (const name of names) {
203
+ if (!VARIABLE_NAME.test(name) || Buffer.byteLength(name, 'utf8') > 64) {
204
+ diagnostics.push(schemaDiagnostic(file, `variables.${name}`, 'safe variable name', name));
205
+ }
206
+ if (RESERVED_VARIABLE_NAMES.has(name)) {
207
+ diagnostics.push(schemaDiagnostic(file, `variables.${name}`, 'non-reserved variable name', name));
208
+ }
209
+ if (!VARIABLE_TYPES.has(value.variables[name])) {
210
+ diagnostics.push(schemaDiagnostic(file, `variables.${name}`, 'string, number, or boolean', value.variables[name]));
211
+ }
212
+ }
213
+ }
214
+ if (diagnostics.length !== initialCount)
215
+ return null;
216
+ return value;
217
+ };
218
+ const validateSequence = (value, pathSlug, file, diagnostics) => {
219
+ if (!isRecord(value)) {
220
+ diagnostics.push(schemaDiagnostic(file, 'root', 'object', value));
221
+ return null;
222
+ }
223
+ const initialCount = diagnostics.length;
224
+ validateExactKeys(value, SEQUENCE_KEYS, file, diagnostics);
225
+ validateIdentity(value, pathSlug, file, diagnostics);
226
+ if (!EMAIL_EVENTS.has(value.triggerEventType)) {
227
+ diagnostics.push(schemaDiagnostic(file, 'triggerEventType', [...EMAIL_EVENTS], value.triggerEventType));
228
+ }
229
+ if (!Array.isArray(value.funnelIds) || value.funnelIds.length < 1 || value.funnelIds.length > 50) {
230
+ diagnostics.push(schemaDiagnostic(file, 'funnelIds', '1 to 50 UUIDs', value.funnelIds));
231
+ }
232
+ else {
233
+ value.funnelIds.forEach((id, index) => {
234
+ if (typeof id !== 'string' || !UUID.test(id)) {
235
+ diagnostics.push(schemaDiagnostic(file, `funnelIds[${index}]`, 'UUID', id));
236
+ }
237
+ });
238
+ }
239
+ if (!Array.isArray(value.steps) || value.steps.length < 1 || value.steps.length > 50) {
240
+ diagnostics.push(schemaDiagnostic(file, 'steps', '1 to 50 steps', value.steps));
241
+ }
242
+ else {
243
+ const seenKeys = new Set();
244
+ value.steps.forEach((step, index) => {
245
+ if (!isRecord(step)) {
246
+ diagnostics.push(schemaDiagnostic(file, `steps[${index}]`, 'object', step));
247
+ return;
248
+ }
249
+ validateExactKeys(step, SEQUENCE_STEP_KEYS, file, diagnostics);
250
+ if (typeof step.key !== 'string' || !STEP_KEY.test(step.key) || step.key.length > 64) {
251
+ diagnostics.push(schemaDiagnostic(file, `steps[${index}].key`, 'lowercase kebab-case key', step.key));
252
+ }
253
+ else if (seenKeys.has(step.key)) {
254
+ diagnostics.push(schemaDiagnostic(file, `steps[${index}].key`, 'unique step key', step.key));
255
+ }
256
+ else {
257
+ seenKeys.add(step.key);
258
+ }
259
+ if (!Number.isInteger(step.delaySeconds) || Number(step.delaySeconds) < 0 || Number(step.delaySeconds) > 7_776_000) {
260
+ diagnostics.push(schemaDiagnostic(file, `steps[${index}].delaySeconds`, 'integer from 0 to 7776000', step.delaySeconds));
261
+ }
262
+ if (typeof step.templateVersionId !== 'string' || !UUID.test(step.templateVersionId)) {
263
+ diagnostics.push(schemaDiagnostic(file, `steps[${index}].templateVersionId`, 'UUID', step.templateVersionId));
264
+ }
265
+ });
266
+ }
267
+ if (!Array.isArray(value.exitEventTypes) || value.exitEventTypes.length > EMAIL_EVENTS.size) {
268
+ diagnostics.push(schemaDiagnostic(file, 'exitEventTypes', 'up to 3 event types', value.exitEventTypes));
269
+ }
270
+ else {
271
+ value.exitEventTypes.forEach((event, index) => {
272
+ if (!EMAIL_EVENTS.has(event)) {
273
+ diagnostics.push(schemaDiagnostic(file, `exitEventTypes[${index}]`, [...EMAIL_EVENTS], event));
274
+ }
275
+ });
276
+ if (value.exitEventTypes.includes(value.triggerEventType)) {
277
+ diagnostics.push(schemaDiagnostic(file, 'exitEventTypes', 'events excluding triggerEventType', value.exitEventTypes));
278
+ }
279
+ }
280
+ if (diagnostics.length !== initialCount)
281
+ return null;
282
+ return {
283
+ id: value.id,
284
+ slug: value.slug,
285
+ name: value.name,
286
+ draft: {
287
+ triggerEventType: value.triggerEventType,
288
+ funnelIds: value.funnelIds,
289
+ steps: value.steps,
290
+ exitEventTypes: value.exitEventTypes,
291
+ },
292
+ };
293
+ };
294
+ const listDirectories = async (directory) => {
295
+ try {
296
+ const entries = await readdir(directory, { withFileTypes: true });
297
+ const symlink = entries.find((entry) => entry.isSymbolicLink());
298
+ if (symlink)
299
+ throw new Error(`Managed email path cannot be a symlink: ${path.join(directory, symlink.name)}`);
300
+ return entries
301
+ .filter((entry) => entry.isDirectory())
302
+ .map((entry) => entry.name)
303
+ .sort();
304
+ }
305
+ catch (error) {
306
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
307
+ return [];
308
+ throw error;
309
+ }
310
+ };
311
+ const listJsonFiles = async (directory) => {
312
+ try {
313
+ const entries = await readdir(directory, { withFileTypes: true });
314
+ const symlink = entries.find((entry) => entry.isSymbolicLink());
315
+ if (symlink)
316
+ throw new Error(`Managed email path cannot be a symlink: ${path.join(directory, symlink.name)}`);
317
+ return entries
318
+ .filter((entry) => entry.isFile() && entry.name.endsWith('.json'))
319
+ .map((entry) => entry.name)
320
+ .sort();
321
+ }
322
+ catch (error) {
323
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
324
+ return [];
325
+ throw error;
326
+ }
327
+ };
328
+ export async function readEmailFiles(sourceDir) {
329
+ const diagnostics = [];
330
+ const templates = [];
331
+ const sequences = [];
332
+ const templateRoot = path.join(sourceDir, 'emails', 'templates');
333
+ const sequenceRoot = path.join(sourceDir, 'emails', 'sequences');
334
+ await Promise.all([
335
+ assertNoSymlinkPath(sourceDir),
336
+ assertNoSymlinkPath(sourceDir, 'emails'),
337
+ assertNoSymlinkPath(sourceDir, 'emails/templates'),
338
+ assertNoSymlinkPath(sourceDir, 'emails/sequences'),
339
+ ]);
340
+ for (const slug of await listDirectories(templateRoot)) {
341
+ const relativeRoot = path.posix.join('emails', 'templates', slug);
342
+ const metadataFile = path.posix.join(relativeRoot, 'template.json');
343
+ const htmlFile = path.posix.join(relativeRoot, 'body.html');
344
+ const textFile = path.posix.join(relativeRoot, 'body.txt');
345
+ await Promise.all([
346
+ assertNoSymlinkPath(sourceDir, relativeRoot),
347
+ assertNoSymlinkPath(sourceDir, metadataFile),
348
+ assertNoSymlinkPath(sourceDir, htmlFile),
349
+ assertNoSymlinkPath(sourceDir, textFile),
350
+ ]);
351
+ const metadataValue = await readJson(path.join(templateRoot, slug, 'template.json'), metadataFile, diagnostics);
352
+ const html = await readUtf8(path.join(templateRoot, slug, 'body.html'), htmlFile, diagnostics);
353
+ const text = await readUtf8(path.join(templateRoot, slug, 'body.txt'), textFile, diagnostics);
354
+ const metadata = metadataValue === null
355
+ ? null
356
+ : validateTemplateMetadata(metadataValue, slug, metadataFile, diagnostics);
357
+ if (metadata && html !== null && text !== null) {
358
+ if (Buffer.byteLength(html, 'utf8') > 256_000) {
359
+ diagnostics.push(schemaDiagnostic(htmlFile, 'body', 'up to 256000 UTF-8 bytes', html.length));
360
+ }
361
+ else if (Buffer.byteLength(text, 'utf8') > 100_000) {
362
+ diagnostics.push(schemaDiagnostic(textFile, 'body', 'up to 100000 UTF-8 bytes', text.length));
363
+ }
364
+ else {
365
+ templates.push({
366
+ id: metadata.id,
367
+ slug: metadata.slug,
368
+ name: metadata.name,
369
+ draft: {
370
+ subject: metadata.subject,
371
+ previewText: metadata.previewText,
372
+ html,
373
+ text,
374
+ variables: metadata.variables,
375
+ },
376
+ });
377
+ }
378
+ }
379
+ }
380
+ for (const filename of await listJsonFiles(sequenceRoot)) {
381
+ const slug = filename.slice(0, -'.json'.length);
382
+ const relativeFile = path.posix.join('emails', 'sequences', filename);
383
+ const value = await readJson(path.join(sequenceRoot, filename), relativeFile, diagnostics);
384
+ const sequence = value === null ? null : validateSequence(value, slug, relativeFile, diagnostics);
385
+ if (sequence)
386
+ sequences.push(sequence);
387
+ }
388
+ return {
389
+ valid: diagnostics.length === 0,
390
+ diagnostics,
391
+ templates,
392
+ sequences,
393
+ };
394
+ }
395
+ const sortedVariables = (variables) => Object.fromEntries(Object.entries(variables).sort(([left], [right]) => (Buffer.compare(Buffer.from(left), Buffer.from(right)))));
396
+ const compareUtf8 = (left, right) => (Buffer.compare(Buffer.from(left), Buffer.from(right)));
397
+ const sortedUnique = (values) => [...new Set(values)].sort(compareUtf8);
398
+ export async function writeEmailTemplateFile(sourceDir, template) {
399
+ assertWriterSlug(template.slug);
400
+ const relativeDirectory = path.posix.join('emails', 'templates', template.slug);
401
+ const directory = path.join(sourceDir, relativeDirectory);
402
+ await Promise.all([
403
+ assertNoSymlinkPath(sourceDir),
404
+ assertNoSymlinkPath(sourceDir, 'emails'),
405
+ assertNoSymlinkPath(sourceDir, 'emails/templates'),
406
+ assertNoSymlinkPath(sourceDir, relativeDirectory),
407
+ assertNoSymlinkPath(sourceDir, path.posix.join(relativeDirectory, 'template.json')),
408
+ assertNoSymlinkPath(sourceDir, path.posix.join(relativeDirectory, 'body.html')),
409
+ assertNoSymlinkPath(sourceDir, path.posix.join(relativeDirectory, 'body.txt')),
410
+ ]);
411
+ await mkdir(directory, { recursive: true });
412
+ const metadata = {
413
+ id: template.id,
414
+ slug: template.slug,
415
+ name: template.name,
416
+ subject: template.draft.subject,
417
+ previewText: template.draft.previewText,
418
+ variables: sortedVariables(template.draft.variables),
419
+ };
420
+ await writeAtomic(path.join(directory, 'template.json'), `${JSON.stringify(metadata, null, 2)}\n`);
421
+ await Promise.all([
422
+ writeAtomic(path.join(directory, 'body.html'), template.draft.html),
423
+ writeAtomic(path.join(directory, 'body.txt'), template.draft.text),
424
+ ]);
425
+ }
426
+ export async function writeEmailSequenceFile(sourceDir, sequence) {
427
+ assertWriterSlug(sequence.slug);
428
+ const relativeRoot = path.posix.join('emails', 'sequences');
429
+ const relativeFile = path.posix.join(relativeRoot, `${sequence.slug}.json`);
430
+ await Promise.all([
431
+ assertNoSymlinkPath(sourceDir),
432
+ assertNoSymlinkPath(sourceDir, 'emails'),
433
+ assertNoSymlinkPath(sourceDir, relativeRoot),
434
+ assertNoSymlinkPath(sourceDir, relativeFile),
435
+ ]);
436
+ const sequenceRoot = path.join(sourceDir, relativeRoot);
437
+ await mkdir(sequenceRoot, { recursive: true });
438
+ const serialized = {
439
+ id: sequence.id,
440
+ slug: sequence.slug,
441
+ name: sequence.name,
442
+ triggerEventType: sequence.draft.triggerEventType,
443
+ funnelIds: sortedUnique(sequence.draft.funnelIds),
444
+ steps: sequence.draft.steps.map((step) => ({
445
+ key: step.key,
446
+ delaySeconds: step.delaySeconds,
447
+ templateVersionId: step.templateVersionId,
448
+ })),
449
+ exitEventTypes: sortedUnique(sequence.draft.exitEventTypes),
450
+ };
451
+ await writeAtomic(path.join(sequenceRoot, `${sequence.slug}.json`), `${JSON.stringify(serialized, null, 2)}\n`);
452
+ }
453
+ export async function writeEmailFiles(input) {
454
+ await Promise.all([
455
+ assertNoSymlinkPath(input.sourceDir),
456
+ assertNoSymlinkPath(input.sourceDir, 'emails'),
457
+ assertNoSymlinkPath(input.sourceDir, 'emails/templates'),
458
+ assertNoSymlinkPath(input.sourceDir, 'emails/sequences'),
459
+ ]);
460
+ await Promise.all([
461
+ mkdir(path.join(input.sourceDir, 'emails', 'templates'), { recursive: true }),
462
+ mkdir(path.join(input.sourceDir, 'emails', 'sequences'), { recursive: true }),
463
+ ]);
464
+ for (const template of [...input.templates].sort((left, right) => compareUtf8(left.slug, right.slug))) {
465
+ await writeEmailTemplateFile(input.sourceDir, template);
466
+ }
467
+ for (const sequence of [...input.sequences].sort((left, right) => compareUtf8(left.slug, right.slug))) {
468
+ await writeEmailSequenceFile(input.sourceDir, sequence);
469
+ }
470
+ }
471
+ const pathExists = async (value) => {
472
+ try {
473
+ await lstat(value);
474
+ return true;
475
+ }
476
+ catch (error) {
477
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
478
+ return false;
479
+ throw error;
480
+ }
481
+ };
482
+ export async function replaceEmailFiles(input) {
483
+ await mkdir(input.sourceDir, { recursive: true });
484
+ await Promise.all([
485
+ assertNoSymlinkPath(input.sourceDir),
486
+ assertNoSymlinkPath(input.sourceDir, 'emails'),
487
+ ]);
488
+ const stagingRoot = await mkdtemp(path.join(input.sourceDir, '.fgrove-email-pull-'));
489
+ const target = path.join(input.sourceDir, 'emails');
490
+ const staged = path.join(stagingRoot, 'emails');
491
+ const backup = path.join(input.sourceDir, `.fgrove-email-backup-${randomUUID()}`);
492
+ let backedUp = false;
493
+ try {
494
+ await writeEmailFiles({ ...input, sourceDir: stagingRoot });
495
+ const validation = await readEmailFiles(stagingRoot);
496
+ if (!validation.valid)
497
+ throw new Error('Invalid remote email resources');
498
+ if (await pathExists(target)) {
499
+ await rename(target, backup);
500
+ backedUp = true;
501
+ }
502
+ try {
503
+ await rename(staged, target);
504
+ }
505
+ catch (error) {
506
+ if (backedUp)
507
+ await rename(backup, target);
508
+ backedUp = false;
509
+ throw error;
510
+ }
511
+ if (backedUp)
512
+ await rm(backup, { recursive: true, force: true });
513
+ }
514
+ finally {
515
+ await rm(stagingRoot, { recursive: true, force: true });
516
+ }
517
+ }
@@ -4,10 +4,10 @@
4
4
  "minimumCliVersion": "0.1.20",
5
5
  "entries": [
6
6
  {
7
- "repositoryCliVersion": "0.1.75",
7
+ "repositoryCliVersion": "0.1.76",
8
8
  "manifest": {
9
9
  "schemaVersion": 1,
10
- "bundleVersion": "2.0.64",
10
+ "bundleVersion": "2.0.65",
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": "e73eba7d01d41d4d87be8a6170835c84b7c4f64792bbafb59201130a380250ec"
48
+ "sha256": "753d4bd01a3f05d3165cbe19510564b44a80d0f8392b72582222b771bc7045e0"
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": "fd64ef085f6037e92d596ef958d4118e671285dd3561e22881eed0d7da1bba82"
148
+ "sha256": "d085f9a552809b085d6b6cd1a5237ad5fcc0d88a8d4384d185638bc3bc99c90f"
149
149
  }
150
150
  ]
151
151
  }
152
152
  },
153
153
  {
154
- "repositoryCliVersion": "0.1.74",
154
+ "repositoryCliVersion": "0.1.75",
155
155
  "manifest": {
156
156
  "schemaVersion": 1,
157
- "bundleVersion": "2.0.63",
157
+ "bundleVersion": "2.0.64",
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": "f025610f7c1d91188a67f50e7511a47642b3606170700e11cef0e7a49c8cd997"
195
+ "sha256": "e73eba7d01d41d4d87be8a6170835c84b7c4f64792bbafb59201130a380250ec"
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": "7852876ec227cb893db0315a00627cd609afe14ac5ffac5fdba0fe585a56fbbf"
295
+ "sha256": "fd64ef085f6037e92d596ef958d4118e671285dd3561e22881eed0d7da1bba82"
296
296
  }
297
297
  ]
298
298
  }
299
299
  },
300
300
  {
301
- "repositoryCliVersion": "0.1.73",
301
+ "repositoryCliVersion": "0.1.74",
302
302
  "manifest": {
303
303
  "schemaVersion": 1,
304
- "bundleVersion": "2.0.62",
304
+ "bundleVersion": "2.0.63",
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": "54e982ca3f199113646be0d6de1f8e2b8dde87744df82d6d7452d8e33b2b5258"
342
+ "sha256": "f025610f7c1d91188a67f50e7511a47642b3606170700e11cef0e7a49c8cd997"
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": "7f343fd806a932abcb3cac6463ae84a7532b7c9f583540e6fa06fd7ff7721ddf"
442
+ "sha256": "7852876ec227cb893db0315a00627cd609afe14ac5ffac5fdba0fe585a56fbbf"
443
443
  }
444
444
  ]
445
445
  }
446
446
  },
447
447
  {
448
- "repositoryCliVersion": "0.1.72",
448
+ "repositoryCliVersion": "0.1.73",
449
449
  "manifest": {
450
450
  "schemaVersion": 1,
451
- "bundleVersion": "2.0.61",
451
+ "bundleVersion": "2.0.62",
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": "217b719ef163d485c7a740906b3a1d551f5af37faf9fb721fc61d1fecf5fa9e6"
489
+ "sha256": "54e982ca3f199113646be0d6de1f8e2b8dde87744df82d6d7452d8e33b2b5258"
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": "f9be1a58ba8548ecbf51b2676479964dca89a04a63c9de53f6f805a6ed090fd0"
589
+ "sha256": "7f343fd806a932abcb3cac6463ae84a7532b7c9f583540e6fa06fd7ff7721ddf"
590
590
  }
591
591
  ]
592
592
  }
593
593
  },
594
594
  {
595
- "repositoryCliVersion": "0.1.71",
595
+ "repositoryCliVersion": "0.1.72",
596
596
  "manifest": {
597
597
  "schemaVersion": 1,
598
- "bundleVersion": "2.0.60",
598
+ "bundleVersion": "2.0.61",
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": "cf02bed62505b7b00ce5f6175eaa2fde99159556b37aad0f304ceba407041173"
636
+ "sha256": "217b719ef163d485c7a740906b3a1d551f5af37faf9fb721fc61d1fecf5fa9e6"
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": "2cd26fc471e315234da4daca6d5f54bf33107d9c7671e1db1a4ba229bc5c2ba0"
736
+ "sha256": "f9be1a58ba8548ecbf51b2676479964dca89a04a63c9de53f6f805a6ed090fd0"
737
737
  }
738
738
  ]
739
739
  }
740
740
  },
741
741
  {
742
- "repositoryCliVersion": "0.1.70",
742
+ "repositoryCliVersion": "0.1.71",
743
743
  "manifest": {
744
744
  "schemaVersion": 1,
745
- "bundleVersion": "2.0.59",
745
+ "bundleVersion": "2.0.60",
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": "f3a61a8d62eb9644f8cf20f86f856b5664cbf1c94e172694c4becc9a6bd11821"
783
+ "sha256": "cf02bed62505b7b00ce5f6175eaa2fde99159556b37aad0f304ceba407041173"
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": "ffae3632d0eb3d1c8f58542d89a95f9068e8fcb7540ea46d1a0a3502419fc599"
883
+ "sha256": "2cd26fc471e315234da4daca6d5f54bf33107d9c7671e1db1a4ba229bc5c2ba0"
884
884
  }
885
885
  ]
886
886
  }
887
887
  },
888
888
  {
889
- "repositoryCliVersion": "0.1.69",
889
+ "repositoryCliVersion": "0.1.70",
890
890
  "manifest": {
891
891
  "schemaVersion": 1,
892
- "bundleVersion": "2.0.58",
892
+ "bundleVersion": "2.0.59",
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": "6a6f526910ce80032feae59d33fc079f10168554430a582f03b39b73d0109367"
930
+ "sha256": "f3a61a8d62eb9644f8cf20f86f856b5664cbf1c94e172694c4becc9a6bd11821"
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": "ec76219d1d3a50f95fc9f5c5b690eb6747c0d468b81c11a926ed9ec484ffc654"
1030
+ "sha256": "ffae3632d0eb3d1c8f58542d89a95f9068e8fcb7540ea46d1a0a3502419fc599"
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.75",
3
+ "version": "0.1.76",
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.64",
3
+ "bundleVersion": "2.0.65",
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": "e73eba7d01d41d4d87be8a6170835c84b7c4f64792bbafb59201130a380250ec"
41
+ "sha256": "753d4bd01a3f05d3165cbe19510564b44a80d0f8392b72582222b771bc7045e0"
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": "fd64ef085f6037e92d596ef958d4118e671285dd3561e22881eed0d7da1bba82"
141
+ "sha256": "d085f9a552809b085d6b6cd1a5237ad5fcc0d88a8d4384d185638bc3bc99c90f"
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.5` first, then `@funnelsgrove/analytics` `0.1.54`, then `@funnelsgrove/payments` `0.7.3`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.75`. Publishing packages and deploying production remain separately approved operational actions.
20
+ Release `@funnelsgrove/runtime` `0.7.5` first, then `@funnelsgrove/analytics` `0.1.54`, then `@funnelsgrove/payments` `0.7.3`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.76`. 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.64",
3
+ "bundleVersion": "2.0.65",
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.64",
3
+ "bundleVersion": "2.0.65",
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": "e73eba7d01d41d4d87be8a6170835c84b7c4f64792bbafb59201130a380250ec"
41
+ "sha256": "753d4bd01a3f05d3165cbe19510564b44a80d0f8392b72582222b771bc7045e0"
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": "fd64ef085f6037e92d596ef958d4118e671285dd3561e22881eed0d7da1bba82"
141
+ "sha256": "d085f9a552809b085d6b6cd1a5237ad5fcc0d88a8d4384d185638bc3bc99c90f"
142
142
  }
143
143
  ]
144
144
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sourceTreeHash": "1d3aed0b290e8bf180195361309a48286c8be8d5ca476c42e148541e7f6fc9ff",
3
+ "sourceTreeHash": "77d2b1cb039b837f9670b9ae962687c4b61b0bbbbb97ad9b370a39265f9b73b4",
4
4
  "stepContractVersion": 3,
5
- "docsBundleVersion": "2.0.64",
5
+ "docsBundleVersion": "2.0.65",
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": "1e188eb21c6d7adee2426c5cfc693e34899246b1dd00f7899d10ad44b71d0109",
19
+ "sha256": "4f86b42926b30547392406f7b7040acd029e348b7d556339298814eefaac119d",
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": "e73eba7d01d41d4d87be8a6170835c84b7c4f64792bbafb59201130a380250ec",
104
+ "sha256": "753d4bd01a3f05d3165cbe19510564b44a80d0f8392b72582222b771bc7045e0",
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": "fd64ef085f6037e92d596ef958d4118e671285dd3561e22881eed0d7da1bba82",
239
+ "sha256": "d085f9a552809b085d6b6cd1a5237ad5fcc0d88a8d4384d185638bc3bc99c90f",
240
240
  "mode": "100644"
241
241
  },
242
242
  {
@@ -916,7 +916,7 @@
916
916
  },
917
917
  {
918
918
  "path": "tests/funnel-agent-docs.test.ts",
919
- "sha256": "0337e69fe6319c8d34aa9278b17997cf97ddbe63cac23c389a9069b9762619d0",
919
+ "sha256": "f5e68980974e69795f2dd8d4d180c2e8b860a63b0496cbcc8ca0aed82db09c57",
920
920
  "mode": "100644"
921
921
  },
922
922
  {
@@ -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.5` first, then `@funnelsgrove/analytics` `0.1.54`, then `@funnelsgrove/payments` `0.7.3`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.75`. Publishing packages and deploying production remain separately approved operational actions.
20
+ Release `@funnelsgrove/runtime` `0.7.5` first, then `@funnelsgrove/analytics` `0.1.54`, then `@funnelsgrove/payments` `0.7.3`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.76`. 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.64",
3
+ "bundleVersion": "2.0.65",
4
4
  "contractSource": "funnelsgrove-repository://apps/funnel-runtime/contracts/step-contract-v2.json",
5
5
  "fullyGenerated": [
6
6
  ".funnelsgrove-docs.json",
@@ -363,7 +363,7 @@ describe('funnel agent documentation supply', () => {
363
363
 
364
364
  expect(manifest).toMatchObject({
365
365
  schemaVersion: 1,
366
- bundleVersion: '2.0.64',
366
+ bundleVersion: '2.0.65',
367
367
  stepContractVersion: contract.stepContractVersion,
368
368
  contractHash: contract.contractHash,
369
369
  });