@hot-updater/plugin-core 1.2.0-rc.50 → 1.2.0-rc.51

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 (37) hide show
  1. package/dist/coreApi.d.cts +32 -1
  2. package/dist/coreApi.d.mts +32 -1
  3. package/dist/database/adapter.d.cts +12 -0
  4. package/dist/database/adapter.d.mts +12 -0
  5. package/dist/databaseRows.cjs +4 -2
  6. package/dist/databaseRows.mjs +4 -2
  7. package/dist/engine/core/schema.cjs +55 -3
  8. package/dist/engine/core/schema.d.cts +27 -0
  9. package/dist/engine/core/schema.d.mts +27 -0
  10. package/dist/engine/core/schema.mjs +55 -4
  11. package/dist/engine/database/sql/sqlAdapter.cjs +27 -8
  12. package/dist/engine/database/sql/sqlAdapter.mjs +28 -9
  13. package/dist/engine/db/engineMigrator.cjs +32 -9
  14. package/dist/engine/db/engineMigrator.mjs +33 -10
  15. package/dist/engine/db/engineSql.cjs +25 -0
  16. package/dist/engine/db/engineSql.d.cts +13 -1
  17. package/dist/engine/db/engineSql.d.mts +13 -1
  18. package/dist/engine/db/engineSql.mjs +26 -2
  19. package/dist/engine/db/engineSqlMigrator.cjs +12 -6
  20. package/dist/engine/db/engineSqlMigrator.mjs +13 -7
  21. package/dist/engine/db/schemaSettings.cjs +22 -2
  22. package/dist/engine/db/schemaSettings.mjs +23 -4
  23. package/dist/engine/db/settingsMigrator.cjs +40 -9
  24. package/dist/engine/db/settingsMigrator.mjs +41 -10
  25. package/dist/engine/db/sqlSchemaState.cjs +36 -8
  26. package/dist/engine/db/sqlSchemaState.mjs +36 -9
  27. package/dist/index.cjs +1 -0
  28. package/dist/index.d.cts +3 -3
  29. package/dist/index.d.mts +3 -3
  30. package/dist/index.mjs +2 -2
  31. package/dist/releaseCatalogCompiler.cjs +18 -7
  32. package/dist/releaseCatalogCompiler.mjs +18 -7
  33. package/dist/releaseCatalogMutation.d.cts +6 -0
  34. package/dist/releaseCatalogMutation.d.mts +6 -0
  35. package/dist/types/databaseRows.d.cts +7 -0
  36. package/dist/types/databaseRows.d.mts +7 -0
  37. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { LATE_COLUMNS } from "../core/schema.mjs";
1
2
  import { SETTINGS_TABLE } from "../database/fence.mjs";
2
3
  import { quoteSql, sqlTableShapes } from "../database/sql/sqlSchema.mjs";
3
4
  //#region src/engine/db/sqlSchemaState.ts
@@ -29,34 +30,54 @@ const fold = (dialect, name) => dialect === "mysql" ? String(name).toLowerCase()
29
30
  const CATALOG = {
30
31
  postgresql: {
31
32
  tables: "SELECT c.relname AS t FROM pg_class c WHERE c.relkind IN ('r', 'p') AND pg_table_is_visible(c.oid)",
32
- indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)"
33
+ indexes: "SELECT t.relname AS t, c.relname AS i FROM pg_index x JOIN pg_class c ON c.oid = x.indexrelid JOIN pg_class t ON t.oid = x.indrelid WHERE pg_table_is_visible(t.oid)",
34
+ columns: "SELECT c.relname AS t, a.attname AS c FROM pg_attribute a JOIN pg_class c ON c.oid = a.attrelid WHERE c.relkind IN ('r', 'p') AND a.attnum > 0 AND NOT a.attisdropped AND pg_table_is_visible(c.oid)"
33
35
  },
34
36
  mysql: {
35
37
  tables: "SELECT TABLE_NAME AS t FROM information_schema.tables WHERE TABLE_SCHEMA = DATABASE()",
36
- indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()"
38
+ indexes: "SELECT DISTINCT TABLE_NAME AS t, INDEX_NAME AS i FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE()",
39
+ columns: "SELECT TABLE_NAME AS t, COLUMN_NAME AS c FROM information_schema.columns WHERE TABLE_SCHEMA = DATABASE()"
37
40
  },
38
41
  sqlite: {
39
42
  tables: "SELECT name AS t FROM sqlite_master WHERE type = 'table'",
40
- indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'"
43
+ indexes: "SELECT tbl_name AS t, name AS i FROM sqlite_master WHERE type = 'index'",
44
+ columns: "SELECT m.name AS t, p.name AS c FROM sqlite_master m JOIN pragma_table_info(m.name) p WHERE m.type = 'table'"
41
45
  }
42
46
  };
43
- /** Reads which tables and indexes exist: two catalog reads. */
47
+ /** Reads which tables, indexes and columns exist: three catalog reads. */
44
48
  const readSqlSchemaState = async (executor) => {
45
49
  const { dialect } = executor;
46
50
  const read = (sql) => executor.execute({
47
51
  sql,
48
52
  params: []
49
53
  });
50
- const [tables, indexes] = await Promise.all([read(CATALOG[dialect].tables), read(CATALOG[dialect].indexes)]);
54
+ const [tables, indexes, columns] = await Promise.all([
55
+ read(CATALOG[dialect].tables),
56
+ read(CATALOG[dialect].indexes),
57
+ read(CATALOG[dialect].columns)
58
+ ]);
59
+ const columnNames = new Set(columns.rows.map(({ t, c }) => JSON.stringify([fold(dialect, t), fold(dialect, c)])));
51
60
  const tableNames = new Set(tables.rows.map(({ t }) => fold(dialect, t)));
52
61
  const indexNames = new Set(indexes.rows.map(({ t, i }) => JSON.stringify([fold(dialect, t), fold(dialect, i)])));
53
62
  return {
54
63
  hasTable: (table) => tableNames.has(fold(dialect, table)),
55
- hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)]))
64
+ hasIndex: (table, index) => indexNames.has(JSON.stringify([fold(dialect, table), fold(dialect, index)])),
65
+ hasColumn: (table, column) => columnNames.has(JSON.stringify([fold(dialect, table), fold(dialect, column)]))
56
66
  };
57
67
  };
58
- /** The declared tables and indexes the database lacks. */
59
- const missingSqlSchema = (shapes, state) => ({
68
+ /**
69
+ * The declared tables, indexes and late columns the database lacks. An index
70
+ * on a late column is missing too while the column is.
71
+ */
72
+ const missingSqlSchema = (shapes, state, tablePrefix = "") => ({
73
+ columns: LATE_COLUMNS.flatMap(({ table, column }) => {
74
+ const shape = shapes.find(({ name }) => name === tablePrefix + table);
75
+ const declared = shape?.columns.find(({ name }) => name === column);
76
+ return shape === void 0 || declared === void 0 || !state.hasTable(shape.name) || state.hasColumn(shape.name, column) ? [] : [{
77
+ table: shape.name,
78
+ column: declared
79
+ }];
80
+ }),
60
81
  tables: shapes.filter((shape) => !state.hasTable(shape.name)).map((shape) => shape.name),
61
82
  indexes: shapes.filter((shape) => state.hasTable(shape.name)).flatMap((shape) => shape.indexes.flatMap((index) => index.kind === "index" && !state.hasIndex(shape.name, index.name) ? [{
62
83
  table: shape.name,
@@ -100,5 +121,11 @@ const collationStatements = async (executor, shapes, collate) => {
100
121
  columns
101
122
  };
102
123
  };
124
+ /**
125
+ * `ALTER TABLE … ADD COLUMN` for each late column a table lacks, which run
126
+ * before the statements that create the table's indexes. Each is nullable,
127
+ * so rows written before it read as null.
128
+ */
129
+ const addColumnStatements = (dialect, columns) => columns.map(({ table, column }) => `ALTER TABLE ${quoteSql(dialect, table)} ADD COLUMN ${quoteSql(dialect, column.name)} ${column.type}`);
103
130
  //#endregion
104
- export { collationStatements, flattenShapes, missingSqlSchema, readSqlSchemaState, targetShapes };
131
+ export { addColumnStatements, collationStatements, flattenShapes, missingSqlSchema, readSqlSchemaState, targetShapes };
package/dist/index.cjs CHANGED
@@ -126,6 +126,7 @@ Object.defineProperty(exports, "isUUIDv7", {
126
126
  return _hot_updater_protocol.isUUIDv7;
127
127
  }
128
128
  });
129
+ exports.lateColumnStatements = require_engineSql.lateColumnStatements;
129
130
  exports.mergeDistinct = require_distinct.mergeDistinct;
130
131
  exports.meterReads = require_readMeter.meterReads;
131
132
  exports.migrateCoreSchema = require_coreDatabase.migrateCoreSchema;
package/dist/index.d.cts CHANGED
@@ -21,7 +21,7 @@ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, Nati
21
21
  import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, ConfigInput, FingerprintExtraSources, IosBuildDestination, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeBuildSandboxOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, resolveLazy, supportedIosPlatforms } from "./types/index.cjs";
22
22
  import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.cjs";
23
23
  import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.cjs";
24
- import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
24
+ import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseLabelFill, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
25
25
  import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.cjs";
26
26
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
27
27
  import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.cjs";
@@ -47,8 +47,8 @@ import { KeyValueStore, KvAdapterOptions, KvCondition, KvItem, KvKey, KvOp, KvRa
47
47
  import { MeteredDatabase, ReadMeasurement, meterReads } from "./engine/database/readMeter.cjs";
48
48
  import { SqlColumnShape, SqlDialect, SqlTableShape, createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.cjs";
49
49
  import { SqlAdapterOptions, SqlConnection, SqlExecutor, SqlResult, SqlStatement, WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.cjs";
50
- import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.cjs";
50
+ import { EngineSqlOptions, generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.cjs";
51
51
  import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.cjs";
52
52
  import { writeSchemaSettings } from "./engine/db/schemaSettings.cjs";
53
53
  import { createSettingsMigrator } from "./engine/db/settingsMigrator.cjs";
54
- export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
54
+ export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, type ReleaseLabelFill, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
package/dist/index.d.mts CHANGED
@@ -21,7 +21,7 @@ import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult, Nati
21
21
  import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, ConfigInput, FingerprintExtraSources, IosBuildDestination, Lazy, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeBuildSandboxOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, resolveLazy, supportedIosPlatforms } from "./types/index.mjs";
22
22
  import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.mjs";
23
23
  import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.mjs";
24
- import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
24
+ import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseLabelFill, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
25
25
  import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.mjs";
26
26
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
27
27
  import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.mjs";
@@ -47,8 +47,8 @@ import { KeyValueStore, KvAdapterOptions, KvCondition, KvItem, KvKey, KvOp, KvRa
47
47
  import { MeteredDatabase, ReadMeasurement, meterReads } from "./engine/database/readMeter.mjs";
48
48
  import { SqlColumnShape, SqlDialect, SqlTableShape, createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.mjs";
49
49
  import { SqlAdapterOptions, SqlConnection, SqlExecutor, SqlResult, SqlStatement, WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.mjs";
50
- import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.mjs";
50
+ import { EngineSqlOptions, generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.mjs";
51
51
  import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.mjs";
52
52
  import { writeSchemaSettings } from "./engine/db/schemaSettings.mjs";
53
53
  import { createSettingsMigrator } from "./engine/db/settingsMigrator.mjs";
54
- export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
54
+ export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type IosDeviceAccount, type IosDeviceAccountClaim, type IosDeviceOutcome, type IosDeviceOutcomeInput, type IosDeviceRequestResult, type IosDeviceRow, type IosDeviceStatus, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, Lazy, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, type NativeBuildDistribution, type NativeBuildExportMethod, NativeBuildIosScheme, type NativeBuildMarkResult, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, NativeBuildSandboxOptions, type NativeBuildSandboxScope, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, type ReleaseLabelFill, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretRef, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
package/dist/index.mjs CHANGED
@@ -30,7 +30,7 @@ import { DatabaseAdapterContractError, verifyAdapter } from "./database/verifyAd
30
30
  import { HotUpdaterSchemaMigrationRequiredError, SETTINGS_TABLE } from "./engine/database/fence.mjs";
31
31
  import { meterReads } from "./engine/database/readMeter.mjs";
32
32
  import { createTableStatements, isMultiIndex, quoteSql, sqlTableShapes } from "./engine/database/sql/sqlSchema.mjs";
33
- import { generateEngineSql } from "./engine/db/engineSql.mjs";
33
+ import { generateEngineSql, lateColumnStatements } from "./engine/db/engineSql.mjs";
34
34
  import { createSettingsMigrator } from "./engine/db/settingsMigrator.mjs";
35
35
  import { writeSchemaSettings } from "./engine/db/schemaSettings.mjs";
36
36
  import { aggregateBatchingTables, coreSchema, coreSettings, coreTarget, createEngineDatabase, migrateCoreSchema, toolingTargetOf } from "./engine/db/coreDatabase.mjs";
@@ -38,4 +38,4 @@ import { createEngine } from "./engine/createEngine.mjs";
38
38
  import { createKvAdapter, encodeKvKey } from "./engine/database/kv/kvAdapter.mjs";
39
39
  import { WRITE_GUARD_TABLE, createSqlAdapter } from "./engine/database/sql/sqlAdapter.mjs";
40
40
  import { createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.mjs";
41
- export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DATABASE_VERSION_COLUMN, DatabaseAdapterContractError, DatabaseAdapterInputError, DatabaseAmbiguousCommitError, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseTransactionError, HotUpdaterConfigError, HotUpdaterSchemaMigrationRequiredError, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, SETTINGS_TABLE, WRITE_GUARD_TABLE, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
41
+ export { BUNDLE_STORAGE_PREFIX, BundleRowHydrationError, BundleRowHydrationErrorReason, CONTENT_ADDRESSED_ASSET_PREFIX, DATABASE_VERSION_COLUMN, DatabaseAdapterContractError, DatabaseAdapterInputError, DatabaseAmbiguousCommitError, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseRowReferencedError, DatabaseSchemaError, DatabaseTransactionError, HotUpdaterConfigError, HotUpdaterSchemaMigrationRequiredError, ReleaseCatalogCompilationError, ReleaseCatalogMutationError, ReleaseManagementError, SETTINGS_TABLE, WRITE_GUARD_TABLE, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, lateColumnStatements, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, replaceStorageUriKeySuffix, resolveLazy, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
@@ -90,7 +90,8 @@ function rangeToIntervals(range) {
90
90
  throw new ReleaseCatalogCompilationError("INVALID_TARGET_RANGE", `Invalid target app-version range: ${range}`);
91
91
  }
92
92
  }
93
- function releaseDescriptor(release) {
93
+ /** A release's descriptor; its label only when it has one and `labels`. */
94
+ function releaseDescriptor(release, labels) {
94
95
  return {
95
96
  releaseId: release.id,
96
97
  kind: release.kind,
@@ -98,7 +99,8 @@ function releaseDescriptor(release) {
98
99
  rolloutCohortCount: release.rolloutCohortCount,
99
100
  targetCohorts: [...new Set(release.targetCohorts)].sort(),
100
101
  shouldForceUpdate: release.shouldForceUpdate,
101
- message: release.message
102
+ message: release.message,
103
+ ...labels && typeof release.label === "number" ? { label: release.label } : {}
102
104
  };
103
105
  }
104
106
  function validateReleases(releases, strategy) {
@@ -311,12 +313,21 @@ async function compileReleaseCatalog(input) {
311
313
  const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
312
314
  if (targetCohorts.size > _hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${_hot_updater_protocol.MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
313
315
  const { envelope, retainedReleases } = input.strategy === "APP_VERSION" ? compileAppVersion(releases) : compileFingerprint(releases);
314
- const payload = {
315
- ...envelope,
316
- releaseDescriptors: retainedReleases.map(releaseDescriptor)
316
+ const compile = (labels) => {
317
+ const payload = {
318
+ ...envelope,
319
+ releaseDescriptors: retainedReleases.map((release) => releaseDescriptor(release, labels))
320
+ };
321
+ const canonicalPayload = canonicalStringify(payload);
322
+ return {
323
+ payload,
324
+ canonicalPayload,
325
+ byteSize: new TextEncoder().encode(canonicalPayload).byteLength
326
+ };
317
327
  };
318
- const canonicalPayload = canonicalStringify(payload);
319
- const byteSize = new TextEncoder().encode(canonicalPayload).byteLength;
328
+ let compiled = compile(true);
329
+ if (compiled.byteSize > _hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES && retainedReleases.some((release) => typeof release.label === "number")) compiled = compile(false);
330
+ const { payload, canonicalPayload, byteSize } = compiled;
320
331
  if (byteSize > _hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${_hot_updater_protocol.MAX_COMPILED_CATALOG_BYTES}`);
321
332
  return {
322
333
  byteSize,
@@ -91,7 +91,8 @@ function rangeToIntervals(range) {
91
91
  throw new ReleaseCatalogCompilationError("INVALID_TARGET_RANGE", `Invalid target app-version range: ${range}`);
92
92
  }
93
93
  }
94
- function releaseDescriptor(release) {
94
+ /** A release's descriptor; its label only when it has one and `labels`. */
95
+ function releaseDescriptor(release, labels) {
95
96
  return {
96
97
  releaseId: release.id,
97
98
  kind: release.kind,
@@ -99,7 +100,8 @@ function releaseDescriptor(release) {
99
100
  rolloutCohortCount: release.rolloutCohortCount,
100
101
  targetCohorts: [...new Set(release.targetCohorts)].sort(),
101
102
  shouldForceUpdate: release.shouldForceUpdate,
102
- message: release.message
103
+ message: release.message,
104
+ ...labels && typeof release.label === "number" ? { label: release.label } : {}
103
105
  };
104
106
  }
105
107
  function validateReleases(releases, strategy) {
@@ -312,12 +314,21 @@ async function compileReleaseCatalog(input) {
312
314
  const targetCohorts = new Set(releases.flatMap((release) => release.targetCohorts));
313
315
  if (targetCohorts.size > MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE) throw new ReleaseCatalogCompilationError("DISTINCT_TARGET_COHORT_LIMIT", `Scope exceeds ${MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE} distinct target cohorts`);
314
316
  const { envelope, retainedReleases } = input.strategy === "APP_VERSION" ? compileAppVersion(releases) : compileFingerprint(releases);
315
- const payload = {
316
- ...envelope,
317
- releaseDescriptors: retainedReleases.map(releaseDescriptor)
317
+ const compile = (labels) => {
318
+ const payload = {
319
+ ...envelope,
320
+ releaseDescriptors: retainedReleases.map((release) => releaseDescriptor(release, labels))
321
+ };
322
+ const canonicalPayload = canonicalStringify(payload);
323
+ return {
324
+ payload,
325
+ canonicalPayload,
326
+ byteSize: new TextEncoder().encode(canonicalPayload).byteLength
327
+ };
318
328
  };
319
- const canonicalPayload = canonicalStringify(payload);
320
- const byteSize = new TextEncoder().encode(canonicalPayload).byteLength;
329
+ let compiled = compile(true);
330
+ if (compiled.byteSize > MAX_COMPILED_CATALOG_BYTES && retainedReleases.some((release) => typeof release.label === "number")) compiled = compile(false);
331
+ const { payload, canonicalPayload, byteSize } = compiled;
321
332
  if (byteSize > MAX_COMPILED_CATALOG_BYTES) throw new ReleaseCatalogCompilationError("CATALOG_OVERSIZE", `Compiled Release catalog is ${byteSize} bytes; maximum is ${MAX_COMPILED_CATALOG_BYTES}`);
322
333
  return {
323
334
  byteSize,
@@ -37,6 +37,12 @@ interface ReleaseCatalogRebuildResult {
37
37
  }
38
38
  interface ReleaseCatalogRebuildPreflight {
39
39
  readonly changed: boolean;
40
+ /**
41
+ * Whether the rebuild would change only release labels: a catalog
42
+ * compiled before its releases had them. A server before labels leaves it
43
+ * out.
44
+ */
45
+ readonly labelsOnly?: boolean;
40
46
  readonly currentCatalog: ReleaseCatalogRow | null;
41
47
  readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
42
48
  readonly projectedCatalog: ReleaseCatalogRow;
@@ -37,6 +37,12 @@ interface ReleaseCatalogRebuildResult {
37
37
  }
38
38
  interface ReleaseCatalogRebuildPreflight {
39
39
  readonly changed: boolean;
40
+ /**
41
+ * Whether the rebuild would change only release labels: a catalog
42
+ * compiled before its releases had them. A server before labels leaves it
43
+ * out.
44
+ */
45
+ readonly labelsOnly?: boolean;
40
46
  readonly currentCatalog: ReleaseCatalogRow | null;
41
47
  readonly diagnostics: ReleaseCatalogCompilation["diagnostics"];
42
48
  readonly projectedCatalog: ReleaseCatalogRow;
@@ -46,6 +46,13 @@ interface ReleaseRow {
46
46
  readonly source_release_id: string | null;
47
47
  readonly created_at_ms: number;
48
48
  readonly updated_at_ms: number;
49
+ /**
50
+ * The release's label, shown `v<label>`: sequential per channel and
51
+ * platform, assigned once and never changed or reused while the channel
52
+ * exists. Null on a row the label fill hasn't reached yet, and left out
53
+ * of a row read through an adapter of an earlier release.
54
+ */
55
+ readonly label?: number | null;
49
56
  }
50
57
  interface ReleaseCatalogRow {
51
58
  readonly scope_key: string;
@@ -46,6 +46,13 @@ interface ReleaseRow {
46
46
  readonly source_release_id: string | null;
47
47
  readonly created_at_ms: number;
48
48
  readonly updated_at_ms: number;
49
+ /**
50
+ * The release's label, shown `v<label>`: sequential per channel and
51
+ * platform, assigned once and never changed or reused while the channel
52
+ * exists. Null on a row the label fill hasn't reached yet, and left out
53
+ * of a row read through an adapter of an earlier release.
54
+ */
55
+ readonly label?: number | null;
49
56
  }
50
57
  interface ReleaseCatalogRow {
51
58
  readonly scope_key: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/plugin-core",
3
- "version": "1.2.0-rc.50",
3
+ "version": "1.2.0-rc.51",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -45,7 +45,7 @@
45
45
  "es-toolkit": "^1.32.0",
46
46
  "mime": "^4.0.4",
47
47
  "verkit": "0.4.0",
48
- "@hot-updater/protocol": "1.2.0-rc.50"
48
+ "@hot-updater/protocol": "1.2.0-rc.51"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@electric-sql/pglite": "0.4.1",