@balena/open-balena-api 32.2.1-build-stop-filling-in-service-install-on-dsev-a20e9ab16f25a3b1f0329f7a5dc85935a5c1b5c2-2 → 32.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.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 './nullify-si-on-device-service-environment-variable.js';
1
+ import './backfill-device-service-environment-variable.js';
@@ -1,2 +1,2 @@
1
- import './nullify-si-on-device-service-environment-variable.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,wDAAwD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,mDAAmD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -209,7 +209,6 @@ export declare const translations: {
209
209
  getTranslations: (_abstractSqlModel?: import("@balena/abstract-sql-compiler").AbstractSqlModel) => {
210
210
  'device-installs-application-has-service name-has-name': {
211
211
  $toResource: string;
212
- 'service install': ["SelectQuery", ["Select", [["ReferencedField", "si", string]]], ["From", ["Alias", ["Table", "service install"], "si"]], ["Where", ["And", ["Equals", ["ReferencedField", "device-installs-application-has-service name-has-name", "device"], ["ReferencedField", "si", string]], ["Equals", ["ReferencedField", "device-installs-application-has-service name-has-name", "service"], ["ReferencedField", "si", string]]]]];
213
212
  };
214
213
  };
215
214
  loadHooks: () => Promise<typeof import("./translations/v7/hooks.js")>;
@@ -1,38 +1,6 @@
1
1
  import { addDeleteHookForDependents } from '../../infra/cascade-delete/index.js';
2
- import { hooks, sbvrUtils, errors } from '@balena/pinejs';
3
- const addReadOnlyHook = (methods, resource, hook) => {
4
- methods.map((method) => {
5
- hooks.addHook(method, 'v7', resource, {
6
- ...hook,
7
- sideEffects: false,
8
- readOnlyTx: true,
9
- });
10
- });
11
- };
12
2
  // Service install resource should only be used for <= v7 translations
13
3
  addDeleteHookForDependents('v7', 'service_install', {
14
4
  device_service_environment_variable: 'service_install',
15
5
  });
16
- addReadOnlyHook(['POST', 'PATCH', 'PUT'], 'device_service_environment_variable', {
17
- POSTPARSE: async ({ request, api }) => {
18
- const { service_install: siId } = request.values;
19
- if (siId == null) {
20
- return;
21
- }
22
- const si = await sbvrUtils.api.resin.get({
23
- resource: 'service_install',
24
- passthrough: api.passthrough,
25
- id: siId,
26
- options: {
27
- $select: ['device', 'service'],
28
- },
29
- });
30
- if (si == null) {
31
- throw new errors.UnauthorizedError();
32
- }
33
- request.values.device = si.device.__id;
34
- request.values.service = si.service.__id;
35
- delete request.values.service_install;
36
- },
37
- });
38
6
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/translations/v7/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,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;Q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/v7/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF,sEAAsE;AACtE,0BAA0B,CAAC,IAAI,EAAE,iBAAiB,EAAE;IACnD,mCAAmC,EAAE,iBAAiB;CACtD,CAAC,CAAC"}
@@ -3,6 +3,5 @@ export declare const v7AbstractSqlModel: import("@balena/abstract-sql-compiler")
3
3
  export declare const getV7Translations: (_abstractSqlModel?: import("@balena/abstract-sql-compiler").AbstractSqlModel) => {
4
4
  'device-installs-application-has-service name-has-name': {
5
5
  $toResource: string;
6
- 'service install': ["SelectQuery", ["Select", [["ReferencedField", "si", string]]], ["From", ["Alias", ["Table", "service install"], "si"]], ["Where", ["And", ["Equals", ["ReferencedField", "device-installs-application-has-service name-has-name", "device"], ["ReferencedField", "si", string]], ["Equals", ["ReferencedField", "device-installs-application-has-service name-has-name", "service"], ["ReferencedField", "si", string]]]]];
7
6
  };
8
7
  };
@@ -10,35 +10,6 @@ export const getV7Translations = (_abstractSqlModel = v7AbstractSqlModel) => {
10
10
  return {
11
11
  'device-installs-application-has-service name-has-name': {
12
12
  $toResource: 'device-has-application-has-service name-has-name',
13
- 'service install': [
14
- 'SelectQuery',
15
- ['Select', [['ReferencedField', 'si', 'id']]],
16
- ['From', ['Alias', ['Table', 'service install'], 'si']],
17
- [
18
- 'Where',
19
- [
20
- 'And',
21
- [
22
- 'Equals',
23
- [
24
- 'ReferencedField',
25
- 'device-installs-application-has-service name-has-name',
26
- 'device',
27
- ],
28
- ['ReferencedField', 'si', 'device'],
29
- ],
30
- [
31
- 'Equals',
32
- [
33
- 'ReferencedField',
34
- 'device-installs-application-has-service name-has-name',
35
- 'service',
36
- ],
37
- ['ReferencedField', 'si', 'installs-service'],
38
- ],
39
- ],
40
- ],
41
- ],
42
13
  },
43
14
  };
44
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"v7.js","sourceRoot":"","sources":["../../../src/translations/v7/v7.ts"],"names":[],"mappings":"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,"file":"v7.js","sourceRoot":"","sources":["../../../src/translations/v7/v7.ts"],"names":[],"mappings":"AACA,OAAO,EACN,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,gCAAgC,MAAM,+EAA+E,CAAC;AAElI,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAwB,CACzD,IAAI,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CACnC,CAAC;AAEF,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;AAE3C,iBAAiB,CAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAEpE,gCAAgC,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAChE,+GAA+G;AAC/G,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,iBAAiB,GAAG,kBAAkB,EAAE,EAAE;IAC3E,OAAO;QACN,uDAAuD,EAAE;YACxD,WAAW,EAAE,kDAAkD;SAC/D;KAC4C,CAAC;AAChD,CAAC,CAAC"}
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": "32.2.1-build-stop-filling-in-service-install-on-dsev-a20e9ab16f25a3b1f0329f7a5dc85935a5c1b5c2-2",
4
+ "version": "32.2.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-12-11T11:11:36.457Z"
169
+ "publishedAt": "2024-12-11T12:29:03.623Z"
170
170
  }
171
171
  }
@@ -1,12 +0,0 @@
1
- import { hooks } from '@balena/pinejs';
2
- // TODO: Drop this once `device_service_environment_variable.service_install` gets removed from the sbvr
3
- function backfillDeviceAndService({ request }) {
4
- delete request.values.service_install;
5
- }
6
- hooks.addPureHook('POST', 'resin', 'device_service_environment_variable', {
7
- POSTPARSE: backfillDeviceAndService,
8
- });
9
- hooks.addPureHook('PATCH', 'resin', 'device_service_environment_variable', {
10
- POSTPARSE: backfillDeviceAndService,
11
- });
12
- //# sourceMappingURL=nullify-si-on-device-service-environment-variable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nullify-si-on-device-service-environment-variable.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/nullify-si-on-device-service-environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,gBAAgB,CAAC;AAEvD,wGAAwG;AACxG,SAAS,wBAAwB,CAAC,EAAE,OAAO,EAA+B;IACzE,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;AACvC,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"}