@effect-app/infra 2.10.0 → 2.12.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 +12 -0
- package/_cjs/Model/Repository/ext.cjs +1 -1
- package/_cjs/Model/Repository/ext.cjs.map +1 -1
- package/_cjs/Model/Repository/internal/internal.cjs +245 -0
- package/_cjs/Model/Repository/internal/internal.cjs.map +1 -0
- package/_cjs/Model/Repository/legacy.cjs +0 -139
- package/_cjs/Model/Repository/legacy.cjs.map +1 -1
- package/_cjs/Model/Repository/makeRepo.cjs +2 -241
- package/_cjs/Model/Repository/makeRepo.cjs.map +1 -1
- package/_cjs/Store/Cosmos/query.cjs +9 -2
- package/_cjs/Store/Cosmos/query.cjs.map +1 -1
- package/_cjs/Store/Cosmos.cjs +49 -23
- package/_cjs/Store/Cosmos.cjs.map +1 -1
- package/_cjs/Store/Disk.cjs +5 -5
- package/_cjs/Store/Disk.cjs.map +1 -1
- package/_cjs/Store/Memory.cjs +9 -9
- package/_cjs/Store/Memory.cjs.map +1 -1
- package/_cjs/Store/codeFilter.cjs.map +1 -1
- package/_cjs/Store/service.cjs.map +1 -1
- package/_cjs/Store/utils.cjs +3 -3
- package/_cjs/Store/utils.cjs.map +1 -1
- package/dist/Model/Repository/ext.d.ts +6 -9
- package/dist/Model/Repository/ext.d.ts.map +1 -1
- package/dist/Model/Repository/ext.js +2 -2
- package/dist/Model/Repository/internal/internal.d.ts +61 -0
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -0
- package/dist/Model/Repository/internal/internal.js +245 -0
- package/dist/Model/Repository/legacy.d.ts +4 -192
- package/dist/Model/Repository/legacy.d.ts.map +1 -1
- package/dist/Model/Repository/legacy.js +2 -123
- package/dist/Model/Repository/makeRepo.d.ts +7 -77
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.js +3 -247
- package/dist/Model/Repository/service.d.ts +1 -3
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Operations.d.ts +3 -3
- package/dist/QueueMaker/sbqueue.d.ts +2 -2
- package/dist/Store/Cosmos/query.d.ts +1 -1
- package/dist/Store/Cosmos/query.d.ts.map +1 -1
- package/dist/Store/Cosmos/query.js +7 -3
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +43 -23
- package/dist/Store/Disk.d.ts +2 -3
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +6 -6
- package/dist/Store/Memory.d.ts +4 -9
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +12 -12
- package/dist/Store/codeFilter.d.ts +2 -3
- package/dist/Store/codeFilter.d.ts.map +1 -1
- package/dist/Store/codeFilter.js +1 -1
- package/dist/Store/service.d.ts +9 -23
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/service.js +1 -1
- package/dist/Store/utils.d.ts +1 -3
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +4 -4
- package/package.json +1 -1
- package/src/Model/Repository/ext.ts +6 -5
- package/src/Model/Repository/internal/internal.ts +482 -0
- package/src/Model/Repository/legacy.ts +4 -538
- package/src/Model/Repository/makeRepo.ts +11 -489
- package/src/Model/Repository/service.ts +1 -1
- package/src/Store/Cosmos/query.ts +6 -1
- package/src/Store/Cosmos.ts +85 -48
- package/src/Store/Disk.ts +20 -8
- package/src/Store/Memory.ts +25 -16
- package/src/Store/codeFilter.ts +2 -1
- package/src/Store/service.ts +8 -7
- package/src/Store/utils.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @effect-app/infra
|
|
2
2
|
|
|
3
|
+
## 2.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 23c8ca5: pushed idKey mapping down to the driver instead of the repo
|
|
8
|
+
|
|
9
|
+
## 2.11.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 90244e1: chore: remove legacy RepositoryBase and move others internally.
|
|
14
|
+
|
|
3
15
|
## 2.10.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -32,7 +32,7 @@ const extendRepo = repo => {
|
|
|
32
32
|
const saveManyWithPure = (items, pure, batch) => batch ? _effectApp.Effect.forEach(_effectApp.Array.chunk_(items, batch === "batched" ? 100 : batch), batch => saveAllWithEffectInt((0, _Pure.runTerm)(pure, batch))) : saveAllWithEffectInt((0, _Pure.runTerm)(pure, [...items]));
|
|
33
33
|
const byIdAndSaveWithPure = (id, pure) => get(id).pipe(_effectApp.Effect.flatMap(item => saveWithPure_(item, pure)));
|
|
34
34
|
const _request = _effectApp.Request.tagged(`Get${repo.itemType}`);
|
|
35
|
-
const requestResolver = _effectApp.RequestResolver.makeBatched(requests => repo.query(Q.where(
|
|
35
|
+
const requestResolver = _effectApp.RequestResolver.makeBatched(requests => repo.query(Q.where(repo.idKey, "in", requests.map(_ => _.id)))
|
|
36
36
|
// TODO
|
|
37
37
|
.pipe(_effectApp.Effect.andThen(items => _effectApp.Effect.forEach(requests, r => _effectApp.Request.complete(r, _effectApp.Array.findFirst(items, _ => _[repo.idKey] === r.id).pipe(_effectApp.Option.match({
|
|
38
38
|
onNone: () => _effectApp.Exit.fail(new _client.NotFoundError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ext.cjs","names":["_effectApp","require","_client","_Pure","_dsl","Q","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","extendRepo","repo","id","Effect","flatMap","find","_","mapError","NotFoundError","type","itemType","saveManyWithPure_","items","pure","saveAllWithEffectInt","runTerm","saveWithPure_","item","pipe","map","events","gen","saveAndPublish","saveManyWithPureBatched_","batchSize","forEach","Array","chunk_","batch","queryAndSavePure","q","query","andThen","isArray","undefined","saveManyWithPure","byIdAndSaveWithPure","_request","Request","tagged","requestResolver","RequestResolver","makeBatched","requests","where","
|
|
1
|
+
{"version":3,"file":"ext.cjs","names":["_effectApp","require","_client","_Pure","_dsl","Q","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","extendRepo","repo","id","Effect","flatMap","find","_","mapError","NotFoundError","type","itemType","saveManyWithPure_","items","pure","saveAllWithEffectInt","runTerm","saveWithPure_","item","pipe","map","events","gen","saveAndPublish","saveManyWithPureBatched_","batchSize","forEach","Array","chunk_","batch","queryAndSavePure","q","query","andThen","isArray","undefined","saveManyWithPure","byIdAndSaveWithPure","_request","Request","tagged","requestResolver","RequestResolver","makeBatched","requests","where","idKey","complete","findFirst","Option","match","onNone","Exit","fail","onSome","succeed","discard","catchAllCause","cause","failCause","batchN","exts","request","log","evt","AnyPureDSL","removeById","removeAndPublish","save","saveWithEvents","saveWithPure","exports"],"sources":["../../../src/Model/Repository/ext.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAGA,IAAAI,CAAA,GAAAC,uBAAA,CAAAL,OAAA;AAAgC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAA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Q,MAAM,CAAC;IAC7GS,gBAAgB;IAChBM,gBAAgB;IAChBC,mBAAmB;IACnBiC,YAAY,EAAEA,CAOZpD,IAAQ,EACRJ,IAA0C,KAE1CC,oBAAoB,CAClB,IAAAC,aAAO,EAACF,IAAI,EAAEI,IAAI,CAAC,CAChBC,IAAI,CAACf,iBAAM,CAACgB,GAAG,CAAC,CAAC,CAACF,IAAI,EAAEG,MAAM,EAAE7B,CAAC,CAAC,KAAK,CAAC,CAAC0B,IAAI,CAAC,EAAEG,MAAM,EAAE7B,CAAC,CAAC,CAAC,CAAC;GAEpE;EAED,OAAO;IACL,GAAGU,IAAI;IACP,GAAG2D;GAC6E;AACpF,CAAC;AAAAU,OAAA,CAAAtE,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeRepoInternal = makeRepoInternal;
|
|
7
|
+
exports.makeStore = makeStore;
|
|
8
|
+
var _effectApp = require("effect-app");
|
|
9
|
+
var _Array = require("effect-app/Array");
|
|
10
|
+
var _client = require("effect-app/client");
|
|
11
|
+
var _Effect = require("effect-app/Effect");
|
|
12
|
+
var _Schema = require("effect-app/Schema");
|
|
13
|
+
var _setupRequest = require("../../../api/setupRequest.cjs");
|
|
14
|
+
var _Store = require("../../../Store.cjs");
|
|
15
|
+
var _ContextMapContainer = require("../../../Store/ContextMapContainer.cjs");
|
|
16
|
+
var Q = _interopRequireWildcard(require("../../query.cjs"));
|
|
17
|
+
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); }
|
|
18
|
+
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 && {}.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; }
|
|
19
|
+
const dedupe = _effectApp.Array.dedupeWith(_effectApp.Equivalence.string);
|
|
20
|
+
/**
|
|
21
|
+
* A base implementation to create a repository.
|
|
22
|
+
*/
|
|
23
|
+
function makeRepoInternal() {
|
|
24
|
+
return (name, schema, mapFrom, mapTo, idKey) => {
|
|
25
|
+
function mapToPersistenceModel(e, getEtag) {
|
|
26
|
+
return mapTo(e, getEtag(e[idKey]));
|
|
27
|
+
}
|
|
28
|
+
function mapReverse({
|
|
29
|
+
_etag,
|
|
30
|
+
...e
|
|
31
|
+
}, setEtag) {
|
|
32
|
+
setEtag(e[idKey], _etag);
|
|
33
|
+
return mapFrom(e);
|
|
34
|
+
}
|
|
35
|
+
const mkStore = makeStore()(name, schema, mapTo, idKey);
|
|
36
|
+
function make(args) {
|
|
37
|
+
return _effectApp.Effect.gen(function* () {
|
|
38
|
+
const rctx = args.schemaContext ?? _effectApp.Context.empty();
|
|
39
|
+
const provideRctx = _effectApp.Effect.provide(rctx);
|
|
40
|
+
const encodeMany = (0, _effectApp.flow)(_effectApp.S.encode(_effectApp.S.Array(schema)), provideRctx, _effectApp.Effect.withSpan("encodeMany", {
|
|
41
|
+
captureStackTrace: false
|
|
42
|
+
}));
|
|
43
|
+
const decode = (0, _effectApp.flow)(_effectApp.S.decode(schema), provideRctx);
|
|
44
|
+
const decodeMany = (0, _effectApp.flow)(_effectApp.S.decode(_effectApp.S.Array(schema)), provideRctx, _effectApp.Effect.withSpan("decodeMany", {
|
|
45
|
+
captureStackTrace: false
|
|
46
|
+
}));
|
|
47
|
+
const store = yield* mkStore(args.makeInitial, args.config);
|
|
48
|
+
const cms = _effectApp.Effect.andThen(_ContextMapContainer.getContextMap.pipe(_effectApp.Effect.orDie), _ => ({
|
|
49
|
+
get: id => _.get(`${name}.${id}`),
|
|
50
|
+
set: (id, etag) => _.set(`${name}.${id}`, etag)
|
|
51
|
+
}));
|
|
52
|
+
const pub = "publishEvents" in args ? args.publishEvents : () => _effectApp.Effect.void;
|
|
53
|
+
const changeFeed = yield* _effectApp.PubSub.unbounded();
|
|
54
|
+
const allE = cms.pipe(_effectApp.Effect.flatMap(cm => _effectApp.Effect.map(store.all, _ => _.map(_ => mapReverse(_, cm.set)))));
|
|
55
|
+
const all = _effectApp.Effect.flatMap(allE, _ => decodeMany(_).pipe(_effectApp.Effect.orDie)).pipe(_effectApp.Effect.map(_ => _));
|
|
56
|
+
const fieldsSchema = schema;
|
|
57
|
+
// assumes the id field never needs a service...
|
|
58
|
+
const i = ("fields" in fieldsSchema ? _effectApp.S.Struct(fieldsSchema["fields"]) : schema).pipe(_ => {
|
|
59
|
+
let ast = _.ast;
|
|
60
|
+
if (ast._tag === "Declaration") ast = ast.typeParameters[0];
|
|
61
|
+
const s = _effectApp.S.make(ast);
|
|
62
|
+
return ast._tag === "Union"
|
|
63
|
+
// we need to get the TypeLiteral, incase of class it's behind a transform...
|
|
64
|
+
? _effectApp.S.Union(...ast.types.map(_ => _effectApp.S.make(_._tag === "Transformation" ? _.from : _).pipe(_effectApp.S.pick(idKey)))) : s.pipe(_effectApp.S.pick(idKey));
|
|
65
|
+
});
|
|
66
|
+
const encodeId = (0, _effectApp.flow)(_effectApp.S.encode(i), provideRctx);
|
|
67
|
+
function findEId(id) {
|
|
68
|
+
return _effectApp.Effect.flatMap(store.find(id), item => _effectApp.Effect.gen(function* () {
|
|
69
|
+
const {
|
|
70
|
+
set
|
|
71
|
+
} = yield* cms;
|
|
72
|
+
return item.pipe(_effectApp.Option.map(_ => mapReverse(_, set)));
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
// TODO: select the particular field, instead of as struct
|
|
76
|
+
function findE(id) {
|
|
77
|
+
return (0, _effectApp.pipe)(encodeId({
|
|
78
|
+
[idKey]: id
|
|
79
|
+
}), _effectApp.Effect.orDie, _effectApp.Effect.map(_ => _[idKey]), _effectApp.Effect.flatMap(findEId));
|
|
80
|
+
}
|
|
81
|
+
function find(id) {
|
|
82
|
+
return _effectApp.Effect.flatMapOption(findE(id), _ => _effectApp.Effect.orDie(decode(_)));
|
|
83
|
+
}
|
|
84
|
+
const saveAllE = a => _effectApp.Effect.flatMapOption(_effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...a])), a => _effectApp.Effect.gen(function* () {
|
|
85
|
+
const {
|
|
86
|
+
get,
|
|
87
|
+
set
|
|
88
|
+
} = yield* cms;
|
|
89
|
+
const items = a.map(_ => mapToPersistenceModel(_, get));
|
|
90
|
+
const ret = yield* store.batchSet(items);
|
|
91
|
+
ret.forEach(_ => set(_[idKey], _._etag));
|
|
92
|
+
})).pipe(_effectApp.Effect.asVoid);
|
|
93
|
+
const saveAll = a => encodeMany(_effectApp.Array.fromIterable(a)).pipe(_effectApp.Effect.orDie, _effectApp.Effect.andThen(saveAllE));
|
|
94
|
+
const saveAndPublish = (items, events = []) => {
|
|
95
|
+
return _effectApp.Effect.suspend(() => {
|
|
96
|
+
const it = _effectApp.Chunk.fromIterable(items);
|
|
97
|
+
return saveAll(it).pipe(_effectApp.Effect.andThen(_effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...events]))),
|
|
98
|
+
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
99
|
+
_ => _effectApp.Effect.flatMapOption(_, pub), _effectApp.Effect.andThen(changeFeed.publish([_effectApp.Chunk.toArray(it), "save"])), _effectApp.Effect.asVoid);
|
|
100
|
+
}).pipe(_effectApp.Effect.withSpan("saveAndPublish", {
|
|
101
|
+
captureStackTrace: false
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
function removeAndPublish(a, events = []) {
|
|
105
|
+
return _effectApp.Effect.gen(function* () {
|
|
106
|
+
const {
|
|
107
|
+
get,
|
|
108
|
+
set
|
|
109
|
+
} = yield* cms;
|
|
110
|
+
const it = [...a];
|
|
111
|
+
const items = yield* encodeMany(it).pipe(_effectApp.Effect.orDie);
|
|
112
|
+
// TODO: we should have a batchRemove on store so the adapter can actually batch...
|
|
113
|
+
for (const e of items) {
|
|
114
|
+
yield* store.remove(mapToPersistenceModel(e, get));
|
|
115
|
+
set(e[idKey], undefined);
|
|
116
|
+
}
|
|
117
|
+
yield* _effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...events]))
|
|
118
|
+
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
119
|
+
.pipe(_ => _effectApp.Effect.flatMapOption(_, pub));
|
|
120
|
+
yield* changeFeed.publish([it, "remove"]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const parseMany = items => _effectApp.Effect.flatMap(cms, cm => decodeMany(items.map(_ => mapReverse(_, cm.set))).pipe(_effectApp.Effect.orDie, _effectApp.Effect.withSpan("parseMany", {
|
|
124
|
+
captureStackTrace: false
|
|
125
|
+
})));
|
|
126
|
+
const parseMany2 = (items, schema) => _effectApp.Effect.flatMap(cms, cm => _effectApp.S.decode(_effectApp.S.Array(schema))(items.map(_ => mapReverse(_, cm.set))).pipe(_effectApp.Effect.orDie, _effectApp.Effect.withSpan("parseMany2", {
|
|
127
|
+
captureStackTrace: false
|
|
128
|
+
})));
|
|
129
|
+
const filter = args => store.filter(
|
|
130
|
+
// always enforce id and _etag because they are system fields, required for etag tracking etc
|
|
131
|
+
{
|
|
132
|
+
...args,
|
|
133
|
+
select: args.select ? dedupe([...args.select, idKey, "_etag"]) : undefined
|
|
134
|
+
}).pipe(_effectApp.Effect.tap(items => _effectApp.Effect.map(cms, ({
|
|
135
|
+
set
|
|
136
|
+
}) => items.forEach(_ => set(_[idKey], _._etag)))));
|
|
137
|
+
// TODO: For raw we should use S.from, and drop the R...
|
|
138
|
+
const query = q => {
|
|
139
|
+
const a = Q.toFilter(q);
|
|
140
|
+
const eff = a.mode === "project" ? filter(a)
|
|
141
|
+
// TODO: mapFrom but need to support per field and dependencies
|
|
142
|
+
.pipe(_effectApp.Effect.andThen((0, _effectApp.flow)(_effectApp.S.decode(_effectApp.S.Array(a.schema ?? schema)), provideRctx))) : a.mode === "collect" ? filter(a)
|
|
143
|
+
// TODO: mapFrom but need to support per field and dependencies
|
|
144
|
+
.pipe(_effectApp.Effect.flatMap((0, _effectApp.flow)(_effectApp.S.decode(_effectApp.S.Array(a.schema)), _effectApp.Effect.map(_effectApp.Array.getSomes), provideRctx))) : _effectApp.Effect.flatMap(filter(a), _ => _effectApp.Unify.unify(a.schema
|
|
145
|
+
// TODO: partial may not match?
|
|
146
|
+
? parseMany2(_, a.schema) : parseMany(_)));
|
|
147
|
+
return (0, _effectApp.pipe)(a.ttype === "one" ? _effectApp.Effect.andThen(eff, (0, _effectApp.flow)(_effectApp.Array.head, _effectApp.Effect.mapError(() => new _client.NotFoundError({
|
|
148
|
+
id: "query",
|
|
149
|
+
/* TODO */type: name
|
|
150
|
+
})))) : a.ttype === "count" ? _effectApp.Effect.andThen(eff, _ => (0, _Schema.NonNegativeInt)(_.length)).pipe(_effectApp.Effect.catchTag("ParseError", e => _effectApp.Effect.die(e))) : eff, _effectApp.Effect.withSpan("Repository.query [effect-app/infra]", {
|
|
151
|
+
captureStackTrace: false,
|
|
152
|
+
attributes: {
|
|
153
|
+
"repository.model_name": name,
|
|
154
|
+
query: {
|
|
155
|
+
...a,
|
|
156
|
+
schema: a.schema ? "__SCHEMA__" : a.schema,
|
|
157
|
+
filter: a.filter
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
};
|
|
162
|
+
const r = {
|
|
163
|
+
changeFeed,
|
|
164
|
+
itemType: name,
|
|
165
|
+
idKey,
|
|
166
|
+
find,
|
|
167
|
+
all,
|
|
168
|
+
saveAndPublish,
|
|
169
|
+
removeAndPublish,
|
|
170
|
+
query(q) {
|
|
171
|
+
// eslint-disable-next-line prefer-rest-params
|
|
172
|
+
return query(typeof q === "function" ? _effectApp.Pipeable.pipeArguments(Q.make(), arguments) : q);
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
mapped: schema => {
|
|
178
|
+
const dec = _effectApp.S.decode(schema);
|
|
179
|
+
const encMany = _effectApp.S.encode(_effectApp.S.Array(schema));
|
|
180
|
+
const decMany = _effectApp.S.decode(_effectApp.S.Array(schema));
|
|
181
|
+
return {
|
|
182
|
+
all: allE.pipe(_effectApp.Effect.flatMap(decMany), _effectApp.Effect.map(_ => _)),
|
|
183
|
+
find: id => (0, _Effect.flatMapOption)(findE(id), dec),
|
|
184
|
+
// query: (q: any) => {
|
|
185
|
+
// const a = Q.toFilter(q)
|
|
186
|
+
// return filter(a)
|
|
187
|
+
// .pipe(
|
|
188
|
+
// Effect.flatMap(decMany),
|
|
189
|
+
// Effect.map((_) => _ as any[]),
|
|
190
|
+
// Effect.withSpan("Repository.mapped.query [effect-app/infra]", {
|
|
191
|
+
// captureStackTrace: false,
|
|
192
|
+
// attributes: {
|
|
193
|
+
// "repository.model_name": name,
|
|
194
|
+
// query: { ...a, schema: a.schema ? "__SCHEMA__" : a.schema, filter: a.filter.build() }
|
|
195
|
+
// }
|
|
196
|
+
// })
|
|
197
|
+
// )
|
|
198
|
+
// },
|
|
199
|
+
save: (...xes) => _effectApp.Effect.flatMap(encMany(xes), _ => saveAllE(_)).pipe(_effectApp.Effect.withSpan("mapped.save", {
|
|
200
|
+
captureStackTrace: false
|
|
201
|
+
}))
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return r;
|
|
206
|
+
}).pipe(_effectApp.Effect
|
|
207
|
+
// .withSpan("Repository.make [effect-app/infra]", { attributes: { "repository.model_name": name } })
|
|
208
|
+
.withLogSpan("Repository.make: " + name));
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
make,
|
|
212
|
+
Q: Q.make()
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const pluralize = s => s.endsWith("s") ? s + "es" : s.endsWith("y") ? s.substring(0, s.length - 1) + "ies" : s + "s";
|
|
217
|
+
function makeStore() {
|
|
218
|
+
return (name, schema, mapTo, idKey) => {
|
|
219
|
+
function makeStore(makeInitial, config) {
|
|
220
|
+
function encodeToEncoded() {
|
|
221
|
+
const getEtag = () => undefined;
|
|
222
|
+
return t => _effectApp.S.encode(schema)(t).pipe(_effectApp.Effect.orDie, _effectApp.Effect.map(_ => mapToPersistenceModel(_, getEtag)));
|
|
223
|
+
}
|
|
224
|
+
function mapToPersistenceModel(e, getEtag) {
|
|
225
|
+
return mapTo(e, getEtag(e[idKey]));
|
|
226
|
+
}
|
|
227
|
+
return _effectApp.Effect.gen(function* () {
|
|
228
|
+
const {
|
|
229
|
+
make
|
|
230
|
+
} = yield* _Store.StoreMaker;
|
|
231
|
+
const store = yield* make(pluralize(name), idKey, makeInitial ? makeInitial.pipe(_effectApp.Effect.flatMap(_effectApp.Effect.forEach(encodeToEncoded())), (0, _setupRequest.setupRequestContextFromCurrent)("Repository.makeInitial [effect-app/infra]", {
|
|
232
|
+
attributes: {
|
|
233
|
+
"repository.model_name": name
|
|
234
|
+
}
|
|
235
|
+
})) : undefined, {
|
|
236
|
+
...config,
|
|
237
|
+
partitionValue: config?.partitionValue ?? (_ => "primary") /*(isIntegrationEvent(r) ? r.companyId : r.id*/
|
|
238
|
+
});
|
|
239
|
+
return store;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return makeStore;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=internal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.cjs","names":["_effectApp","require","_Array","_client","_Effect","_Schema","_setupRequest","_Store","_ContextMapContainer","Q","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","dedupe","Array","dedupeWith","Equivalence","string","makeRepoInternal","name","schema","mapFrom","mapTo","idKey","mapToPersistenceModel","getEtag","mapReverse","_etag","setEtag","mkStore","makeStore","make","args","Effect","gen","rctx","schemaContext","Context","empty","provideRctx","provide","encodeMany","flow","S","encode","withSpan","captureStackTrace","decode","decodeMany","store","makeInitial","config","cms","andThen","getContextMap","pipe","orDie","_","id","etag","pub","publishEvents","void","changeFeed","PubSub","unbounded","allE","flatMap","cm","map","all","fieldsSchema","Struct","ast","_tag","typeParameters","s","Union","types","from","pick","encodeId","findEId","find","item","Option","findE","flatMapOption","saveAllE","sync","toNonEmptyArray","items","ret","batchSet","forEach","asVoid","saveAll","fromIterable","saveAndPublish","events","suspend","it","Chunk","publish","toArray","removeAndPublish","remove","undefined","parseMany","parseMany2","filter","select","tap","query","q","toFilter","eff","mode","getSomes","Unify","unify","ttype","head","mapError","NotFoundError","type","NonNegativeInt","length","catchTag","die","attributes","itemType","Pipeable","pipeArguments","arguments","mapped","dec","encMany","decMany","save","xes","withLogSpan","pluralize","endsWith","substring","encodeToEncoded","StoreMaker","setupRequestContextFromCurrent","partitionValue"],"sources":["../../../../src/Model/Repository/internal/internal.ts"],"sourcesContent":[null],"mappings":";;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAEA,IAAAQ,CAAA,GAAAC,uBAAA,CAAAT,OAAA;AAAmC,SAAAU,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IA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AM;UAAEH;QAAI,CAAE,GAAG,OAAOmH,iBAAU;QAElC,MAAMjG,KAAK,GAAG,OAAOlB,IAAI,CACvB+G,SAAS,CAAC3H,IAAI,CAAC,EACfI,KAAK,EACL2B,WAAW,GACPA,WAAW,CACVK,IAAI,CACHtB,iBAAM,CAACkC,OAAO,CAAClC,iBAAM,CAAC6D,OAAO,CAACmD,eAAe,EAAE,CAAC,CAAC,EACjD,IAAAE,4CAA8B,EAAC,2CAA2C,EAAE;UAC1EjB,UAAU,EAAE;YAAE,uBAAuB,EAAE/G;UAAI;SAC5C,CAAC,CACH,GACDwF,SAAS,EACb;UACE,GAAGxD,MAAM;UACTiG,cAAc,EAAEjG,MAAM,EAAEiG,cAAc,KAC/B3F,CAAC,IAAK,SAAS,CAAC,CAAC;SACzB,CACF;QAED,OAAOR,KAAK;MACd,CAAC,CAAC;IACJ;IAEA,OAAOnB,SAAS;EAClB,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,143 +3,4 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RepositoryDefaultImpl2 = exports.RepositoryBase = void 0;
|
|
7
|
-
var _effectApp = require("effect-app");
|
|
8
|
-
var Q = _interopRequireWildcard(require("../query.cjs"));
|
|
9
|
-
var _ext = require("./ext.cjs");
|
|
10
|
-
var _makeRepo = require("./makeRepo.cjs");
|
|
11
|
-
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); }
|
|
12
|
-
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 && {}.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; }
|
|
13
|
-
const names = new Map();
|
|
14
|
-
const registerName = name => {
|
|
15
|
-
const existing = names.get(name);
|
|
16
|
-
if (existing === undefined) {
|
|
17
|
-
names.set(name, 1);
|
|
18
|
-
return name;
|
|
19
|
-
} else {
|
|
20
|
-
const n = existing + 1;
|
|
21
|
-
names.set(name, n);
|
|
22
|
-
return name + "-" + existing;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated
|
|
27
|
-
*/
|
|
28
|
-
const makeRepoFunctions = (tag, itemType) => {
|
|
29
|
-
const {
|
|
30
|
-
all
|
|
31
|
-
} = _effectApp.Effect.serviceConstants(tag);
|
|
32
|
-
const {
|
|
33
|
-
byIdAndSaveWithPure,
|
|
34
|
-
find,
|
|
35
|
-
get,
|
|
36
|
-
query,
|
|
37
|
-
queryAndSavePure,
|
|
38
|
-
removeAndPublish,
|
|
39
|
-
removeById,
|
|
40
|
-
save,
|
|
41
|
-
saveAndPublish,
|
|
42
|
-
saveManyWithPure
|
|
43
|
-
} = _effectApp.Effect.serviceFunctions(tag);
|
|
44
|
-
const mapped = s => _effectApp.Effect.map(tag, _ => _.mapped(s));
|
|
45
|
-
return {
|
|
46
|
-
itemType,
|
|
47
|
-
all,
|
|
48
|
-
byIdAndSaveWithPure,
|
|
49
|
-
find,
|
|
50
|
-
removeById,
|
|
51
|
-
saveAndPublish,
|
|
52
|
-
removeAndPublish,
|
|
53
|
-
save,
|
|
54
|
-
get,
|
|
55
|
-
query,
|
|
56
|
-
mapped,
|
|
57
|
-
queryAndSavePure,
|
|
58
|
-
saveManyWithPure,
|
|
59
|
-
use: body => _effectApp.Effect.andThen(tag, body)
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
/** @deprecated use makeRepo/extendRepo */
|
|
63
|
-
class RepositoryBase {
|
|
64
|
-
impl;
|
|
65
|
-
constructor(impl) {
|
|
66
|
-
this.impl = impl;
|
|
67
|
-
this.saveAndPublish = this.impl.saveAndPublish;
|
|
68
|
-
this.removeAndPublish = this.impl.removeAndPublish;
|
|
69
|
-
this.find = this.impl.find;
|
|
70
|
-
this.all = this.impl.all;
|
|
71
|
-
this.changeFeed = this.impl.changeFeed;
|
|
72
|
-
this.mapped = this.impl.mapped;
|
|
73
|
-
this.query = this.impl.query;
|
|
74
|
-
this.get = this.impl.get;
|
|
75
|
-
this.itemType = this.impl.itemType;
|
|
76
|
-
this.idKey = this.impl.idKey;
|
|
77
|
-
this.log = this.impl.log;
|
|
78
|
-
this.removeById = this.impl.removeById;
|
|
79
|
-
this.save = this.impl.save;
|
|
80
|
-
this.saveWithEvents = this.impl.saveWithEvents;
|
|
81
|
-
this.queryAndSavePure = this.impl.queryAndSavePure;
|
|
82
|
-
this.saveManyWithPure = this.impl.saveManyWithPure;
|
|
83
|
-
this.byIdAndSaveWithPure = this.impl.byIdAndSaveWithPure;
|
|
84
|
-
this.saveWithPure = this.impl.saveWithPure;
|
|
85
|
-
this.request = this.impl.request;
|
|
86
|
-
}
|
|
87
|
-
get;
|
|
88
|
-
idKey;
|
|
89
|
-
request;
|
|
90
|
-
itemType;
|
|
91
|
-
saveAndPublish;
|
|
92
|
-
removeAndPublish;
|
|
93
|
-
find;
|
|
94
|
-
all;
|
|
95
|
-
changeFeed;
|
|
96
|
-
mapped;
|
|
97
|
-
query;
|
|
98
|
-
log;
|
|
99
|
-
removeById;
|
|
100
|
-
save;
|
|
101
|
-
saveWithEvents;
|
|
102
|
-
queryAndSavePure;
|
|
103
|
-
saveManyWithPure;
|
|
104
|
-
byIdAndSaveWithPure;
|
|
105
|
-
saveWithPure;
|
|
106
|
-
}
|
|
107
|
-
exports.RepositoryBase = RepositoryBase;
|
|
108
|
-
const RepositoryDefaultImpl2 = () => {
|
|
109
|
-
const f = (itemType, schema, options) => {
|
|
110
|
-
let layerCache = undefined;
|
|
111
|
-
let layerCache2 = undefined;
|
|
112
|
-
class Cls extends RepositoryBase {
|
|
113
|
-
static Q = Q.make();
|
|
114
|
-
static get DefaultWithoutDependencies() {
|
|
115
|
-
const self = this;
|
|
116
|
-
return layerCache ??= _effectApp.Effect.gen(function* () {
|
|
117
|
-
const opts = yield* options.options ?? _effectApp.Effect.succeed({});
|
|
118
|
-
const mkRepo = (0, _makeRepo.makeRepoInternal)()(itemType, schema, options?.jitM ? pm => options.jitM(pm) : pm => pm, (e, _etag) => ({
|
|
119
|
-
...e,
|
|
120
|
-
_etag
|
|
121
|
-
}), options.idKey ?? "id");
|
|
122
|
-
const r = yield* mkRepo.make({
|
|
123
|
-
...options,
|
|
124
|
-
...opts
|
|
125
|
-
});
|
|
126
|
-
const repo = new self(Object.assign((0, _ext.extendRepo)(r), "ext" in opts ? opts.ext : {}));
|
|
127
|
-
return _effectApp.Layer.succeed(self, repo);
|
|
128
|
-
}).pipe(_effectApp.Layer.unwrapEffect);
|
|
129
|
-
}
|
|
130
|
-
static get Default() {
|
|
131
|
-
const self = this;
|
|
132
|
-
return layerCache2 ??= options.dependencies ? self.DefaultWithoutDependencies.pipe(_effectApp.Layer.provide(options.dependencies)) : self.DefaultWithoutDependencies;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const limit = Error.stackTraceLimit;
|
|
136
|
-
Error.stackTraceLimit = 2;
|
|
137
|
-
const creationError = new Error();
|
|
138
|
-
Error.stackTraceLimit = limit;
|
|
139
|
-
// TODO: actual class name or expect a string identifier - careful with overlapping between modules
|
|
140
|
-
return _effectApp.Context.assignTag(registerName(itemType + "Repo"), creationError)(Object.assign(Cls, makeRepoFunctions(Cls, itemType))); // impl is missing, but its marked protected
|
|
141
|
-
};
|
|
142
|
-
return f;
|
|
143
|
-
};
|
|
144
|
-
exports.RepositoryDefaultImpl2 = RepositoryDefaultImpl2;
|
|
145
6
|
//# sourceMappingURL=legacy.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.cjs","names":[
|
|
1
|
+
{"version":3,"file":"legacy.cjs","names":[],"sources":["../../../src/Model/Repository/legacy.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
|