diff --git a/src/balena-model.ts b/src/balena-model.ts index 788118100..cc54e9aad 100644 --- a/src/balena-model.ts +++ b/src/balena-model.ts @@ -600,16 +600,10 @@ export interface Service { >; device__installs__service?: Array; service_install?: Array; - device__installs__application__has__service_name__has__name?: Array< + device__has__application__has__service_name__has__env_var_name?: Array< DeviceServiceEnvironmentVariable['Read'] >; - device__installs__service__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device__installs__service_environment_variable?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - service_install__has__name?: Array< + device__has__service__has__env_var_name?: Array< DeviceServiceEnvironmentVariable['Read'] >; device_service_environment_variable?: Array< @@ -783,6 +777,15 @@ export interface Device { device_environment_variable?: Array; device__has__config_var_name?: Array; device_config_variable?: Array; + device__has__application__has__service_name__has__env_var_name?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; + device__has__service__has__env_var_name?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; + device_service_environment_variable?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; device__has__tag_key?: Array; device_tag?: Array; device__installs__image?: Array; @@ -792,21 +795,6 @@ export interface Device { >; device__installs__service?: Array; service_install?: Array; - device__installs__application__has__service_name__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device__installs__service__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device__installs__service_environment_variable?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - service_install__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device_service_environment_variable?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; installs__image?: Array; installs__application__has__service_name?: Array; installs__service?: Array; @@ -941,21 +929,6 @@ export interface ServiceInstall { device: { __id: Device['Read']['id'] } | [Device['Read']]; installs__service: { __id: Service['Read']['id'] } | [Service['Read']]; id: Types['Serial']['Read']; - device__installs__application__has__service_name__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device__installs__service__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device__installs__service_environment_variable?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - service_install__has__name?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; - device_service_environment_variable?: Array< - DeviceServiceEnvironmentVariable['Read'] - >; application__has__service_name: | { __id: Service['Read']['id'] } | [Service['Read']]; @@ -964,6 +937,15 @@ export interface ServiceInstall { | { __id: Service['Read']['id'] } | [Service['Read']]; is_installed_on__device: { __id: Device['Read']['id'] } | [Device['Read']]; + is_of__device__has__application__has__service_name__has__env_var_name?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; + is_of__device__has__service__has__env_var_name?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; + is_of__device_service_environment_variable?: Array< + DeviceServiceEnvironmentVariable['Read'] + >; }; Write: { created_at: Types['Date Time']['Write']; @@ -978,14 +960,14 @@ export interface DeviceServiceEnvironmentVariable { Read: { created_at: Types['Date Time']['Read']; modified_at: Types['Date Time']['Read']; - service_install: - | { __id: ServiceInstall['Read']['id'] } - | [ServiceInstall['Read']]; + device: { __id: Device['Read']['id'] } | [Device['Read']]; + service: { __id: Service['Read']['id'] } | [Service['Read']]; name: Types['Short Text']['Read']; id: Types['Serial']['Read']; value: Types['Text']['Read']; - service: { __id: Service['Read']['id'] } | [Service['Read']]; - device: { __id: Device['Read']['id'] } | [Device['Read']]; + service_install: + | { __id: ServiceInstall['Read']['id'] } + | [ServiceInstall['Read']]; device__installs__application__has__service_name: | { __id: ServiceInstall['Read']['id'] } | [ServiceInstall['Read']]; @@ -999,12 +981,12 @@ export interface DeviceServiceEnvironmentVariable { Write: { created_at: Types['Date Time']['Write']; modified_at: Types['Date Time']['Write']; - service_install: ServiceInstall['Write']['id']; + device: Device['Write']['id']; + service: Service['Write']['id']; name: Types['Short Text']['Write']; id: Types['Serial']['Write']; value: Types['Text']['Write']; - service: Service['Write']['id']; - device: Device['Write']['id']; + service_install: ServiceInstall['Write']['id']; }; } @@ -1329,7 +1311,7 @@ export default interface $Model { device__has__config_var_name: DeviceConfigVariable; device__installs__image: ImageInstall; device__installs__application__has__service_name: ServiceInstall; - device__installs__application__has__service_name__has__name: DeviceServiceEnvironmentVariable; + device__has__application__has__service_name__has__env_var_name: DeviceServiceEnvironmentVariable; device__has__tag_key: DeviceTag; release: Release; release__has__tag_key: ReleaseTag; diff --git a/src/balena.sbvr b/src/balena.sbvr index 1ade14cf6..7bdf14d87 100644 --- a/src/balena.sbvr +++ b/src/balena.sbvr @@ -395,9 +395,7 @@ Term: device Term Form: service install Database Table Name: service install - -- Target form for this table is: - -- Fact type: device has service has env var name - Fact type: service install has name (Auth) + Fact type: device has service has env var name Term Form: device service environment variable Database Table Name: device service environment variable @@ -814,16 +812,8 @@ Fact type: image environment variable has value Fact type: device service environment variable has value Necessity: each device service environment variable has exactly one value. -Fact type: device service environment variable has service - -- This is the default name that will be given to the synonymous form - -- once the device service environment variable origin fact type changes - Synonymous form: service has device service environment variable - Necessity: each device service environment variable has exactly one service. -Fact type: device service environment variable has device - -- This is the default name that will be given to the synonymous form - -- once the device service environment variable origin fact type changes - Synonymous form: device has device service environment variable - Necessity: each device service environment variable has exactly one device. +Fact type: device service environment variable has service install + Necessity: each device service environment variable has exactly one service install. -- application tag diff --git a/src/balena.ts b/src/balena.ts index 034d31b85..b055db0cc 100644 --- a/src/balena.ts +++ b/src/balena.ts @@ -3,6 +3,7 @@ import { generateAbstractSqlModel, renameVarResourcesName, optimizeSchema, + renameField, } from './abstract-sql-utils.js'; import * as userHasDirectAccessToApplication from './features/applications/models/user__has_direct_access_to__application.js'; @@ -22,6 +23,13 @@ export const model = { abstractSql, } satisfies ConfigLoader.Model; +renameField( + abstractSql, + 'device-has-application-has-service name-has-env var name', + ['has'], + 'env var name', + 'name', +); renameVarResourcesName(abstractSql); userHasDirectAccessToApplication.addToModel(abstractSql); diff --git a/src/translations/v7/v7.ts b/src/translations/v7/v7.ts index 823543bd3..fcda71f7e 100644 --- a/src/translations/v7/v7.ts +++ b/src/translations/v7/v7.ts @@ -19,5 +19,9 @@ overrideFieldType(v7AbstractSqlModel, 'release', 'version', 'JSON'); userHasDirectAccessToApplication.addToModel(v7AbstractSqlModel); // eslint-disable-next-line @typescript-eslint/no-unused-vars -- So that the interface is already well defined. export const getV7Translations = (_abstractSqlModel = v7AbstractSqlModel) => { - return {} satisfies ConfigLoader.Model['translations']; + return { + 'device-installs-application-has-service name-has-name': { + $toResource: 'device-has-application-has-service name-has-env var name', + }, + } satisfies ConfigLoader.Model['translations']; };