@balena/open-balena-api 28.0.12-build-renovate-major-5-chai-d6dc0e320ea2053faebff644859f1d3ba40d54e7-1 → 29.0.0-build-reduce-service-install-usage-state-get-v3-427fd396ec055f8061204b216e28a5f9216da822-1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/features/device-state/routes/fleet-state-get-v3.d.ts +60 -0
- package/dist/features/device-state/routes/fleet-state-get-v3.js.map +1 -1
- package/dist/features/device-state/routes/state-get-v3.d.ts +879 -2
- package/dist/features/device-state/routes/state-get-v3.js +27 -19
- package/dist/features/device-state/routes/state-get-v3.js.map +1 -1
- package/dist/features/device-state/state-get-utils.d.ts +15 -27
- package/dist/features/device-state/state-get-utils.js +2 -9
- package/dist/features/device-state/state-get-utils.js.map +1 -1
- package/package.json +3 -3
@@ -24,12 +24,12 @@ export function buildAppFromRelease(device, application, release, config, defaul
|
|
24
24
|
// extract the per-image information
|
25
25
|
const image = ipr.image[0];
|
26
26
|
const si = serviceInstallFromImage(device ?? application, image);
|
27
|
+
const svc = image.is_a_build_of__service[0];
|
27
28
|
if (si == null) {
|
28
|
-
throw new Error(`Could not find service install for device or application: '${application.uuid}', image: '${image?.id}', service: '${JSON.stringify(
|
29
|
+
throw new Error(`Could not find service install for device or application: '${application.uuid}', image: '${image?.id}', service: '${JSON.stringify(svc)}', service: '${device != null
|
29
30
|
? JSON.stringify(device.service_install)
|
30
31
|
: JSON.stringify(application.service)}'`);
|
31
32
|
}
|
32
|
-
const svc = si.service?.[0] ?? si;
|
33
33
|
const environment = {};
|
34
34
|
varListInsert(ipr.image_environment_variable, environment);
|
35
35
|
varListInsert(application.application_environment_variable, environment);
|
@@ -37,7 +37,7 @@ export function buildAppFromRelease(device, application, release, config, defaul
|
|
37
37
|
if (device?.device_environment_variable) {
|
38
38
|
varListInsert(device.device_environment_variable, environment);
|
39
39
|
}
|
40
|
-
if (si
|
40
|
+
if ('device_service_environment_variable' in si) {
|
41
41
|
varListInsert(si.device_service_environment_variable, environment);
|
42
42
|
}
|
43
43
|
const labels = {
|
@@ -97,9 +97,21 @@ export const releaseExpand = {
|
|
97
97
|
'id',
|
98
98
|
'is_stored_at__image_location',
|
99
99
|
'content_hash',
|
100
|
-
'is_a_build_of__service',
|
101
100
|
'contract',
|
102
101
|
],
|
102
|
+
$expand: {
|
103
|
+
is_a_build_of__service: {
|
104
|
+
$select: ['id', 'service_name'],
|
105
|
+
$expand: {
|
106
|
+
service_environment_variable: {
|
107
|
+
$select: ['name', 'value'],
|
108
|
+
},
|
109
|
+
service_label: {
|
110
|
+
$select: ['label_name', 'value'],
|
111
|
+
},
|
112
|
+
},
|
113
|
+
},
|
114
|
+
},
|
103
115
|
},
|
104
116
|
image_label: {
|
105
117
|
$select: ['label_name', 'value'],
|
@@ -111,6 +123,13 @@ export const releaseExpand = {
|
|
111
123
|
},
|
112
124
|
},
|
113
125
|
};
|
126
|
+
const appSelect = [
|
127
|
+
'id',
|
128
|
+
'uuid',
|
129
|
+
'app_name',
|
130
|
+
'is_host',
|
131
|
+
'is_of__class',
|
132
|
+
];
|
114
133
|
const appExpand = {
|
115
134
|
application_environment_variable: {
|
116
135
|
$select: ['name', 'value'],
|
@@ -126,26 +145,15 @@ const deviceExpand = {
|
|
126
145
|
// `should_be_running__release` will automatically defer to the app release as necessary
|
127
146
|
should_be_running__release: releaseExpand,
|
128
147
|
service_install: {
|
129
|
-
$select: ['id'],
|
148
|
+
$select: ['id', 'service'],
|
130
149
|
$expand: {
|
131
|
-
service: {
|
132
|
-
$select: ['id', 'service_name'],
|
133
|
-
$expand: {
|
134
|
-
service_environment_variable: {
|
135
|
-
$select: ['name', 'value'],
|
136
|
-
},
|
137
|
-
service_label: {
|
138
|
-
$select: ['label_name', 'value'],
|
139
|
-
},
|
140
|
-
},
|
141
|
-
},
|
142
150
|
device_service_environment_variable: {
|
143
151
|
$select: ['name', 'value'],
|
144
152
|
},
|
145
153
|
},
|
146
154
|
},
|
147
155
|
belongs_to__application: {
|
148
|
-
$select:
|
156
|
+
$select: appSelect,
|
149
157
|
$expand: {
|
150
158
|
...appExpand,
|
151
159
|
application_config_variable: {
|
@@ -158,7 +166,7 @@ const deviceExpand = {
|
|
158
166
|
$expand: {
|
159
167
|
...releaseExpand.$expand,
|
160
168
|
belongs_to__application: {
|
161
|
-
$select:
|
169
|
+
$select: appSelect,
|
162
170
|
$expand: appExpand,
|
163
171
|
},
|
164
172
|
},
|
@@ -168,7 +176,7 @@ const deviceExpand = {
|
|
168
176
|
$expand: {
|
169
177
|
...releaseExpand.$expand,
|
170
178
|
belongs_to__application: {
|
171
|
-
$select:
|
179
|
+
$select: appSelect,
|
172
180
|
$expand: appExpand,
|
173
181
|
},
|
174
182
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state-get-v3.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-get-v3.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,6BAA6B,EAC7B,eAAe,EACf,uBAAuB,EACvB,aAAa,GACb,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;
|
1
|
+
{"version":3,"file":"state-get-v3.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-get-v3.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,6BAA6B,EAC7B,eAAe,EACf,uBAAuB,EACvB,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CAAC,EAAE;YACnB,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,IAAI,EAAE,WAAW,CAAC,QAAQ;YAC1B,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,KAAK,EAAE,WAAW,CAAC,YAAY;YAC/B,GAAG,CAAC,OAAO,IAAI,IAAI,IAAI;gBACtB,QAAQ,EAAE,mBAAmB,CAC5B,MAAM,EACN,WAAW,EACX,OAAO,EACP,MAAM,EACN,aAAa,CACb;aACD,CAAC;SACF;KACD,CAAC;AACH,CAAC,CAAC"}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import type { ExpandableStringKeyOf } from 'pinejs-client-core';
|
2
2
|
import type { dbModule, permissions } from '@balena/pinejs';
|
3
|
-
import type { Device
|
3
|
+
import type { Device } from '../../balena-model.js';
|
4
|
+
import type { ExpandedDevice as ExpandedDeviceV3, ExpandedRelease as ExpandedReleaseV3 } from './routes/state-get-v3.js';
|
5
|
+
import type { ExpandedApplicationWithService } from './routes/fleet-state-get-v3.js';
|
4
6
|
export declare const getStateEventAdditionalFields: Array<Exclude<keyof Device['Read'], ExpandableStringKeyOf<Device['Read']>>>;
|
5
7
|
declare const defaultConfigVariableFns: Array<(config: Dictionary<string>) => void>;
|
6
8
|
export declare const addDefaultConfigVariableFn: (fn: (typeof defaultConfigVariableFns)[number]) => void;
|
@@ -13,34 +15,20 @@ export declare const getConfig: (device: {
|
|
13
15
|
} | undefined, application?: {
|
14
16
|
application_config_variable: EnvVarList;
|
15
17
|
} | undefined) => Dictionary<string>;
|
16
|
-
type
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
};
|
23
|
-
type ExpandedServiceInstall = {
|
24
|
-
id: ServiceInstall['Read']['id'];
|
25
|
-
service: ExpandedService[];
|
26
|
-
device_service_environment_variable: EnvVarList;
|
27
|
-
};
|
18
|
+
type Image = ExpandedReleaseV3['contains__image'][number]['image'][number];
|
19
|
+
type ServiceInstall = ExpandedDeviceV3['service_install'][number];
|
20
|
+
type Service = ExpandedApplicationWithService['service'][number];
|
21
|
+
export declare function serviceInstallFromImage(deviceOrFleet: {
|
22
|
+
service_install: ServiceInstall[];
|
23
|
+
}, image?: Image): ServiceInstall | undefined;
|
28
24
|
export declare function serviceInstallFromImage(deviceOrFleet: {
|
29
|
-
|
30
|
-
}, image?:
|
31
|
-
is_a_build_of__service: number | {
|
32
|
-
__id: number;
|
33
|
-
};
|
34
|
-
}): ExpandedServiceInstall | undefined;
|
25
|
+
service: Service[];
|
26
|
+
}, image?: Image): Service | undefined;
|
35
27
|
export declare function serviceInstallFromImage(deviceOrFleet: {
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
};
|
41
|
-
}): ExpandedService | undefined;
|
42
|
-
/** @deprecated Use the strongly-typed overloads with `{ service_install }` or `{ service }` instead */
|
43
|
-
export declare function serviceInstallFromImage(deviceOrFleet: AnyObject, image?: AnyObject): undefined | AnyObject;
|
28
|
+
service_install: ServiceInstall[];
|
29
|
+
} | {
|
30
|
+
service: Service[];
|
31
|
+
}, image?: Image): Service | ServiceInstall | undefined;
|
44
32
|
export declare const formatImageLocation: (imageLocation: string) => string;
|
45
33
|
export declare const filterDeviceConfig: (configVars: Dictionary<string>) => void;
|
46
34
|
export declare const setReadTransaction: (newReadTransaction: dbModule.Database["readTransaction"]) => void;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import _ from 'lodash';
|
2
1
|
import { sbvrUtils, errors } from '@balena/pinejs';
|
3
2
|
import { DEFAULT_SUPERVISOR_POLL_INTERVAL, EMPTY_DEVICE_STATE_GET_DELAY_SECONDS, } from '../../lib/config.js';
|
4
3
|
import { createMultiLevelStore, reqPermissionNormalizer, } from '../../infra/cache/index.js';
|
@@ -39,15 +38,9 @@ export function serviceInstallFromImage(deviceOrFleet, image) {
|
|
39
38
|
if (image == null) {
|
40
39
|
return;
|
41
40
|
}
|
42
|
-
|
43
|
-
if (typeof image.is_a_build_of__service === 'object') {
|
44
|
-
id = image.is_a_build_of__service.__id;
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
id = image.is_a_build_of__service;
|
48
|
-
}
|
41
|
+
const id = image.is_a_build_of__service[0].id;
|
49
42
|
if ('service_install' in deviceOrFleet) {
|
50
|
-
return
|
43
|
+
return deviceOrFleet.service_install.find(({ service }) => service.__id === id);
|
51
44
|
}
|
52
45
|
else if ('service' in deviceOrFleet) {
|
53
46
|
return deviceOrFleet.service.find((fleetService) => fleetService.id === id);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state-get-utils.js","sourceRoot":"","sources":["../../../src/features/device-state/state-get-utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"state-get-utils.js","sourceRoot":"","sources":["../../../src/features/device-state/state-get-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACN,gCAAgC,EAChC,oCAAoC,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,4BAA4B,CAAC;AAQpC,MAAM,CAAC,MAAM,6BAA6B,GAEtC,EAAE,CAAC;AAEP,MAAM,wBAAwB,GAAgD;IAC7E,SAAS,kBAAkB,CAAC,MAAM;QACjC,MAAM,YAAY,GACjB,MAAM,CAAC,8BAA8B,IAAI,IAAI;YAC5C,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;QACxD,sEAAsE;QACtE,MAAM,CAAC,8BAA8B;YACpC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,gCAAgC,CAAC,CAAC;IAChE,CAAC;CACD,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACzC,EAA6C,EAC5C,EAAE;IACH,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAA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",
|
3
3
|
"description": "Internet of things, Made Simple",
|
4
|
-
"version": "
|
4
|
+
"version": "29.0.0-build-reduce-service-install-usage-state-get-v3-427fd396ec055f8061204b216e28a5f9216da822-1",
|
5
5
|
"license": "AGPL-3.0",
|
6
6
|
"repository": {
|
7
7
|
"type": "git",
|
@@ -136,7 +136,7 @@
|
|
136
136
|
},
|
137
137
|
"devDependencies": {
|
138
138
|
"@balena/lint": "^9.0.1",
|
139
|
-
"@types/chai": "^
|
139
|
+
"@types/chai": "^4.3.19",
|
140
140
|
"@types/mocha": "^10.0.8",
|
141
141
|
"@types/mockery": "^1.4.33",
|
142
142
|
"@types/sinon": "^17.0.3",
|
@@ -168,6 +168,6 @@
|
|
168
168
|
"loader": "ts-node/esm/transpile-only"
|
169
169
|
},
|
170
170
|
"versionist": {
|
171
|
-
"publishedAt": "2024-09-
|
171
|
+
"publishedAt": "2024-09-28T12:14:28.875Z"
|
172
172
|
}
|
173
173
|
}
|