@microtronics/studio-cli 0.13.0 → 0.14.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,12 @@
1
1
 
2
2
 
3
+ ## 0.14.0 (2025-01-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * **studio-core:** allow editing the release notes of iot app versions ([2d19d13](https://bitbucket.org/microtronics-core/vscode-studio/commits/2d19d13ca32cceaf4a574a9594563d6dc0931fc5))
9
+
3
10
  ## 0.13.0 (2025-01-29)
4
11
 
5
12
 
@@ -1944,6 +1944,13 @@ export declare namespace Helper {
1944
1944
  * @param arrayIndex
1945
1945
  */
1946
1946
  export function patchValueWithArrayInfo(valueToPatch: any, arrayIndex: number): any;
1947
+ /**
1948
+ * Defer a given named task
1949
+ * @param token
1950
+ * @param timeout Milliseconds
1951
+ * @param callback Callback
1952
+ */
1953
+ export function defer(token: string, timeout: number, callback: any): void;
1947
1954
  }
1948
1955
 
1949
1956
  export declare namespace Library {
@@ -3358,7 +3365,7 @@ declare interface paths {
3358
3365
  patch?: never;
3359
3366
  trace?: never;
3360
3367
  };
3361
- "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{fileName}": {
3368
+ "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}": {
3362
3369
  parameters: {
3363
3370
  query?: never;
3364
3371
  header?: never;
@@ -4234,7 +4241,7 @@ export declare namespace Registry {
4234
4241
  * @param libraryId
4235
4242
  */
4236
4243
  export function getLibraryProfile(token: AuthToken, publisherId: string, libraryId: string): Promise<LibraryProfile>;
4237
- export function fetchLibraryContent(token: AuthToken, contentURL: string, json?: boolean): Promise<any>;
4244
+ export function fetchCustomContent(token: AuthToken, contentURL: string, json?: boolean, env?: Globals.ENV): Promise<ArrayBuffer | any>;
4238
4245
  export type Publisher = components['schemas']['Publisher'];
4239
4246
  export function getPublisher(token: AuthToken, publisherId: string): Promise<Publisher | null>;
4240
4247
  export type ApiNewApplication = components['schemas']['NewApplication'];
@@ -4251,6 +4258,8 @@ export declare namespace Registry {
4251
4258
  'CHANGELOG.md': Uint8Array;
4252
4259
  };
4253
4260
  export function publishLibraryVersion(token: AuthToken, publisherId: string, libraryId: string, libraryVersion: string, files: LibraryFiles, env?: Globals.ENV): Promise<void>;
4261
+ export type ApplicationFileName = components['parameters']['ApplicationFileName'];
4262
+ export function updateApplicationFile(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, applicationFileName: ApplicationFileName, blob: Uint8Array, env?: Globals.ENV): Promise<void>;
4254
4263
  }
4255
4264
 
4256
4265
  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
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",