@effect-app/infra 0.118.0 → 0.119.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/CHANGELOG.md +6 -0
- package/_cjs/services/Repository.cjs +4 -38
- package/_cjs/services/Repository.cjs.map +1 -1
- package/_cjs/services/RepositoryBase.cjs +39 -36
- package/_cjs/services/RepositoryBase.cjs.map +1 -1
- package/_cjs/services/Store/Cosmos/query.cjs +291 -0
- package/_cjs/services/Store/Cosmos/query.cjs.map +1 -0
- package/_cjs/services/Store/Cosmos.cjs +38 -183
- package/_cjs/services/Store/Cosmos.cjs.map +1 -1
- package/_cjs/services/Store/Cosmos.test.cjs +7 -7
- package/_cjs/services/Store/Cosmos.test.cjs.map +1 -1
- package/_cjs/services/Store/Memory.cjs +20 -17
- package/_cjs/services/Store/Memory.cjs.map +1 -1
- package/_cjs/services/Store/Redis.cjs +1 -1
- package/_cjs/services/Store/Redis.cjs.map +1 -1
- package/_cjs/services/Store/codeFilter.cjs +151 -0
- package/_cjs/services/Store/codeFilter.cjs.map +1 -0
- package/_cjs/services/Store/filterApi/proxy.cjs +40 -0
- package/_cjs/services/Store/filterApi/proxy.cjs.map +1 -0
- package/_cjs/services/Store/filterApi/query.cjs +173 -0
- package/_cjs/services/Store/filterApi/query.cjs.map +1 -0
- package/_cjs/services/Store/filterApi.test.cjs +164 -0
- package/_cjs/services/Store/filterApi.test.cjs.map +1 -0
- package/_cjs/services/Store/service.cjs.map +1 -1
- package/_cjs/services/Store/utils.cjs +8 -1
- package/_cjs/services/Store/utils.cjs.map +1 -1
- package/_src/services/Repository.ts +124 -70
- package/_src/services/RepositoryBase.ts +26 -12
- package/_src/services/Store/Cosmos/query.ts +390 -0
- package/_src/services/Store/Cosmos.test.ts +5 -5
- package/_src/services/Store/Cosmos.ts +39 -245
- package/_src/services/Store/Memory.ts +21 -18
- package/_src/services/Store/Redis.ts +2 -3
- package/_src/services/Store/codeFilter.ts +150 -0
- package/_src/services/Store/filterApi/proxy.ts +109 -0
- package/_src/services/Store/filterApi/query.ts +256 -0
- package/_src/services/Store/filterApi.test.ts +263 -0
- package/_src/services/Store/service.ts +17 -5
- package/_src/services/Store/utils.ts +10 -7
- package/dist/services/Repository.d.ts +44 -104
- package/dist/services/Repository.d.ts.map +1 -1
- package/dist/services/Repository.js +6 -30
- package/dist/services/RepositoryBase.d.ts +11 -21
- package/dist/services/RepositoryBase.d.ts.map +1 -1
- package/dist/services/RepositoryBase.js +41 -37
- package/dist/services/Store/Cosmos/query.d.ts +61 -0
- package/dist/services/Store/Cosmos/query.d.ts.map +1 -0
- package/dist/services/Store/Cosmos/query.js +302 -0
- package/dist/services/Store/Cosmos.d.ts +3 -47
- package/dist/services/Store/Cosmos.d.ts.map +1 -1
- package/dist/services/Store/Cosmos.js +39 -193
- package/dist/services/Store/Memory.d.ts +2 -7
- package/dist/services/Store/Memory.d.ts.map +1 -1
- package/dist/services/Store/Memory.js +17 -15
- package/dist/services/Store/Redis.d.ts.map +1 -1
- package/dist/services/Store/Redis.js +2 -2
- package/dist/services/Store/codeFilter.d.ts +5 -0
- package/dist/services/Store/codeFilter.d.ts.map +1 -0
- package/dist/services/Store/codeFilter.js +140 -0
- package/dist/services/Store/filterApi/proxy.d.ts +41 -0
- package/dist/services/Store/filterApi/proxy.d.ts.map +1 -0
- package/dist/services/Store/filterApi/proxy.js +41 -0
- package/dist/services/Store/filterApi/query.d.ts +64 -0
- package/dist/services/Store/filterApi/query.d.ts.map +1 -0
- package/dist/services/Store/filterApi/query.js +134 -0
- package/dist/services/Store/filterApi.test.d.ts.map +1 -0
- package/dist/services/Store/service.d.ts +12 -5
- package/dist/services/Store/service.d.ts.map +1 -1
- package/dist/services/Store/service.js +1 -1
- package/dist/services/Store/utils.d.ts +7 -1
- package/dist/services/Store/utils.d.ts.map +1 -1
- package/dist/services/Store/utils.js +118 -115
- package/package.json +44 -4
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildCosmosQuery = buildCosmosQuery;
|
|
7
|
+
exports.buildFilterJoinSelectCosmosQuery = buildFilterJoinSelectCosmosQuery;
|
|
8
|
+
exports.buildFindJoinCosmosQuery = buildFindJoinCosmosQuery;
|
|
9
|
+
exports.buildLegacyCosmosQuery = buildLegacyCosmosQuery;
|
|
10
|
+
exports.buildWhereCosmosQuery = buildWhereCosmosQuery;
|
|
11
|
+
exports.buildWhereCosmosQuery3 = buildWhereCosmosQuery3;
|
|
12
|
+
exports.logQuery = logQuery;
|
|
13
|
+
var tsplus_module_1 = _interopRequireWildcard(require("effect/Effect"));
|
|
14
|
+
var tsplus_module_2 = _interopRequireWildcard(require("effect/Equivalence"));
|
|
15
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/core/_ext/ord.ext"));
|
|
16
|
+
var tsplus_module_4 = _interopRequireWildcard(require("effect/ReadonlyArray"));
|
|
17
|
+
var _utils = require("@effect-app/prelude/utils");
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
+
function logQuery(q) {
|
|
21
|
+
return tsplus_module_1.logDebug("cosmos query").pipe(tsplus_module_1.annotateLogs({
|
|
22
|
+
query: q.query,
|
|
23
|
+
parameters: JSON.stringify(q.parameters.reduce((acc, v) => {
|
|
24
|
+
acc[v.name] = v.value;
|
|
25
|
+
return acc;
|
|
26
|
+
}, {}), undefined, 2)
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated: should build Select into Where query
|
|
31
|
+
*/
|
|
32
|
+
function buildFilterJoinSelectCosmosQuery(filter, k, name, skip, limit) {
|
|
33
|
+
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
34
|
+
return {
|
|
35
|
+
query: `
|
|
36
|
+
SELECT r, f.id as _rootId
|
|
37
|
+
FROM ${name} f
|
|
38
|
+
JOIN r IN f.${k}
|
|
39
|
+
WHERE LOWER(r.${filter.valueKey}) = LOWER(@value)
|
|
40
|
+
${lm}
|
|
41
|
+
`,
|
|
42
|
+
parameters: [{
|
|
43
|
+
name: "@value",
|
|
44
|
+
value: filter.value
|
|
45
|
+
}]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated: is now part of Where query as k.-1.valueKey
|
|
50
|
+
*/
|
|
51
|
+
function buildFindJoinCosmosQuery(filter, k, name, skip, limit) {
|
|
52
|
+
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
53
|
+
return {
|
|
54
|
+
query: `
|
|
55
|
+
SELECT DISTINCT VALUE f
|
|
56
|
+
FROM ${name} f
|
|
57
|
+
JOIN r IN f.${k}
|
|
58
|
+
WHERE LOWER(r.${filter.valueKey}) = LOWER(@value)
|
|
59
|
+
${lm}`,
|
|
60
|
+
parameters: [{
|
|
61
|
+
name: "@value",
|
|
62
|
+
value: filter.value
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated: should build into Where query
|
|
68
|
+
*/
|
|
69
|
+
function buildLegacyCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
70
|
+
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
71
|
+
return {
|
|
72
|
+
query: `
|
|
73
|
+
SELECT *
|
|
74
|
+
FROM ${name} f
|
|
75
|
+
WHERE f.id != @id AND f.${String(filter.by)} LIKE @filter
|
|
76
|
+
${lm}`,
|
|
77
|
+
parameters: [{
|
|
78
|
+
name: "@id",
|
|
79
|
+
value: importedMarkerId
|
|
80
|
+
}, {
|
|
81
|
+
name: "@filter",
|
|
82
|
+
value: filter.type === "endsWith" ? `%${filter.value}` : filter.type === "contains" ? `%${filter.value}%` : `${filter.value}%`
|
|
83
|
+
}]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function buildWhereCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
87
|
+
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
88
|
+
return {
|
|
89
|
+
query: `
|
|
90
|
+
SELECT *
|
|
91
|
+
FROM ${name} f
|
|
92
|
+
${tsplus_module_3.uniqArray(tsplus_module_2.string)(filter.where.filter(_ => _.key.includes(".-1.")).map(_ => _.key.split(".-1.")[0]).map(_ => `JOIN ${_} IN f.${_}`)).join("\n")}
|
|
93
|
+
WHERE f.id != @id AND ${filter.where.map(_ => _.key.includes(".-1.") ? {
|
|
94
|
+
..._,
|
|
95
|
+
f: _.key.split(".-1.")[0],
|
|
96
|
+
key: _.key.split(".-1.")[1]
|
|
97
|
+
} : {
|
|
98
|
+
..._,
|
|
99
|
+
f: "f"
|
|
100
|
+
}).map((x, i) => {
|
|
101
|
+
const k = `${x.f}.${x.key}`;
|
|
102
|
+
const v = `@v${i}`;
|
|
103
|
+
switch (x.t) {
|
|
104
|
+
case "in":
|
|
105
|
+
return `ARRAY_CONTAINS(${v}, ${k})`;
|
|
106
|
+
case "not-in":
|
|
107
|
+
return `(NOT ARRAY_CONTAINS(${v}, ${k}))`;
|
|
108
|
+
case "includes":
|
|
109
|
+
return `ARRAY_CONTAINS(${k}, ${v})`;
|
|
110
|
+
case "not-includes":
|
|
111
|
+
return `(NOT ARRAY_CONTAINS(${k}, ${v}))`;
|
|
112
|
+
case "contains":
|
|
113
|
+
return `CONTAINS(${k}, ${v}, true)`;
|
|
114
|
+
case "starts-with":
|
|
115
|
+
return `STARTSWITH(${k}, ${v}, true)`;
|
|
116
|
+
case "ends-with":
|
|
117
|
+
return `ENDSWITH(${k}, ${v}, true)`;
|
|
118
|
+
case "not-contains":
|
|
119
|
+
return `NOT(CONTAINS(${k}, ${v}, true))`;
|
|
120
|
+
case "not-starts-with":
|
|
121
|
+
return `NOT(STARTSWITH(${k}, ${v}, true))`;
|
|
122
|
+
case "not-ends-with":
|
|
123
|
+
return `NOT(ENDSWITH(${k}, ${v}, true))`;
|
|
124
|
+
}
|
|
125
|
+
const lk = lowerIfNeeded(k, x.value);
|
|
126
|
+
const lv = lowerIfNeeded(v, x.value);
|
|
127
|
+
switch (x.t) {
|
|
128
|
+
case "lt":
|
|
129
|
+
return `${lk} < ${lv}`;
|
|
130
|
+
case "lte":
|
|
131
|
+
return `${lk} <= ${lv}`;
|
|
132
|
+
case "gt":
|
|
133
|
+
return `${lk} > ${lv}`;
|
|
134
|
+
case "gte":
|
|
135
|
+
return `${lk} >= ${lv}`;
|
|
136
|
+
case "not-eq":
|
|
137
|
+
return x.value === null ? `IS_NULL(${k}) = false` : `${lk} <> ${lv}`;
|
|
138
|
+
case undefined:
|
|
139
|
+
case "eq":
|
|
140
|
+
return x.value === null ? `IS_NULL(${k}) = true` : `${lk} = ${lv}`;
|
|
141
|
+
}
|
|
142
|
+
}).join(filter.mode === "or" ? " OR " : " AND ")}
|
|
143
|
+
${lm}`,
|
|
144
|
+
parameters: [{
|
|
145
|
+
name: "@id",
|
|
146
|
+
value: importedMarkerId
|
|
147
|
+
}, ...filter.where.map((x, i) => ({
|
|
148
|
+
name: `@v${i}`,
|
|
149
|
+
value: x.value
|
|
150
|
+
}))]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// function isArray(t: SupportedValues | readonly SupportedValues[]): t is readonly SupportedValues[] {
|
|
154
|
+
// return Array.isArray(t)
|
|
155
|
+
// }
|
|
156
|
+
function lowerIfNeeded(key, value) {
|
|
157
|
+
return typeof value === "string" ? `LOWER(${key})` : `${key}`;
|
|
158
|
+
}
|
|
159
|
+
function buildCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
160
|
+
return filter.type === "startsWith" || filter.type === "endsWith" || filter.type === "contains" ? buildLegacyCosmosQuery(filter, name, importedMarkerId, skip, limit) : buildWhereCosmosQuery(filter, name, importedMarkerId, skip, limit);
|
|
161
|
+
}
|
|
162
|
+
function buildWhereCosmosQuery3(filter, name, importedMarkerId, select, skip, limit) {
|
|
163
|
+
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
164
|
+
const statement = (x, i) => {
|
|
165
|
+
const k = x.path.includes(".-1.") ? `${x.path.split(".-1.")[0]}.${x.path.split(".-1.")[1]}` : `f.${x.path}`;
|
|
166
|
+
const v = "@v" + i;
|
|
167
|
+
switch (x.op) {
|
|
168
|
+
case "in":
|
|
169
|
+
return `ARRAY_CONTAINS(${v}, ${k})`;
|
|
170
|
+
case "notIn":
|
|
171
|
+
return `(NOT ARRAY_CONTAINS(${v}, ${k}))`;
|
|
172
|
+
case "includes":
|
|
173
|
+
return `ARRAY_CONTAINS(${k}, ${v})`;
|
|
174
|
+
case "notIncludes":
|
|
175
|
+
return `(NOT ARRAY_CONTAINS(${k}, ${v}))`;
|
|
176
|
+
case "contains":
|
|
177
|
+
return `CONTAINS(${k}, ${v}, true)`;
|
|
178
|
+
case "startsWith":
|
|
179
|
+
return `STARTSWITH(${k}, ${v}, true)`;
|
|
180
|
+
case "endsWith":
|
|
181
|
+
return `ENDSWITH(${k}, ${v}, true)`;
|
|
182
|
+
case "notContains":
|
|
183
|
+
return `NOT(CONTAINS(${k}, ${v}, true))`;
|
|
184
|
+
case "notStartsWith":
|
|
185
|
+
return `NOT(STARTSWITH(${k}, ${v}, true))`;
|
|
186
|
+
case "notEndsWith":
|
|
187
|
+
return `NOT(ENDSWITH(${k}, ${v}, true))`;
|
|
188
|
+
}
|
|
189
|
+
const lk = lowerIfNeeded(k, x.value);
|
|
190
|
+
const lv = lowerIfNeeded(v, x.value);
|
|
191
|
+
switch (x.op) {
|
|
192
|
+
case "lt":
|
|
193
|
+
return `${lk} < ${lv}`;
|
|
194
|
+
case "lte":
|
|
195
|
+
return `${lk} <= ${lv}`;
|
|
196
|
+
case "gt":
|
|
197
|
+
return `${lk} > ${lv}`;
|
|
198
|
+
case "gte":
|
|
199
|
+
return `${lk} >= ${lv}`;
|
|
200
|
+
case "neq":
|
|
201
|
+
return x.value === null ? `IS_NULL(${k}) = false` : `${lk} <> ${lv}`;
|
|
202
|
+
case undefined:
|
|
203
|
+
case "eq":
|
|
204
|
+
return x.value === null ? `IS_NULL(${k}) = true` : `${lk} = ${lv}`;
|
|
205
|
+
default:
|
|
206
|
+
{
|
|
207
|
+
return (0, _utils.assertUnreachable)(x.op);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
let i = 0;
|
|
212
|
+
const print = state => {
|
|
213
|
+
let s = "";
|
|
214
|
+
let l = 0;
|
|
215
|
+
const printN = n => {
|
|
216
|
+
return n === 0 ? "" : tsplus_module_4.range(1, n).map(() => " ").join("");
|
|
217
|
+
};
|
|
218
|
+
for (const e of state) {
|
|
219
|
+
switch (e.t) {
|
|
220
|
+
case "where":
|
|
221
|
+
s += statement(e, i++);
|
|
222
|
+
break;
|
|
223
|
+
case "or":
|
|
224
|
+
s += ` OR ${statement(e, i++)}`;
|
|
225
|
+
break;
|
|
226
|
+
case "and":
|
|
227
|
+
s += ` AND ${statement(e, i++)}`;
|
|
228
|
+
break;
|
|
229
|
+
case "or-scope":
|
|
230
|
+
{
|
|
231
|
+
;
|
|
232
|
+
++l;
|
|
233
|
+
s += ` OR (\n${printN(l + 1)}${print(e.result)}\n${printN(l)})`;
|
|
234
|
+
--l;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case "and-scope":
|
|
238
|
+
{
|
|
239
|
+
;
|
|
240
|
+
++l;
|
|
241
|
+
s += ` AND (\n${printN(l + 1)}${print(e.result)}\n${printN(l)})`;
|
|
242
|
+
--l;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
case "where-scope":
|
|
246
|
+
{
|
|
247
|
+
// ;++l
|
|
248
|
+
s += `(\n${printN(l + 1)}${print(e.result)}\n)`;
|
|
249
|
+
// ;--l
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return s;
|
|
255
|
+
};
|
|
256
|
+
// const fff = (filter: readonly FilterR[], mode: "AND" | "OR") =>
|
|
257
|
+
// "(" + filter
|
|
258
|
+
// .map((_) =>
|
|
259
|
+
// _.path.includes(".-1.")
|
|
260
|
+
// ? { ..._, f: _.path.split(".-1.")[0], key: _.path.split(".-1.")[1]! }
|
|
261
|
+
// : { ..._, f: "f" }
|
|
262
|
+
// )
|
|
263
|
+
// .map(
|
|
264
|
+
// (x, i) => {
|
|
265
|
+
// const k = `${x.f}.${x.path}`
|
|
266
|
+
// const v = `@v${i}`
|
|
267
|
+
// return statement(x, k, v)
|
|
268
|
+
// }
|
|
269
|
+
// )
|
|
270
|
+
// .join(mode === "OR" ? " OR " : " AND ") + ")"
|
|
271
|
+
const getValues = filter => filter.flatMap(_ => _.t === "and-scope" || _.t === "or-scope" || _.t === "where-scope" ? getValues(_.result) : [_]);
|
|
272
|
+
const values = getValues(filter);
|
|
273
|
+
return {
|
|
274
|
+
query: `
|
|
275
|
+
SELECT ${select ? `VALUE {\n${select.map(_ => `${_}: f.${_}`).join(",\n")}\n}` : "*"}
|
|
276
|
+
FROM ${name} f
|
|
277
|
+
|
|
278
|
+
${tsplus_module_3.uniqArray(tsplus_module_2.string)(values.filter(_ => _.path.includes(".-1.")).map(_ => _.path.split(".-1.")[0]).map(_ => `JOIN ${_} IN f.${_}`)).join("\n")}
|
|
279
|
+
|
|
280
|
+
WHERE f.id != @id ${filter.length ? `AND ${print(filter)}` : ""}
|
|
281
|
+
${lm}`,
|
|
282
|
+
parameters: [{
|
|
283
|
+
name: "@id",
|
|
284
|
+
value: importedMarkerId
|
|
285
|
+
}, ...values.map((x, i) => ({
|
|
286
|
+
name: `@v${i}`,
|
|
287
|
+
value: x.value
|
|
288
|
+
}))]
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=query.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.cjs","names":["_utils","require","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","logQuery","q","tsplus_module_1","logDebug","pipe","annotateLogs","query","parameters","JSON","stringify","reduce","acc","v","name","value","undefined","buildFilterJoinSelectCosmosQuery","filter","k","skip","limit","lm","valueKey","buildFindJoinCosmosQuery","buildLegacyCosmosQuery","importedMarkerId","String","by","type","buildWhereCosmosQuery","tsplus_module_3","uniqArray","tsplus_module_2","string","where","_","key","includes","map","split","join","f","x","lk","lowerIfNeeded","lv","mode","buildCosmosQuery","buildWhereCosmosQuery3","select","statement","path","op","assertUnreachable","print","state","s","l","printN","tsplus_module_4","range","result","getValues","flatMap","values","length"],"sources":["../../../../_src/services/Store/Cosmos/query.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAA6D,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAA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B,MAAM,CAACgD,MAAM,GAAG,OAAOX,KAAK,CAACrC,MAAM,CAAC,EAAE,GAAG,EAAE;MAC7DI,EAAE,EAAE;IACNd,UAAU,EAAE,CACV;MAAEM,IAAI,EAAE,KAAK;MAAEC,KAAK,EAAEW;IAAgB,CAAE,EACxC,GAAGuC,MAAM,CACN1B,GAAG,CAAC,CAACI,CAAC,EAAE5C,CAAC,MAAM;MACde,IAAI,EAAE,KAAKf,CAAC,EAAE;MACdgB,KAAK,EAAE4B,CAAC,CAAC5B;KACV,CAAC,CAAC;GAER;AACH"}
|
|
@@ -4,31 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CosmosStoreLive = CosmosStoreLive;
|
|
7
|
-
exports.buildCosmosQuery = buildCosmosQuery;
|
|
8
|
-
exports.buildFilterJoinSelectCosmosQuery = buildFilterJoinSelectCosmosQuery;
|
|
9
|
-
exports.buildFindJoinCosmosQuery = buildFindJoinCosmosQuery;
|
|
10
|
-
exports.buildLegacyCosmosQuery = buildLegacyCosmosQuery;
|
|
11
|
-
exports.buildWhereCosmosQuery = buildWhereCosmosQuery;
|
|
12
7
|
exports.makeCosmosStore = makeCosmosStore;
|
|
13
8
|
var tsplus_module_1 = _interopRequireWildcard(require("effect/Effect"));
|
|
14
|
-
var tsplus_module_2 = _interopRequireWildcard(require("effect/
|
|
15
|
-
var tsplus_module_3 = _interopRequireWildcard(require("
|
|
16
|
-
var tsplus_module_4 = _interopRequireWildcard(require("effect/
|
|
17
|
-
var tsplus_module_5 = _interopRequireWildcard(require("
|
|
9
|
+
var tsplus_module_2 = _interopRequireWildcard(require("effect/Layer"));
|
|
10
|
+
var tsplus_module_3 = _interopRequireWildcard(require("effect/Option"));
|
|
11
|
+
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/core/Array"));
|
|
12
|
+
var tsplus_module_5 = _interopRequireWildcard(require("effect/Chunk"));
|
|
13
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect-app/core/_ext/Iterable"));
|
|
18
14
|
var _utils = _interopRequireWildcard(require("@effect-app/prelude/utils"));
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var tsplus_module_8 = _interopRequireWildcard(require("effect/Equivalence"));
|
|
22
|
-
var tsplus_module_9 = _interopRequireWildcard(require("@effect-app/core/_ext/ord.ext"));
|
|
23
|
-
var tsplus_module_10 = _interopRequireWildcard(require("effect/Layer"));
|
|
15
|
+
var tsplus_module_7 = _utils;
|
|
16
|
+
var tsplus_module_8 = _interopRequireWildcard(require("@effect-app/core/Effect"));
|
|
24
17
|
var _cosmosClient = require("@effect-app/infra-adapters/cosmos-client");
|
|
25
18
|
var _errors = require("../../errors.cjs");
|
|
19
|
+
var _query = require("./Cosmos/query.cjs");
|
|
26
20
|
var _service = require("./service.cjs");
|
|
27
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
28
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
23
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
function CosmosStoreLive(config) {
|
|
26
|
+
return tsplus_module_2.effect(_service.StoreMaker)(tsplus_module_1.flatMap(tsplus_module_1.config(config), makeCosmosStore));
|
|
27
|
+
}
|
|
28
|
+
class CosmosDbOperationError {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
this.message = message;
|
|
31
|
+
}
|
|
32
|
+
} // TODO: Retry operation when running into RU limit.
|
|
32
33
|
function makeCosmosStore({
|
|
33
34
|
prefix
|
|
34
35
|
}) {
|
|
@@ -52,7 +53,7 @@ function makeCosmosStore({
|
|
|
52
53
|
const bulkSet = items => tsplus_module_1.withSpan(tsplus_module_1.gen(function* ($) {
|
|
53
54
|
// TODO: disable batching if need atomicity
|
|
54
55
|
// we delay and batch to keep low amount of RUs
|
|
55
|
-
const b = [...items].map(x => [x,
|
|
56
|
+
const b = [...items].map(x => [x, tsplus_module_3.match(tsplus_module_3.fromNullable(x._etag), {
|
|
56
57
|
onNone: () => ({
|
|
57
58
|
operationType: "Create",
|
|
58
59
|
resourceBody: {
|
|
@@ -72,8 +73,8 @@ function makeCosmosStore({
|
|
|
72
73
|
partitionKey: config?.partitionValue(x)
|
|
73
74
|
})
|
|
74
75
|
})]);
|
|
75
|
-
const batches =
|
|
76
|
-
const batchResult = yield* $(
|
|
76
|
+
const batches = tsplus_module_5.toReadonlyArray(tsplus_module_4.chunk_(b, config?.maxBulkSize ?? 10));
|
|
77
|
+
const batchResult = yield* $(tsplus_module_6.ext_forEach(batches.map((x, i) => [i, x]), ([i, batch]) => tsplus_module_1.flatMap(tsplus_module_1.delay(tsplus_module_1.promise(() => bulk(batch.map(([, op]) => op))), tsplus_module_4.millis_(i === 0 ? 0 : 1100)), responses => tsplus_module_1.gen(function* ($) {
|
|
77
78
|
const r = responses.find(x => x.statusCode === 412 || x.statusCode === 404);
|
|
78
79
|
if (r) {
|
|
79
80
|
return yield* $(tsplus_module_1.fail(new _errors.OptimisticConcurrencyException({
|
|
@@ -100,7 +101,7 @@ function makeCosmosStore({
|
|
|
100
101
|
});
|
|
101
102
|
const batchSet = items => {
|
|
102
103
|
return tsplus_module_1.withSpan(tsplus_module_1.suspend(() => {
|
|
103
|
-
const batch = [...items].map(x => [x,
|
|
104
|
+
const batch = [...items].map(x => [x, tsplus_module_3.match(tsplus_module_3.fromNullable(x._etag), {
|
|
104
105
|
onNone: () => ({
|
|
105
106
|
operationType: "Create",
|
|
106
107
|
resourceBody: {
|
|
@@ -151,7 +152,7 @@ function makeCosmosStore({
|
|
|
151
152
|
name: "@id",
|
|
152
153
|
value: importedMarkerId
|
|
153
154
|
}]
|
|
154
|
-
})), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
155
|
+
})), q => (0, _query.logQuery)(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
155
156
|
resources
|
|
156
157
|
}) => resources))), "Cosmos.all [effect-app/infra/Store]", {
|
|
157
158
|
attributes: {
|
|
@@ -159,10 +160,10 @@ function makeCosmosStore({
|
|
|
159
160
|
"repository.model_name": name
|
|
160
161
|
}
|
|
161
162
|
}),
|
|
162
|
-
filterJoinSelect: (filter, cursor) => tsplus_module_1.withSpan(tsplus_module_1.map(
|
|
163
|
+
filterJoinSelect: (filter, cursor) => tsplus_module_1.withSpan(tsplus_module_1.map(tsplus_module_6.ext_forEach(filter.keys, k => tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => (0, _query.buildFilterJoinSelectCosmosQuery)(filter, k, name, cursor?.skip, cursor?.limit)), q => (0, _query.logQuery)(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
163
164
|
resources
|
|
164
165
|
}) => resources)))), a => {
|
|
165
|
-
const v = a.flatMap(_ => _).map(x =>
|
|
166
|
+
const v = a.flatMap(_ => _).map(x => tsplus_module_7.spread(x, ({
|
|
166
167
|
r,
|
|
167
168
|
...rest
|
|
168
169
|
}) => ({
|
|
@@ -179,18 +180,22 @@ function makeCosmosStore({
|
|
|
179
180
|
/**
|
|
180
181
|
* May return duplicate results for "join_find", when matching more than once.
|
|
181
182
|
*/
|
|
182
|
-
filter:
|
|
183
|
-
const skip =
|
|
184
|
-
const limit =
|
|
183
|
+
filter: f => {
|
|
184
|
+
const skip = f?.skip;
|
|
185
|
+
const limit = f?.limit;
|
|
186
|
+
const filter = f.filter ?? {
|
|
187
|
+
type: "new-kid",
|
|
188
|
+
build: () => []
|
|
189
|
+
};
|
|
185
190
|
return tsplus_module_1.withSpan(filter.type === "join_find"
|
|
186
191
|
// This is a problem if one of the multiple joined arrays can be empty!
|
|
187
192
|
// https://stackoverflow.com/questions/60320780/azure-cosmosdb-sql-join-not-returning-results-when-the-child-contains-empty-arra
|
|
188
193
|
// so we use multiple queries instead.
|
|
189
|
-
? tsplus_module_1.map(
|
|
194
|
+
? tsplus_module_1.map(tsplus_module_6.ext_forEach(filter.keys, k => tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => (0, _query.buildFindJoinCosmosQuery)(filter, k, name, skip, limit)), q => (0, _query.logQuery)(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
190
195
|
resources
|
|
191
|
-
}) => resources)))), _ => _.flatMap(_ => _)) : tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => buildCosmosQuery(filter, name, importedMarkerId, skip, limit)), q => logQuery(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
196
|
+
}) => resources)))), _ => _.flatMap(_ => _)) : tsplus_module_1.flatMap(tsplus_module_1.tap(tsplus_module_1.sync(() => filter.type === "new-kid" ? (0, _query.buildWhereCosmosQuery3)(filter.build(), name, importedMarkerId, f.select, skip, limit) : (0, _query.buildCosmosQuery)(filter, name, importedMarkerId, skip, limit)), q => (0, _query.logQuery)(q)), q => tsplus_module_1.promise(() => container.items.query(q).fetchAll().then(({
|
|
192
197
|
resources
|
|
193
|
-
}) => resources
|
|
198
|
+
}) => resources))), "Cosmos.filter [effect-app/infra/Store]", {
|
|
194
199
|
attributes: {
|
|
195
200
|
"repository.container_id": containerId,
|
|
196
201
|
"repository.model_name": name
|
|
@@ -201,13 +206,13 @@ function makeCosmosStore({
|
|
|
201
206
|
id
|
|
202
207
|
})).read().then(({
|
|
203
208
|
resource
|
|
204
|
-
}) =>
|
|
209
|
+
}) => tsplus_module_3.fromNullable(resource))), "Cosmos.find [effect-app/infra/Store]", {
|
|
205
210
|
attributes: {
|
|
206
211
|
"repository.container_id": containerId,
|
|
207
212
|
"repository.model_name": name
|
|
208
213
|
}
|
|
209
214
|
}),
|
|
210
|
-
set: e => tsplus_module_1.withSpan(tsplus_module_1.flatMap(
|
|
215
|
+
set: e => tsplus_module_1.withSpan(tsplus_module_1.flatMap(tsplus_module_3.match(tsplus_module_3.fromNullable(e._etag), {
|
|
211
216
|
onNone: () => tsplus_module_1.promise(() => container.items.create({
|
|
212
217
|
...e,
|
|
213
218
|
_partitionKey: config?.partitionValue(e)
|
|
@@ -253,12 +258,12 @@ function makeCosmosStore({
|
|
|
253
258
|
// handle mock data
|
|
254
259
|
const marker = yield* $(tsplus_module_1.promise(() => container.item(importedMarkerId, importedMarkerId).read().then(({
|
|
255
260
|
resource
|
|
256
|
-
}) =>
|
|
257
|
-
if (!
|
|
261
|
+
}) => tsplus_module_3.fromNullable(resource))));
|
|
262
|
+
if (!tsplus_module_3.isSome(marker)) {
|
|
258
263
|
console.log("Creating mock data for " + name);
|
|
259
264
|
if (seed) {
|
|
260
265
|
const m = yield* $(seed);
|
|
261
|
-
yield* $(
|
|
266
|
+
yield* $(tsplus_module_8.flatMapOption(tsplus_module_1.sync(() => tsplus_module_4.CollectionToNonEmptyReadonlyArray(m)), a => tsplus_module_1.delay(tsplus_module_1.orDie(s.bulkSet(a)), tsplus_module_4.millis_(1100))));
|
|
262
267
|
}
|
|
263
268
|
// Mark as imported
|
|
264
269
|
yield* $(tsplus_module_1.promise(() => container.items.create({
|
|
@@ -271,154 +276,4 @@ function makeCosmosStore({
|
|
|
271
276
|
};
|
|
272
277
|
});
|
|
273
278
|
}
|
|
274
|
-
function logQuery(q) {
|
|
275
|
-
return tsplus_module_1.logDebug("cosmos query").pipe(tsplus_module_1.annotateLogs({
|
|
276
|
-
query: q.query,
|
|
277
|
-
parameters: JSON.stringify(q.parameters.reduce((acc, v) => {
|
|
278
|
-
acc[v.name] = v.value;
|
|
279
|
-
return acc;
|
|
280
|
-
}, {}), undefined, 2)
|
|
281
|
-
}));
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* @deprecated: should build Select into Where query
|
|
285
|
-
*/
|
|
286
|
-
function buildFilterJoinSelectCosmosQuery(filter, k, name, skip, limit) {
|
|
287
|
-
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
288
|
-
return {
|
|
289
|
-
query: `
|
|
290
|
-
SELECT r, f.id as _rootId
|
|
291
|
-
FROM ${name} f
|
|
292
|
-
JOIN r IN f.${k}
|
|
293
|
-
WHERE LOWER(r.${filter.valueKey}) = LOWER(@value)
|
|
294
|
-
${lm}
|
|
295
|
-
`,
|
|
296
|
-
parameters: [{
|
|
297
|
-
name: "@value",
|
|
298
|
-
value: filter.value
|
|
299
|
-
}]
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* @deprecated: is now part of Where query as k.-1.valueKey
|
|
304
|
-
*/
|
|
305
|
-
function buildFindJoinCosmosQuery(filter, k, name, skip, limit) {
|
|
306
|
-
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
307
|
-
return {
|
|
308
|
-
query: `
|
|
309
|
-
SELECT DISTINCT VALUE f
|
|
310
|
-
FROM ${name} f
|
|
311
|
-
JOIN r IN f.${k}
|
|
312
|
-
WHERE LOWER(r.${filter.valueKey}) = LOWER(@value)
|
|
313
|
-
${lm}`,
|
|
314
|
-
parameters: [{
|
|
315
|
-
name: "@value",
|
|
316
|
-
value: filter.value
|
|
317
|
-
}]
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @deprecated: should build into Where query
|
|
322
|
-
*/
|
|
323
|
-
function buildLegacyCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
324
|
-
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
325
|
-
return {
|
|
326
|
-
query: `
|
|
327
|
-
SELECT f
|
|
328
|
-
FROM ${name} AS f
|
|
329
|
-
WHERE f.id != @id AND f.${String(filter.by)} LIKE @filter
|
|
330
|
-
${lm}`,
|
|
331
|
-
parameters: [{
|
|
332
|
-
name: "@id",
|
|
333
|
-
value: importedMarkerId
|
|
334
|
-
}, {
|
|
335
|
-
name: "@filter",
|
|
336
|
-
value: filter.type === "endsWith" ? `%${filter.value}` : filter.type === "contains" ? `%${filter.value}%` : `${filter.value}%`
|
|
337
|
-
}]
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
function buildWhereCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
341
|
-
const lm = skip !== undefined || limit !== undefined ? `OFFSET ${skip ?? 0} LIMIT ${limit ?? 999999}` : "";
|
|
342
|
-
return {
|
|
343
|
-
query: `
|
|
344
|
-
SELECT f
|
|
345
|
-
FROM ${name} AS f
|
|
346
|
-
${tsplus_module_9.uniqArray(tsplus_module_8.string)(filter.where.filter(_ => _.key.includes(".-1.")).map(_ => _.key.split(".-1.")[0]).map(_ => `JOIN ${_} IN f.${_}`)).join("\n")}
|
|
347
|
-
WHERE f.id != @id AND ${filter.where.map(_ => _.key.includes(".-1.") ? {
|
|
348
|
-
..._,
|
|
349
|
-
f: _.key.split(".-1.")[0],
|
|
350
|
-
key: _.key.split(".-1.")[1]
|
|
351
|
-
} : {
|
|
352
|
-
..._,
|
|
353
|
-
f: "f"
|
|
354
|
-
}).map((x, i) => {
|
|
355
|
-
const k = `${x.f}.${x.key}`;
|
|
356
|
-
const v = `@v${i}`;
|
|
357
|
-
switch (x.t) {
|
|
358
|
-
case "in":
|
|
359
|
-
return `ARRAY_CONTAINS(${v}, ${k})`;
|
|
360
|
-
case "not-in":
|
|
361
|
-
return `(NOT ARRAY_CONTAINS(${v}, ${k}))`;
|
|
362
|
-
case "includes":
|
|
363
|
-
return `ARRAY_CONTAINS(${k}, ${v})`;
|
|
364
|
-
case "not-includes":
|
|
365
|
-
return `(NOT ARRAY_CONTAINS(${k}, ${v}))`;
|
|
366
|
-
case "contains":
|
|
367
|
-
return `CONTAINS(${k}, ${v}, true)`;
|
|
368
|
-
case "starts-with":
|
|
369
|
-
return `STARTSWITH(${k}, ${v}, true)`;
|
|
370
|
-
case "ends-with":
|
|
371
|
-
return `ENDSWITH(${k}, ${v}, true)`;
|
|
372
|
-
case "not-contains":
|
|
373
|
-
return `NOT(CONTAINS(${k}, ${v}, true))`;
|
|
374
|
-
case "not-starts-with":
|
|
375
|
-
return `NOT(STARTSWITH(${k}, ${v}, true))`;
|
|
376
|
-
case "not-ends-with":
|
|
377
|
-
return `NOT(ENDSWITH(${k}, ${v}, true))`;
|
|
378
|
-
}
|
|
379
|
-
const lk = lowerIfNeeded(k, x.value);
|
|
380
|
-
const lv = lowerIfNeeded(v, x.value);
|
|
381
|
-
switch (x.t) {
|
|
382
|
-
case "lt":
|
|
383
|
-
return `${lk} < ${lv}`;
|
|
384
|
-
case "lte":
|
|
385
|
-
return `${lk} <= ${lv}`;
|
|
386
|
-
case "gt":
|
|
387
|
-
return `${lk} > ${lv}`;
|
|
388
|
-
case "gte":
|
|
389
|
-
return `${lk} >= ${lv}`;
|
|
390
|
-
case "not-eq":
|
|
391
|
-
return x.value === null ? `IS_NULL(${k}) = false` : `${lk} <> ${lv}`;
|
|
392
|
-
case undefined:
|
|
393
|
-
case "eq":
|
|
394
|
-
return x.value === null ? `IS_NULL(${k}) = true` : `${lk} = ${lv}`;
|
|
395
|
-
}
|
|
396
|
-
}).join(filter.mode === "or" ? " OR " : " AND ")}
|
|
397
|
-
${lm}`,
|
|
398
|
-
parameters: [{
|
|
399
|
-
name: "@id",
|
|
400
|
-
value: importedMarkerId
|
|
401
|
-
}, ...filter.where.map((x, i) => ({
|
|
402
|
-
name: `@v${i}`,
|
|
403
|
-
value: x.value
|
|
404
|
-
}))]
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
// function isArray(t: SupportedValues | readonly SupportedValues[]): t is readonly SupportedValues[] {
|
|
408
|
-
// return Array.isArray(t)
|
|
409
|
-
// }
|
|
410
|
-
function lowerIfNeeded(key, value) {
|
|
411
|
-
return typeof value === "string" ? `LOWER(${key})` : `${key}`;
|
|
412
|
-
}
|
|
413
|
-
function buildCosmosQuery(filter, name, importedMarkerId, skip, limit) {
|
|
414
|
-
return filter.type === "startsWith" || filter.type === "endsWith" || filter.type === "contains" ? buildLegacyCosmosQuery(filter, name, importedMarkerId, skip, limit) : buildWhereCosmosQuery(filter, name, importedMarkerId, skip, limit);
|
|
415
|
-
}
|
|
416
|
-
class CosmosDbOperationError {
|
|
417
|
-
constructor(message) {
|
|
418
|
-
this.message = message;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
function CosmosStoreLive(config) {
|
|
422
|
-
return tsplus_module_10.effect(_service.StoreMaker)(tsplus_module_1.flatMap(tsplus_module_1.config(config), makeCosmosStore));
|
|
423
|
-
}
|
|
424
279
|
//# sourceMappingURL=Cosmos.cjs.map
|