@ptkl/toolkit 0.7.0 → 0.7.2

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.
@@ -76,12 +76,12 @@ class AppsCommand {
76
76
  async upload(options) {
77
77
  const { apptype, directory, build } = options;
78
78
  const profile = util.getCurrentProfile();
79
- const client = new Api({ token: profile.token, host: profile.host }).app(apptype);
79
+ const api = new Api({ token: profile.token, host: profile.host }).app(apptype);
80
80
  try {
81
- const chunks = [];
81
+ let buffer = Buffer.alloc(0);
82
82
  const bufferStream = new Writable({
83
83
  write(chunk, encoding, callback) {
84
- chunks.push(Buffer.from(chunk));
84
+ buffer = Buffer.concat([buffer, chunk]);
85
85
  callback();
86
86
  },
87
87
  });
@@ -93,35 +93,19 @@ class AppsCommand {
93
93
  .on('error', reject);
94
94
  });
95
95
  console.log('Archive created successfully');
96
- // Convert chunks to a single ArrayBuffer to avoid Node Buffer issues
97
- const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
98
- const arrayBuffer = new ArrayBuffer(totalLength);
99
- const uint8View = new Uint8Array(arrayBuffer);
100
- let offset = 0;
101
- for (const chunk of chunks) {
102
- uint8View.set(new Uint8Array(chunk), offset);
103
- offset += chunk.length;
104
- }
105
- console.log('ArrayBuffer size:', arrayBuffer.byteLength);
106
- // Create FormData with ArrayBuffer
96
+ // Create FormData with buffer
107
97
  const formData = new FormData();
108
- const blob = new Blob([arrayBuffer], { type: 'application/gzip' });
109
- console.log('Blob size:', blob.size);
98
+ const blob = new Blob([buffer], { type: 'application/gzip' });
110
99
  formData.append('app', blob, 'app.tar.gz');
111
100
  if (build) {
112
101
  formData.append('build', 'true');
113
102
  }
114
- console.log('About to call client.upload...');
115
- try {
116
- const result = await client.upload(formData);
117
- console.log('Upload successful');
118
- return result;
119
- }
120
- catch (error) {
121
- console.log('Upload failed with error:', error.message);
122
- console.log('Error details:', error);
123
- throw error;
124
- }
103
+ return await api.client.post(`/v3/system/gateway/app-service/${apptype}/upload`, formData, {
104
+ timeout: 60000,
105
+ headers: {
106
+ 'Content-Type': 'multipart/form-data'
107
+ }
108
+ });
125
109
  }
126
110
  catch (error) {
127
111
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/toolkit",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A command-line toolkit for managing Protokol platform applications, profiles, functions, and components",
5
5
  "keywords": [
6
6
  "protokol",