Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azurite

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azurite - npm Package Compare versions

Comparing version 2.5.1 to 2.6.0

lib/actions/table/InsertOrMergeEntity.js

5

lib/core/Constants.js

@@ -114,3 +114,6 @@ 'use strict';

QUERY_ENTITY: 'QueryEntity',
UPDATE_ENTITY: 'UpdateEntity'
UPDATE_ENTITY: 'UpdateEntity',
INSERT_OR_REPLACE_ENTITY: 'InsertOrReplaceEntity',
MERGE_ENTITY: 'MergeEntity',
INSERT_OR_MERGE_ENTITY: 'InsertOrMergeEntity'
}

@@ -117,0 +120,0 @@ }

@@ -130,2 +130,17 @@ 'use strict';

insertOrReplaceEntity(request) {
const proxy = this._createOrUpdateEntity(request.partitionKey, request.rowKey, request.tableName, request.payload);
return BbPromise.resolve(new AzuriteTableResponse({ proxy: proxy }));
}
mergeEntity(request) {
const proxy = this._insertOrMergeEntity(request.partitionKey, request.rowKey, request.tableName, request.payload);
return BbPromise.resolve(new AzuriteTableResponse({ proxy: proxy }));
}
insertOrMergeEntity(request) {
const proxy = this._insertOrMergeEntity(request.partitionKey, request.rowKey, request.tableName, request.payload);
return BbPromise.resolve(new AzuriteTableResponse({ proxy: proxy }));
}
_getTable(name) {

@@ -191,2 +206,21 @@ const coll = this.db.getCollection(Tables.Tables);

}
_insertOrMergeEntity(partitionKey, rowKey, tableName, rawEntity) {
const coll = this.db.getCollection(tableName),
entity = EntityGenerator.generateEntity(rawEntity, tableName),
res = coll.findOne({ partitionKey: partitionKey, rowKey: rowKey });
if (res !== null) {
// A property cannot be removed with a Merge Entity operation (in contrast to an update operation).
for (const key of Object.keys(entity.attribs)) {
if (entity.attribs[key]) {
res.attribs[key] = entity.attribs[key];
}
}
res.odata = entity.odata;
coll.update(res);
return new EntityProxy(res);
}
return this._createOrUpdateEntity(partitionKey, rowKey, tableName, rawEntity);
}
}

@@ -193,0 +227,0 @@

@@ -11,2 +11,5 @@ 'use strict';

updateEntity = require('./../../actions/table/UpdateEntity'),
insertOrReplaceEntity = require('./../../actions/table/InsertOrReplaceEntity'),
mergeEntity = require('./../../actions/table/MergeEntity'),
insertOrMergeEntity = require('./../../actions/table/InsertOrMergeEntity'),
createTable = require('./../../actions/table/CreateTable');

@@ -55,2 +58,14 @@

updateEntity.process(request, res);
}
actions[Operations.INSERT_OR_REPLACE_ENTITY] = (request, res) => {
insertOrReplaceEntity.process(request, res);
}
actions[Operations.MERGE_ENTITY] = (request, res) => {
mergeEntity.process(request, res);
}
actions[Operations.INSERT_OR_MERGE_ENTITY] = (request, res) => {
insertOrMergeEntity.process(request, res);
}

@@ -84,2 +84,19 @@ 'use strict';

.run(EntityIfMatchVal);
}
validations[Operations.INSERT_OR_REPLACE_ENTITY] = (valContext) => {
valContext
.run(TableExistsVal);
}
validations[Operations.MERGE_ENTITY] = (valContext) => {
valContext
.run(TableExistsVal)
.run(EntityExistsVal)
.run(EntityIfMatchVal);
}
validations[Operations.INSERT_OR_MERGE_ENTITY] = (valContext) => {
valContext
.run(TableExistsVal);
}

10

lib/model/table/EntityGenerator.js

@@ -37,8 +37,12 @@ 'use strict';

const entity = {};
entity.partitionKey = rawEntity.PartitionKey;
entity.rowKey = rawEntity.RowKey;
entity.attribs = rawEntity;
delete entity.attribs.PartitionKey;
delete entity.attribs.RowKey;
for (const key of Object.keys(rawEntity)) {
if (key === 'PartitionKey' || key === 'RowKey') {
continue;
}
entity.attribs[key] = rawEntity[key];
}

@@ -45,0 +49,0 @@ entity.odata = {};

@@ -5,2 +5,3 @@ 'use strict';

AzuriteTableRequest = require('./../../model/table/AzuriteTableRequest'),
N = require('./../../core/HttpHeaderNames'),
Operations = require('./../../core/Constants').Operations.Table;

@@ -25,4 +26,6 @@

if (req.azuriteOperation === undefined) {
req.azuriteOperation = Operations.UPDATE_ENTITY;
req.azuriteRequest = new AzuriteTableRequest({ req: req, payload: req.payload });
req.azuriteOperation = req.azuriteRequest.httpProps[N.IF_MATCH]
? Operations.UPDATE_ENTITY
: Operations.INSERT_OR_REPLACE_ENTITY;
}

@@ -33,3 +36,3 @@ next();

if (req.azuriteOperation === undefined) {
req.azuriteOperation = Operations.INSERT_ENTITY;
req.azuriteOperation = Operations.INSERT_ENTITY
req.azuriteRequest = new AzuriteTableRequest({ req: req, payload: req.payload });

@@ -43,3 +46,10 @@ }

next();
})
.merge((req, res, next) => {
req.azuriteRequest = new AzuriteTableRequest({ req: req, payload: req.payload });
req.azuriteOperation = req.azuriteRequest.httpProps[N.IF_MATCH]
? Operations.MERGE_ENTITY
: Operations.INSERT_OR_MERGE_ENTITY;
next();
});
}

@@ -12,6 +12,5 @@ 'use strict';

validate({ request = undefined, entity = undefined }) {
// This header is not set by some SDKs (see https://github.com/Azure/azure-storage-node/issues/418)
// if (request.httpProps[N.IF_MATCH] === undefined) {
// throw new AError(ErrorCodes.MissingRequiredHeader);
// }
if (request.httpProps[N.IF_MATCH] === undefined) {
throw new AError(ErrorCodes.MissingRequiredHeader);
}
if (request.httpProps[N.IF_MATCH] === '*') {

@@ -18,0 +17,0 @@ return;

{
"name": "azurite",
"version": "2.5.1",
"version": "2.6.0",
"description": "A lightweight server clone of Azure Blob, Queue, and Table Storage that simulates most of the commands supported by it with minimal dependencies.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -165,8 +165,4 @@ # Azurite

ALL DONE except:
- Get Table ACL [TODO]
- Set Table ACL [TODO]
- Merge Entity [TODO]
- Insert or Replace Entity [TODO]
- Insert or Merge Entity [TODO]
- Entity Group Transaction (Batch Operation) [TODO]
# 2.0
## 2.6.0
- support for Merge Entity [#137](https://github.com/arafato/azurite/issues/137)
- support for Insert or Replace Entity [#139](https://github.com/arafato/azurite/issues/139)
- support for Insert Or Merge Entity [#140](https://github.com/arafato/azurite/issues/140)
## 2.5.1

@@ -3,0 +7,0 @@ - fixes [#166](https://github.com/arafato/azurite/issues/166): Blob: ETag in validation is now also properly enclosed in escaped double parenthesis

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc