@funnelsgrove/cli 0.1.14 → 0.1.18
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/contracts/step-contract-v2.json +733 -0
- package/dist/analyticsOutput.d.ts +30 -15
- package/dist/analyticsOutput.js +45 -28
- package/dist/apiClient.d.ts +85 -0
- package/dist/apiClient.js +225 -8
- package/dist/cli.d.ts +149 -1
- package/dist/cli.js +1232 -71
- package/dist/diagnosticOutput.d.ts +42 -0
- package/dist/diagnosticOutput.js +83 -0
- package/dist/docsOutput.d.ts +19 -0
- package/dist/docsOutput.js +73 -0
- package/dist/docsTransaction.d.ts +81 -0
- package/dist/docsTransaction.js +1755 -0
- package/dist/funnelValidation.d.ts +14 -0
- package/dist/funnelValidation.js +297 -0
- package/dist/localSync.d.ts +79 -0
- package/dist/localSync.js +428 -53
- package/dist/projectValidator.d.ts +27 -0
- package/dist/projectValidator.js +208 -0
- package/dist/reskin.js +27 -1
- package/dist/stepContractMigration.d.ts +71 -0
- package/dist/stepContractMigration.js +1323 -0
- package/dist/templateDocs.js +8 -25
- package/docs-release-history.json +66 -0
- package/legacy-docs-catalog.json +1012 -0
- package/package.json +13 -4
- package/template_docs/.funnelsgrove-docs.json +144 -0
- package/template_docs/AGENTS.md +30 -58
- package/template_docs/CLAUDE.md +0 -2
- package/template_docs/docs/funnelsgrove/START-HERE.md +73 -0
- package/template_docs/docs/funnelsgrove/contracts/analytics-events.md +59 -0
- package/template_docs/docs/funnelsgrove/contracts/content-answers.md +44 -0
- package/template_docs/docs/funnelsgrove/contracts/flow-routing.md +41 -0
- package/template_docs/docs/funnelsgrove/contracts/payments.md +42 -0
- package/template_docs/docs/funnelsgrove/contracts/step-metadata.md +57 -0
- package/template_docs/docs/funnelsgrove/migrations/step-contract-v3.md +39 -0
- package/template_docs/docs/funnelsgrove/qa/analytics.md +43 -0
- package/template_docs/docs/funnelsgrove/qa/local.md +42 -0
- package/template_docs/docs/funnelsgrove/qa/paywall-checkout.md +55 -0
- package/template_docs/docs/funnelsgrove/qa/publish.md +32 -0
- package/template_docs/docs/funnelsgrove/recipes/add-experiment.md +34 -0
- package/template_docs/docs/funnelsgrove/recipes/add-step.md +33 -0
- package/template_docs/docs/funnelsgrove/recipes/edit-step.md +31 -0
- package/template_docs/docs/funnelsgrove/steps/INDEX.md +26 -0
- package/template_docs/docs/funnelsgrove/steps/cancellation_offer.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/checkout.md +120 -0
- package/template_docs/docs/funnelsgrove/steps/form_input.md +115 -0
- package/template_docs/docs/funnelsgrove/steps/intro_hero.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/multi_select_choice.md +123 -0
- package/template_docs/docs/funnelsgrove/steps/paywall_offer.md +115 -0
- package/template_docs/docs/funnelsgrove/steps/progress_interstitial.md +111 -0
- package/template_docs/docs/funnelsgrove/steps/purchase_completed.md +117 -0
- package/template_docs/docs/funnelsgrove/steps/single_step_choice.md +122 -0
- package/template_docs/docs/funnelsgrove/steps/single_step_choice_emoji.md +122 -0
- package/template_docs/docs/funnelsgrove/steps/social_proof.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/subscription_handoff.md +113 -0
- package/template_docs/docs/funnelsgrove/steps/subscription_management.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/summary_confirmation.md +110 -0
- package/template_docs/docs/funnelsgrove/steps/upsell_offer.md +112 -0
- package/template_docs/docs/funnelsgrove/steps/value_prop_story.md +110 -0
- package/template_docs/funnel-docs.config.json +43 -0
- package/template_scaffold/.env.example +41 -0
- package/template_scaffold/.funnelsgrove-contract-tools.json +19 -0
- package/template_scaffold/.funnelsgrove-docs.json +144 -0
- package/template_scaffold/.funnelsgrove-scaffold.json +1078 -0
- package/template_scaffold/AGENTS.md +42 -0
- package/template_scaffold/CLAUDE.md +1 -0
- package/template_scaffold/PLAN.md +81 -0
- package/template_scaffold/PRODUCT_SENSE.md +28 -0
- package/template_scaffold/context/build-context.md +34 -0
- package/template_scaffold/docs/AGENT_FUNNEL_IMPLEMENTATION_SPEC.md +5 -0
- package/template_scaffold/docs/ARCHITECTURE.md +5 -0
- package/template_scaffold/docs/FLOW_CONFIG_AND_ROUTING.md +5 -0
- package/template_scaffold/docs/PAYWALL_AND_PAYMENTS.md +5 -0
- package/template_scaffold/docs/README.md +5 -0
- package/template_scaffold/docs/funnelsgrove/START-HERE.md +73 -0
- package/template_scaffold/docs/funnelsgrove/contracts/analytics-events.md +59 -0
- package/template_scaffold/docs/funnelsgrove/contracts/content-answers.md +44 -0
- package/template_scaffold/docs/funnelsgrove/contracts/flow-routing.md +41 -0
- package/template_scaffold/docs/funnelsgrove/contracts/payments.md +42 -0
- package/template_scaffold/docs/funnelsgrove/contracts/step-metadata.md +57 -0
- package/template_scaffold/docs/funnelsgrove/migrations/step-contract-v3.md +39 -0
- package/template_scaffold/docs/funnelsgrove/qa/analytics.md +43 -0
- package/template_scaffold/docs/funnelsgrove/qa/local.md +42 -0
- package/template_scaffold/docs/funnelsgrove/qa/paywall-checkout.md +55 -0
- package/template_scaffold/docs/funnelsgrove/qa/publish.md +32 -0
- package/template_scaffold/docs/funnelsgrove/recipes/add-experiment.md +34 -0
- package/template_scaffold/docs/funnelsgrove/recipes/add-step.md +33 -0
- package/template_scaffold/docs/funnelsgrove/recipes/edit-step.md +31 -0
- package/template_scaffold/docs/funnelsgrove/steps/INDEX.md +26 -0
- package/template_scaffold/docs/funnelsgrove/steps/cancellation_offer.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/checkout.md +120 -0
- package/template_scaffold/docs/funnelsgrove/steps/form_input.md +115 -0
- package/template_scaffold/docs/funnelsgrove/steps/intro_hero.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/multi_select_choice.md +123 -0
- package/template_scaffold/docs/funnelsgrove/steps/paywall_offer.md +115 -0
- package/template_scaffold/docs/funnelsgrove/steps/progress_interstitial.md +111 -0
- package/template_scaffold/docs/funnelsgrove/steps/purchase_completed.md +117 -0
- package/template_scaffold/docs/funnelsgrove/steps/single_step_choice.md +122 -0
- package/template_scaffold/docs/funnelsgrove/steps/single_step_choice_emoji.md +122 -0
- package/template_scaffold/docs/funnelsgrove/steps/social_proof.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/subscription_handoff.md +113 -0
- package/template_scaffold/docs/funnelsgrove/steps/subscription_management.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/summary_confirmation.md +110 -0
- package/template_scaffold/docs/funnelsgrove/steps/upsell_offer.md +112 -0
- package/template_scaffold/docs/funnelsgrove/steps/value_prop_story.md +110 -0
- package/template_scaffold/docs/references/funnel-sdk-user-answers.md +5 -0
- package/template_scaffold/eslint.config.mjs +16 -0
- package/template_scaffold/funnel-agent-docs.test.ts +699 -0
- package/template_scaffold/funnel-docs.config.json +43 -0
- package/template_scaffold/funnel.config.json +5 -0
- package/template_scaffold/gitignore.template +5 -0
- package/template_scaffold/next-env.d.ts +6 -0
- package/template_scaffold/next.config.ts +53 -0
- package/template_scaffold/package-lock.json +7737 -0
- package/template_scaffold/package.json +37 -0
- package/template_scaffold/package.test.ts +23 -0
- package/template_scaffold/public/claimbee/bee.png +0 -0
- package/template_scaffold/public/claimbee/device-iphone.png +0 -0
- package/template_scaffold/public/claimbee/device-macbook.png +0 -0
- package/template_scaffold/public/claimbee/device-none.png +0 -0
- package/template_scaffold/public/claimbee/device-watch.png +0 -0
- package/template_scaffold/public/claimbee/glow.svg +3 -0
- package/template_scaffold/public/claimbee/steps-sprite-alt.png +0 -0
- package/template_scaffold/public/claimbee/steps-sprite-default.png +0 -0
- package/template_scaffold/public/claimbee/testimonial-avatar.png +0 -0
- package/template_scaffold/public/claimbee/testimonial-star.svg +3 -0
- package/template_scaffold/public/paywall/ai-claim-assistant.png +0 -0
- package/template_scaffold/public/paywall/claim-history.png +0 -0
- package/template_scaffold/public/paywall/clear-progress.png +0 -0
- package/template_scaffold/public/paywall/hero.png +0 -0
- package/template_scaffold/public/paywall/money-alerts.png +0 -0
- package/template_scaffold/public/paywall/money-back-badge.png +0 -0
- package/template_scaffold/public/paywall/paywall-image.png +0 -0
- package/template_scaffold/public/paywall/r1.png +0 -0
- package/template_scaffold/public/paywall/r2.png +0 -0
- package/template_scaffold/public/paywall/r3.png +0 -0
- package/template_scaffold/public/paywall/r4.png +0 -0
- package/template_scaffold/public/paywall/r5.png +0 -0
- package/template_scaffold/public/paywall/r6.png +0 -0
- package/template_scaffold/public/paywall/special-offer-gift.png +0 -0
- package/template_scaffold/public/please/bee.png +0 -0
- package/template_scaffold/public/please/device-iphone.png +0 -0
- package/template_scaffold/public/please/device-macbook.png +0 -0
- package/template_scaffold/public/please/device-none.png +0 -0
- package/template_scaffold/public/please/device-watch.png +0 -0
- package/template_scaffold/public/please/glow.svg +3 -0
- package/template_scaffold/public/please/steps-sprite-alt.png +0 -0
- package/template_scaffold/public/please/steps-sprite-default.png +0 -0
- package/template_scaffold/public/please/testimonial-avatar.png +0 -0
- package/template_scaffold/public/please/testimonial-star.svg +3 -0
- package/template_scaffold/public/upsell/upgrade-hero.png +0 -0
- package/template_scaffold/src/app/[stepId]/page.test.tsx +59 -0
- package/template_scaffold/src/app/[stepId]/page.tsx +62 -0
- package/template_scaffold/src/app/globals.css +49 -0
- package/template_scaffold/src/app/layout.test.ts +26 -0
- package/template_scaffold/src/app/layout.tsx +61 -0
- package/template_scaffold/src/app/page.tsx +8 -0
- package/template_scaffold/src/app/sdk/page.tsx +673 -0
- package/template_scaffold/src/app/subscription-dashboard/page.tsx +274 -0
- package/template_scaffold/src/assets/claimbee/bee.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-iphone.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-macbook.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-none.png +0 -0
- package/template_scaffold/src/assets/claimbee/device-watch.png +0 -0
- package/template_scaffold/src/assets/claimbee/glow.svg +3 -0
- package/template_scaffold/src/assets/claimbee/steps-sprite-alt.png +0 -0
- package/template_scaffold/src/assets/claimbee/steps-sprite-default.png +0 -0
- package/template_scaffold/src/assets/claimbee/testimonial-avatar.png +0 -0
- package/template_scaffold/src/assets/claimbee/testimonial-star.svg +3 -0
- package/template_scaffold/src/components/FunnelEditorPanel.tsx +194 -0
- package/template_scaffold/src/components/FunnelFlow.test.tsx +17 -0
- package/template_scaffold/src/components/FunnelFlow.tsx +114 -0
- package/template_scaffold/src/components/FunnelStepImage.test.ts +15 -0
- package/template_scaffold/src/components/FunnelStepImage.tsx +28 -0
- package/template_scaffold/src/components/step/FunnelStepHeader.tsx +35 -0
- package/template_scaffold/src/config/billing.plans.test.ts +143 -0
- package/template_scaffold/src/config/billing.plans.ts +69 -0
- package/template_scaffold/src/config/billing.test.plans.ts +32 -0
- package/template_scaffold/src/config/experiments.generated.ts +4 -0
- package/template_scaffold/src/config/experiments.test.ts +12 -0
- package/template_scaffold/src/config/experiments.ts +9 -0
- package/template_scaffold/src/config/funnel.config.ts +12 -0
- package/template_scaffold/src/config/funnel.manifest.test.ts +166 -0
- package/template_scaffold/src/config/funnel.manifest.ts +139 -0
- package/template_scaffold/src/config/offer-sets.generated.ts +4 -0
- package/template_scaffold/src/contract/funnel-project.validation.test.ts +80 -0
- package/template_scaffold/src/contract/funnel-project.validation.ts +44 -0
- package/template_scaffold/src/contract/funnel-validator.vite.config.ts +11 -0
- package/template_scaffold/src/contract/golden/cancellation_offer.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/checkout.fixture.ts +37 -0
- package/template_scaffold/src/contract/golden/form_input.fixture.ts +28 -0
- package/template_scaffold/src/contract/golden/golden-fixtures.test.ts +190 -0
- package/template_scaffold/src/contract/golden/intro_hero.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/multi_select_choice.fixture.ts +37 -0
- package/template_scaffold/src/contract/golden/paywall_offer.fixture.ts +30 -0
- package/template_scaffold/src/contract/golden/progress_interstitial.fixture.ts +28 -0
- package/template_scaffold/src/contract/golden/purchase_completed.fixture.ts +33 -0
- package/template_scaffold/src/contract/golden/single_step_choice.fixture.ts +36 -0
- package/template_scaffold/src/contract/golden/single_step_choice_emoji.fixture.ts +36 -0
- package/template_scaffold/src/contract/golden/social_proof.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/subscription_handoff.fixture.ts +30 -0
- package/template_scaffold/src/contract/golden/subscription_management.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/summary_confirmation.fixture.ts +27 -0
- package/template_scaffold/src/contract/golden/upsell_offer.fixture.ts +29 -0
- package/template_scaffold/src/contract/golden/value_prop_story.fixture.ts +27 -0
- package/template_scaffold/src/contract/validate-funnel.cli.test.ts +180 -0
- package/template_scaffold/src/contract/validate-funnel.cli.ts +199 -0
- package/template_scaffold/src/runtime/checkout-runtime-config.test.ts +60 -0
- package/template_scaffold/src/runtime/checkout-runtime-config.ts +26 -0
- package/template_scaffold/src/runtime/funnel-runtime.test.ts +25 -0
- package/template_scaffold/src/runtime/funnel-runtime.ts +118 -0
- package/template_scaffold/src/runtime/step-content-context.test.ts +38 -0
- package/template_scaffold/src/runtime/step-content-context.ts +65 -0
- package/template_scaffold/src/runtime/step-registry.ts +66 -0
- package/template_scaffold/src/runtime/step-variable-values.ts +31 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.integration.test.ts +203 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.test.ts +76 -0
- package/template_scaffold/src/runtime/use-funnel-flow-controller.ts +53 -0
- package/template_scaffold/src/steps/content/email-capture.content.ts +29 -0
- package/template_scaffold/src/steps/content/manage-subscription.content.ts +62 -0
- package/template_scaffold/src/steps/content/paywall.content.ts +191 -0
- package/template_scaffold/src/steps/content/step-01.content.ts +23 -0
- package/template_scaffold/src/steps/content/step-02.content.ts +77 -0
- package/template_scaffold/src/steps/content/step-03.content.ts +40 -0
- package/template_scaffold/src/steps/content/step-04.content.ts +49 -0
- package/template_scaffold/src/steps/content/step-32-paywall.content.ts +352 -0
- package/template_scaffold/src/steps/content/subscription-started.content.ts +68 -0
- package/template_scaffold/src/steps/editor/email-capture.editor.ts +58 -0
- package/template_scaffold/src/steps/editor/manage-subscription.editor.ts +179 -0
- package/template_scaffold/src/steps/editor/paywall.editor.ts +232 -0
- package/template_scaffold/src/steps/editor/step-01.editor.ts +22 -0
- package/template_scaffold/src/steps/editor/step-02.editor.ts +41 -0
- package/template_scaffold/src/steps/editor/step-03.editor.ts +58 -0
- package/template_scaffold/src/steps/editor/step-04.editor.ts +98 -0
- package/template_scaffold/src/steps/editor/step-32-paywall.editor.ts +478 -0
- package/template_scaffold/src/steps/editor/subscription-started.editor.ts +131 -0
- package/template_scaffold/src/steps/index.ts +25 -0
- package/template_scaffold/src/steps/paywall-checkout-options.test.ts +104 -0
- package/template_scaffold/src/steps/paywall-checkout-options.ts +130 -0
- package/template_scaffold/src/steps/pricing/paywall-b.pricing.ts +12 -0
- package/template_scaffold/src/steps/pricing/paywall.pricing.ts +12 -0
- package/template_scaffold/src/steps/pricing/shared-plan-order.ts +17 -0
- package/template_scaffold/src/steps/pricing/upsell-form.pricing.ts +16 -0
- package/template_scaffold/src/steps/shared-header-contract.test.ts +27 -0
- package/template_scaffold/src/steps/step-01.test.ts +38 -0
- package/template_scaffold/src/steps/step-01.tsx +108 -0
- package/template_scaffold/src/steps/step-02.test.ts +43 -0
- package/template_scaffold/src/steps/step-02.tsx +140 -0
- package/template_scaffold/src/steps/step-03.test.ts +15 -0
- package/template_scaffold/src/steps/step-03.tsx +262 -0
- package/template_scaffold/src/steps/step-04.test.ts +32 -0
- package/template_scaffold/src/steps/step-04.tsx +673 -0
- package/template_scaffold/src/steps/step-31-email-capture.test.ts +22 -0
- package/template_scaffold/src/steps/step-31-email-capture.tsx +195 -0
- package/template_scaffold/src/steps/step-32-paywall.test.ts +770 -0
- package/template_scaffold/src/steps/step-32-paywall.tsx +2253 -0
- package/template_scaffold/src/steps/step-32b-paywall-b.tsx +35 -0
- package/template_scaffold/src/steps/step-33-subscription-started.test.ts +26 -0
- package/template_scaffold/src/steps/step-33-subscription-started.tsx +86 -0
- package/template_scaffold/src/steps/step-34-upsell-form.test.ts +27 -0
- package/template_scaffold/src/steps/step-35-manage-subscription.tsx +46 -0
- package/template_scaffold/src/steps/step-content.registry.ts +45 -0
- package/template_scaffold/src/steps/step-image-migration.test.ts +20 -0
- package/template_scaffold/src/steps/styles/index.css +2 -0
- package/template_scaffold/src/steps/styles/shared/final-flow-shared.css +55 -0
- package/template_scaffold/src/steps/styles/shared/funnel-base.css +543 -0
- package/template_scaffold/src/steps/styles/shared/info-shared.css +139 -0
- package/template_scaffold/src/steps/styles/shared/progress-shared.css +117 -0
- package/template_scaffold/src/steps/styles/shared/question-shared.css +76 -0
- package/template_scaffold/src/steps/styles/shared/responsive-container.css +176 -0
- package/template_scaffold/src/steps/types.ts +7 -0
- package/template_scaffold/src/steps/use-claimbee-step-content.ts +15 -0
- package/template_scaffold/src/theme/theme.ts +81 -0
- package/template_scaffold/tsconfig.json +38 -0
- package/template_scaffold/vitest.config.ts +32 -0
- package/template_validation/.funnelsgrove-contract-tools.json +19 -0
- package/template_validation/src/contract/funnel-project.validation.ts +44 -0
- package/template_validation/src/contract/funnel-validator.vite.config.ts +11 -0
- package/template_validation/src/contract/validate-funnel.cli.ts +199 -0
- package/template_docs/docs/ab-experiments.md +0 -55
- package/template_docs/docs/analytics.md +0 -65
- package/template_docs/docs/editing-flow.md +0 -125
- package/template_docs/docs/editing-step.md +0 -125
- package/template_docs/docs/editor-and-content.md +0 -58
- package/template_docs/docs/funnel-runtime-architecture.md +0 -125
- package/template_docs/docs/meta-pixel-conversions-api.md +0 -50
- package/template_docs/docs/payment-plans-and-discounts.md +0 -106
- package/template_docs/docs/publishing-and-versioning.md +0 -117
- package/template_docs/docs/qa-checklist.md +0 -80
- package/template_docs/docs/sdk-api-endpoints.md +0 -78
- package/template_docs/docs/step-ui-guidelines.md +0 -110
- package/template_docs/docs/theme.md +0 -35
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FunnelValidationExitCode = 0 | 1 | 2;
|
|
2
|
+
export type FunnelValidationDiagnostic = {
|
|
3
|
+
code: string;
|
|
4
|
+
severity: 'error';
|
|
5
|
+
file: string | null;
|
|
6
|
+
stepId: string | null;
|
|
7
|
+
expected?: unknown;
|
|
8
|
+
received?: unknown;
|
|
9
|
+
reason: string;
|
|
10
|
+
guide: string;
|
|
11
|
+
repair: string;
|
|
12
|
+
};
|
|
13
|
+
export type FunnelValidationResult = {
|
|
14
|
+
schemaVersion: 1;
|
|
15
|
+
contractVersion: number;
|
|
16
|
+
valid: boolean;
|
|
17
|
+
diagnostics: readonly FunnelValidationDiagnostic[];
|
|
18
|
+
exitCode: FunnelValidationExitCode;
|
|
19
|
+
};
|
|
20
|
+
export type ValidationOutputInput = {
|
|
21
|
+
command: string;
|
|
22
|
+
result: FunnelValidationResult;
|
|
23
|
+
};
|
|
24
|
+
export type FunnelValidationOutput = {
|
|
25
|
+
schemaVersion: 1;
|
|
26
|
+
command: string;
|
|
27
|
+
contractVersion: number;
|
|
28
|
+
valid: boolean;
|
|
29
|
+
diagnostics: readonly FunnelValidationDiagnostic[];
|
|
30
|
+
exitCode: FunnelValidationExitCode;
|
|
31
|
+
};
|
|
32
|
+
export type ValidationDiagnosticInput = Omit<FunnelValidationDiagnostic, 'severity' | 'file' | 'stepId' | 'expected' | 'received'> & {
|
|
33
|
+
file?: string | null;
|
|
34
|
+
stepId?: string | null;
|
|
35
|
+
expected: unknown;
|
|
36
|
+
received: unknown;
|
|
37
|
+
};
|
|
38
|
+
export declare const createValidationDiagnostic: (input: ValidationDiagnosticInput) => FunnelValidationDiagnostic;
|
|
39
|
+
export declare const isValidationDiagnostic: (value: unknown) => value is FunnelValidationDiagnostic;
|
|
40
|
+
export declare const buildValidationOutput: (input: ValidationOutputInput) => FunnelValidationOutput;
|
|
41
|
+
export declare const renderValidationJson: (input: ValidationOutputInput) => string;
|
|
42
|
+
export declare const renderValidationHuman: (input: ValidationOutputInput) => string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const DIAGNOSTIC_KEYS = [
|
|
2
|
+
'code',
|
|
3
|
+
'severity',
|
|
4
|
+
'file',
|
|
5
|
+
'stepId',
|
|
6
|
+
'expected',
|
|
7
|
+
'received',
|
|
8
|
+
'reason',
|
|
9
|
+
'guide',
|
|
10
|
+
'repair',
|
|
11
|
+
];
|
|
12
|
+
const REQUIRED_DIAGNOSTIC_KEYS = [
|
|
13
|
+
'code',
|
|
14
|
+
'severity',
|
|
15
|
+
'file',
|
|
16
|
+
'stepId',
|
|
17
|
+
'reason',
|
|
18
|
+
'guide',
|
|
19
|
+
'repair',
|
|
20
|
+
];
|
|
21
|
+
export const createValidationDiagnostic = (input) => ({
|
|
22
|
+
code: input.code,
|
|
23
|
+
severity: 'error',
|
|
24
|
+
file: input.file ?? null,
|
|
25
|
+
stepId: input.stepId ?? null,
|
|
26
|
+
expected: input.expected,
|
|
27
|
+
received: input.received,
|
|
28
|
+
reason: input.reason,
|
|
29
|
+
guide: input.guide,
|
|
30
|
+
repair: input.repair,
|
|
31
|
+
});
|
|
32
|
+
export const isValidationDiagnostic = (value) => {
|
|
33
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
34
|
+
return false;
|
|
35
|
+
const diagnostic = value;
|
|
36
|
+
if (Object.keys(diagnostic).some((key) => !DIAGNOSTIC_KEYS.includes(key))
|
|
37
|
+
|| REQUIRED_DIAGNOSTIC_KEYS.some((key) => !(key in diagnostic)))
|
|
38
|
+
return false;
|
|
39
|
+
return typeof diagnostic.code === 'string'
|
|
40
|
+
&& /^FG-[A-Z]+-\d{3}$/.test(diagnostic.code)
|
|
41
|
+
&& diagnostic.severity === 'error'
|
|
42
|
+
&& (diagnostic.file === null || typeof diagnostic.file === 'string')
|
|
43
|
+
&& (diagnostic.stepId === null || typeof diagnostic.stepId === 'string')
|
|
44
|
+
&& typeof diagnostic.reason === 'string'
|
|
45
|
+
&& typeof diagnostic.guide === 'string'
|
|
46
|
+
&& typeof diagnostic.repair === 'string';
|
|
47
|
+
};
|
|
48
|
+
export const buildValidationOutput = (input) => ({
|
|
49
|
+
schemaVersion: 1,
|
|
50
|
+
command: input.command,
|
|
51
|
+
contractVersion: input.result.contractVersion,
|
|
52
|
+
valid: input.result.valid,
|
|
53
|
+
diagnostics: input.result.diagnostics,
|
|
54
|
+
exitCode: input.result.exitCode,
|
|
55
|
+
});
|
|
56
|
+
export const renderValidationJson = (input) => `${JSON.stringify(buildValidationOutput(input), null, 2)}\n`;
|
|
57
|
+
const renderValue = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.stringify(value) ?? String(value);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return '[unserializable]';
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const renderDiagnostic = (diagnostic) => [
|
|
66
|
+
`[${diagnostic.code}] ${diagnostic.reason}`,
|
|
67
|
+
...(diagnostic.file === null ? [] : [` File: ${diagnostic.file}`]),
|
|
68
|
+
...(diagnostic.stepId === null ? [] : [` Step: ${diagnostic.stepId}`]),
|
|
69
|
+
` Expected: ${renderValue(diagnostic.expected)}`,
|
|
70
|
+
` Received: ${renderValue(diagnostic.received)}`,
|
|
71
|
+
` Repair: ${diagnostic.repair}`,
|
|
72
|
+
` Guide: ${diagnostic.guide}`,
|
|
73
|
+
].join('\n');
|
|
74
|
+
export const renderValidationHuman = (input) => {
|
|
75
|
+
const summary = input.result.exitCode === 0
|
|
76
|
+
? 'valid'
|
|
77
|
+
: input.result.exitCode === 1 ? 'blocked' : 'error';
|
|
78
|
+
const lines = [
|
|
79
|
+
`Funnel validation: ${summary} (contract ${input.result.contractVersion})`,
|
|
80
|
+
...input.result.diagnostics.map(renderDiagnostic),
|
|
81
|
+
];
|
|
82
|
+
return `${lines.join('\n')}\n`;
|
|
83
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DocsDiagnostic, DocsFileStatus, DocsStatus } from './docsTransaction.js';
|
|
2
|
+
export type DocsExitCode = 0 | 1 | 2 | 3 | 4;
|
|
3
|
+
export type DocsHumanMode = 'status' | 'diff';
|
|
4
|
+
export type DocsOutputInput = {
|
|
5
|
+
command: string;
|
|
6
|
+
status: DocsStatus;
|
|
7
|
+
exitCode: DocsExitCode;
|
|
8
|
+
};
|
|
9
|
+
export type DocsOutput = {
|
|
10
|
+
schemaVersion: 1;
|
|
11
|
+
command: string;
|
|
12
|
+
status: DocsStatus;
|
|
13
|
+
actions: DocsFileStatus[];
|
|
14
|
+
diagnostics: DocsDiagnostic[];
|
|
15
|
+
exitCode: DocsExitCode;
|
|
16
|
+
};
|
|
17
|
+
export declare const buildDocsOutput: (input: DocsOutputInput) => DocsOutput;
|
|
18
|
+
export declare const renderDocsJson: (input: DocsOutputInput) => string;
|
|
19
|
+
export declare const renderDocsHuman: (input: DocsOutputInput, mode?: DocsHumanMode) => string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const compareText = (left, right) => {
|
|
2
|
+
const normalizedLeft = left ?? '';
|
|
3
|
+
const normalizedRight = right ?? '';
|
|
4
|
+
return normalizedLeft < normalizedRight ? -1 : normalizedLeft > normalizedRight ? 1 : 0;
|
|
5
|
+
};
|
|
6
|
+
const compareFiles = (left, right) => compareText(left.path, right.path)
|
|
7
|
+
|| compareText(left.action, right.action)
|
|
8
|
+
|| compareText(left.state, right.state)
|
|
9
|
+
|| compareText(left.currentHash, right.currentHash)
|
|
10
|
+
|| compareText(left.bundledHash, right.bundledHash)
|
|
11
|
+
|| compareText(left.priorHash, right.priorHash);
|
|
12
|
+
const compareDiagnostics = (left, right) => compareText(left.code, right.code)
|
|
13
|
+
|| compareText(left.path, right.path)
|
|
14
|
+
|| compareText(left.message, right.message);
|
|
15
|
+
const normalizeFile = (file) => ({
|
|
16
|
+
path: file.path,
|
|
17
|
+
state: file.state,
|
|
18
|
+
action: file.action,
|
|
19
|
+
...(file.currentHash === undefined ? {} : { currentHash: file.currentHash }),
|
|
20
|
+
...(file.bundledHash === undefined ? {} : { bundledHash: file.bundledHash }),
|
|
21
|
+
...(file.priorHash === undefined ? {} : { priorHash: file.priorHash }),
|
|
22
|
+
});
|
|
23
|
+
const normalizeDiagnostic = (diagnostic) => ({
|
|
24
|
+
code: diagnostic.code,
|
|
25
|
+
...(diagnostic.path === undefined ? {} : { path: diagnostic.path }),
|
|
26
|
+
message: diagnostic.message,
|
|
27
|
+
});
|
|
28
|
+
const normalizeStatus = (status) => ({
|
|
29
|
+
bundleVersion: status.bundleVersion,
|
|
30
|
+
contractVersion: status.contractVersion,
|
|
31
|
+
clean: status.clean,
|
|
32
|
+
files: status.files.map(normalizeFile).sort(compareFiles),
|
|
33
|
+
diagnostics: status.diagnostics.map(normalizeDiagnostic).sort(compareDiagnostics),
|
|
34
|
+
});
|
|
35
|
+
export const buildDocsOutput = (input) => {
|
|
36
|
+
const status = normalizeStatus(input.status);
|
|
37
|
+
return {
|
|
38
|
+
schemaVersion: 1,
|
|
39
|
+
command: input.command,
|
|
40
|
+
status,
|
|
41
|
+
actions: status.files.filter((file) => file.action !== 'none'),
|
|
42
|
+
diagnostics: status.diagnostics,
|
|
43
|
+
exitCode: input.exitCode,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const renderDocsJson = (input) => `${JSON.stringify(buildDocsOutput(input), null, 2)}\n`;
|
|
47
|
+
const renderDiagnostic = (diagnostic) => [
|
|
48
|
+
diagnostic.code,
|
|
49
|
+
diagnostic.path,
|
|
50
|
+
diagnostic.message,
|
|
51
|
+
].filter((part) => part !== undefined).join('\t');
|
|
52
|
+
const renderSummary = (label, status) => `${label}: ${status.clean ? 'clean' : 'drift'} (bundle ${status.bundleVersion}, contract ${status.contractVersion})`;
|
|
53
|
+
const hashBefore = (file) => file.currentHash ?? file.priorHash ?? '-';
|
|
54
|
+
const hashAfter = (file) => file.action === 'retire-known' || file.action === 'retire-owned'
|
|
55
|
+
? '-'
|
|
56
|
+
: file.bundledHash ?? '-';
|
|
57
|
+
export const renderDocsHuman = (input, mode = 'status') => {
|
|
58
|
+
const output = buildDocsOutput(input);
|
|
59
|
+
const files = mode === 'diff' ? output.actions : output.status.files;
|
|
60
|
+
const lines = [
|
|
61
|
+
renderSummary(mode === 'diff' ? 'Funnel docs diff' : 'Funnel docs', output.status),
|
|
62
|
+
...files.map((file) => mode === 'diff'
|
|
63
|
+
? [
|
|
64
|
+
file.action,
|
|
65
|
+
file.path,
|
|
66
|
+
file.state,
|
|
67
|
+
`${hashBefore(file)} -> ${hashAfter(file)}`,
|
|
68
|
+
].join('\t')
|
|
69
|
+
: [file.action, file.path, file.state].join('\t')),
|
|
70
|
+
...output.diagnostics.map(renderDiagnostic),
|
|
71
|
+
];
|
|
72
|
+
return `${lines.join('\n')}\n`;
|
|
73
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare const DOCS_MANIFEST_FILE = ".funnelsgrove-docs.json";
|
|
2
|
+
export type FunnelDocsManifest = {
|
|
3
|
+
schemaVersion: 1;
|
|
4
|
+
bundleVersion: string;
|
|
5
|
+
stepContractVersion: number;
|
|
6
|
+
contractHash: string;
|
|
7
|
+
managedFiles: Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
sha256: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export type LegacyDocsCatalogEntry = {
|
|
13
|
+
version: string;
|
|
14
|
+
path: string;
|
|
15
|
+
sha256: string;
|
|
16
|
+
};
|
|
17
|
+
export type DocsFileState = 'current' | 'missing' | 'changed' | 'known-legacy-current-path' | 'known-legacy-obsolete' | 'owned-obsolete' | 'conflict';
|
|
18
|
+
export type DocsAction = 'none' | 'install' | 'adopt' | 'replace-known' | 'retire-known' | 'retire-owned' | 'conflict';
|
|
19
|
+
export type DocsDiagnostic = {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
};
|
|
24
|
+
export type Diagnostic = DocsDiagnostic;
|
|
25
|
+
export type DocsFileStatus = {
|
|
26
|
+
path: string;
|
|
27
|
+
state: DocsFileState;
|
|
28
|
+
action: DocsAction;
|
|
29
|
+
currentHash?: string;
|
|
30
|
+
bundledHash?: string;
|
|
31
|
+
priorHash?: string;
|
|
32
|
+
};
|
|
33
|
+
export type DocsStatus = {
|
|
34
|
+
bundleVersion: string;
|
|
35
|
+
contractVersion: number;
|
|
36
|
+
clean: boolean;
|
|
37
|
+
files: DocsFileStatus[];
|
|
38
|
+
diagnostics: DocsDiagnostic[];
|
|
39
|
+
};
|
|
40
|
+
type BundledFile = {
|
|
41
|
+
bytes: Buffer;
|
|
42
|
+
mode: number;
|
|
43
|
+
path: string;
|
|
44
|
+
sha256: string;
|
|
45
|
+
};
|
|
46
|
+
export type BundledDocs = {
|
|
47
|
+
root: string;
|
|
48
|
+
manifest: FunnelDocsManifest;
|
|
49
|
+
manifestBytes: Buffer;
|
|
50
|
+
files: Map<string, BundledFile>;
|
|
51
|
+
};
|
|
52
|
+
type InspectedFile = Omit<DocsFileStatus, 'action'>;
|
|
53
|
+
export type DocsInspection = {
|
|
54
|
+
bundle: BundledDocs;
|
|
55
|
+
targetRoot: string;
|
|
56
|
+
priorManifest: FunnelDocsManifest | null;
|
|
57
|
+
files: InspectedFile[];
|
|
58
|
+
};
|
|
59
|
+
export type DocsFaultPoint = {
|
|
60
|
+
operation: 'stage' | 'backup' | 'apply' | 'manifest' | 'residue';
|
|
61
|
+
timing: 'before' | 'after';
|
|
62
|
+
path: string;
|
|
63
|
+
};
|
|
64
|
+
export type DocsTransactionOptions = {
|
|
65
|
+
transactionId?: string;
|
|
66
|
+
faultInjector?: (point: DocsFaultPoint) => void | Promise<void>;
|
|
67
|
+
legacyCatalog?: readonly LegacyDocsCatalogEntry[];
|
|
68
|
+
};
|
|
69
|
+
export declare class DocsTransactionError extends Error {
|
|
70
|
+
readonly code: string;
|
|
71
|
+
constructor(code: string, message: string);
|
|
72
|
+
}
|
|
73
|
+
export declare const loadBundledDocs: (sourceDir: string) => Promise<BundledDocs>;
|
|
74
|
+
export declare const inspectTemplateDocs: (bundle: BundledDocs, targetDir: string, options?: {
|
|
75
|
+
legacyCatalog?: readonly LegacyDocsCatalogEntry[];
|
|
76
|
+
}) => Promise<DocsInspection>;
|
|
77
|
+
export declare const planTemplateDocsUpdate: (inspection: DocsInspection) => DocsStatus;
|
|
78
|
+
export declare const applyTemplateDocsUpdate: (bundle: BundledDocs, targetDir: string, status: DocsStatus, options?: DocsTransactionOptions) => Promise<void>;
|
|
79
|
+
export declare const recoverTemplateDocs: (targetDir: string, options?: Pick<DocsTransactionOptions, "faultInjector">) => Promise<"none" | "completed" | "restored">;
|
|
80
|
+
export declare const resolveTemplateDocsConflict: (bundle: BundledDocs, targetDir: string, relativePath: string, options?: DocsTransactionOptions) => Promise<void>;
|
|
81
|
+
export {};
|