azure-mock 2.11.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +26 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm i -D azure-mock
|
|
|
23
23
|
|
|
24
24
|
## <a name="documentation">📖 Documentation</a>
|
|
25
25
|
|
|
26
|
-
We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/
|
|
26
|
+
We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/azure-mock.html) to level up.
|
|
27
27
|
|
|
28
28
|
### Usage
|
|
29
29
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1530,9 +1530,10 @@ declare enum BinaryOperator {
|
|
|
1530
1530
|
gt = "gt",
|
|
1531
1531
|
le = "le",
|
|
1532
1532
|
lt = "lt",
|
|
1533
|
+
ne = "ne",
|
|
1533
1534
|
}
|
|
1534
1535
|
//#endregion
|
|
1535
|
-
//#region src/models/
|
|
1536
|
+
//#region src/models/azure/Literal.d.ts
|
|
1536
1537
|
|
|
1537
1538
|
//#endregion
|
|
1538
1539
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/observable-like.d.ts
|
|
@@ -1593,6 +1594,7 @@ const update2: UpdateOperation<User> = {
|
|
|
1593
1594
|
//#region src/models/tableFilter/Clause.d.ts
|
|
1594
1595
|
interface Clause {
|
|
1595
1596
|
key: string;
|
|
1597
|
+
not?: boolean;
|
|
1596
1598
|
operator: BinaryOperator;
|
|
1597
1599
|
value: string;
|
|
1598
1600
|
}
|
|
@@ -1609,7 +1611,14 @@ declare const CLAUSE_REGEX: RegExp;
|
|
|
1609
1611
|
//#region src/util/tableFilter/createTableFilterPredicate.d.ts
|
|
1610
1612
|
declare const createTableFilterPredicate: <T extends object>(filter: string) => ((entity: TableEntity<T>) => boolean);
|
|
1611
1613
|
//#endregion
|
|
1614
|
+
//#region src/util/tableFilter/isNullClause.d.ts
|
|
1615
|
+
declare const isNullClause: ({
|
|
1616
|
+
not,
|
|
1617
|
+
operator,
|
|
1618
|
+
value
|
|
1619
|
+
}: Clause) => boolean;
|
|
1620
|
+
//#endregion
|
|
1612
1621
|
//#region src/util/tableFilter/parseClause.d.ts
|
|
1613
1622
|
declare const parseClause: (rawClause: string) => Clause;
|
|
1614
1623
|
//#endregion
|
|
1615
|
-
export { BlobHierarchyItem, CLAUSE_REGEX, Clause, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, parseClause, toWebResourceLike };
|
|
1624
|
+
export { BlobHierarchyItem, CLAUSE_REGEX, Clause, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, PageSettings, PagedAsyncIterableIterator, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, parseClause, toWebResourceLike };
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,13 @@ let BinaryOperator = /* @__PURE__ */ function(BinaryOperator$1) {
|
|
|
11
11
|
BinaryOperator$1["gt"] = "gt";
|
|
12
12
|
BinaryOperator$1["le"] = "le";
|
|
13
13
|
BinaryOperator$1["lt"] = "lt";
|
|
14
|
+
BinaryOperator$1["ne"] = "ne";
|
|
14
15
|
return BinaryOperator$1;
|
|
15
16
|
}({});
|
|
17
|
+
let Literal = /* @__PURE__ */ function(Literal$1) {
|
|
18
|
+
Literal$1["NaN"] = "NaN";
|
|
19
|
+
return Literal$1;
|
|
20
|
+
}({});
|
|
16
21
|
var InvalidOperationError = class extends Error {
|
|
17
22
|
constructor(operation, name, message) {
|
|
18
23
|
super(`Invalid operation: ${operation}, name: ${name}, ${message}`);
|
|
@@ -1135,12 +1140,18 @@ const compare = (operator, leftHandSide, rightHandSide) => {
|
|
|
1135
1140
|
case BinaryOperator.gt: return leftHandSide > rightHandSide;
|
|
1136
1141
|
case BinaryOperator.le: return leftHandSide <= rightHandSide;
|
|
1137
1142
|
case BinaryOperator.lt: return leftHandSide < rightHandSide;
|
|
1143
|
+
case BinaryOperator.ne: return leftHandSide !== rightHandSide;
|
|
1144
|
+
default: exhaustiveGuard(operator);
|
|
1138
1145
|
}
|
|
1139
1146
|
};
|
|
1140
1147
|
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/util/tableFilter/isNullClause.ts
|
|
1150
|
+
const isNullClause = ({ not, operator, value }) => Boolean(not) && operator === BinaryOperator.ne && value === Literal.NaN;
|
|
1151
|
+
|
|
1141
1152
|
//#endregion
|
|
1142
1153
|
//#region src/util/tableFilter/constants.ts
|
|
1143
|
-
const CLAUSE_REGEX =
|
|
1154
|
+
const CLAUSE_REGEX = new RegExp(`^(?<not>not\\s+)?(?<key>[A-Za-z0-9_]+)\\s+(?<operator>${Object.values(BinaryOperator).join("|")})\\s+(?<value>'[^']*'|${Object.values(Literal).join("|")})$`, "i");
|
|
1144
1155
|
|
|
1145
1156
|
//#endregion
|
|
1146
1157
|
//#region src/util/tableFilter/parseClause.ts
|
|
@@ -1149,18 +1160,19 @@ const parseClause = (rawClause) => {
|
|
|
1149
1160
|
if (!match) throw new NotFoundError(parseClause.name, rawClause);
|
|
1150
1161
|
const groups = match.groups;
|
|
1151
1162
|
if (!groups) throw new NotFoundError(parseClause.name, rawClause);
|
|
1152
|
-
const
|
|
1163
|
+
const normalizedValue = groups.value.startsWith("'") && groups.value.endsWith("'") ? groups.value.slice(1, -1) : groups.value;
|
|
1153
1164
|
return {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1165
|
+
...groups,
|
|
1166
|
+
not: Boolean(groups.not),
|
|
1167
|
+
operator: groups.operator,
|
|
1168
|
+
value: normalizedValue
|
|
1157
1169
|
};
|
|
1158
1170
|
};
|
|
1159
1171
|
|
|
1160
1172
|
//#endregion
|
|
1161
1173
|
//#region src/util/tableFilter/createTableFilterPredicate.ts
|
|
1162
1174
|
const createTableFilterPredicate = (filter) => {
|
|
1163
|
-
const normalizedFilter = filter.replaceAll(String.raw`(`, "").replaceAll(String.raw`)`, "");
|
|
1175
|
+
const normalizedFilter = filter.replaceAll(String.raw`(`, " ").replaceAll(String.raw`)`, "");
|
|
1164
1176
|
const andGroups = normalizedFilter.split(/\s+and\s+/i).filter(Boolean);
|
|
1165
1177
|
const orGroups = andGroups.map((group) => group.split(/\s+or\s+/i).filter(Boolean));
|
|
1166
1178
|
return (entity) => {
|
|
@@ -1174,7 +1186,13 @@ const createTableFilterPredicate = (filter) => {
|
|
|
1174
1186
|
filter,
|
|
1175
1187
|
key: normalizedClauseKey
|
|
1176
1188
|
}));
|
|
1177
|
-
|
|
1189
|
+
let isMatched = false;
|
|
1190
|
+
if (isNullClause(clause)) isMatched = compare(BinaryOperator.eq, String(entity[normalizedClauseKey]), "null");
|
|
1191
|
+
else {
|
|
1192
|
+
const comparisonResult = compare(clause.operator, String(entity[normalizedClauseKey]), clause.value);
|
|
1193
|
+
isMatched = clause.not ? !comparisonResult : comparisonResult;
|
|
1194
|
+
}
|
|
1195
|
+
if (isMatched) {
|
|
1178
1196
|
isGroupMatched = true;
|
|
1179
1197
|
break;
|
|
1180
1198
|
}
|
|
@@ -1321,4 +1339,4 @@ var MockTableClient = class {
|
|
|
1321
1339
|
};
|
|
1322
1340
|
|
|
1323
1341
|
//#endregion
|
|
1324
|
-
export { CLAUSE_REGEX, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isReadableStream, parseClause, toWebResourceLike };
|
|
1342
|
+
export { CLAUSE_REGEX, MockBlobBatchClient, MockBlobClient, MockBlockBlobClient, MockContainerClient, MockContainerDatabase, MockRestError, MockTableClient, MockTableDatabase, applyTableFilter, bodyToBuffer, compare, createTableFilterPredicate, getAzureErrorXml, getBlobItemXml, getBlobPrefixXml, getListBlobsXml, isNullClause, isReadableStream, parseClause, toWebResourceLike };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "A library that contains azure mock classes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/Esposter/Esposter#readme",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@azure/data-tables": "^13.3.1",
|
|
37
37
|
"@azure/storage-blob": "^12.28.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "1765c0d90ecc03c94e942d88b8d8da962a8f53bc"
|
|
40
40
|
}
|