@hot-updater/server 1.0.0-rc.2 → 1.0.0-rc.21
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/LICENSE +12 -14
- package/dist/adapters/drizzle.cjs +32 -75
- package/dist/adapters/drizzle.d.cts +13 -5
- package/dist/adapters/drizzle.d.mts +13 -5
- package/dist/adapters/drizzle.mjs +32 -77
- package/dist/adapters/drizzleExecutor.cjs +114 -0
- package/dist/adapters/drizzleExecutor.d.cts +9 -0
- package/dist/adapters/drizzleExecutor.d.mts +9 -0
- package/dist/adapters/drizzleExecutor.mjs +112 -0
- package/dist/adapters/kysely.cjs +22 -31
- package/dist/adapters/kysely.d.cts +10 -6
- package/dist/adapters/kysely.d.mts +10 -6
- package/dist/adapters/kysely.mjs +23 -33
- package/dist/adapters/kyselyExecutor.cjs +32 -0
- package/dist/adapters/kyselyExecutor.d.cts +11 -0
- package/dist/adapters/kyselyExecutor.d.mts +11 -0
- package/dist/adapters/kyselyExecutor.mjs +32 -0
- package/dist/adapters/mongodb.cjs +18 -54
- package/dist/adapters/mongodb.d.cts +10 -5
- package/dist/adapters/mongodb.d.mts +10 -5
- package/dist/adapters/mongodb.mjs +19 -56
- package/dist/adapters/mongodbAdapter.cjs +192 -0
- package/dist/adapters/mongodbAdapter.d.cts +9 -0
- package/dist/adapters/mongodbAdapter.d.mts +9 -0
- package/dist/adapters/mongodbAdapter.mjs +191 -0
- package/dist/adapters/prisma.cjs +35 -267
- package/dist/adapters/prisma.d.cts +12 -7
- package/dist/adapters/prisma.d.mts +12 -7
- package/dist/adapters/prisma.mjs +36 -268
- package/dist/adapters/prismaExecutor.cjs +63 -0
- package/dist/adapters/prismaExecutor.mjs +63 -0
- package/dist/adapters/sqlProviders.cjs +14 -0
- package/dist/adapters/sqlProviders.mjs +14 -0
- package/dist/assembly/assemblePlugins.cjs +144 -0
- package/dist/assembly/assemblePlugins.d.cts +5 -0
- package/dist/assembly/assemblePlugins.d.mts +5 -0
- package/dist/assembly/assemblePlugins.mjs +139 -0
- package/dist/assembly/clientPlugins.cjs +88 -0
- package/dist/assembly/clientPlugins.mjs +88 -0
- package/dist/assembly/configError.d.cts +2 -0
- package/dist/assembly/configError.d.mts +2 -0
- package/dist/assembly/configError.mjs +2 -0
- package/dist/core/api.cjs +51 -0
- package/dist/core/api.d.cts +54 -0
- package/dist/core/api.d.mts +54 -0
- package/dist/core/api.mjs +51 -0
- package/dist/core/baseCandidates.cjs +28 -0
- package/dist/core/baseCandidates.mjs +28 -0
- package/dist/core/operations.cjs +351 -0
- package/dist/core/operations.mjs +351 -0
- package/dist/core/reads.cjs +273 -0
- package/dist/core/reads.d.cts +9 -0
- package/dist/core/reads.d.mts +9 -0
- package/dist/core/reads.mjs +267 -0
- package/dist/core/releases.cjs +193 -0
- package/dist/core/releases.mjs +190 -0
- package/dist/core/writes.cjs +96 -0
- package/dist/core/writes.mjs +91 -0
- package/dist/createHotUpdaterCore.cjs +72 -91
- package/dist/createHotUpdaterCore.d.cts +106 -38
- package/dist/createHotUpdaterCore.d.mts +106 -38
- package/dist/createHotUpdaterCore.mjs +74 -89
- package/dist/db/engineDrizzleSchema.cjs +53 -0
- package/dist/db/engineDrizzleSchema.mjs +53 -0
- package/dist/db/enginePrismaSchema.cjs +84 -0
- package/dist/db/enginePrismaSchema.d.cts +5 -0
- package/dist/db/enginePrismaSchema.d.mts +5 -0
- package/dist/db/enginePrismaSchema.mjs +83 -0
- package/dist/db/releaseCatalog.cjs +24 -47
- package/dist/db/releaseCatalog.mjs +20 -44
- package/dist/db/updateArtifacts.cjs +43 -72
- package/dist/db/updateArtifacts.mjs +40 -69
- package/dist/handler.cjs +59 -43
- package/dist/handler.d.cts +3 -5
- package/dist/handler.d.mts +3 -5
- package/dist/handler.mjs +61 -43
- package/dist/handlerAdminRoutes.cjs +374 -0
- package/dist/handlerAdminRoutes.mjs +372 -0
- package/dist/handlerParameters.cjs +6 -11
- package/dist/handlerParameters.mjs +6 -10
- package/dist/handlerReleaseCatalogRoutes.cjs +32 -15
- package/dist/handlerReleaseCatalogRoutes.mjs +32 -15
- package/dist/handlerTypes.d.cts +2 -55
- package/dist/handlerTypes.d.mts +2 -55
- package/dist/handlerVersionRoutes.cjs +20 -4
- package/dist/handlerVersionRoutes.mjs +20 -4
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +8 -9
- package/dist/index.mjs +3 -4
- package/dist/node.cjs +3 -6
- package/dist/node.d.cts +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +4 -4
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/api-keys/index.cjs +9 -0
- package/dist/plugins/api-keys/index.d.cts +1 -0
- package/dist/plugins/api-keys/index.d.mts +1 -0
- package/dist/plugins/api-keys/index.mjs +2 -0
- package/dist/plugins/definePlugin.d.cts +2 -0
- package/dist/plugins/definePlugin.d.mts +2 -0
- package/dist/plugins/insights/index.cjs +9 -0
- package/dist/plugins/insights/index.d.cts +1 -0
- package/dist/plugins/insights/index.d.mts +1 -0
- package/dist/plugins/insights/index.mjs +2 -0
- package/dist/plugins/official.cjs +30 -0
- package/dist/plugins/official.mjs +29 -0
- package/dist/storageAccess.cjs +13 -10
- package/dist/storageAccess.mjs +13 -10
- package/dist/types/index.d.cts +2 -28
- package/dist/types/index.d.mts +2 -28
- package/package.json +26 -14
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
- package/dist/adapters/databaseConstraintErrors.cjs +0 -22
- package/dist/adapters/databaseConstraintErrors.mjs +0 -21
- package/dist/adapters/databasePluginUtils.cjs +0 -116
- package/dist/adapters/databasePluginUtils.mjs +0 -106
- package/dist/adapters/drizzleCrud.cjs +0 -311
- package/dist/adapters/drizzleCrud.mjs +0 -308
- package/dist/adapters/drizzleLazyDB.cjs +0 -106
- package/dist/adapters/drizzleLazyDB.mjs +0 -106
- package/dist/adapters/drizzleQuery.cjs +0 -69
- package/dist/adapters/drizzleQuery.mjs +0 -69
- package/dist/adapters/insightsTransaction.cjs +0 -22
- package/dist/adapters/insightsTransaction.mjs +0 -22
- package/dist/adapters/kyselyCrud.cjs +0 -305
- package/dist/adapters/kyselyCrud.mjs +0 -304
- package/dist/adapters/kyselyQuery.cjs +0 -56
- package/dist/adapters/kyselyQuery.mjs +0 -56
- package/dist/adapters/mongodbCollections.cjs +0 -38
- package/dist/adapters/mongodbCollections.mjs +0 -32
- package/dist/adapters/mongodbQuery.cjs +0 -94
- package/dist/adapters/mongodbQuery.mjs +0 -86
- package/dist/adapters/mongodbReads.cjs +0 -210
- package/dist/adapters/mongodbReads.mjs +0 -210
- package/dist/adapters/mongodbWrites.cjs +0 -148
- package/dist/adapters/mongodbWrites.mjs +0 -148
- package/dist/adapters/prismaQuery.cjs +0 -57
- package/dist/adapters/prismaQuery.mjs +0 -56
- package/dist/adapters/prismaRows.cjs +0 -219
- package/dist/adapters/prismaRows.mjs +0 -209
- package/dist/apiKeys.cjs +0 -143
- package/dist/apiKeys.d.cts +0 -49
- package/dist/apiKeys.d.mts +0 -49
- package/dist/apiKeys.mjs +0 -133
- package/dist/db/createBundleDiff.cjs +0 -144
- package/dist/db/createBundleDiff.d.cts +0 -16
- package/dist/db/createBundleDiff.d.mts +0 -16
- package/dist/db/createBundleDiff.mjs +0 -141
- package/dist/db/databasePluginCore.cjs +0 -137
- package/dist/db/databasePluginCore.mjs +0 -137
- package/dist/db/fixedMigrator.cjs +0 -79
- package/dist/db/fixedMigrator.mjs +0 -78
- package/dist/db/fixedMigratorMongo.cjs +0 -321
- package/dist/db/fixedMigratorMongo.mjs +0 -321
- package/dist/db/fixedMigratorShared.cjs +0 -23
- package/dist/db/fixedMigratorShared.mjs +0 -18
- package/dist/db/index.cjs +0 -27
- package/dist/db/index.d.cts +0 -12
- package/dist/db/index.d.mts +0 -12
- package/dist/db/index.mjs +0 -22
- package/dist/db/mongoMigrationExecution.cjs +0 -11
- package/dist/db/mongoMigrationExecution.mjs +0 -11
- package/dist/db/releaseCatalog.d.cts +0 -16
- package/dist/db/releaseCatalog.d.mts +0 -16
- package/dist/db/schema/insightsCollation.cjs +0 -14
- package/dist/db/schema/insightsCollation.mjs +0 -14
- package/dist/db/schema/mongodb.cjs +0 -25
- package/dist/db/schema/mongodb.mjs +0 -25
- package/dist/db/schema/registry.cjs +0 -21
- package/dist/db/schema/registry.mjs +0 -17
- package/dist/db/schema/sql.cjs +0 -105
- package/dist/db/schema/sql.mjs +0 -97
- package/dist/db/schema/sqlOperations.cjs +0 -27
- package/dist/db/schema/sqlOperations.mjs +0 -26
- package/dist/db/schemaGenerators.cjs +0 -275
- package/dist/db/schemaGenerators.mjs +0 -273
- package/dist/db/schemaReadiness.cjs +0 -26
- package/dist/db/schemaReadiness.d.cts +0 -9
- package/dist/db/schemaReadiness.d.mts +0 -9
- package/dist/db/schemaReadiness.mjs +0 -25
- package/dist/db/sqlMigrationExecution.cjs +0 -67
- package/dist/db/sqlMigrationExecution.mjs +0 -67
- package/dist/db/types.cjs +0 -22
- package/dist/db/types.d.cts +0 -118
- package/dist/db/types.d.mts +0 -118
- package/dist/db/types.mjs +0 -19
- package/dist/handlerBundleRoutes.cjs +0 -155
- package/dist/handlerBundleRoutes.mjs +0 -155
- package/dist/handlerReleaseManagementRoutes.cjs +0 -124
- package/dist/handlerReleaseManagementRoutes.mjs +0 -124
- package/dist/insights/domain.d.cts +0 -89
- package/dist/insights/domain.d.mts +0 -89
- package/dist/insights/errors.cjs +0 -15
- package/dist/insights/errors.mjs +0 -14
- package/dist/insights/eventInput.cjs +0 -155
- package/dist/insights/eventInput.mjs +0 -153
- package/dist/insights/provider.cjs +0 -314
- package/dist/insights/provider.d.cts +0 -6
- package/dist/insights/provider.d.mts +0 -6
- package/dist/insights/provider.mjs +0 -314
- package/dist/insights/queryInput.cjs +0 -93
- package/dist/insights/queryInput.mjs +0 -91
- package/dist/insights/routes.cjs +0 -58
- package/dist/insights/routes.mjs +0 -56
- package/dist/insights/types.d.cts +0 -32
- package/dist/insights/types.d.mts +0 -32
- package/dist/schema/dsl.cjs +0 -103
- package/dist/schema/dsl.mjs +0 -87
- package/dist/schema/index.cjs +0 -20
- package/dist/schema/index.mjs +0 -7
- package/dist/schema/settings.cjs +0 -9
- package/dist/schema/settings.mjs +0 -9
- package/dist/schema/types.cjs +0 -8
- package/dist/schema/types.mjs +0 -6
- package/dist/schema/v1_0_0.cjs +0 -406
- package/dist/schema/v1_0_0.mjs +0 -398
- package/src/adapters/databaseConstraintErrors.ts +0 -25
- package/src/adapters/databasePluginTestDatabase.ts +0 -120
- package/src/adapters/databasePluginUtils.spec.ts +0 -29
- package/src/adapters/databasePluginUtils.ts +0 -214
- package/src/adapters/drizzle.spec.ts +0 -336
- package/src/adapters/drizzle.ts +0 -162
- package/src/adapters/drizzleCrud.ts +0 -571
- package/src/adapters/drizzleLazyDB.ts +0 -271
- package/src/adapters/drizzleQuery.ts +0 -164
- package/src/adapters/insightsTransaction.ts +0 -32
- package/src/adapters/kysely.spec.ts +0 -174
- package/src/adapters/kysely.ts +0 -110
- package/src/adapters/kyselyCrud.ts +0 -709
- package/src/adapters/kyselyQuery.ts +0 -128
- package/src/adapters/mongodb.integration.spec.ts +0 -210
- package/src/adapters/mongodb.spec.ts +0 -209
- package/src/adapters/mongodb.ts +0 -138
- package/src/adapters/mongodbCollections.ts +0 -67
- package/src/adapters/mongodbQuery.ts +0 -255
- package/src/adapters/mongodbReads.ts +0 -380
- package/src/adapters/mongodbRows.spec.ts +0 -64
- package/src/adapters/mongodbRows.ts +0 -118
- package/src/adapters/mongodbTestClient.ts +0 -377
- package/src/adapters/mongodbTestFilter.ts +0 -169
- package/src/adapters/mongodbWrites.ts +0 -287
- package/src/adapters/prisma.spec.ts +0 -293
- package/src/adapters/prisma.ts +0 -565
- package/src/adapters/prismaQuery.ts +0 -129
- package/src/adapters/prismaRows.spec.ts +0 -98
- package/src/adapters/prismaRows.ts +0 -337
- package/src/adapters/prismaTestClient.ts +0 -413
- package/src/apiKeys.integration.spec.ts +0 -192
- package/src/apiKeys.spec.ts +0 -162
- package/src/apiKeys.ts +0 -220
- package/src/calculatePagination.ts +0 -34
- package/src/createHotUpdaterCore.ts +0 -246
- package/src/db/bundleRows.spec.ts +0 -164
- package/src/db/bundleRows.ts +0 -10
- package/src/db/createBundleDiff.spec.ts +0 -450
- package/src/db/createBundleDiff.ts +0 -364
- package/src/db/databasePluginCore.spec.ts +0 -62
- package/src/db/databasePluginCore.testFixtures.ts +0 -76
- package/src/db/databasePluginCore.ts +0 -185
- package/src/db/databasePluginUpdateCheck.bench.ts +0 -110
- package/src/db/fixedMigrator.spec.ts +0 -296
- package/src/db/fixedMigrator.ts +0 -147
- package/src/db/fixedMigratorMongo.spec.ts +0 -239
- package/src/db/fixedMigratorMongo.ts +0 -425
- package/src/db/fixedMigratorShared.ts +0 -36
- package/src/db/hotUpdaterSchema.ts +0 -5
- package/src/db/index.spec.ts +0 -1269
- package/src/db/index.ts +0 -47
- package/src/db/mongoMigrationExecution.ts +0 -23
- package/src/db/node-sqlite.d.ts +0 -25
- package/src/db/releaseCatalog.ts +0 -148
- package/src/db/schema/definitions.ts +0 -1
- package/src/db/schema/insightsCollation.ts +0 -21
- package/src/db/schema/mongodb.ts +0 -40
- package/src/db/schema/registry.ts +0 -55
- package/src/db/schema/sql.ts +0 -244
- package/src/db/schema/sqlOperations.ts +0 -63
- package/src/db/schema/types.ts +0 -1
- package/src/db/schemaGenerators.ts +0 -494
- package/src/db/schemaReadiness.ts +0 -34
- package/src/db/sqlMigrationExecution.spec.ts +0 -65
- package/src/db/sqlMigrationExecution.ts +0 -108
- package/src/db/types.spec.ts +0 -63
- package/src/db/types.ts +0 -228
- package/src/db/updateArtifacts.spec.ts +0 -359
- package/src/db/updateArtifacts.ts +0 -541
- package/src/handler-standalone.integration.spec.ts +0 -528
- package/src/handler.spec.ts +0 -190
- package/src/handler.testFixtures.ts +0 -30
- package/src/handler.ts +0 -245
- package/src/handlerAuth.integration.spec.ts +0 -33
- package/src/handlerBundleRoutes.ts +0 -259
- package/src/handlerErrors.ts +0 -7
- package/src/handlerManagement.spec.ts +0 -262
- package/src/handlerParameters.ts +0 -105
- package/src/handlerReleaseCatalogRoutes.ts +0 -154
- package/src/handlerReleaseManagementRoutes.ts +0 -213
- package/src/handlerTypes.ts +0 -96
- package/src/handlerVersionRoutes.ts +0 -12
- package/src/index.ts +0 -30
- package/src/insights/domain.ts +0 -103
- package/src/insights/errors.ts +0 -11
- package/src/insights/eventInput.ts +0 -225
- package/src/insights/insights.integration.spec.ts +0 -381
- package/src/insights/provider.spec.ts +0 -385
- package/src/insights/provider.ts +0 -591
- package/src/insights/queryInput.ts +0 -141
- package/src/insights/routes.ts +0 -104
- package/src/insights/types.ts +0 -55
- package/src/internalRouter.ts +0 -104
- package/src/node.spec.ts +0 -119
- package/src/node.ts +0 -111
- package/src/releaseCatalogRoutes.integration.spec.ts +0 -238
- package/src/runtime.spec.ts +0 -194
- package/src/runtime.testFixtures.ts +0 -71
- package/src/schema/dsl-all-versions.spec.ts +0 -37
- package/src/schema/dsl.ts +0 -187
- package/src/schema/index.ts +0 -10
- package/src/schema/settings.ts +0 -15
- package/src/schema/types.ts +0 -79
- package/src/schema/v1_0_0.spec.ts +0 -220
- package/src/schema/v1_0_0.ts +0 -529
- package/src/storageAccess.spec.ts +0 -152
- package/src/storageAccess.ts +0 -141
- package/src/types/index.ts +0 -34
- package/src/version.ts +0 -3
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import type { Bundle } from "@hot-updater/core";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
BundleRowHydrationError,
|
|
6
|
-
bundleToPatchRows,
|
|
7
|
-
bundleToRow,
|
|
8
|
-
rowsToBundles,
|
|
9
|
-
type BundlePatchRow,
|
|
10
|
-
type BundleRow,
|
|
11
|
-
} from "./bundleRows";
|
|
12
|
-
|
|
13
|
-
const createBundle = (id: string): Bundle => ({
|
|
14
|
-
id,
|
|
15
|
-
platform: "ios",
|
|
16
|
-
fileHash: `hash-${id}`,
|
|
17
|
-
gitCommitHash: null,
|
|
18
|
-
storageUri: `s3://bucket/${id}.zip`,
|
|
19
|
-
archiveByteSize: 3_000_000_001,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const toRow = (bundle: Bundle): BundleRow => bundleToRow(bundle);
|
|
23
|
-
|
|
24
|
-
const createPatchRow = (
|
|
25
|
-
id: string,
|
|
26
|
-
bundleId: string,
|
|
27
|
-
baseBundleId: string,
|
|
28
|
-
orderIndex: number,
|
|
29
|
-
): BundlePatchRow => ({
|
|
30
|
-
id,
|
|
31
|
-
bundle_id: bundleId,
|
|
32
|
-
base_bundle_id: baseBundleId,
|
|
33
|
-
base_file_hash: `base-hash-${id}`,
|
|
34
|
-
patch_file_hash: `patch-hash-${id}`,
|
|
35
|
-
patch_storage_uri: `s3://bucket/${id}.patch`,
|
|
36
|
-
byte_size: 3_000_000_002,
|
|
37
|
-
order_index: orderIndex,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("bundle row conversion", () => {
|
|
41
|
-
it("round-trips bundle fields without embedding patch artifacts in the bundle row", () => {
|
|
42
|
-
const baseBundle = createBundle("base");
|
|
43
|
-
const bundle: Bundle = {
|
|
44
|
-
...createBundle("target"),
|
|
45
|
-
metadata: { app_version: "1.0.0" },
|
|
46
|
-
manifestStorageUri: "s3://bucket/manifest.json",
|
|
47
|
-
manifestFileHash: "manifest-hash",
|
|
48
|
-
assetBaseStorageUri: "s3://bucket/assets",
|
|
49
|
-
patches: [
|
|
50
|
-
{
|
|
51
|
-
baseBundleId: baseBundle.id,
|
|
52
|
-
baseFileHash: "base-hash",
|
|
53
|
-
byteSize: 3_000_000_002,
|
|
54
|
-
patchFileHash: "patch-hash",
|
|
55
|
-
patchStorageUri: "s3://bucket/target.patch",
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const row = toRow(bundle);
|
|
61
|
-
const patchRows = bundleToPatchRows(bundle);
|
|
62
|
-
const hydratedBundles = rowsToBundles([row], patchRows, [
|
|
63
|
-
toRow(baseBundle),
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
expect(row).not.toHaveProperty("patches");
|
|
67
|
-
expect(row).not.toHaveProperty("patch_file_hash");
|
|
68
|
-
expect(row).not.toHaveProperty("channel");
|
|
69
|
-
expect(row).not.toHaveProperty("enabled");
|
|
70
|
-
expect(hydratedBundles).toHaveLength(1);
|
|
71
|
-
expect(hydratedBundles[0]).toEqual(bundle);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("orders multiple patches deterministically", () => {
|
|
75
|
-
const oldest = createBundle("oldest");
|
|
76
|
-
const newest = createBundle("newest");
|
|
77
|
-
const target = createBundle("target");
|
|
78
|
-
const rows: readonly BundleRow[] = [toRow(target)];
|
|
79
|
-
const later = createPatchRow("later", target.id, newest.id, 1);
|
|
80
|
-
const firstById = createPatchRow("a-first", target.id, oldest.id, 0);
|
|
81
|
-
const secondById = createPatchRow("z-second", target.id, newest.id, 0);
|
|
82
|
-
|
|
83
|
-
const [hydrated] = rowsToBundles(
|
|
84
|
-
rows,
|
|
85
|
-
[later, secondById, firstById],
|
|
86
|
-
[toRow(oldest), toRow(newest)],
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
expect(hydrated?.patches?.map((patch) => patch.patchFileHash)).toEqual([
|
|
90
|
-
firstById.patch_file_hash,
|
|
91
|
-
secondById.patch_file_hash,
|
|
92
|
-
later.patch_file_hash,
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("hydrates an empty patch set", () => {
|
|
97
|
-
const bundle = createBundle("without-patches");
|
|
98
|
-
|
|
99
|
-
const [hydrated] = rowsToBundles([toRow(bundle)], [], []);
|
|
100
|
-
|
|
101
|
-
expect(hydrated).toMatchObject({ patches: [] });
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("preserves nested metadata at the row boundary", () => {
|
|
105
|
-
const row: BundleRow = {
|
|
106
|
-
...toRow(createBundle("nested-metadata")),
|
|
107
|
-
metadata: { release: { flags: [true, null, 3] } },
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const [hydrated] = rowsToBundles([row], [], []);
|
|
111
|
-
|
|
112
|
-
expect(hydrated).toMatchObject({
|
|
113
|
-
metadata: { release: { flags: [true, null, 3] } },
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("rejects duplicate patch ids during aggregate hydration", () => {
|
|
118
|
-
const base = createBundle("base");
|
|
119
|
-
const target = createBundle("target");
|
|
120
|
-
const patch = createPatchRow("duplicate", target.id, base.id, 0);
|
|
121
|
-
const duplicate = { ...patch, base_file_hash: "different-hash" };
|
|
122
|
-
|
|
123
|
-
const hydrate = () =>
|
|
124
|
-
rowsToBundles([toRow(target)], [patch, duplicate], [toRow(base)]);
|
|
125
|
-
|
|
126
|
-
expect(hydrate).toThrowError(BundleRowHydrationError);
|
|
127
|
-
expect(hydrate).toThrowError(
|
|
128
|
-
expect.objectContaining({
|
|
129
|
-
reason: "duplicate_patch_id",
|
|
130
|
-
patchId: patch.id,
|
|
131
|
-
}),
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("rejects a patch whose owner bundle row is absent", () => {
|
|
136
|
-
const base = createBundle("base");
|
|
137
|
-
const patch = createPatchRow("orphan-owner", "missing", base.id, 0);
|
|
138
|
-
|
|
139
|
-
const hydrate = () => rowsToBundles([], [patch], [toRow(base)]);
|
|
140
|
-
|
|
141
|
-
expect(hydrate).toThrowError(
|
|
142
|
-
expect.objectContaining({
|
|
143
|
-
reason: "orphan_patch_owner",
|
|
144
|
-
patchId: patch.id,
|
|
145
|
-
bundleId: patch.bundle_id,
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("rejects a patch whose base bundle row is absent", () => {
|
|
151
|
-
const target = createBundle("target");
|
|
152
|
-
const patch = createPatchRow("orphan-base", target.id, "missing", 0);
|
|
153
|
-
|
|
154
|
-
const hydrate = () => rowsToBundles([toRow(target)], [patch], []);
|
|
155
|
-
|
|
156
|
-
expect(hydrate).toThrowError(
|
|
157
|
-
expect.objectContaining({
|
|
158
|
-
reason: "orphan_patch_base",
|
|
159
|
-
patchId: patch.id,
|
|
160
|
-
bundleId: patch.base_bundle_id,
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
});
|
package/src/db/bundleRows.ts
DELETED
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
import { brotliCompressSync } from "node:zlib";
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
Bundle,
|
|
5
|
-
DatabasePlugin,
|
|
6
|
-
StoragePlugin,
|
|
7
|
-
StoragePluginWith,
|
|
8
|
-
} from "@hot-updater/plugin-core";
|
|
9
|
-
import {
|
|
10
|
-
createDatabaseClient,
|
|
11
|
-
createStoragePlugin as createCoreStoragePlugin,
|
|
12
|
-
} from "@hot-updater/plugin-core";
|
|
13
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
14
|
-
|
|
15
|
-
import { createInMemoryDatabasePlugin } from "../../../test-utils/test/inMemoryDatabasePlugin";
|
|
16
|
-
|
|
17
|
-
vi.mock("@hot-updater/bsdiff", () => ({
|
|
18
|
-
hdiff: vi.fn(async () => new Uint8Array([1, 2, 3, 4])),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
import { createBundleDiff } from "./createBundleDiff";
|
|
22
|
-
|
|
23
|
-
const createBundle = (id: string, overrides: Partial<Bundle> = {}): Bundle => ({
|
|
24
|
-
archiveByteSize: 1_024,
|
|
25
|
-
fileHash: `${id}-file-hash`,
|
|
26
|
-
gitCommitHash: null,
|
|
27
|
-
id,
|
|
28
|
-
assetBaseStorageUri: "s3://test-bucket/releases/assets",
|
|
29
|
-
manifestStorageUri: `s3://test-bucket/releases/bundles/${id}/manifest.json`,
|
|
30
|
-
metadata: {},
|
|
31
|
-
platform: "ios",
|
|
32
|
-
storageUri: `s3://test-bucket/releases/bundles/${id}/bundle.zip`,
|
|
33
|
-
...overrides,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const createDatabasePlugin = async (
|
|
37
|
-
bundles: readonly Bundle[],
|
|
38
|
-
): Promise<DatabasePlugin> => {
|
|
39
|
-
const plugin = createInMemoryDatabasePlugin();
|
|
40
|
-
const client = createDatabaseClient(plugin);
|
|
41
|
-
for (const bundle of bundles) await client.insertBundle(bundle);
|
|
42
|
-
return plugin;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createStoragePlugin = (
|
|
46
|
-
put: NonNullable<StoragePlugin["put"]>,
|
|
47
|
-
options: {
|
|
48
|
-
get?: NonNullable<StoragePlugin["get"]>;
|
|
49
|
-
protocol?: string;
|
|
50
|
-
} = {},
|
|
51
|
-
): StoragePluginWith<"get" | "put" | "delete"> =>
|
|
52
|
-
createCoreStoragePlugin({
|
|
53
|
-
name: "mockStorage",
|
|
54
|
-
protocol: options.protocol ?? "s3",
|
|
55
|
-
async delete({ storageUri }) {
|
|
56
|
-
void storageUri;
|
|
57
|
-
return { deleted: true };
|
|
58
|
-
},
|
|
59
|
-
get:
|
|
60
|
-
options.get ??
|
|
61
|
-
(async ({ storageUri }) => {
|
|
62
|
-
const storageUrl = new URL(storageUri);
|
|
63
|
-
const response = await fetch(
|
|
64
|
-
`https://assets.example.com${storageUrl.pathname}`,
|
|
65
|
-
);
|
|
66
|
-
return { response: response.ok ? response : null };
|
|
67
|
-
}),
|
|
68
|
-
put,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe("createBundleDiff", () => {
|
|
72
|
-
afterEach(() => {
|
|
73
|
-
vi.restoreAllMocks();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("uploads a Hermes patch and stores patch metadata on the target bundle", async () => {
|
|
77
|
-
const baseBundle = createBundle("00000000-0000-0000-0000-000000000001");
|
|
78
|
-
const targetBundle = createBundle("00000000-0000-0000-0000-000000000002");
|
|
79
|
-
const baseDownloadFileHash = "a".repeat(64);
|
|
80
|
-
const targetDownloadFileHash = "b".repeat(64);
|
|
81
|
-
const plugin = await createDatabasePlugin([baseBundle, targetBundle]);
|
|
82
|
-
const databasePlugin: DatabasePlugin = plugin;
|
|
83
|
-
const commit = vi.spyOn(databasePlugin, "commit");
|
|
84
|
-
const upload = vi.fn<NonNullable<StoragePlugin["put"]>>(
|
|
85
|
-
async ({ key, body, contentLength }) => {
|
|
86
|
-
const bytes = new Uint8Array(await new Response(body).arrayBuffer());
|
|
87
|
-
expect(bytes).toEqual(new Uint8Array([1, 2, 3, 4]));
|
|
88
|
-
expect(contentLength).toBe(bytes.byteLength);
|
|
89
|
-
return { storageUri: `s3://test-bucket/${key}` };
|
|
90
|
-
},
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
vi.stubGlobal(
|
|
94
|
-
"fetch",
|
|
95
|
-
vi.fn(async (input: Request | URL | string) => {
|
|
96
|
-
const url = String(input);
|
|
97
|
-
|
|
98
|
-
if (url.endsWith(`${baseBundle.id}/manifest.json`)) {
|
|
99
|
-
return new Response(
|
|
100
|
-
JSON.stringify({
|
|
101
|
-
assets: {
|
|
102
|
-
"index.ios.bundle": {
|
|
103
|
-
downloadByteSize: 7,
|
|
104
|
-
downloadFileHash: baseDownloadFileHash,
|
|
105
|
-
fileHash: "hash-old",
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
bundleId: baseBundle.id,
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (url.endsWith(`${targetBundle.id}/manifest.json`)) {
|
|
114
|
-
return new Response(
|
|
115
|
-
JSON.stringify({
|
|
116
|
-
assets: {
|
|
117
|
-
"index.ios.bundle": {
|
|
118
|
-
downloadByteSize: 7,
|
|
119
|
-
downloadFileHash: targetDownloadFileHash,
|
|
120
|
-
fileHash: "hash-new",
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
bundleId: targetBundle.id,
|
|
124
|
-
}),
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (url.endsWith(`/assets/sha256/aa/${baseDownloadFileHash}.br`)) {
|
|
129
|
-
return new Response(brotliCompressSync(new Uint8Array([1, 2, 3])));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (url.endsWith("/assets/sha256/ha/hash-old.bundle")) {
|
|
133
|
-
return new Response(new Uint8Array([1, 2, 3]));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (url.endsWith(`/assets/sha256/bb/${targetDownloadFileHash}.br`)) {
|
|
137
|
-
return new Response(brotliCompressSync(new Uint8Array([1, 9, 3])));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (url.endsWith("/assets/sha256/ha/hash-new.bundle")) {
|
|
141
|
-
return new Response(new Uint8Array([1, 9, 3]));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return new Response("not found", { status: 404 });
|
|
145
|
-
}),
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
const updatedBundle = await createBundleDiff(
|
|
150
|
-
{
|
|
151
|
-
baseBundleId: baseBundle.id,
|
|
152
|
-
bundleId: targetBundle.id,
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
databasePlugin,
|
|
156
|
-
storagePlugin: createStoragePlugin(upload),
|
|
157
|
-
},
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(upload).toHaveBeenCalledOnce();
|
|
161
|
-
expect(commit).toHaveBeenCalledOnce();
|
|
162
|
-
const [patch] = updatedBundle.patches ?? [];
|
|
163
|
-
expect(patch?.baseBundleId).toBe(baseBundle.id);
|
|
164
|
-
expect(patch?.baseFileHash).toBe("hash-old");
|
|
165
|
-
expect(patch?.byteSize).toBe(4);
|
|
166
|
-
expect(patch?.patchFileHash).toMatch(/[a-f0-9]{64}/);
|
|
167
|
-
expect(patch?.patchStorageUri).toContain(
|
|
168
|
-
`bundles/${targetBundle.id}/patches/${baseBundle.id}/${patch?.patchFileHash}/`,
|
|
169
|
-
);
|
|
170
|
-
expect(updatedBundle.patches).toEqual([
|
|
171
|
-
{
|
|
172
|
-
baseBundleId: baseBundle.id,
|
|
173
|
-
baseFileHash: "hash-old",
|
|
174
|
-
byteSize: 4,
|
|
175
|
-
patchFileHash: patch?.patchFileHash,
|
|
176
|
-
patchStorageUri: patch?.patchStorageUri,
|
|
177
|
-
},
|
|
178
|
-
]);
|
|
179
|
-
} finally {
|
|
180
|
-
vi.unstubAllGlobals();
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("rejects ambiguous Hermes bundle assets in manifests", async () => {
|
|
185
|
-
const baseBundle = createBundle("00000000-0000-0000-0000-000000000001");
|
|
186
|
-
const targetBundle = createBundle("00000000-0000-0000-0000-000000000002");
|
|
187
|
-
const databasePlugin = await createDatabasePlugin([
|
|
188
|
-
baseBundle,
|
|
189
|
-
targetBundle,
|
|
190
|
-
]);
|
|
191
|
-
const upload = vi.fn<NonNullable<StoragePlugin["put"]>>(
|
|
192
|
-
async ({ key }) => ({
|
|
193
|
-
storageUri: `s3://test-bucket/${key}`,
|
|
194
|
-
}),
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
vi.stubGlobal(
|
|
198
|
-
"fetch",
|
|
199
|
-
vi.fn(async (input: Request | URL | string) => {
|
|
200
|
-
const url = String(input);
|
|
201
|
-
|
|
202
|
-
if (url.endsWith(`${baseBundle.id}/manifest.json`)) {
|
|
203
|
-
return new Response(
|
|
204
|
-
JSON.stringify({
|
|
205
|
-
assets: {
|
|
206
|
-
"index.ios.bundle": {
|
|
207
|
-
fileHash: "hash-old",
|
|
208
|
-
},
|
|
209
|
-
"secondary.ios.bundle": {
|
|
210
|
-
fileHash: "hash-secondary-old",
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
bundleId: baseBundle.id,
|
|
214
|
-
}),
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (url.endsWith(`${targetBundle.id}/manifest.json`)) {
|
|
219
|
-
return new Response(
|
|
220
|
-
JSON.stringify({
|
|
221
|
-
assets: {
|
|
222
|
-
"index.ios.bundle": {
|
|
223
|
-
fileHash: "hash-new",
|
|
224
|
-
},
|
|
225
|
-
"secondary.ios.bundle": {
|
|
226
|
-
fileHash: "hash-secondary-new",
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
bundleId: targetBundle.id,
|
|
230
|
-
}),
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return new Response("not found", { status: 404 });
|
|
235
|
-
}),
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
await expect(
|
|
240
|
-
createBundleDiff(
|
|
241
|
-
{
|
|
242
|
-
baseBundleId: baseBundle.id,
|
|
243
|
-
bundleId: targetBundle.id,
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
databasePlugin,
|
|
247
|
-
storagePlugin: createStoragePlugin(upload),
|
|
248
|
-
},
|
|
249
|
-
),
|
|
250
|
-
).rejects.toThrow("Expected exactly one Hermes bundle asset in manifest");
|
|
251
|
-
expect(upload).not.toHaveBeenCalled();
|
|
252
|
-
} finally {
|
|
253
|
-
vi.unstubAllGlobals();
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it("uses a matching HTTPS storage plugin before direct fetch", async () => {
|
|
258
|
-
const baseBundle = createBundle("00000000-0000-0000-0000-000000000001", {
|
|
259
|
-
assetBaseStorageUri: "https://storage.example.com/releases/assets",
|
|
260
|
-
manifestStorageUri:
|
|
261
|
-
"https://storage.example.com/releases/base/manifest.json",
|
|
262
|
-
});
|
|
263
|
-
const targetBundle = createBundle("00000000-0000-0000-0000-000000000002", {
|
|
264
|
-
assetBaseStorageUri: "https://storage.example.com/releases/assets",
|
|
265
|
-
manifestStorageUri:
|
|
266
|
-
"https://storage.example.com/releases/target/manifest.json",
|
|
267
|
-
});
|
|
268
|
-
const databasePlugin = await createDatabasePlugin([
|
|
269
|
-
baseBundle,
|
|
270
|
-
targetBundle,
|
|
271
|
-
]);
|
|
272
|
-
const responses = new Map<string, string | Uint8Array>([
|
|
273
|
-
[
|
|
274
|
-
baseBundle.manifestStorageUri!,
|
|
275
|
-
JSON.stringify({
|
|
276
|
-
assets: { "index.ios.bundle": { fileHash: "hash-old" } },
|
|
277
|
-
bundleId: baseBundle.id,
|
|
278
|
-
}),
|
|
279
|
-
],
|
|
280
|
-
[
|
|
281
|
-
targetBundle.manifestStorageUri!,
|
|
282
|
-
JSON.stringify({
|
|
283
|
-
assets: { "index.ios.bundle": { fileHash: "hash-new" } },
|
|
284
|
-
bundleId: targetBundle.id,
|
|
285
|
-
}),
|
|
286
|
-
],
|
|
287
|
-
[
|
|
288
|
-
`${baseBundle.assetBaseStorageUri}/sha256/ha/hash-old.bundle`,
|
|
289
|
-
new Uint8Array([1, 2, 3]),
|
|
290
|
-
],
|
|
291
|
-
[
|
|
292
|
-
`${targetBundle.assetBaseStorageUri}/sha256/ha/hash-new.bundle`,
|
|
293
|
-
new Uint8Array([1, 9, 3]),
|
|
294
|
-
],
|
|
295
|
-
]);
|
|
296
|
-
const get = vi.fn<NonNullable<StoragePlugin["get"]>>(
|
|
297
|
-
async ({ storageUri }) => ({
|
|
298
|
-
response: responses.has(storageUri)
|
|
299
|
-
? new Response(responses.get(storageUri))
|
|
300
|
-
: null,
|
|
301
|
-
}),
|
|
302
|
-
);
|
|
303
|
-
const directFetch = vi.fn<typeof fetch>();
|
|
304
|
-
vi.stubGlobal("fetch", directFetch);
|
|
305
|
-
const upload = vi.fn<NonNullable<StoragePlugin["put"]>>(
|
|
306
|
-
async ({ key }) => ({
|
|
307
|
-
storageUri: `https://storage.example.com/${key}`,
|
|
308
|
-
}),
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
try {
|
|
312
|
-
await createBundleDiff(
|
|
313
|
-
{ baseBundleId: baseBundle.id, bundleId: targetBundle.id },
|
|
314
|
-
{
|
|
315
|
-
databasePlugin,
|
|
316
|
-
storagePlugin: createStoragePlugin(upload, {
|
|
317
|
-
get,
|
|
318
|
-
protocol: "https",
|
|
319
|
-
}),
|
|
320
|
-
},
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
expect(get).toHaveBeenCalledWith({
|
|
324
|
-
storageUri: baseBundle.manifestStorageUri,
|
|
325
|
-
});
|
|
326
|
-
expect(get).toHaveBeenCalledWith({
|
|
327
|
-
storageUri: targetBundle.manifestStorageUri,
|
|
328
|
-
});
|
|
329
|
-
expect(directFetch).not.toHaveBeenCalled();
|
|
330
|
-
} finally {
|
|
331
|
-
vi.unstubAllGlobals();
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it("appends additional patch bases without replacing the primary patch when requested", async () => {
|
|
336
|
-
const primaryBaseBundle = createBundle(
|
|
337
|
-
"00000000-0000-0000-0000-000000000001",
|
|
338
|
-
);
|
|
339
|
-
const secondaryBaseBundle = createBundle(
|
|
340
|
-
"00000000-0000-0000-0000-000000000002",
|
|
341
|
-
);
|
|
342
|
-
const targetBundle = createBundle("00000000-0000-0000-0000-000000000003", {
|
|
343
|
-
patches: [
|
|
344
|
-
{
|
|
345
|
-
baseBundleId: primaryBaseBundle.id,
|
|
346
|
-
baseFileHash: "hash-primary-old",
|
|
347
|
-
byteSize: 4,
|
|
348
|
-
patchFileHash: "hash-primary-patch",
|
|
349
|
-
patchStorageUri: `s3://test-bucket/${primaryBaseBundle.id}/existing.bsdiff`,
|
|
350
|
-
},
|
|
351
|
-
],
|
|
352
|
-
});
|
|
353
|
-
const databasePlugin = await createDatabasePlugin([
|
|
354
|
-
primaryBaseBundle,
|
|
355
|
-
secondaryBaseBundle,
|
|
356
|
-
targetBundle,
|
|
357
|
-
]);
|
|
358
|
-
const upload = vi.fn<NonNullable<StoragePlugin["put"]>>(
|
|
359
|
-
async ({ key }) => ({
|
|
360
|
-
storageUri: `s3://test-bucket/${key}`,
|
|
361
|
-
}),
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
vi.stubGlobal(
|
|
365
|
-
"fetch",
|
|
366
|
-
vi.fn(async (input: Request | URL | string) => {
|
|
367
|
-
const url = String(input);
|
|
368
|
-
|
|
369
|
-
if (url.endsWith(`${secondaryBaseBundle.id}/manifest.json`)) {
|
|
370
|
-
return new Response(
|
|
371
|
-
JSON.stringify({
|
|
372
|
-
assets: {
|
|
373
|
-
"index.ios.bundle": {
|
|
374
|
-
fileHash: "hash-secondary-old",
|
|
375
|
-
},
|
|
376
|
-
},
|
|
377
|
-
bundleId: secondaryBaseBundle.id,
|
|
378
|
-
}),
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (url.endsWith(`${targetBundle.id}/manifest.json`)) {
|
|
383
|
-
return new Response(
|
|
384
|
-
JSON.stringify({
|
|
385
|
-
assets: {
|
|
386
|
-
"index.ios.bundle": {
|
|
387
|
-
fileHash: "hash-target-new",
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
bundleId: targetBundle.id,
|
|
391
|
-
}),
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (url.endsWith("/assets/sha256/ha/hash-secondary-old.br")) {
|
|
396
|
-
return new Response(brotliCompressSync(new Uint8Array([1, 2, 3])));
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (url.endsWith("/assets/sha256/ha/hash-secondary-old.bundle")) {
|
|
400
|
-
return new Response(new Uint8Array([1, 2, 3]));
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (url.endsWith("/assets/sha256/ha/hash-target-new.br")) {
|
|
404
|
-
return new Response(brotliCompressSync(new Uint8Array([1, 4, 3])));
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (url.endsWith("/assets/sha256/ha/hash-target-new.bundle")) {
|
|
408
|
-
return new Response(new Uint8Array([1, 4, 3]));
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return new Response("not found", { status: 404 });
|
|
412
|
-
}),
|
|
413
|
-
);
|
|
414
|
-
|
|
415
|
-
try {
|
|
416
|
-
const updatedBundle = await createBundleDiff(
|
|
417
|
-
{
|
|
418
|
-
baseBundleId: secondaryBaseBundle.id,
|
|
419
|
-
bundleId: targetBundle.id,
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
databasePlugin,
|
|
423
|
-
storagePlugin: createStoragePlugin(upload),
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
makePrimary: false,
|
|
427
|
-
},
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
expect(updatedBundle.patches).toMatchObject([
|
|
431
|
-
{
|
|
432
|
-
baseBundleId: primaryBaseBundle.id,
|
|
433
|
-
baseFileHash: "hash-primary-old",
|
|
434
|
-
patchFileHash: "hash-primary-patch",
|
|
435
|
-
patchStorageUri: `s3://test-bucket/${primaryBaseBundle.id}/existing.bsdiff`,
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
baseBundleId: secondaryBaseBundle.id,
|
|
439
|
-
baseFileHash: "hash-secondary-old",
|
|
440
|
-
patchFileHash: expect.any(String),
|
|
441
|
-
patchStorageUri: expect.stringContaining(
|
|
442
|
-
`bundles/${targetBundle.id}/patches/${secondaryBaseBundle.id}`,
|
|
443
|
-
),
|
|
444
|
-
},
|
|
445
|
-
]);
|
|
446
|
-
} finally {
|
|
447
|
-
vi.unstubAllGlobals();
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
});
|