@api-client/core 0.12.3 → 0.12.4

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.
Files changed (56) hide show
  1. package/build/src/browser.d.ts +2 -0
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +2 -0
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/events/BaseEvents.d.ts +11 -1
  6. package/build/src/events/BaseEvents.d.ts.map +1 -1
  7. package/build/src/events/BaseEvents.js.map +1 -1
  8. package/build/src/index.d.ts +2 -0
  9. package/build/src/index.d.ts.map +1 -1
  10. package/build/src/index.js +2 -0
  11. package/build/src/index.js.map +1 -1
  12. package/build/src/modeling/DomainVersioning.d.ts +2 -2
  13. package/build/src/modeling/DomainVersioning.d.ts.map +1 -1
  14. package/build/src/modeling/DomainVersioning.js +16 -1
  15. package/build/src/modeling/DomainVersioning.js.map +1 -1
  16. package/build/src/models/DataCatalog.d.ts +142 -0
  17. package/build/src/models/DataCatalog.d.ts.map +1 -0
  18. package/build/src/models/DataCatalog.js +120 -0
  19. package/build/src/models/DataCatalog.js.map +1 -0
  20. package/build/src/models/DataCatalogVersion.d.ts +123 -0
  21. package/build/src/models/DataCatalogVersion.d.ts.map +1 -0
  22. package/build/src/models/DataCatalogVersion.js +118 -0
  23. package/build/src/models/DataCatalogVersion.js.map +1 -0
  24. package/build/src/models/kinds.d.ts +2 -0
  25. package/build/src/models/kinds.d.ts.map +1 -1
  26. package/build/src/models/kinds.js +2 -0
  27. package/build/src/models/kinds.js.map +1 -1
  28. package/build/src/runtime/store/DataCatalogSdk.d.ts +46 -0
  29. package/build/src/runtime/store/DataCatalogSdk.d.ts.map +1 -0
  30. package/build/src/runtime/store/DataCatalogSdk.js +425 -0
  31. package/build/src/runtime/store/DataCatalogSdk.js.map +1 -0
  32. package/build/src/runtime/store/RouteBuilder.d.ts +10 -0
  33. package/build/src/runtime/store/RouteBuilder.d.ts.map +1 -1
  34. package/build/src/runtime/store/RouteBuilder.js +30 -0
  35. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  36. package/build/src/runtime/store/Sdk.d.ts +2 -0
  37. package/build/src/runtime/store/Sdk.d.ts.map +1 -1
  38. package/build/src/runtime/store/Sdk.js +10 -2
  39. package/build/src/runtime/store/Sdk.js.map +1 -1
  40. package/build/src/runtime/store/StoreSdkNode.d.ts +1 -0
  41. package/build/src/runtime/store/StoreSdkNode.d.ts.map +1 -1
  42. package/build/src/runtime/store/StoreSdkNode.js.map +1 -1
  43. package/build/src/runtime/store/StoreSdkWeb.d.ts +1 -0
  44. package/build/src/runtime/store/StoreSdkWeb.d.ts.map +1 -1
  45. package/build/src/runtime/store/StoreSdkWeb.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/events/BaseEvents.ts +11 -1
  48. package/src/modeling/DomainVersioning.ts +18 -3
  49. package/src/models/DataCatalog.ts +260 -0
  50. package/src/models/DataCatalogVersion.ts +235 -0
  51. package/src/models/kinds.ts +2 -0
  52. package/src/runtime/store/DataCatalogSdk.ts +473 -0
  53. package/src/runtime/store/RouteBuilder.ts +40 -0
  54. package/src/runtime/store/Sdk.ts +11 -2
  55. package/src/runtime/store/StoreSdkNode.ts +1 -0
  56. package/src/runtime/store/StoreSdkWeb.ts +1 -0
@@ -0,0 +1,235 @@
1
+ import { DataCatalogScope } from './DataCatalog.js'
2
+ import { DataCatalogVersionKind } from './kinds.js'
3
+
4
+ export type DataCatalogLifecycle = 'stable' | 'beta' | 'dev'
5
+
6
+ export interface DataCatalogVersionSchema {
7
+ /**
8
+ * The key of the version.
9
+ *
10
+ * The key can only be set when creating a new data catalog entry.
11
+ * @readonly
12
+ */
13
+ key: string
14
+ /**
15
+ * The kind of the schema
16
+ */
17
+ readonly kind: typeof DataCatalogVersionKind
18
+ /**
19
+ * The key of the parent data catalog entry.
20
+ * It is only populated by the API when creating the version.
21
+ * @readonly
22
+ */
23
+ catalogKey: string
24
+ /**
25
+ * The publication scope of the data catalog entry.
26
+ *
27
+ * When the scope is set to a different value than the one of the parent data catalog entry,
28
+ * then this value is used to determine the visibility of the data catalog entry. However,
29
+ * the reader cannot access the version with a "public" scope if the parent data catalog entry is private.
30
+ *
31
+ * @required
32
+ */
33
+ scope: DataCatalogScope
34
+ /**
35
+ * The lifecycle of the data catalog entry.
36
+ *
37
+ * - `stable`: The data catalog entry is stable and can be used in production.
38
+ * - `beta`: The data catalog entry is in beta and may change in the future.
39
+ * - `dev`: The data catalog entry is in development and likely will change in the future.
40
+ *
41
+ * The lifecycle is a readonly property and is set by the API when creating or updating the data catalog entry.
42
+ * A version is immutable and to change the lifecycle, a new version must be created.
43
+ *
44
+ * @required
45
+ */
46
+ lifecycle: DataCatalogLifecycle
47
+ /**
48
+ * The version string according to the [semantic versioning](https://semver.org/) specification.
49
+ * Note, this value is limited to 32 characters by the API.
50
+ * @required
51
+ */
52
+ version: string
53
+ /**
54
+ * The id of the user who created the version.
55
+ * It is ignored when creating or updating a data catalog entry.
56
+ * @readonly
57
+ */
58
+ publishedBy: string
59
+ /**
60
+ * The timestamp when this version was unpublished.
61
+ * Only set when the version was unpublished.
62
+ * @readonly
63
+ */
64
+ unpublishedAt?: number
65
+ /**
66
+ * A flag indicating if the version is deprecated.
67
+ * @readonly
68
+ */
69
+ deprecated?: boolean
70
+ /**
71
+ * The timestamp when the version was deprecated.
72
+ * Only set when the version was deprecated.
73
+ * @readonly
74
+ */
75
+ deprecatedAt?: number
76
+ /**
77
+ * The id of the user who deprecated the version.
78
+ * Only set when the version was deprecated.
79
+ * @readonly
80
+ */
81
+ deprecatedBy?: string
82
+ /**
83
+ * The reason why the version was deprecated.
84
+ * Only set when the version was deprecated.
85
+ */
86
+ deprecationReason?: string
87
+ /**
88
+ * The timestamp when the data catalog entry was created.
89
+ * It is ignored when creating or updating a data catalog entry.
90
+ * @readonly
91
+ */
92
+ createdAt: number
93
+ /**
94
+ * The timestamp when the data catalog entry was last updated.
95
+ * It is ignored when creating or updating a data catalog entry.
96
+ * @readonly
97
+ */
98
+ updatedAt: number
99
+ /**
100
+ * The changelog of the data catalog entry.
101
+ * Note, this value is required by the API when creating the version.
102
+ */
103
+ changelog?: string
104
+ }
105
+
106
+ export class DataCatalogVersion implements DataCatalogVersionSchema {
107
+ key: string
108
+
109
+ get kind(): typeof DataCatalogVersionKind {
110
+ return DataCatalogVersionKind
111
+ }
112
+
113
+ catalogKey: string
114
+ scope: DataCatalogScope
115
+ lifecycle: DataCatalogLifecycle
116
+ version: string
117
+ publishedBy: string
118
+ unpublishedAt?: number | undefined
119
+ deprecated?: boolean | undefined
120
+ deprecatedAt?: number | undefined
121
+ deprecatedBy?: string | undefined
122
+ deprecationReason?: string | undefined
123
+ createdAt: number
124
+ updatedAt: number
125
+ changelog?: string | undefined
126
+
127
+ static createSchema(input: Partial<DataCatalogVersionSchema>): DataCatalogVersionSchema {
128
+ const {
129
+ key = '',
130
+ scope = 'private',
131
+ publishedBy = '',
132
+ createdAt = 0,
133
+ updatedAt = 0,
134
+ catalogKey = '',
135
+ lifecycle = 'stable',
136
+ version = '',
137
+ } = input
138
+ if (['public', 'private', 'organization'].indexOf(scope) === -1) {
139
+ throw new Error(`Invalid scope: ${scope}`)
140
+ }
141
+ const result: DataCatalogVersionSchema = {
142
+ key,
143
+ kind: DataCatalogVersionKind,
144
+ scope,
145
+ publishedBy,
146
+ createdAt,
147
+ updatedAt,
148
+ catalogKey,
149
+ lifecycle,
150
+ version,
151
+ }
152
+ if (typeof input.deprecated === 'boolean') {
153
+ result.deprecated = input.deprecated
154
+ }
155
+ if (typeof input.deprecatedAt === 'number') {
156
+ result.deprecatedAt = input.deprecatedAt
157
+ }
158
+ if (typeof input.deprecatedBy === 'string') {
159
+ result.deprecatedBy = input.deprecatedBy
160
+ }
161
+ if (typeof input.changelog === 'string') {
162
+ result.changelog = input.changelog
163
+ }
164
+ if (typeof input.deprecationReason === 'string') {
165
+ result.deprecationReason = input.deprecationReason
166
+ }
167
+ if (typeof input.unpublishedAt === 'number') {
168
+ result.unpublishedAt = input.unpublishedAt
169
+ }
170
+ return result
171
+ }
172
+
173
+ constructor(input: Partial<DataCatalogVersionSchema> = {}) {
174
+ const init = DataCatalogVersion.createSchema(input)
175
+ this.key = init.key
176
+ this.catalogKey = init.catalogKey
177
+ this.lifecycle = init.lifecycle
178
+ this.scope = init.scope
179
+ this.version = init.version
180
+ this.publishedBy = init.publishedBy
181
+ this.createdAt = init.createdAt
182
+ this.updatedAt = init.updatedAt
183
+ if (typeof init.changelog === 'string') {
184
+ this.changelog = init.changelog
185
+ }
186
+ if (typeof init.deprecated === 'boolean') {
187
+ this.deprecated = init.deprecated
188
+ }
189
+ if (typeof init.deprecatedAt === 'number') {
190
+ this.deprecatedAt = init.deprecatedAt
191
+ }
192
+ if (typeof init.deprecatedBy === 'string') {
193
+ this.deprecatedBy = init.deprecatedBy
194
+ }
195
+ if (typeof init.deprecationReason === 'string') {
196
+ this.deprecationReason = init.deprecationReason
197
+ }
198
+ if (typeof init.unpublishedAt === 'number') {
199
+ this.unpublishedAt = init.unpublishedAt
200
+ }
201
+ }
202
+
203
+ toJSON(): DataCatalogVersionSchema {
204
+ const result: DataCatalogVersionSchema = {
205
+ key: this.key,
206
+ kind: DataCatalogVersionKind,
207
+ scope: this.scope,
208
+ publishedBy: this.publishedBy,
209
+ createdAt: this.createdAt,
210
+ updatedAt: this.updatedAt,
211
+ catalogKey: this.catalogKey,
212
+ lifecycle: this.lifecycle,
213
+ version: this.version,
214
+ }
215
+ if (typeof this.deprecated === 'boolean') {
216
+ result.deprecated = this.deprecated
217
+ }
218
+ if (typeof this.deprecatedAt === 'number') {
219
+ result.deprecatedAt = this.deprecatedAt
220
+ }
221
+ if (typeof this.deprecatedBy === 'string') {
222
+ result.deprecatedBy = this.deprecatedBy
223
+ }
224
+ if (typeof this.deprecationReason === 'string') {
225
+ result.deprecationReason = this.deprecationReason
226
+ }
227
+ if (typeof this.unpublishedAt === 'number') {
228
+ result.unpublishedAt = this.unpublishedAt
229
+ }
230
+ if (typeof this.changelog === 'string' && this.changelog) {
231
+ result.changelog = this.changelog
232
+ }
233
+ return result
234
+ }
235
+ }
@@ -16,6 +16,8 @@ export const DomainModelKind = 'Domain#Model'
16
16
  export const DomainEntityKind = 'Domain#Entity'
17
17
  export const DomainAssociationKind = 'Domain#Association'
18
18
  export const DomainPropertyKind = 'Domain#Property'
19
+ export const DataCatalogKind = 'Core#DataCatalog'
20
+ export const DataCatalogVersionKind = 'Core#DataCatalogVersion'
19
21
 
20
22
  /**
21
23
  * @deprecated Not used anymore.
@@ -0,0 +1,473 @@
1
+ import {
2
+ SdkBase,
3
+ E_RESPONSE_STATUS,
4
+ E_RESPONSE_NO_VALUE,
5
+ E_INVALID_JSON,
6
+ E_RESPONSE_UNKNOWN,
7
+ SdkOptions,
8
+ } from './SdkBase.js'
9
+ import { ContextListResult, ContextListOptions, ContextChangeRecord } from '../../events/BaseEvents.js'
10
+ import type {
11
+ DataCatalogSchema,
12
+ DataCatalogSchemaWithVersion,
13
+ DataCatalogScope,
14
+ DataCatalogStatus,
15
+ } from '../../models/DataCatalog.js'
16
+ import { RouteBuilder } from './RouteBuilder.js'
17
+ import { SdkError } from './Errors.js'
18
+ import { DataCatalogKind, DataCatalogVersionKind } from '../../models/kinds.js'
19
+ import type { DataCatalogVersionSchema } from '../../models/DataCatalogVersion.js'
20
+ import type { ForeignDomainDependency } from '../../modeling/types.js'
21
+ import type { DataDomainSchema } from '../../modeling/DataDomain.js'
22
+
23
+ export interface DataCatalogListOptions extends ContextListOptions {
24
+ scope?: DataCatalogScope
25
+ }
26
+
27
+ export class DataCatalogSdk extends SdkBase {
28
+ async list(
29
+ options: DataCatalogListOptions = {},
30
+ request: SdkOptions = {}
31
+ ): Promise<ContextListResult<DataCatalogSchemaWithVersion>> {
32
+ const { token } = request
33
+ const opts = { ...options }
34
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalog())
35
+ this.sdk.appendListOptions(url, opts)
36
+ if (opts.scope) {
37
+ url.searchParams.set('scope', opts.scope)
38
+ }
39
+ const result = await this.sdk.http.get(url.toString(), { token })
40
+ this.inspectCommonStatusCodes(result)
41
+ const E_PREFIX = 'Unable to list data domains. '
42
+ if (result.status !== 200) {
43
+ this.logInvalidResponse(result)
44
+ let e = this.createGenericSdkError(result.body)
45
+ if (!e) {
46
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
47
+ e.response = result.body
48
+ }
49
+ throw e
50
+ }
51
+ if (!result.body) {
52
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
53
+ }
54
+
55
+ let data: ContextListResult<DataCatalogSchemaWithVersion>
56
+ try {
57
+ data = JSON.parse(result.body)
58
+ } catch {
59
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
60
+ }
61
+ if (!Array.isArray(data.items)) {
62
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
63
+ }
64
+ return data
65
+ }
66
+
67
+ async listVersions(
68
+ key: string,
69
+ request: SdkOptions = {}
70
+ ): Promise<ContextListResult<{ key: string; version: string; published: number }>> {
71
+ const { token } = request
72
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogEntryVersions(key))
73
+ const result = await this.sdk.http.get(url.toString(), { token })
74
+ this.inspectCommonStatusCodes(result)
75
+ const E_PREFIX = 'Unable to list data domain versions. '
76
+ if (result.status !== 200) {
77
+ this.logInvalidResponse(result)
78
+ let e = this.createGenericSdkError(result.body)
79
+ if (!e) {
80
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
81
+ e.response = result.body
82
+ }
83
+ throw e
84
+ }
85
+ if (!result.body) {
86
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
87
+ }
88
+ let data: ContextListResult<{ key: string; version: string; published: number }>
89
+ try {
90
+ data = JSON.parse(result.body)
91
+ } catch {
92
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
93
+ }
94
+ if (!Array.isArray(data.items)) {
95
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
96
+ }
97
+ return data
98
+ }
99
+
100
+ /**
101
+ * Publishes a new data catalog entry.
102
+ * To publish a version, use the `publishVersion` method.
103
+ * @param entry The data catalog entry to publish.
104
+ * @returns The created data catalog entry.
105
+ */
106
+ async publish(entry: DataCatalogSchema, request: SdkOptions = {}): Promise<ContextChangeRecord<DataCatalogSchema>> {
107
+ const { token } = request
108
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalog())
109
+ const body = JSON.stringify(entry)
110
+ const result = await this.sdk.http.post(url.toString(), {
111
+ token,
112
+ body,
113
+ headers: {
114
+ 'content-type': 'application/json',
115
+ },
116
+ })
117
+ this.inspectCommonStatusCodes(result)
118
+ const E_PREFIX = 'Unable to publish data domain. '
119
+ if (result.status !== 200) {
120
+ this.logInvalidResponse(result)
121
+ let e = this.createGenericSdkError(result.body)
122
+ if (!e) {
123
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
124
+ e.response = result.body
125
+ }
126
+ throw e
127
+ }
128
+
129
+ if (!result.body) {
130
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
131
+ }
132
+ let data: ContextChangeRecord<DataCatalogSchema>
133
+ try {
134
+ data = JSON.parse(result.body)
135
+ } catch {
136
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
137
+ }
138
+ if (!data.key) {
139
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
140
+ }
141
+ return data
142
+ }
143
+
144
+ async read(key: string, request: SdkOptions = {}): Promise<DataCatalogSchema> {
145
+ const { token } = request
146
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogEntry(key))
147
+ const result = await this.sdk.http.get(url.toString(), { token })
148
+ this.inspectCommonStatusCodes(result)
149
+ const E_PREFIX = 'Unable to read data domain. '
150
+ if (result.status !== 200) {
151
+ this.logInvalidResponse(result)
152
+ let e = this.createGenericSdkError(result.body)
153
+ if (!e) {
154
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
155
+ e.response = result.body
156
+ }
157
+ throw e
158
+ }
159
+ if (!result.body) {
160
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
161
+ }
162
+ let data: DataCatalogSchema
163
+ try {
164
+ data = JSON.parse(result.body)
165
+ } catch {
166
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
167
+ }
168
+ if (data.kind !== DataCatalogKind) {
169
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
170
+ }
171
+ return data
172
+ }
173
+
174
+ /**
175
+ * Deprecates the entire data catalog entry.
176
+ * To deprecate a version, use the `deprecateVersion` method.
177
+ * @param key The key of the data catalog entry to deprecate.
178
+ * @param reason The reason for deprecation.
179
+ */
180
+ async deprecate(
181
+ key: string,
182
+ reason: string,
183
+ request: SdkOptions = {}
184
+ ): Promise<ContextChangeRecord<DataCatalogSchema>> {
185
+ const { token } = request
186
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogDeprecate(key))
187
+ const body = JSON.stringify({ reason })
188
+ const result = await this.sdk.http.put(url.toString(), {
189
+ token,
190
+ body,
191
+ headers: {
192
+ 'content-type': 'application/json',
193
+ },
194
+ })
195
+ this.inspectCommonStatusCodes(result)
196
+ const E_PREFIX = 'Unable to deprecate data domain. '
197
+ if (result.status !== 200) {
198
+ this.logInvalidResponse(result)
199
+ let e = this.createGenericSdkError(result.body)
200
+ if (!e) {
201
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
202
+ e.response = result.body
203
+ }
204
+ throw e
205
+ }
206
+ if (!result.body) {
207
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
208
+ }
209
+ let data: ContextChangeRecord<DataCatalogSchema>
210
+ try {
211
+ data = JSON.parse(result.body)
212
+ } catch {
213
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
214
+ }
215
+ if (data.kind !== DataCatalogKind) {
216
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
217
+ }
218
+ return data
219
+ }
220
+
221
+ /**
222
+ * Removes the data catalog entry from the catalog. The entry is preserved in the database
223
+ * and the user can still access it. It is used to recover from error when the entry was published
224
+ * by mistake.
225
+ * @param key The key of the data catalog entry to unpublish.
226
+ */
227
+ async unpublish(key: string, request: SdkOptions = {}): Promise<ContextChangeRecord<DataCatalogSchema>> {
228
+ const { token } = request
229
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogUnpublish(key))
230
+ const result = await this.sdk.http.put(url.toString(), { token })
231
+ this.inspectCommonStatusCodes(result)
232
+ const E_PREFIX = 'Unable to unpublish data domain. '
233
+ if (result.status !== 200) {
234
+ this.logInvalidResponse(result)
235
+ let e = this.createGenericSdkError(result.body)
236
+ if (!e) {
237
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
238
+ e.response = result.body
239
+ }
240
+ throw e
241
+ }
242
+ if (!result.body) {
243
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
244
+ }
245
+ let data: ContextChangeRecord<DataCatalogSchema>
246
+ try {
247
+ data = JSON.parse(result.body)
248
+ } catch {
249
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
250
+ }
251
+ if (data.kind !== DataCatalogKind) {
252
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
253
+ }
254
+ return data
255
+ }
256
+
257
+ async publishVersion(
258
+ key: string,
259
+ version: DataCatalogVersionSchema,
260
+ request: SdkOptions = {}
261
+ ): Promise<ContextChangeRecord<DataCatalogVersionSchema>> {
262
+ const { token } = request
263
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogEntryVersions(key))
264
+ const body = JSON.stringify(version)
265
+ const result = await this.sdk.http.post(url.toString(), {
266
+ token,
267
+ body,
268
+ headers: {
269
+ 'content-type': 'application/json',
270
+ },
271
+ })
272
+ this.inspectCommonStatusCodes(result)
273
+ const E_PREFIX = 'Unable to publish data domain version. '
274
+ if (result.status !== 200) {
275
+ this.logInvalidResponse(result)
276
+ let e = this.createGenericSdkError(result.body)
277
+ if (!e) {
278
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
279
+ e.response = result.body
280
+ }
281
+ throw e
282
+ }
283
+ if (!result.body) {
284
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
285
+ }
286
+ let data: ContextChangeRecord<DataCatalogVersionSchema>
287
+ try {
288
+ data = JSON.parse(result.body)
289
+ } catch {
290
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
291
+ }
292
+ if (data.kind !== DataCatalogVersionKind) {
293
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
294
+ }
295
+ return data
296
+ }
297
+
298
+ async readVersion(key: string, version: string, request: SdkOptions = {}): Promise<DataCatalogVersionSchema> {
299
+ const { token } = request
300
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogVersion(key, version))
301
+ const result = await this.sdk.http.get(url.toString(), { token })
302
+ this.inspectCommonStatusCodes(result)
303
+ const E_PREFIX = 'Unable to read data domain version. '
304
+ if (result.status !== 200) {
305
+ this.logInvalidResponse(result)
306
+ let e = this.createGenericSdkError(result.body)
307
+ if (!e) {
308
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
309
+ e.response = result.body
310
+ }
311
+ throw e
312
+ }
313
+ if (!result.body) {
314
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
315
+ }
316
+ let data: DataCatalogVersionSchema
317
+ try {
318
+ data = JSON.parse(result.body)
319
+ } catch {
320
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
321
+ }
322
+ if (data.kind !== DataCatalogVersionKind) {
323
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
324
+ }
325
+ return data
326
+ }
327
+
328
+ async listDependencies(
329
+ dependencies?: ForeignDomainDependency[],
330
+ request: SdkOptions = {}
331
+ ): Promise<ContextListResult<DataDomainSchema[]>> {
332
+ const { token } = request
333
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogDependencies())
334
+ const body = JSON.stringify({ items: dependencies })
335
+ const result = await this.sdk.http.post(url.toString(), {
336
+ token,
337
+ body,
338
+ headers: {
339
+ 'content-type': 'application/json',
340
+ },
341
+ })
342
+ this.inspectCommonStatusCodes(result)
343
+ const E_PREFIX = 'Unable to list data domain dependencies. '
344
+ if (result.status !== 200) {
345
+ this.logInvalidResponse(result)
346
+ let e = this.createGenericSdkError(result.body)
347
+ if (!e) {
348
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
349
+ e.response = result.body
350
+ }
351
+ throw e
352
+ }
353
+ if (!result.body) {
354
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
355
+ }
356
+ let data: ContextListResult<DataDomainSchema[]>
357
+ try {
358
+ data = JSON.parse(result.body)
359
+ } catch {
360
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
361
+ }
362
+ if (!Array.isArray(data.items)) {
363
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
364
+ }
365
+ return data
366
+ }
367
+
368
+ async deprecateVersion(
369
+ key: string,
370
+ version: string,
371
+ reason: string,
372
+ request: SdkOptions = {}
373
+ ): Promise<ContextChangeRecord<DataCatalogVersionSchema>> {
374
+ const { token } = request
375
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogVersion(key, version))
376
+ const body = JSON.stringify({ reason })
377
+ const result = await this.sdk.http.put(url.toString(), {
378
+ token,
379
+ body,
380
+ headers: {
381
+ 'content-type': 'application/json',
382
+ },
383
+ })
384
+ this.inspectCommonStatusCodes(result)
385
+ const E_PREFIX = 'Unable to deprecate data domain version. '
386
+ if (result.status !== 200) {
387
+ this.logInvalidResponse(result)
388
+ let e = this.createGenericSdkError(result.body)
389
+ if (!e) {
390
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
391
+ e.response = result.body
392
+ }
393
+ throw e
394
+ }
395
+ if (!result.body) {
396
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
397
+ }
398
+ let data: ContextChangeRecord<DataCatalogVersionSchema>
399
+ try {
400
+ data = JSON.parse(result.body)
401
+ } catch {
402
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
403
+ }
404
+ if (data.kind !== DataCatalogVersionKind) {
405
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
406
+ }
407
+ return data
408
+ }
409
+
410
+ async unpublishVersion(
411
+ key: string,
412
+ version: string,
413
+ request: SdkOptions = {}
414
+ ): Promise<ContextChangeRecord<DataCatalogVersionSchema>> {
415
+ const { token } = request
416
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogVersion(key, version))
417
+ const result = await this.sdk.http.put(url.toString(), { token })
418
+ this.inspectCommonStatusCodes(result)
419
+ const E_PREFIX = 'Unable to unpublish data domain version. '
420
+ if (result.status !== 200) {
421
+ this.logInvalidResponse(result)
422
+ let e = this.createGenericSdkError(result.body)
423
+ if (!e) {
424
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
425
+ e.response = result.body
426
+ }
427
+ throw e
428
+ }
429
+ if (!result.body) {
430
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
431
+ }
432
+ let data: ContextChangeRecord<DataCatalogVersionSchema>
433
+ try {
434
+ data = JSON.parse(result.body)
435
+ } catch {
436
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
437
+ }
438
+ if (data.kind !== DataCatalogVersionKind) {
439
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
440
+ }
441
+ return data
442
+ }
443
+
444
+ async checkPublicationStatus(domainId: string, request: SdkOptions = {}): Promise<DataCatalogStatus> {
445
+ const { token } = request
446
+ const url = this.sdk.getUrl(RouteBuilder.dataCatalogStatus(domainId))
447
+ const result = await this.sdk.http.get(url.toString(), { token })
448
+ this.inspectCommonStatusCodes(result)
449
+ const E_PREFIX = 'Unable to check data domain publication status. '
450
+ if (result.status !== 200) {
451
+ this.logInvalidResponse(result)
452
+ let e = this.createGenericSdkError(result.body)
453
+ if (!e) {
454
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
455
+ e.response = result.body
456
+ }
457
+ throw e
458
+ }
459
+ if (!result.body) {
460
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)
461
+ }
462
+ let data: DataCatalogStatus
463
+ try {
464
+ data = JSON.parse(result.body)
465
+ } catch {
466
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)
467
+ }
468
+ if (data.kind !== DataCatalogKind) {
469
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)
470
+ }
471
+ return data
472
+ }
473
+ }