@atek-cloud/adb-api
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -9,3 +9,3 @@ import { AdbApi, DbSettings, TableSettings, ListOpts, BlobMap, BlobDesc, Record } from './types.js'; | ||
dbId: string; | ||
isReady: Promise<any> | undefined; | ||
isReady: Promise<any>; | ||
constructor(api: AdbApi, dbId: string, opts?: DbSettings); | ||
@@ -12,0 +12,0 @@ /** |
@@ -16,17 +16,16 @@ import { rpc, createRpcServer } from '@atek-cloud/node-rpc'; | ||
this.dbId = dbId; | ||
if (opts) { | ||
if (!dbId) { | ||
this.isReady = api.dbCreate(opts).then(res => { | ||
this.dbId = res.dbId; | ||
}); | ||
} | ||
else if (!HYPER_KEY_RE.test(dbId)) { | ||
this.isReady = api.dbGetOrCreate(dbId, opts).then(res => { | ||
this.dbId = res.dbId; | ||
}); | ||
} | ||
if (!this.isReady) { | ||
this.isReady = Promise.resolve(undefined); | ||
} | ||
opts = opts || {}; | ||
if (!dbId) { | ||
this.isReady = api.dbCreate(opts).then(res => { | ||
this.dbId = res.dbId; | ||
}); | ||
} | ||
else if (!HYPER_KEY_RE.test(dbId)) { | ||
this.isReady = api.dbGetOrCreate(dbId, opts).then(res => { | ||
this.dbId = res.dbId; | ||
}); | ||
} | ||
else { | ||
this.isReady = Promise.resolve(undefined); | ||
} | ||
} | ||
@@ -116,3 +115,3 @@ /** | ||
this.tableDesc = tableDesc; | ||
this.isReady = db.define(tableId, tableDesc); | ||
this.isReady = db.isReady.then(() => db.define(tableId, tableDesc)); | ||
} | ||
@@ -119,0 +118,0 @@ /** |
@@ -36,2 +36,3 @@ /// <reference types="node" /> | ||
export declare class DbSettings { | ||
dbId?: string; | ||
type?: DbInternalType; | ||
@@ -47,2 +48,5 @@ alias?: string; | ||
properties: { | ||
dbId: { | ||
type: string; | ||
}; | ||
type: { | ||
@@ -449,2 +453,6 @@ type: string; | ||
/** | ||
* @desc List databases owned by a given user | ||
*/ | ||
adminListDbsByOwningUser(owningUserKey: string): Promise<DbSettings[]>; | ||
/** | ||
* @desc Create a new database | ||
@@ -527,2 +535,47 @@ */ | ||
}; | ||
adminListDbsByOwningUser: { | ||
params: { | ||
type: string; | ||
}[]; | ||
response: { | ||
type: string; | ||
items: { | ||
type: string; | ||
properties: { | ||
dbId: { | ||
type: string; | ||
}; | ||
type: { | ||
type: string; | ||
}; | ||
alias: { | ||
type: string; | ||
}; | ||
displayName: { | ||
type: string; | ||
}; | ||
tables: { | ||
type: string; | ||
items: { | ||
type: string; | ||
}; | ||
}; | ||
network: { | ||
type: string; | ||
properties: { | ||
access: { | ||
type: string; | ||
}; | ||
}; | ||
}; | ||
persist: { | ||
type: string; | ||
}; | ||
presync: { | ||
type: string; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
dbCreate: { | ||
@@ -555,2 +608,5 @@ params: (typeof DbSettings)[]; | ||
properties: { | ||
dbId: { | ||
type: string; | ||
}; | ||
type: { | ||
@@ -557,0 +613,0 @@ type: string; |
@@ -33,2 +33,5 @@ const EMPTY_BUFFER = Buffer.alloc(0); | ||
export class DbSettings { | ||
constructor() { | ||
this.dbId = ''; | ||
} | ||
} | ||
@@ -38,2 +41,3 @@ DbSettings.schema = { | ||
properties: { | ||
dbId: { type: 'string' }, | ||
type: { type: 'string' }, | ||
@@ -195,2 +199,6 @@ alias: { type: 'string' }, | ||
}, | ||
adminListDbsByOwningUser: { | ||
params: [{ type: 'string' }], | ||
response: { type: 'array', items: DbSettings.schema } | ||
}, | ||
dbCreate: { | ||
@@ -197,0 +205,0 @@ params: [DbSettings], |
{ | ||
"name": "@atek-cloud/adb-api", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Atek DB API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -17,17 +17,15 @@ import { rpc, createRpcServer } from '@atek-cloud/node-rpc' | ||
export class AdbDatabase { | ||
public isReady: Promise<any>|undefined | ||
public isReady: Promise<any> | ||
constructor (public api: AdbApi, public dbId: string, opts?: DbSettings) { | ||
if (opts) { | ||
if (!dbId) { | ||
this.isReady = api.dbCreate(opts).then(res => { | ||
this.dbId = res.dbId | ||
}) | ||
} else if (!HYPER_KEY_RE.test(dbId)) { | ||
this.isReady = api.dbGetOrCreate(dbId, opts).then(res => { | ||
this.dbId = res.dbId | ||
}) | ||
} | ||
if (!this.isReady) { | ||
this.isReady = Promise.resolve(undefined) | ||
} | ||
opts = opts || {} | ||
if (!dbId) { | ||
this.isReady = api.dbCreate(opts).then(res => { | ||
this.dbId = res.dbId | ||
}) | ||
} else if (!HYPER_KEY_RE.test(dbId)) { | ||
this.isReady = api.dbGetOrCreate(dbId, opts).then(res => { | ||
this.dbId = res.dbId | ||
}) | ||
} else { | ||
this.isReady = Promise.resolve(undefined) | ||
} | ||
@@ -128,3 +126,3 @@ } | ||
constructor (public db: AdbDatabase, public tableId: string, public tableDesc: TableSettings) { | ||
this.isReady = db.define(tableId, tableDesc) | ||
this.isReady = db.isReady.then(() => db.define(tableId, tableDesc)) | ||
} | ||
@@ -131,0 +129,0 @@ |
@@ -34,2 +34,3 @@ const EMPTY_BUFFER = Buffer.alloc(0) | ||
export class DbSettings { | ||
dbId?: string = '' | ||
type?: DbInternalType | ||
@@ -45,2 +46,3 @@ alias?: string // An alias ID for the application to reference the database. | ||
properties: { | ||
dbId: {type: 'string'}, | ||
type: {type: 'string'}, | ||
@@ -234,2 +236,6 @@ alias: {type: 'string'}, | ||
getConfig (): Promise<AdbProcessConfig> | ||
/** | ||
* @desc List databases owned by a given user | ||
*/ | ||
adminListDbsByOwningUser (owningUserKey: string): Promise<DbSettings[]> | ||
@@ -310,2 +316,6 @@ /** | ||
}, | ||
adminListDbsByOwningUser: { | ||
params: [{type: 'string'}], | ||
response: {type: 'array', items: DbSettings.schema} | ||
}, | ||
dbCreate: { | ||
@@ -312,0 +322,0 @@ params: [DbSettings], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66611
1963