summaryrefslogtreecommitdiff
path: root/src/jet/dependencies/object-graph.ts
blob: 40ad0a9735f6149e00e0ba0ac4722f753445fafe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { AppStoreObjectGraph } from '@jet-app/app-store/foundation/runtime/app-store-object-graph';
import { ObjectGraphType } from '@jet-app/app-store/gameservicesui/src/foundation/object-graph-types';

import type { Dependencies } from './make-dependencies';
import { WebFeatureFlags } from './feature-flags';
import { WebMediaTokenService } from './media-token-service';

export { ObjectGraphType };

class AppStoreWebObjectGraph extends AppStoreObjectGraph {
    /**
     * Configures the ObjectGraph from our `Dependencies` definition
     *
     * @param dependencies
     * @returns
     */
    configureWithDependencies(dependencies: Dependencies) {
        const {
            bag,
            client,
            console,
            host,
            locale,
            localization,
            metricsIdentifiers,
            net,
            properties,
            random,
            seo,
            storage,
            user,
        } = dependencies;

        return this.addingClient(client)
            .addingNetwork(net)
            .addingHost(host)
            .addingBag(bag)
            .addingLoc(localization)
            .addingMediaToken(new WebMediaTokenService())
            .addingConsole(console)
            .addingAppleSilicon(undefined)
            .addingProperties(properties)
            .addingLocale(locale)
            .addingUser(user)
            .addingFeatureFlags(new WebFeatureFlags())
            .addingMetricsIdentifiers(metricsIdentifiers)
            .addingSEO(seo)
            .addingStorage(storage)
            .addingRandom(random);
    }
}

export function makeObjectGraph(
    dependencies: Dependencies,
): AppStoreObjectGraph {
    const objectGraph = new AppStoreWebObjectGraph('app-store');

    return objectGraph.configureWithDependencies(dependencies);
}