@hot-updater/plugin-core 1.0.0-rc.15 → 1.0.0-rc.16

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.
Files changed (145) hide show
  1. package/dist/bundleEventRow.cjs +42 -0
  2. package/dist/bundleEventRow.mjs +41 -0
  3. package/dist/coreApi.d.cts +131 -0
  4. package/dist/coreApi.d.mts +131 -0
  5. package/dist/database/adapter.cjs +37 -0
  6. package/dist/database/adapter.d.cts +150 -0
  7. package/dist/database/adapter.d.mts +150 -0
  8. package/dist/database/adapter.mjs +30 -0
  9. package/dist/database/memoryAdapter.cjs +102 -0
  10. package/dist/database/memoryAdapter.d.cts +16 -0
  11. package/dist/database/memoryAdapter.d.mts +16 -0
  12. package/dist/database/memoryAdapter.mjs +102 -0
  13. package/dist/database/values.cjs +110 -0
  14. package/dist/database/values.d.cts +30 -0
  15. package/dist/database/values.d.mts +30 -0
  16. package/dist/database/values.mjs +100 -0
  17. package/dist/database/verifyAdapter.cjs +129 -0
  18. package/dist/database/verifyAdapter.d.cts +29 -0
  19. package/dist/database/verifyAdapter.d.mts +29 -0
  20. package/dist/database/verifyAdapter.mjs +128 -0
  21. package/dist/databaseErrors.cjs +30 -0
  22. package/dist/databaseErrors.d.cts +21 -0
  23. package/dist/databaseErrors.d.mts +21 -0
  24. package/dist/databaseErrors.mjs +28 -0
  25. package/dist/databaseMetadata.cjs +2 -2
  26. package/dist/databaseMetadata.mjs +1 -1
  27. package/dist/index.cjs +10 -36
  28. package/dist/index.d.cts +13 -17
  29. package/dist/index.d.mts +13 -17
  30. package/dist/index.mjs +8 -14
  31. package/dist/insightsContract.cjs +26 -24
  32. package/dist/insightsContract.d.cts +6 -1
  33. package/dist/insightsContract.d.mts +6 -1
  34. package/dist/insightsContract.mjs +6 -5
  35. package/dist/insightsDistinctSummary.cjs +2 -1
  36. package/dist/insightsDistinctSummary.mjs +2 -1
  37. package/dist/insightsOverview.cjs +4 -4
  38. package/dist/insightsOverview.d.cts +3 -1
  39. package/dist/insightsOverview.d.mts +3 -1
  40. package/dist/insightsOverview.mjs +4 -5
  41. package/dist/internal.cjs +32 -8
  42. package/dist/internal.d.cts +11 -10
  43. package/dist/internal.d.mts +11 -10
  44. package/dist/internal.mjs +8 -5
  45. package/dist/releaseCatalogCompiler.cjs +1 -1
  46. package/dist/releaseCatalogCompiler.mjs +2 -2
  47. package/dist/releaseCatalogMutation.cjs +0 -292
  48. package/dist/releaseCatalogMutation.d.cts +4 -45
  49. package/dist/releaseCatalogMutation.d.mts +4 -45
  50. package/dist/releaseCatalogMutation.mjs +1 -288
  51. package/dist/releaseManagement.cjs +0 -221
  52. package/dist/releaseManagement.d.cts +4 -28
  53. package/dist/releaseManagement.d.mts +4 -28
  54. package/dist/releaseManagement.mjs +1 -216
  55. package/dist/types/databaseConfig.cjs +5 -0
  56. package/dist/types/databaseConfig.d.cts +33 -0
  57. package/dist/types/databaseConfig.d.mts +33 -0
  58. package/dist/types/databaseConfig.mjs +5 -0
  59. package/dist/types/databaseOperations.d.cts +5 -174
  60. package/dist/types/databaseOperations.d.mts +5 -174
  61. package/dist/types/index.cjs +2 -0
  62. package/dist/types/index.d.cts +8 -73
  63. package/dist/types/index.d.mts +8 -73
  64. package/dist/types/index.mjs +2 -1
  65. package/dist/types/insights.d.cts +172 -0
  66. package/dist/types/insights.d.mts +172 -0
  67. package/dist/types/internal.d.cts +4 -7
  68. package/dist/types/internal.d.mts +4 -7
  69. package/dist/types/models.d.cts +24 -0
  70. package/dist/types/models.d.mts +24 -0
  71. package/dist/types/public.d.cts +4 -2
  72. package/dist/types/public.d.mts +4 -2
  73. package/package.json +1 -1
  74. package/dist/calculatePagination.cjs +0 -25
  75. package/dist/calculatePagination.d.cts +0 -12
  76. package/dist/calculatePagination.d.mts +0 -12
  77. package/dist/calculatePagination.mjs +0 -25
  78. package/dist/createDatabasePlugin.cjs +0 -875
  79. package/dist/createDatabasePlugin.d.cts +0 -28
  80. package/dist/createDatabasePlugin.d.mts +0 -28
  81. package/dist/createDatabasePlugin.mjs +0 -871
  82. package/dist/databaseClient.cjs +0 -117
  83. package/dist/databaseClient.d.cts +0 -32
  84. package/dist/databaseClient.d.mts +0 -32
  85. package/dist/databaseClient.mjs +0 -114
  86. package/dist/databaseClientReads.cjs +0 -115
  87. package/dist/databaseClientReads.mjs +0 -113
  88. package/dist/databaseClientUpdates.cjs +0 -37
  89. package/dist/databaseClientUpdates.d.cts +0 -11
  90. package/dist/databaseClientUpdates.d.mts +0 -11
  91. package/dist/databaseClientUpdates.mjs +0 -35
  92. package/dist/databasePluginCrud.cjs +0 -87
  93. package/dist/databasePluginCrud.d.cts +0 -4
  94. package/dist/databasePluginCrud.d.mts +0 -4
  95. package/dist/databasePluginCrud.mjs +0 -86
  96. package/dist/databasePluginCrudValidation.d.cts +0 -6
  97. package/dist/databasePluginCrudValidation.d.mts +0 -6
  98. package/dist/databasePluginCrudValidationErrors.cjs +0 -11
  99. package/dist/databasePluginCrudValidationErrors.d.cts +0 -9
  100. package/dist/databasePluginCrudValidationErrors.d.mts +0 -9
  101. package/dist/databasePluginCrudValidationErrors.mjs +0 -11
  102. package/dist/databasePluginCrudValidationFields.cjs +0 -284
  103. package/dist/databasePluginCrudValidationFields.d.cts +0 -1
  104. package/dist/databasePluginCrudValidationFields.d.mts +0 -1
  105. package/dist/databasePluginCrudValidationFields.mjs +0 -272
  106. package/dist/databasePluginCrudValidationMutations.cjs +0 -88
  107. package/dist/databasePluginCrudValidationMutations.d.cts +0 -1
  108. package/dist/databasePluginCrudValidationMutations.d.mts +0 -1
  109. package/dist/databasePluginCrudValidationMutations.mjs +0 -82
  110. package/dist/databasePluginCrudValidationQueries.cjs +0 -103
  111. package/dist/databasePluginCrudValidationQueries.d.cts +0 -2
  112. package/dist/databasePluginCrudValidationQueries.d.mts +0 -2
  113. package/dist/databasePluginCrudValidationQueries.mjs +0 -97
  114. package/dist/databasePluginCrudValidationRows.cjs +0 -55
  115. package/dist/databasePluginCrudValidationRows.d.cts +0 -1
  116. package/dist/databasePluginCrudValidationRows.d.mts +0 -1
  117. package/dist/databasePluginCrudValidationRows.mjs +0 -53
  118. package/dist/databasePluginTransaction.cjs +0 -7
  119. package/dist/databasePluginTransaction.mjs +0 -7
  120. package/dist/insightsLatestQueries.cjs +0 -53
  121. package/dist/insightsLatestQueries.d.cts +0 -13
  122. package/dist/insightsLatestQueries.d.mts +0 -13
  123. package/dist/insightsLatestQueries.mjs +0 -52
  124. package/dist/paginateBundles.cjs +0 -53
  125. package/dist/paginateBundles.d.cts +0 -13
  126. package/dist/paginateBundles.d.mts +0 -13
  127. package/dist/paginateBundles.mjs +0 -53
  128. package/dist/queryBundles.cjs +0 -34
  129. package/dist/queryBundles.d.cts +0 -9
  130. package/dist/queryBundles.d.mts +0 -9
  131. package/dist/queryBundles.mjs +0 -32
  132. package/dist/requestBundleCache.cjs +0 -22
  133. package/dist/requestBundleCache.d.cts +0 -8
  134. package/dist/requestBundleCache.d.mts +0 -8
  135. package/dist/requestBundleCache.mjs +0 -22
  136. package/dist/types/database.d.cts +0 -5
  137. package/dist/types/database.d.mts +0 -5
  138. package/dist/types/databaseFields.cjs +0 -85
  139. package/dist/types/databaseFields.d.cts +0 -12
  140. package/dist/types/databaseFields.d.mts +0 -12
  141. package/dist/types/databaseFields.mjs +0 -85
  142. package/dist/types/databasePlugin.d.cts +0 -388
  143. package/dist/types/databasePlugin.d.mts +0 -388
  144. package/dist/types/databaseQuery.d.cts +0 -46
  145. package/dist/types/databaseQuery.d.mts +0 -46
@@ -1,13 +1,14 @@
1
+ import { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.cjs";
1
2
  import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseField, DatabaseJsonObject, DatabaseJsonValue, DatabaseModel, DatabaseModelMap, DatabaseRow, 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
- import { DatabaseDistinctFields, DatabaseDistinctOn, DatabaseOrderBy, DatabaseSelect, DatabaseSortBy, DatabaseSortClause, DatabaseSortNulls, DatabaseStringComparisonMode, DatabaseWhere, DatabaseWhereConnector, DatabaseWhereOperator, SelectedDatabaseRow } from "./types/databaseQuery.cjs";
4
- import { ApiKeyRowUpdate, BundleRowUpdate, CountBundlesDatabaseImplementationInput, CountBundlesDatabaseInput, CountDatabaseImplementationInput, CountDatabaseInput, CountDatabaseModel, CreateDatabaseImplementationInput, CreateDatabaseInput, CreateDatabaseModel, DatabaseCapability, DatabaseDeleteModel, DatabaseFindOneModel, DatabaseImplementationResult, DatabaseModelCapabilities, DatabaseModelsWithCapability, DatabasePluginCrud, DatabasePluginImplementation, DatabaseRowUpdate, DeleteDatabaseImplementationInput, DeleteDatabaseInput, DeleteDatabaseModel, FindManyDatabaseImplementationInput, FindManyDatabaseInput, FindManyDatabaseModel, FindManyDatabasePluginInput, FindOneDatabaseImplementationInput, FindOneDatabaseInput, FindOneDatabaseModel, ReleaseCatalogRowUpdate, ReleaseRowUpdate, SelectedDatabaseInputRow, TransactionDatabasePluginImplementation, UpdateBundleDatabaseImplementationInput, UpdateBundleDatabaseInput, UpdateDatabaseImplementationInput, UpdateDatabaseInput, UpdateDatabaseModel } from "./types/databaseOperations.cjs";
5
- import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.cjs";
6
- 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";
7
- import { databaseFields } from "./types/databaseFields.cjs";
3
+ import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.cjs";
4
+ import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./types/insights.cjs";
5
+ import { ApiKeyModel, ChannelDeleteResult, ChannelInsertResult } from "./types/models.cjs";
6
+ import { DatabaseRowReferencedError } from "./databaseErrors.cjs";
7
+ import { assertBundleEventRow, createValidatedInsightsModel } from "./insightsContract.cjs";
8
8
  import "./types/internal.cjs";
9
- import { DatabasePluginAdapter, DatabaseRowReferencedError, createDatabasePluginAdapter } from "./createDatabasePlugin.cjs";
10
- import { latestInsightsCountGroups, latestInsightsWhere } from "./insightsLatestQueries.cjs";
11
9
  import { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct } from "./insightsDistinctSummary.cjs";
12
- import { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.cjs";
13
- export { type ApiKeyModel, type ApiKeyRow, type ApiKeyRowUpdate, type ApplePlatform, type BasePluginArgs, type BuildPlugin, type BuildPluginConfig, type BuiltIns, type Bundle, type BundleEventRow, type BundleEventRowBase, type BundleModel, type BundleModelQuery, type BundlePatchModel, type BundlePatchRow, type BundleRepository, type BundleRepositoryChange, type BundleRepositoryCommit, type BundleRow, type BundleRowUpdate, type BundleSigningPlugin, type ChannelDeleteInput, type ChannelDeleteResult, type ChannelInsertInput, type ChannelInsertResult, type ChannelModel, type ChannelRow, type ConfigInput, type CountBundlesDatabaseImplementationInput, type CountBundlesDatabaseInput, type CountDatabaseImplementationInput, type CountDatabaseInput, type CountDatabaseModel, type CreateDatabaseImplementationInput, type CreateDatabaseInput, type CreateDatabaseModel, type DatabaseBundleCursor, type DatabaseBundleEventMetadata, type DatabaseBundleIdFilter, type DatabaseBundleMetadata, type DatabaseBundleQueryOptions, type DatabaseBundleQueryOrder, type DatabaseBundleQueryWhere, type DatabaseCapability, type DatabaseChange, type DatabaseCommit, type DatabaseCommitExpectation, type DatabaseCommitResult, type DatabaseDeleteModel, type DatabaseDistinctFields, type DatabaseDistinctOn, type DatabaseField, type DatabaseFindOneModel, type DatabaseImplementationResult, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseModel, type DatabaseModelCapabilities, type DatabaseModelMap, type DatabaseModels, type DatabaseModelsWithCapability, type DatabaseOrderBy, type DatabasePlugin, type DatabasePluginAdapter, type DatabasePluginCrud, type DatabasePluginImplementation, type DatabaseRow, DatabaseRowReferencedError, type DatabaseRowUpdate, type DatabaseSelect, type DatabaseSortBy, type DatabaseSortClause, type DatabaseSortNulls, type DatabaseStringComparisonMode, type DatabaseWhere, type DatabaseWhereConnector, type DatabaseWhereOperator, type DeleteDatabaseImplementationInput, type DeleteDatabaseInput, type DeleteDatabaseModel, type FindManyDatabaseImplementationInput, type FindManyDatabaseInput, type FindManyDatabaseModel, type FindManyDatabasePluginInput, type FindOneDatabaseImplementationInput, type FindOneDatabaseInput, type FindOneDatabaseModel, type FingerprintExtraSources, type 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 InsightsOverviewDelta, type InsightsOverviewIdentity, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, type IosBuildDestination, type LocalSigningConfig, type NativeBuildAndroidScheme, type NativeBuildArgs, type NativeBuildIosScheme, type NativeBuildOptions, type Paginated, type PaginatedResult, type PaginationInfo, type Platform, type PlatformConfig, type Primitive, type ReleaseActivityMetrics, type ReleaseCatalogModel, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseModel, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, type RequiredDeep, type SelectedDatabaseInputRow, type SelectedDatabaseRow, type SigningConfig, type StorageDeleteInput, type StorageDeleteResult, type StorageExistsInput, type StorageExistsResult, type StorageGetDownloadUrlInput, type StorageGetDownloadUrlResult, type StorageGetInput, type StorageGetResult, type StorageObject, type StoragePlugin, type StoragePutInput, type StoragePutResult, type TransactionDatabasePluginImplementation, type UpdateBundleDatabaseImplementationInput, type UpdateBundleDatabaseInput, type UpdateDatabaseImplementationInput, type UpdateDatabaseInput, type UpdateDatabaseModel, addInsightsDistinct, countInsightsDistinct, createDatabasePluginAdapter, currentInsightsReleaseId, databaseFields, emptyInsightsDistinct, getInsightsDistinctRegister, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, latestInsightsCountGroups, latestInsightsWhere, mergeInsightsDistinct, type supportedIosPlatforms };
10
+ import { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.cjs";
11
+ import { MemoryAdapterOptions, createMemoryAdapter } from "./database/memoryAdapter.cjs";
12
+ import { DatabaseValueError, NormalizeOptions, canonicalJson, compareKeyValues, compareTuples, compareUtf8, indexEntries, indexOrderTuple, isKeyValue, matchesQuery, normalizeStoredRow, normalizeStoredValue } from "./database/values.cjs";
13
+ import { DatabaseAdapterContractError, DatabaseReadCount, DatabaseReadMeter, VerifiedDatabaseAdapter, VerifyAdapterOptions, verifyAdapter } from "./database/verifyAdapter.cjs";
14
+ export { type ApiKeyModel, type ApiKeyRow, type BundleEventRow, type BundleEventRowBase, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseAdapterContractError, type DatabaseBundleEventMetadata, type DatabaseBundleMetadata, type DatabaseField, DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, DatabaseKey, DatabaseKeyValue, type DatabaseModel, type DatabaseModelMap, DatabaseReadCount, DatabaseReadMeter, type DatabaseRow, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseValue, DatabaseValueError, 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 InsightsOverviewDelta, type InsightsOverviewIdentity, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, MemoryAdapterOptions, NormalizeOptions, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, type ReleaseActivityMetrics, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, StoredRow, VerifiedDatabaseAdapter, VerifyAdapterOptions, WriteGuard, WriteOp, WriteResult, addInsightsDistinct, assertBundleEventRow, canonicalJson, compareKeyValues, compareTuples, compareUtf8, countInsightsDistinct, createMemoryAdapter, createValidatedInsightsModel, currentInsightsReleaseId, emptyInsightsDistinct, findPhysicalColumn, findPhysicalIndex, getInsightsDistinctRegister, indexEntries, indexOrderColumns, indexOrderTuple, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, isKeyValue, matchesQuery, mergeInsightsDistinct, normalizeStoredRow, normalizeStoredValue, rowKey, verifyAdapter };
@@ -1,13 +1,14 @@
1
+ import { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.mjs";
1
2
  import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseField, DatabaseJsonObject, DatabaseJsonValue, DatabaseModel, DatabaseModelMap, DatabaseRow, 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
- import { DatabaseDistinctFields, DatabaseDistinctOn, DatabaseOrderBy, DatabaseSelect, DatabaseSortBy, DatabaseSortClause, DatabaseSortNulls, DatabaseStringComparisonMode, DatabaseWhere, DatabaseWhereConnector, DatabaseWhereOperator, SelectedDatabaseRow } from "./types/databaseQuery.mjs";
4
- import { ApiKeyRowUpdate, BundleRowUpdate, CountBundlesDatabaseImplementationInput, CountBundlesDatabaseInput, CountDatabaseImplementationInput, CountDatabaseInput, CountDatabaseModel, CreateDatabaseImplementationInput, CreateDatabaseInput, CreateDatabaseModel, DatabaseCapability, DatabaseDeleteModel, DatabaseFindOneModel, DatabaseImplementationResult, DatabaseModelCapabilities, DatabaseModelsWithCapability, DatabasePluginCrud, DatabasePluginImplementation, DatabaseRowUpdate, DeleteDatabaseImplementationInput, DeleteDatabaseInput, DeleteDatabaseModel, FindManyDatabaseImplementationInput, FindManyDatabaseInput, FindManyDatabaseModel, FindManyDatabasePluginInput, FindOneDatabaseImplementationInput, FindOneDatabaseInput, FindOneDatabaseModel, ReleaseCatalogRowUpdate, ReleaseRowUpdate, SelectedDatabaseInputRow, TransactionDatabasePluginImplementation, UpdateBundleDatabaseImplementationInput, UpdateBundleDatabaseInput, UpdateDatabaseImplementationInput, UpdateDatabaseInput, UpdateDatabaseModel } from "./types/databaseOperations.mjs";
5
- import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.mjs";
6
- 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";
7
- import { databaseFields } from "./types/databaseFields.mjs";
3
+ import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.mjs";
4
+ import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./types/insights.mjs";
5
+ import { ApiKeyModel, ChannelDeleteResult, ChannelInsertResult } from "./types/models.mjs";
6
+ import { DatabaseRowReferencedError } from "./databaseErrors.mjs";
7
+ import { assertBundleEventRow, createValidatedInsightsModel } from "./insightsContract.mjs";
8
8
  import "./types/internal.mjs";
9
- import { DatabasePluginAdapter, DatabaseRowReferencedError, createDatabasePluginAdapter } from "./createDatabasePlugin.mjs";
10
- import { latestInsightsCountGroups, latestInsightsWhere } from "./insightsLatestQueries.mjs";
11
9
  import { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct } from "./insightsDistinctSummary.mjs";
12
- import { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.mjs";
13
- export { type ApiKeyModel, type ApiKeyRow, type ApiKeyRowUpdate, type ApplePlatform, type BasePluginArgs, type BuildPlugin, type BuildPluginConfig, type BuiltIns, type Bundle, type BundleEventRow, type BundleEventRowBase, type BundleModel, type BundleModelQuery, type BundlePatchModel, type BundlePatchRow, type BundleRepository, type BundleRepositoryChange, type BundleRepositoryCommit, type BundleRow, type BundleRowUpdate, type BundleSigningPlugin, type ChannelDeleteInput, type ChannelDeleteResult, type ChannelInsertInput, type ChannelInsertResult, type ChannelModel, type ChannelRow, type ConfigInput, type CountBundlesDatabaseImplementationInput, type CountBundlesDatabaseInput, type CountDatabaseImplementationInput, type CountDatabaseInput, type CountDatabaseModel, type CreateDatabaseImplementationInput, type CreateDatabaseInput, type CreateDatabaseModel, type DatabaseBundleCursor, type DatabaseBundleEventMetadata, type DatabaseBundleIdFilter, type DatabaseBundleMetadata, type DatabaseBundleQueryOptions, type DatabaseBundleQueryOrder, type DatabaseBundleQueryWhere, type DatabaseCapability, type DatabaseChange, type DatabaseCommit, type DatabaseCommitExpectation, type DatabaseCommitResult, type DatabaseDeleteModel, type DatabaseDistinctFields, type DatabaseDistinctOn, type DatabaseField, type DatabaseFindOneModel, type DatabaseImplementationResult, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseModel, type DatabaseModelCapabilities, type DatabaseModelMap, type DatabaseModels, type DatabaseModelsWithCapability, type DatabaseOrderBy, type DatabasePlugin, type DatabasePluginAdapter, type DatabasePluginCrud, type DatabasePluginImplementation, type DatabaseRow, DatabaseRowReferencedError, type DatabaseRowUpdate, type DatabaseSelect, type DatabaseSortBy, type DatabaseSortClause, type DatabaseSortNulls, type DatabaseStringComparisonMode, type DatabaseWhere, type DatabaseWhereConnector, type DatabaseWhereOperator, type DeleteDatabaseImplementationInput, type DeleteDatabaseInput, type DeleteDatabaseModel, type FindManyDatabaseImplementationInput, type FindManyDatabaseInput, type FindManyDatabaseModel, type FindManyDatabasePluginInput, type FindOneDatabaseImplementationInput, type FindOneDatabaseInput, type FindOneDatabaseModel, type FingerprintExtraSources, type 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 InsightsOverviewDelta, type InsightsOverviewIdentity, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, type IosBuildDestination, type LocalSigningConfig, type NativeBuildAndroidScheme, type NativeBuildArgs, type NativeBuildIosScheme, type NativeBuildOptions, type Paginated, type PaginatedResult, type PaginationInfo, type Platform, type PlatformConfig, type Primitive, type ReleaseActivityMetrics, type ReleaseCatalogModel, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseModel, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, type RequiredDeep, type SelectedDatabaseInputRow, type SelectedDatabaseRow, type SigningConfig, type StorageDeleteInput, type StorageDeleteResult, type StorageExistsInput, type StorageExistsResult, type StorageGetDownloadUrlInput, type StorageGetDownloadUrlResult, type StorageGetInput, type StorageGetResult, type StorageObject, type StoragePlugin, type StoragePutInput, type StoragePutResult, type TransactionDatabasePluginImplementation, type UpdateBundleDatabaseImplementationInput, type UpdateBundleDatabaseInput, type UpdateDatabaseImplementationInput, type UpdateDatabaseInput, type UpdateDatabaseModel, addInsightsDistinct, countInsightsDistinct, createDatabasePluginAdapter, currentInsightsReleaseId, databaseFields, emptyInsightsDistinct, getInsightsDistinctRegister, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, latestInsightsCountGroups, latestInsightsWhere, mergeInsightsDistinct, type supportedIosPlatforms };
10
+ import { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.mjs";
11
+ import { MemoryAdapterOptions, createMemoryAdapter } from "./database/memoryAdapter.mjs";
12
+ import { DatabaseValueError, NormalizeOptions, canonicalJson, compareKeyValues, compareTuples, compareUtf8, indexEntries, indexOrderTuple, isKeyValue, matchesQuery, normalizeStoredRow, normalizeStoredValue } from "./database/values.mjs";
13
+ import { DatabaseAdapterContractError, DatabaseReadCount, DatabaseReadMeter, VerifiedDatabaseAdapter, VerifyAdapterOptions, verifyAdapter } from "./database/verifyAdapter.mjs";
14
+ export { type ApiKeyModel, type ApiKeyRow, type BundleEventRow, type BundleEventRowBase, type BundlePatchRow, type BundleRow, type BundleRowUpdate, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseAdapterContractError, type DatabaseBundleEventMetadata, type DatabaseBundleMetadata, type DatabaseField, DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, DatabaseKey, DatabaseKeyValue, type DatabaseModel, type DatabaseModelMap, DatabaseReadCount, DatabaseReadMeter, type DatabaseRow, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseValue, DatabaseValueError, 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 InsightsOverviewDelta, type InsightsOverviewIdentity, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, MemoryAdapterOptions, NormalizeOptions, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, type ReleaseActivityMetrics, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, StoredRow, VerifiedDatabaseAdapter, VerifyAdapterOptions, WriteGuard, WriteOp, WriteResult, addInsightsDistinct, assertBundleEventRow, canonicalJson, compareKeyValues, compareTuples, compareUtf8, countInsightsDistinct, createMemoryAdapter, createValidatedInsightsModel, currentInsightsReleaseId, emptyInsightsDistinct, findPhysicalColumn, findPhysicalIndex, getInsightsDistinctRegister, indexEntries, indexOrderColumns, indexOrderTuple, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, isKeyValue, matchesQuery, mergeInsightsDistinct, normalizeStoredRow, normalizeStoredValue, rowKey, verifyAdapter };
package/dist/internal.mjs CHANGED
@@ -1,6 +1,9 @@
1
- import { databaseFields } from "./types/databaseFields.mjs";
2
- import { DatabaseRowReferencedError, createDatabasePluginAdapter } from "./createDatabasePlugin.mjs";
3
- import { latestInsightsCountGroups, latestInsightsWhere } from "./insightsLatestQueries.mjs";
1
+ import { DatabaseRowReferencedError } from "./databaseErrors.mjs";
2
+ import { assertBundleEventRow, createValidatedInsightsModel } from "./insightsContract.mjs";
4
3
  import { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct } from "./insightsDistinctSummary.mjs";
5
- import { currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.mjs";
6
- export { DatabaseRowReferencedError, addInsightsDistinct, countInsightsDistinct, createDatabasePluginAdapter, currentInsightsReleaseId, databaseFields, emptyInsightsDistinct, getInsightsDistinctRegister, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, latestInsightsCountGroups, latestInsightsWhere, mergeInsightsDistinct };
4
+ import { currentInsightsReleaseId, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues } from "./insightsOverview.mjs";
5
+ import { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseSchemaError, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.mjs";
6
+ import { DatabaseValueError, canonicalJson, compareKeyValues, compareTuples, compareUtf8, indexEntries, indexOrderTuple, isKeyValue, matchesQuery, normalizeStoredRow, normalizeStoredValue } from "./database/values.mjs";
7
+ import { createMemoryAdapter } from "./database/memoryAdapter.mjs";
8
+ import { DatabaseAdapterContractError, verifyAdapter } from "./database/verifyAdapter.mjs";
9
+ export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapterContractError, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseValueError, addInsightsDistinct, assertBundleEventRow, canonicalJson, compareKeyValues, compareTuples, compareUtf8, countInsightsDistinct, createMemoryAdapter, createValidatedInsightsModel, currentInsightsReleaseId, emptyInsightsDistinct, findPhysicalColumn, findPhysicalIndex, getInsightsDistinctRegister, indexEntries, indexOrderColumns, indexOrderTuple, insightsDistributionIdentity, insightsKey, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues, isKeyValue, matchesQuery, mergeInsightsDistinct, normalizeStoredRow, normalizeStoredValue, rowKey, verifyAdapter };
@@ -283,7 +283,7 @@ function compileAppVersion(releases) {
283
283
  ...segment,
284
284
  releaseIndexes: releases.filter((release) => retainedIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0),
285
285
  rollbackReleaseIndexes: releases.filter((release) => rollbackIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0)
286
- })).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0));
286
+ }))).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0);
287
287
  return {
288
288
  envelope: {
289
289
  fallbackPolicy: _hot_updater_core.RELEASE_CATALOG_FALLBACK_POLICY,
@@ -1,7 +1,7 @@
1
- import { isUUIDv7 as isUUIDv7$1 } from "./uuidv7.mjs";
2
1
  import { t as compare } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs";
3
2
  import { f as satisfies, m as parseRange } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs";
4
3
  import { m as normalizeFull, n as coerce, p as normalize } from "./node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs";
4
+ import { isUUIDv7 as isUUIDv7$1 } from "./uuidv7.mjs";
5
5
  import { MAX_COMPILED_CATALOG_BYTES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_TARGET_COHORTS_PER_RELEASE, NUMERIC_COHORT_SIZE, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, getNumericCohortValue, getRolledOutNumericCohorts, isCustomCohort, normalizeCohortValue, normalizeRolloutCohortCount } from "@hot-updater/core";
6
6
  //#region src/releaseCatalogCompiler.ts
7
7
  var ReleaseCatalogCompilationError = class extends Error {
@@ -284,7 +284,7 @@ function compileAppVersion(releases) {
284
284
  ...segment,
285
285
  releaseIndexes: releases.filter((release) => retainedIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0),
286
286
  rollbackReleaseIndexes: releases.filter((release) => rollbackIds.has(release.id)).map((release) => descriptorIndex.get(release.id)).filter((index) => index !== void 0)
287
- })).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0));
287
+ }))).filter((segment) => segment.releaseIndexes.length > 0 || segment.rollbackReleaseIndexes.length > 0);
288
288
  return {
289
289
  envelope: {
290
290
  fallbackPolicy: RELEASE_CATALOG_FALLBACK_POLICY,
@@ -1,10 +1,4 @@
1
- const require_uuidv7 = require("./uuidv7.cjs");
2
- const require_databaseRows = require("./databaseRows.cjs");
3
- const require_releaseCatalogCompiler = require("./releaseCatalogCompiler.cjs");
4
- let _hot_updater_core = require("@hot-updater/core");
5
1
  //#region src/releaseCatalogMutation.ts
6
- const RELEASE_PAGE_SIZE = 1e3;
7
- const DEFAULT_MAX_ATTEMPTS = 3;
8
2
  var ReleaseCatalogMutationError = class extends Error {
9
3
  code;
10
4
  name = "ReleaseCatalogMutationError";
@@ -13,291 +7,5 @@ var ReleaseCatalogMutationError = class extends Error {
13
7
  this.code = code;
14
8
  }
15
9
  };
16
- const readScopeReleases = async (database, scopeKey) => {
17
- const releases = [];
18
- let afterReleaseId;
19
- for (;;) {
20
- const page = await database.models.releases.findManyByScope({
21
- scopeKey,
22
- ...afterReleaseId === void 0 ? {} : { afterReleaseId },
23
- limit: RELEASE_PAGE_SIZE,
24
- consistency: "strong"
25
- });
26
- for (const row of page) {
27
- if (row.scope_key !== scopeKey) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release "${row.id}" was returned for the wrong catalog scope`);
28
- if (releases.at(-1)?.id === row.id) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release "${row.id}" was returned more than once`);
29
- releases.push(row);
30
- }
31
- if (page.length < RELEASE_PAGE_SIZE) return releases;
32
- const next = page.at(-1)?.id;
33
- if (next === void 0 || next === afterReleaseId) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release scope paging did not advance");
34
- afterReleaseId = next;
35
- }
36
- };
37
- const validateScope = (scope) => {
38
- const channelKey = (0, _hot_updater_core.encodeChannelKey)(scope.channelName);
39
- if (scope.strategy === "FINGERPRINT" !== (scope.fingerprintHash !== null)) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release catalog strategy and fingerprint are inconsistent");
40
- const expectedScopeKey = scope.strategy === "APP_VERSION" ? (0, _hot_updater_core.createReleaseCatalogScopeKey)({
41
- channelKey,
42
- platform: scope.platform,
43
- strategy: "APP_VERSION"
44
- }) : (0, _hot_updater_core.createReleaseCatalogScopeKey)({
45
- channelKey,
46
- fingerprintHash: scope.fingerprintHash ?? "",
47
- platform: scope.platform,
48
- strategy: "FINGERPRINT"
49
- });
50
- if (scope.scopeKey !== expectedScopeKey) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Release catalog scope metadata is inconsistent");
51
- };
52
- const applyMutation = (rows, scope, mutation) => {
53
- const currentIndex = mutation.operation === "insert" ? -1 : rows.findIndex(({ id }) => id === mutation.id);
54
- const current = currentIndex < 0 ? void 0 : rows[currentIndex];
55
- if (mutation.operation === "insert") {
56
- const latestId = rows.at(-1)?.id;
57
- if (mutation.row.scope_key !== scope.scopeKey || mutation.row.channel_id !== scope.channelId || mutation.row.platform !== scope.platform || mutation.row.strategy !== scope.strategy || mutation.row.fingerprint_hash !== scope.fingerprintHash || mutation.row.revision !== 1) throw new ReleaseCatalogMutationError("INVALID_SCOPE", "Inserted Release does not match its catalog scope");
58
- if (latestId !== void 0 && mutation.row.id <= latestId) throw new ReleaseCatalogMutationError("NON_MONOTONIC_RELEASE_ID", `Release "${mutation.row.id}" must sort after "${latestId}"`);
59
- return {
60
- change: {
61
- model: "releases",
62
- operation: "insert",
63
- row: mutation.row
64
- },
65
- expectedRevision: null,
66
- nextRows: [...rows, mutation.row],
67
- release: mutation.row
68
- };
69
- }
70
- if (current === void 0) throw new ReleaseCatalogMutationError("RELEASE_NOT_FOUND", `Release "${mutation.id}" was not found in scope "${scope.scopeKey}"`);
71
- if (mutation.operation === "delete") return {
72
- change: {
73
- model: "releases",
74
- operation: "delete",
75
- where: { id: mutation.id }
76
- },
77
- expectedRevision: current.revision,
78
- nextRows: rows.filter(({ id }) => id !== mutation.id),
79
- release: null
80
- };
81
- const release = {
82
- ...current,
83
- ...mutation.update,
84
- revision: current.revision + 1
85
- };
86
- return {
87
- change: {
88
- model: "releases",
89
- operation: "update",
90
- where: { id: mutation.id },
91
- update: {
92
- ...mutation.update,
93
- revision: release.revision
94
- }
95
- },
96
- expectedRevision: current.revision,
97
- nextRows: rows.map((row) => row.id === release.id ? release : row),
98
- release
99
- };
100
- };
101
- const catalogIdentity = (current, rows) => {
102
- if (current !== null) return current.catalog_id;
103
- if (rows.length > 0) throw new ReleaseCatalogMutationError("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
104
- return require_uuidv7.createUUIDv7();
105
- };
106
- const readCatalogScope = async (database, scopeKey) => {
107
- let currentCatalog = await database.models.releaseCatalogs.findByScopeKey(scopeKey);
108
- let rows = await readScopeReleases(database, scopeKey);
109
- if (currentCatalog === null && rows.length > 0) {
110
- currentCatalog = await database.models.releaseCatalogs.findByScopeKey(scopeKey);
111
- if (currentCatalog !== null) rows = await readScopeReleases(database, scopeKey);
112
- }
113
- return {
114
- currentCatalog,
115
- rows
116
- };
117
- };
118
- const prepareReleaseCatalogMutation = async (database, mutationInput) => {
119
- const { rows, currentCatalog } = await readCatalogScope(database, mutationInput.scope.scopeKey);
120
- const applied = applyMutation(rows, mutationInput.scope, mutationInput.mutation);
121
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
122
- strategy: mutationInput.scope.strategy,
123
- releases: applied.nextRows.map(require_databaseRows.releaseRowToRelease)
124
- });
125
- const generation = (currentCatalog?.generation ?? 0) + 1;
126
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${mutationInput.scope.scopeKey}" exhausted its generation counter`);
127
- return {
128
- applied,
129
- catalog: {
130
- scope_key: mutationInput.scope.scopeKey,
131
- catalog_id: catalogIdentity(currentCatalog, rows),
132
- strategy: mutationInput.scope.strategy,
133
- channel_id: mutationInput.scope.channelId,
134
- channel_key: (0, _hot_updater_core.encodeChannelKey)(mutationInput.scope.channelName),
135
- platform: mutationInput.scope.platform,
136
- fingerprint_hash: mutationInput.scope.fingerprintHash,
137
- generation,
138
- payload: compilation.canonicalPayload,
139
- catalog_hash: compilation.catalogHash,
140
- byte_size: compilation.byteSize,
141
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
142
- updated_at_ms: mutationInput.updatedAtMs ?? Date.now()
143
- },
144
- compilation,
145
- currentCatalog,
146
- mutationInput
147
- };
148
- };
149
- async function preflightReleaseCatalogMutation(input) {
150
- validateScope(input.scope);
151
- const prepared = await prepareReleaseCatalogMutation(input.database, input);
152
- return {
153
- catalog: prepared.catalog,
154
- currentCatalog: prepared.currentCatalog,
155
- diagnostics: prepared.compilation.diagnostics,
156
- expectedReleaseRevision: prepared.applied.expectedRevision,
157
- release: prepared.applied.release
158
- };
159
- }
160
- async function commitReleaseCatalogMutations(input) {
161
- if (input.mutations.length === 0) return [];
162
- const scopeKeys = /* @__PURE__ */ new Set();
163
- for (const mutation of input.mutations) {
164
- validateScope(mutation.scope);
165
- if (scopeKeys.has(mutation.scope.scopeKey)) throw new ReleaseCatalogMutationError("INVALID_SCOPE", `A batch cannot mutate catalog scope "${mutation.scope.scopeKey}" more than once`);
166
- scopeKeys.add(mutation.scope.scopeKey);
167
- }
168
- const maxAttempts = input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
169
- if (!Number.isSafeInteger(maxAttempts) || maxAttempts <= 0) throw new RangeError("maxAttempts must be a positive safe integer");
170
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
171
- const prepared = await Promise.all(input.mutations.map((mutationInput) => prepareReleaseCatalogMutation(input.database, mutationInput)));
172
- const result = await input.database.commit({
173
- expectations: prepared.flatMap(({ applied, currentCatalog, mutationInput }) => [{
174
- model: "releases",
175
- id: mutationInput.mutation.operation === "insert" ? mutationInput.mutation.row.id : mutationInput.mutation.id,
176
- revision: applied.expectedRevision
177
- }, {
178
- model: "releaseCatalogs",
179
- scopeKey: mutationInput.scope.scopeKey,
180
- generation: currentCatalog?.generation ?? null
181
- }]),
182
- changes: prepared.flatMap(({ applied, catalog, mutationInput }) => [
183
- ...mutationInput.companionChanges ?? [],
184
- applied.change,
185
- {
186
- model: "releaseCatalogs",
187
- operation: "put",
188
- row: catalog
189
- },
190
- ...mutationInput.trailingChanges ?? []
191
- ])
192
- });
193
- if (result.committed) return prepared.map(({ applied, catalog }) => ({
194
- attempts: attempt,
195
- catalog,
196
- release: applied.release
197
- }));
198
- if (result.conflict.reason !== "version_conflict") throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release mutation failed: ${result.conflict.reason}`);
199
- }
200
- throw new ReleaseCatalogMutationError("VERSION_CONFLICT", `Release catalog mutation batch conflicted ${maxAttempts} times`);
201
- }
202
- async function commitReleaseCatalogMutation(input) {
203
- const [result] = await commitReleaseCatalogMutations({
204
- database: input.database,
205
- maxAttempts: input.maxAttempts,
206
- mutations: [input]
207
- });
208
- return result;
209
- }
210
- const catalogProjectionMatches = (current, scope, compilation) => current.strategy === scope.strategy && current.channel_id === scope.channelId && current.channel_key === (0, _hot_updater_core.encodeChannelKey)(scope.channelName) && current.platform === scope.platform && current.fingerprint_hash === scope.fingerprintHash && current.payload === compilation.canonicalPayload && current.catalog_hash === compilation.catalogHash && current.byte_size === compilation.byteSize && current.is_tombstone === (compilation.payload.releaseDescriptors.length === 0);
211
- async function preflightReleaseCatalogRebuild(input) {
212
- validateScope(input.scope);
213
- const { rows, currentCatalog } = await readCatalogScope(input.database, input.scope.scopeKey);
214
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
215
- releases: rows.map(require_databaseRows.releaseRowToRelease),
216
- strategy: input.scope.strategy
217
- });
218
- const changed = currentCatalog === null || !catalogProjectionMatches(currentCatalog, input.scope, compilation);
219
- const generation = changed ? (currentCatalog?.generation ?? 0) + 1 : currentCatalog.generation;
220
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${input.scope.scopeKey}" exhausted its generation counter`);
221
- return {
222
- changed,
223
- currentCatalog,
224
- diagnostics: compilation.diagnostics,
225
- projectedCatalog: {
226
- catalog_id: catalogIdentity(currentCatalog, rows),
227
- byte_size: compilation.byteSize,
228
- catalog_hash: compilation.catalogHash,
229
- channel_id: input.scope.channelId,
230
- channel_key: (0, _hot_updater_core.encodeChannelKey)(input.scope.channelName),
231
- fingerprint_hash: input.scope.fingerprintHash,
232
- generation,
233
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
234
- payload: compilation.canonicalPayload,
235
- platform: input.scope.platform,
236
- scope_key: input.scope.scopeKey,
237
- strategy: input.scope.strategy,
238
- updated_at_ms: changed || currentCatalog === null ? input.updatedAtMs ?? Date.now() : currentCatalog.updated_at_ms
239
- }
240
- };
241
- }
242
- async function rebuildReleaseCatalog(input) {
243
- validateScope(input.scope);
244
- const maxAttempts = input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
245
- if (!Number.isSafeInteger(maxAttempts) || maxAttempts <= 0) throw new RangeError("maxAttempts must be a positive safe integer");
246
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
247
- const { rows, currentCatalog } = await readCatalogScope(input.database, input.scope.scopeKey);
248
- const compilation = await require_releaseCatalogCompiler.compileReleaseCatalog({
249
- releases: rows.map(require_databaseRows.releaseRowToRelease),
250
- strategy: input.scope.strategy
251
- });
252
- if (currentCatalog !== null && catalogProjectionMatches(currentCatalog, input.scope, compilation)) return {
253
- attempts: attempt,
254
- catalog: currentCatalog,
255
- changed: false,
256
- diagnostics: compilation.diagnostics
257
- };
258
- const generation = (currentCatalog?.generation ?? 0) + 1;
259
- if (!Number.isSafeInteger(generation)) throw new ReleaseCatalogMutationError("CATALOG_GENERATION_EXHAUSTED", `Catalog "${input.scope.scopeKey}" exhausted its generation counter`);
260
- const catalog = {
261
- catalog_id: catalogIdentity(currentCatalog, rows),
262
- byte_size: compilation.byteSize,
263
- catalog_hash: compilation.catalogHash,
264
- channel_id: input.scope.channelId,
265
- channel_key: (0, _hot_updater_core.encodeChannelKey)(input.scope.channelName),
266
- fingerprint_hash: input.scope.fingerprintHash,
267
- generation,
268
- is_tombstone: compilation.payload.releaseDescriptors.length === 0,
269
- payload: compilation.canonicalPayload,
270
- platform: input.scope.platform,
271
- scope_key: input.scope.scopeKey,
272
- strategy: input.scope.strategy,
273
- updated_at_ms: input.updatedAtMs ?? Date.now()
274
- };
275
- const result = await input.database.commit({
276
- changes: [{
277
- model: "releaseCatalogs",
278
- operation: "put",
279
- row: catalog
280
- }],
281
- expectations: [{
282
- generation: currentCatalog?.generation ?? null,
283
- model: "releaseCatalogs",
284
- scopeKey: input.scope.scopeKey
285
- }]
286
- });
287
- if (result.committed) return {
288
- attempts: attempt,
289
- catalog,
290
- changed: true,
291
- diagnostics: compilation.diagnostics
292
- };
293
- if (result.conflict.reason !== "version_conflict") throw new ReleaseCatalogMutationError("INVALID_SCOPE", `Release catalog rebuild failed: ${result.conflict.reason}`);
294
- }
295
- throw new ReleaseCatalogMutationError("VERSION_CONFLICT", `Release catalog rebuild conflicted ${maxAttempts} times`);
296
- }
297
10
  //#endregion
298
11
  exports.ReleaseCatalogMutationError = ReleaseCatalogMutationError;
299
- exports.commitReleaseCatalogMutation = commitReleaseCatalogMutation;
300
- exports.commitReleaseCatalogMutations = commitReleaseCatalogMutations;
301
- exports.preflightReleaseCatalogMutation = preflightReleaseCatalogMutation;
302
- exports.preflightReleaseCatalogRebuild = preflightReleaseCatalogRebuild;
303
- exports.rebuildReleaseCatalog = rebuildReleaseCatalog;
@@ -1,9 +1,8 @@
1
+ import { ReleaseCatalogCompilation } from "./releaseCatalogCompiler.cjs";
1
2
  import { ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
2
- import { BundleRepository, DatabaseChange } from "./types/databasePlugin.cjs";
3
- import { ReleaseRowUpdate } from "./types/databaseOperations.cjs";
4
3
  import "./types/index.cjs";
5
- import { ReleaseCatalogCompilation } from "./releaseCatalogCompiler.cjs";
6
4
  //#region src/releaseCatalogMutation.d.ts
5
+ /** One Release Catalog: a channel, platform, and target kind. */
7
6
  interface ReleaseCatalogScope {
8
7
  readonly channelId: string;
9
8
  readonly channelName: string;
@@ -12,17 +11,6 @@ interface ReleaseCatalogScope {
12
11
  readonly strategy: "APP_VERSION" | "FINGERPRINT";
13
12
  readonly fingerprintHash: string | null;
14
13
  }
15
- type ReleaseCatalogMutation = {
16
- readonly operation: "insert";
17
- readonly row: ReleaseRow;
18
- } | {
19
- readonly operation: "update";
20
- readonly id: string;
21
- readonly update: Omit<ReleaseRowUpdate, "revision" | "scope_key">;
22
- } | {
23
- readonly operation: "delete";
24
- readonly id: string;
25
- };
26
14
  interface ReleaseCatalogMutationResult {
27
15
  readonly attempts: number;
28
16
  readonly catalog: ReleaseCatalogRow;
@@ -33,13 +21,7 @@ declare class ReleaseCatalogMutationError extends Error {
33
21
  readonly name = "ReleaseCatalogMutationError";
34
22
  constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
35
23
  }
36
- interface ReleaseCatalogMutationInput {
37
- readonly scope: ReleaseCatalogScope;
38
- readonly mutation: ReleaseCatalogMutation;
39
- readonly companionChanges?: readonly DatabaseChange[];
40
- readonly trailingChanges?: readonly DatabaseChange[];
41
- readonly updatedAtMs?: number;
42
- }
24
+ /** What a release change would write, without writing it. */
43
25
  interface ReleaseCatalogMutationPreflight {
44
26
  readonly catalog: ReleaseCatalogRow;
45
27
  readonly currentCatalog: ReleaseCatalogRow | null;
@@ -47,18 +29,6 @@ interface ReleaseCatalogMutationPreflight {
47
29
  readonly expectedReleaseRevision: number | null;
48
30
  readonly release: ReleaseRow | null;
49
31
  }
50
- declare function preflightReleaseCatalogMutation(input: ReleaseCatalogMutationInput & {
51
- readonly database: BundleRepository;
52
- }): Promise<ReleaseCatalogMutationPreflight>;
53
- declare function commitReleaseCatalogMutations(input: {
54
- readonly database: BundleRepository;
55
- readonly mutations: readonly ReleaseCatalogMutationInput[];
56
- readonly maxAttempts?: number;
57
- }): Promise<readonly ReleaseCatalogMutationResult[]>;
58
- declare function commitReleaseCatalogMutation(input: ReleaseCatalogMutationInput & {
59
- readonly database: BundleRepository;
60
- readonly maxAttempts?: number;
61
- }): Promise<ReleaseCatalogMutationResult>;
62
32
  interface ReleaseCatalogRebuildResult {
63
33
  readonly attempts: number;
64
34
  readonly catalog: ReleaseCatalogRow;
@@ -71,16 +41,5 @@ interface ReleaseCatalogRebuildPreflight {
71
41
  readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
72
42
  readonly projectedCatalog: ReleaseCatalogRow;
73
43
  }
74
- declare function preflightReleaseCatalogRebuild(input: {
75
- readonly database: BundleRepository;
76
- readonly scope: ReleaseCatalogScope;
77
- readonly updatedAtMs?: number;
78
- }): Promise<ReleaseCatalogRebuildPreflight>;
79
- declare function rebuildReleaseCatalog(input: {
80
- readonly database: BundleRepository;
81
- readonly maxAttempts?: number;
82
- readonly scope: ReleaseCatalogScope;
83
- readonly updatedAtMs?: number;
84
- }): Promise<ReleaseCatalogRebuildResult>;
85
44
  //#endregion
86
- export { ReleaseCatalogMutation, ReleaseCatalogMutationError, ReleaseCatalogMutationInput, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope, commitReleaseCatalogMutation, commitReleaseCatalogMutations, preflightReleaseCatalogMutation, preflightReleaseCatalogRebuild, rebuildReleaseCatalog };
45
+ export { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope };
@@ -1,9 +1,8 @@
1
+ import { ReleaseCatalogCompilation } from "./releaseCatalogCompiler.mjs";
1
2
  import { ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
2
- import { BundleRepository, DatabaseChange } from "./types/databasePlugin.mjs";
3
- import { ReleaseRowUpdate } from "./types/databaseOperations.mjs";
4
3
  import "./types/index.mjs";
5
- import { ReleaseCatalogCompilation } from "./releaseCatalogCompiler.mjs";
6
4
  //#region src/releaseCatalogMutation.d.ts
5
+ /** One Release Catalog: a channel, platform, and target kind. */
7
6
  interface ReleaseCatalogScope {
8
7
  readonly channelId: string;
9
8
  readonly channelName: string;
@@ -12,17 +11,6 @@ interface ReleaseCatalogScope {
12
11
  readonly strategy: "APP_VERSION" | "FINGERPRINT";
13
12
  readonly fingerprintHash: string | null;
14
13
  }
15
- type ReleaseCatalogMutation = {
16
- readonly operation: "insert";
17
- readonly row: ReleaseRow;
18
- } | {
19
- readonly operation: "update";
20
- readonly id: string;
21
- readonly update: Omit<ReleaseRowUpdate, "revision" | "scope_key">;
22
- } | {
23
- readonly operation: "delete";
24
- readonly id: string;
25
- };
26
14
  interface ReleaseCatalogMutationResult {
27
15
  readonly attempts: number;
28
16
  readonly catalog: ReleaseCatalogRow;
@@ -33,13 +21,7 @@ declare class ReleaseCatalogMutationError extends Error {
33
21
  readonly name = "ReleaseCatalogMutationError";
34
22
  constructor(code: "CATALOG_GENERATION_EXHAUSTED" | "CATALOG_IDENTITY_MISSING" | "INVALID_SCOPE" | "NON_MONOTONIC_RELEASE_ID" | "RELEASE_NOT_FOUND" | "VERSION_CONFLICT", message: string);
35
23
  }
36
- interface ReleaseCatalogMutationInput {
37
- readonly scope: ReleaseCatalogScope;
38
- readonly mutation: ReleaseCatalogMutation;
39
- readonly companionChanges?: readonly DatabaseChange[];
40
- readonly trailingChanges?: readonly DatabaseChange[];
41
- readonly updatedAtMs?: number;
42
- }
24
+ /** What a release change would write, without writing it. */
43
25
  interface ReleaseCatalogMutationPreflight {
44
26
  readonly catalog: ReleaseCatalogRow;
45
27
  readonly currentCatalog: ReleaseCatalogRow | null;
@@ -47,18 +29,6 @@ interface ReleaseCatalogMutationPreflight {
47
29
  readonly expectedReleaseRevision: number | null;
48
30
  readonly release: ReleaseRow | null;
49
31
  }
50
- declare function preflightReleaseCatalogMutation(input: ReleaseCatalogMutationInput & {
51
- readonly database: BundleRepository;
52
- }): Promise<ReleaseCatalogMutationPreflight>;
53
- declare function commitReleaseCatalogMutations(input: {
54
- readonly database: BundleRepository;
55
- readonly mutations: readonly ReleaseCatalogMutationInput[];
56
- readonly maxAttempts?: number;
57
- }): Promise<readonly ReleaseCatalogMutationResult[]>;
58
- declare function commitReleaseCatalogMutation(input: ReleaseCatalogMutationInput & {
59
- readonly database: BundleRepository;
60
- readonly maxAttempts?: number;
61
- }): Promise<ReleaseCatalogMutationResult>;
62
32
  interface ReleaseCatalogRebuildResult {
63
33
  readonly attempts: number;
64
34
  readonly catalog: ReleaseCatalogRow;
@@ -71,16 +41,5 @@ interface ReleaseCatalogRebuildPreflight {
71
41
  readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
72
42
  readonly projectedCatalog: ReleaseCatalogRow;
73
43
  }
74
- declare function preflightReleaseCatalogRebuild(input: {
75
- readonly database: BundleRepository;
76
- readonly scope: ReleaseCatalogScope;
77
- readonly updatedAtMs?: number;
78
- }): Promise<ReleaseCatalogRebuildPreflight>;
79
- declare function rebuildReleaseCatalog(input: {
80
- readonly database: BundleRepository;
81
- readonly maxAttempts?: number;
82
- readonly scope: ReleaseCatalogScope;
83
- readonly updatedAtMs?: number;
84
- }): Promise<ReleaseCatalogRebuildResult>;
85
44
  //#endregion
86
- export { ReleaseCatalogMutation, ReleaseCatalogMutationError, ReleaseCatalogMutationInput, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope, commitReleaseCatalogMutation, commitReleaseCatalogMutations, preflightReleaseCatalogMutation, preflightReleaseCatalogRebuild, rebuildReleaseCatalog };
45
+ export { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope };