-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.ts
66 lines (63 loc) · 2.62 KB
/
extension.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
import { Context, ExasolExtension, NotFoundError, registerExtension } from "@exasol/extension-manager-interface";
import { addInstance } from "./addInstance";
import { EXTENSION_NAME } from "./common";
import { deleteInstance } from "./deleteInstance";
import { EXTENSION_DESCRIPTION } from "./extension-description";
import { findInstallations } from "./findInstallations";
import { findInstances } from "./findInstances";
import { install } from "./install";
import { createInstanceParameters } from "./parameterDefinitions";
import { uninstall } from "./uninstall";
import { upgrade } from "./upgrade";
export type ExtendedContext = Context & {
version: string,
luaScriptContent: string
}
function extendContext(context: Context): ExtendedContext {
return {
...context,
version: EXTENSION_DESCRIPTION.version,
luaScriptContent: EXTENSION_DESCRIPTION.content
}
}
export function createExtension(): ExasolExtension {
const baseExtension: ExasolExtension = {
name: EXTENSION_NAME,
description: "Lua implementation of Exasol's row-level-security",
category: "security",
bucketFsUploads: [],
installableVersions: [{ name: EXTENSION_DESCRIPTION.version, deprecated: false, latest: true }],
findInstallations(context, metadata) {
return findInstallations(extendContext(context), metadata.allScripts.rows)
},
install(context, versionToInstall) {
install(extendContext(context), versionToInstall)
},
uninstall(context, versionToUninstall) {
uninstall(extendContext(context), versionToUninstall)
},
upgrade(context) {
return upgrade(extendContext(context))
},
findInstances(context, _version) {
return findInstances(extendContext(context))
},
getInstanceParameters(context, version) {
if (EXTENSION_DESCRIPTION.version !== version) {
throw new NotFoundError(`Version '${version}' not supported, can only use '${EXTENSION_DESCRIPTION.version}'.`)
}
return createInstanceParameters()
},
addInstance(context, version, params) {
return addInstance(extendContext(context), version, params);
},
deleteInstance(context, version, instanceId) {
deleteInstance(extendContext(context), version, instanceId)
},
readInstanceParameterValues(_context, _version, _instanceId) {
throw new NotFoundError("Reading instance parameter values not supported")
},
}
return baseExtension
}
registerExtension(createExtension())