@ditojs/server 1.9.1 → 1.10.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "1.9.1",
3
+ "version": "1.10.1",
4
4
  "type": "module",
5
5
  "description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/server",
@@ -21,22 +21,22 @@
21
21
  "node >= 16"
22
22
  ],
23
23
  "dependencies": {
24
- "@ditojs/admin": "^1.9.1",
25
- "@ditojs/build": "^1.8.0",
26
- "@ditojs/router": "^1.9.0",
27
- "@ditojs/utils": "^1.9.0",
28
- "@koa/cors": "^3.3.0",
24
+ "@aws-sdk/client-s3": "^3.135.0",
25
+ "@ditojs/admin": "^1.10.1",
26
+ "@ditojs/build": "^1.10.1",
27
+ "@ditojs/router": "^1.10.1",
28
+ "@ditojs/utils": "^1.10.1",
29
+ "@koa/cors": "^3.4.3",
29
30
  "@koa/multer": "^3.0.0",
30
31
  "@originjs/vite-plugin-commonjs": "^1.0.3",
31
32
  "ajv": "^8.11.0",
32
33
  "ajv-formats": "^2.1.1",
33
- "aws-sdk": "^2.1180.0",
34
34
  "axios": "^0.27.2",
35
35
  "bcryptjs": "^2.4.3",
36
36
  "bytes": "^3.1.2",
37
37
  "data-uri-to-buffer": "^4.0.0",
38
- "eventemitter2": "^6.4.6",
39
- "file-type": "^17.1.3",
38
+ "eventemitter2": "^6.4.9",
39
+ "file-type": "^17.1.6",
40
40
  "fs-extra": "^10.1.0",
41
41
  "image-size": "^1.0.2",
42
42
  "is-svg": "^4.3.2",
@@ -54,30 +54,30 @@
54
54
  "koa-static": "^5.0.0",
55
55
  "mime-types": "^2.1.35",
56
56
  "multer": "^1.4.5-lts.1",
57
- "multer-s3": "^2.10.0",
57
+ "multer-s3": "^3.0.1",
58
58
  "nanoid": "^4.0.0",
59
59
  "parse-duration": "^1.0.2",
60
60
  "passport-local": "^1.0.0",
61
61
  "passthrough-counter": "^1.0.0",
62
62
  "picocolors": "^1.0.0",
63
63
  "picomatch": "^2.3.1",
64
- "pino": "^8.3.0",
64
+ "pino": "^8.7.0",
65
65
  "pino-pretty": "^8.1.0",
66
66
  "pluralize": "^8.0.0",
67
67
  "repl": "^0.1.3",
68
- "uuid": "^8.3.2",
69
- "vite": "^3.0.2",
68
+ "uuid": "^9.0.0",
69
+ "vite": "^3.2.2",
70
70
  "vite-plugin-vue2": "^2.0.2",
71
- "vue": "^2.7.8",
72
- "vue-template-compiler": "^2.7.8"
71
+ "vue": "^2.7.13",
72
+ "vue-template-compiler": "^2.7.13"
73
73
  },
74
74
  "peerDependencies": {
75
- "knex": "^1.0.5",
75
+ "knex": ">=2.0.5",
76
76
  "objection": "^3.0.1"
77
77
  },
78
78
  "devDependencies": {
79
- "knex": "^2.2.0",
79
+ "knex": "^2.3.0",
80
80
  "objection": "^3.0.1"
81
81
  },
82
- "gitHead": "36ad7c74fedaf7ea7c94eb5bb7ecb4b2dca3a0ba"
82
+ "gitHead": "2a5658aeeef2666b0a5ddd37ce6fbdb1d9eab3c3"
83
83
  }
@@ -64,11 +64,10 @@ export const AssetMixin = mixin(Model => class extends TimeStampedMixin(Model) {
64
64
 
65
65
  // @override
66
66
  $parseJson(json) {
67
- const { constructor } = this
68
67
  const { file, storage } = json
69
68
  // Convert `AssetMixin#file` to an `AssetFile` instance:
70
69
  if (file && storage) {
71
- constructor.app.getStorage(storage)?.convertAssetFile(file)
70
+ this.constructor.app.getStorage(storage)?.convertAssetFile(file)
72
71
  }
73
72
  return json
74
73
  }
@@ -579,20 +579,8 @@ export class Model extends objection.Model {
579
579
 
580
580
  // @override
581
581
  $formatJson(json) {
582
- const { constructor } = this
583
- // Calculate and set the computed properties.
584
- for (const key of constructor.computedAttributes) {
585
- // Perhaps the computed property is produced in the SQL statement,
586
- // in which case we don't have to do anything anymore here.
587
- if (!(key in json)) {
588
- const value = this[key]
589
- if (value !== undefined) {
590
- json[key] = value
591
- }
592
- }
593
- }
594
582
  // Remove hidden attributes.
595
- for (const key of constructor.hiddenAttributes) {
583
+ for (const key of this.constructor.hiddenAttributes) {
596
584
  delete json[key]
597
585
  }
598
586
  return json
@@ -1,9 +1,10 @@
1
- import aws from 'aws-sdk'
1
+ import { S3 } from '@aws-sdk/client-s3'
2
2
  import multerS3 from 'multer-s3'
3
3
  import { fileTypeFromBuffer } from 'file-type'
4
4
  import isSvg from 'is-svg'
5
5
  import { Storage } from './Storage.js'
6
6
  import { PassThrough } from 'stream'
7
+ import consumers from 'stream/consumers'
7
8
 
8
9
  export class S3Storage extends Storage {
9
10
  static type = 's3'
@@ -17,7 +18,7 @@ export class S3Storage extends Storage {
17
18
  bucket,
18
19
  ...options
19
20
  } = config
20
- this.s3 = new aws.S3(s3)
21
+ this.s3 = new S3(s3)
21
22
  this.acl = acl
22
23
  this.bucket = bucket
23
24
 
@@ -101,13 +102,13 @@ export class S3Storage extends Storage {
101
102
 
102
103
  // @override
103
104
  async _addFile(file, buffer) {
104
- const data = await this.s3.upload({
105
+ const data = await this.s3.putObject({
105
106
  Bucket: this.bucket,
106
107
  ACL: this.acl,
107
108
  Key: file.key,
108
109
  ContentType: file.type,
109
110
  Body: buffer
110
- }).promise()
111
+ })
111
112
  // "Convert" `file` to something looking more like a S3 `storageFile`.
112
113
  // For now, only the `location` property is of interest:
113
114
  return {
@@ -121,7 +122,7 @@ export class S3Storage extends Storage {
121
122
  await this.s3.deleteObject({
122
123
  Bucket: this.bucket,
123
124
  Key: file.key
124
- }).promise()
125
+ })
125
126
  // TODO: Check for errors and throw?
126
127
  }
127
128
 
@@ -129,12 +130,12 @@ export class S3Storage extends Storage {
129
130
  async _readFile(file) {
130
131
  const {
131
132
  ContentType: type,
132
- Body: data
133
+ Body: stream
133
134
  } = await this.s3.getObject({
134
135
  Bucket: this.bucket,
135
136
  Key: file.key
136
- }).promise()
137
- const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data)
137
+ })
138
+ const buffer = await consumers.buffer(stream)
138
139
  // See `AssetFile.data` setter:
139
140
  buffer.type = type
140
141
  return buffer
@@ -146,8 +147,8 @@ export class S3Storage extends Storage {
146
147
  const params = { Bucket: this.bucket }
147
148
  let result
148
149
  do {
149
- result = await this.s3.listObjectsV2(params).promise()
150
- for (const { Key: key } of result.Contents) {
150
+ result = await this.s3.listObjectsV2(params)
151
+ for (const { Key: key } of result.Contents ?? []) {
151
152
  files.push(key)
152
153
  }
153
154
  // Continue it if results are truncated.