@microtronics/studio-cli 0.13.0 → 0.15.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
 
2
2
 
3
+ ## 0.15.0 (2025-01-31)
4
+
5
+
6
+ ### Features
7
+
8
+ * **studio-cli:** removed `allowedBackends` and `target` from manifest.registry ([99398ae](https://bitbucket.org/microtronics-core/vscode-studio/commits/99398ae8e475946204d49045b8fff83c2f013e6d))
9
+
10
+ ## 0.14.0 (2025-01-29)
11
+
12
+
13
+ ### Features
14
+
15
+ * **studio-core:** allow editing the release notes of iot app versions ([2d19d13](https://bitbucket.org/microtronics-core/vscode-studio/commits/2d19d13ca32cceaf4a574a9594563d6dc0931fc5))
16
+
3
17
  ## 0.13.0 (2025-01-29)
4
18
 
5
19
 
@@ -175,15 +175,11 @@ declare interface components {
175
175
  targetSystem: components["schemas"]["TargetSystem"];
176
176
  /** @description ONE specific parameter for the organizationId */
177
177
  organizationId?: string;
178
- /**
179
- * @description Defines which servers are allowed to see this application. If null, the application wont be shared with anyone
180
- * @default null
181
- */
182
- allowedBackends: ("*" | string[]) | null;
178
+ /** @description Defines which servers are allowed to see this application. If null, the application wont be shared with anyone */
179
+ allowedBackends?: ("*" | string[]) | null;
183
180
  };
184
181
  ApplicationInformationBase: {
185
- /** @description The actual released version of the application */
186
- version: number;
182
+ version: components["parameters"]["ApplicationVersion"];
187
183
  publisherId: components["parameters"]["PublisherId"];
188
184
  } & components["schemas"]["NewApplication"];
189
185
  ApplicationListInformation: {
@@ -200,8 +196,7 @@ declare interface components {
200
196
  ApplicationVersion: {
201
197
  /** @description The name of the application when this version wos released */
202
198
  name: string;
203
- /** @description The version number */
204
- version: number;
199
+ version: components["parameters"]["ApplicationVersion"];
205
200
  /**
206
201
  * Format: date-time
207
202
  * @description Date when this version was published
@@ -1944,6 +1939,13 @@ export declare namespace Helper {
1944
1939
  * @param arrayIndex
1945
1940
  */
1946
1941
  export function patchValueWithArrayInfo(valueToPatch: any, arrayIndex: number): any;
1942
+ /**
1943
+ * Defer a given named task
1944
+ * @param token
1945
+ * @param timeout Milliseconds
1946
+ * @param callback Callback
1947
+ */
1948
+ export function defer(token: string, timeout: number, callback: any): void;
1947
1949
  }
1948
1950
 
1949
1951
  export declare namespace Library {
@@ -2042,7 +2044,14 @@ export declare namespace Manifest {
2042
2044
  };
2043
2045
  registry?: {
2044
2046
  id?: string;
2045
- allowedBackends?: null | '*' | string[];
2047
+ /**
2048
+ * @deprecated
2049
+ */
2050
+ allowedBackends?: Registry.ApiNewApplication['allowedBackends'];
2051
+ /**
2052
+ * @deprecated
2053
+ */
2054
+ target?: Registry.ApiNewApplication['targetSystem'];
2046
2055
  };
2047
2056
  pov?: {
2048
2057
  details?: ApmPartScripts;
@@ -3358,7 +3367,7 @@ declare interface paths {
3358
3367
  patch?: never;
3359
3368
  trace?: never;
3360
3369
  };
3361
- "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{fileName}": {
3370
+ "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}": {
3362
3371
  parameters: {
3363
3372
  query?: never;
3364
3373
  header?: never;
@@ -4234,7 +4243,7 @@ export declare namespace Registry {
4234
4243
  * @param libraryId
4235
4244
  */
4236
4245
  export function getLibraryProfile(token: AuthToken, publisherId: string, libraryId: string): Promise<LibraryProfile>;
4237
- export function fetchLibraryContent(token: AuthToken, contentURL: string, json?: boolean): Promise<any>;
4246
+ export function fetchCustomContent(token: AuthToken, contentURL: string, json?: boolean, env?: Globals.ENV): Promise<ArrayBuffer | any>;
4238
4247
  export type Publisher = components['schemas']['Publisher'];
4239
4248
  export function getPublisher(token: AuthToken, publisherId: string): Promise<Publisher | null>;
4240
4249
  export type ApiNewApplication = components['schemas']['NewApplication'];
@@ -4251,6 +4260,8 @@ export declare namespace Registry {
4251
4260
  'CHANGELOG.md': Uint8Array;
4252
4261
  };
4253
4262
  export function publishLibraryVersion(token: AuthToken, publisherId: string, libraryId: string, libraryVersion: string, files: LibraryFiles, env?: Globals.ENV): Promise<void>;
4263
+ export type ApplicationFileName = components['parameters']['ApplicationFileName'];
4264
+ export function updateApplicationFile(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, applicationFileName: ApplicationFileName, blob: Uint8Array, env?: Globals.ENV): Promise<void>;
4254
4265
  }
4255
4266
 
4256
4267
  declare function uriToMemFsPath(path: URI): string;
@@ -237,7 +237,7 @@ var Dependencies;
237
237
  if (!libraryArchive) {
238
238
  throw new Error(`Library ${publisherIdName} has no content!`);
239
239
  }
240
- const libraryBuffer = await registryAPI_1.Registry.fetchLibraryContent(token, libraryArchive.downloadUrl);
240
+ const libraryBuffer = await registryAPI_1.Registry.fetchCustomContent(token, libraryArchive.downloadUrl);
241
241
  await extractLibraryContent(cwd, fs, libraryName, libraryBuffer);
242
242
  // update manifest
243
243
  const manifest = await manifest_1.Manifest.read(cwd, fs);
@@ -337,7 +337,7 @@ var Dependencies;
337
337
  Dependencies.getApmPartDependencies = getApmPartDependencies;
338
338
  })(Dependencies || (exports.Dependencies = Dependencies = {}));
339
339
  async function fetchStudioJson(token, studioJsonURL) {
340
- return await registryAPI_1.Registry.fetchLibraryContent(token, studioJsonURL, true);
340
+ return await registryAPI_1.Registry.fetchCustomContent(token, studioJsonURL, true);
341
341
  }
342
342
  async function validateIfLibraryCanBeRemoved(cwd, fs, dependencies) {
343
343
  const allLibraries = {};
package/out/helper.js CHANGED
@@ -119,5 +119,27 @@ var Helper;
119
119
  }
120
120
  }
121
121
  Helper.patchValueWithArrayInfo = patchValueWithArrayInfo;
122
+ const _deferrals = {}; // <token>:{ handler:func, tmr:timeoutHandle }
123
+ /**
124
+ * Defer a given named task
125
+ * @param token
126
+ * @param timeout Milliseconds
127
+ * @param callback Callback
128
+ */
129
+ function defer(token, timeout, callback) {
130
+ const d = _deferrals[token];
131
+ if (d) {
132
+ clearTimeout(d.timer);
133
+ }
134
+ _deferrals[token] = {
135
+ // @ts-ignore
136
+ timer: setTimeout(() => {
137
+ delete _deferrals[token];
138
+ callback();
139
+ }, timeout),
140
+ handler: callback
141
+ };
142
+ }
143
+ Helper.defer = defer;
122
144
  })(Helper || (exports.Helper = Helper = {}));
123
145
  //# sourceMappingURL=helper.js.map
package/out/manifest.js CHANGED
@@ -90,6 +90,7 @@ var Manifest;
90
90
  manifestCache.clear();
91
91
  // patch the options if they are not valid for a specific device profile
92
92
  patchDloCompileOptionsBasedOnDpid(manifest);
93
+ removeDeprecatedOptions(manifest);
93
94
  return fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, STUDIO_JSON_NAME), JSON.stringify(manifest, null, '\t'));
94
95
  }
95
96
  Manifest.write = write;
@@ -328,4 +329,10 @@ function patchDloCompileOptionsBasedOnDpid(manifest) {
328
329
  });
329
330
  }
330
331
  }
332
+ function removeDeprecatedOptions(manifest) {
333
+ if (manifest.registry) {
334
+ delete manifest.registry.allowedBackends;
335
+ delete manifest.registry.target;
336
+ }
337
+ }
331
338
  //# sourceMappingURL=manifest.js.map
@@ -173,12 +173,12 @@ var APM;
173
173
  async function registerNew(cwd, fs, token, manifest, env) {
174
174
  // only myDatanet -> ONE support not needed.
175
175
  const backendTarget = 'myDatanet';
176
- const { publisher, name, description, registry } = manifest;
176
+ const { publisher, name, description } = manifest;
177
177
  const newApplication = {
178
178
  name: name,
179
179
  targetSystem: backendTarget,
180
180
  description: description || '',
181
- allowedBackends: registry?.allowedBackends ?? null
181
+ allowedBackends: null
182
182
  };
183
183
  // create new application
184
184
  const projectId = await registryAPI_1.Registry.createNewApplication(token, publisher, newApplication, env);
@@ -186,8 +186,7 @@ var APM;
186
186
  throw new Error('Failed to initialize application');
187
187
  }
188
188
  manifest.registry = {
189
- id: projectId,
190
- allowedBackends: newApplication.allowedBackends
189
+ id: projectId
191
190
  };
192
191
  // write the updated manifest to disk
193
192
  await manifest_1.Manifest.write(cwd, fs, manifest);
@@ -206,8 +205,6 @@ var APM;
206
205
  const { name, publisher, description, registry } = await manifest_1.Manifest.read(cwd, fs);
207
206
  const applicationId = registry?.id;
208
207
  await registryAPI_1.Registry.updateExistingApplication(token, publisher, applicationId, {
209
- // @ts-ignore
210
- allowedBackends: registry.allowedBackends,
211
208
  description: description,
212
209
  name: name,
213
210
  targetSystem: 'myDatanet'
@@ -154,7 +154,7 @@ var Package;
154
154
  */
155
155
  async function validatePublishSettings(cwd, fs, token) {
156
156
  const manifest = await manifest_1.Manifest.read(cwd, fs);
157
- const { name, publisher, description, registry } = manifest;
157
+ const { name, publisher, description } = manifest;
158
158
  const invalidName = manifest_1.Manifest.validateProjectName(name, manifest_1.Manifest.isLibraryProject(manifest));
159
159
  if (invalidName) {
160
160
  throw new Error(`name: ${invalidName}`);
@@ -171,10 +171,6 @@ var Package;
171
171
  if (!manifest_1.Manifest.isLibraryProject(manifest)) {
172
172
  await manifest_1.Manifest.validateApplicationIcon(cwd, fs, manifest);
173
173
  manifest_1.Manifest.validateEngineSettings(manifest);
174
- const invalidBackends = await manifest_1.Manifest.validateRegistryAllowedBackends(registry?.allowedBackends);
175
- if (invalidBackends) {
176
- throw new Error(`registry: ${invalidBackends}`);
177
- }
178
174
  }
179
175
  }
180
176
  Package.validatePublishSettings = validatePublishSettings;
@@ -48,9 +48,13 @@ var Registry;
48
48
  return data;
49
49
  }
50
50
  Registry.getLibraryProfile = getLibraryProfile;
51
- async function fetchLibraryContent(token, contentURL, json = false) {
51
+ async function fetchCustomContent(token, contentURL, json = false, env = globals_1.Globals.ENV.production) {
52
52
  const response = await fetch(contentURL, {
53
- headers: { ...buildAuthHeader(token) }
53
+ // @ts-ignore
54
+ headers: {
55
+ ...buildAuthHeader(token),
56
+ ...headerBasedOnEnv(env)
57
+ }
54
58
  });
55
59
  if (response.status === 200) {
56
60
  if (json) {
@@ -64,7 +68,7 @@ var Registry;
64
68
  throw new Error('Failed to fetch the library content');
65
69
  }
66
70
  }
67
- Registry.fetchLibraryContent = fetchLibraryContent;
71
+ Registry.fetchCustomContent = fetchCustomContent;
68
72
  async function getPublisher(token, publisherId) {
69
73
  try {
70
74
  const { data, error } = await GET('/publisher/{publisherId}', {
@@ -240,6 +244,33 @@ var Registry;
240
244
  }
241
245
  }
242
246
  Registry.publishLibraryVersion = publishLibraryVersion;
247
+ async function updateApplicationFile(token, publisherId, applicationId, applicationVersion, applicationFileName, blob, env = globals_1.Globals.ENV.production) {
248
+ const { error } = await POST('/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}', {
249
+ ...Registry.getAPIUrl(),
250
+ headers: {
251
+ ...buildAuthHeader(token),
252
+ ...headerBasedOnEnv(env),
253
+ 'Content-Type': 'application/octet-stream'
254
+ },
255
+ params: {
256
+ path: {
257
+ publisherId,
258
+ applicationId,
259
+ applicationVersion,
260
+ applicationFileName
261
+ }
262
+ },
263
+ //@ts-ignore
264
+ body: {},
265
+ bodySerializer() {
266
+ return blob;
267
+ }
268
+ });
269
+ if (error) {
270
+ throw new Error(error.reason);
271
+ }
272
+ }
273
+ Registry.updateApplicationFile = updateApplicationFile;
243
274
  })(Registry || (exports.Registry = Registry = {}));
244
275
  /**
245
276
  * inject the X-Semver header for application based requests
package/package.json CHANGED
@@ -1,76 +1,76 @@
1
- {
2
- "name": "@microtronics/studio-cli",
3
- "version": "0.13.0",
4
- "description": "Microtronics Studio CLI Tool",
5
- "main": "./out/api.js",
6
- "typings": "./dist/studio-cli.d.ts",
7
- "bin": {
8
- "studio-cli": "studio-cli"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "release": "release-it --ci",
15
- "compile": "npm run build:registryApiTypings && tsc",
16
- "api": "api-extractor run --local --verbose",
17
- "build": "npm run compile && npm run api",
18
- "watch:build": "npm run compile -- --watch",
19
- "test": "cross-env STUDIO_ENV=lucky mocha",
20
- "test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
21
- "watch:test": "npm run test -- --watch",
22
- "prepublishOnly": "npm run build",
23
- "build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
24
- },
25
- "author": "Microtronics",
26
- "license": "ISC",
27
- "dependencies": {
28
- "ajv": "^8.17.1",
29
- "ajv-formats": "^3.0.1",
30
- "ajv-keywords": "^5.1.0",
31
- "commander": "^12.1.0",
32
- "cross-fetch": "^4.0.0",
33
- "glob": "^11.0.1",
34
- "iconv-lite": "^0.6.3",
35
- "minimatch": "^10.0.1",
36
- "ini": "^5.0.0",
37
- "openapi-fetch": "^0.13.0",
38
- "pako": "^2.1.0",
39
- "semver": "^7.6.3",
40
- "tarballjs": "github:ankitrohatgi/tarballjs",
41
- "tinytar-fix": "^0.1.1",
42
- "vscode-uri": "^3.0.8",
43
- "yaml": "^2.6.1",
44
- "image-dimensions": "^2.3.0",
45
- "file-type-checker": "^1.1.2"
46
- },
47
- "engines": {
48
- "node": ">= 22"
49
- },
50
- "devDependencies": {
51
- "@microsoft/api-extractor": "^7.47.11",
52
- "@types/chai": "^4.3.6",
53
- "@types/chai-as-promised": "^7.1.5",
54
- "@types/ini": "^4.1.1",
55
- "@types/mocha": "^10.0.9",
56
- "@types/node": "^22.9.1",
57
- "@types/semver": "^7.5.6",
58
- "@types/vscode": "^1.86.2",
59
- "chai": "^4.3.8",
60
- "chai-as-promised": "^7.1.2",
61
- "cross-env": "^7.0.3",
62
- "mocha": "^10.8.2",
63
- "mocha-junit-reporter": "^2.2.1",
64
- "openapi-typescript": "^7.4.3",
65
- "ts-node": "^10.9.2",
66
- "typescript": "^5.6.3"
67
- },
68
- "mocha": {
69
- "require": [
70
- "ts-node/register"
71
- ],
72
- "watch-files": "src/**",
73
- "spec": "./test/**/*.spec.ts",
74
- "recursive": true
75
- }
76
- }
1
+ {
2
+ "name": "@microtronics/studio-cli",
3
+ "version": "0.15.0",
4
+ "description": "Microtronics Studio CLI Tool",
5
+ "main": "./out/api.js",
6
+ "typings": "./dist/studio-cli.d.ts",
7
+ "bin": {
8
+ "studio-cli": "studio-cli"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "release": "release-it --ci",
15
+ "compile": "npm run build:registryApiTypings && tsc",
16
+ "api": "api-extractor run --local --verbose",
17
+ "build": "npm run compile && npm run api",
18
+ "watch:build": "npm run compile -- --watch",
19
+ "test": "cross-env STUDIO_ENV=lucky mocha",
20
+ "test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
21
+ "watch:test": "npm run test -- --watch",
22
+ "prepublishOnly": "npm run build",
23
+ "build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
24
+ },
25
+ "author": "Microtronics",
26
+ "license": "ISC",
27
+ "dependencies": {
28
+ "ajv": "^8.17.1",
29
+ "ajv-formats": "^3.0.1",
30
+ "ajv-keywords": "^5.1.0",
31
+ "commander": "^12.1.0",
32
+ "cross-fetch": "^4.0.0",
33
+ "glob": "^11.0.1",
34
+ "iconv-lite": "^0.6.3",
35
+ "minimatch": "^10.0.1",
36
+ "ini": "^5.0.0",
37
+ "openapi-fetch": "^0.13.0",
38
+ "pako": "^2.1.0",
39
+ "semver": "^7.6.3",
40
+ "tarballjs": "github:ankitrohatgi/tarballjs",
41
+ "tinytar-fix": "^0.1.1",
42
+ "vscode-uri": "^3.0.8",
43
+ "yaml": "^2.6.1",
44
+ "image-dimensions": "^2.3.0",
45
+ "file-type-checker": "^1.1.2"
46
+ },
47
+ "engines": {
48
+ "node": ">= 22"
49
+ },
50
+ "devDependencies": {
51
+ "@microsoft/api-extractor": "^7.47.11",
52
+ "@types/chai": "^4.3.6",
53
+ "@types/chai-as-promised": "^7.1.5",
54
+ "@types/ini": "^4.1.1",
55
+ "@types/mocha": "^10.0.9",
56
+ "@types/node": "^22.9.1",
57
+ "@types/semver": "^7.5.6",
58
+ "@types/vscode": "^1.86.2",
59
+ "chai": "^4.3.8",
60
+ "chai-as-promised": "^7.1.2",
61
+ "cross-env": "^7.0.3",
62
+ "mocha": "^10.8.2",
63
+ "mocha-junit-reporter": "^2.2.1",
64
+ "openapi-typescript": "^7.6.0",
65
+ "ts-node": "^10.9.2",
66
+ "typescript": "^5.6.3"
67
+ },
68
+ "mocha": {
69
+ "require": [
70
+ "ts-node/register"
71
+ ],
72
+ "watch-files": "src/**",
73
+ "spec": "./test/**/*.spec.ts",
74
+ "recursive": true
75
+ }
76
+ }