-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcompiled_types.ts
208 lines (192 loc) · 7.76 KB
/
compiled_types.ts
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import type {AWSAccessKeyAuthentication} from './types';
import type {AWSAssumeRoleAuthentication} from './types';
import type {Authentication} from './types';
import type {AuthenticationType} from './types';
import type {CodaApiBearerTokenAuthentication} from './types';
import type {CustomAuthentication} from './types';
import type {CustomHeaderTokenAuthentication} from './types';
import type {DistributiveOmit} from './type_utils';
import type {Format} from './types';
import type {GoogleDomainWideDelegationAuthentication} from './types';
import type {GoogleServiceAccountAuthentication} from './types';
import type {HeaderBearerTokenAuthentication} from './types';
import type {MetadataFormulaMetadata} from './api';
import type {MultiHeaderTokenAuthentication} from './types';
import type {MultiQueryParamTokenAuthentication} from './types';
import type {NoAuthentication} from './types';
import type {OAuth2Authentication} from './types';
import type {OAuth2ClientCredentialsAuthentication} from './types';
import type {ObjectPackFormulaMetadata} from './api';
import type {PackDefinition} from './types';
import type {PackFormulaMetadata} from './api';
import type {PackVersionDefinition} from './types';
import type {PostSetup} from './types';
import type {QueryParamTokenAuthentication} from './types';
import type {SyncTable} from './api';
import type {VariousAuthentication} from './types';
import type {WebBasicAuthentication} from './types';
// TODO(jonathan): Anything in this file that gets exported in index.ts should probably
// be removed from there and put into a separate entrypoint. These types should
// only need to be used by `coda` code that handles implementation and rendering
// of pack listings.
/** @hidden */
export type PackSyncTable = Omit<
SyncTable,
'getter' | 'getName' | 'getSchema' | 'listDynamicUrls' | 'searchDynamicUrls' | 'getDisplayUrl'
> & {
getter: PackFormulaMetadata;
isDynamic?: boolean;
hasDynamicSchema?: boolean;
getSchema?: MetadataFormulaMetadata;
getName?: MetadataFormulaMetadata;
getDisplayUrl?: MetadataFormulaMetadata;
listDynamicUrls?: MetadataFormulaMetadata;
searchDynamicUrls?: MetadataFormulaMetadata;
};
/** @hidden */
export interface PackFormatMetadata extends Omit<Format, 'matchers'> {
matchers: string[];
}
/** @hidden */
export type PostSetupMetadata = Omit<PostSetup, 'getOptions' | 'getOptionsFormula'> & {
getOptions?: MetadataFormulaMetadata; // TODO(packs-dev): Make this required after migration.
getOptionsFormula?: MetadataFormulaMetadata;
};
/** @hidden */
export type AuthenticationMetadata = DistributiveOmit<
Authentication,
'getConnectionName' | 'getConnectionUserId' | 'postSetup'
> & {
getConnectionName?: MetadataFormulaMetadata;
getConnectionUserId?: MetadataFormulaMetadata;
postSetup?: PostSetupMetadata[];
};
/** @hidden */
type AuthenticationToMetadata<T extends Authentication> = DistributiveOmit<
T,
'getConnectionName' | 'getConnectionUserId' | 'postSetup'
> & {
getConnectionName?: MetadataFormulaMetadata;
getConnectionUserId?: MetadataFormulaMetadata;
postSetup?: PostSetupMetadata[];
};
/** @hidden */
export interface AuthenticationMetadataTypeMap {
[AuthenticationType.AWSAccessKey]: AuthenticationToMetadata<AWSAccessKeyAuthentication>;
[AuthenticationType.AWSAssumeRole]: AuthenticationToMetadata<AWSAssumeRoleAuthentication>;
[AuthenticationType.CodaApiHeaderBearerToken]: AuthenticationToMetadata<CodaApiBearerTokenAuthentication>;
[AuthenticationType.CustomHeaderToken]: AuthenticationToMetadata<CustomHeaderTokenAuthentication>;
[AuthenticationType.MultiHeaderToken]: AuthenticationToMetadata<MultiHeaderTokenAuthentication>;
[AuthenticationType.Custom]: AuthenticationToMetadata<CustomAuthentication>;
[AuthenticationType.HeaderBearerToken]: AuthenticationToMetadata<HeaderBearerTokenAuthentication>;
[AuthenticationType.MultiQueryParamToken]: AuthenticationToMetadata<MultiQueryParamTokenAuthentication>;
[AuthenticationType.None]: AuthenticationToMetadata<NoAuthentication>;
[AuthenticationType.QueryParamToken]: AuthenticationToMetadata<QueryParamTokenAuthentication>;
[AuthenticationType.Various]: AuthenticationToMetadata<VariousAuthentication>;
[AuthenticationType.WebBasic]: AuthenticationToMetadata<WebBasicAuthentication>;
[AuthenticationType.OAuth2]: AuthenticationToMetadata<OAuth2Authentication>;
[AuthenticationType.OAuth2ClientCredentials]: AuthenticationToMetadata<OAuth2ClientCredentialsAuthentication>;
[AuthenticationType.GoogleDomainWideDelegation]: AuthenticationToMetadata<GoogleDomainWideDelegationAuthentication>;
[AuthenticationType.GoogleServiceAccount]: AuthenticationToMetadata<GoogleServiceAccountAuthentication>;
}
// Stripped-down version of `PackVersionDefinition` that doesn't contain formula definitions.
/** @hidden */
export type PackVersionMetadata = Omit<
PackVersionDefinition,
'formulas' | 'formats' | 'defaultAuthentication' | 'syncTables'
> & {
formulas: PackFormulaMetadata[];
formats: PackFormatMetadata[];
syncTables: PackSyncTable[];
defaultAuthentication?: AuthenticationMetadata;
};
// Stripped-down version of `PackDefinition` that doesn't contain formula definitions.
/** @hidden */
export type PackMetadata = PackVersionMetadata &
Pick<
PackDefinition,
| 'id'
| 'name'
| 'shortDescription'
| 'description'
| 'permissionsDescription'
| 'category'
| 'logoPath'
| 'exampleImages'
| 'exampleVideoIds'
| 'minimumFeatureSet'
| 'quotas'
| 'rateLimits'
| 'isSystem'
>;
// Re-exported values for use in browser code.
/** @hidden */
export type ExternalPackAuthenticationType = AuthenticationType;
/** @hidden */
export type ExternalPackFormulas = PackFormulaMetadata[];
/** @hidden */
export type ExternalObjectPackFormula = ObjectPackFormulaMetadata;
/** @hidden */
export type ExternalPackFormula = PackFormulaMetadata;
/** @hidden */
export type ExternalPackFormat = Omit<Format, 'matchers'> & {matchers?: string[]};
/** @hidden */
export type ExternalPackFormatMetadata = PackFormatMetadata;
/** @hidden */
export type ExternalSyncTable = PackSyncTable;
type BasePackVersionMetadata = Omit<
PackVersionMetadata,
'defaultAuthentication' | 'systemConnectionAuthentication' | 'formulas' | 'formats' | 'syncTables'
>;
// Further stripped-down version of `PackVersionMetadata` that contains only what the browser needs.
/** @hidden */
export interface ExternalPackVersionMetadata extends BasePackVersionMetadata {
authentication: {
type: ExternalPackAuthenticationType;
params?: Array<{name: string; description: string}>;
requiresEndpointUrl: boolean;
endpointDomain?: string;
postSetup?: PostSetupMetadata[];
deferConnectionSetup?: boolean;
shouldAutoAuthSetup?: boolean;
oauthScopes?: string[];
oauthAuthorizationUrl?: string;
oauthTokenUrl?: string;
networkDomain?: string | string[];
endpointKey?: string;
};
instructionsUrl?: string;
// User-facing components
formulas?: ExternalPackFormulas;
formats?: ExternalPackFormat[];
syncTables?: ExternalSyncTable[];
}
// Further stripped-down version of `PackMetadata` that contains only what the browser needs.
/** @hidden */
export type ExternalPackMetadata = ExternalPackVersionMetadata &
Pick<
PackMetadata,
| 'id'
| 'name'
| 'shortDescription'
| 'description'
| 'permissionsDescription'
| 'category'
| 'logoPath'
| 'exampleImages'
| 'exampleVideoIds'
| 'minimumFeatureSet'
| 'quotas'
| 'rateLimits'
| 'isSystem'
>;
/** @hidden */
export interface PackUpload {
// PackMetadata is only for legacy packs. This should be removed once
// all the feature's we're relying on from legacy pack defs like quotas
// have been migrated or retired.
metadata: PackVersionMetadata | PackMetadata;
sdkVersion: string;
bundle: string;
sourceMap: string;
}