@esposter/azure 3.0.0 → 3.3.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 +2 -2
- package/dist/index.d.ts +31 -30
- package/dist/index.js +38 -40
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ import type { Clause } from "@esposter/azure";
|
|
|
38
38
|
|
|
39
39
|
import { BinaryOperator } from "@esposter/azure";
|
|
40
40
|
|
|
41
|
-
const clause: Clause<{ createdAt: Date }> = { key: "createdAt", operator: BinaryOperator.
|
|
41
|
+
const clause: Clause<{ createdAt: Date }> = { key: "createdAt", operator: BinaryOperator.Ge, value: new Date(0) };
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
### Values
|
|
@@ -65,7 +65,7 @@ import { BinaryOperator, CompositeKeyPropertyNames, getTableNullClause, serializ
|
|
|
65
65
|
|
|
66
66
|
const roomId = "00000000-0000-0000-0000-000000000000";
|
|
67
67
|
const filter = serializeClauses([
|
|
68
|
-
{ key: CompositeKeyPropertyNames.partitionKey, operator: BinaryOperator.
|
|
68
|
+
{ key: CompositeKeyPropertyNames.partitionKey, operator: BinaryOperator.Eq, value: roomId },
|
|
69
69
|
getTableNullClause("deletedAt"),
|
|
70
70
|
]);
|
|
71
71
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PropertyNames } from "@esposter/shared";
|
|
3
3
|
import { TableEntity } from "@azure/data-tables";
|
|
4
|
-
//#region src/models/BinaryOperator.d.ts
|
|
5
|
-
export declare enum BinaryOperator {
|
|
6
|
-
eq = "eq",
|
|
7
|
-
ge = "ge",
|
|
8
|
-
gt = "gt",
|
|
9
|
-
le = "le",
|
|
10
|
-
lt = "lt",
|
|
11
|
-
ne = "ne"
|
|
12
|
-
}
|
|
13
|
-
export declare const BinaryOperators: readonly BinaryOperator[];
|
|
14
|
-
//#endregion
|
|
15
4
|
//#region src/models/search/SearchOperator.d.ts
|
|
16
5
|
export declare enum SearchOperator {
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
ArrayAny = "arrayAny",
|
|
7
|
+
ArrayContains = "arrayContains"
|
|
19
8
|
}
|
|
20
9
|
//#endregion
|
|
21
|
-
//#region src/models/
|
|
22
|
-
export declare
|
|
10
|
+
//#region src/models/shared/BinaryOperator.d.ts
|
|
11
|
+
export declare enum BinaryOperator {
|
|
12
|
+
Eq = "eq",
|
|
13
|
+
Ge = "ge",
|
|
14
|
+
Gt = "gt",
|
|
15
|
+
Le = "le",
|
|
16
|
+
Lt = "lt",
|
|
17
|
+
Ne = "ne"
|
|
18
|
+
}
|
|
19
|
+
export declare const BinaryOperators: readonly BinaryOperator[];
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/models/shared/SerializableValue.d.ts
|
|
23
22
|
export type SerializableValue = boolean | Date | null | number | string;
|
|
24
23
|
export declare const serializableValueSchema: z.ZodType<SerializableValue, SerializableValue>;
|
|
25
24
|
//#endregion
|
|
26
|
-
//#region src/models/Clause.d.ts
|
|
25
|
+
//#region src/models/shared/Clause.d.ts
|
|
27
26
|
export type Clause<T extends object> = {
|
|
28
27
|
key: keyof T & string;
|
|
29
28
|
not?: boolean;
|
|
@@ -31,25 +30,20 @@ export type Clause<T extends object> = {
|
|
|
31
30
|
operator: BinaryOperator;
|
|
32
31
|
value: SerializableValue;
|
|
33
32
|
} | {
|
|
34
|
-
operator: SearchOperator.
|
|
33
|
+
operator: SearchOperator.ArrayAny;
|
|
35
34
|
} | {
|
|
36
|
-
operator: SearchOperator.
|
|
35
|
+
operator: SearchOperator.ArrayContains;
|
|
37
36
|
value: SerializableValue[];
|
|
38
37
|
});
|
|
39
38
|
//#endregion
|
|
40
|
-
//#region src/models/UnaryOperator.d.ts
|
|
39
|
+
//#region src/models/shared/UnaryOperator.d.ts
|
|
41
40
|
export declare enum UnaryOperator {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
And = "and",
|
|
42
|
+
Not = "not",
|
|
43
|
+
Or = "or"
|
|
45
44
|
}
|
|
46
45
|
//#endregion
|
|
47
|
-
//#region
|
|
48
|
-
export declare const AZURE_MAX_BATCH_SIZE = 100;
|
|
49
|
-
export declare const AZURE_MAX_PAGE_SIZE = 1e3;
|
|
50
|
-
export declare const AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS: number;
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region ../../node_modules/.pnpm/type-fest@5.9.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
46
|
+
//#region ../../node_modules/.pnpm/type-fest@5.10.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
53
47
|
/**
|
|
54
48
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
55
49
|
|
|
@@ -156,9 +150,15 @@ export declare const getSearchNonNullClause: <T extends object>(key: keyof T & s
|
|
|
156
150
|
//#region src/services/search/getSearchNullClause.d.ts
|
|
157
151
|
export declare const getSearchNullClause: <T extends object>(key: keyof T & string) => Clause<T>;
|
|
158
152
|
//#endregion
|
|
153
|
+
//#region src/services/shared/constants.d.ts
|
|
154
|
+
export declare const AZURE_MAX_BATCH_SIZE = 100;
|
|
155
|
+
export declare const AZURE_MAX_PAGE_SIZE = 1e3;
|
|
156
|
+
export declare const SERIALIZABLE_VALUE_MAX_LENGTH = 100;
|
|
157
|
+
export declare const AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS: number;
|
|
158
|
+
//#endregion
|
|
159
159
|
//#region src/services/table/constants.d.ts
|
|
160
|
-
export declare const
|
|
161
|
-
export declare const
|
|
160
|
+
export declare const KEYS_TO_CAPITALIZE: ReadonlySet<string>;
|
|
161
|
+
export declare const KEYS_TO_UNCAPITALIZE: ReadonlySet<string>;
|
|
162
162
|
//#endregion
|
|
163
163
|
//#region src/services/table/deserializeKey.d.ts
|
|
164
164
|
export declare const deserializeKey: (key: string) => string;
|
|
@@ -170,6 +170,7 @@ export declare const getTableNullClause: <T extends object>(key: keyof T & strin
|
|
|
170
170
|
export declare const serializeKey: (key: string) => string;
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/services/transformer/constants.d.ts
|
|
173
|
+
export declare const DATETIME_LITERAL_PREFIX = "datetime'";
|
|
173
174
|
export declare const CLAUSE_REGEX: RegExp;
|
|
174
175
|
//#endregion
|
|
175
176
|
//#region src/services/transformer/deserializeClause.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
//#region src/models/
|
|
2
|
+
import { InvalidOperationError, NotFoundError, Operation, capitalize, getPropertyNames, getResult, normalizeString, takeOne, uncapitalize } from "@esposter/shared";
|
|
3
|
+
//#region src/models/search/SearchOperator.ts
|
|
4
|
+
let SearchOperator = /* @__PURE__ */ function(SearchOperator) {
|
|
5
|
+
SearchOperator["ArrayAny"] = "arrayAny";
|
|
6
|
+
SearchOperator["ArrayContains"] = "arrayContains";
|
|
7
|
+
return SearchOperator;
|
|
8
|
+
}({});
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/models/shared/BinaryOperator.ts
|
|
4
11
|
let BinaryOperator = /* @__PURE__ */ function(BinaryOperator) {
|
|
5
|
-
BinaryOperator["
|
|
6
|
-
BinaryOperator["
|
|
7
|
-
BinaryOperator["
|
|
8
|
-
BinaryOperator["
|
|
9
|
-
BinaryOperator["
|
|
10
|
-
BinaryOperator["
|
|
12
|
+
BinaryOperator["Eq"] = "eq";
|
|
13
|
+
BinaryOperator["Ge"] = "ge";
|
|
14
|
+
BinaryOperator["Gt"] = "gt";
|
|
15
|
+
BinaryOperator["Le"] = "le";
|
|
16
|
+
BinaryOperator["Lt"] = "lt";
|
|
17
|
+
BinaryOperator["Ne"] = "ne";
|
|
11
18
|
return BinaryOperator;
|
|
12
19
|
}({});
|
|
13
20
|
const BinaryOperators = Object.values(BinaryOperator);
|
|
14
21
|
//#endregion
|
|
15
|
-
//#region src/
|
|
22
|
+
//#region src/services/shared/constants.ts
|
|
23
|
+
const AZURE_MAX_BATCH_SIZE = 100;
|
|
24
|
+
const AZURE_MAX_PAGE_SIZE = 1e3;
|
|
16
25
|
const SERIALIZABLE_VALUE_MAX_LENGTH = 100;
|
|
26
|
+
const AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS = Temporal.Duration.from({ days: 7 }).total("milliseconds");
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/models/shared/SerializableValue.ts
|
|
17
29
|
const serializableValueSchema = z.union([
|
|
18
30
|
z.boolean(),
|
|
19
31
|
z.date(),
|
|
@@ -22,26 +34,14 @@ const serializableValueSchema = z.union([
|
|
|
22
34
|
z.string().min(1).max(100)
|
|
23
35
|
]);
|
|
24
36
|
//#endregion
|
|
25
|
-
//#region src/models/UnaryOperator.ts
|
|
37
|
+
//#region src/models/shared/UnaryOperator.ts
|
|
26
38
|
let UnaryOperator = /* @__PURE__ */ function(UnaryOperator) {
|
|
27
|
-
UnaryOperator["
|
|
28
|
-
UnaryOperator["
|
|
29
|
-
UnaryOperator["
|
|
39
|
+
UnaryOperator["And"] = "and";
|
|
40
|
+
UnaryOperator["Not"] = "not";
|
|
41
|
+
UnaryOperator["Or"] = "or";
|
|
30
42
|
return UnaryOperator;
|
|
31
43
|
}({});
|
|
32
44
|
//#endregion
|
|
33
|
-
//#region src/services/constants.ts
|
|
34
|
-
const AZURE_MAX_BATCH_SIZE = 100;
|
|
35
|
-
const AZURE_MAX_PAGE_SIZE = 1e3;
|
|
36
|
-
const AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS = Temporal.Duration.from({ days: 7 }).total("milliseconds");
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/models/search/SearchOperator.ts
|
|
39
|
-
let SearchOperator = /* @__PURE__ */ function(SearchOperator) {
|
|
40
|
-
SearchOperator["arrayAny"] = "arrayAny";
|
|
41
|
-
SearchOperator["arrayContains"] = "arrayContains";
|
|
42
|
-
return SearchOperator;
|
|
43
|
-
}({});
|
|
44
|
-
//#endregion
|
|
45
45
|
//#region src/models/table/CompositeKey.ts
|
|
46
46
|
var CompositeKey = class {};
|
|
47
47
|
const CompositeKeyPropertyNames = getPropertyNames();
|
|
@@ -61,11 +61,11 @@ const getSearchNullClause = (key) => ({
|
|
|
61
61
|
});
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/services/table/constants.ts
|
|
64
|
-
const
|
|
65
|
-
const
|
|
64
|
+
const KEYS_TO_CAPITALIZE = /* @__PURE__ */ new Set([CompositeKeyPropertyNames.partitionKey, CompositeKeyPropertyNames.rowKey]);
|
|
65
|
+
const KEYS_TO_UNCAPITALIZE = /* @__PURE__ */ new Set([capitalize(CompositeKeyPropertyNames.partitionKey), capitalize(CompositeKeyPropertyNames.rowKey)]);
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/services/table/deserializeKey.ts
|
|
68
|
-
const deserializeKey = (key) =>
|
|
68
|
+
const deserializeKey = (key) => KEYS_TO_UNCAPITALIZE.has(key) ? uncapitalize(key) : key;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/services/table/getTableNullClause.ts
|
|
71
71
|
const getTableNullClause = (key) => ({
|
|
@@ -76,35 +76,33 @@ const getTableNullClause = (key) => ({
|
|
|
76
76
|
});
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/services/table/serializeKey.ts
|
|
79
|
-
const serializeKey = (key) =>
|
|
79
|
+
const serializeKey = (key) => KEYS_TO_CAPITALIZE.has(key) ? capitalize(key) : key;
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/services/transformer/constants.ts
|
|
82
|
+
const DATETIME_LITERAL_PREFIX = "datetime'";
|
|
82
83
|
const VALUE_REGEX = [
|
|
83
84
|
true,
|
|
84
85
|
false,
|
|
85
|
-
String.raw
|
|
86
|
+
String.raw`${DATETIME_LITERAL_PREFIX}[^']*'`,
|
|
86
87
|
String.raw`\d{4}-\d{2}-\d{2}T[^\s]+`,
|
|
87
88
|
String(null),
|
|
88
89
|
String.raw`-?\d+(?:\.\d+)?`,
|
|
89
90
|
String(NaN),
|
|
90
91
|
"'(?:[^']|'')*'"
|
|
91
|
-
].join(
|
|
92
|
-
const CLAUSE_REGEX = new RegExp(String.raw`^(?<not>not\s+)?(?<key>[A-Za-z0-9_]*)\s*(?<operator>${BinaryOperators.join(
|
|
92
|
+
].join("|");
|
|
93
|
+
const CLAUSE_REGEX = new RegExp(String.raw`^(?<not>not\s+)?(?<key>[A-Za-z0-9_]*)\s*(?<operator>${BinaryOperators.join("|")})\s+(?<value>${VALUE_REGEX})$`, "iu");
|
|
93
94
|
//#endregion
|
|
94
95
|
//#region src/services/transformer/deserializeValue.ts
|
|
96
|
+
const parseIsoDate = (isoValue) => getResult(() => new Date(Temporal.Instant.from(isoValue).epochMilliseconds)).unwrapOr(void 0);
|
|
95
97
|
const deserializeValue = (serializedValue) => {
|
|
96
98
|
if (serializedValue === String(true)) return true;
|
|
97
99
|
else if (serializedValue === String(false)) return false;
|
|
98
100
|
else if (serializedValue === String(null)) return null;
|
|
99
101
|
else if (Number.isFinite(Number(serializedValue))) return Number(serializedValue);
|
|
100
102
|
else if (serializedValue === String(NaN)) return NaN;
|
|
101
|
-
else if (serializedValue.startsWith("datetime'") && serializedValue.endsWith("'")) return
|
|
103
|
+
else if (serializedValue.startsWith("datetime'") && serializedValue.endsWith("'")) return parseIsoDate(serializedValue.slice(9, -1)) ?? serializedValue;
|
|
102
104
|
else if (serializedValue.startsWith("'") && serializedValue.endsWith("'")) return serializedValue.slice(1, -1).replaceAll("''", "'");
|
|
103
|
-
else
|
|
104
|
-
const date = new Date(serializedValue);
|
|
105
|
-
if (Number.isNaN(date)) return serializedValue;
|
|
106
|
-
else return date;
|
|
107
|
-
}
|
|
105
|
+
else return parseIsoDate(serializedValue) ?? serializedValue;
|
|
108
106
|
};
|
|
109
107
|
//#endregion
|
|
110
108
|
//#region src/services/transformer/deserializeClause.ts
|
|
@@ -135,7 +133,7 @@ const RangeOperators = [
|
|
|
135
133
|
//#endregion
|
|
136
134
|
//#region src/services/transformer/serializeValue.ts
|
|
137
135
|
const serializeValue = (value, isTableFilter = false) => {
|
|
138
|
-
if (value instanceof Date) return isTableFilter ?
|
|
136
|
+
if (value instanceof Date) return isTableFilter ? `${DATETIME_LITERAL_PREFIX}${value.toISOString()}'` : value.toISOString();
|
|
139
137
|
else if (typeof value === "string") return escapeValue(value);
|
|
140
138
|
else return String(value);
|
|
141
139
|
};
|
|
@@ -188,4 +186,4 @@ const getPartitionKeyFilter = (partitionKey) => serializeClauses([{
|
|
|
188
186
|
//#region src/services/transformer/serializeSearchClauses.ts
|
|
189
187
|
const serializeSearchClauses = (clauses) => serializeClausesCore(clauses, false);
|
|
190
188
|
//#endregion
|
|
191
|
-
export { AZURE_MAX_BATCH_SIZE, AZURE_MAX_PAGE_SIZE, AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS, BinaryOperator, BinaryOperators, CLAUSE_REGEX, CompositeKey, CompositeKeyPropertyNames,
|
|
189
|
+
export { AZURE_MAX_BATCH_SIZE, AZURE_MAX_PAGE_SIZE, AZURE_MAX_QUEUE_VISIBILITY_TIMEOUT_MS, BinaryOperator, BinaryOperators, CLAUSE_REGEX, CompositeKey, CompositeKeyPropertyNames, DATETIME_LITERAL_PREFIX, KEYS_TO_CAPITALIZE, KEYS_TO_UNCAPITALIZE, RangeOperators, SERIALIZABLE_VALUE_MAX_LENGTH, SearchOperator, UnaryOperator, deserializeClause, deserializeKey, deserializeValue, escapeValue, getPartitionKeyFilter, getSearchNonNullClause, getSearchNullClause, getTableNullClause, serializableValueSchema, serializeClause, serializeClauses, serializeClausesCore, serializeKey, serializeSearchClauses, serializeValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esposter/azure",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "The Azure wire conventions Esposter's clients and its mocks both speak — OData filter clauses, entity key casing, and service limits.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -47,22 +47,22 @@
|
|
|
47
47
|
"typecheck": "tsc"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@esposter/shared": "3.
|
|
50
|
+
"@esposter/shared": "3.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@arethetypeswrong/core": "^0.18.5",
|
|
54
|
-
"@esposter/configuration": "3.
|
|
54
|
+
"@esposter/configuration": "3.3.0",
|
|
55
55
|
"publint": "^0.3.24",
|
|
56
56
|
"tsdown": "^0.23.0",
|
|
57
|
-
"type-fest": "^5.
|
|
58
|
-
"vitest": "^5.0.
|
|
57
|
+
"type-fest": "^5.10.0",
|
|
58
|
+
"vitest": "^5.0.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@azure/data-tables": "^13.3.2",
|
|
62
|
-
"zod": "^4.6.
|
|
62
|
+
"zod": "^4.6.5"
|
|
63
63
|
},
|
|
64
64
|
"inlinedDependencies": {
|
|
65
|
-
"type-fest": "5.
|
|
65
|
+
"type-fest": "5.10.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "5854a00717502d8de96adc8b44d3621ab85f9b57"
|
|
68
68
|
}
|