Repository navigation
Expand file tree
/
Copy pathremote-config-schema.ts
More file actions
127 lines (118 loc) · 4.84 KB
/
Copy pathremote-config-schema.ts
File metadata and controls
127 lines (118 loc) · 4.84 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import {
PROVIDER_DEVICE_ORIENTATIONS,
PROVIDER_DEVICE_TYPES,
type RemoteConfigProfile,
} from '@agent-device/contracts/remote';
// Declared in contracts/ so zones below remote/ can be stated in terms of the profile vocabulary;
// re-exported here because this module is where consumers already import it from.
export type { RemoteConfigProfile } from '@agent-device/contracts/remote';
import { LEASE_BACKENDS } from '@agent-device/kernel/contracts';
import { buildPrimaryEnvVarName } from '@agent-device/kernel/source-value';
import { PLATFORM_SELECTORS } from '@agent-device/kernel/device';
export type RemoteConfigProfileOptions = {
configPath: string;
cwd: string;
env?: Record<string, string | undefined>;
};
export type ResolvedRemoteConfigProfile = {
resolvedPath: string;
profile: RemoteConfigProfile;
};
export type RemoteConfigFieldSpec = {
key: keyof RemoteConfigProfile;
type: 'string' | 'int' | 'boolean' | 'enum';
enumValues?: readonly string[];
min?: number;
max?: number;
path?: boolean;
env?: false;
};
export const REMOTE_CONFIG_FIELD_SPECS = [
{ key: 'stateDir', type: 'string', path: true },
{ key: 'daemonBaseUrl', type: 'string' },
{ key: 'daemonAuthToken', type: 'string' },
{ key: 'daemonTransport', type: 'enum', enumValues: ['auto', 'socket', 'http'] },
{ key: 'daemonServerMode', type: 'enum', enumValues: ['socket', 'http', 'dual'] },
{ key: 'tenant', type: 'string' },
{ key: 'sessionIsolation', type: 'enum', enumValues: ['none', 'tenant'] },
{ key: 'runId', type: 'string' },
{ key: 'leaseId', type: 'string' },
{ key: 'leaseBackend', type: 'enum', enumValues: LEASE_BACKENDS },
{ key: 'platform', type: 'enum', enumValues: PLATFORM_SELECTORS },
{ key: 'target', type: 'enum', enumValues: ['mobile', 'tv', 'desktop'] },
{ key: 'device', type: 'string' },
{ key: 'udid', type: 'string' },
{ key: 'serial', type: 'string' },
{
key: 'iosSimulatorDeviceSet',
type: 'string',
path: true,
env: false,
},
{ key: 'androidDeviceAllowlist', type: 'string' },
{ key: 'session', type: 'string' },
{ key: 'providerApp', type: 'string' },
{ key: 'providerOsVersion', type: 'string' },
{ key: 'providerDeviceType', type: 'enum', enumValues: PROVIDER_DEVICE_TYPES },
{ key: 'providerProject', type: 'string' },
{ key: 'providerBuild', type: 'string' },
{ key: 'providerSessionName', type: 'string' },
{
key: 'providerDeviceOrientation',
type: 'enum',
enumValues: PROVIDER_DEVICE_ORIENTATIONS,
},
{ key: 'providerGeoLocation', type: 'string' },
{ key: 'providerTimezone', type: 'string' },
{ key: 'providerAppiumVersion', type: 'string' },
{ key: 'providerLanguage', type: 'string' },
{ key: 'providerLocale', type: 'string' },
{ key: 'providerNetworkProfile', type: 'string' },
{ key: 'providerCustomNetwork', type: 'string' },
{ key: 'providerNoResignApp', type: 'boolean' },
{ key: 'awsProjectArn', type: 'string' },
{ key: 'awsDeviceArn', type: 'string' },
{ key: 'awsAppArn', type: 'string' },
{ key: 'awsRegion', type: 'string' },
{
key: 'awsInteractionMode',
type: 'enum',
enumValues: ['INTERACTIVE', 'NO_VIDEO', 'VIDEO_ONLY'],
},
{ key: 'metroProjectRoot', type: 'string', path: true },
{ key: 'metroKind', type: 'enum', enumValues: ['auto', 'react-native', 'expo', 'repack'] },
{ key: 'metroPublicBaseUrl', type: 'string' },
{ key: 'metroProxyBaseUrl', type: 'string' },
{ key: 'metroBearerToken', type: 'string' },
{ key: 'metroPreparePort', type: 'int', min: 1, max: 65535 },
{ key: 'metroListenHost', type: 'string' },
{ key: 'metroStatusHost', type: 'string' },
{ key: 'metroStartupTimeoutMs', type: 'int', min: 1 },
{ key: 'metroProbeTimeoutMs', type: 'int', min: 1 },
{ key: 'metroRuntimeFile', type: 'string', path: true },
{ key: 'metroNoReuseExisting', type: 'boolean' },
{ key: 'metroNoInstallDeps', type: 'boolean' },
{ key: 'launchUrl', type: 'string' },
] as const satisfies readonly RemoteConfigFieldSpec[];
const REMOTE_CONFIG_LEASE_FIELD_SPECS = [
{ key: 'leaseProvider', type: 'string', env: false },
{ key: 'deviceKey', type: 'string', env: false },
{ key: 'clientId', type: 'string', env: false },
] as const satisfies readonly RemoteConfigFieldSpec[];
export const REMOTE_CONFIG_PROFILE_FIELD_SPECS = [
...REMOTE_CONFIG_FIELD_SPECS,
...REMOTE_CONFIG_LEASE_FIELD_SPECS,
] as const satisfies readonly RemoteConfigFieldSpec[];
const remoteConfigFieldSpecByKey = new Map(
REMOTE_CONFIG_PROFILE_FIELD_SPECS.map((spec) => [spec.key, spec]),
);
export function getRemoteConfigFieldSpec(
key: keyof RemoteConfigProfile,
): RemoteConfigFieldSpec | undefined {
return remoteConfigFieldSpecByKey.get(key);
}
export function getRemoteConfigEnvNames(key: keyof RemoteConfigProfile): string[] {
const spec = getRemoteConfigFieldSpec(key);
if (spec?.env === false) return [];
return [buildPrimaryEnvVarName(key)];
}