proto.io 0.0.215 → 0.0.217
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/dist/adapters/file/aliyun-oss.d.ts +3 -3
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +1 -1
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- package/dist/adapters/storage/progres.d.ts +8 -10
- package/dist/adapters/storage/progres.js +833 -451
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +834 -452
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -7
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +3 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-Cp5le5dC.d.ts → base-CWnOBKD5.d.ts} +2 -2
- package/dist/internals/base-CWnOBKD5.d.ts.map +1 -0
- package/dist/internals/{chunk--Vo2-p-z.d.ts → chunk-CNNSQpRF.d.ts} +3 -3
- package/dist/internals/chunk-CNNSQpRF.d.ts.map +1 -0
- package/dist/internals/{index-CZUGnb-y.d.ts → index-BRIlS3mY.d.ts} +3 -9
- package/dist/internals/index-BRIlS3mY.d.ts.map +1 -0
- package/dist/internals/{index-YLrO0f2D.d.ts → index-Bs8n7Q8f.d.ts} +60 -20
- package/dist/internals/index-Bs8n7Q8f.d.ts.map +1 -0
- package/dist/internals/{index-al1N-qi7.mjs → index-BzDsTt4R.mjs} +2 -2
- package/dist/internals/{index-al1N-qi7.mjs.map → index-BzDsTt4R.mjs.map} +1 -1
- package/dist/internals/{index-ZPbBr9Db.mjs → index-DfqABzjr.mjs} +135 -142
- package/dist/internals/index-DfqABzjr.mjs.map +1 -0
- package/dist/internals/{index-DfnPpl1I.js → index-DylUjD_1.js} +133 -146
- package/dist/internals/index-DylUjD_1.js.map +1 -0
- package/dist/internals/{validator-ChrCrz_C.mjs → validator-CEcBF4Cn.mjs} +730 -27
- package/dist/internals/validator-CEcBF4Cn.mjs.map +1 -0
- package/dist/internals/{validator-m6wY35c6.js → validator-mcBCJP4P.js} +737 -27
- package/dist/internals/validator-mcBCJP4P.js.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-Cp5le5dC.d.ts.map +0 -1
- package/dist/internals/chunk--Vo2-p-z.d.ts.map +0 -1
- package/dist/internals/index-CZUGnb-y.d.ts.map +0 -1
- package/dist/internals/index-DfnPpl1I.js.map +0 -1
- package/dist/internals/index-YLrO0f2D.d.ts.map +0 -1
- package/dist/internals/index-ZPbBr9Db.mjs.map +0 -1
- package/dist/internals/validator-ChrCrz_C.mjs.map +0 -1
- package/dist/internals/validator-m6wY35c6.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Server } from '@o2ter/server-js';
|
|
3
|
-
import { Q as QueryValidator, r as resolveColumn,
|
|
3
|
+
import { Q as QueryValidator, a as QueryExpression, r as resolveColumn, b as resolveDataType, c as QuerySelector } from './internals/validator-CEcBF4Cn.mjs';
|
|
4
4
|
import { P as PVK } from './internals/private-CNw40LZ7.mjs';
|
|
5
5
|
import { prototypes, asyncStream, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
|
|
6
|
-
import { L as LiveQuerySubscription, T as TQuery, d as deserialize, s as serialize, a as TUser, P as ProtoType, _ as _logLevels } from './internals/index-
|
|
7
|
-
export { b as ProtoClient, c as classExtends
|
|
8
|
-
import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-
|
|
6
|
+
import { L as LiveQuerySubscription, T as TQuery, d as deserialize, s as serialize, a as TUser, P as ProtoType, _ as _logLevels } from './internals/index-DfqABzjr.mjs';
|
|
7
|
+
export { b as ProtoClient, c as classExtends } from './internals/index-DfqABzjr.mjs';
|
|
8
|
+
import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-BzDsTt4R.mjs';
|
|
9
9
|
import jwt from 'jsonwebtoken';
|
|
10
10
|
import { Blob } from 'node:buffer';
|
|
11
11
|
import { Readable } from 'node:stream';
|
|
@@ -14,9 +14,9 @@ import { scrypt } from 'node:crypto';
|
|
|
14
14
|
import { promisify } from 'util';
|
|
15
15
|
import { randomBytes, randomUUID } from '@o2ter/crypto-js';
|
|
16
16
|
import { P as PROTO_NOTY_MSG, a as PROTO_LIVEQUERY_MSG, M as MASTER_USER_HEADER_NAME, b as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/const-Dkp7Nsv5.mjs';
|
|
17
|
-
export { Decimal } from 'decimal.js';
|
|
18
17
|
import queryType from 'query-types';
|
|
19
18
|
import busboy from 'busboy';
|
|
19
|
+
export { Decimal } from 'decimal.js';
|
|
20
20
|
import 'axios';
|
|
21
21
|
import '@o2ter/server-js/dist/const';
|
|
22
22
|
import 'socket.io-client';
|
|
@@ -129,9 +129,12 @@ const dispatcher = (proto, options) => {
|
|
|
129
129
|
const isGet = _validator.isGetMethod(decoded.filter);
|
|
130
130
|
if (!_validator.validateCLPs(query.className, isGet ? 'get' : 'find'))
|
|
131
131
|
throw Error('No permission');
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
const weight = opts?.weight ? QueryExpression.decode(opts.weight, false) : undefined;
|
|
133
|
+
for (const key of weight?.keyPaths() ?? []) {
|
|
134
|
+
if (!_validator.validateKey(query.className, key, 'read', QueryValidator.patterns.path))
|
|
135
|
+
throw Error('No permission');
|
|
136
|
+
}
|
|
137
|
+
return proto.storage.random(decoded, { weight });
|
|
135
138
|
},
|
|
136
139
|
async insert(options, values) {
|
|
137
140
|
if (!createFile && options.className === 'File')
|
|
@@ -1998,16 +2001,12 @@ var classesRoute = (router, proto) => {
|
|
|
1998
2001
|
return void res.sendStatus(404);
|
|
1999
2002
|
const payload = proto.connect(req);
|
|
2000
2003
|
const { weight } = req.query;
|
|
2001
|
-
if (_.isEmpty(weight) || !_.isString(weight))
|
|
2002
|
-
throw Error('Invalid operation');
|
|
2003
2004
|
await response(res, async () => createQuery(payload, req, true).random({ weight }, { master: payload.isMaster }));
|
|
2004
2005
|
});
|
|
2005
2006
|
router.get('/relation/random', queryType.middleware(), async (req, res) => {
|
|
2006
2007
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2007
2008
|
const payload = proto.connect(req);
|
|
2008
2009
|
const { weight } = req.query;
|
|
2009
|
-
if (_.isEmpty(weight) || !_.isString(weight))
|
|
2010
|
-
throw Error('Invalid operation');
|
|
2011
2010
|
await response(res, async () => createQuery(payload, req, true).random({ weight }, { master: payload.isMaster }));
|
|
2012
2011
|
});
|
|
2013
2012
|
router.get('/classes/:name/nonrefs', queryType.middleware(), async (req, res) => {
|