Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add core model transpiled files (#2159)
Leendert de Borst7cdd4917bfbb
diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.tsindex 546c008ba..67e2795a3 100644--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts@@ -316,16 +316,10 @@ declare const FieldKey: {*/type FieldKeyValue = typeof FieldKey[keyof typeof FieldKey];-/**- * <auto-generated />- * This file is auto-generated from core/rust/src/vault_codec/types.rs (BUCKET_TABLES).- * Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-bucket-categories.cjs') to regenerate.- *//*** Known data-bucket categories for the manifest-v1 storage format. Each value is one small,* independently-versioned, user-scoped category of encrypted data kept out of the main vault content- * manifest so it syncs cheaply. Serialized as its string name on the wire. The canonical list lives in- * the Rust codec's BUCKET_TABLES.+ * manifest so it syncs cheaply. Serialized as its string name on the wire.*/declare const VaultDataBucketCategory: {/**@@ -341,6 +335,10 @@ declare const VaultDataBucketCategory: {* Type representing all valid vault data bucket category values.*/type VaultDataBucketCategoryValue = typeof VaultDataBucketCategory[keyof typeof VaultDataBucketCategory];+/**+ * Human-readable description per category, emitted into the generated platform variants' doc comments.+ */+declare const VaultDataBucketCategoryDescriptions: Record<VaultDataBucketCategoryValue, string>;type Tag = {Id: string;@@ -699,4 +697,126 @@ type FieldHistory = {*/declare const MAX_FIELD_HISTORY_RECORDS = 10;-export { type Alias, type Attachment, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MAX_FIELD_HISTORY_RECORDS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, type Tag, type TotpCode, VaultDataBucketCategory, type VaultDataBucketCategoryValue, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };+/**+ * The client vault datamodel registry: one entry per syncable client vault table, carrying the+ * metadata every platform needs to agree on (primary keys, manifest scoping, merge match keys,+ * bucket layout, blob extraction). This file is the single source of truth; the Rust codec's+ * registry (core/rust/src/vault_model/generated.rs) is generated from it by+ * core/models/scripts/generate-vault-table-registry.cjs.+ */+/**+ * The scope column every stamped table carries: the id of the manifest that owns the row.+ */+declare const VAULT_MANIFEST_ID_COLUMN = "ManifestId";+/**+ * Metadata for one syncable client vault table.+ */+type VaultTableDefinition = {+ /** Table name in the client SQLite database. */+ Name: string;+ /** True when the table's rows are namespaced per manifest. */+ ManifestScoped: boolean;+ /**+ * The columns that name a row within its manifest, excluding ManifestId. Defaults to ['Id'];+ * tables keyed differently (Settings by Key, ItemTags by its natural key) override this.+ */+ PrimaryKey: string[];+ /** True when the table's rows hang off an Item row (re-stamped with their item, cascaded on delete). */+ ItemChild: boolean;+ /**+ * Match columns for the legacy statement merge. When absent, matching falls back to+ * (ManifestId, PrimaryKey).+ */+ LegacyMergeKey?: string[];+ /**+ * Match columns for the canonical merge only, where both sides are first normalized to the+ * manifest shape (see the Rust vault_codec::normalize module). Absent means the canonical merge+ * uses the same rule as the statement merge.+ */+ CanonicalMergeKey?: string[];+ /**+ * The data-bucket category the table syncs in, when it is split out of the manifest into a+ * bucket with its own server revision. Mirrors the server VaultDataBucketCategory.+ */+ BucketCategory?: string;+ /**+ * The column whose contents are extracted into content-addressed blobs rather than kept inline+ * in the manifest. Kind is the label reported to the server on upload (metrics / retention).+ */+ BlobColumn?: {+ Column: string;+ Kind: string;+ };+ /**+ * Rows in other tables that reference this table's rows from inside manifest content. On a+ * manifest split the referenced rows are reference-copied into the destination manifest so each+ * manifest stays self-contained.+ */+ ReferencedBy?: {+ Table: string;+ Column: string;+ }[];+};+/**+ * All syncable client vault tables, in registry order. Order is load-bearing: a merge inserts rows+ * in this order, so child tables must be listed after the table they reference (Items first).+ */+declare const VAULT_TABLES: VaultTableDefinition[];+/**+ * The column names the shared (Rust) vault logic references by name, emitted as named constants so+ * every module spells them identically. The full column set of each table is deliberately not+ * modeled here: it lives in the SQL schema and is passed to the codec at runtime.+ */+declare const VAULT_COLUMN_NAMES: string[];+/**+ * Data-bucket categories in declaration order. This order, not the table order, decides the order+ * buckets are emitted in; every category must be used by at least one VAULT_TABLES entry.+ */+declare const VAULT_BUCKET_CATEGORIES: string[];+/**+ * Tables never serialized into the server-stored manifest: internal SQLite, platform, or EF+ * bookkeeping that only exists at runtime and must not become part of a persisted manifest.+ */+declare const VAULT_SKIP_TABLES: string[];+/**+ * Tables that belong exclusively to the user's own (personal) vault, never to a shared manifest.+ * Empty today; kept as the declaration point for a future personal-only table.+ */+declare const VAULT_PERSONAL_TABLES: string[];+/**+ * System field keys whose field holds multiple values, derived from SystemFieldRegistry+ * (IsMultiValue). A value of such a field owns its row id: two devices each adding a value are+ * adding two different things, so their ids are never derived.+ */+declare const MULTI_VALUE_FIELD_KEYS: string[];+/**+ * The per-manifest delivery-keypair table. Every manifest carries its own asymmetric keypair(s),+ * stamped with that manifest's id.+ */+declare const ENCRYPTION_KEYS_TABLE = "EncryptionKeys";+/**+ * Local bookkeeping table the codec materializes into the vault DB: one row per manifest this+ * vault is materialized from (Id, Name).+ */+declare const MANIFESTS_TABLE = "Manifests";+/**+ * Client-local SQLite table that carries the codec overflow inside the vault database itself:+ * unknown row columns and tables preserved for forward compatibility.+ */+declare const CODEC_OVERFLOW_TABLE = "CodecOverflows";+/**+ * Fixed sentinel primary key of the single CodecOverflows row (deterministic on purpose:+ * materialize output must not depend on a random source).+ */+declare const CODEC_OVERFLOW_ROW_ID = "00000000-0000-0000-0000-00000000c0de";+/**+ * All-zero GUID used for default values which indicate unstamped rows (a ManifestId naming no+ * manifest).+ */+declare const UNSTAMPED_SCOPE_SENTINEL = "00000000-0000-0000-0000-000000000000";+/**+ * Default trash retention in days: how long a trashed item survives before the pruner deletes it.+ */+declare const TRASH_RETENTION_DEFAULT_DAYS = 30;++export { type Alias, type Attachment, CODEC_OVERFLOW_ROW_ID, CODEC_OVERFLOW_TABLE, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, ENCRYPTION_KEYS_TABLE, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MANIFESTS_TABLE, MAX_FIELD_HISTORY_RECORDS, MULTI_VALUE_FIELD_KEYS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, TRASH_RETENTION_DEFAULT_DAYS, type Tag, type TotpCode, UNSTAMPED_SCOPE_SENTINEL, VAULT_BUCKET_CATEGORIES, VAULT_COLUMN_NAMES, VAULT_MANIFEST_ID_COLUMN, VAULT_PERSONAL_TABLES, VAULT_SKIP_TABLES, VAULT_TABLES, VaultDataBucketCategory, VaultDataBucketCategoryDescriptions, type VaultDataBucketCategoryValue, type VaultTableDefinition, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.js b/apps/browser-extension/src/utils/dist/core/models/vault/index.jsindex 90782efcc..a66e2de71 100644--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.js+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.js@@ -110,6 +110,10 @@ var VaultDataBucketCategory = {*/Stats: "Stats"};+var VaultDataBucketCategoryDescriptions = {+ Settings: "User client settings (sort order, autofill prefs, identity defaults, etc.).",+ Stats: "Per-item usage statistics (last used, use counts)."+};// src/vault/Item.tsvar ItemTypes = {@@ -481,4 +485,127 @@ function createCustomField(options) {// src/vault/FieldHistory.tsvar MAX_FIELD_HISTORY_RECORDS = 10;-export { FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MAX_FIELD_HISTORY_RECORDS, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, VaultDataBucketCategory, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };+// src/vault/VaultTableRegistry.ts+var VAULT_MANIFEST_ID_COLUMN = "ManifestId";+var VAULT_TABLES = [+ { Name: "Items", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ /*+ * ItemStats is keyed by the item it describes: Id IS the item's id, so recording a use is an+ * upsert and two devices never mint competing rows. Listed after Items so a merge inserts the+ * item first.+ */+ { Name: "ItemStats", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true, BucketCategory: "Stats" },+ /*+ * FieldValues legacy statement merge: a field value matches on the field it belongs to (FieldKey+ * for system fields, FieldDefinitionId for custom ones; exactly one is set), so independently+ * minted rows of the same field converge. Canonical merge: both sides are normalized first,+ * which strips the derived id of every single-value row, so adding Id to the key makes a+ * single-value row match by its field (id part empty on both sides) while a multi-value row+ * matches by its OWNED id: two devices each adding a login.url are two different rows that must+ * both survive, and the id, unlike ValueIndex, is stable under reordering.+ */+ {+ Name: "FieldValues",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ LegacyMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId"],+ CanonicalMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId", "Id"]+ },+ { Name: "Folders", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ {+ Name: "Tags",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ ReferencedBy: [{ Table: "ItemTags", Column: "TagId" }]+ },+ /*+ * ItemTags is a pure join table keyed by its natural key; it carries no surrogate id so two devices tagging the same item converge on one row.+ */+ { Name: "ItemTags", ManifestScoped: true, PrimaryKey: ["ItemId", "TagId"], ItemChild: true },+ {+ Name: "Attachments",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ BlobColumn: { Column: "Blob", Kind: "attachment" }+ },+ { Name: "TotpCodes", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true },+ { Name: "Passkeys", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true },+ {+ Name: "FieldDefinitions",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ ReferencedBy: [{ Table: "FieldValues", Column: "FieldDefinitionId" }, { Table: "FieldHistories", Column: "FieldDefinitionId" }]+ },+ /*+ * FieldHistories canonical merge: every history row derives its id from (item, field, ChangedAt),+ * so after normalization the natural key IS the identity: concurrent changes union (distinct+ * ChangedAt), same-millisecond snapshots converge. Legacy statement merge keeps plain+ * (ManifestId, Id).+ */+ {+ Name: "FieldHistories",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ CanonicalMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId", "ChangedAt"]+ },+ {+ Name: "Logos",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ BlobColumn: { Column: "FileData", Kind: "favicon" }+ },+ { Name: "EncryptionKeys", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ {+ Name: "Settings",+ ManifestScoped: true,+ PrimaryKey: ["Key"],+ ItemChild: false,+ BucketCategory: "Settings"+ }+];+var VAULT_COLUMN_NAMES = [+ "Id",+ "ItemId",+ "TagId",+ "FieldKey",+ "FieldDefinitionId",+ "ValueIndex",+ "ChangedAt",+ "IsMultiValue",+ "ParentFolderId",+ "FolderId",+ "LogoId",+ "Kind",+ "Source",+ "FileData",+ "Blob",+ "UpdatedAt",+ "DeletedAt",+ "PublicKey",+ "IsPrimary",+ "IsDeleted"+];+var VAULT_BUCKET_CATEGORIES = ["Settings", "Stats"];+var VAULT_SKIP_TABLES = [+ "__EFMigrationsHistory",+ "__EFMigrationsLock",+ "sqlite_sequence",+ "android_metadata",+ "Manifests"+];+var VAULT_PERSONAL_TABLES = [];+var MULTI_VALUE_FIELD_KEYS = Object.values(SystemFieldRegistry).filter((field) => field.IsMultiValue).map((field) => field.FieldKey.toLowerCase());+var ENCRYPTION_KEYS_TABLE = "EncryptionKeys";+var MANIFESTS_TABLE = "Manifests";+var CODEC_OVERFLOW_TABLE = "CodecOverflows";+var CODEC_OVERFLOW_ROW_ID = "00000000-0000-0000-0000-00000000c0de";+var UNSTAMPED_SCOPE_SENTINEL = "00000000-0000-0000-0000-000000000000";+var TRASH_RETENTION_DEFAULT_DAYS = 30;++export { CODEC_OVERFLOW_ROW_ID, CODEC_OVERFLOW_TABLE, ENCRYPTION_KEYS_TABLE, FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MANIFESTS_TABLE, MAX_FIELD_HISTORY_RECORDS, MULTI_VALUE_FIELD_KEYS, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, TRASH_RETENTION_DEFAULT_DAYS, UNSTAMPED_SCOPE_SENTINEL, VAULT_BUCKET_CATEGORIES, VAULT_COLUMN_NAMES, VAULT_MANIFEST_ID_COLUMN, VAULT_PERSONAL_TABLES, VAULT_SKIP_TABLES, VAULT_TABLES, VaultDataBucketCategory, VaultDataBucketCategoryDescriptions, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.ktindex df042cc08..d2a035b02 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt@@ -1,12 +1,12 @@// <auto-generated />-// This file is auto-generated from core/rust/src/vault_codec/types.rs (BUCKET_TABLES).-// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-bucket-categories.cjs') to regenerate.+// This file is auto-generated from core/models/src/vault/VaultTableRegistry.ts (VAULT_BUCKET_CATEGORIES).+// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-vault-table-registry.cjs') to regenerate.package net.aliasvault.app.vaultstore.models/*** Known data-bucket categories for the manifest-v1 storage format.- * The canonical list lives in the Rust codec's BUCKET_TABLES.+ * The canonical list lives in the vault table registry (core/models).*/object VaultDataBucketCategory {/**diff --git a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swiftindex 1b89ace08..725a22e86 100644--- a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift+++ b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift@@ -1,11 +1,11 @@// <auto-generated />-// This file is auto-generated from core/rust/src/vault_codec/types.rs (BUCKET_TABLES).-// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-bucket-categories.cjs') to regenerate.+// This file is auto-generated from core/models/src/vault/VaultTableRegistry.ts (VAULT_BUCKET_CATEGORIES).+// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-vault-table-registry.cjs') to regenerate.import Foundation/// Known data-bucket categories for the manifest-v1 storage format.-/// The canonical list lives in the Rust codec's BUCKET_TABLES.+/// The canonical list lives in the vault table registry (core/models).public struct VaultDataBucketCategory {/// User client settings (sort order, autofill prefs, identity defaults, etc.).public static let settings = "Settings"diff --git a/apps/mobile-app/utils/dist/core/models/vault/index.d.ts b/apps/mobile-app/utils/dist/core/models/vault/index.d.tsindex 546c008ba..67e2795a3 100644--- a/apps/mobile-app/utils/dist/core/models/vault/index.d.ts+++ b/apps/mobile-app/utils/dist/core/models/vault/index.d.ts@@ -316,16 +316,10 @@ declare const FieldKey: {*/type FieldKeyValue = typeof FieldKey[keyof typeof FieldKey];-/**- * <auto-generated />- * This file is auto-generated from core/rust/src/vault_codec/types.rs (BUCKET_TABLES).- * Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-bucket-categories.cjs') to regenerate.- *//*** Known data-bucket categories for the manifest-v1 storage format. Each value is one small,* independently-versioned, user-scoped category of encrypted data kept out of the main vault content- * manifest so it syncs cheaply. Serialized as its string name on the wire. The canonical list lives in- * the Rust codec's BUCKET_TABLES.+ * manifest so it syncs cheaply. Serialized as its string name on the wire.*/declare const VaultDataBucketCategory: {/**@@ -341,6 +335,10 @@ declare const VaultDataBucketCategory: {* Type representing all valid vault data bucket category values.*/type VaultDataBucketCategoryValue = typeof VaultDataBucketCategory[keyof typeof VaultDataBucketCategory];+/**+ * Human-readable description per category, emitted into the generated platform variants' doc comments.+ */+declare const VaultDataBucketCategoryDescriptions: Record<VaultDataBucketCategoryValue, string>;type Tag = {Id: string;@@ -699,4 +697,126 @@ type FieldHistory = {*/declare const MAX_FIELD_HISTORY_RECORDS = 10;-export { type Alias, type Attachment, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MAX_FIELD_HISTORY_RECORDS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, type Tag, type TotpCode, VaultDataBucketCategory, type VaultDataBucketCategoryValue, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };+/**+ * The client vault datamodel registry: one entry per syncable client vault table, carrying the+ * metadata every platform needs to agree on (primary keys, manifest scoping, merge match keys,+ * bucket layout, blob extraction). This file is the single source of truth; the Rust codec's+ * registry (core/rust/src/vault_model/generated.rs) is generated from it by+ * core/models/scripts/generate-vault-table-registry.cjs.+ */+/**+ * The scope column every stamped table carries: the id of the manifest that owns the row.+ */+declare const VAULT_MANIFEST_ID_COLUMN = "ManifestId";+/**+ * Metadata for one syncable client vault table.+ */+type VaultTableDefinition = {+ /** Table name in the client SQLite database. */+ Name: string;+ /** True when the table's rows are namespaced per manifest. */+ ManifestScoped: boolean;+ /**+ * The columns that name a row within its manifest, excluding ManifestId. Defaults to ['Id'];+ * tables keyed differently (Settings by Key, ItemTags by its natural key) override this.+ */+ PrimaryKey: string[];+ /** True when the table's rows hang off an Item row (re-stamped with their item, cascaded on delete). */+ ItemChild: boolean;+ /**+ * Match columns for the legacy statement merge. When absent, matching falls back to+ * (ManifestId, PrimaryKey).+ */+ LegacyMergeKey?: string[];+ /**+ * Match columns for the canonical merge only, where both sides are first normalized to the+ * manifest shape (see the Rust vault_codec::normalize module). Absent means the canonical merge+ * uses the same rule as the statement merge.+ */+ CanonicalMergeKey?: string[];+ /**+ * The data-bucket category the table syncs in, when it is split out of the manifest into a+ * bucket with its own server revision. Mirrors the server VaultDataBucketCategory.+ */+ BucketCategory?: string;+ /**+ * The column whose contents are extracted into content-addressed blobs rather than kept inline+ * in the manifest. Kind is the label reported to the server on upload (metrics / retention).+ */+ BlobColumn?: {+ Column: string;+ Kind: string;+ };+ /**+ * Rows in other tables that reference this table's rows from inside manifest content. On a+ * manifest split the referenced rows are reference-copied into the destination manifest so each+ * manifest stays self-contained.+ */+ ReferencedBy?: {+ Table: string;+ Column: string;+ }[];+};+/**+ * All syncable client vault tables, in registry order. Order is load-bearing: a merge inserts rows+ * in this order, so child tables must be listed after the table they reference (Items first).+ */+declare const VAULT_TABLES: VaultTableDefinition[];+/**+ * The column names the shared (Rust) vault logic references by name, emitted as named constants so+ * every module spells them identically. The full column set of each table is deliberately not+ * modeled here: it lives in the SQL schema and is passed to the codec at runtime.+ */+declare const VAULT_COLUMN_NAMES: string[];+/**+ * Data-bucket categories in declaration order. This order, not the table order, decides the order+ * buckets are emitted in; every category must be used by at least one VAULT_TABLES entry.+ */+declare const VAULT_BUCKET_CATEGORIES: string[];+/**+ * Tables never serialized into the server-stored manifest: internal SQLite, platform, or EF+ * bookkeeping that only exists at runtime and must not become part of a persisted manifest.+ */+declare const VAULT_SKIP_TABLES: string[];+/**+ * Tables that belong exclusively to the user's own (personal) vault, never to a shared manifest.+ * Empty today; kept as the declaration point for a future personal-only table.+ */+declare const VAULT_PERSONAL_TABLES: string[];+/**+ * System field keys whose field holds multiple values, derived from SystemFieldRegistry+ * (IsMultiValue). A value of such a field owns its row id: two devices each adding a value are+ * adding two different things, so their ids are never derived.+ */+declare const MULTI_VALUE_FIELD_KEYS: string[];+/**+ * The per-manifest delivery-keypair table. Every manifest carries its own asymmetric keypair(s),+ * stamped with that manifest's id.+ */+declare const ENCRYPTION_KEYS_TABLE = "EncryptionKeys";+/**+ * Local bookkeeping table the codec materializes into the vault DB: one row per manifest this+ * vault is materialized from (Id, Name).+ */+declare const MANIFESTS_TABLE = "Manifests";+/**+ * Client-local SQLite table that carries the codec overflow inside the vault database itself:+ * unknown row columns and tables preserved for forward compatibility.+ */+declare const CODEC_OVERFLOW_TABLE = "CodecOverflows";+/**+ * Fixed sentinel primary key of the single CodecOverflows row (deterministic on purpose:+ * materialize output must not depend on a random source).+ */+declare const CODEC_OVERFLOW_ROW_ID = "00000000-0000-0000-0000-00000000c0de";+/**+ * All-zero GUID used for default values which indicate unstamped rows (a ManifestId naming no+ * manifest).+ */+declare const UNSTAMPED_SCOPE_SENTINEL = "00000000-0000-0000-0000-000000000000";+/**+ * Default trash retention in days: how long a trashed item survives before the pruner deletes it.+ */+declare const TRASH_RETENTION_DEFAULT_DAYS = 30;++export { type Alias, type Attachment, CODEC_OVERFLOW_ROW_ID, CODEC_OVERFLOW_TABLE, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, ENCRYPTION_KEYS_TABLE, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MANIFESTS_TABLE, MAX_FIELD_HISTORY_RECORDS, MULTI_VALUE_FIELD_KEYS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, TRASH_RETENTION_DEFAULT_DAYS, type Tag, type TotpCode, UNSTAMPED_SCOPE_SENTINEL, VAULT_BUCKET_CATEGORIES, VAULT_COLUMN_NAMES, VAULT_MANIFEST_ID_COLUMN, VAULT_PERSONAL_TABLES, VAULT_SKIP_TABLES, VAULT_TABLES, VaultDataBucketCategory, VaultDataBucketCategoryDescriptions, type VaultDataBucketCategoryValue, type VaultTableDefinition, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };diff --git a/apps/mobile-app/utils/dist/core/models/vault/index.js b/apps/mobile-app/utils/dist/core/models/vault/index.jsindex 90782efcc..a66e2de71 100644--- a/apps/mobile-app/utils/dist/core/models/vault/index.js+++ b/apps/mobile-app/utils/dist/core/models/vault/index.js@@ -110,6 +110,10 @@ var VaultDataBucketCategory = {*/Stats: "Stats"};+var VaultDataBucketCategoryDescriptions = {+ Settings: "User client settings (sort order, autofill prefs, identity defaults, etc.).",+ Stats: "Per-item usage statistics (last used, use counts)."+};// src/vault/Item.tsvar ItemTypes = {@@ -481,4 +485,127 @@ function createCustomField(options) {// src/vault/FieldHistory.tsvar MAX_FIELD_HISTORY_RECORDS = 10;-export { FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MAX_FIELD_HISTORY_RECORDS, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, VaultDataBucketCategory, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };+// src/vault/VaultTableRegistry.ts+var VAULT_MANIFEST_ID_COLUMN = "ManifestId";+var VAULT_TABLES = [+ { Name: "Items", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ /*+ * ItemStats is keyed by the item it describes: Id IS the item's id, so recording a use is an+ * upsert and two devices never mint competing rows. Listed after Items so a merge inserts the+ * item first.+ */+ { Name: "ItemStats", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true, BucketCategory: "Stats" },+ /*+ * FieldValues legacy statement merge: a field value matches on the field it belongs to (FieldKey+ * for system fields, FieldDefinitionId for custom ones; exactly one is set), so independently+ * minted rows of the same field converge. Canonical merge: both sides are normalized first,+ * which strips the derived id of every single-value row, so adding Id to the key makes a+ * single-value row match by its field (id part empty on both sides) while a multi-value row+ * matches by its OWNED id: two devices each adding a login.url are two different rows that must+ * both survive, and the id, unlike ValueIndex, is stable under reordering.+ */+ {+ Name: "FieldValues",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ LegacyMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId"],+ CanonicalMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId", "Id"]+ },+ { Name: "Folders", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ {+ Name: "Tags",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ ReferencedBy: [{ Table: "ItemTags", Column: "TagId" }]+ },+ /*+ * ItemTags is a pure join table keyed by its natural key; it carries no surrogate id so two devices tagging the same item converge on one row.+ */+ { Name: "ItemTags", ManifestScoped: true, PrimaryKey: ["ItemId", "TagId"], ItemChild: true },+ {+ Name: "Attachments",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ BlobColumn: { Column: "Blob", Kind: "attachment" }+ },+ { Name: "TotpCodes", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true },+ { Name: "Passkeys", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: true },+ {+ Name: "FieldDefinitions",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ ReferencedBy: [{ Table: "FieldValues", Column: "FieldDefinitionId" }, { Table: "FieldHistories", Column: "FieldDefinitionId" }]+ },+ /*+ * FieldHistories canonical merge: every history row derives its id from (item, field, ChangedAt),+ * so after normalization the natural key IS the identity: concurrent changes union (distinct+ * ChangedAt), same-millisecond snapshots converge. Legacy statement merge keeps plain+ * (ManifestId, Id).+ */+ {+ Name: "FieldHistories",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: true,+ CanonicalMergeKey: ["ManifestId", "ItemId", "FieldKey", "FieldDefinitionId", "ChangedAt"]+ },+ {+ Name: "Logos",+ ManifestScoped: true,+ PrimaryKey: ["Id"],+ ItemChild: false,+ BlobColumn: { Column: "FileData", Kind: "favicon" }+ },+ { Name: "EncryptionKeys", ManifestScoped: true, PrimaryKey: ["Id"], ItemChild: false },+ {+ Name: "Settings",+ ManifestScoped: true,+ PrimaryKey: ["Key"],+ ItemChild: false,+ BucketCategory: "Settings"+ }+];+var VAULT_COLUMN_NAMES = [+ "Id",+ "ItemId",+ "TagId",+ "FieldKey",+ "FieldDefinitionId",+ "ValueIndex",+ "ChangedAt",+ "IsMultiValue",+ "ParentFolderId",+ "FolderId",+ "LogoId",+ "Kind",+ "Source",+ "FileData",+ "Blob",+ "UpdatedAt",+ "DeletedAt",+ "PublicKey",+ "IsPrimary",+ "IsDeleted"+];+var VAULT_BUCKET_CATEGORIES = ["Settings", "Stats"];+var VAULT_SKIP_TABLES = [+ "__EFMigrationsHistory",+ "__EFMigrationsLock",+ "sqlite_sequence",+ "android_metadata",+ "Manifests"+];+var VAULT_PERSONAL_TABLES = [];+var MULTI_VALUE_FIELD_KEYS = Object.values(SystemFieldRegistry).filter((field) => field.IsMultiValue).map((field) => field.FieldKey.toLowerCase());+var ENCRYPTION_KEYS_TABLE = "EncryptionKeys";+var MANIFESTS_TABLE = "Manifests";+var CODEC_OVERFLOW_TABLE = "CodecOverflows";+var CODEC_OVERFLOW_ROW_ID = "00000000-0000-0000-0000-00000000c0de";+var UNSTAMPED_SCOPE_SENTINEL = "00000000-0000-0000-0000-000000000000";+var TRASH_RETENTION_DEFAULT_DAYS = 30;++export { CODEC_OVERFLOW_ROW_ID, CODEC_OVERFLOW_TABLE, ENCRYPTION_KEYS_TABLE, FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MANIFESTS_TABLE, MAX_FIELD_HISTORY_RECORDS, MULTI_VALUE_FIELD_KEYS, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, TRASH_RETENTION_DEFAULT_DAYS, UNSTAMPED_SCOPE_SENTINEL, VAULT_BUCKET_CATEGORIES, VAULT_COLUMN_NAMES, VAULT_MANIFEST_ID_COLUMN, VAULT_PERSONAL_TABLES, VAULT_SKIP_TABLES, VAULT_TABLES, VaultDataBucketCategory, VaultDataBucketCategoryDescriptions, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };diff --git a/apps/server/Databases/AliasClientDb/Models/VaultTableRegistry.cs b/apps/server/Databases/AliasClientDb/Models/VaultTableRegistry.csnew file mode 100644index 000000000..6fbb9f805--- /dev/null+++ b/apps/server/Databases/AliasClientDb/Models/VaultTableRegistry.cs@@ -0,0 +1,48 @@+// <auto-generated />+// This file is auto-generated from core/models/src/vault/VaultTableRegistry.ts+// Do not edit this file directly. Run 'core/models/build.sh' (or+// 'node core/models/scripts/generate-vault-table-registry.cjs') to regenerate.++#nullable enable++namespace AliasClientDb.Models;++using System.Collections.Generic;++/// <summary>+/// The client vault datamodel registry: one entry per syncable vault table, generated from the+/// TypeScript source of truth shared with the Rust codec. A unit test asserts the EF model+/// matches this registry, so a datamodel change that skips one of the encodings fails loudly.+/// </summary>+public static class VaultTableRegistry+{+ /// <summary>+ /// Gets all syncable client vault tables, in registry order.+ /// </summary>+ public static IReadOnlyList<VaultTableDefinition> Tables { get; } = new VaultTableDefinition[]+ {+ new("Items", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("ItemStats", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("FieldValues", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("Folders", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("Tags", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("ItemTags", new[] { "ItemId", "TagId" }, ManifestScoped: true, ItemChild: true),+ new("Attachments", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("TotpCodes", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("Passkeys", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("FieldDefinitions", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("FieldHistories", new[] { "Id" }, ManifestScoped: true, ItemChild: true),+ new("Logos", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("EncryptionKeys", new[] { "Id" }, ManifestScoped: true, ItemChild: false),+ new("Settings", new[] { "Key" }, ManifestScoped: true, ItemChild: false),+ };+}++/// <summary>+/// Metadata for one syncable client vault table.+/// </summary>+/// <param name="Name">Table name in the client SQLite database.</param>+/// <param name="PrimaryKey">The columns that name a row within its manifest, excluding ManifestId.</param>+/// <param name="ManifestScoped">True when the table's rows are namespaced per manifest.</param>+/// <param name="ItemChild">True when the table's rows hang off an Item row.</param>+public sealed record VaultTableDefinition(string Name, IReadOnlyList<string> PrimaryKey, bool ManifestScoped, bool ItemChild);diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.csindex 807e7f940..b7e3dbd53 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs@@ -1,6 +1,6 @@// <auto-generated />-// This file is auto-generated from core/rust/src/vault_codec/types.rs (BUCKET_TABLES).-// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-bucket-categories.cjs') to regenerate.+// This file is auto-generated from core/models/src/vault/VaultTableRegistry.ts (VAULT_BUCKET_CATEGORIES).+// Do not edit this file directly. Run 'core/models/build.sh' (or 'node core/models/scripts/generate-vault-table-registry.cjs') to regenerate.namespace AliasVault.Shared.Models.WebApi.V2.Vault;@@ -11,7 +11,7 @@ using System.Text.Json.Serialization;/// user-scoped category of encrypted data kept out of the main vault content manifest so it syncs cheaply./// Serialized as its string name on the wire (not the numeric value) and stored as a string in the database./// Adding a new kind requires a server-side rollout first, because the server reasons about kinds for-/// per-kind retention policies. The canonical list lives in the Rust codec's BUCKET_TABLES.+/// per-kind retention policies. The canonical list lives in the vault table registry (core/models)./// </summary>[JsonConverter(typeof(JsonStringEnumConverter))]public enum VaultDataBucketCategorydiff --git a/apps/server/Tests/AliasVault.UnitTests/Vault/VaultTableRegistryTests.cs b/apps/server/Tests/AliasVault.UnitTests/Vault/VaultTableRegistryTests.csnew file mode 100644index 000000000..05a99c560--- /dev/null+++ b/apps/server/Tests/AliasVault.UnitTests/Vault/VaultTableRegistryTests.cs@@ -0,0 +1,99 @@+//-----------------------------------------------------------------------+// <copyright file="VaultTableRegistryTests.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.UnitTests.Vault;++using AliasClientDb;+using AliasClientDb.Abstracts;+using AliasClientDb.Models;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Metadata;++/// <summary>+/// Asserts the generated vault table registry (core/models) matches the EF client datamodel, so a+/// datamodel change that is not applied to both places throws an error here during CI.+/// </summary>+public class VaultTableRegistryTests+{+ private static readonly IModel Model = BuildModel();++ /// <summary>+ /// Every EF entity deriving from SyncableEntity must appear in the registry and vice versa.+ /// </summary>+ [Test]+ public void EverySyncableEntityIsRegistered()+ {+ var efTables = Model.GetEntityTypes().Where(e => typeof(SyncableEntity).IsAssignableFrom(e.ClrType)).Select(e => e.GetTableName()).ToList();+ var registryTables = VaultTableRegistry.Tables.Select(t => t.Name).ToList();+ Assert.That(efTables, Is.EquivalentTo(registryTables));+ }++ /// <summary>+ /// The EF primary key of every registered table must match the registry's key definition.+ /// </summary>+ [Test]+ public void PrimaryKeysMatchTheRegistry()+ {+ foreach (var table in VaultTableRegistry.Tables)+ {+ var pkProperties = FindEntity(table.Name).FindPrimaryKey()!.Properties.Select(p => p.Name).ToList();+ var expected = table.ManifestScoped ? new[] { "ManifestId" }.Concat(table.PrimaryKey).ToList() : table.PrimaryKey.ToList();+ Assert.That(pkProperties, Is.EqualTo(expected).AsCollection, $"{table.Name} primary key drifted from the registry");+ }+ }++ /// <summary>+ /// The registry's manifest-scoped flag must match the entity deriving from ManifestScopedEntity.+ /// </summary>+ [Test]+ public void ManifestScopingMatchesTheRegistry()+ {+ foreach (var table in VaultTableRegistry.Tables)+ {+ var scoped = typeof(ManifestScopedEntity).IsAssignableFrom(FindEntity(table.Name).ClrType);+ Assert.That(scoped, Is.EqualTo(table.ManifestScoped), $"{table.Name} manifest scoping drifted from the registry");+ }+ }++ /// <summary>+ /// Every item-child table must carry its owning item's id: an ItemId property, or for ItemStats+ /// the Id column itself (its Id is the item's id). Tables not flagged as item children must not+ /// silently reference items.+ /// </summary>+ [Test]+ public void ItemChildFlagsMatchTheRegistry()+ {+ foreach (var table in VaultTableRegistry.Tables)+ {+ var hasItemReference = table.Name == "ItemStats" || FindEntity(table.Name).FindProperty("ItemId") != null;+ Assert.That(hasItemReference, Is.EqualTo(table.ItemChild), $"{table.Name} item-child flag drifted from the registry");+ }+ }++ /// <summary>+ /// Build the EF model without opening a database connection.+ /// </summary>+ /// <returns>The EF model of the client database.</returns>+ private static IModel BuildModel()+ {+ var options = new DbContextOptionsBuilder<AliasClientDbContext>().UseSqlite("Data Source=:memory:").Options;+ using var context = new AliasClientDbContext(options);+ return context.Model;+ }++ /// <summary>+ /// Find the EF entity type mapped to a table name.+ /// </summary>+ /// <param name="tableName">The SQLite table name.</param>+ /// <returns>The entity type.</returns>+ private static IEntityType FindEntity(string tableName)+ {+ var entity = Model.GetEntityTypes().SingleOrDefault(e => e.GetTableName() == tableName);+ Assert.That(entity, Is.Not.Null, $"registry table {tableName} has no EF entity");+ return entity!;+ }+}