@superblocksteam/shared 0.9545.1 → 0.9546.0
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/dist/jwt/verifier.d.ts +1 -0
- package/dist/jwt/verifier.d.ts.map +1 -1
- package/dist/jwt/verifier.js +4 -1
- package/dist/jwt/verifier.js.map +1 -1
- package/dist/plugins/templates/databricks.d.ts +1 -0
- package/dist/plugins/templates/databricks.d.ts.map +1 -1
- package/dist/plugins/templates/databricks.js +27 -3
- package/dist/plugins/templates/databricks.js.map +1 -1
- package/dist/plugins/templates/shared/sshtunnel.d.ts.map +1 -1
- package/dist/plugins/templates/shared/sshtunnel.js +0 -1
- package/dist/plugins/templates/shared/sshtunnel.js.map +1 -1
- package/dist/types/ai/index.d.ts +2 -0
- package/dist/types/ai/index.d.ts.map +1 -1
- package/dist/types/datasource/index.d.ts +14 -0
- package/dist/types/datasource/index.d.ts.map +1 -1
- package/dist/types/datasource/index.js +36 -2
- package/dist/types/datasource/index.js.map +1 -1
- package/dist/types/datasource/index.test.d.ts +2 -0
- package/dist/types/datasource/index.test.d.ts.map +1 -0
- package/dist/types/datasource/index.test.js +421 -0
- package/dist/types/datasource/index.test.js.map +1 -0
- package/dist/types/plugin/integration.d.ts +2 -1
- package/dist/types/plugin/integration.d.ts.map +1 -1
- package/dist/types/plugin/integration.js +3 -1
- package/dist/types/plugin/integration.js.map +1 -1
- package/dist-esm/jwt/verifier.d.ts +1 -0
- package/dist-esm/jwt/verifier.d.ts.map +1 -1
- package/dist-esm/jwt/verifier.js +4 -1
- package/dist-esm/jwt/verifier.js.map +1 -1
- package/dist-esm/plugins/templates/databricks.d.ts +1 -0
- package/dist-esm/plugins/templates/databricks.d.ts.map +1 -1
- package/dist-esm/plugins/templates/databricks.js +27 -3
- package/dist-esm/plugins/templates/databricks.js.map +1 -1
- package/dist-esm/plugins/templates/shared/sshtunnel.d.ts.map +1 -1
- package/dist-esm/plugins/templates/shared/sshtunnel.js +0 -1
- package/dist-esm/plugins/templates/shared/sshtunnel.js.map +1 -1
- package/dist-esm/types/ai/index.d.ts +2 -0
- package/dist-esm/types/ai/index.d.ts.map +1 -1
- package/dist-esm/types/datasource/index.d.ts +14 -0
- package/dist-esm/types/datasource/index.d.ts.map +1 -1
- package/dist-esm/types/datasource/index.js +33 -1
- package/dist-esm/types/datasource/index.js.map +1 -1
- package/dist-esm/types/datasource/index.test.d.ts +2 -0
- package/dist-esm/types/datasource/index.test.d.ts.map +1 -0
- package/dist-esm/types/datasource/index.test.js +419 -0
- package/dist-esm/types/datasource/index.test.js.map +1 -0
- package/dist-esm/types/plugin/integration.d.ts +2 -1
- package/dist-esm/types/plugin/integration.d.ts.map +1 -1
- package/dist-esm/types/plugin/integration.js +3 -1
- package/dist-esm/types/plugin/integration.js.map +1 -1
- package/package.json +2 -2
- package/src/jwt/verifier.ts +6 -1
- package/src/plugins/templates/databricks.ts +29 -3
- package/src/plugins/templates/shared/sshtunnel.ts +0 -1
- package/src/types/ai/index.ts +2 -0
- package/src/types/datasource/index.test.ts +499 -0
- package/src/types/datasource/index.ts +45 -1
- package/src/types/plugin/integration.ts +4 -2
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { IntegrationAuthType } from './auth.js';
|
|
2
|
+
import {
|
|
3
|
+
DatasourceConfiguration,
|
|
4
|
+
isAuthenticatedDatasourceConfig,
|
|
5
|
+
isAuthenticatedDatasourceConfigWithDynamicAuthType,
|
|
6
|
+
getAuthTypeFromConfig
|
|
7
|
+
} from './index.js';
|
|
8
|
+
|
|
9
|
+
describe('isAuthenticatedDatasourceConfig', () => {
|
|
10
|
+
test('returns true for config with authConfig and authType', () => {
|
|
11
|
+
const config: DatasourceConfiguration = {
|
|
12
|
+
name: 'test',
|
|
13
|
+
authConfig: {
|
|
14
|
+
clientId: 'test-client',
|
|
15
|
+
clientSecret: 'test-secret'
|
|
16
|
+
},
|
|
17
|
+
authType: IntegrationAuthType.OAUTH2_CODE
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('returns false for config with authConfig and authTypeField', () => {
|
|
24
|
+
const config: DatasourceConfiguration = {
|
|
25
|
+
name: 'test',
|
|
26
|
+
authConfig: {
|
|
27
|
+
clientId: 'test-client',
|
|
28
|
+
clientSecret: 'test-secret'
|
|
29
|
+
},
|
|
30
|
+
authTypeField: 'connectionType',
|
|
31
|
+
connectionType: 'fields' // This field must exist for the test to pass
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('returns false for config without authConfig', () => {
|
|
38
|
+
const config: DatasourceConfiguration = {
|
|
39
|
+
name: 'test',
|
|
40
|
+
authType: IntegrationAuthType.OAUTH2_CODE
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('returns false for config with authConfig but no authType or authTypeField', () => {
|
|
47
|
+
const config: DatasourceConfiguration = {
|
|
48
|
+
name: 'test',
|
|
49
|
+
authConfig: {
|
|
50
|
+
clientId: 'test-client',
|
|
51
|
+
clientSecret: 'test-secret'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('returns false for config with authType but no authConfig', () => {
|
|
59
|
+
const config: DatasourceConfiguration = {
|
|
60
|
+
name: 'test',
|
|
61
|
+
authType: IntegrationAuthType.OAUTH2_CODE
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('returns false for config with authTypeField but no authConfig', () => {
|
|
68
|
+
const config: DatasourceConfiguration = {
|
|
69
|
+
name: 'test',
|
|
70
|
+
authTypeField: 'connectionType'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('returns false for empty config', () => {
|
|
77
|
+
const config: DatasourceConfiguration = {
|
|
78
|
+
name: 'test'
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('returns true for config with authConfig and both authType and authTypeField', () => {
|
|
85
|
+
const config: DatasourceConfiguration = {
|
|
86
|
+
name: 'test',
|
|
87
|
+
authConfig: {
|
|
88
|
+
clientId: 'test-client',
|
|
89
|
+
clientSecret: 'test-secret'
|
|
90
|
+
},
|
|
91
|
+
authType: IntegrationAuthType.OAUTH2_CODE,
|
|
92
|
+
authTypeField: 'connectionType',
|
|
93
|
+
connectionType: 'fields' // This field must exist for the test to pass
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('returns false for config with authConfig but empty authTypeField', () => {
|
|
100
|
+
const config: DatasourceConfiguration = {
|
|
101
|
+
name: 'test',
|
|
102
|
+
authConfig: {
|
|
103
|
+
clientId: 'test-client',
|
|
104
|
+
clientSecret: 'test-secret'
|
|
105
|
+
},
|
|
106
|
+
authTypeField: ''
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('returns false for config with authConfig but undefined authTypeField', () => {
|
|
113
|
+
const config: DatasourceConfiguration = {
|
|
114
|
+
name: 'test',
|
|
115
|
+
authConfig: {
|
|
116
|
+
clientId: 'test-client',
|
|
117
|
+
clientSecret: 'test-secret'
|
|
118
|
+
},
|
|
119
|
+
authTypeField: undefined
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('returns false for config with authConfig but authTypeField pointing to non-existent field', () => {
|
|
126
|
+
const config: DatasourceConfiguration = {
|
|
127
|
+
name: 'test',
|
|
128
|
+
authConfig: {
|
|
129
|
+
clientId: 'test-client',
|
|
130
|
+
clientSecret: 'test-secret'
|
|
131
|
+
},
|
|
132
|
+
authTypeField: 'nonExistentField'
|
|
133
|
+
// nonExistentField is not defined in the config
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('returns false for config with authConfig but undefined authTypeField', () => {
|
|
140
|
+
const config: DatasourceConfiguration = {
|
|
141
|
+
name: 'test',
|
|
142
|
+
authConfig: {
|
|
143
|
+
clientId: 'test-client',
|
|
144
|
+
clientSecret: 'test-secret'
|
|
145
|
+
},
|
|
146
|
+
authTypeField: undefined
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('returns false for config with authConfig and authTypeField pointing to undefined field', () => {
|
|
153
|
+
const config: DatasourceConfiguration = {
|
|
154
|
+
name: 'test',
|
|
155
|
+
authConfig: {
|
|
156
|
+
clientId: 'test-client',
|
|
157
|
+
clientSecret: 'test-secret'
|
|
158
|
+
},
|
|
159
|
+
authTypeField: 'connectionType'
|
|
160
|
+
// connectionType is not defined, so it's undefined
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('returns false for config with authConfig and authTypeField pointing to undefined field', () => {
|
|
167
|
+
const config: DatasourceConfiguration = {
|
|
168
|
+
name: 'test',
|
|
169
|
+
authConfig: {
|
|
170
|
+
clientId: 'test-client',
|
|
171
|
+
clientSecret: 'test-secret'
|
|
172
|
+
},
|
|
173
|
+
authTypeField: 'connectionType',
|
|
174
|
+
connectionType: undefined
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
expect(isAuthenticatedDatasourceConfig(config)).toBe(false);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe('isAuthenticatedDatasourceConfigWithDynamicAuthType', () => {
|
|
182
|
+
test('returns true for config with authConfig and valid authTypeField', () => {
|
|
183
|
+
const config = {
|
|
184
|
+
name: 'test',
|
|
185
|
+
authConfig: {
|
|
186
|
+
clientId: 'test-client',
|
|
187
|
+
clientSecret: 'test-secret'
|
|
188
|
+
},
|
|
189
|
+
authTypeField: 'connectionType',
|
|
190
|
+
connectionType: 'oauth2'
|
|
191
|
+
} as DatasourceConfiguration;
|
|
192
|
+
|
|
193
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('returns true for config with authConfig and authTypeField pointing to non-empty string', () => {
|
|
197
|
+
const config = {
|
|
198
|
+
name: 'test',
|
|
199
|
+
authConfig: {
|
|
200
|
+
clientId: 'test-client',
|
|
201
|
+
clientSecret: 'test-secret'
|
|
202
|
+
},
|
|
203
|
+
authTypeField: 'authMethod',
|
|
204
|
+
authMethod: 'api_key'
|
|
205
|
+
} as DatasourceConfiguration;
|
|
206
|
+
|
|
207
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('returns false for config without authConfig', () => {
|
|
211
|
+
const config = {
|
|
212
|
+
name: 'test',
|
|
213
|
+
authTypeField: 'connectionType',
|
|
214
|
+
connectionType: 'oauth2'
|
|
215
|
+
} as DatasourceConfiguration;
|
|
216
|
+
|
|
217
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test('returns false for config with authConfig but no authTypeField', () => {
|
|
221
|
+
const config: DatasourceConfiguration = {
|
|
222
|
+
name: 'test',
|
|
223
|
+
authConfig: {
|
|
224
|
+
clientId: 'test-client',
|
|
225
|
+
clientSecret: 'test-secret'
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test('returns false for config with authConfig and empty authTypeField', () => {
|
|
233
|
+
const config = {
|
|
234
|
+
name: 'test',
|
|
235
|
+
authConfig: {
|
|
236
|
+
clientId: 'test-client',
|
|
237
|
+
clientSecret: 'test-secret'
|
|
238
|
+
},
|
|
239
|
+
authTypeField: '',
|
|
240
|
+
connectionType: 'oauth2'
|
|
241
|
+
} as DatasourceConfiguration;
|
|
242
|
+
|
|
243
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('returns false for config with authConfig and undefined authTypeField', () => {
|
|
247
|
+
const config = {
|
|
248
|
+
name: 'test',
|
|
249
|
+
authConfig: {
|
|
250
|
+
clientId: 'test-client',
|
|
251
|
+
clientSecret: 'test-secret'
|
|
252
|
+
},
|
|
253
|
+
authTypeField: undefined,
|
|
254
|
+
connectionType: 'oauth2'
|
|
255
|
+
} as DatasourceConfiguration;
|
|
256
|
+
|
|
257
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test('returns false for config with authConfig and authTypeField pointing to undefined field', () => {
|
|
261
|
+
const config = {
|
|
262
|
+
name: 'test',
|
|
263
|
+
authConfig: {
|
|
264
|
+
clientId: 'test-client',
|
|
265
|
+
clientSecret: 'test-secret'
|
|
266
|
+
},
|
|
267
|
+
authTypeField: 'connectionType'
|
|
268
|
+
// connectionType is not defined
|
|
269
|
+
} as DatasourceConfiguration;
|
|
270
|
+
|
|
271
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test('returns false for config with authConfig and authTypeField pointing to null field', () => {
|
|
275
|
+
const config = {
|
|
276
|
+
name: 'test',
|
|
277
|
+
authConfig: {
|
|
278
|
+
clientId: 'test-client',
|
|
279
|
+
clientSecret: 'test-secret'
|
|
280
|
+
},
|
|
281
|
+
authTypeField: 'connectionType',
|
|
282
|
+
connectionType: null
|
|
283
|
+
} as DatasourceConfiguration;
|
|
284
|
+
|
|
285
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test('returns false for config with authConfig and authTypeField pointing to empty string', () => {
|
|
289
|
+
const config = {
|
|
290
|
+
name: 'test',
|
|
291
|
+
authConfig: {
|
|
292
|
+
clientId: 'test-client',
|
|
293
|
+
clientSecret: 'test-secret'
|
|
294
|
+
},
|
|
295
|
+
authTypeField: 'connectionType',
|
|
296
|
+
connectionType: ''
|
|
297
|
+
} as DatasourceConfiguration;
|
|
298
|
+
|
|
299
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test('returns true for config with authConfig and authTypeField pointing to zero', () => {
|
|
303
|
+
const config = {
|
|
304
|
+
name: 'test',
|
|
305
|
+
authConfig: {
|
|
306
|
+
clientId: 'test-client',
|
|
307
|
+
clientSecret: 'test-secret'
|
|
308
|
+
},
|
|
309
|
+
authTypeField: 'connectionType',
|
|
310
|
+
connectionType: 0
|
|
311
|
+
} as DatasourceConfiguration;
|
|
312
|
+
|
|
313
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('returns true for config with authConfig and authTypeField pointing to false', () => {
|
|
317
|
+
const config = {
|
|
318
|
+
name: 'test',
|
|
319
|
+
authConfig: {
|
|
320
|
+
clientId: 'test-client',
|
|
321
|
+
clientSecret: 'test-secret'
|
|
322
|
+
},
|
|
323
|
+
authTypeField: 'connectionType',
|
|
324
|
+
connectionType: false
|
|
325
|
+
} as DatasourceConfiguration;
|
|
326
|
+
|
|
327
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
test('returns true for config with authConfig and authTypeField pointing to object', () => {
|
|
331
|
+
const config = {
|
|
332
|
+
name: 'test',
|
|
333
|
+
authConfig: {
|
|
334
|
+
clientId: 'test-client',
|
|
335
|
+
clientSecret: 'test-secret'
|
|
336
|
+
},
|
|
337
|
+
authTypeField: 'connectionType',
|
|
338
|
+
connectionType: { type: 'oauth2' }
|
|
339
|
+
} as DatasourceConfiguration;
|
|
340
|
+
|
|
341
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
test('returns true for config with authConfig and authTypeField pointing to array', () => {
|
|
345
|
+
const config = {
|
|
346
|
+
name: 'test',
|
|
347
|
+
authConfig: {
|
|
348
|
+
clientId: 'test-client',
|
|
349
|
+
clientSecret: 'test-secret'
|
|
350
|
+
},
|
|
351
|
+
authTypeField: 'connectionType',
|
|
352
|
+
connectionType: ['oauth2', 'api_key']
|
|
353
|
+
} as DatasourceConfiguration;
|
|
354
|
+
|
|
355
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
test('returns false for empty config', () => {
|
|
359
|
+
const config: DatasourceConfiguration = {
|
|
360
|
+
name: 'test'
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
test('returns false for config with authConfig but authTypeField pointing to non-existent field', () => {
|
|
367
|
+
const config = {
|
|
368
|
+
name: 'test',
|
|
369
|
+
authConfig: {
|
|
370
|
+
clientId: 'test-client',
|
|
371
|
+
clientSecret: 'test-secret'
|
|
372
|
+
},
|
|
373
|
+
authTypeField: 'nonExistentField'
|
|
374
|
+
// nonExistentField is not defined in the config
|
|
375
|
+
} as DatasourceConfiguration;
|
|
376
|
+
|
|
377
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(false);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test('returns true for config with authConfig and authTypeField pointing to numeric value', () => {
|
|
381
|
+
const config = {
|
|
382
|
+
name: 'test',
|
|
383
|
+
authConfig: {
|
|
384
|
+
clientId: 'test-client',
|
|
385
|
+
clientSecret: 'test-secret'
|
|
386
|
+
},
|
|
387
|
+
authTypeField: 'connectionType',
|
|
388
|
+
connectionType: 42
|
|
389
|
+
} as DatasourceConfiguration;
|
|
390
|
+
|
|
391
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test('returns true for config with authConfig and authTypeField pointing to boolean true', () => {
|
|
395
|
+
const config = {
|
|
396
|
+
name: 'test',
|
|
397
|
+
authConfig: {
|
|
398
|
+
clientId: 'test-client',
|
|
399
|
+
clientSecret: 'test-secret'
|
|
400
|
+
},
|
|
401
|
+
authTypeField: 'connectionType',
|
|
402
|
+
connectionType: true
|
|
403
|
+
} as DatasourceConfiguration;
|
|
404
|
+
|
|
405
|
+
expect(isAuthenticatedDatasourceConfigWithDynamicAuthType(config)).toBe(true);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
describe('getAuthTypeFromConfig', () => {
|
|
410
|
+
test('returns authType for config with direct authType field', () => {
|
|
411
|
+
const config: DatasourceConfiguration = {
|
|
412
|
+
name: 'test',
|
|
413
|
+
authConfig: {
|
|
414
|
+
clientId: 'test-client',
|
|
415
|
+
clientSecret: 'test-secret'
|
|
416
|
+
},
|
|
417
|
+
authType: IntegrationAuthType.OAUTH2_CODE
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
expect(getAuthTypeFromConfig(config)).toBe(IntegrationAuthType.OAUTH2_CODE);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
test('returns authType for config with authTypeField pointing to valid field', () => {
|
|
424
|
+
const config: DatasourceConfiguration = {
|
|
425
|
+
name: 'test',
|
|
426
|
+
authConfig: {
|
|
427
|
+
clientId: 'test-client',
|
|
428
|
+
clientSecret: 'test-secret'
|
|
429
|
+
},
|
|
430
|
+
authTypeField: 'connectionType',
|
|
431
|
+
connectionType: 'fields'
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
expect(getAuthTypeFromConfig(config)).toBe('fields');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test('returns undefined for non-authenticated config', () => {
|
|
438
|
+
const config: DatasourceConfiguration = {
|
|
439
|
+
name: 'test'
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
expect(getAuthTypeFromConfig(config)).toBe(undefined);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test('returns undefined for config with authConfig but no authType or authTypeField', () => {
|
|
446
|
+
const config: DatasourceConfiguration = {
|
|
447
|
+
name: 'test',
|
|
448
|
+
authConfig: {
|
|
449
|
+
clientId: 'test-client',
|
|
450
|
+
clientSecret: 'test-secret'
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
expect(getAuthTypeFromConfig(config)).toBe(undefined);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
test('returns undefined for config with authTypeField pointing to undefined field', () => {
|
|
458
|
+
const config: DatasourceConfiguration = {
|
|
459
|
+
name: 'test',
|
|
460
|
+
authConfig: {
|
|
461
|
+
clientId: 'test-client',
|
|
462
|
+
clientSecret: 'test-secret'
|
|
463
|
+
},
|
|
464
|
+
authTypeField: 'connectionType'
|
|
465
|
+
// connectionType is not defined
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
expect(getAuthTypeFromConfig(config)).toBe(undefined);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
test('returns undefined for config with authTypeField pointing to undefined field', () => {
|
|
472
|
+
const config: DatasourceConfiguration = {
|
|
473
|
+
name: 'test',
|
|
474
|
+
authConfig: {
|
|
475
|
+
clientId: 'test-client',
|
|
476
|
+
clientSecret: 'test-secret'
|
|
477
|
+
},
|
|
478
|
+
authTypeField: 'connectionType',
|
|
479
|
+
connectionType: undefined
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
expect(getAuthTypeFromConfig(config)).toBe(undefined);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
test('prioritizes direct authType over authTypeField', () => {
|
|
486
|
+
const config: DatasourceConfiguration = {
|
|
487
|
+
name: 'test',
|
|
488
|
+
authConfig: {
|
|
489
|
+
clientId: 'test-client',
|
|
490
|
+
clientSecret: 'test-secret'
|
|
491
|
+
},
|
|
492
|
+
authType: IntegrationAuthType.OAUTH2_CODE,
|
|
493
|
+
authTypeField: 'connectionType',
|
|
494
|
+
connectionType: 'fields'
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
expect(getAuthTypeFromConfig(config)).toBe(IntegrationAuthType.OAUTH2_CODE);
|
|
498
|
+
});
|
|
499
|
+
});
|
|
@@ -253,7 +253,51 @@ export type AuthenticatedDatasourceConfig = BaseDatasourceConfiguration & {
|
|
|
253
253
|
};
|
|
254
254
|
|
|
255
255
|
export function isAuthenticatedDatasourceConfig(dc: DatasourceConfiguration): dc is AuthenticatedDatasourceConfig {
|
|
256
|
-
|
|
256
|
+
if (!('authConfig' in dc)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return 'authType' in dc && dc.authType !== undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export type AuthenticatedDatasourceConfigWithDynamicAuthType = BaseDatasourceConfiguration & {
|
|
264
|
+
authConfig?: AuthConfig;
|
|
265
|
+
authTypeField: string;
|
|
266
|
+
[key: string]: string | AuthConfig | undefined;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export function isAuthenticatedDatasourceConfigWithDynamicAuthType(
|
|
270
|
+
dc: DatasourceConfiguration
|
|
271
|
+
): dc is AuthenticatedDatasourceConfigWithDynamicAuthType {
|
|
272
|
+
if (!('authConfig' in dc)) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
if (
|
|
276
|
+
'authTypeField' in dc &&
|
|
277
|
+
dc.authTypeField &&
|
|
278
|
+
dc[dc.authTypeField] !== undefined &&
|
|
279
|
+
dc[dc.authTypeField] !== null &&
|
|
280
|
+
dc[dc.authTypeField] !== ''
|
|
281
|
+
) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Safely extracts the authType from an authenticated datasource configuration.
|
|
289
|
+
* This function handles both direct authType fields and authTypeField references.
|
|
290
|
+
*
|
|
291
|
+
* @param dc - The datasource configuration
|
|
292
|
+
* @returns The authType if available, undefined otherwise
|
|
293
|
+
*/
|
|
294
|
+
export function getAuthTypeFromConfig(dc: DatasourceConfiguration): AuthType | undefined {
|
|
295
|
+
if (isAuthenticatedDatasourceConfig(dc)) {
|
|
296
|
+
return dc.authType;
|
|
297
|
+
} else if (isAuthenticatedDatasourceConfigWithDynamicAuthType(dc)) {
|
|
298
|
+
return dc[dc.authTypeField] as AuthType;
|
|
299
|
+
}
|
|
300
|
+
return undefined;
|
|
257
301
|
}
|
|
258
302
|
|
|
259
303
|
export type GraphQLDatasourceConfiguration = AuthenticatedHttpDatasourceConfig & {
|
|
@@ -46,7 +46,8 @@ export enum ExtendedIntegrationPluginId {
|
|
|
46
46
|
OPENAI_V2 = 'openai_v2',
|
|
47
47
|
// Not native OpenAPI-backed integrations, but leveraging the same auth system
|
|
48
48
|
GOOGLE_SHEETS_PLUGIN_ID = 'gsheets',
|
|
49
|
-
SNOWFLAKE = 'snowflake'
|
|
49
|
+
SNOWFLAKE = 'snowflake',
|
|
50
|
+
DATABRICKS = 'databricks'
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
// Note that we cannot import the plugins themselves to reference the id as
|
|
@@ -121,7 +122,8 @@ export const extendsAnyApiIntegrationPlugin = (pluginId = ''): boolean => {
|
|
|
121
122
|
return (
|
|
122
123
|
getBasePluginId(pluginId) === ExtendedIntegrationPluginId.REST_API ||
|
|
123
124
|
pluginId === ExtendedIntegrationPluginId.GRAPHQL ||
|
|
124
|
-
pluginId === ExtendedIntegrationPluginId.SNOWFLAKE
|
|
125
|
+
pluginId === ExtendedIntegrationPluginId.SNOWFLAKE ||
|
|
126
|
+
pluginId === ExtendedIntegrationPluginId.DATABRICKS
|
|
125
127
|
);
|
|
126
128
|
};
|
|
127
129
|
|