@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.13 → 0.4.0-alpha.130

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,103 @@
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
+ 'detail_field',
40
+ 'detail_view',
41
+ // @stackwright-pro/pulse
42
+ 'pulse_provider',
43
+ 'metric_card_pulse',
44
+ 'data_table_pulse',
45
+ 'status_badge_pulse',
46
+ 'detail_card_pulse',
47
+ 'stats_grid',
48
+ 'map_pulse',
49
+ 'alert_banner',
50
+ // @stackwright-pro/workflow-components
51
+ 'workflow_mount',
52
+ // @stackwright-pro/display-components — navigation
53
+ 'breadcrumb',
54
+ 'page_header_bar',
55
+ ];
56
+
57
+ // OSS content types that Pro otters augment with extra fields (e.g. `theme:`,
58
+ // `auth:`). The strict OSS Zod schemas reject unknown properties, so we
59
+ // register passthrough variants here. When build-scripts@0.7.0+ evaluates
60
+ // the union [contentItemSchema, ...extraSchemas], the strict OSS schema
61
+ // fails on the extra field and falls through to our passthrough version.
62
+ const OSS_TYPES_WITH_PRO_EXTENSIONS = [
63
+ 'text_block',
64
+ 'alert',
65
+ 'grid',
66
+ 'main',
67
+ 'collection_list',
68
+ ];
69
+
70
+ const proContentPlugin = {
71
+ name: 'pro-content',
72
+
73
+ // --- Fields read by build-scripts@0.7.0+ (types@1.4.0+) ---
74
+ // Passthrough schemas — let each component handle its own prop validation
75
+ // at runtime. Registered here so the prebuild content-item validator
76
+ // accepts pro types without errors.
77
+ contentItemSchemas: [
78
+ // Pro-only types — fully passthrough (no OSS schema exists)
79
+ ...PRO_CONTENT_TYPE_KEYS.map((type) =>
80
+ z.object({ type: z.literal(type) }).passthrough()
81
+ ),
82
+ // OSS types with Pro extensions (theme:, auth:, etc.) — passthrough
83
+ // variants so the extra fields don't fail strict OSS validation.
84
+ ...OSS_TYPES_WITH_PRO_EXTENSIONS.map((type) =>
85
+ z.object({ type: z.literal(type) }).passthrough()
86
+ ),
87
+ ],
88
+ // String keys so the prebuild skips "unknown content type" warnings.
89
+ knownContentTypeKeys: [...PRO_CONTENT_TYPE_KEYS, ...OSS_TYPES_WITH_PRO_EXTENSIONS],
90
+
91
+ // --- Stub lifecycle hook (required for build-scripts@0.5.x / types@1.2.x) ---
92
+ // build-scripts@0.5.x only calls plugins that have beforeBuild or afterBuild.
93
+ // Without this stub the plugin object is accepted but never invoked, making
94
+ // the whole registration a silent no-op. The stub has no side-effects; its
95
+ // only purpose is to keep the plugin in the active lifecycle.
96
+ //
97
+ // Remove this stub when build-scripts@0.7.0 is the resolved floor (the
98
+ // 0.7.x runner calls plugins purely for their schema/key registration,
99
+ // not via beforeBuild/afterBuild).
100
+ beforeBuild: () => {},
101
+ };
102
+
103
+ module.exports = { proContentPlugin };