@hot-updater/plugin-core 0.36.7 → 1.0.0-rc.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/dist/assetStorageLayout.cjs +36 -18
- package/dist/assetStorageLayout.d.cts +21 -6
- package/dist/assetStorageLayout.d.mts +21 -6
- package/dist/assetStorageLayout.mjs +36 -18
- package/dist/bundleStorageLayout.cjs +2 -3
- package/dist/bundleStorageLayout.mjs +2 -3
- package/dist/contentAddressedAssets.cjs +5 -0
- package/dist/contentAddressedAssets.d.cts +2 -1
- package/dist/contentAddressedAssets.d.mts +2 -1
- package/dist/contentAddressedAssets.mjs +5 -1
- package/dist/createDatabasePlugin.cjs +775 -284
- package/dist/createDatabasePlugin.d.cts +20 -64
- package/dist/createDatabasePlugin.d.mts +20 -64
- package/dist/createDatabasePlugin.mjs +773 -284
- package/dist/createStorageKeyBuilder.cjs +9 -2
- package/dist/createStorageKeyBuilder.mjs +9 -2
- package/dist/createStoragePlugin.cjs +6 -145
- package/dist/createStoragePlugin.d.cts +7 -52
- package/dist/createStoragePlugin.d.mts +7 -52
- package/dist/createStoragePlugin.mjs +5 -143
- package/dist/databaseClient.cjs +112 -0
- package/dist/databaseClient.d.cts +33 -0
- package/dist/databaseClient.d.mts +33 -0
- package/dist/databaseClient.mjs +110 -0
- package/dist/databaseClientReads.cjs +113 -0
- package/dist/databaseClientReads.mjs +112 -0
- package/dist/databaseClientUpdates.cjs +39 -0
- package/dist/databaseClientUpdates.d.cts +11 -0
- package/dist/databaseClientUpdates.d.mts +11 -0
- package/dist/databaseClientUpdates.mjs +36 -0
- package/dist/databaseJsonValue.cjs +37 -0
- package/dist/databaseJsonValue.d.cts +5 -0
- package/dist/databaseJsonValue.d.mts +5 -0
- package/dist/databaseJsonValue.mjs +37 -0
- package/dist/databaseMetadata.cjs +13 -0
- package/dist/databaseMetadata.mjs +12 -0
- package/dist/databasePluginCrud.cjs +86 -0
- package/dist/databasePluginCrud.d.cts +1 -0
- package/dist/databasePluginCrud.d.mts +1 -0
- package/dist/databasePluginCrud.mjs +86 -0
- package/dist/databasePluginCrudValidation.d.cts +1 -0
- package/dist/databasePluginCrudValidation.d.mts +1 -0
- package/dist/databasePluginCrudValidationErrors.cjs +10 -0
- package/dist/databasePluginCrudValidationErrors.d.cts +9 -0
- package/dist/databasePluginCrudValidationErrors.d.mts +9 -0
- package/dist/databasePluginCrudValidationErrors.mjs +10 -0
- package/dist/databasePluginCrudValidationFields.cjs +291 -0
- package/dist/databasePluginCrudValidationFields.d.cts +1 -0
- package/dist/databasePluginCrudValidationFields.d.mts +1 -0
- package/dist/databasePluginCrudValidationFields.mjs +281 -0
- package/dist/databasePluginCrudValidationMutations.cjs +88 -0
- package/dist/databasePluginCrudValidationMutations.d.cts +1 -0
- package/dist/databasePluginCrudValidationMutations.d.mts +1 -0
- package/dist/databasePluginCrudValidationMutations.mjs +82 -0
- package/dist/databasePluginCrudValidationQueries.cjs +103 -0
- package/dist/databasePluginCrudValidationQueries.d.cts +1 -0
- package/dist/databasePluginCrudValidationQueries.d.mts +1 -0
- package/dist/databasePluginCrudValidationQueries.mjs +97 -0
- package/dist/databasePluginCrudValidationRows.cjs +55 -0
- package/dist/databasePluginCrudValidationRows.d.cts +1 -0
- package/dist/databasePluginCrudValidationRows.d.mts +1 -0
- package/dist/databasePluginCrudValidationRows.mjs +53 -0
- package/dist/databasePluginTransaction.cjs +7 -0
- package/dist/databasePluginTransaction.mjs +7 -0
- package/dist/databaseRows.cjs +149 -0
- package/dist/databaseRows.d.cts +34 -0
- package/dist/databaseRows.d.mts +34 -0
- package/dist/databaseRows.mjs +141 -0
- package/dist/index.cjs +76 -24
- package/dist/index.d.cts +22 -12
- package/dist/index.d.mts +22 -12
- package/dist/index.mjs +21 -14
- package/dist/internal.cjs +6 -0
- package/dist/internal.d.cts +9 -0
- package/dist/internal.d.mts +9 -0
- package/dist/internal.mjs +3 -0
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.cjs +345 -0
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.mjs +341 -0
- package/dist/paginateBundles.d.cts +6 -4
- package/dist/paginateBundles.d.mts +6 -4
- package/dist/parseStorageUri.cjs +46 -30
- package/dist/parseStorageUri.d.cts +20 -17
- package/dist/parseStorageUri.d.mts +20 -17
- package/dist/parseStorageUri.mjs +46 -30
- package/dist/queryBundles.cjs +1 -7
- package/dist/queryBundles.d.cts +3 -1
- package/dist/queryBundles.d.mts +3 -1
- package/dist/queryBundles.mjs +1 -7
- package/dist/releaseCatalogCompiler.cjs +391 -0
- package/dist/releaseCatalogCompiler.d.cts +55 -0
- package/dist/releaseCatalogCompiler.d.mts +55 -0
- package/dist/releaseCatalogCompiler.mjs +386 -0
- package/dist/releaseCatalogMutation.cjs +303 -0
- package/dist/releaseCatalogMutation.d.cts +86 -0
- package/dist/releaseCatalogMutation.d.mts +86 -0
- package/dist/releaseCatalogMutation.mjs +297 -0
- package/dist/releaseManagement.cjs +231 -0
- package/dist/releaseManagement.d.cts +48 -0
- package/dist/releaseManagement.d.mts +48 -0
- package/dist/releaseManagement.mjs +224 -0
- package/dist/remoteBundleSigning.cjs +296 -0
- package/dist/remoteBundleSigning.d.cts +43 -0
- package/dist/remoteBundleSigning.d.mts +43 -0
- package/dist/remoteBundleSigning.mjs +291 -0
- package/dist/requestBundleCache.cjs +22 -0
- package/dist/requestBundleCache.d.cts +9 -0
- package/dist/requestBundleCache.d.mts +9 -0
- package/dist/requestBundleCache.mjs +22 -0
- package/dist/semverSatisfies.cjs +3 -4
- package/dist/semverSatisfies.mjs +1 -1
- package/dist/storageDownloadPath.cjs +48 -0
- package/dist/storageDownloadPath.d.cts +15 -0
- package/dist/storageDownloadPath.d.mts +15 -0
- package/dist/storageDownloadPath.mjs +46 -0
- package/dist/types/database.d.cts +4 -0
- package/dist/types/database.d.mts +4 -0
- package/dist/types/databaseFields.cjs +92 -0
- package/dist/types/databaseFields.d.cts +12 -0
- package/dist/types/databaseFields.d.mts +12 -0
- package/dist/types/databaseFields.mjs +92 -0
- package/dist/types/databaseOperations.d.cts +173 -0
- package/dist/types/databaseOperations.d.mts +173 -0
- package/dist/types/databasePlugin.d.cts +240 -0
- package/dist/types/databasePlugin.d.mts +240 -0
- package/dist/types/databaseQuery.d.cts +47 -0
- package/dist/types/databaseQuery.d.mts +47 -0
- package/dist/types/databaseRows.d.cts +120 -0
- package/dist/types/databaseRows.d.mts +120 -0
- package/dist/types/index.d.cts +120 -162
- package/dist/types/index.d.mts +120 -162
- package/dist/types/internal.d.cts +7 -0
- package/dist/types/internal.d.mts +7 -0
- package/dist/types/public.d.cts +3 -0
- package/dist/types/public.d.mts +3 -0
- package/dist/uuidv7.cjs +9 -0
- package/dist/uuidv7.d.cts +4 -1
- package/dist/uuidv7.d.mts +4 -1
- package/dist/uuidv7.mjs +8 -1
- package/package.json +10 -5
- package/dist/bundleUnitOfWork.cjs +0 -158
- package/dist/bundleUnitOfWork.mjs +0 -158
- package/dist/bundleUnitOfWorkStore.cjs +0 -15
- package/dist/bundleUnitOfWorkStore.mjs +0 -15
- package/dist/createBlobDatabasePlugin.cjs +0 -382
- package/dist/createBlobDatabasePlugin.d.cts +0 -29
- package/dist/createBlobDatabasePlugin.d.mts +0 -29
- package/dist/createBlobDatabasePlugin.mjs +0 -381
- package/dist/legacyAssetStorageLayout.cjs +0 -12
- package/dist/legacyAssetStorageLayout.mjs +0 -12
- package/dist/requestUpdateBundleState.cjs +0 -26
- package/dist/requestUpdateBundleState.d.cts +0 -12
- package/dist/requestUpdateBundleState.d.mts +0 -12
- package/dist/requestUpdateBundleState.mjs +0 -24
- package/dist/resolveUpdateInfoFromBundles.cjs +0 -14
- package/dist/resolveUpdateInfoFromBundles.d.cts +0 -16
- package/dist/resolveUpdateInfoFromBundles.d.mts +0 -16
- package/dist/resolveUpdateInfoFromBundles.mjs +0 -13
- package/dist/storageProfile.cjs +0 -15
- package/dist/storageProfile.d.cts +0 -9
- package/dist/storageProfile.d.mts +0 -9
- package/dist/storageProfile.mjs +0 -12
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
const require_queryBundles = require("./queryBundles.cjs");
|
|
2
|
-
//#region src/bundleUnitOfWork.ts
|
|
3
|
-
const resolveEntryValue = (entry) => entry.kind === "present" ? entry.bundle : null;
|
|
4
|
-
var BundleUnitOfWork = class {
|
|
5
|
-
entries = /* @__PURE__ */ new Map();
|
|
6
|
-
pendingLoads = /* @__PURE__ */ new Map();
|
|
7
|
-
changes = /* @__PURE__ */ new Map();
|
|
8
|
-
seededIds = /* @__PURE__ */ new Set();
|
|
9
|
-
seed(seeds) {
|
|
10
|
-
for (const seed of seeds) {
|
|
11
|
-
if (!seed) continue;
|
|
12
|
-
this.seededIds.add(seed.id);
|
|
13
|
-
if (!this.changes.has(seed.id)) this.entries.set(seed.id, {
|
|
14
|
-
kind: "present",
|
|
15
|
-
bundle: seed
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
hasSeeds() {
|
|
20
|
-
return this.seededIds.size > 0;
|
|
21
|
-
}
|
|
22
|
-
seededBundles() {
|
|
23
|
-
const bundles = [];
|
|
24
|
-
for (const bundleId of this.seededIds) {
|
|
25
|
-
const entry = this.entries.get(bundleId);
|
|
26
|
-
if (entry?.kind === "present") bundles.push(entry.bundle);
|
|
27
|
-
}
|
|
28
|
-
return bundles;
|
|
29
|
-
}
|
|
30
|
-
peek(bundleId) {
|
|
31
|
-
const entry = this.entries.get(bundleId);
|
|
32
|
-
if (entry?.kind === "present") return entry.bundle;
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
peekChanged(bundleId) {
|
|
36
|
-
if (!this.changes.has(bundleId)) return { found: false };
|
|
37
|
-
const entry = this.entries.get(bundleId);
|
|
38
|
-
return {
|
|
39
|
-
found: true,
|
|
40
|
-
value: entry ? resolveEntryValue(entry) : null
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async getById(bundleId, loadBundleById) {
|
|
44
|
-
const entry = this.entries.get(bundleId);
|
|
45
|
-
if (entry) return resolveEntryValue(entry);
|
|
46
|
-
const pendingLoad = this.pendingLoads.get(bundleId);
|
|
47
|
-
if (pendingLoad) return pendingLoad;
|
|
48
|
-
const load = loadBundleById().then((bundle) => {
|
|
49
|
-
this.pendingLoads.delete(bundleId);
|
|
50
|
-
const currentEntry = this.entries.get(bundleId);
|
|
51
|
-
if (currentEntry) return resolveEntryValue(currentEntry);
|
|
52
|
-
this.entries.set(bundleId, bundle ? {
|
|
53
|
-
kind: "present",
|
|
54
|
-
bundle
|
|
55
|
-
} : { kind: "missing" });
|
|
56
|
-
return bundle;
|
|
57
|
-
}, (error) => {
|
|
58
|
-
this.pendingLoads.delete(bundleId);
|
|
59
|
-
throw error;
|
|
60
|
-
});
|
|
61
|
-
this.pendingLoads.set(bundleId, load);
|
|
62
|
-
return load;
|
|
63
|
-
}
|
|
64
|
-
overlayList(bundles, options) {
|
|
65
|
-
const dataById = /* @__PURE__ */ new Map();
|
|
66
|
-
for (const bundle of bundles) {
|
|
67
|
-
const entry = this.entries.get(bundle.id);
|
|
68
|
-
if (entry?.kind === "deleted") continue;
|
|
69
|
-
if (entry?.kind === "present") {
|
|
70
|
-
if (require_queryBundles.bundleMatchesQueryWhere(entry.bundle, options.where)) dataById.set(entry.bundle.id, entry.bundle);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
this.entries.set(bundle.id, {
|
|
74
|
-
kind: "present",
|
|
75
|
-
bundle
|
|
76
|
-
});
|
|
77
|
-
dataById.set(bundle.id, bundle);
|
|
78
|
-
}
|
|
79
|
-
for (const change of this.changes.values()) {
|
|
80
|
-
if (change.operation === "delete" || change.operation === "insert") {
|
|
81
|
-
dataById.delete(change.data.id);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (require_queryBundles.bundleMatchesQueryWhere(change.data, options.where)) dataById.set(change.data.id, change.data);
|
|
85
|
-
else dataById.delete(change.data.id);
|
|
86
|
-
}
|
|
87
|
-
return require_queryBundles.sortBundles(Array.from(dataById.values()), options.orderBy).slice(0, options.limit);
|
|
88
|
-
}
|
|
89
|
-
markInsert(bundle) {
|
|
90
|
-
this.entries.set(bundle.id, {
|
|
91
|
-
kind: "present",
|
|
92
|
-
bundle
|
|
93
|
-
});
|
|
94
|
-
this.changes.set(bundle.id, {
|
|
95
|
-
operation: "insert",
|
|
96
|
-
data: bundle,
|
|
97
|
-
before: null
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
markUpdate(bundle) {
|
|
101
|
-
const previousChange = this.changes.get(bundle.id);
|
|
102
|
-
const previousEntry = this.entries.get(bundle.id);
|
|
103
|
-
const operation = previousChange?.operation ?? "update";
|
|
104
|
-
this.entries.set(bundle.id, {
|
|
105
|
-
kind: "present",
|
|
106
|
-
bundle
|
|
107
|
-
});
|
|
108
|
-
this.changes.set(bundle.id, {
|
|
109
|
-
operation,
|
|
110
|
-
data: bundle,
|
|
111
|
-
before: previousChange?.before ?? (previousEntry ? resolveEntryValue(previousEntry) : null)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
markDelete(bundle) {
|
|
115
|
-
const previousChange = this.changes.get(bundle.id);
|
|
116
|
-
const previousEntry = this.entries.get(bundle.id);
|
|
117
|
-
this.entries.set(bundle.id, {
|
|
118
|
-
kind: "deleted",
|
|
119
|
-
bundle
|
|
120
|
-
});
|
|
121
|
-
this.changes.set(bundle.id, {
|
|
122
|
-
operation: "delete",
|
|
123
|
-
data: bundle,
|
|
124
|
-
before: previousChange?.before ?? (previousEntry ? resolveEntryValue(previousEntry) : bundle)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
changedSets() {
|
|
128
|
-
return Array.from(this.changes.values(), ({ data, operation }) => ({
|
|
129
|
-
operation,
|
|
130
|
-
data
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
hasChanges() {
|
|
134
|
-
return this.changes.size > 0;
|
|
135
|
-
}
|
|
136
|
-
listFetchExtraCount() {
|
|
137
|
-
return Array.from(this.changes.values()).filter((change) => change.operation === "update" || change.operation === "delete").length;
|
|
138
|
-
}
|
|
139
|
-
totalDelta(where) {
|
|
140
|
-
let total = 0;
|
|
141
|
-
for (const change of this.changes.values()) {
|
|
142
|
-
if (change.operation === "insert") continue;
|
|
143
|
-
const matchedBefore = change.before !== null && require_queryBundles.bundleMatchesQueryWhere(change.before, where);
|
|
144
|
-
const matchesAfter = change.operation === "update" && require_queryBundles.bundleMatchesQueryWhere(change.data, where);
|
|
145
|
-
if (matchedBefore && !matchesAfter) total -= 1;
|
|
146
|
-
else if (!matchedBefore && matchesAfter) total += 1;
|
|
147
|
-
}
|
|
148
|
-
return total;
|
|
149
|
-
}
|
|
150
|
-
clear() {
|
|
151
|
-
this.entries.clear();
|
|
152
|
-
this.pendingLoads.clear();
|
|
153
|
-
this.changes.clear();
|
|
154
|
-
this.seededIds.clear();
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
|
-
exports.BundleUnitOfWork = BundleUnitOfWork;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { bundleMatchesQueryWhere, sortBundles } from "./queryBundles.mjs";
|
|
2
|
-
//#region src/bundleUnitOfWork.ts
|
|
3
|
-
const resolveEntryValue = (entry) => entry.kind === "present" ? entry.bundle : null;
|
|
4
|
-
var BundleUnitOfWork = class {
|
|
5
|
-
entries = /* @__PURE__ */ new Map();
|
|
6
|
-
pendingLoads = /* @__PURE__ */ new Map();
|
|
7
|
-
changes = /* @__PURE__ */ new Map();
|
|
8
|
-
seededIds = /* @__PURE__ */ new Set();
|
|
9
|
-
seed(seeds) {
|
|
10
|
-
for (const seed of seeds) {
|
|
11
|
-
if (!seed) continue;
|
|
12
|
-
this.seededIds.add(seed.id);
|
|
13
|
-
if (!this.changes.has(seed.id)) this.entries.set(seed.id, {
|
|
14
|
-
kind: "present",
|
|
15
|
-
bundle: seed
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
hasSeeds() {
|
|
20
|
-
return this.seededIds.size > 0;
|
|
21
|
-
}
|
|
22
|
-
seededBundles() {
|
|
23
|
-
const bundles = [];
|
|
24
|
-
for (const bundleId of this.seededIds) {
|
|
25
|
-
const entry = this.entries.get(bundleId);
|
|
26
|
-
if (entry?.kind === "present") bundles.push(entry.bundle);
|
|
27
|
-
}
|
|
28
|
-
return bundles;
|
|
29
|
-
}
|
|
30
|
-
peek(bundleId) {
|
|
31
|
-
const entry = this.entries.get(bundleId);
|
|
32
|
-
if (entry?.kind === "present") return entry.bundle;
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
peekChanged(bundleId) {
|
|
36
|
-
if (!this.changes.has(bundleId)) return { found: false };
|
|
37
|
-
const entry = this.entries.get(bundleId);
|
|
38
|
-
return {
|
|
39
|
-
found: true,
|
|
40
|
-
value: entry ? resolveEntryValue(entry) : null
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async getById(bundleId, loadBundleById) {
|
|
44
|
-
const entry = this.entries.get(bundleId);
|
|
45
|
-
if (entry) return resolveEntryValue(entry);
|
|
46
|
-
const pendingLoad = this.pendingLoads.get(bundleId);
|
|
47
|
-
if (pendingLoad) return pendingLoad;
|
|
48
|
-
const load = loadBundleById().then((bundle) => {
|
|
49
|
-
this.pendingLoads.delete(bundleId);
|
|
50
|
-
const currentEntry = this.entries.get(bundleId);
|
|
51
|
-
if (currentEntry) return resolveEntryValue(currentEntry);
|
|
52
|
-
this.entries.set(bundleId, bundle ? {
|
|
53
|
-
kind: "present",
|
|
54
|
-
bundle
|
|
55
|
-
} : { kind: "missing" });
|
|
56
|
-
return bundle;
|
|
57
|
-
}, (error) => {
|
|
58
|
-
this.pendingLoads.delete(bundleId);
|
|
59
|
-
throw error;
|
|
60
|
-
});
|
|
61
|
-
this.pendingLoads.set(bundleId, load);
|
|
62
|
-
return load;
|
|
63
|
-
}
|
|
64
|
-
overlayList(bundles, options) {
|
|
65
|
-
const dataById = /* @__PURE__ */ new Map();
|
|
66
|
-
for (const bundle of bundles) {
|
|
67
|
-
const entry = this.entries.get(bundle.id);
|
|
68
|
-
if (entry?.kind === "deleted") continue;
|
|
69
|
-
if (entry?.kind === "present") {
|
|
70
|
-
if (bundleMatchesQueryWhere(entry.bundle, options.where)) dataById.set(entry.bundle.id, entry.bundle);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
this.entries.set(bundle.id, {
|
|
74
|
-
kind: "present",
|
|
75
|
-
bundle
|
|
76
|
-
});
|
|
77
|
-
dataById.set(bundle.id, bundle);
|
|
78
|
-
}
|
|
79
|
-
for (const change of this.changes.values()) {
|
|
80
|
-
if (change.operation === "delete" || change.operation === "insert") {
|
|
81
|
-
dataById.delete(change.data.id);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (bundleMatchesQueryWhere(change.data, options.where)) dataById.set(change.data.id, change.data);
|
|
85
|
-
else dataById.delete(change.data.id);
|
|
86
|
-
}
|
|
87
|
-
return sortBundles(Array.from(dataById.values()), options.orderBy).slice(0, options.limit);
|
|
88
|
-
}
|
|
89
|
-
markInsert(bundle) {
|
|
90
|
-
this.entries.set(bundle.id, {
|
|
91
|
-
kind: "present",
|
|
92
|
-
bundle
|
|
93
|
-
});
|
|
94
|
-
this.changes.set(bundle.id, {
|
|
95
|
-
operation: "insert",
|
|
96
|
-
data: bundle,
|
|
97
|
-
before: null
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
markUpdate(bundle) {
|
|
101
|
-
const previousChange = this.changes.get(bundle.id);
|
|
102
|
-
const previousEntry = this.entries.get(bundle.id);
|
|
103
|
-
const operation = previousChange?.operation ?? "update";
|
|
104
|
-
this.entries.set(bundle.id, {
|
|
105
|
-
kind: "present",
|
|
106
|
-
bundle
|
|
107
|
-
});
|
|
108
|
-
this.changes.set(bundle.id, {
|
|
109
|
-
operation,
|
|
110
|
-
data: bundle,
|
|
111
|
-
before: previousChange?.before ?? (previousEntry ? resolveEntryValue(previousEntry) : null)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
markDelete(bundle) {
|
|
115
|
-
const previousChange = this.changes.get(bundle.id);
|
|
116
|
-
const previousEntry = this.entries.get(bundle.id);
|
|
117
|
-
this.entries.set(bundle.id, {
|
|
118
|
-
kind: "deleted",
|
|
119
|
-
bundle
|
|
120
|
-
});
|
|
121
|
-
this.changes.set(bundle.id, {
|
|
122
|
-
operation: "delete",
|
|
123
|
-
data: bundle,
|
|
124
|
-
before: previousChange?.before ?? (previousEntry ? resolveEntryValue(previousEntry) : bundle)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
changedSets() {
|
|
128
|
-
return Array.from(this.changes.values(), ({ data, operation }) => ({
|
|
129
|
-
operation,
|
|
130
|
-
data
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
hasChanges() {
|
|
134
|
-
return this.changes.size > 0;
|
|
135
|
-
}
|
|
136
|
-
listFetchExtraCount() {
|
|
137
|
-
return Array.from(this.changes.values()).filter((change) => change.operation === "update" || change.operation === "delete").length;
|
|
138
|
-
}
|
|
139
|
-
totalDelta(where) {
|
|
140
|
-
let total = 0;
|
|
141
|
-
for (const change of this.changes.values()) {
|
|
142
|
-
if (change.operation === "insert") continue;
|
|
143
|
-
const matchedBefore = change.before !== null && bundleMatchesQueryWhere(change.before, where);
|
|
144
|
-
const matchesAfter = change.operation === "update" && bundleMatchesQueryWhere(change.data, where);
|
|
145
|
-
if (matchedBefore && !matchesAfter) total -= 1;
|
|
146
|
-
else if (!matchedBefore && matchesAfter) total += 1;
|
|
147
|
-
}
|
|
148
|
-
return total;
|
|
149
|
-
}
|
|
150
|
-
clear() {
|
|
151
|
-
this.entries.clear();
|
|
152
|
-
this.pendingLoads.clear();
|
|
153
|
-
this.changes.clear();
|
|
154
|
-
this.seededIds.clear();
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
|
-
export { BundleUnitOfWork };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const require_bundleUnitOfWork = require("./bundleUnitOfWork.cjs");
|
|
2
|
-
//#region src/bundleUnitOfWorkStore.ts
|
|
3
|
-
const requestUnitOfWorks = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
const isUnitOfWorkContext = (value) => typeof value === "object" && value !== null || typeof value === "function";
|
|
5
|
-
const getRequestBundleUnitOfWork = (context) => {
|
|
6
|
-
if (!isUnitOfWorkContext(context)) return null;
|
|
7
|
-
let unitOfWork = requestUnitOfWorks.get(context);
|
|
8
|
-
if (!unitOfWork) {
|
|
9
|
-
unitOfWork = new require_bundleUnitOfWork.BundleUnitOfWork();
|
|
10
|
-
requestUnitOfWorks.set(context, unitOfWork);
|
|
11
|
-
}
|
|
12
|
-
return unitOfWork;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
exports.getRequestBundleUnitOfWork = getRequestBundleUnitOfWork;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BundleUnitOfWork } from "./bundleUnitOfWork.mjs";
|
|
2
|
-
//#region src/bundleUnitOfWorkStore.ts
|
|
3
|
-
const requestUnitOfWorks = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
const isUnitOfWorkContext = (value) => typeof value === "object" && value !== null || typeof value === "function";
|
|
5
|
-
const getRequestBundleUnitOfWork = (context) => {
|
|
6
|
-
if (!isUnitOfWorkContext(context)) return null;
|
|
7
|
-
let unitOfWork = requestUnitOfWorks.get(context);
|
|
8
|
-
if (!unitOfWork) {
|
|
9
|
-
unitOfWork = new BundleUnitOfWork();
|
|
10
|
-
requestUnitOfWorks.set(context, unitOfWork);
|
|
11
|
-
}
|
|
12
|
-
return unitOfWork;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { getRequestBundleUnitOfWork };
|