@balena/open-balena-api 31.1.1 → 31.2.0-build-add-device-service-fks-1ff87a4571c56db99c0ea335811003f32b366432-1

Sign up to get free protection for your applications and to get access to all the features.
@@ -598,6 +598,11 @@ export interface Service {
598
598
  service_install?: Array<ServiceInstall['Read']>;
599
599
  is_installed_on__device?: Array<ServiceInstall['Read']>;
600
600
  is_built_by__image?: Array<Image['Read']>;
601
+ is_of__device__installs__application__has__service_name__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
602
+ is_of__device__installs__service__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
603
+ is_of__device__installs__service_environment_variable?: Array<DeviceServiceEnvironmentVariable['Read']>;
604
+ is_of__service_install__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
605
+ is_of__device_service_environment_variable?: Array<DeviceServiceEnvironmentVariable['Read']>;
601
606
  };
602
607
  Write: {
603
608
  created_at: Types['Date Time']['Write'];
@@ -757,6 +762,11 @@ export interface Device {
757
762
  installs__image?: Array<ImageInstall['Read']>;
758
763
  installs__application__has__service_name?: Array<ServiceInstall['Read']>;
759
764
  installs__service?: Array<ServiceInstall['Read']>;
765
+ is_of__device__installs__application__has__service_name__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
766
+ is_of__device__installs__service__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
767
+ is_of__device__installs__service_environment_variable?: Array<DeviceServiceEnvironmentVariable['Read']>;
768
+ is_of__service_install__has__name?: Array<DeviceServiceEnvironmentVariable['Read']>;
769
+ is_of__device_service_environment_variable?: Array<DeviceServiceEnvironmentVariable['Read']>;
760
770
  };
761
771
  Write: {
762
772
  created_at: Types['Date Time']['Write'];
@@ -929,12 +939,21 @@ export interface DeviceServiceEnvironmentVariable {
929
939
  name: Types['Short Text']['Read'];
930
940
  id: Types['Serial']['Read'];
931
941
  value: Types['Text']['Read'];
942
+ service: {
943
+ __id: Service['Read']['id'];
944
+ } | [Service['Read']] | [] | null;
945
+ device: {
946
+ __id: Device['Read']['id'];
947
+ } | [Device['Read']] | [] | null;
932
948
  device__installs__application__has__service_name: {
933
949
  __id: ServiceInstall['Read']['id'];
934
950
  } | [ServiceInstall['Read']];
935
951
  device__installs__service: {
936
952
  __id: ServiceInstall['Read']['id'];
937
953
  } | [ServiceInstall['Read']];
954
+ application__has__service_name: {
955
+ __id: Service['Read']['id'];
956
+ } | [Service['Read']] | [] | null;
938
957
  };
939
958
  Write: {
940
959
  created_at: Types['Date Time']['Write'];
@@ -943,6 +962,8 @@ export interface DeviceServiceEnvironmentVariable {
943
962
  name: Types['Short Text']['Write'];
944
963
  id: Types['Serial']['Write'];
945
964
  value: Types['Text']['Write'];
965
+ service: Service['Write']['id'] | null;
966
+ device: Device['Write']['id'] | null;
946
967
  };
947
968
  }
948
969
  export interface DeviceTag {
package/dist/balena.sbvr CHANGED
@@ -812,6 +812,10 @@ Fact type: image environment variable has value
812
812
 
813
813
  Fact type: device service environment variable has value
814
814
  Necessity: each device service environment variable has exactly one value.
815
+ Fact type: device service environment variable has service
816
+ Necessity: each device service environment variable has at most one service.
817
+ Fact type: device service environment variable has device
818
+ Necessity: each device service environment variable has at most one device.
815
819
 
816
820
 
817
821
  -- application tag
@@ -0,0 +1,26 @@
1
+ import { hooks, errors } from '@balena/pinejs';
2
+ async function backfillDeviceAndService({ request, api, }) {
3
+ const { service_install: siId } = request.values;
4
+ if (siId == null) {
5
+ return;
6
+ }
7
+ const si = await api.get({
8
+ resource: 'service_install',
9
+ id: siId,
10
+ options: {
11
+ $select: ['device', 'service'],
12
+ },
13
+ });
14
+ if (si == null) {
15
+ throw new errors.NotFoundError(`Service install not found: ${siId}`);
16
+ }
17
+ request.values.device = si.device.__id;
18
+ request.values.service = si.service.__id;
19
+ }
20
+ hooks.addPureHook('POST', 'resin', 'device_service_environment_variable', {
21
+ POSTPARSE: backfillDeviceAndService,
22
+ });
23
+ hooks.addPureHook('PATCH', 'resin', 'device_service_environment_variable', {
24
+ POSTPARSE: backfillDeviceAndService,
25
+ });
26
+ //# sourceMappingURL=backfill-device-service-environment-variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill-device-service-environment-variable.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/backfill-device-service-environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,wBAAwB,CAAC,EACvC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;QACxB,QAAQ,EAAE,iBAAiB;QAC3B,EAAE,EAAE,IAAI;QACR,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC9B;KACD,CAAC,CAAC;IAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IACvC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,qCAAqC,EAAE;IACzE,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAC1E,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import './app-update-trigger.js';
2
+ import './backfill-device-service-environment-variable.js';
2
3
  import './device-update-trigger.js';
3
4
  import './image-is-stored-at-location.js';
4
5
  import './release-update-timestamp.js';
@@ -1,4 +1,5 @@
1
1
  import './app-update-trigger.js';
2
+ import './backfill-device-service-environment-variable.js';
2
3
  import './device-update-trigger.js';
3
4
  import './image-is-stored-at-location.js';
4
5
  import './release-update-timestamp.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,+BAA+B,CAAC;AACvC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,mDAAmD,CAAC;AAC3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,+BAA+B,CAAC;AACvC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,2BAA2B,CAAC"}
@@ -189,6 +189,11 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
189
189
  installs__image?: Array<import("../../../balena-model.js").ImageInstall["Read"]>;
190
190
  installs__application__has__service_name?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
191
191
  installs__service?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
192
+ is_of__device__installs__application__has__service_name__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
193
+ is_of__device__installs__service__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
194
+ is_of__device__installs__service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
195
+ is_of__service_install__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
196
+ is_of__device_service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
192
197
  }, "id" | "status" | "created_at" | "modified_at" | "api_heartbeat_state" | "changed_api_heartbeat_state_on__date" | "uuid" | "local_id" | "device_name" | "note" | "is_online" | "last_connectivity_event" | "is_connected_to_vpn" | "last_vpn_event" | "is_locked_until__date" | "public_address" | "ip_address" | "mac_address" | "memory_usage" | "memory_total" | "storage_block_device" | "storage_usage" | "storage_total" | "cpu_usage" | "cpu_temp" | "is_undervolted" | "cpu_id" | "download_progress" | "os_version" | "os_variant" | "supervisor_version" | "provisioning_progress" | "provisioning_state" | "api_port" | "api_secret" | "update_status" | "last_update_status_event" | "is_web_accessible" | "is_frozen" | "overall_status" | "overall_progress"> & {
193
198
  readonly device_config_variable: import("@balena/abstract-sql-to-typescript").PickDeferred<{
194
199
  created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
@@ -332,6 +337,11 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
332
337
  service_install?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
333
338
  is_installed_on__device?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
334
339
  is_built_by__image?: Array<import("../../../balena-model.js").Image["Read"]>;
340
+ is_of__device__installs__application__has__service_name__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
341
+ is_of__device__installs__service__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
342
+ is_of__device__installs__service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
343
+ is_of__service_install__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
344
+ is_of__device_service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
335
345
  }, "id" | "service_name"> & {
336
346
  readonly service_environment_variable: import("@balena/abstract-sql-to-typescript").PickDeferred<{
337
347
  created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
@@ -426,12 +436,21 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
426
436
  name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
427
437
  id: import("@balena/sbvr-types").Types["Serial"]["Read"];
428
438
  value: import("@balena/sbvr-types").Types["Text"]["Read"];
439
+ service: {
440
+ __id: import("../../../balena-model.js").Service["Read"]["id"];
441
+ } | [import("../../../balena-model.js").Service["Read"]] | [] | null;
442
+ device: {
443
+ __id: import("../../../balena-model.js").Device["Read"]["id"];
444
+ } | [import("../../../balena-model.js").Device["Read"]] | [] | null;
429
445
  device__installs__application__has__service_name: {
430
446
  __id: import("../../../balena-model.js").ServiceInstall["Read"]["id"];
431
447
  } | [import("../../../balena-model.js").ServiceInstall["Read"]];
432
448
  device__installs__service: {
433
449
  __id: import("../../../balena-model.js").ServiceInstall["Read"]["id"];
434
450
  } | [import("../../../balena-model.js").ServiceInstall["Read"]];
451
+ application__has__service_name: {
452
+ __id: import("../../../balena-model.js").Service["Read"]["id"];
453
+ } | [import("../../../balena-model.js").Service["Read"]] | [] | null;
435
454
  }, "name" | "value">[];
436
455
  })[];
437
456
  readonly belongs_to__application: (import("@balena/abstract-sql-to-typescript").PickDeferred<{
@@ -666,6 +685,11 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
666
685
  service_install?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
667
686
  is_installed_on__device?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
668
687
  is_built_by__image?: Array<import("../../../balena-model.js").Image["Read"]>;
688
+ is_of__device__installs__application__has__service_name__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
689
+ is_of__device__installs__service__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
690
+ is_of__device__installs__service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
691
+ is_of__service_install__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
692
+ is_of__device_service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
669
693
  }, "id" | "service_name"> & {
670
694
  readonly service_environment_variable: import("@balena/abstract-sql-to-typescript").PickDeferred<{
671
695
  created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
@@ -895,6 +919,11 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
895
919
  service_install?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
896
920
  is_installed_on__device?: Array<import("../../../balena-model.js").ServiceInstall["Read"]>;
897
921
  is_built_by__image?: Array<import("../../../balena-model.js").Image["Read"]>;
922
+ is_of__device__installs__application__has__service_name__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
923
+ is_of__device__installs__service__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
924
+ is_of__device__installs__service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
925
+ is_of__service_install__has__name?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
926
+ is_of__device_service_environment_variable?: Array<import("../../../balena-model.js").DeviceServiceEnvironmentVariable["Read"]>;
898
927
  }, "id" | "service_name"> & {
899
928
  readonly service_environment_variable: import("@balena/abstract-sql-to-typescript").PickDeferred<{
900
929
  created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
@@ -0,0 +1,14 @@
1
+ ALTER TABLE "device service environment variable"
2
+ ADD COLUMN IF NOT EXISTS "device" INTEGER NULL,
3
+ ADD CONSTRAINT "device service environment variable_device_fkey"
4
+ FOREIGN KEY ("device")
5
+ REFERENCES "device" ("id");
6
+
7
+ ALTER TABLE "device service environment variable"
8
+ ADD COLUMN IF NOT EXISTS "service" INTEGER NULL,
9
+ ADD CONSTRAINT "device service environment variable_service_fkey"
10
+ FOREIGN KEY ("service")
11
+ REFERENCES "service" ("id");
12
+
13
+ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "device service environment variable_device_service_name_key"
14
+ ON "device service environment variable" ("device", "service", "name");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@balena/open-balena-api",
3
3
  "description": "Internet of things, Made Simple",
4
- "version": "31.1.1",
4
+ "version": "31.2.0-build-add-device-service-fks-1ff87a4571c56db99c0ea335811003f32b366432-1",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -166,6 +166,6 @@
166
166
  "loader": "ts-node/esm/transpile-only"
167
167
  },
168
168
  "versionist": {
169
- "publishedAt": "2024-11-11T01:27:13.163Z"
169
+ "publishedAt": "2024-11-12T23:29:43.432Z"
170
170
  }
171
171
  }