66use Utopia \Migration \Transfer ;
77
88/**
9- * Singleton settings resource carrying the project's 17 per-service
10- * enable/disable flags. One per project; destination flips each via
11- * Project::updateService() .
9+ * Singleton settings resource carrying the project's per-service enable/disable
10+ * flags, keyed by ServiceId value . One per project; destination merges each
11+ * entry into the project's services map .
1212 */
1313class Services extends Resource
1414{
15+ /**
16+ * @param array<string, bool> $services Map of ServiceId string → enabled flag.
17+ */
1518 public function __construct (
1619 string $ id ,
17- private readonly bool $ account = true ,
18- private readonly bool $ avatars = true ,
19- private readonly bool $ databases = true ,
20- private readonly bool $ tablesdb = true ,
21- private readonly bool $ locale = true ,
22- private readonly bool $ health = true ,
23- private readonly bool $ project = true ,
24- private readonly bool $ storage = true ,
25- private readonly bool $ teams = true ,
26- private readonly bool $ users = true ,
27- private readonly bool $ vcs = true ,
28- private readonly bool $ sites = true ,
29- private readonly bool $ functions = true ,
30- private readonly bool $ proxy = true ,
31- private readonly bool $ graphql = true ,
32- private readonly bool $ migrations = true ,
33- private readonly bool $ messaging = true ,
20+ private readonly array $ services = [],
3421 string $ createdAt = '' ,
3522 string $ updatedAt = '' ,
3623 ) {
@@ -46,23 +33,7 @@ public static function fromArray(array $array): self
4633 {
4734 return new self (
4835 $ array ['id ' ],
49- (bool ) ($ array ['account ' ] ?? true ),
50- (bool ) ($ array ['avatars ' ] ?? true ),
51- (bool ) ($ array ['databases ' ] ?? true ),
52- (bool ) ($ array ['tablesdb ' ] ?? true ),
53- (bool ) ($ array ['locale ' ] ?? true ),
54- (bool ) ($ array ['health ' ] ?? true ),
55- (bool ) ($ array ['project ' ] ?? true ),
56- (bool ) ($ array ['storage ' ] ?? true ),
57- (bool ) ($ array ['teams ' ] ?? true ),
58- (bool ) ($ array ['users ' ] ?? true ),
59- (bool ) ($ array ['vcs ' ] ?? true ),
60- (bool ) ($ array ['sites ' ] ?? true ),
61- (bool ) ($ array ['functions ' ] ?? true ),
62- (bool ) ($ array ['proxy ' ] ?? true ),
63- (bool ) ($ array ['graphql ' ] ?? true ),
64- (bool ) ($ array ['migrations ' ] ?? true ),
65- (bool ) ($ array ['messaging ' ] ?? true ),
36+ (array ) ($ array ['services ' ] ?? []),
6637 createdAt: $ array ['createdAt ' ] ?? '' ,
6738 updatedAt: $ array ['updatedAt ' ] ?? '' ,
6839 );
@@ -75,120 +46,27 @@ public function jsonSerialize(): array
7546 {
7647 return [
7748 'id ' => $ this ->id ,
78- 'account ' => $ this ->account ,
79- 'avatars ' => $ this ->avatars ,
80- 'databases ' => $ this ->databases ,
81- 'tablesdb ' => $ this ->tablesdb ,
82- 'locale ' => $ this ->locale ,
83- 'health ' => $ this ->health ,
84- 'project ' => $ this ->project ,
85- 'storage ' => $ this ->storage ,
86- 'teams ' => $ this ->teams ,
87- 'users ' => $ this ->users ,
88- 'vcs ' => $ this ->vcs ,
89- 'sites ' => $ this ->sites ,
90- 'functions ' => $ this ->functions ,
91- 'proxy ' => $ this ->proxy ,
92- 'graphql ' => $ this ->graphql ,
93- 'migrations ' => $ this ->migrations ,
94- 'messaging ' => $ this ->messaging ,
49+ 'services ' => $ this ->services ,
9550 'createdAt ' => $ this ->createdAt ,
9651 'updatedAt ' => $ this ->updatedAt ,
9752 ];
9853 }
9954
10055 public static function getName (): string
10156 {
102- return Resource::TYPE_SERVICES ;
57+ return Resource::TYPE_PROJECT_SERVICES ;
10358 }
10459
10560 public function getGroup (): string
10661 {
107- return Transfer::GROUP_SETTINGS ;
108- }
109-
110- public function getAccount (): bool
111- {
112- return $ this ->account ;
113- }
114-
115- public function getAvatars (): bool
116- {
117- return $ this ->avatars ;
118- }
119-
120- public function getDatabases (): bool
121- {
122- return $ this ->databases ;
123- }
124-
125- public function getTablesdb (): bool
126- {
127- return $ this ->tablesdb ;
128- }
129-
130- public function getLocale (): bool
131- {
132- return $ this ->locale ;
133- }
134-
135- public function getHealth (): bool
136- {
137- return $ this ->health ;
138- }
139-
140- public function getProject (): bool
141- {
142- return $ this ->project ;
143- }
144-
145- public function getStorage (): bool
146- {
147- return $ this ->storage ;
62+ return Transfer::GROUP_PROJECTS ;
14863 }
14964
150- public function getTeams (): bool
151- {
152- return $ this ->teams ;
153- }
154-
155- public function getUsers (): bool
156- {
157- return $ this ->users ;
158- }
159-
160- public function getVcs (): bool
161- {
162- return $ this ->vcs ;
163- }
164-
165- public function getSites (): bool
166- {
167- return $ this ->sites ;
168- }
169-
170- public function getFunctions (): bool
171- {
172- return $ this ->functions ;
173- }
174-
175- public function getProxy (): bool
176- {
177- return $ this ->proxy ;
178- }
179-
180- public function getGraphql (): bool
181- {
182- return $ this ->graphql ;
183- }
184-
185- public function getMigrations (): bool
186- {
187- return $ this ->migrations ;
188- }
189-
190- public function getMessaging (): bool
65+ /**
66+ * @return array<string, bool>
67+ */
68+ public function getServices (): array
19169 {
192- return $ this ->messaging ;
70+ return $ this ->services ;
19371 }
19472}
0 commit comments