Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions internal/i18n/models/i18n_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var i18nServiceMethods = []string{
}

// EnsureI18nMeta registers declaration-layer I18n + Service methods via the meta
// declaration facade, recomputes the effective projection, and seeds Terminology
// Editor ACL rows against effective service ids. Does not register TranslationTerm.
// declaration facade, flushes the effective projection for ACL seeding, and seeds
// Terminology Editor ACL rows against effective service ids. Does not register TranslationTerm.
func EnsureI18nMeta(runtimeScope scope.Scope, application string, moduleID sql.NullString) error {
application = strings.TrimSpace(application)
if application == "" || application == coreApplication {
Expand All @@ -45,18 +45,18 @@ func EnsureI18nMeta(runtimeScope scope.Scope, application string, moduleID sql.N
}

path := fmt.Sprintf("go://i18n/%s", application)
decl := meta.NewAbstractReadonlyDeclaration(i18nModelName, path, application, moduleID, i18nServiceMethods)
if err := meta.UpsertDeclaration(db, decl); err != nil {
if err := meta.EnsureAbstractModel(db, meta.AbstractModelSpec{
Name: i18nModelName,
Path: path,
Application: application,
ModuleID: moduleID,
ServiceNames: i18nServiceMethods,
}); err != nil {
return err
}
// E2 tip scalars (Path, Abstract, …) come from the last-ranked same-name raw, and the
// first effective id is minted from pickTipRaw (created_at). Prefer the canonical path
// so Path and id stay on go://i18n/<application>.
if err := meta.PreferDeclarationTip(db, application, i18nModelName, path); err != nil {
return err
}
if err := meta.RecomputeEffective(db, application, i18nModelName); err != nil {
return fmt.Errorf("recompute I18n effective: %w", err)
// Flush before ACL seeding reads effective service ids (install boundary for I18n).
if err := meta.FlushEffective(db, []meta.LogicalKey{{Application: application, Name: i18nModelName}}); err != nil {
return fmt.Errorf("flush I18n effective: %w", err)
}
serviceIDs, err := loadEffectiveI18nServiceIDs(db, application)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/i18n/models/i18n_meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ func TestEnsureI18nMetaSaveModuleAndServiceLookupErrors(t *testing.T) {
if err := db.Exec("ALTER TABLE meta_model RENAME COLUMN name TO name_broken").Error; err != nil {
t.Fatal(err)
}
if err := EnsureI18nMeta(rs, "auth", sql.NullString{}); err == nil || !strings.Contains(err.Error(), "recompute I18n effective") {
t.Fatalf("expected recompute effective error, got %v", err)
if err := EnsureI18nMeta(rs, "auth", sql.NullString{}); err == nil || !strings.Contains(err.Error(), "flush I18n effective") {
t.Fatalf("expected flush effective error, got %v", err)
}
}

Expand Down
Loading