@@ -4,30 +4,13 @@ import type {
4
4
SpaceComponentInternalTag ,
5
5
SpaceComponentPreset ,
6
6
} from '../../constants' ;
7
- import type { SpaceDatasource } from '../../../datasources/constants' ;
8
7
import type { DependencyGraph , GraphBuildingContext , NodeData , NodeType , ProcessingLevel , SchemaDependencies , TargetResourceInfo , UnifiedNode } from './types' ;
9
8
import { upsertComponent , upsertComponentGroup , upsertComponentInternalTag , upsertComponentPreset } from '../actions' ;
10
- import { upsertDatasource } from '../../../datasources/push/actions' ;
11
9
12
10
// =============================================================================
13
11
// HELPER FUNCTIONS
14
12
// =============================================================================
15
13
16
- /**
17
- * Creates a minimal stub datasource with only required fields.
18
- */
19
- function createStubDatasource ( name : string ) : SpaceDatasource {
20
- return {
21
- id : 0 , // Will be set by API
22
- name,
23
- slug : name ,
24
- dimensions : [ ] ,
25
- entries : [ ] , // Empty entries for stub
26
- created_at : new Date ( ) . toISOString ( ) ,
27
- updated_at : new Date ( ) . toISOString ( ) ,
28
- } ;
29
- }
30
-
31
14
// =============================================================================
32
15
// GRAPH BUILDING
33
16
// =============================================================================
@@ -53,27 +36,8 @@ export function buildDependencyGraph(context: GraphBuildingContext): DependencyG
53
36
}
54
37
}
55
38
56
- // Collect all datasource names referenced by components
57
- const referencedDatasources = new Set < string > ( ) ;
58
- spaceState . local . components . forEach ( ( component ) => {
59
- if ( component . schema ) {
60
- const dependencies = collectWhitelistDependencies ( component . schema ) ;
61
- dependencies . datasourceNames . forEach ( ( datasourceName ) => {
62
- referencedDatasources . add ( datasourceName ) ;
63
- } ) ;
64
- }
65
- } ) ;
66
-
67
- // Create stub datasource nodes for all referenced datasources
68
- referencedDatasources . forEach ( ( datasourceName ) => {
69
- const nodeId = `datasource:${ datasourceName } ` ;
70
- const targetDatasource = spaceState . target . datasources ?. get ( datasourceName ) ;
71
-
72
- // Create minimal stub datasource
73
- const stubDatasource = createStubDatasource ( datasourceName ) ;
74
- const node = new DatasourceNode ( nodeId , stubDatasource , targetDatasource ) ;
75
- graph . nodes . set ( nodeId , node ) ;
76
- } ) ;
39
+ // Note: Datasource dependencies are not processed by the components push command.
40
+ // Datasources should be managed using the dedicated 'storyblok datasources push' command.
77
41
78
42
// Create nodes for all tags with colocated target data
79
43
spaceState . local . internalTags . forEach ( ( tag ) => {
@@ -185,13 +149,6 @@ export function buildDependencyGraph(context: GraphBuildingContext): DependencyG
185
149
const dependencyId = `component:${ componentName } ` ;
186
150
addDependency ( componentId , dependencyId ) ;
187
151
} ) ;
188
-
189
- // Add dependencies on datasources (from schema fields with internal source)
190
- dependencies . datasourceNames . forEach ( ( datasourceName ) => {
191
- const datasourceId = `datasource:${ datasourceName } ` ;
192
- // Always add dependency since we create stubs for all referenced datasources
193
- addDependency ( componentId , datasourceId ) ;
194
- } ) ;
195
152
}
196
153
} ) ;
197
154
@@ -755,17 +712,9 @@ export class ComponentNode extends GraphNode<SpaceComponent> {
755
712
// Component whitelist doesn't need ID resolution as it uses names
756
713
}
757
714
758
- // Resolve datasource references in option/options fields with internal source
759
- if ( ( resolvedField . type === 'option' || resolvedField . type === 'options' ) && resolvedField . source === 'internal' ) {
760
- if ( resolvedField . datasource_slug && typeof resolvedField . datasource_slug === 'string' ) {
761
- const datasourceNodeId = `datasource:${ resolvedField . datasource_slug } ` ;
762
- const datasourceNode = graph . nodes . get ( datasourceNodeId ) as DatasourceNode ;
763
- if ( datasourceNode ?. targetData ) {
764
- // Update the datasource_slug to the target datasource slug
765
- resolvedField . datasource_slug = datasourceNode . targetData . resource . slug ;
766
- }
767
- }
768
- }
715
+ // Note: Datasource references are not resolved by the components push command.
716
+ // Components that reference datasources will work correctly if the datasources
717
+ // already exist in the target space with the same slug names.
769
718
770
719
// Recursively resolve nested fields
771
720
Object . keys ( resolvedField ) . forEach ( ( key ) => {
@@ -857,28 +806,5 @@ class PresetNode implements UnifiedNode<SpaceComponentPreset> {
857
806
}
858
807
}
859
808
860
- export class DatasourceNode extends GraphNode < SpaceDatasource > {
861
- constructor ( id : string , data : SpaceDatasource , targetDatasource ?: SpaceDatasource ) {
862
- super ( id , 'datasource' , data . name , data , targetDatasource ) ;
863
- }
864
-
865
- resolveReferences ( _graph : DependencyGraph ) : void {
866
- // Datasources don't have references to resolve
867
- }
868
-
869
- async upsert ( space : string ) : Promise < SpaceDatasource > {
870
- const existingDatasource = this . targetData ?. resource as SpaceDatasource | undefined ;
871
- const existingId = existingDatasource ?. id ;
872
-
873
- // For components push, we only create the datasource stub without entries.
874
- // Pushing entries is handled by the datasources push command.
875
- const { entries, ...datasourceDefinition } = this . sourceData ;
876
-
877
- const result = await upsertDatasource ( space , datasourceDefinition , existingId ) ;
878
- if ( ! result ) {
879
- throw new Error ( `Failed to upsert datasource ${ this . name } ` ) ;
880
- }
881
-
882
- return result ;
883
- }
884
- }
809
+ // Note: DatasourceNode class removed as datasources are not managed
810
+ // by the components push command. Use 'storyblok datasources push' instead.
0 commit comments