@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.9 → 0.4.0-alpha.94

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.
@@ -0,0 +1,99 @@
1
+ // packages/launch-stackwright-pro/templates/pro/scripts/pro-content-plugin.js
2
+ //
3
+ // Pro content type plugin for @stackwright/build-scripts.
4
+ //
5
+ // CONFIRMED CASE B (@stackwright/build-scripts@0.5.0-alpha.0 / types@1.2.0-alpha.0):
6
+ // The currently shipped version of build-scripts does NOT read
7
+ // `contentItemSchemas` or `knownContentTypeKeys` from plugin objects.
8
+ // Those fields first appear in @stackwright/types@1.4.0+ and will be
9
+ // consumed by build-scripts@0.7.0 when that release ships.
10
+ //
11
+ // CURRENT BEHAVIOUR (pre-0.7.0):
12
+ // `unknownContentTypes: 'warn'` in prebuild.js already prevents hard failures
13
+ // for unrecognised content types. The `beforeBuild` stub below ensures this
14
+ // plugin is a syntactically valid, callable plugin (not silently ignored by
15
+ // the plugin runner) even though there is no side-effect to execute yet.
16
+ //
17
+ // TODO(@stackwright/build-scripts@0.7.0): Once 0.7.0 is the resolved floor,
18
+ // remove the `beforeBuild` stub — `contentItemSchemas` and
19
+ // `knownContentTypeKeys` will be consumed natively by the runtime and the
20
+ // plugin will suppress "unknown content type" warnings automatically.
21
+
22
+ 'use strict';
23
+
24
+ const { z } = require('zod');
25
+
26
+ const PRO_CONTENT_TYPE_KEYS = [
27
+ // @stackwright-pro/display-components
28
+ 'metric_card',
29
+ 'status_badge',
30
+ 'stat_bar',
31
+ 'sparkline',
32
+ 'activity_feed',
33
+ 'dashboard_grid',
34
+ 'data_table',
35
+ 'json_viewer',
36
+ 'action_bar',
37
+ 'section',
38
+ 'collection_listing',
39
+ // @stackwright-pro/pulse
40
+ 'pulse_provider',
41
+ 'metric_card_pulse',
42
+ 'data_table_pulse',
43
+ 'status_badge_pulse',
44
+ 'stats_grid',
45
+ 'alert_banner',
46
+ // @stackwright-pro/workflow-components
47
+ 'workflow_mount',
48
+ // @stackwright-pro/display-components — navigation
49
+ 'breadcrumb',
50
+ 'page_header_bar',
51
+ ];
52
+
53
+ // OSS content types that Pro otters augment with extra fields (e.g. `theme:`,
54
+ // `auth:`). The strict OSS Zod schemas reject unknown properties, so we
55
+ // register passthrough variants here. When build-scripts@0.7.0+ evaluates
56
+ // the union [contentItemSchema, ...extraSchemas], the strict OSS schema
57
+ // fails on the extra field and falls through to our passthrough version.
58
+ const OSS_TYPES_WITH_PRO_EXTENSIONS = [
59
+ 'text_block',
60
+ 'alert',
61
+ 'grid',
62
+ 'main',
63
+ 'collection_list',
64
+ ];
65
+
66
+ const proContentPlugin = {
67
+ name: 'pro-content',
68
+
69
+ // --- Fields read by build-scripts@0.7.0+ (types@1.4.0+) ---
70
+ // Passthrough schemas — let each component handle its own prop validation
71
+ // at runtime. Registered here so the prebuild content-item validator
72
+ // accepts pro types without errors.
73
+ contentItemSchemas: [
74
+ // Pro-only types — fully passthrough (no OSS schema exists)
75
+ ...PRO_CONTENT_TYPE_KEYS.map((type) =>
76
+ z.object({ type: z.literal(type) }).passthrough()
77
+ ),
78
+ // OSS types with Pro extensions (theme:, auth:, etc.) — passthrough
79
+ // variants so the extra fields don't fail strict OSS validation.
80
+ ...OSS_TYPES_WITH_PRO_EXTENSIONS.map((type) =>
81
+ z.object({ type: z.literal(type) }).passthrough()
82
+ ),
83
+ ],
84
+ // String keys so the prebuild skips "unknown content type" warnings.
85
+ knownContentTypeKeys: [...PRO_CONTENT_TYPE_KEYS, ...OSS_TYPES_WITH_PRO_EXTENSIONS],
86
+
87
+ // --- Stub lifecycle hook (required for build-scripts@0.5.x / types@1.2.x) ---
88
+ // build-scripts@0.5.x only calls plugins that have beforeBuild or afterBuild.
89
+ // Without this stub the plugin object is accepted but never invoked, making
90
+ // the whole registration a silent no-op. The stub has no side-effects; its
91
+ // only purpose is to keep the plugin in the active lifecycle.
92
+ //
93
+ // Remove this stub when build-scripts@0.7.0 is the resolved floor (the
94
+ // 0.7.x runner calls plugins purely for their schema/key registration,
95
+ // not via beforeBuild/afterBuild).
96
+ beforeBuild: () => {},
97
+ };
98
+
99
+ module.exports = { proContentPlugin };