@teambit/component 1.0.107 → 1.0.108
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/aspect-entry.ts +73 -0
- package/aspect-list.ts +132 -0
- package/component-factory.ts +190 -0
- package/component-fs.ts +66 -0
- package/component-interface.ts +26 -0
- package/component-meta.ts +29 -0
- package/component.aspect.ts +9 -0
- package/component.graphql.ts +256 -0
- package/component.main.runtime.ts +170 -0
- package/component.route.ts +38 -0
- package/component.ts +319 -0
- package/config.ts +24 -0
- package/dist/aspect-entry.d.ts +4 -4
- package/dist/aspect-entry.js +1 -2
- package/dist/aspect-entry.js.map +1 -1
- package/dist/aspect-list.js +2 -2
- package/dist/aspect-list.js.map +1 -1
- package/dist/aspect.section.d.ts +3 -3
- package/dist/component-factory.d.ts +3 -3
- package/dist/component-interface.d.ts +1 -1
- package/dist/component-map/component-map.d.ts +2 -2
- package/dist/component.composition.d.ts +2 -2
- package/dist/component.d.ts +3 -3
- package/dist/component.graphql.d.ts +13 -13
- package/dist/component.graphql.js +3 -6
- package/dist/component.graphql.js.map +1 -1
- package/dist/component.js +5 -9
- package/dist/component.js.map +1 -1
- package/dist/component.main.runtime.d.ts +2 -2
- package/dist/component.route.d.ts +2 -2
- package/dist/component.ui.runtime.d.ts +7 -7
- package/dist/component.ui.runtime.js +12 -27
- package/dist/component.ui.runtime.js.map +1 -1
- package/dist/get-component-opts.d.ts +1 -1
- package/dist/hash.d.ts +1 -1
- package/dist/{preview-1703590665075.js → preview-1703647408454.js} +2 -2
- package/dist/snap/author.d.ts +1 -1
- package/dist/snap/snap.d.ts +1 -1
- package/dist/tag/tag.d.ts +1 -1
- package/dist/tag-map.d.ts +1 -1
- package/dist/ui/aspect-page/aspect-page.d.ts +2 -2
- package/dist/ui/aspect-page/aspect-page.js +1 -2
- package/dist/ui/aspect-page/aspect-page.js.map +1 -1
- package/dist/ui/component-error/component-error.d.ts +4 -4
- package/dist/ui/component-model/component-model.d.ts +21 -21
- package/dist/ui/component-model/component-model.js +1 -1
- package/dist/ui/component-model/component-model.js.map +1 -1
- package/dist/ui/component-searcher/component-result.d.ts +4 -4
- package/dist/ui/component-searcher/component-result.js +2 -2
- package/dist/ui/component-searcher/component-result.js.map +1 -1
- package/dist/ui/component-searcher/component-searcher.d.ts +2 -2
- package/dist/ui/component.d.ts +5 -5
- package/dist/ui/component.js +6 -6
- package/dist/ui/component.js.map +1 -1
- package/dist/ui/context/component-context.d.ts +1 -1
- package/dist/ui/context/component-provider.d.ts +5 -5
- package/dist/ui/menu/menu-nav.d.ts +2 -2
- package/dist/ui/menu/menu-nav.js +5 -5
- package/dist/ui/menu/menu-nav.js.map +1 -1
- package/dist/ui/menu/menu.d.ts +9 -9
- package/dist/ui/menu/menu.js +28 -31
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/menu/nav-plugin.d.ts +7 -7
- package/dist/ui/top-bar-nav/top-bar-nav.d.ts +2 -2
- package/dist/ui/use-component-from-location.js +1 -1
- package/dist/ui/use-component-from-location.js.map +1 -1
- package/dist/ui/use-component-logs.d.ts +7 -7
- package/dist/ui/use-component-logs.js +5 -6
- package/dist/ui/use-component-logs.js.map +1 -1
- package/dist/ui/use-component-query.js +13 -17
- package/dist/ui/use-component-query.js.map +1 -1
- package/dist/ui/use-component.model.d.ts +7 -7
- package/get-component-opts.ts +14 -0
- package/hash.ts +4 -0
- package/head.ts +0 -0
- package/history-graph.ts +1 -0
- package/index.ts +50 -0
- package/on-load.ts +0 -0
- package/package.json +30 -37
- package/state.ts +88 -0
- package/store.ts +3 -0
- package/tag-map.ts +87 -0
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
package/component.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { AnyFS } from '@teambit/any-fs';
|
|
2
|
+
import { capitalize } from '@teambit/toolbox.string.capitalize';
|
|
3
|
+
import { SemVer } from 'semver';
|
|
4
|
+
import { ComponentID } from '@teambit/component-id';
|
|
5
|
+
import { BitError } from '@teambit/bit-error';
|
|
6
|
+
import { BuildStatus } from '@teambit/legacy/dist/constants';
|
|
7
|
+
|
|
8
|
+
import { slice } from 'lodash';
|
|
9
|
+
import { ComponentFactory } from './component-factory';
|
|
10
|
+
import ComponentFS from './component-fs';
|
|
11
|
+
// import { NothingToSnap } from './exceptions';
|
|
12
|
+
import { Config as ComponentConfig } from './config';
|
|
13
|
+
// eslint-disable-next-line import/no-cycle
|
|
14
|
+
import { Snap } from './snap';
|
|
15
|
+
import { State } from './state';
|
|
16
|
+
import { TagMap } from './tag-map';
|
|
17
|
+
import { Tag } from './tag';
|
|
18
|
+
import { CouldNotFindLatest } from './exceptions';
|
|
19
|
+
import { IComponent, RawComponentMetadata } from './component-interface';
|
|
20
|
+
// import { Author } from './types';
|
|
21
|
+
|
|
22
|
+
type SnapsIterableOpts = {
|
|
23
|
+
firstParentOnly?: boolean;
|
|
24
|
+
stopFn?: (snap: Snap) => Promise<boolean>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type InvalidComponent = { id: ComponentID; err: Error };
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* in-memory representation of a component.
|
|
31
|
+
*/
|
|
32
|
+
export class Component implements IComponent {
|
|
33
|
+
constructor(
|
|
34
|
+
/**
|
|
35
|
+
* component ID represented by the `ComponentId` type.
|
|
36
|
+
*/
|
|
37
|
+
readonly id: ComponentID,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* head version of the component. can be `null` for new components.
|
|
41
|
+
*/
|
|
42
|
+
readonly head: Snap | null = null,
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* state of the component.
|
|
46
|
+
*/
|
|
47
|
+
private _state: State,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* tags of the component.
|
|
51
|
+
*/
|
|
52
|
+
readonly tags: TagMap = new TagMap(),
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* the component factory
|
|
56
|
+
*/
|
|
57
|
+
private factory: ComponentFactory
|
|
58
|
+
) {}
|
|
59
|
+
|
|
60
|
+
get mainFile() {
|
|
61
|
+
return this.state.mainFile;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get state(): State {
|
|
65
|
+
return this._state;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
set state(state: State) {
|
|
69
|
+
this._state = state;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* component configuration which is later generated to a component `package.json` and `bit.json`.
|
|
74
|
+
*/
|
|
75
|
+
get config(): ComponentConfig {
|
|
76
|
+
return this.state.config;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* in-memory representation of the component current filesystem.
|
|
81
|
+
*/
|
|
82
|
+
get filesystem(): ComponentFS {
|
|
83
|
+
return this.state.filesystem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* build status of the component
|
|
88
|
+
*/
|
|
89
|
+
get buildStatus(): BuildStatus {
|
|
90
|
+
return this._state._consumer.buildStatus;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get headTag() {
|
|
94
|
+
if (!this.head) return undefined;
|
|
95
|
+
return this.tags.byHash(this.head.hash);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get latest(): string | undefined {
|
|
99
|
+
if (!this.head) return undefined;
|
|
100
|
+
try {
|
|
101
|
+
return this.tags.getLatest();
|
|
102
|
+
} catch (err: any) {
|
|
103
|
+
if (err instanceof CouldNotFindLatest) {
|
|
104
|
+
return this.head.hash;
|
|
105
|
+
}
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* get aspect data from current state.
|
|
112
|
+
*/
|
|
113
|
+
get(id: string): RawComponentMetadata | undefined {
|
|
114
|
+
return this.state.aspects.get(id)?.serialize();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async getLogs(filter?: { type?: string; offset?: number; limit?: number; head?: string; sort?: string }) {
|
|
118
|
+
const allLogs = await this.factory.getLogs(this.id, false, filter?.head);
|
|
119
|
+
|
|
120
|
+
if (!filter) return allLogs;
|
|
121
|
+
|
|
122
|
+
const { type, limit, offset, sort } = filter;
|
|
123
|
+
|
|
124
|
+
const typeFilter = (snap) => {
|
|
125
|
+
if (type === 'tag') return snap.tag;
|
|
126
|
+
if (type === 'snap') return !snap.tag;
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
let filteredLogs = (type && allLogs.filter(typeFilter)) || allLogs;
|
|
131
|
+
if (sort !== 'asc') filteredLogs = filteredLogs.reverse();
|
|
132
|
+
|
|
133
|
+
if (limit) {
|
|
134
|
+
filteredLogs = slice(filteredLogs, offset, limit + (offset || 0));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return filteredLogs;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
stringify(): string {
|
|
141
|
+
return JSON.stringify({
|
|
142
|
+
id: this.id,
|
|
143
|
+
head: this.head,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* record component changes in the `Scope`.
|
|
149
|
+
*/
|
|
150
|
+
// snap(author: Author, message = '') {
|
|
151
|
+
// if (!this.isModified()) throw new NothingToSnap();
|
|
152
|
+
// const snap = new Snap(this, author, message);
|
|
153
|
+
|
|
154
|
+
// return new Component(this.id, snap, snap.state);
|
|
155
|
+
// }
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* display name of the component.
|
|
159
|
+
*/
|
|
160
|
+
get displayName() {
|
|
161
|
+
const tokens = this.id.name.split('-').map((token) => capitalize(token));
|
|
162
|
+
return tokens.join(' ');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* tag a component `Snap` with a semantic version. we follow SemVer specs as defined [here](https://semver.org/)).
|
|
167
|
+
*/
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
169
|
+
tag(version: SemVer) {
|
|
170
|
+
// const snap = this.snap();
|
|
171
|
+
// const tag = new Tag(version, snap);
|
|
172
|
+
// this.tags.set(tag);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* determines whether this component is modified in the workspace.
|
|
177
|
+
*/
|
|
178
|
+
isModified(): Promise<boolean> {
|
|
179
|
+
return this.factory.isModified(this);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* whether a component is marked as deleted.
|
|
184
|
+
*/
|
|
185
|
+
isDeleted(): boolean {
|
|
186
|
+
return this.state._consumer.isRemoved();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* is component isOutdated
|
|
191
|
+
*/
|
|
192
|
+
isOutdated(): boolean {
|
|
193
|
+
if (!this.latest) return false;
|
|
194
|
+
const latestTag = this.tags.byVersion(this.latest);
|
|
195
|
+
if (!latestTag) return false;
|
|
196
|
+
if (this.head?.hash !== latestTag?.hash) return true;
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* determines whether this component is new.
|
|
202
|
+
*/
|
|
203
|
+
isNew(): Promise<boolean> {
|
|
204
|
+
return Promise.resolve(this.head === null);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// TODO: @david after snap we need to make sure to refactor here.
|
|
208
|
+
loadState(snapId: string): Promise<State> {
|
|
209
|
+
return this.factory.getState(this.id, snapId);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
loadSnap(snapId?: string): Promise<Snap> {
|
|
213
|
+
const snapToGet = snapId || this.head?.hash;
|
|
214
|
+
if (!snapToGet) {
|
|
215
|
+
throw new BitError('could not load snap for new components');
|
|
216
|
+
}
|
|
217
|
+
return this.factory.getSnap(this.id, snapToGet);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get iterable which iterate over snap parents lazily
|
|
222
|
+
* @param snapId
|
|
223
|
+
* @param options
|
|
224
|
+
*/
|
|
225
|
+
snapsIterable(snapId?: string, options: SnapsIterableOpts = {}): AsyncIterable<Snap> {
|
|
226
|
+
const snapToStart = snapId || this.head?.hash;
|
|
227
|
+
let nextSnaps = [snapToStart];
|
|
228
|
+
let done;
|
|
229
|
+
if (!snapToStart) {
|
|
230
|
+
done = true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const iterator: AsyncIterator<Snap> = {
|
|
234
|
+
next: async () => {
|
|
235
|
+
if (done) {
|
|
236
|
+
return { value: undefined, done };
|
|
237
|
+
}
|
|
238
|
+
const currSnapId = nextSnaps.shift();
|
|
239
|
+
const snap = await this.loadSnap(currSnapId);
|
|
240
|
+
if (snap.parents && snap.parents.length) {
|
|
241
|
+
if (options.firstParentOnly) {
|
|
242
|
+
nextSnaps.push(snap.parents[0]);
|
|
243
|
+
} else {
|
|
244
|
+
nextSnaps = nextSnaps.concat(snap.parents);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (!nextSnaps.length) {
|
|
248
|
+
done = true;
|
|
249
|
+
} else if (options.stopFn) {
|
|
250
|
+
done = await options.stopFn(snap);
|
|
251
|
+
}
|
|
252
|
+
return { value: snap, done: undefined };
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
return {
|
|
256
|
+
[Symbol.asyncIterator]: () => iterator,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* traverse recursively from the provided snap (or head) upwards until it finds a tag
|
|
262
|
+
* @param snapToStartFrom
|
|
263
|
+
*/
|
|
264
|
+
async getClosestTag(snapToStartFrom?: string): Promise<Tag | undefined> {
|
|
265
|
+
const tagsHashMap = this.tags.getHashMap();
|
|
266
|
+
const stopFn = async (snap: Snap) => {
|
|
267
|
+
if (tagsHashMap.has(snap.hash)) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
};
|
|
272
|
+
const iterable = this.snapsIterable(snapToStartFrom, { firstParentOnly: true, stopFn });
|
|
273
|
+
const snaps: Snap[] = [];
|
|
274
|
+
for await (const snap of iterable) {
|
|
275
|
+
snaps.push(snap);
|
|
276
|
+
}
|
|
277
|
+
if (snaps.length) {
|
|
278
|
+
const hashOfLastSnap = snaps[snaps.length - 1].hash;
|
|
279
|
+
return tagsHashMap.get(hashOfLastSnap);
|
|
280
|
+
}
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* checkout the component to a different version in its working tree.
|
|
286
|
+
*/
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
288
|
+
checkout(version: SemVer) {}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* examine difference between two components.
|
|
292
|
+
*/
|
|
293
|
+
// diff(other: Component): Difference {}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* merge two different components
|
|
297
|
+
*/
|
|
298
|
+
// merge(other: Component): Component {}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* write a component to a given file system.
|
|
302
|
+
* @param path root path to write the component
|
|
303
|
+
* @param fs instance of any fs to use.
|
|
304
|
+
*/
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
306
|
+
write(path: string, fs?: AnyFS) {}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
* Check if 2 components are equal
|
|
311
|
+
* @param {Component} component
|
|
312
|
+
* @returns {boolean}
|
|
313
|
+
* @memberof Component
|
|
314
|
+
*/
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
316
|
+
equals(component: Component): boolean {
|
|
317
|
+
return component.id.toString() === this.id.toString();
|
|
318
|
+
}
|
|
319
|
+
}
|
package/config.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
2
|
+
import { PathLinuxRelative, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* in-memory representation of the component configuration.
|
|
6
|
+
*/
|
|
7
|
+
export class Config {
|
|
8
|
+
constructor(private consumerComponent: any) {}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* component main file
|
|
12
|
+
* when loaded from the workspace, it's PathOsBasedRelative. otherwise, PathLinuxRelative.
|
|
13
|
+
*/
|
|
14
|
+
get main(): PathLinuxRelative | PathOsBasedRelative {
|
|
15
|
+
return this.consumerComponent.mainFile;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* configured extensions
|
|
20
|
+
*/
|
|
21
|
+
get extensions(): ExtensionDataList {
|
|
22
|
+
return this.consumerComponent.extensions;
|
|
23
|
+
}
|
|
24
|
+
}
|
package/dist/aspect-entry.d.ts
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
import type { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
5
5
|
import { ComponentID } from '@teambit/component-id';
|
|
6
6
|
import { RawComponentMetadata } from './component-interface';
|
|
7
|
-
export
|
|
7
|
+
export type Serializable = {
|
|
8
8
|
toString(): string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type SerializableMap = {
|
|
11
11
|
[key: string]: Serializable;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type AspectData = {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type ResolveComponentIdFunc = (id: string) => Promise<ComponentID>;
|
|
17
17
|
export declare class AspectEntry {
|
|
18
18
|
id: ComponentID;
|
|
19
19
|
private legacyEntry;
|
package/dist/aspect-entry.js
CHANGED
|
@@ -17,8 +17,7 @@ class AspectEntry {
|
|
|
17
17
|
return this.legacyEntry;
|
|
18
18
|
}
|
|
19
19
|
get isLegacy() {
|
|
20
|
-
|
|
21
|
-
if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.__legacy) return true;
|
|
20
|
+
if (this.config?.__legacy) return true;
|
|
22
21
|
return false;
|
|
23
22
|
}
|
|
24
23
|
get config() {
|
package/dist/aspect-entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AspectEntry","constructor","id","legacyEntry","legacy","isLegacy","
|
|
1
|
+
{"version":3,"names":["AspectEntry","constructor","id","legacyEntry","legacy","isLegacy","config","__legacy","data","isRemoved","val","transform","newData","newEntry","clone","serialize","toString","icon","exports"],"sources":["aspect-entry.ts"],"sourcesContent":["/**\n * avoid importing any (non-type) legacy code here. otherwise, PreviewTask will throw cryptic errors\n */\n\nimport type { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { ComponentID } from '@teambit/component-id';\nimport { RawComponentMetadata } from './component-interface';\n\nexport type Serializable = {\n toString(): string;\n};\n\nexport type SerializableMap = {\n [key: string]: Serializable;\n};\n\nexport type AspectData = {\n [key: string]: any;\n};\n\nexport type ResolveComponentIdFunc = (id: string) => Promise<ComponentID>;\nexport class AspectEntry {\n constructor(public id: ComponentID, private legacyEntry: ExtensionDataEntry) {}\n\n get legacy() {\n return this.legacyEntry;\n }\n\n get isLegacy(): boolean {\n if (this.config?.__legacy) return true;\n return false;\n }\n\n get config() {\n return this.legacy.config;\n }\n\n set config(config) {\n this.legacy.config = config;\n }\n\n get data(): { [key: string]: any } {\n return this.legacy.data;\n }\n\n get isRemoved(): boolean {\n return this.legacy.isRemoved;\n }\n\n // eslint-disable-next-line @typescript-eslint/adjacent-overload-signatures\n set data(val: { [key: string]: any }) {\n this.legacy.data = val;\n }\n\n transform(newData: SerializableMap): AspectEntry {\n const newEntry = this.clone();\n newEntry.data = newData;\n return new AspectEntry(this.id, newEntry.legacy);\n }\n\n clone(): AspectEntry {\n return new AspectEntry(this.id, this.legacyEntry.clone());\n }\n\n serialize(): RawComponentMetadata {\n return {\n id: this.id.toString(),\n config: this.config,\n data: this.data,\n icon: 'https://static.bit.dev/extensions-icons/default.svg', // TODO @gilad - once you connect the icon here please use this url as the default icon\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAmBO,MAAMA,WAAW,CAAC;EACvBC,WAAWA,CAAQC,EAAe,EAAUC,WAA+B,EAAE;IAAA,KAA1DD,EAAe,GAAfA,EAAe;IAAA,KAAUC,WAA+B,GAA/BA,WAA+B;EAAG;EAE9E,IAAIC,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAACD,WAAW;EACzB;EAEA,IAAIE,QAAQA,CAAA,EAAY;IACtB,IAAI,IAAI,CAACC,MAAM,EAAEC,QAAQ,EAAE,OAAO,IAAI;IACtC,OAAO,KAAK;EACd;EAEA,IAAID,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAACF,MAAM,CAACE,MAAM;EAC3B;EAEA,IAAIA,MAAMA,CAACA,MAAM,EAAE;IACjB,IAAI,CAACF,MAAM,CAACE,MAAM,GAAGA,MAAM;EAC7B;EAEA,IAAIE,IAAIA,CAAA,EAA2B;IACjC,OAAO,IAAI,CAACJ,MAAM,CAACI,IAAI;EACzB;EAEA,IAAIC,SAASA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACL,MAAM,CAACK,SAAS;EAC9B;;EAEA;EACA,IAAID,IAAIA,CAACE,GAA2B,EAAE;IACpC,IAAI,CAACN,MAAM,CAACI,IAAI,GAAGE,GAAG;EACxB;EAEAC,SAASA,CAACC,OAAwB,EAAe;IAC/C,MAAMC,QAAQ,GAAG,IAAI,CAACC,KAAK,CAAC,CAAC;IAC7BD,QAAQ,CAACL,IAAI,GAAGI,OAAO;IACvB,OAAO,IAAIZ,WAAW,CAAC,IAAI,CAACE,EAAE,EAAEW,QAAQ,CAACT,MAAM,CAAC;EAClD;EAEAU,KAAKA,CAAA,EAAgB;IACnB,OAAO,IAAId,WAAW,CAAC,IAAI,CAACE,EAAE,EAAE,IAAI,CAACC,WAAW,CAACW,KAAK,CAAC,CAAC,CAAC;EAC3D;EAEAC,SAASA,CAAA,EAAyB;IAChC,OAAO;MACLb,EAAE,EAAE,IAAI,CAACA,EAAE,CAACc,QAAQ,CAAC,CAAC;MACtBV,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBE,IAAI,EAAE,IAAI,CAACA,IAAI;MACfS,IAAI,EAAE,qDAAqD,CAAE;IAC/D,CAAC;EACH;AACF;AAACC,OAAA,CAAAlB,WAAA,GAAAA,WAAA"}
|
package/dist/aspect-list.js
CHANGED
|
@@ -113,9 +113,9 @@ class AspectList {
|
|
|
113
113
|
return serializedEntries;
|
|
114
114
|
}
|
|
115
115
|
filter(ids) {
|
|
116
|
-
if (!
|
|
116
|
+
if (!ids?.length) return new AspectList(this.entries);
|
|
117
117
|
const entries = this.entries.filter(aspectEntry => {
|
|
118
|
-
return ids
|
|
118
|
+
return ids?.includes(aspectEntry.id.toStringWithoutVersion());
|
|
119
119
|
});
|
|
120
120
|
return new AspectList(entries);
|
|
121
121
|
}
|
package/dist/aspect-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_extensionData","data","require","_componentId","_aspectEntry","AspectList","constructor","entries","addEntry","aspectId","extensionDataEntry","ExtensionDataEntry","undefined","entry","AspectEntry","push","upsertEntry","existingEntry","find","id","isEqual","withoutEntries","aspectIds","filter","includes","legacy","stringId","ids","list","map","toString","get","toStringWithoutVersion","ignoreVersion","aspectEntry","predicate","pmap","entriesP","Promise","all","toConfigObject","res","forEach","config","removeInternalConfigFields","rawConfig","serialize","serializedEntries","length","toLegacy","legacyEntries","ExtensionDataList","fromArray","stringIds","clone","fromLegacyExtensions","legacyDataList","newEntries","getAspectId","exports","extensionId","name","ComponentID","fromString","Error"],"sources":["aspect-list.ts"],"sourcesContent":["import {\n ExtensionDataList,\n ExtensionDataEntry,\n removeInternalConfigFields,\n} from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { ComponentID } from '@teambit/component-id';\nimport { AspectEntry, SerializableMap } from './aspect-entry';\n\n/**\n * list of aspects, each may have data and artifacts saved per component.\n */\nexport class AspectList {\n constructor(readonly entries: AspectEntry[]) {}\n\n addEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const extensionDataEntry = new ExtensionDataEntry(undefined, aspectId, undefined, {}, data);\n const entry = new AspectEntry(aspectId, extensionDataEntry);\n this.entries.push(entry);\n return entry;\n }\n\n upsertEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const existingEntry = this.entries.find((entry) => entry.id.isEqual(aspectId));\n if (existingEntry) {\n existingEntry.data = data;\n return existingEntry;\n }\n return this.addEntry(aspectId, data);\n }\n\n /**\n * transform an aspect list into a new one without the given aspect ids\n */\n withoutEntries(aspectIds: string[]): AspectList {\n const entries = this.entries.filter((entry) => !aspectIds.includes(entry.legacy.stringId));\n return new AspectList(entries);\n }\n\n /**\n * get all ids as strings from the aspect list.\n */\n get ids(): string[] {\n const list = this.entries.map((entry) => entry.id.toString());\n return list;\n }\n\n /**\n * get an aspect from the list using a serialized ID.\n */\n get(id: string): AspectEntry | undefined {\n return this.entries.find((entry) => {\n return entry.legacy.stringId === id || entry.id.toStringWithoutVersion() === id;\n });\n }\n\n /**\n * find aspect by component ID.\n */\n find(id: ComponentID, ignoreVersion = false): AspectEntry | undefined {\n return this.entries.find((aspectEntry) => {\n return id.isEqual(aspectEntry.id, { ignoreVersion });\n });\n }\n\n /**\n * transform an aspect list into a new one.\n */\n map(predicate: (entry: AspectEntry) => AspectEntry) {\n const entries = this.entries.map(predicate);\n return new AspectList(entries);\n }\n\n /**\n * transform an aspect list into a new one.\n */\n async pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>) {\n const entriesP = this.entries.map(predicate);\n const entries = await Promise.all(entriesP);\n return new AspectList(entries);\n }\n\n toConfigObject() {\n const res = {};\n this.entries.forEach((entry) => {\n if (entry.config) {\n res[entry.id.toString()] = removeInternalConfigFields(entry.legacy.rawConfig);\n }\n });\n return res;\n }\n\n serialize() {\n const serializedEntries = this.entries.map((entry) => entry.serialize());\n return serializedEntries;\n }\n\n filter(ids?: string[]): AspectList {\n if (!ids?.length) return new AspectList(this.entries);\n const entries = this.entries.filter((aspectEntry) => {\n return ids?.includes(aspectEntry.id.toStringWithoutVersion());\n });\n return new AspectList(entries);\n }\n\n toLegacy(): ExtensionDataList {\n const legacyEntries = this.entries.map((entry) => entry.legacy);\n return ExtensionDataList.fromArray(legacyEntries);\n }\n\n stringIds(): string[] {\n const ids = this.entries.map((entry) => entry.id.toString());\n return ids;\n }\n\n clone(): AspectList {\n return new AspectList(this.entries.map((entry) => entry.clone()));\n }\n\n static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList {\n const newEntries = legacyDataList.map((entry) => {\n return new AspectEntry(getAspectId(entry), entry);\n });\n\n return new AspectList(newEntries);\n }\n}\n\nfunction getAspectId(entry: ExtensionDataEntry) {\n if (!entry.extensionId && entry.name) return ComponentID.fromString(entry.name);\n if (entry.extensionId) return entry.extensionId;\n throw new Error('aspect cannot be loaded without setting an ID');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;AACA;AACA;AACO,MAAMI,UAAU,CAAC;EACtBC,WAAWA,CAAUC,OAAsB,EAAE;IAAA,KAAxBA,OAAsB,GAAtBA,OAAsB;EAAG;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SAASA,CAAA,EAAG;IACV,MAAMC,iBAAiB,GAAG,IAAI,CAACxC,OAAO,CAACsB,GAAG,CAAEhB,KAAK,IAAKA,KAAK,CAACiC,SAAS,CAAC,CAAC,CAAC;IACxE,OAAOC,iBAAiB;EAC1B;EAEAxB,MAAMA,CAACI,GAAc,EAAc;IACjC,IAAI,
|
|
1
|
+
{"version":3,"names":["_extensionData","data","require","_componentId","_aspectEntry","AspectList","constructor","entries","addEntry","aspectId","extensionDataEntry","ExtensionDataEntry","undefined","entry","AspectEntry","push","upsertEntry","existingEntry","find","id","isEqual","withoutEntries","aspectIds","filter","includes","legacy","stringId","ids","list","map","toString","get","toStringWithoutVersion","ignoreVersion","aspectEntry","predicate","pmap","entriesP","Promise","all","toConfigObject","res","forEach","config","removeInternalConfigFields","rawConfig","serialize","serializedEntries","length","toLegacy","legacyEntries","ExtensionDataList","fromArray","stringIds","clone","fromLegacyExtensions","legacyDataList","newEntries","getAspectId","exports","extensionId","name","ComponentID","fromString","Error"],"sources":["aspect-list.ts"],"sourcesContent":["import {\n ExtensionDataList,\n ExtensionDataEntry,\n removeInternalConfigFields,\n} from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { ComponentID } from '@teambit/component-id';\nimport { AspectEntry, SerializableMap } from './aspect-entry';\n\n/**\n * list of aspects, each may have data and artifacts saved per component.\n */\nexport class AspectList {\n constructor(readonly entries: AspectEntry[]) {}\n\n addEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const extensionDataEntry = new ExtensionDataEntry(undefined, aspectId, undefined, {}, data);\n const entry = new AspectEntry(aspectId, extensionDataEntry);\n this.entries.push(entry);\n return entry;\n }\n\n upsertEntry(aspectId: ComponentID, data: SerializableMap = {}) {\n const existingEntry = this.entries.find((entry) => entry.id.isEqual(aspectId));\n if (existingEntry) {\n existingEntry.data = data;\n return existingEntry;\n }\n return this.addEntry(aspectId, data);\n }\n\n /**\n * transform an aspect list into a new one without the given aspect ids\n */\n withoutEntries(aspectIds: string[]): AspectList {\n const entries = this.entries.filter((entry) => !aspectIds.includes(entry.legacy.stringId));\n return new AspectList(entries);\n }\n\n /**\n * get all ids as strings from the aspect list.\n */\n get ids(): string[] {\n const list = this.entries.map((entry) => entry.id.toString());\n return list;\n }\n\n /**\n * get an aspect from the list using a serialized ID.\n */\n get(id: string): AspectEntry | undefined {\n return this.entries.find((entry) => {\n return entry.legacy.stringId === id || entry.id.toStringWithoutVersion() === id;\n });\n }\n\n /**\n * find aspect by component ID.\n */\n find(id: ComponentID, ignoreVersion = false): AspectEntry | undefined {\n return this.entries.find((aspectEntry) => {\n return id.isEqual(aspectEntry.id, { ignoreVersion });\n });\n }\n\n /**\n * transform an aspect list into a new one.\n */\n map(predicate: (entry: AspectEntry) => AspectEntry) {\n const entries = this.entries.map(predicate);\n return new AspectList(entries);\n }\n\n /**\n * transform an aspect list into a new one.\n */\n async pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>) {\n const entriesP = this.entries.map(predicate);\n const entries = await Promise.all(entriesP);\n return new AspectList(entries);\n }\n\n toConfigObject() {\n const res = {};\n this.entries.forEach((entry) => {\n if (entry.config) {\n res[entry.id.toString()] = removeInternalConfigFields(entry.legacy.rawConfig);\n }\n });\n return res;\n }\n\n serialize() {\n const serializedEntries = this.entries.map((entry) => entry.serialize());\n return serializedEntries;\n }\n\n filter(ids?: string[]): AspectList {\n if (!ids?.length) return new AspectList(this.entries);\n const entries = this.entries.filter((aspectEntry) => {\n return ids?.includes(aspectEntry.id.toStringWithoutVersion());\n });\n return new AspectList(entries);\n }\n\n toLegacy(): ExtensionDataList {\n const legacyEntries = this.entries.map((entry) => entry.legacy);\n return ExtensionDataList.fromArray(legacyEntries);\n }\n\n stringIds(): string[] {\n const ids = this.entries.map((entry) => entry.id.toString());\n return ids;\n }\n\n clone(): AspectList {\n return new AspectList(this.entries.map((entry) => entry.clone()));\n }\n\n static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList {\n const newEntries = legacyDataList.map((entry) => {\n return new AspectEntry(getAspectId(entry), entry);\n });\n\n return new AspectList(newEntries);\n }\n}\n\nfunction getAspectId(entry: ExtensionDataEntry) {\n if (!entry.extensionId && entry.name) return ComponentID.fromString(entry.name);\n if (entry.extensionId) return entry.extensionId;\n throw new Error('aspect cannot be loaded without setting an ID');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;AACA;AACA;AACO,MAAMI,UAAU,CAAC;EACtBC,WAAWA,CAAUC,OAAsB,EAAE;IAAA,KAAxBA,OAAsB,GAAtBA,OAAsB;EAAG;EAE9CC,QAAQA,CAACC,QAAqB,EAAER,IAAqB,GAAG,CAAC,CAAC,EAAE;IAC1D,MAAMS,kBAAkB,GAAG,KAAIC,mCAAkB,EAACC,SAAS,EAAEH,QAAQ,EAAEG,SAAS,EAAE,CAAC,CAAC,EAAEX,IAAI,CAAC;IAC3F,MAAMY,KAAK,GAAG,KAAIC,0BAAW,EAACL,QAAQ,EAAEC,kBAAkB,CAAC;IAC3D,IAAI,CAACH,OAAO,CAACQ,IAAI,CAACF,KAAK,CAAC;IACxB,OAAOA,KAAK;EACd;EAEAG,WAAWA,CAACP,QAAqB,EAAER,IAAqB,GAAG,CAAC,CAAC,EAAE;IAC7D,MAAMgB,aAAa,GAAG,IAAI,CAACV,OAAO,CAACW,IAAI,CAAEL,KAAK,IAAKA,KAAK,CAACM,EAAE,CAACC,OAAO,CAACX,QAAQ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|
|
2
2
|
import { Section } from './section';
|
|
3
3
|
export declare class AspectSection implements Section {
|
|
4
4
|
route: {
|
|
5
5
|
path: string;
|
|
6
|
-
element:
|
|
6
|
+
element: JSX.Element;
|
|
7
7
|
};
|
|
8
8
|
navigationLink: {
|
|
9
9
|
href: string;
|
|
10
|
-
children:
|
|
10
|
+
children: JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
|
13
13
|
order: number;
|
|
@@ -7,7 +7,7 @@ import type { AspectDefinition } from '@teambit/aspect-loader';
|
|
|
7
7
|
import { Component, InvalidComponent } from './component';
|
|
8
8
|
import { State } from './state';
|
|
9
9
|
import { Snap } from './snap';
|
|
10
|
-
export
|
|
10
|
+
export type ResolveAspectsOptions = FilterAspectsOptions & {
|
|
11
11
|
throwOnError?: boolean;
|
|
12
12
|
useScopeAspectsCapsule?: boolean;
|
|
13
13
|
workspaceName?: string;
|
|
@@ -15,13 +15,13 @@ export declare type ResolveAspectsOptions = FilterAspectsOptions & {
|
|
|
15
15
|
resolveEnvsFromRoots?: boolean;
|
|
16
16
|
packageManagerConfigRootDir?: string;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type LoadAspectsOptions = {
|
|
19
19
|
throwOnError?: boolean;
|
|
20
20
|
hideMissingModuleError?: boolean;
|
|
21
21
|
ignoreErrors?: boolean;
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type FilterAspectsOptions = {
|
|
25
25
|
/**
|
|
26
26
|
* Do not return results for the core aspects
|
|
27
27
|
*/
|
|
@@ -9,12 +9,12 @@ export declare class ComponentMap<T> {
|
|
|
9
9
|
/**
|
|
10
10
|
* @deprecated please use `get` instead
|
|
11
11
|
*/
|
|
12
|
-
byComponent(component: Component): [Component, T]
|
|
12
|
+
byComponent(component: Component): [Component, T];
|
|
13
13
|
get components(): Component[];
|
|
14
14
|
/**
|
|
15
15
|
* get a value for a component.
|
|
16
16
|
*/
|
|
17
|
-
get(component: Component): [Component, T]
|
|
17
|
+
get(component: Component): [Component, T];
|
|
18
18
|
/**
|
|
19
19
|
* get a value by the component-id
|
|
20
20
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const Logo: () =>
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Logo: () => JSX.Element;
|
package/dist/component.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ import { State } from './state';
|
|
|
10
10
|
import { TagMap } from './tag-map';
|
|
11
11
|
import { Tag } from './tag';
|
|
12
12
|
import { IComponent, RawComponentMetadata } from './component-interface';
|
|
13
|
-
|
|
13
|
+
type SnapsIterableOpts = {
|
|
14
14
|
firstParentOnly?: boolean;
|
|
15
15
|
stopFn?: (snap: Snap) => Promise<boolean>;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type InvalidComponent = {
|
|
18
18
|
id: ComponentID;
|
|
19
19
|
err: Error;
|
|
20
20
|
};
|
|
@@ -78,7 +78,7 @@ export declare class Component implements IComponent {
|
|
|
78
78
|
* build status of the component
|
|
79
79
|
*/
|
|
80
80
|
get buildStatus(): BuildStatus;
|
|
81
|
-
get headTag(): Tag
|
|
81
|
+
get headTag(): Tag;
|
|
82
82
|
get latest(): string | undefined;
|
|
83
83
|
/**
|
|
84
84
|
* get aspect data from current state.
|
|
@@ -12,7 +12,7 @@ export declare function componentSchema(componentExtension: ComponentMain): {
|
|
|
12
12
|
log: (component: Component) => Promise<{
|
|
13
13
|
date: number;
|
|
14
14
|
email: string;
|
|
15
|
-
username: string
|
|
15
|
+
username: string;
|
|
16
16
|
displayName: string;
|
|
17
17
|
id: string;
|
|
18
18
|
hash: string;
|
|
@@ -23,13 +23,13 @@ export declare function componentSchema(componentExtension: ComponentMain): {
|
|
|
23
23
|
}>;
|
|
24
24
|
getFile: (component: Component, { path }: {
|
|
25
25
|
path: string;
|
|
26
|
-
}) => string
|
|
26
|
+
}) => string;
|
|
27
27
|
mainFile: (component: Component) => any;
|
|
28
|
-
headTag: (component: Component) => import(".").TagProps
|
|
29
|
-
latest: (component: Component) => string
|
|
28
|
+
headTag: (component: Component) => import(".").TagProps;
|
|
29
|
+
latest: (component: Component) => string;
|
|
30
30
|
tags: (component: any) => any;
|
|
31
31
|
aspects: (component: Component, { include }: {
|
|
32
|
-
include?: string[]
|
|
32
|
+
include?: string[];
|
|
33
33
|
}) => import("./component-interface").RawComponentMetadata[];
|
|
34
34
|
logs: (component: Component, filter?: {
|
|
35
35
|
type?: string;
|
|
@@ -41,21 +41,21 @@ export declare function componentSchema(componentExtension: ComponentMain): {
|
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
43
|
message: string;
|
|
44
|
-
username?: string
|
|
45
|
-
displayName?: string
|
|
46
|
-
email?: string
|
|
47
|
-
date?: string
|
|
44
|
+
username?: string;
|
|
45
|
+
displayName?: string;
|
|
46
|
+
email?: string;
|
|
47
|
+
date?: string;
|
|
48
48
|
hash: string;
|
|
49
|
-
tag?: string
|
|
49
|
+
tag?: string;
|
|
50
50
|
parents: string[];
|
|
51
|
-
profileImage?: string
|
|
52
|
-
onLane?: boolean
|
|
51
|
+
profileImage?: string;
|
|
52
|
+
onLane?: boolean;
|
|
53
53
|
}[]>;
|
|
54
54
|
};
|
|
55
55
|
ComponentHost: {
|
|
56
56
|
get: (host: ComponentFactory, { id }: {
|
|
57
57
|
id: string;
|
|
58
|
-
}) => Promise<Component
|
|
58
|
+
}) => Promise<Component>;
|
|
59
59
|
snaps: (host: ComponentFactory, { id }: {
|
|
60
60
|
id: string;
|
|
61
61
|
}) => Promise<import("@teambit/legacy-component-log").LegacyComponentLog[]>;
|
|
@@ -216,10 +216,7 @@ function componentSchema(componentExtension) {
|
|
|
216
216
|
mainFile: component => {
|
|
217
217
|
return component.state._consumer.mainFile;
|
|
218
218
|
},
|
|
219
|
-
headTag: component =>
|
|
220
|
-
var _component$headTag;
|
|
221
|
-
return (_component$headTag = component.headTag) === null || _component$headTag === void 0 ? void 0 : _component$headTag.toObject();
|
|
222
|
-
},
|
|
219
|
+
headTag: component => component.headTag?.toObject(),
|
|
223
220
|
latest: component => component.latest,
|
|
224
221
|
tags: component => {
|
|
225
222
|
// graphql doesn't support map types
|
|
@@ -231,8 +228,8 @@ function componentSchema(componentExtension) {
|
|
|
231
228
|
return component.state.aspects.filter(include).serialize();
|
|
232
229
|
},
|
|
233
230
|
logs: async (component, filter) => {
|
|
234
|
-
let head = filter
|
|
235
|
-
if (!head && filter
|
|
231
|
+
let head = filter?.head;
|
|
232
|
+
if (!head && filter?.takeHeadFromComponent) {
|
|
236
233
|
head = component.id.version;
|
|
237
234
|
}
|
|
238
235
|
const finalFilter = _objectSpread(_objectSpread({}, filter), {
|