1
- import TerminusClient , { WOQLClient , WOQL } from "@terminusdb/terminusdb-client"
1
+ import TerminusClient , { WOQLClient , WOQL , AccessControl } from "@terminusdb/terminusdb-client"
2
2
import { DbDetails , DocParamsGet , DocParamsPut , DiffObject } from "@terminusdb/terminusdb-client/dist/typescript/lib/typedef"
3
3
import { Request } from "express"
4
4
import * as typeDef from "./typeDef"
5
5
import { ApiError } from "./ApiError"
6
- const server : string = process . env . SERVER_ENDPOINT || "http://127.0.0.1:6363"
7
-
8
6
import * as IndexClient from './IndexClient'
9
7
10
8
import dbSchema from '../../change_request_schema.json'
11
9
import { doc } from "@terminusdb/terminusdb-client/dist/typescript/lib/woql"
12
10
//import {v4 as uuidv4} from 'uuid';
13
11
const { v4 : uuidv4 } = require ( 'uuid' ) ;
14
12
15
- const endpoint = process . env . SERVER_ENDPOINT || ""
16
- const key = process . env . USER_KEY || ""
17
- const CROrg = process . env . CR_TEARM_NAME || ""
18
- const user = process . env . USER_NAME || ""
13
+ const endpoint : string = process . env . SERVER_ENDPOINT || "http://127.0.0.1:6363 "
14
+ const key = process . env . USER_KEY || "root "
15
+ const CROrg = process . env . CR_TEAM_NAME || "terminusCR "
16
+ const user = process . env . USER_NAME || "admin "
19
17
20
18
21
19
const logger = {
@@ -38,6 +36,7 @@ const logger = {
38
36
}
39
37
class ChangeRequestDB {
40
38
client : WOQLClient ;
39
+ accessControl : AccessControl ;
41
40
request : Request
42
41
user : string | undefined
43
42
password : string | undefined
@@ -60,6 +59,7 @@ class ChangeRequestDB {
60
59
this . logger = logger //req.context.logger
61
60
// every dataproduct has the related change_request database
62
61
this . changeRequestDbName = `${ TerminusClient . UTILS . encodeURISegment ( this . orgName ) } __${ this . dbName } __CR`
62
+ this . accessControl = new AccessControl ( endpoint , { key : key , user : user } )
63
63
this . client . db ( this . changeRequestDbName )
64
64
}
65
65
@@ -84,6 +84,14 @@ class ChangeRequestDB {
84
84
}
85
85
}
86
86
87
+ async createTeam ( ) {
88
+ try {
89
+ await this . accessControl . createOrganization ( CROrg )
90
+ } catch ( err ) {
91
+ // the team already exists
92
+ }
93
+ }
94
+
87
95
async createCRDatabase ( ) {
88
96
try {
89
97
if ( this . changeRequestDbName ) {
0 commit comments