@balena/open-balena-api 31.2.9-build-resolve-dsev-permission-with-device-2dc23ee89aaea920572df3ffabc06fa8fe5770e8-1 → 31.2.9-build-v2-state-get-wo-si-b661e36512aca5efdc4edccca18b8c9e18e6bb1b-1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,16 +23,13 @@ function buildAppFromRelease(device, application, release, config) {
23
23
  for (const ipr of release.release_image) {
24
24
  // extract the per-image information
25
25
  const image = ipr.image[0];
26
- const si = device.service_install.find(({ service }) => service.__id === image.is_a_build_of__service[0].id);
27
26
  const svc = image.is_a_build_of__service[0];
28
27
  const environment = {};
29
28
  varListInsert(ipr.image_environment_variable, environment);
30
29
  varListInsert(application.application_environment_variable, environment);
31
30
  varListInsert(svc.service_environment_variable, environment);
32
31
  varListInsert(device.device_environment_variable, environment);
33
- if (si != null) {
34
- varListInsert(si.device_service_environment_variable, environment);
35
- }
32
+ varListInsert(svc.is_of__device_service_environment_variable, environment);
36
33
  const labels = {};
37
34
  for (const { label_name, value } of [
38
35
  ...ipr.image_label,
@@ -112,6 +109,9 @@ const stateQuery = _.once(() => api.resin.prepare({
112
109
  is_a_build_of__service: {
113
110
  $select: ['id', 'service_name'],
114
111
  $expand: {
112
+ is_of__device_service_environment_variable: {
113
+ $select: ['name', 'value'],
114
+ },
115
115
  service_environment_variable: {
116
116
  $select: ['name', 'value'],
117
117
  },
@@ -132,14 +132,6 @@ const stateQuery = _.once(() => api.resin.prepare({
132
132
  },
133
133
  },
134
134
  },
135
- service_install: {
136
- $select: ['id', 'service'],
137
- $expand: {
138
- device_service_environment_variable: {
139
- $select: ['name', 'value'],
140
- },
141
- },
142
- },
143
135
  belongs_to__application: {
144
136
  $select: ['id', 'app_name'],
145
137
  $expand: {
@@ -1 +1 @@
1
- {"version":3,"file":"state-get-v2.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-get-v2.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB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AAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC"}
1
+ {"version":3,"file":"state-get-v2.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-get-v2.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,SAAS,EACT,6BAA6B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AA4C1B,SAAS,mBAAmB,CAC3B,MAAsB,EACtB,WAA8D,EAC9D,OAA6D,EAC7D,MAA0B;IAE1B,IAAI,WAAW,GAAc,EAAE,CAAC;IAChC,MAAM,QAAQ,GAA8B,EAAE,CAAC;IAE/C,wDAAwD;IACxD,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACnC,CAAC;SAAM,CAAC;QACP,IAAI,CAAC;YACJ,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACR,WAAW,GAAG,EAAE,CAAC;QAClB,CAAC;IACF,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QACzC,oCAAoC;QACpC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE3B,MAAM,GA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} 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.UnauthorizedError();
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/service-install/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,iBAAiB,EAAE,CAAC;IACtC,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 +1 @@
1
- import './backfill-service-install-on-device-service-env-var.js';
1
+ import './backfill-device-service-environment-variable.js';
@@ -1,2 +1,2 @@
1
- import './backfill-service-install-on-device-service-env-var.js';
1
+ import './backfill-device-service-environment-variable.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yDAAyD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,mDAAmD,CAAC"}
@@ -1,32 +1,2 @@
1
- import { hooks, sbvrUtils, errors } from '@balena/pinejs';
2
- const addReadOnlyHook = (methods, resource, hook) => {
3
- methods.map((method) => {
4
- hooks.addHook(method, 'v7', resource, {
5
- ...hook,
6
- sideEffects: false,
7
- readOnlyTx: true,
8
- });
9
- });
10
- };
11
- addReadOnlyHook(['POST', 'PATCH', 'PUT'], 'device_service_environment_variable', {
12
- POSTPARSE: async ({ request, api }) => {
13
- const { service_install: siId } = request.values;
14
- if (siId == null) {
15
- return;
16
- }
17
- const si = await sbvrUtils.api.resin.get({
18
- resource: 'service_install',
19
- passthrough: api.passthrough,
20
- id: siId,
21
- options: {
22
- $select: ['device', 'service'],
23
- },
24
- });
25
- if (si == null) {
26
- throw new errors.UnauthorizedError();
27
- }
28
- request.values.device = si.device.__id;
29
- request.values.service = si.service.__id;
30
- },
31
- });
1
+ export {};
32
2
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/translations/v7/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,eAAe,GAAG,CACvB,OAAmD,EACnD,QAAgB,EAChB,IAA2B,EAC1B,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACtB,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,GAAG,IAAI;YACP,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,CACd,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EACxB,qCAAqC,EACrC;IACC,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE;QACrC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO;QACR,CAAC;QAED,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;YACxC,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,EAAE,EAAE,IAAI;YACR,OAAO,EAAE;gBACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;aAC9B;SACD,CAAC,CAAC;QAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACtC,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1C,CAAC;CACD,CACD,CAAC"}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/translations/v7/hooks.ts"],"names":[],"mappings":""}
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.2.9-build-resolve-dsev-permission-with-device-2dc23ee89aaea920572df3ffabc06fa8fe5770e8-1",
4
+ "version": "31.2.9-build-v2-state-get-wo-si-b661e36512aca5efdc4edccca18b8c9e18e6bb1b-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-19T23:57:47.310Z"
169
+ "publishedAt": "2024-11-20T15:33:07.693Z"
170
170
  }
171
171
  }
@@ -1,41 +0,0 @@
1
- import { hooks, errors } from '@balena/pinejs';
2
- async function backfillServiceInstall({ request, api, }) {
3
- const { device: deviceId, service: serviceId } = request.values;
4
- if (deviceId == null && serviceId == null) {
5
- return;
6
- }
7
- if ((deviceId == null && serviceId != null) ||
8
- (deviceId != null && serviceId == null)) {
9
- throw new errors.BadRequestError('Both or none of device and service must be specified');
10
- }
11
- let si = await api.get({
12
- resource: 'service_install',
13
- id: {
14
- device: deviceId,
15
- installs__service: serviceId,
16
- },
17
- options: {
18
- $select: ['id'],
19
- },
20
- });
21
- if (si == null) {
22
- si = await api.post({
23
- resource: 'service_install',
24
- body: {
25
- device: deviceId,
26
- installs__service: serviceId,
27
- },
28
- });
29
- }
30
- if (si == null) {
31
- throw new errors.BadRequestError(`No service install exists for device: ${deviceId} and service ${serviceId} and one could not be created`);
32
- }
33
- request.values.service_install = si.id;
34
- }
35
- hooks.addPureHook('POST', 'resin', 'device_service_environment_variable', {
36
- POSTPARSE: backfillServiceInstall,
37
- });
38
- hooks.addPureHook('PATCH', 'resin', 'device_service_environment_variable', {
39
- POSTPARSE: backfillServiceInstall,
40
- });
41
- //# sourceMappingURL=backfill-service-install-on-device-service-env-var.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backfill-service-install-on-device-service-env-var.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/backfill-service-install-on-device-service-env-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,sBAAsB,CAAC,EACrC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhE,IAAI,QAAQ,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QAC3C,OAAO;IACR,CAAC;IAED,IACC,CAAC,QAAQ,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC;QACvC,CAAC,QAAQ,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,EACtC,CAAC;QACF,MAAM,IAAI,MAAM,CAAC,eAAe,CAC/B,sDAAsD,CACtD,CAAC;IACH,CAAC;IAED,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;QACtB,QAAQ,EAAE,iBAAiB;QAC3B,EAAE,EAAE;YACH,MAAM,EAAE,QAAQ;YAChB,iBAAiB,EAAE,SAAS;SAC5B;QACD,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,IAAI,CAAC;SACf;KACD,CAAC,CAAC;IAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAChB,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,iBAAiB;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