@contello/store 4.3.0 → 4.4.1
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 -4
- package/dist/fragments.d.ts +1 -2
- package/dist/fragments.d.ts.map +1 -1
- package/dist/fragments.js.map +1 -1
- package/dist/index.cjs +78 -25
- package/dist/index.d.cts +32 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +32 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -25
- package/dist/index.js.map +1 -1
- package/fragments/route.gql +3 -0
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -82,6 +82,9 @@ const StoreRouteFragmentSchema = `fragment StoreRoute on ContelloRoute {
|
|
|
82
82
|
content
|
|
83
83
|
mimeType
|
|
84
84
|
}
|
|
85
|
+
... on ContelloRouteTargetSitemap {
|
|
86
|
+
sitemapId
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
customHeaders {
|
|
87
90
|
name
|
|
@@ -145,6 +148,26 @@ const schema = {
|
|
|
145
148
|
document: `${MediaFileFragmentSchema}\n${MediaAssetFragmentSchema}\n${StoreAssetFragmentSchema}`,
|
|
146
149
|
fragment: "StoreAsset",
|
|
147
150
|
subscription: "contelloAssetsBatch",
|
|
151
|
+
mutations: {
|
|
152
|
+
update: {
|
|
153
|
+
field: "updateContelloAsset",
|
|
154
|
+
arguments: [{
|
|
155
|
+
name: "request",
|
|
156
|
+
type: "ContelloAssetUpdateInput!",
|
|
157
|
+
from: "input"
|
|
158
|
+
}],
|
|
159
|
+
result: "entity"
|
|
160
|
+
},
|
|
161
|
+
delete: {
|
|
162
|
+
field: "deleteContelloAsset",
|
|
163
|
+
arguments: [{
|
|
164
|
+
name: "id",
|
|
165
|
+
type: "String!",
|
|
166
|
+
from: "id"
|
|
167
|
+
}],
|
|
168
|
+
result: "idObject"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
148
171
|
__model: "storeAsset",
|
|
149
172
|
__cardinality: "asset"
|
|
150
173
|
},
|
|
@@ -159,6 +182,35 @@ const schema = {
|
|
|
159
182
|
document: StoreRouteFragmentSchema,
|
|
160
183
|
fragment: "StoreRoute",
|
|
161
184
|
subscription: "contelloRoutesBatch",
|
|
185
|
+
mutations: {
|
|
186
|
+
create: {
|
|
187
|
+
field: "createContelloRoute",
|
|
188
|
+
arguments: [{
|
|
189
|
+
name: "route",
|
|
190
|
+
type: "ContelloRouteInput!",
|
|
191
|
+
from: "input"
|
|
192
|
+
}],
|
|
193
|
+
result: "entity"
|
|
194
|
+
},
|
|
195
|
+
update: {
|
|
196
|
+
field: "updateContelloRoute",
|
|
197
|
+
arguments: [{
|
|
198
|
+
name: "route",
|
|
199
|
+
type: "ContelloRouteInput!",
|
|
200
|
+
from: "input"
|
|
201
|
+
}],
|
|
202
|
+
result: "entity"
|
|
203
|
+
},
|
|
204
|
+
delete: {
|
|
205
|
+
field: "deleteContelloRoute",
|
|
206
|
+
arguments: [{
|
|
207
|
+
name: "id",
|
|
208
|
+
type: "String",
|
|
209
|
+
from: "id"
|
|
210
|
+
}],
|
|
211
|
+
result: "idScalar"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
162
214
|
__model: "storeRoute",
|
|
163
215
|
__cardinality: "route"
|
|
164
216
|
}
|
|
@@ -175,7 +227,7 @@ const { wrap } = createOperationTelemetry("@contello/store");
|
|
|
175
227
|
* use it as the interval for a periodic full refresh; lazy stores use it as the per-item
|
|
176
228
|
* LRU eviction window. 3 hours.
|
|
177
229
|
*/
|
|
178
|
-
const DEFAULT_TTL_MS =
|
|
230
|
+
const DEFAULT_TTL_MS = 108e5;
|
|
179
231
|
/**
|
|
180
232
|
* resolves the consumer-supplied `ttl` (number | false | undefined) into a runtime
|
|
181
233
|
* value: undefined → default, false or 0 → disabled (undefined), positive → as-is.
|
|
@@ -214,11 +266,10 @@ function createRefresher(fn, onRefreshed, onStart) {
|
|
|
214
266
|
refreshing = false;
|
|
215
267
|
inFlightKind = void 0;
|
|
216
268
|
onRefreshed(finished);
|
|
217
|
-
if (pendingKind)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
269
|
+
if (!pendingKind) return;
|
|
270
|
+
const { kind: next } = pendingKind;
|
|
271
|
+
pendingKind = void 0;
|
|
272
|
+
scheduleRefresh(next);
|
|
222
273
|
});
|
|
223
274
|
}
|
|
224
275
|
return scheduleRefresh;
|
|
@@ -558,10 +609,9 @@ var DependencyCollector = class {
|
|
|
558
609
|
if (!existingDeps) return;
|
|
559
610
|
for (const dk of existingDeps) {
|
|
560
611
|
const set = this.reverseIndex.get(dk);
|
|
561
|
-
if (set)
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
612
|
+
if (!set) continue;
|
|
613
|
+
set.delete(key);
|
|
614
|
+
if (set.size === 0) this.reverseIndex.delete(dk);
|
|
565
615
|
}
|
|
566
616
|
this.forwardIndex.delete(key);
|
|
567
617
|
}
|
|
@@ -1126,13 +1176,12 @@ function createLazyCollection(source, options, client, updates$, resolver) {
|
|
|
1126
1176
|
const ownModelEvents = batch.entity.get(_def.model);
|
|
1127
1177
|
if (ownModelEvents) for (const event of ownModelEvents) evicted.add(event.id);
|
|
1128
1178
|
for (const event of batch.events) for (const key of dependencyCollector.getAffectedKeys(event)) evicted.add(key);
|
|
1129
|
-
if (evicted.size
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
emit([...evicted], "upstream-update");
|
|
1179
|
+
if (evicted.size === 0) return;
|
|
1180
|
+
for (const key of evicted) {
|
|
1181
|
+
dependencyCollector.removeItem(key);
|
|
1182
|
+
projected.delete(key);
|
|
1135
1183
|
}
|
|
1184
|
+
emit([...evicted], "upstream-update");
|
|
1136
1185
|
});
|
|
1137
1186
|
return {
|
|
1138
1187
|
instance: {
|
|
@@ -1198,6 +1247,11 @@ function mapRoute(raw, resolver) {
|
|
|
1198
1247
|
entityId: raw.target.entity.id
|
|
1199
1248
|
};
|
|
1200
1249
|
}
|
|
1250
|
+
case "ContelloRouteTargetSitemap": return {
|
|
1251
|
+
...base,
|
|
1252
|
+
type: "sitemap",
|
|
1253
|
+
sitemapId: raw.target.sitemapId
|
|
1254
|
+
};
|
|
1201
1255
|
default: return;
|
|
1202
1256
|
}
|
|
1203
1257
|
}
|
|
@@ -1468,10 +1522,9 @@ function createRoutesCollection(options, client, updates$, resolver, refreshByTt
|
|
|
1468
1522
|
for (const id of ids) {
|
|
1469
1523
|
if (returnedIds.has(id)) continue;
|
|
1470
1524
|
const oldPath = pathById.get(id);
|
|
1471
|
-
if (oldPath
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1525
|
+
if (oldPath === void 0) continue;
|
|
1526
|
+
idByPath.delete(oldPath);
|
|
1527
|
+
pathById.delete(id);
|
|
1475
1528
|
}
|
|
1476
1529
|
for (const r of items) {
|
|
1477
1530
|
const oldPath = pathById.get(r.id);
|
|
@@ -1523,10 +1576,9 @@ function createRoutesCollection(options, client, updates$, resolver, refreshByTt
|
|
|
1523
1576
|
writeBuffer.release(deleted);
|
|
1524
1577
|
for (const id of deleted) {
|
|
1525
1578
|
const oldPath = pathById.get(id);
|
|
1526
|
-
if (oldPath
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
}
|
|
1579
|
+
if (oldPath === void 0) continue;
|
|
1580
|
+
idByPath.delete(oldPath);
|
|
1581
|
+
pathById.delete(id);
|
|
1530
1582
|
}
|
|
1531
1583
|
if (deleted.length > 0) projected.delete(deleted);
|
|
1532
1584
|
runPartialRefresh([...upserted], deleted);
|
|
@@ -1858,7 +1910,8 @@ function createInternalWatcher(client, resolver) {
|
|
|
1858
1910
|
const signal = controller.signal;
|
|
1859
1911
|
wrap("watcher:start", () => {
|
|
1860
1912
|
(async () => {
|
|
1861
|
-
const
|
|
1913
|
+
const source = keepalive(() => client.subscribe(storeWatchUpdatesDocument), { signal });
|
|
1914
|
+
const events = mapAsync(source, (data) => (data.contelloUpdatesBatch?.events ?? []).map((e) => safeMapEvent(e, resolver)).filter((e) => e !== void 0));
|
|
1862
1915
|
for await (const list of events) {
|
|
1863
1916
|
if (signal.aborted) return;
|
|
1864
1917
|
if (list.length === 0) continue;
|