@effect-app/infra 2.10.0 → 2.11.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @effect-app/infra
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 90244e1: chore: remove legacy RepositoryBase and move others internally.
8
+
3
9
  ## 2.10.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,247 @@
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.id));
27
+ }
28
+ function mapReverse({
29
+ _etag,
30
+ ...e
31
+ }, setEtag) {
32
+ setEtag(e.id, _etag);
33
+ return mapFrom(e);
34
+ }
35
+ const mkStore = makeStore()(name, schema, mapTo);
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
+ function findE(id) {
76
+ return (0, _effectApp.pipe)(encodeId({
77
+ [idKey]: id
78
+ }), _effectApp.Effect.orDie,
79
+ // we will have idKey because the transform is undone again by the encode schema mumbo jumbo above
80
+ // TODO: make reliable. (Security: isin: PrimaryKey(ISIN), idKey: "isin", does end up with "id")
81
+ _effectApp.Effect.map(_ => _[idKey] ?? _.id), _effectApp.Effect.flatMap(findEId));
82
+ }
83
+ function find(id) {
84
+ return _effectApp.Effect.flatMapOption(findE(id), _ => _effectApp.Effect.orDie(decode(_)));
85
+ }
86
+ const saveAllE = a => _effectApp.Effect.flatMapOption(_effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...a])), a => _effectApp.Effect.gen(function* () {
87
+ const {
88
+ get,
89
+ set
90
+ } = yield* cms;
91
+ const items = a.map(_ => mapToPersistenceModel(_, get));
92
+ const ret = yield* store.batchSet(items);
93
+ ret.forEach(_ => set(_.id, _._etag));
94
+ })).pipe(_effectApp.Effect.asVoid);
95
+ const saveAll = a => encodeMany(_effectApp.Array.fromIterable(a)).pipe(_effectApp.Effect.orDie, _effectApp.Effect.andThen(saveAllE));
96
+ const saveAndPublish = (items, events = []) => {
97
+ return _effectApp.Effect.suspend(() => {
98
+ const it = _effectApp.Chunk.fromIterable(items);
99
+ return saveAll(it).pipe(_effectApp.Effect.andThen(_effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...events]))),
100
+ // TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
101
+ _ => _effectApp.Effect.flatMapOption(_, pub), _effectApp.Effect.andThen(changeFeed.publish([_effectApp.Chunk.toArray(it), "save"])), _effectApp.Effect.asVoid);
102
+ }).pipe(_effectApp.Effect.withSpan("saveAndPublish", {
103
+ captureStackTrace: false
104
+ }));
105
+ };
106
+ function removeAndPublish(a, events = []) {
107
+ return _effectApp.Effect.gen(function* () {
108
+ const {
109
+ get,
110
+ set
111
+ } = yield* cms;
112
+ const it = [...a];
113
+ const items = yield* encodeMany(it).pipe(_effectApp.Effect.orDie);
114
+ // TODO: we should have a batchRemove on store so the adapter can actually batch...
115
+ for (const e of items) {
116
+ yield* store.remove(mapToPersistenceModel(e, get));
117
+ set(e.id, undefined);
118
+ }
119
+ yield* _effectApp.Effect.sync(() => (0, _Array.toNonEmptyArray)([...events]))
120
+ // TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
121
+ .pipe(_ => _effectApp.Effect.flatMapOption(_, pub));
122
+ yield* changeFeed.publish([it, "remove"]);
123
+ });
124
+ }
125
+ const parseMany = items => _effectApp.Effect.flatMap(cms, cm => decodeMany(items.map(_ => mapReverse(_, cm.set))).pipe(_effectApp.Effect.orDie, _effectApp.Effect.withSpan("parseMany", {
126
+ captureStackTrace: false
127
+ })));
128
+ 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", {
129
+ captureStackTrace: false
130
+ })));
131
+ const filter = args => store.filter(
132
+ // always enforce id and _etag because they are system fields, required for etag tracking etc
133
+ {
134
+ ...args,
135
+ select: args.select ? dedupe([...args.select, "id", "_etag"]) : undefined
136
+ }).pipe(_effectApp.Effect.tap(items => _effectApp.Effect.map(cms, ({
137
+ set
138
+ }) => items.forEach(_ => set(_.id, _._etag)))));
139
+ // TODO: For raw we should use S.from, and drop the R...
140
+ const query = q => {
141
+ const a = Q.toFilter(q);
142
+ const eff = a.mode === "project" ? filter(a)
143
+ // TODO: mapFrom but need to support per field and dependencies
144
+ .pipe(_effectApp.Effect.andThen((0, _effectApp.flow)(_effectApp.S.decode(_effectApp.S.Array(a.schema ?? schema)), provideRctx))) : a.mode === "collect" ? filter(a)
145
+ // TODO: mapFrom but need to support per field and dependencies
146
+ .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
147
+ // TODO: partial may not match?
148
+ ? parseMany2(_, a.schema) : parseMany(_)));
149
+ return (0, _effectApp.pipe)(a.ttype === "one" ? _effectApp.Effect.andThen(eff, (0, _effectApp.flow)(_effectApp.Array.head, _effectApp.Effect.mapError(() => new _client.NotFoundError({
150
+ id: "query",
151
+ /* TODO */type: name
152
+ })))) : 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]", {
153
+ captureStackTrace: false,
154
+ attributes: {
155
+ "repository.model_name": name,
156
+ query: {
157
+ ...a,
158
+ schema: a.schema ? "__SCHEMA__" : a.schema,
159
+ filter: a.filter
160
+ }
161
+ }
162
+ }));
163
+ };
164
+ const r = {
165
+ changeFeed,
166
+ itemType: name,
167
+ idKey,
168
+ find,
169
+ all,
170
+ saveAndPublish,
171
+ removeAndPublish,
172
+ query(q) {
173
+ // eslint-disable-next-line prefer-rest-params
174
+ return query(typeof q === "function" ? _effectApp.Pipeable.pipeArguments(Q.make(), arguments) : q);
175
+ },
176
+ /**
177
+ * @internal
178
+ */
179
+ mapped: schema => {
180
+ const dec = _effectApp.S.decode(schema);
181
+ const encMany = _effectApp.S.encode(_effectApp.S.Array(schema));
182
+ const decMany = _effectApp.S.decode(_effectApp.S.Array(schema));
183
+ return {
184
+ all: allE.pipe(_effectApp.Effect.flatMap(decMany), _effectApp.Effect.map(_ => _)),
185
+ find: id => (0, _Effect.flatMapOption)(findE(id), dec),
186
+ // query: (q: any) => {
187
+ // const a = Q.toFilter(q)
188
+ // return filter(a)
189
+ // .pipe(
190
+ // Effect.flatMap(decMany),
191
+ // Effect.map((_) => _ as any[]),
192
+ // Effect.withSpan("Repository.mapped.query [effect-app/infra]", {
193
+ // captureStackTrace: false,
194
+ // attributes: {
195
+ // "repository.model_name": name,
196
+ // query: { ...a, schema: a.schema ? "__SCHEMA__" : a.schema, filter: a.filter.build() }
197
+ // }
198
+ // })
199
+ // )
200
+ // },
201
+ save: (...xes) => _effectApp.Effect.flatMap(encMany(xes), _ => saveAllE(_)).pipe(_effectApp.Effect.withSpan("mapped.save", {
202
+ captureStackTrace: false
203
+ }))
204
+ };
205
+ }
206
+ };
207
+ return r;
208
+ }).pipe(_effectApp.Effect
209
+ // .withSpan("Repository.make [effect-app/infra]", { attributes: { "repository.model_name": name } })
210
+ .withLogSpan("Repository.make: " + name));
211
+ }
212
+ return {
213
+ make,
214
+ Q: Q.make()
215
+ };
216
+ };
217
+ }
218
+ const pluralize = s => s.endsWith("s") ? s + "es" : s.endsWith("y") ? s.substring(0, s.length - 1) + "ies" : s + "s";
219
+ function makeStore() {
220
+ return (name, schema, mapTo) => {
221
+ function encodeToEncoded() {
222
+ const getEtag = () => undefined;
223
+ return t => _effectApp.S.encode(schema)(t).pipe(_effectApp.Effect.orDie, _effectApp.Effect.map(_ => mapToPersistenceModel(_, getEtag)));
224
+ }
225
+ function mapToPersistenceModel(e, getEtag) {
226
+ return mapTo(e, getEtag(e.id));
227
+ }
228
+ function makeStore(makeInitial, config) {
229
+ return _effectApp.Effect.gen(function* () {
230
+ const {
231
+ make
232
+ } = yield* _Store.StoreMaker;
233
+ const store = yield* make(pluralize(name), makeInitial ? makeInitial.pipe(_effectApp.Effect.flatMap(_effectApp.Effect.forEach(encodeToEncoded())), (0, _setupRequest.setupRequestContextFromCurrent)("Repository.makeInitial [effect-app/infra]", {
234
+ attributes: {
235
+ "repository.model_name": name
236
+ }
237
+ })) : undefined, {
238
+ ...config,
239
+ partitionValue: config?.partitionValue ?? (_ => "primary") /*(isIntegrationEvent(r) ? r.companyId : r.id*/
240
+ });
241
+ return store;
242
+ });
243
+ }
244
+ return makeStore;
245
+ };
246
+ }
247
+ //# 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","id","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","_","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":";;;;;;;AAGA,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,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,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,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O,GAAGA,CAAA,KAAMkF,SAAS;MAC/B,OAAQ9G,CAAI,IACV+C,YAAC,CAACC,MAAM,CAACzB,MAAM,CAAC,CAACvB,CAAC,CAAC,CAAC2D,IAAI,CACtBtB,iBAAM,CAACuB,KAAK,EACZvB,iBAAM,CAACmC,GAAG,CAAEX,CAAC,IAAKlC,qBAAqB,CAACkC,CAAC,EAAEjC,OAAO,CAAC,CAAC,CACrD;IACL;IAEA,SAASD,qBAAqBA,CAC5B9B,CAAI,EACJ+B,OAA2C;MAE3C,OAAOH,KAAK,CAAC5B,CAAC,EAAE+B,OAAO,CAAC/B,CAAC,CAACgC,EAAE,CAAC,CAAC;IAChC;IAEA,SAASK,SAASA,CAChBoB,WAAsD,EACtDC,MAEC;MAED,OAAOlB,iBAAM,CAACC,GAAG,CAAC,aAAS;QACzB,MAAM;UAAEH;QAAI,CAAE,GAAG,OAAOkH,iBAAU;QAElC,MAAMhG,KAAK,GAAG,OAAOlB,IAAI,CACvB8G,SAAS,CAAC3H,IAAI,CAAC,EACfgC,WAAW,GACPA,WAAW,CACVK,IAAI,CACHtB,iBAAM,CAACiC,OAAO,CAACjC,iBAAM,CAAC4D,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,GAAGvD,MAAM;UACTgG,cAAc,EAAEhG,MAAM,EAAEgG,cAAc,KAC/B1F,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":["_effectApp","require","Q","_interopRequireWildcard","_ext","_makeRepo","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","names","Map","registerName","name","existing","undefined","makeRepoFunctions","tag","itemType","all","Effect","serviceConstants","byIdAndSaveWithPure","find","query","queryAndSavePure","removeAndPublish","removeById","save","saveAndPublish","saveManyWithPure","serviceFunctions","mapped","s","map","_","use","body","andThen","RepositoryBase","impl","constructor","changeFeed","idKey","log","saveWithEvents","saveWithPure","request","exports","RepositoryDefaultImpl2","f","schema","options","layerCache","layerCache2","Cls","make","DefaultWithoutDependencies","self","gen","opts","succeed","mkRepo","makeRepoInternal","jitM","pm","_etag","repo","assign","extendRepo","ext","Layer","pipe","unwrapEffect","Default","dependencies","provide","limit","Error","stackTraceLimit","creationError","Context","assignTag"],"sources":["../../../src/Model/Repository/legacy.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;A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IT,IAAI,CAACxD,MAAM,CAACkE,MAAM,CAAC,IAAAC,eAAU,EAAC5E,CAAC,CAAC,EAAE,KAAK,IAAImE,IAAI,GAAGA,IAAI,CAACU,GAAG,GAAG,EAAE,CAAC,CAAC;UAClF,OAAOC,gBAAK,CAACV,OAAO,CAACH,IAAI,EAAES,IAAI,CAAC;QAClC,CAAC,CAAC,CACDK,IAAI,CAACD,gBAAK,CAACE,YAAY,CAAC;MAC7B;MACA,WAAWC,OAAOA,CAAA;QAChB,MAAMhB,IAAI,GAAG,IAAW;QACxB,OAAOJ,WAAW,KAAKF,OAAO,CAACuB,YAAY,GACvCjB,IAAI,CACHD,0BAA0B,CAC1Be,IAAI,CAACD,gBAAK,CAACK,OAAO,CAACxB,OAAO,CAACuB,YAAmB,CAAC,CAAC,GACjDjB,IAAI,CAACD,0BAA0B;MACrC;;IAEF,MAAMoB,KAAK,GAAGC,KAAK,CAACC,eAAe;IACnCD,KAAK,CAACC,eAAe,GAAG,CAAC;IACzB,MAAMC,aAAa,GAAG,IAAIF,KAAK,EAAE;IACjCA,KAAK,CAACC,eAAe,GAAGF,KAAK;IAC7B;IACA,OAAOI,kBAAO,CAACC,SAAS,CAAUtE,YAAY,CAACM,QAAQ,GAAG,MAAM,CAAC,EAAE8D,aAAa,CAAC,CAC/E9E,MAAM,CAACkE,MAAM,CAACb,GAAG,EAAEvC,iBAAiB,CAACuC,GAAG,EAAErC,QAAQ,CAAC,CAAC,CAC9C,EAAC;EACX,CAAC;EAED,OAAOgC,CAAC;AACV,CAAC;AAAAF,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"file":"legacy.cjs","names":[],"sources":["../../../src/Model/Repository/legacy.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}