@hot-updater/plugin-core 1.0.0-rc.1 → 1.0.0-rc.15
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/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/assetStorageLayout.cjs +4 -2
- package/dist/assetStorageLayout.d.cts +5 -24
- package/dist/assetStorageLayout.d.mts +5 -24
- package/dist/assetStorageLayout.mjs +4 -2
- package/dist/bundleStorageLayout.cjs +7 -0
- package/dist/bundleStorageLayout.d.cts +5 -1
- package/dist/bundleStorageLayout.d.mts +5 -1
- package/dist/bundleStorageLayout.mjs +7 -1
- package/dist/calculatePagination.d.cts +0 -1
- package/dist/calculatePagination.d.mts +0 -1
- package/dist/contentAddressedAssets.d.cts +1 -4
- package/dist/contentAddressedAssets.d.mts +1 -4
- package/dist/contentType.cjs +9 -0
- package/dist/contentType.d.cts +4 -0
- package/dist/contentType.d.mts +4 -0
- package/dist/contentType.mjs +7 -0
- package/dist/createDatabasePlugin.cjs +118 -42
- package/dist/createDatabasePlugin.d.cts +3 -1
- package/dist/createDatabasePlugin.d.mts +3 -1
- package/dist/createDatabasePlugin.mjs +118 -43
- package/dist/createStoragePlugin.d.cts +0 -1
- package/dist/createStoragePlugin.d.mts +0 -1
- package/dist/databaseClient.cjs +6 -1
- package/dist/databaseClient.d.cts +1 -2
- package/dist/databaseClient.d.mts +1 -2
- package/dist/databaseClient.mjs +6 -2
- package/dist/databaseClientReads.cjs +3 -1
- package/dist/databaseClientReads.mjs +3 -2
- package/dist/databaseClientUpdates.cjs +2 -4
- package/dist/databaseClientUpdates.d.cts +1 -1
- package/dist/databaseClientUpdates.d.mts +1 -1
- package/dist/databaseClientUpdates.mjs +2 -3
- package/dist/databaseJsonValue.cjs +4 -0
- package/dist/databaseJsonValue.d.cts +4 -2
- package/dist/databaseJsonValue.d.mts +4 -2
- package/dist/databaseJsonValue.mjs +2 -1
- package/dist/databaseMetadata.cjs +0 -1
- package/dist/databasePluginCrud.cjs +1 -0
- package/dist/databasePluginCrud.d.cts +4 -1
- package/dist/databasePluginCrud.d.mts +4 -1
- package/dist/databasePluginCrud.mjs +1 -1
- package/dist/databasePluginCrudValidation.d.cts +6 -1
- package/dist/databasePluginCrudValidation.d.mts +6 -1
- package/dist/databasePluginCrudValidationErrors.cjs +1 -0
- package/dist/databasePluginCrudValidationErrors.mjs +1 -0
- package/dist/databasePluginCrudValidationFields.cjs +24 -31
- package/dist/databasePluginCrudValidationFields.d.cts +1 -1
- package/dist/databasePluginCrudValidationFields.d.mts +1 -1
- package/dist/databasePluginCrudValidationFields.mjs +23 -32
- package/dist/databasePluginCrudValidationMutations.cjs +1 -1
- package/dist/databasePluginCrudValidationMutations.d.cts +1 -1
- package/dist/databasePluginCrudValidationMutations.d.mts +1 -1
- package/dist/databasePluginCrudValidationMutations.mjs +1 -1
- package/dist/databasePluginCrudValidationQueries.d.cts +2 -1
- package/dist/databasePluginCrudValidationQueries.d.mts +2 -1
- package/dist/databasePluginCrudValidationRows.cjs +2 -2
- package/dist/databasePluginCrudValidationRows.d.cts +1 -1
- package/dist/databasePluginCrudValidationRows.d.mts +1 -1
- package/dist/databasePluginCrudValidationRows.mjs +2 -2
- package/dist/databaseRows.cjs +0 -7
- package/dist/databaseRows.d.cts +2 -6
- package/dist/databaseRows.d.mts +2 -6
- package/dist/databaseRows.mjs +0 -6
- package/dist/index.cjs +8 -6
- package/dist/index.d.cts +7 -6
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +5 -4
- package/dist/insightsContract.cjs +192 -0
- package/dist/insightsContract.d.cts +9 -0
- package/dist/insightsContract.d.mts +9 -0
- package/dist/insightsContract.mjs +189 -0
- package/dist/insightsDistinctSummary.cjs +72 -0
- package/dist/insightsDistinctSummary.d.cts +12 -0
- package/dist/insightsDistinctSummary.d.mts +12 -0
- package/dist/insightsDistinctSummary.mjs +68 -0
- package/dist/insightsLatestQueries.cjs +53 -0
- package/dist/insightsLatestQueries.d.cts +13 -0
- package/dist/insightsLatestQueries.d.mts +13 -0
- package/dist/insightsLatestQueries.mjs +52 -0
- package/dist/insightsOverview.cjs +139 -0
- package/dist/insightsOverview.d.cts +40 -0
- package/dist/insightsOverview.d.mts +40 -0
- package/dist/insightsOverview.mjs +135 -0
- package/dist/internal.cjs +15 -0
- package/dist/internal.d.cts +7 -3
- package/dist/internal.d.mts +7 -3
- package/dist/internal.mjs +4 -1
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.cjs +136 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs +116 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs +167 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs +165 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.cjs +42 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.mjs +39 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.cjs +39 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs +37 -0
- package/dist/paginateBundles.d.cts +1 -8
- package/dist/paginateBundles.d.mts +1 -8
- package/dist/parseStorageUri.d.cts +1 -5
- package/dist/parseStorageUri.d.mts +1 -5
- package/dist/queryBundles.d.cts +0 -1
- package/dist/queryBundles.d.mts +0 -1
- package/dist/releaseCatalogCompiler.cjs +15 -12
- package/dist/releaseCatalogCompiler.d.cts +0 -1
- package/dist/releaseCatalogCompiler.d.mts +0 -1
- package/dist/releaseCatalogCompiler.mjs +11 -7
- package/dist/releaseCatalogMutation.cjs +1 -1
- package/dist/releaseCatalogMutation.d.cts +1 -1
- package/dist/releaseCatalogMutation.d.mts +1 -1
- package/dist/releaseCatalogMutation.mjs +1 -0
- package/dist/releaseManagement.cjs +3 -2
- package/dist/releaseManagement.d.cts +1 -1
- package/dist/releaseManagement.d.mts +1 -1
- package/dist/releaseManagement.mjs +3 -1
- package/dist/remoteBundleSigning.cjs +4 -4
- package/dist/remoteBundleSigning.d.cts +2 -13
- package/dist/remoteBundleSigning.d.mts +2 -13
- package/dist/remoteBundleSigning.mjs +4 -4
- package/dist/requestBundleCache.d.cts +1 -2
- package/dist/requestBundleCache.d.mts +1 -2
- package/dist/semverSatisfies.cjs +4 -3
- package/dist/semverSatisfies.mjs +2 -1
- package/dist/storageDownloadPath.cjs +2 -1
- package/dist/storageDownloadPath.d.cts +1 -3
- package/dist/storageDownloadPath.d.mts +1 -3
- package/dist/storageDownloadPath.mjs +2 -1
- package/dist/types/database.d.cts +4 -3
- package/dist/types/database.d.mts +4 -3
- package/dist/types/databaseFields.cjs +1 -8
- package/dist/types/databaseFields.d.cts +2 -2
- package/dist/types/databaseFields.d.mts +2 -2
- package/dist/types/databaseFields.mjs +1 -8
- package/dist/types/databaseOperations.d.cts +17 -12
- package/dist/types/databaseOperations.d.mts +17 -12
- package/dist/types/databasePlugin.d.cts +159 -11
- package/dist/types/databasePlugin.d.mts +159 -11
- package/dist/types/databaseQuery.d.cts +2 -3
- package/dist/types/databaseQuery.d.mts +2 -3
- package/dist/types/databaseRows.d.cts +19 -17
- package/dist/types/databaseRows.d.mts +19 -17
- package/dist/types/index.d.cts +12 -20
- package/dist/types/index.d.mts +12 -20
- package/dist/types/internal.d.cts +4 -3
- package/dist/types/internal.d.mts +4 -3
- package/dist/types/public.d.cts +4 -3
- package/dist/types/public.d.mts +4 -3
- package/dist/types/utils.d.cts +1 -1
- package/dist/types/utils.d.mts +1 -1
- package/dist/uuidv7.cjs +7 -2
- package/dist/uuidv7.d.cts +0 -1
- package/dist/uuidv7.d.mts +0 -1
- package/dist/uuidv7.mjs +1 -1
- package/package.json +4 -4
- package/dist/compressionFormat.cjs +0 -55
- package/dist/compressionFormat.d.cts +0 -33
- package/dist/compressionFormat.d.mts +0 -33
- package/dist/compressionFormat.mjs +0 -51
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.cjs +0 -345
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.mjs +0 -341
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
2
|
-
import { ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, InsightsModel,
|
|
1
|
+
import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
2
|
+
import { ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseCatalogModel, ReleaseModel, ReleaseReference } from "./types/databasePlugin.cjs";
|
|
3
3
|
import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.cjs";
|
|
4
4
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.cjs";
|
|
5
5
|
import { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, Bundle, BundleSigningPlugin, ConfigInput, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, Platform, PlatformConfig, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePlugin, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.cjs";
|
|
6
6
|
import { PaginationOptions, calculatePagination } from "./calculatePagination.cjs";
|
|
7
|
-
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath } from "./bundleStorageLayout.cjs";
|
|
8
|
-
import { CompressionFormat, CompressionFormatInfo, detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.cjs";
|
|
7
|
+
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri } from "./bundleStorageLayout.cjs";
|
|
9
8
|
import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri } from "./assetStorageLayout.cjs";
|
|
10
9
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.cjs";
|
|
10
|
+
import { getContentType } from "./contentType.cjs";
|
|
11
11
|
import { DatabasePluginInputError, DatabasePluginInputErrorCode } from "./databasePluginCrudValidationErrors.cjs";
|
|
12
12
|
import { CreateDatabasePluginOptions, DatabaseAtomicCommitUnsupportedError, createDatabasePlugin } from "./createDatabasePlugin.cjs";
|
|
13
13
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
|
|
14
14
|
import { CreateStoragePluginOptions, StorageOperation, StoragePluginWith, assertStorageOperations, createStoragePlugin } from "./createStoragePlugin.cjs";
|
|
15
15
|
import { DatabasePatchUpdateUnsupportedError } from "./databaseClientUpdates.cjs";
|
|
16
16
|
import { DatabaseBundleNotFoundError, DatabaseClient, DatabaseMutationClient, DatabasePatchInsertUnsupportedError, createDatabaseClient } from "./databaseClient.cjs";
|
|
17
|
-
import { isDatabaseMetadataObject } from "./databaseJsonValue.cjs";
|
|
17
|
+
import { isDatabaseBundleEventMetadata, isDatabaseMetadataObject } from "./databaseJsonValue.cjs";
|
|
18
18
|
import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.cjs";
|
|
19
19
|
import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.cjs";
|
|
20
20
|
import { generateMinBundleId } from "./generateMinBundleId.cjs";
|
|
21
|
+
import { compareInsightsText, isInsightsMovementEvent } from "./insightsContract.cjs";
|
|
21
22
|
import { CreateStorageUriInput, ParsedStorageUri, createStorageUri, parseStorageUri } from "./parseStorageUri.cjs";
|
|
22
23
|
import { paginateBundles } from "./paginateBundles.cjs";
|
|
23
24
|
import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.cjs";
|
|
@@ -29,4 +30,4 @@ import { BundleSigningHandlerOptions, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BU
|
|
|
29
30
|
import { semverSatisfies } from "./semverSatisfies.cjs";
|
|
30
31
|
import { createStorageDownloadPath, createStorageDownloadUrl, parseStorageDownloadPath } from "./storageDownloadPath.cjs";
|
|
31
32
|
import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.cjs";
|
|
32
|
-
export { ApiKeyModel, ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, BundleEventRow, BundleEventRowBase, BundleModel, BundleModelQuery, BundlePatchModel, BundlePatchRow, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog,
|
|
33
|
+
export { type ApiKeyModel, type ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleEventRow, type BundleEventRowBase, type BundleModel, type BundleModelQuery, type BundlePatchModel, type BundlePatchRow, type BundleRepository, type BundleRepositoryChange, type BundleRepositoryCommit, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteInput, type ChannelDeleteResult, type ChannelInsertInput, type ChannelInsertResult, type ChannelModel, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type CreateDatabasePluginOptions, CreateStoragePluginOptions, CreateStorageUriInput, DatabaseAtomicCommitUnsupportedError, DatabaseBundleCursor, type DatabaseBundleEventMetadata, DatabaseBundleIdFilter, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, type DatabaseChange, DatabaseClient, type DatabaseCommit, type DatabaseCommitExpectation, type DatabaseCommitResult, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseModels, DatabaseMutationClient, DatabasePatchInsertUnsupportedError, DatabasePatchUpdateUnsupportedError, type DatabasePlugin, DatabasePluginInputError, type DatabasePluginInputErrorCode, FingerprintExtraSources, HasMultipleCallSignatures, type InsightsBundleEventFilter, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsListEventsInput, type InsightsModel, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseInput, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReleaseActivityMetrics, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, type ReleaseCatalogModel, ReleaseCatalogMutation, ReleaseCatalogMutationError, ReleaseCatalogMutationInput, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, ReleaseManagementError, type ReleaseModel, ReleaseMutationTarget, ReleasePolicyPatch, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, RemoteSigningOptions, RequiredDeep, RollbackReleaseInput, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, assertStorageOperations, bundleIdMatchesFilter, bundleMatchesQueryWhere, bundleToPatchRows, bundleToRow, calculatePagination, canonicalizeAppVersion, commitReleaseCatalogMutation, commitReleaseCatalogMutations, compareInsightsText, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createDatabaseClient, createDatabasePlugin, createRequestBundleResolver, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, deleteRelease, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBundleEventMetadata, isDatabaseMetadataObject, isInsightsMovementEvent, isUUIDv7, paginateBundles, parseStorageDownloadPath, parseStorageUri, preflightReleaseCatalogMutation, preflightReleaseCatalogRebuild, preflightReleasePolicy, projectCompiledCatalog, projectCompiledRollbackCatalog, promoteRelease, rebuildReleaseCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rollbackRelease, rollbackReleases, rowToBundle, rowsToBundles, semverSatisfies, sortBundles, supportedIosPlatforms, updateReleasePolicy };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
2
|
-
import { ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, InsightsModel,
|
|
1
|
+
import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
2
|
+
import { ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseCatalogModel, ReleaseModel, ReleaseReference } from "./types/databasePlugin.mjs";
|
|
3
3
|
import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.mjs";
|
|
4
4
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.mjs";
|
|
5
5
|
import { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, Bundle, BundleSigningPlugin, ConfigInput, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, Platform, PlatformConfig, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePlugin, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.mjs";
|
|
6
6
|
import { PaginationOptions, calculatePagination } from "./calculatePagination.mjs";
|
|
7
|
-
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath } from "./bundleStorageLayout.mjs";
|
|
8
|
-
import { CompressionFormat, CompressionFormatInfo, detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.mjs";
|
|
7
|
+
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri } from "./bundleStorageLayout.mjs";
|
|
9
8
|
import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri } from "./assetStorageLayout.mjs";
|
|
10
9
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.mjs";
|
|
10
|
+
import { getContentType } from "./contentType.mjs";
|
|
11
11
|
import { DatabasePluginInputError, DatabasePluginInputErrorCode } from "./databasePluginCrudValidationErrors.mjs";
|
|
12
12
|
import { CreateDatabasePluginOptions, DatabaseAtomicCommitUnsupportedError, createDatabasePlugin } from "./createDatabasePlugin.mjs";
|
|
13
13
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
|
|
14
14
|
import { CreateStoragePluginOptions, StorageOperation, StoragePluginWith, assertStorageOperations, createStoragePlugin } from "./createStoragePlugin.mjs";
|
|
15
15
|
import { DatabasePatchUpdateUnsupportedError } from "./databaseClientUpdates.mjs";
|
|
16
16
|
import { DatabaseBundleNotFoundError, DatabaseClient, DatabaseMutationClient, DatabasePatchInsertUnsupportedError, createDatabaseClient } from "./databaseClient.mjs";
|
|
17
|
-
import { isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
|
|
17
|
+
import { isDatabaseBundleEventMetadata, isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
|
|
18
18
|
import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.mjs";
|
|
19
19
|
import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.mjs";
|
|
20
20
|
import { generateMinBundleId } from "./generateMinBundleId.mjs";
|
|
21
|
+
import { compareInsightsText, isInsightsMovementEvent } from "./insightsContract.mjs";
|
|
21
22
|
import { CreateStorageUriInput, ParsedStorageUri, createStorageUri, parseStorageUri } from "./parseStorageUri.mjs";
|
|
22
23
|
import { paginateBundles } from "./paginateBundles.mjs";
|
|
23
24
|
import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.mjs";
|
|
@@ -29,4 +30,4 @@ import { BundleSigningHandlerOptions, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BU
|
|
|
29
30
|
import { semverSatisfies } from "./semverSatisfies.mjs";
|
|
30
31
|
import { createStorageDownloadPath, createStorageDownloadUrl, parseStorageDownloadPath } from "./storageDownloadPath.mjs";
|
|
31
32
|
import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.mjs";
|
|
32
|
-
export { ApiKeyModel, ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, BundleEventRow, BundleEventRowBase, BundleModel, BundleModelQuery, BundlePatchModel, BundlePatchRow, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog,
|
|
33
|
+
export { type ApiKeyModel, type ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleEventRow, type BundleEventRowBase, type BundleModel, type BundleModelQuery, type BundlePatchModel, type BundlePatchRow, type BundleRepository, type BundleRepositoryChange, type BundleRepositoryCommit, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteInput, type ChannelDeleteResult, type ChannelInsertInput, type ChannelInsertResult, type ChannelModel, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type CreateDatabasePluginOptions, CreateStoragePluginOptions, CreateStorageUriInput, DatabaseAtomicCommitUnsupportedError, DatabaseBundleCursor, type DatabaseBundleEventMetadata, DatabaseBundleIdFilter, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, type DatabaseChange, DatabaseClient, type DatabaseCommit, type DatabaseCommitExpectation, type DatabaseCommitResult, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseModels, DatabaseMutationClient, DatabasePatchInsertUnsupportedError, DatabasePatchUpdateUnsupportedError, type DatabasePlugin, DatabasePluginInputError, type DatabasePluginInputErrorCode, FingerprintExtraSources, HasMultipleCallSignatures, type InsightsBundleEventFilter, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsListEventsInput, type InsightsModel, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseInput, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReleaseActivityMetrics, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, type ReleaseCatalogModel, ReleaseCatalogMutation, ReleaseCatalogMutationError, ReleaseCatalogMutationInput, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, ReleaseManagementError, type ReleaseModel, ReleaseMutationTarget, ReleasePolicyPatch, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, RemoteSigningOptions, RequiredDeep, RollbackReleaseInput, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, assertStorageOperations, bundleIdMatchesFilter, bundleMatchesQueryWhere, bundleToPatchRows, bundleToRow, calculatePagination, canonicalizeAppVersion, commitReleaseCatalogMutation, commitReleaseCatalogMutations, compareInsightsText, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createDatabaseClient, createDatabasePlugin, createRequestBundleResolver, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, deleteRelease, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBundleEventMetadata, isDatabaseMetadataObject, isInsightsMovementEvent, isUUIDv7, paginateBundles, parseStorageDownloadPath, parseStorageUri, preflightReleaseCatalogMutation, preflightReleaseCatalogRebuild, preflightReleasePolicy, projectCompiledCatalog, projectCompiledRollbackCatalog, promoteRelease, rebuildReleaseCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rollbackRelease, rollbackReleases, rowToBundle, rowsToBundles, semverSatisfies, sortBundles, supportedIosPlatforms, updateReleasePolicy };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { calculatePagination } from "./calculatePagination.mjs";
|
|
2
|
-
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath } from "./bundleStorageLayout.mjs";
|
|
3
|
-
import { detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.mjs";
|
|
4
2
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.mjs";
|
|
5
3
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
|
|
6
4
|
import { createStorageUri, parseStorageUri } from "./parseStorageUri.mjs";
|
|
7
5
|
import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri } from "./assetStorageLayout.mjs";
|
|
6
|
+
import { BUNDLE_STORAGE_PREFIX, createBundleStorageKey, createStorageRootUriWithPath, getBundleArchiveStorageUri } from "./bundleStorageLayout.mjs";
|
|
7
|
+
import { getContentType } from "./contentType.mjs";
|
|
8
8
|
import { DatabasePluginInputError } from "./databasePluginCrudValidationErrors.mjs";
|
|
9
|
-
import { isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
|
|
9
|
+
import { isDatabaseBundleEventMetadata, isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
|
|
10
10
|
import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.mjs";
|
|
11
|
+
import { compareInsightsText, isInsightsMovementEvent } from "./insightsContract.mjs";
|
|
11
12
|
import { DatabaseAtomicCommitUnsupportedError, createDatabasePlugin } from "./createDatabasePlugin.mjs";
|
|
12
13
|
import { assertStorageOperations, createStoragePlugin } from "./createStoragePlugin.mjs";
|
|
13
14
|
import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.mjs";
|
|
@@ -25,4 +26,4 @@ import { ReleaseManagementError, deleteRelease, preflightReleasePolicy, promoteR
|
|
|
25
26
|
import { REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, createBundleSigningHandler, remoteSigning } from "./remoteBundleSigning.mjs";
|
|
26
27
|
import { createStorageDownloadPath, createStorageDownloadUrl, parseStorageDownloadPath } from "./storageDownloadPath.mjs";
|
|
27
28
|
import { supportedIosPlatforms } from "./types/index.mjs";
|
|
28
|
-
export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DatabaseAtomicCommitUnsupportedError, DatabaseBundleNotFoundError, DatabasePatchInsertUnsupportedError, DatabasePatchUpdateUnsupportedError, DatabasePluginInputError, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, assertStorageOperations, bundleIdMatchesFilter, bundleMatchesQueryWhere, bundleToPatchRows, bundleToRow, calculatePagination, canonicalizeAppVersion, commitReleaseCatalogMutation, commitReleaseCatalogMutations, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createDatabaseClient, createDatabasePlugin, createRequestBundleResolver, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, deleteRelease,
|
|
29
|
+
export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DatabaseAtomicCommitUnsupportedError, DatabaseBundleNotFoundError, DatabasePatchInsertUnsupportedError, DatabasePatchUpdateUnsupportedError, DatabasePluginInputError, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, assertStorageOperations, bundleIdMatchesFilter, bundleMatchesQueryWhere, bundleToPatchRows, bundleToRow, calculatePagination, canonicalizeAppVersion, commitReleaseCatalogMutation, commitReleaseCatalogMutations, compareInsightsText, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createDatabaseClient, createDatabasePlugin, createRequestBundleResolver, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, deleteRelease, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBundleEventMetadata, isDatabaseMetadataObject, isInsightsMovementEvent, isUUIDv7, paginateBundles, parseStorageDownloadPath, parseStorageUri, preflightReleaseCatalogMutation, preflightReleaseCatalogRebuild, preflightReleasePolicy, projectCompiledCatalog, projectCompiledRollbackCatalog, promoteRelease, rebuildReleaseCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rollbackRelease, rollbackReleases, rowToBundle, rowsToBundles, semverSatisfies, sortBundles, supportedIosPlatforms, updateReleasePolicy };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const require_databasePluginCrudValidationErrors = require("./databasePluginCrudValidationErrors.cjs");
|
|
2
|
+
const require_databasePluginCrudValidationFields = require("./databasePluginCrudValidationFields.cjs");
|
|
3
|
+
const require_databasePluginCrudValidationRows = require("./databasePluginCrudValidationRows.cjs");
|
|
4
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
5
|
+
//#region src/insightsContract.ts
|
|
6
|
+
const encoder = new TextEncoder();
|
|
7
|
+
/** Exact UTF-8 byte ordering, without case folding or Unicode normalization. */
|
|
8
|
+
const compareInsightsText = (left, right) => {
|
|
9
|
+
const a = encoder.encode(left);
|
|
10
|
+
const b = encoder.encode(right);
|
|
11
|
+
for (let index = 0; index < Math.min(a.length, b.length); index += 1) if (a[index] !== b[index]) return a[index] - b[index];
|
|
12
|
+
return a.length - b.length;
|
|
13
|
+
};
|
|
14
|
+
const isWellFormedText = (value) => {
|
|
15
|
+
for (const character of value) {
|
|
16
|
+
const point = character.codePointAt(0);
|
|
17
|
+
if (point >= 55296 && point <= 57343) return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
const isIdentity = (value) => typeof value === "string" && value.length > 0 && value.length <= 255 && isWellFormedText(value);
|
|
22
|
+
const isText = (value) => typeof value === "string" && value.length > 0 && isWellFormedText(value);
|
|
23
|
+
const isTimestamp = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
24
|
+
const isLimit = (value) => isTimestamp(value) && value >= 1 && value <= 101;
|
|
25
|
+
const hasOnlyKeys = (value, keys) => Object.keys(value).every((key) => keys.includes(key));
|
|
26
|
+
const hasScope = (value) => (value.platform === "ios" || value.platform === "android") && isText(value.channel);
|
|
27
|
+
const isBundleFilter = (value, withKind = false) => {
|
|
28
|
+
if (!require_databasePluginCrudValidationFields.isRecord(value) || !hasScope(value)) return false;
|
|
29
|
+
const keys = [
|
|
30
|
+
"platform",
|
|
31
|
+
"channel",
|
|
32
|
+
"type",
|
|
33
|
+
...withKind ? ["kind"] : []
|
|
34
|
+
];
|
|
35
|
+
return value.type === "RECOVERED" ? isText(value.fromBundleId) && hasOnlyKeys(value, [...keys, "fromBundleId"]) : (value.type === "UPDATE_DOWNLOADED" || value.type === "UPDATE_APPLIED" || value.type === "UNCHANGED") && isText(value.toBundleId) && hasOnlyKeys(value, [...keys, "toBundleId"]);
|
|
36
|
+
};
|
|
37
|
+
const isEventFilter = (value) => {
|
|
38
|
+
if (!require_databasePluginCrudValidationFields.isRecord(value)) return false;
|
|
39
|
+
if (value.kind === "all") return hasOnlyKeys(value, ["kind"]);
|
|
40
|
+
if (value.kind === "installationMovement") return isIdentity(value.installId) && hasOnlyKeys(value, ["kind", "installId"]);
|
|
41
|
+
return value.kind === "bundle" && isBundleFilter(value, true);
|
|
42
|
+
};
|
|
43
|
+
const validateRow = (model, row, result = false) => {
|
|
44
|
+
try {
|
|
45
|
+
require_databasePluginCrudValidationRows.validateCreateData(model, row);
|
|
46
|
+
if (!require_databasePluginCrudValidationFields.isRecord(row) || typeof row.id !== "string" || !(0, _hot_updater_core.isUUIDv7)(row.id) || [...Object.values(row), ...require_databasePluginCrudValidationFields.isRecord(row.metadata) ? Object.values(row.metadata) : []].some((value) => typeof value === "string" && !isWellFormedText(value))) throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-data");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (result) throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-result");
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/** Downloads and applied transitions belong in installation history. */
|
|
53
|
+
const isInsightsMovementEvent = (event) => event.type === "UPDATE_DOWNLOADED" || event.type === "UPDATE_APPLIED" || event.type === "RECOVERED";
|
|
54
|
+
const matchesInsightsEventFilter = (event, filter) => {
|
|
55
|
+
if (filter.kind === "all") return true;
|
|
56
|
+
if (filter.kind === "installationMovement") return event.install_id === filter.installId && isInsightsMovementEvent(event);
|
|
57
|
+
return event.type === filter.type && event.platform === filter.platform && event.channel === filter.channel && (filter.type === "RECOVERED" ? event.from_bundle_id === filter.fromBundleId : event.to_bundle_id === filter.toBundleId);
|
|
58
|
+
};
|
|
59
|
+
const invalidQuery = () => {
|
|
60
|
+
throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-query");
|
|
61
|
+
};
|
|
62
|
+
const invalidResult = () => {
|
|
63
|
+
throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-result");
|
|
64
|
+
};
|
|
65
|
+
const validateCount = (count) => isTimestamp(count) ? count : invalidResult();
|
|
66
|
+
const isTimeRange = (value) => require_databasePluginCrudValidationFields.isRecord(value) && hasOnlyKeys(value, ["start", "end"]) && isTimestamp(value.start) && isTimestamp(value.end) && value.start < value.end;
|
|
67
|
+
const isReleaseReference = (value) => require_databasePluginCrudValidationFields.isRecord(value) && hasOnlyKeys(value, [
|
|
68
|
+
"releaseId",
|
|
69
|
+
"platform",
|
|
70
|
+
"channel"
|
|
71
|
+
]) && isIdentity(value.releaseId) && hasScope(value);
|
|
72
|
+
const validateAggregateResult = (value) => {
|
|
73
|
+
const result = require_databasePluginCrudValidationFields.isRecord(value) ? value : invalidResult();
|
|
74
|
+
if (!isTimestamp(result.measuredAtMs)) invalidResult();
|
|
75
|
+
const coverage = result.coverage;
|
|
76
|
+
if (!require_databasePluginCrudValidationFields.isRecord(coverage) || coverage.kind !== "complete" && coverage.kind !== "partial" || coverage.sinceMs !== null && !isTimestamp(coverage.sinceMs)) invalidResult();
|
|
77
|
+
};
|
|
78
|
+
/** Validate custom and bundled providers at the same public boundary. */
|
|
79
|
+
const createValidatedInsightsModel = (model) => ({
|
|
80
|
+
async recordEvent(input) {
|
|
81
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, ["event"])) throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-data");
|
|
82
|
+
validateRow("bundle_events", input.event);
|
|
83
|
+
await model.recordEvent(input);
|
|
84
|
+
},
|
|
85
|
+
async listEvents(input) {
|
|
86
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, [
|
|
87
|
+
"filter",
|
|
88
|
+
"sinceMs",
|
|
89
|
+
"beforeReceivedAtMs",
|
|
90
|
+
"after",
|
|
91
|
+
"limit"
|
|
92
|
+
]) || !isEventFilter(input.filter) || !isLimit(input.limit) || !isTimestamp(input.beforeReceivedAtMs) || input.sinceMs !== void 0 && !isTimestamp(input.sinceMs)) invalidQuery();
|
|
93
|
+
const sinceMs = input.sinceMs ?? 0;
|
|
94
|
+
if (sinceMs > input.beforeReceivedAtMs || input.after !== void 0 && (!require_databasePluginCrudValidationFields.isRecord(input.after) || !hasOnlyKeys(input.after, ["receivedAtMs", "id"]) || !isTimestamp(input.after.receivedAtMs) || typeof input.after.id !== "string" || !(0, _hot_updater_core.isUUIDv7)(input.after.id) || input.after.receivedAtMs < sinceMs || input.after.receivedAtMs >= input.beforeReceivedAtMs)) invalidQuery();
|
|
95
|
+
const rows = await model.listEvents(input);
|
|
96
|
+
if (!Array.isArray(rows) || rows.length > input.limit) invalidResult();
|
|
97
|
+
let previous = input.after;
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
validateRow("bundle_events", row, true);
|
|
100
|
+
if (row.received_at_ms < sinceMs || row.received_at_ms >= input.beforeReceivedAtMs || !matchesInsightsEventFilter(row, input.filter) || previous !== void 0 && (row.received_at_ms > previous.receivedAtMs || row.received_at_ms === previous.receivedAtMs && row.id >= previous.id)) invalidResult();
|
|
101
|
+
previous = {
|
|
102
|
+
receivedAtMs: row.received_at_ms,
|
|
103
|
+
id: row.id
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return rows;
|
|
107
|
+
},
|
|
108
|
+
async findLatestEvents(input) {
|
|
109
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input)) invalidQuery();
|
|
110
|
+
if ("installId" in input) {
|
|
111
|
+
if (!hasOnlyKeys(input, ["installId"]) || !isIdentity(input.installId)) invalidQuery();
|
|
112
|
+
} else if (!hasOnlyKeys(input, [
|
|
113
|
+
"userId",
|
|
114
|
+
"afterInstallId",
|
|
115
|
+
"limit"
|
|
116
|
+
]) || !isIdentity(input.userId) || !isLimit(input.limit) || input.afterInstallId !== void 0 && !isIdentity(input.afterInstallId)) invalidQuery();
|
|
117
|
+
const rows = await model.findLatestEvents(input);
|
|
118
|
+
if (!Array.isArray(rows) || rows.length > ("installId" in input ? 1 : input.limit)) invalidResult();
|
|
119
|
+
let previous = "installId" in input ? void 0 : input.afterInstallId;
|
|
120
|
+
for (const row of rows) {
|
|
121
|
+
validateRow("bundle_events", row, true);
|
|
122
|
+
if ("installId" in input ? row.install_id !== input.installId : row.user_id !== input.userId || previous !== void 0 && compareInsightsText(row.install_id, previous) <= 0) invalidResult();
|
|
123
|
+
previous = row.install_id;
|
|
124
|
+
}
|
|
125
|
+
return rows;
|
|
126
|
+
},
|
|
127
|
+
async countLatestEvents(input) {
|
|
128
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, [
|
|
129
|
+
"platform",
|
|
130
|
+
"channel",
|
|
131
|
+
"sinceMs",
|
|
132
|
+
"bundle"
|
|
133
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || input.bundle !== void 0 && (!Array.isArray(input.bundle) || input.bundle.length < 1 || input.bundle.length > 2 || input.bundle.some((bundle) => !require_databasePluginCrudValidationFields.isRecord(bundle) || !hasOnlyKeys(bundle, [
|
|
134
|
+
"field",
|
|
135
|
+
"value",
|
|
136
|
+
"types"
|
|
137
|
+
]) || bundle.field !== "from_bundle_id" && bundle.field !== "to_bundle_id" || !isText(bundle.value) || !Array.isArray(bundle.types) || bundle.types.length === 0 || bundle.types.some((type) => ![
|
|
138
|
+
"UNCHANGED",
|
|
139
|
+
"UPDATE_DOWNLOADED",
|
|
140
|
+
"UPDATE_APPLIED",
|
|
141
|
+
"RECOVERED"
|
|
142
|
+
].includes(type))))) invalidQuery();
|
|
143
|
+
return validateCount(await model.countLatestEvents(input));
|
|
144
|
+
},
|
|
145
|
+
async countEvents(input) {
|
|
146
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, [
|
|
147
|
+
"filter",
|
|
148
|
+
"sinceMs",
|
|
149
|
+
"beforeReceivedAtMs"
|
|
150
|
+
]) || !isBundleFilter(input.filter) || !isTimestamp(input.sinceMs) || !isTimestamp(input.beforeReceivedAtMs) || input.sinceMs > input.beforeReceivedAtMs) invalidQuery();
|
|
151
|
+
return validateCount(await model.countEvents(input));
|
|
152
|
+
},
|
|
153
|
+
async getReleaseActivity(input) {
|
|
154
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, [
|
|
155
|
+
"releases",
|
|
156
|
+
"scope",
|
|
157
|
+
"timeRange"
|
|
158
|
+
])) invalidQuery();
|
|
159
|
+
const releases = input.releases;
|
|
160
|
+
const scope = input.scope;
|
|
161
|
+
const timeRange = input.timeRange;
|
|
162
|
+
const releaseQuery = Array.isArray(releases) && releases.length > 0 && releases.length <= 100 && releases.every(isReleaseReference) && scope === void 0 && (timeRange === void 0 || isTimeRange(timeRange));
|
|
163
|
+
const scopeQuery = releases === void 0 && require_databasePluginCrudValidationFields.isRecord(scope) && hasOnlyKeys(scope, ["platform", "channel"]) && hasScope(scope) && isTimeRange(timeRange);
|
|
164
|
+
if (!releaseQuery && !scopeQuery) invalidQuery();
|
|
165
|
+
const result = await model.getReleaseActivity(input);
|
|
166
|
+
validateAggregateResult(result);
|
|
167
|
+
if (!Array.isArray(result.data)) invalidResult();
|
|
168
|
+
return result;
|
|
169
|
+
},
|
|
170
|
+
async getAppUsage(input) {
|
|
171
|
+
if (!require_databasePluginCrudValidationFields.isRecord(input) || !hasOnlyKeys(input, [
|
|
172
|
+
"channel",
|
|
173
|
+
"platform",
|
|
174
|
+
"appVersion",
|
|
175
|
+
"timeRange",
|
|
176
|
+
"intervalMs"
|
|
177
|
+
]) || !isText(input.channel) || ![
|
|
178
|
+
"all",
|
|
179
|
+
"ios",
|
|
180
|
+
"android"
|
|
181
|
+
].includes(input.platform) || input.appVersion !== void 0 && !isText(input.appVersion) || !isTimeRange(input.timeRange) || !isTimestamp(input.intervalMs) || input.intervalMs < 36e5) invalidQuery();
|
|
182
|
+
const result = await model.getAppUsage(input);
|
|
183
|
+
validateAggregateResult(result);
|
|
184
|
+
if (!isTimestamp(result.activeInstallations) || !Array.isArray(result.points) || !Array.isArray(result.appVersions) || !Array.isArray(result.versions) || !Array.isArray(result.platforms) || !Array.isArray(result.bundleDistribution)) invalidResult();
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
//#endregion
|
|
189
|
+
exports.compareInsightsText = compareInsightsText;
|
|
190
|
+
exports.createValidatedInsightsModel = createValidatedInsightsModel;
|
|
191
|
+
exports.isInsightsMovementEvent = isInsightsMovementEvent;
|
|
192
|
+
exports.matchesInsightsEventFilter = matchesInsightsEventFilter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BundleEventRow } from "./types/databaseRows.cjs";
|
|
2
|
+
import "./types/index.cjs";
|
|
3
|
+
//#region src/insightsContract.d.ts
|
|
4
|
+
/** Exact UTF-8 byte ordering, without case folding or Unicode normalization. */
|
|
5
|
+
declare const compareInsightsText: (left: string, right: string) => number;
|
|
6
|
+
/** Downloads and applied transitions belong in installation history. */
|
|
7
|
+
declare const isInsightsMovementEvent: (event: Pick<BundleEventRow, "type">) => boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { compareInsightsText, isInsightsMovementEvent };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BundleEventRow } from "./types/databaseRows.mjs";
|
|
2
|
+
import "./types/index.mjs";
|
|
3
|
+
//#region src/insightsContract.d.ts
|
|
4
|
+
/** Exact UTF-8 byte ordering, without case folding or Unicode normalization. */
|
|
5
|
+
declare const compareInsightsText: (left: string, right: string) => number;
|
|
6
|
+
/** Downloads and applied transitions belong in installation history. */
|
|
7
|
+
declare const isInsightsMovementEvent: (event: Pick<BundleEventRow, "type">) => boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { compareInsightsText, isInsightsMovementEvent };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { DatabasePluginInputError } from "./databasePluginCrudValidationErrors.mjs";
|
|
2
|
+
import { isUUIDv7 } from "./uuidv7.mjs";
|
|
3
|
+
import { isRecord } from "./databasePluginCrudValidationFields.mjs";
|
|
4
|
+
import { validateCreateData } from "./databasePluginCrudValidationRows.mjs";
|
|
5
|
+
//#region src/insightsContract.ts
|
|
6
|
+
const encoder = new TextEncoder();
|
|
7
|
+
/** Exact UTF-8 byte ordering, without case folding or Unicode normalization. */
|
|
8
|
+
const compareInsightsText = (left, right) => {
|
|
9
|
+
const a = encoder.encode(left);
|
|
10
|
+
const b = encoder.encode(right);
|
|
11
|
+
for (let index = 0; index < Math.min(a.length, b.length); index += 1) if (a[index] !== b[index]) return a[index] - b[index];
|
|
12
|
+
return a.length - b.length;
|
|
13
|
+
};
|
|
14
|
+
const isWellFormedText = (value) => {
|
|
15
|
+
for (const character of value) {
|
|
16
|
+
const point = character.codePointAt(0);
|
|
17
|
+
if (point >= 55296 && point <= 57343) return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
const isIdentity = (value) => typeof value === "string" && value.length > 0 && value.length <= 255 && isWellFormedText(value);
|
|
22
|
+
const isText = (value) => typeof value === "string" && value.length > 0 && isWellFormedText(value);
|
|
23
|
+
const isTimestamp = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
24
|
+
const isLimit = (value) => isTimestamp(value) && value >= 1 && value <= 101;
|
|
25
|
+
const hasOnlyKeys = (value, keys) => Object.keys(value).every((key) => keys.includes(key));
|
|
26
|
+
const hasScope = (value) => (value.platform === "ios" || value.platform === "android") && isText(value.channel);
|
|
27
|
+
const isBundleFilter = (value, withKind = false) => {
|
|
28
|
+
if (!isRecord(value) || !hasScope(value)) return false;
|
|
29
|
+
const keys = [
|
|
30
|
+
"platform",
|
|
31
|
+
"channel",
|
|
32
|
+
"type",
|
|
33
|
+
...withKind ? ["kind"] : []
|
|
34
|
+
];
|
|
35
|
+
return value.type === "RECOVERED" ? isText(value.fromBundleId) && hasOnlyKeys(value, [...keys, "fromBundleId"]) : (value.type === "UPDATE_DOWNLOADED" || value.type === "UPDATE_APPLIED" || value.type === "UNCHANGED") && isText(value.toBundleId) && hasOnlyKeys(value, [...keys, "toBundleId"]);
|
|
36
|
+
};
|
|
37
|
+
const isEventFilter = (value) => {
|
|
38
|
+
if (!isRecord(value)) return false;
|
|
39
|
+
if (value.kind === "all") return hasOnlyKeys(value, ["kind"]);
|
|
40
|
+
if (value.kind === "installationMovement") return isIdentity(value.installId) && hasOnlyKeys(value, ["kind", "installId"]);
|
|
41
|
+
return value.kind === "bundle" && isBundleFilter(value, true);
|
|
42
|
+
};
|
|
43
|
+
const validateRow = (model, row, result = false) => {
|
|
44
|
+
try {
|
|
45
|
+
validateCreateData(model, row);
|
|
46
|
+
if (!isRecord(row) || typeof row.id !== "string" || !isUUIDv7(row.id) || [...Object.values(row), ...isRecord(row.metadata) ? Object.values(row.metadata) : []].some((value) => typeof value === "string" && !isWellFormedText(value))) throw new DatabasePluginInputError("invalid-data");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (result) throw new DatabasePluginInputError("invalid-result");
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/** Downloads and applied transitions belong in installation history. */
|
|
53
|
+
const isInsightsMovementEvent = (event) => event.type === "UPDATE_DOWNLOADED" || event.type === "UPDATE_APPLIED" || event.type === "RECOVERED";
|
|
54
|
+
const matchesInsightsEventFilter = (event, filter) => {
|
|
55
|
+
if (filter.kind === "all") return true;
|
|
56
|
+
if (filter.kind === "installationMovement") return event.install_id === filter.installId && isInsightsMovementEvent(event);
|
|
57
|
+
return event.type === filter.type && event.platform === filter.platform && event.channel === filter.channel && (filter.type === "RECOVERED" ? event.from_bundle_id === filter.fromBundleId : event.to_bundle_id === filter.toBundleId);
|
|
58
|
+
};
|
|
59
|
+
const invalidQuery = () => {
|
|
60
|
+
throw new DatabasePluginInputError("invalid-query");
|
|
61
|
+
};
|
|
62
|
+
const invalidResult = () => {
|
|
63
|
+
throw new DatabasePluginInputError("invalid-result");
|
|
64
|
+
};
|
|
65
|
+
const validateCount = (count) => isTimestamp(count) ? count : invalidResult();
|
|
66
|
+
const isTimeRange = (value) => isRecord(value) && hasOnlyKeys(value, ["start", "end"]) && isTimestamp(value.start) && isTimestamp(value.end) && value.start < value.end;
|
|
67
|
+
const isReleaseReference = (value) => isRecord(value) && hasOnlyKeys(value, [
|
|
68
|
+
"releaseId",
|
|
69
|
+
"platform",
|
|
70
|
+
"channel"
|
|
71
|
+
]) && isIdentity(value.releaseId) && hasScope(value);
|
|
72
|
+
const validateAggregateResult = (value) => {
|
|
73
|
+
const result = isRecord(value) ? value : invalidResult();
|
|
74
|
+
if (!isTimestamp(result.measuredAtMs)) invalidResult();
|
|
75
|
+
const coverage = result.coverage;
|
|
76
|
+
if (!isRecord(coverage) || coverage.kind !== "complete" && coverage.kind !== "partial" || coverage.sinceMs !== null && !isTimestamp(coverage.sinceMs)) invalidResult();
|
|
77
|
+
};
|
|
78
|
+
/** Validate custom and bundled providers at the same public boundary. */
|
|
79
|
+
const createValidatedInsightsModel = (model) => ({
|
|
80
|
+
async recordEvent(input) {
|
|
81
|
+
if (!isRecord(input) || !hasOnlyKeys(input, ["event"])) throw new DatabasePluginInputError("invalid-data");
|
|
82
|
+
validateRow("bundle_events", input.event);
|
|
83
|
+
await model.recordEvent(input);
|
|
84
|
+
},
|
|
85
|
+
async listEvents(input) {
|
|
86
|
+
if (!isRecord(input) || !hasOnlyKeys(input, [
|
|
87
|
+
"filter",
|
|
88
|
+
"sinceMs",
|
|
89
|
+
"beforeReceivedAtMs",
|
|
90
|
+
"after",
|
|
91
|
+
"limit"
|
|
92
|
+
]) || !isEventFilter(input.filter) || !isLimit(input.limit) || !isTimestamp(input.beforeReceivedAtMs) || input.sinceMs !== void 0 && !isTimestamp(input.sinceMs)) invalidQuery();
|
|
93
|
+
const sinceMs = input.sinceMs ?? 0;
|
|
94
|
+
if (sinceMs > input.beforeReceivedAtMs || input.after !== void 0 && (!isRecord(input.after) || !hasOnlyKeys(input.after, ["receivedAtMs", "id"]) || !isTimestamp(input.after.receivedAtMs) || typeof input.after.id !== "string" || !isUUIDv7(input.after.id) || input.after.receivedAtMs < sinceMs || input.after.receivedAtMs >= input.beforeReceivedAtMs)) invalidQuery();
|
|
95
|
+
const rows = await model.listEvents(input);
|
|
96
|
+
if (!Array.isArray(rows) || rows.length > input.limit) invalidResult();
|
|
97
|
+
let previous = input.after;
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
validateRow("bundle_events", row, true);
|
|
100
|
+
if (row.received_at_ms < sinceMs || row.received_at_ms >= input.beforeReceivedAtMs || !matchesInsightsEventFilter(row, input.filter) || previous !== void 0 && (row.received_at_ms > previous.receivedAtMs || row.received_at_ms === previous.receivedAtMs && row.id >= previous.id)) invalidResult();
|
|
101
|
+
previous = {
|
|
102
|
+
receivedAtMs: row.received_at_ms,
|
|
103
|
+
id: row.id
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return rows;
|
|
107
|
+
},
|
|
108
|
+
async findLatestEvents(input) {
|
|
109
|
+
if (!isRecord(input)) invalidQuery();
|
|
110
|
+
if ("installId" in input) {
|
|
111
|
+
if (!hasOnlyKeys(input, ["installId"]) || !isIdentity(input.installId)) invalidQuery();
|
|
112
|
+
} else if (!hasOnlyKeys(input, [
|
|
113
|
+
"userId",
|
|
114
|
+
"afterInstallId",
|
|
115
|
+
"limit"
|
|
116
|
+
]) || !isIdentity(input.userId) || !isLimit(input.limit) || input.afterInstallId !== void 0 && !isIdentity(input.afterInstallId)) invalidQuery();
|
|
117
|
+
const rows = await model.findLatestEvents(input);
|
|
118
|
+
if (!Array.isArray(rows) || rows.length > ("installId" in input ? 1 : input.limit)) invalidResult();
|
|
119
|
+
let previous = "installId" in input ? void 0 : input.afterInstallId;
|
|
120
|
+
for (const row of rows) {
|
|
121
|
+
validateRow("bundle_events", row, true);
|
|
122
|
+
if ("installId" in input ? row.install_id !== input.installId : row.user_id !== input.userId || previous !== void 0 && compareInsightsText(row.install_id, previous) <= 0) invalidResult();
|
|
123
|
+
previous = row.install_id;
|
|
124
|
+
}
|
|
125
|
+
return rows;
|
|
126
|
+
},
|
|
127
|
+
async countLatestEvents(input) {
|
|
128
|
+
if (!isRecord(input) || !hasOnlyKeys(input, [
|
|
129
|
+
"platform",
|
|
130
|
+
"channel",
|
|
131
|
+
"sinceMs",
|
|
132
|
+
"bundle"
|
|
133
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || input.bundle !== void 0 && (!Array.isArray(input.bundle) || input.bundle.length < 1 || input.bundle.length > 2 || input.bundle.some((bundle) => !isRecord(bundle) || !hasOnlyKeys(bundle, [
|
|
134
|
+
"field",
|
|
135
|
+
"value",
|
|
136
|
+
"types"
|
|
137
|
+
]) || bundle.field !== "from_bundle_id" && bundle.field !== "to_bundle_id" || !isText(bundle.value) || !Array.isArray(bundle.types) || bundle.types.length === 0 || bundle.types.some((type) => ![
|
|
138
|
+
"UNCHANGED",
|
|
139
|
+
"UPDATE_DOWNLOADED",
|
|
140
|
+
"UPDATE_APPLIED",
|
|
141
|
+
"RECOVERED"
|
|
142
|
+
].includes(type))))) invalidQuery();
|
|
143
|
+
return validateCount(await model.countLatestEvents(input));
|
|
144
|
+
},
|
|
145
|
+
async countEvents(input) {
|
|
146
|
+
if (!isRecord(input) || !hasOnlyKeys(input, [
|
|
147
|
+
"filter",
|
|
148
|
+
"sinceMs",
|
|
149
|
+
"beforeReceivedAtMs"
|
|
150
|
+
]) || !isBundleFilter(input.filter) || !isTimestamp(input.sinceMs) || !isTimestamp(input.beforeReceivedAtMs) || input.sinceMs > input.beforeReceivedAtMs) invalidQuery();
|
|
151
|
+
return validateCount(await model.countEvents(input));
|
|
152
|
+
},
|
|
153
|
+
async getReleaseActivity(input) {
|
|
154
|
+
if (!isRecord(input) || !hasOnlyKeys(input, [
|
|
155
|
+
"releases",
|
|
156
|
+
"scope",
|
|
157
|
+
"timeRange"
|
|
158
|
+
])) invalidQuery();
|
|
159
|
+
const releases = input.releases;
|
|
160
|
+
const scope = input.scope;
|
|
161
|
+
const timeRange = input.timeRange;
|
|
162
|
+
const releaseQuery = Array.isArray(releases) && releases.length > 0 && releases.length <= 100 && releases.every(isReleaseReference) && scope === void 0 && (timeRange === void 0 || isTimeRange(timeRange));
|
|
163
|
+
const scopeQuery = releases === void 0 && isRecord(scope) && hasOnlyKeys(scope, ["platform", "channel"]) && hasScope(scope) && isTimeRange(timeRange);
|
|
164
|
+
if (!releaseQuery && !scopeQuery) invalidQuery();
|
|
165
|
+
const result = await model.getReleaseActivity(input);
|
|
166
|
+
validateAggregateResult(result);
|
|
167
|
+
if (!Array.isArray(result.data)) invalidResult();
|
|
168
|
+
return result;
|
|
169
|
+
},
|
|
170
|
+
async getAppUsage(input) {
|
|
171
|
+
if (!isRecord(input) || !hasOnlyKeys(input, [
|
|
172
|
+
"channel",
|
|
173
|
+
"platform",
|
|
174
|
+
"appVersion",
|
|
175
|
+
"timeRange",
|
|
176
|
+
"intervalMs"
|
|
177
|
+
]) || !isText(input.channel) || ![
|
|
178
|
+
"all",
|
|
179
|
+
"ios",
|
|
180
|
+
"android"
|
|
181
|
+
].includes(input.platform) || input.appVersion !== void 0 && !isText(input.appVersion) || !isTimeRange(input.timeRange) || !isTimestamp(input.intervalMs) || input.intervalMs < 36e5) invalidQuery();
|
|
182
|
+
const result = await model.getAppUsage(input);
|
|
183
|
+
validateAggregateResult(result);
|
|
184
|
+
if (!isTimestamp(result.activeInstallations) || !Array.isArray(result.points) || !Array.isArray(result.appVersions) || !Array.isArray(result.versions) || !Array.isArray(result.platforms) || !Array.isArray(result.bundleDistribution)) invalidResult();
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
//#endregion
|
|
189
|
+
export { compareInsightsText, createValidatedInsightsModel, isInsightsMovementEvent, matchesInsightsEventFilter };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/insightsDistinctSummary.ts
|
|
2
|
+
const PRECISION = 10;
|
|
3
|
+
const REGISTER_COUNT = 1024;
|
|
4
|
+
const MAX_RANK = 55;
|
|
5
|
+
const hash = (value) => {
|
|
6
|
+
let result = 14695981039346656037n;
|
|
7
|
+
for (const byte of new TextEncoder().encode(value)) {
|
|
8
|
+
result ^= BigInt(byte);
|
|
9
|
+
result = BigInt.asUintN(64, result * 1099511628211n);
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
const OFFSET = 33;
|
|
14
|
+
const decode = (summary) => {
|
|
15
|
+
if (!summary) return new Uint8Array(REGISTER_COUNT);
|
|
16
|
+
if (summary.length !== REGISTER_COUNT) throw new Error("Invalid Insights distinct summary");
|
|
17
|
+
const registers = new Uint8Array(REGISTER_COUNT);
|
|
18
|
+
for (let index = 0; index < REGISTER_COUNT; index += 1) {
|
|
19
|
+
const value = summary.charCodeAt(index) - OFFSET;
|
|
20
|
+
if (!Number.isInteger(value) || value < 0 || value > MAX_RANK) throw new Error("Invalid Insights distinct summary");
|
|
21
|
+
registers[index] = value;
|
|
22
|
+
}
|
|
23
|
+
return registers;
|
|
24
|
+
};
|
|
25
|
+
const encode = (registers) => Array.from(registers, (value) => String.fromCharCode(value + OFFSET)).join("");
|
|
26
|
+
const getInsightsDistinctRegister = (identity) => {
|
|
27
|
+
const value = hash(identity);
|
|
28
|
+
const index = Number(value & BigInt(1023));
|
|
29
|
+
let remainder = value >> BigInt(PRECISION);
|
|
30
|
+
let rank = 1;
|
|
31
|
+
while ((remainder & 1n) === 0n && rank < MAX_RANK) {
|
|
32
|
+
rank += 1;
|
|
33
|
+
remainder >>= 1n;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
index,
|
|
37
|
+
rank,
|
|
38
|
+
character: String.fromCharCode(rank + OFFSET)
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const addInsightsDistinct = (summary, identity) => {
|
|
42
|
+
const registers = decode(summary);
|
|
43
|
+
const { index, rank } = getInsightsDistinctRegister(identity);
|
|
44
|
+
registers[index] = Math.max(registers[index], rank);
|
|
45
|
+
return encode(registers);
|
|
46
|
+
};
|
|
47
|
+
const mergeInsightsDistinct = (summaries) => {
|
|
48
|
+
const merged = new Uint8Array(REGISTER_COUNT);
|
|
49
|
+
for (const summary of summaries) {
|
|
50
|
+
const registers = decode(summary);
|
|
51
|
+
for (let index = 0; index < REGISTER_COUNT; index += 1) merged[index] = Math.max(merged[index], registers[index]);
|
|
52
|
+
}
|
|
53
|
+
return encode(merged);
|
|
54
|
+
};
|
|
55
|
+
const countInsightsDistinct = (summary) => {
|
|
56
|
+
const registers = decode(summary);
|
|
57
|
+
let inverseSum = 0;
|
|
58
|
+
let empty = 0;
|
|
59
|
+
for (const register of registers) {
|
|
60
|
+
inverseSum += 2 ** -register;
|
|
61
|
+
if (register === 0) empty += 1;
|
|
62
|
+
}
|
|
63
|
+
const estimate = empty > 0 ? REGISTER_COUNT * Math.log(REGISTER_COUNT / empty) : .7213 / 1.0010537109375 * REGISTER_COUNT ** 2 / inverseSum;
|
|
64
|
+
return Math.max(0, Math.round(estimate));
|
|
65
|
+
};
|
|
66
|
+
const emptyInsightsDistinct = () => encode(new Uint8Array(REGISTER_COUNT));
|
|
67
|
+
//#endregion
|
|
68
|
+
exports.addInsightsDistinct = addInsightsDistinct;
|
|
69
|
+
exports.countInsightsDistinct = countInsightsDistinct;
|
|
70
|
+
exports.emptyInsightsDistinct = emptyInsightsDistinct;
|
|
71
|
+
exports.getInsightsDistinctRegister = getInsightsDistinctRegister;
|
|
72
|
+
exports.mergeInsightsDistinct = mergeInsightsDistinct;
|