@appsemble/node-utils 0.36.8 → 0.36.10-test.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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.8/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.10-test.0/config/assets/logo.svg) Appsemble Node Utilities
2
2
 
3
3
  > NodeJS utilities used by Appsemble internally.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/node-utils)](https://www.npmjs.com/package/@appsemble/node-utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.8/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.8)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.10-test.0/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.10-test.0)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.8/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.10-test.0/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.36.8",
3
+ "version": "0.36.10-test.0",
4
4
  "description": "NodeJS utilities used by Appsemble internally.",
5
5
  "keywords": [
6
6
  "app",
@@ -40,9 +40,9 @@
40
40
  "test": "vitest"
41
41
  },
42
42
  "dependencies": {
43
- "@appsemble/lang-sdk": "0.36.8",
44
- "@appsemble/types": "0.36.8",
45
- "@appsemble/utils": "0.36.8",
43
+ "@appsemble/lang-sdk": "0.36.10-test.0",
44
+ "@appsemble/types": "0.36.10-test.0",
45
+ "@appsemble/utils": "0.36.10-test.0",
46
46
  "@formatjs/fast-memoize": "^2.0.0",
47
47
  "@fortawesome/fontawesome-free": "^6.0.0",
48
48
  "@inquirer/prompts": "^8.0.0",
@@ -82,7 +82,7 @@
82
82
  "lodash": "^4.0.0",
83
83
  "lodash-es": "^4.0.0",
84
84
  "logform": "^2.0.0",
85
- "memfs": "4.17.0",
85
+ "memfs": "4.57.2",
86
86
  "mime-types": "^2.0.0",
87
87
  "minio": "^8.0.3",
88
88
  "mustache": "^4.0.0",
package/parsers.js CHANGED
@@ -3,6 +3,7 @@ import { createWriteStream } from 'node:fs';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { parse } from 'node:querystring';
6
+ import { finished } from 'node:stream/promises';
6
7
  import busboy from 'busboy';
7
8
  import { parse as parseCSV } from 'csv-parse';
8
9
  import { bufferParser } from 'koas-body-parser';
@@ -67,6 +68,7 @@ export const streamParser = async (body, mediaTypeObject, { resolveRef }, ctx) =
67
68
  const { properties = {} } = resolveRef(schema) || {};
68
69
  const response = {};
69
70
  const tempFiles = {};
71
+ const fileWrites = [];
70
72
  await new Promise((resolve, reject) => {
71
73
  function onError(error) {
72
74
  bb.removeAllListeners();
@@ -78,6 +80,7 @@ export const streamParser = async (body, mediaTypeObject, { resolveRef }, ctx) =
78
80
  const path = join(tmpdir(), `${Date.now()}-${randomUUID()}`);
79
81
  try {
80
82
  const fileWriteStream = createWriteStream(path);
83
+ fileWrites.push(finished(fileWriteStream));
81
84
  stream.pipe(fileWriteStream);
82
85
  stream.on('error', onError);
83
86
  fileWriteStream.on('error', onError);
@@ -112,9 +115,15 @@ export const streamParser = async (body, mediaTypeObject, { resolveRef }, ctx) =
112
115
  response[fieldName] = fromString(propertySchema, content);
113
116
  }
114
117
  })
115
- .on('close', () => {
118
+ .on('close', async () => {
116
119
  bb.removeAllListeners();
117
- resolve(response);
120
+ try {
121
+ await Promise.all(fileWrites);
122
+ resolve();
123
+ }
124
+ catch (error) {
125
+ reject(error);
126
+ }
118
127
  })
119
128
  .on('error', onError)
120
129
  .on('partsLimit', onError)
package/s3.js CHANGED
@@ -1,4 +1,4 @@
1
- import { streamToBuffer } from 'memfs/lib/node/util.js';
1
+ import { buffer as streamToBuffer } from 'node:stream/consumers';
2
2
  import { Client, S3Error } from 'minio';
3
3
  import { logger } from './logger.js';
4
4
  let s3Client;
package/uploads.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createReadStream } from 'node:fs';
2
2
  import { unlink } from 'node:fs/promises';
3
- import { streamToBuffer } from 'memfs/lib/node/util.js';
3
+ import { buffer as streamToBuffer } from 'node:stream/consumers';
4
4
  import { logger } from './logger.js';
5
5
  // XXX: a bit severe
6
6
  // @ts-expect-error 2366 - Function lacks ending return statement and return type does not include 'undefined'