@mcma/data
Advanced tools
Comparing version 0.11.0 to 0.11.1
import { DocumentDatabaseTable } from "./document-database-table"; | ||
import { DocumentDatabaseTableConfig } from "./document-database-table-config"; | ||
import { Document } from "./document"; | ||
import { DocumentType } from "./document-type"; | ||
export interface DocumentDatabaseTableProvider { | ||
configure<TDocument extends Document = Document, TPartitionKey = string, TSortKey = string>(type: DocumentType<TDocument>, config: DocumentDatabaseTableConfig<TDocument, TPartitionKey, TSortKey>): this; | ||
get<TDocument extends Document = Document, TPartitionKey = string, TSortKey = string>(tableName: string, type: DocumentType<TDocument>): DocumentDatabaseTable<TDocument, TPartitionKey, TSortKey>; | ||
get<TPartitionKey = string, TSortKey = string>(tableName: string): Promise<DocumentDatabaseTable<TPartitionKey, TSortKey>>; | ||
} | ||
export declare abstract class DocumentDatabaseTableProvider implements DocumentDatabaseTableProvider { | ||
private configurations; | ||
isConfigured<TDocument extends Document = Document>(type: DocumentType<TDocument>): boolean; | ||
protected abstract getFromConfig<TDocument extends Document = Document, TPartitionKey = string, TSortKey = string>(tableName: string, type: DocumentType<TDocument>, config: DocumentDatabaseTableConfig<TDocument, TPartitionKey, TSortKey>): DocumentDatabaseTable<TDocument, TPartitionKey, TSortKey>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@mcma/core"); | ||
class DocumentDatabaseTableProvider { | ||
constructor() { | ||
this.configurations = {}; | ||
} | ||
isConfigured(type) { | ||
return !!this.configurations[core_1.Utils.getTypeName(type)]; | ||
} | ||
configure(type, config, overwriteIfExisting = false) { | ||
const typeName = core_1.Utils.getTypeName(type); | ||
if (this.configurations[typeName] && !overwriteIfExisting) { | ||
throw new core_1.McmaException(`Document type ${typeName} has already been configured for this DocumentDatabaseTableProvider. If you would like overwrite the existing configuration, specify true for the optional overwriteIfExisting argument.`); | ||
} | ||
this.configurations[typeName] = config; | ||
return this; | ||
} | ||
get(tableName, type) { | ||
const typeName = core_1.Utils.getTypeName(type); | ||
if (!this.configurations[typeName]) { | ||
throw new core_1.McmaException(`Type '${typeName}' does not have a configured partition key and/or sort key.`); | ||
} | ||
return this.getFromConfig(tableName, type, this.configurations[typeName]); | ||
} | ||
} | ||
exports.DocumentDatabaseTableProvider = DocumentDatabaseTableProvider; |
import { DocumentDatabaseQuery } from "./document-database-query"; | ||
import { Document } from "./document"; | ||
import { DocumentType } from "./document-type"; | ||
export declare abstract class DocumentDatabaseTable<TDocument extends Document = Document, TPartitionKey = string, TSortKey = string> { | ||
protected type: string; | ||
protected constructor(type: DocumentType<TDocument>); | ||
abstract query(query: DocumentDatabaseQuery<TDocument, TPartitionKey, TSortKey>): Promise<TDocument[]>; | ||
abstract get(partitionKey: TPartitionKey, sortKey: TSortKey): Promise<TDocument>; | ||
abstract put(resource: TDocument): Promise<TDocument>; | ||
export declare abstract class DocumentDatabaseTable<TPartitionKey = string, TSortKey = string> { | ||
abstract query<TDocument extends Document = Document>(query: DocumentDatabaseQuery<TDocument, TPartitionKey, TSortKey>): Promise<TDocument[]>; | ||
abstract get<TDocument extends Document = Document>(partitionKey: TPartitionKey, sortKey: TSortKey): Promise<TDocument>; | ||
abstract put<TDocument extends Document = Document>(partitionKey: TPartitionKey, sortKey: TSortKey, resource: TDocument): Promise<TDocument>; | ||
abstract delete(partitionKey: TPartitionKey, sortKey: TSortKey): Promise<void>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@mcma/core"); | ||
class DocumentDatabaseTable { | ||
constructor(type) { | ||
this.type = core_1.Utils.getTypeName(type); | ||
} | ||
} | ||
exports.DocumentDatabaseTable = DocumentDatabaseTable; |
@@ -6,5 +6,4 @@ export * from "./document"; | ||
export * from "./document-database-table"; | ||
export * from "./document-database-table-config"; | ||
export * from "./document-database-table-provider"; | ||
export * from "./document-type"; | ||
export * from "./get-filter-expression-from-key-value-pairs"; |
@@ -9,4 +9,2 @@ "use strict"; | ||
__export(require("./document-database-table")); | ||
__export(require("./document-database-table-config")); | ||
__export(require("./document-database-table-provider")); | ||
__export(require("./get-filter-expression-from-key-value-pairs")); |
{ | ||
"name": "@mcma/data", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Node module with helper utils for dealing with data in the EBU MCMA framework", | ||
@@ -32,6 +32,6 @@ "engines": { | ||
"peerDependencies": { | ||
"@mcma/core": "0.11.0" | ||
"@mcma/core": "0.11.1" | ||
}, | ||
"devDependencies": { | ||
"@mcma/core": "0.11.0", | ||
"@mcma/core": "0.11.1", | ||
"@types/node": "^13.7.4", | ||
@@ -38,0 +38,0 @@ "jasmine": "^3.3.1" |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
6581
23
116