-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathintegrations.model.ts
More file actions
143 lines (129 loc) · 4.53 KB
/
integrations.model.ts
File metadata and controls
143 lines (129 loc) · 4.53 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import {
Document as DocumentResolverType,
IntegrationType,
} from '../../../../../__generated__/resolvers-types';
import Document from '../../../../../model/kanel/public/Document';
import type { ServiceInstanceId } from '../../../../../model/kanel/public/ServiceInstance';
import { MetadataArray } from '../../../../../utils/metadata';
export const INTEGRATION_SERVICE_INSTANCE_ID: ServiceInstanceId =
'0f4aad4b-bdd6-4084-8b1f-82c9c66578cc' as ServiceInstanceId;
export const OPENCTI_INTEGRATION_DOCUMENT_TYPE = 'opencti_integration';
export const isIntegrationType = (
maybeIntegrationType: string
): maybeIntegrationType is IntegrationType => {
return (Object.values(IntegrationType) as string[]).includes(
maybeIntegrationType
);
};
export type Integration = Document & {
integration_type: IntegrationType;
datasheet_url?: string;
demo_url?: string;
};
export type CsvFeed = Integration & {
feed_url: string;
};
export type TaxiiFeed = Integration & {
feed_url: string;
integration_subtype: string;
};
export type Stream = Integration & {
feed_url: string;
integration_subtype: string;
};
export type ThirdPartyIntegration = Integration & {
integration_subtype: string;
vendor_url: string;
github_url?: string;
product_version?: string;
};
export type Connector = Integration & {
product_version: string;
container_image?: string | null; // Docker/container identifier
verified: boolean;
source_code?: string | null; // URL to repository
subscription_link?: string | null; // URL to subscription page
integration_subtype: string;
manager_supported: boolean;
playbook_supported: boolean;
};
export type CsvFeedMetadata = MetadataArray<
Exclude<keyof Omit<CsvFeed, 'use_cases'>, keyof DocumentResolverType>
>;
export type TaxiiFeedMetadata = MetadataArray<
Exclude<keyof Omit<TaxiiFeed, 'use_cases'>, keyof DocumentResolverType>
>;
export type StreamFeedMetadata = MetadataArray<
Exclude<keyof Omit<Stream, 'use_cases'>, keyof DocumentResolverType>
>;
export type ThirdPartyIntegrationMetadata = MetadataArray<
Exclude<
keyof Omit<ThirdPartyIntegration, 'use_cases'>,
keyof DocumentResolverType
>
>;
export type ConnectorMetadata = MetadataArray<
Exclude<keyof Omit<Connector, 'use_cases'>, keyof DocumentResolverType>
>;
export const INTEGRATION_CSV_FEED_METADATA: CsvFeedMetadata = [
{ key: 'feed_url' },
{ key: 'integration_type' },
{ key: 'datasheet_url', optional: true },
{ key: 'demo_url', optional: true },
];
export const INTEGRATION_CSV_FEED_METADATA_KEYS =
INTEGRATION_CSV_FEED_METADATA.map(({ key }) => key);
export const INTEGRATION_TAXII_FEED_METADATA: TaxiiFeedMetadata = [
{ key: 'feed_url' },
{ key: 'integration_type' },
{ key: 'integration_subtype' },
{ key: 'datasheet_url', optional: true },
{ key: 'demo_url', optional: true },
];
export const INTEGRATION_TAXII_FEED_METADATA_KEYS =
INTEGRATION_TAXII_FEED_METADATA.map(({ key }) => key);
export const INTEGRATION_STREAM_METADATA: StreamFeedMetadata = [
{ key: 'feed_url' },
{ key: 'integration_type' },
{ key: 'integration_subtype' },
{ key: 'datasheet_url', optional: true },
{ key: 'demo_url', optional: true },
];
export const INTEGRATION_STREAM_METADATA_KEYS = INTEGRATION_STREAM_METADATA.map(
({ key }) => key
);
export const INTEGRATION_THIRD_PARTY_INTEGRATION_METADATA: ThirdPartyIntegrationMetadata =
[
{ key: 'integration_subtype' },
{ key: 'product_version', optional: true },
{ key: 'vendor_url' },
{ key: 'github_url', optional: true },
{ key: 'datasheet_url', optional: true },
{ key: 'demo_url', optional: true },
];
export const INTEGRATION_THIRD_PARTY_INTEGRATION_METADATA_KEYS =
INTEGRATION_THIRD_PARTY_INTEGRATION_METADATA.map(({ key }) => key);
export const INTEGRATION_CONNECTOR_METADATA: ConnectorMetadata = [
{ key: 'product_version' },
{ key: 'container_image' },
{ key: 'verified' },
{ key: 'source_code' },
{ key: 'subscription_link' },
{ key: 'integration_subtype' },
{ key: 'integration_type' },
{ key: 'manager_supported' },
{ key: 'playbook_supported' },
{ key: 'datasheet_url', optional: true },
{ key: 'demo_url', optional: true },
];
export const INTEGRATION_CONNECTOR_METADATA_KEYS =
INTEGRATION_CONNECTOR_METADATA.map(({ key }) => key);
export const INTEGRATION_METADATA_KEYS: string[] = Array.from(
new Set([
...INTEGRATION_CSV_FEED_METADATA_KEYS,
...INTEGRATION_TAXII_FEED_METADATA_KEYS,
...INTEGRATION_CONNECTOR_METADATA_KEYS,
...INTEGRATION_STREAM_METADATA_KEYS,
...INTEGRATION_THIRD_PARTY_INTEGRATION_METADATA_KEYS,
])
);