@ones-open/node-sdk 0.0.3 → 0.0.4-10001.152
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/index.cjs +65 -49
- package/dist/index.js +65 -49
- package/dist/types/packages/node/storage/entity/entity/types.d.ts +20 -20
- package/dist/types/packages/node/storage/entity/error/consts.d.ts +29 -29
- package/dist/types/packages/node/storage/entity/fetch/index.d.ts.map +1 -1
- package/dist/types/packages/node/storage/entity/index.d.ts +1 -1
- package/dist/types/packages/node/storage/entity/query/types.d.ts +52 -52
- package/dist/types/packages/node/storage/entity/result/types.d.ts +12 -12
- package/dist/types/packages/node/storage/entity/sort/consts.d.ts +3 -3
- package/dist/types/packages/node/storage/entity/types.d.ts +29 -29
- package/dist/types/packages/node/storage/entity/where/index.d.ts +1 -1
- package/dist/types/packages/node/storage/object/error/consts.d.ts +4 -4
- package/dist/types/packages/node/storage/object/error/index.d.ts +4 -4
- package/dist/types/packages/node/storage/object/fetch/index.d.ts.map +1 -1
- package/dist/types/packages/node/storage/object/index.d.ts +1 -1
- package/dist/types/packages/node/storage/object/result/types.d.ts +3 -3
- package/dist/types/packages/node/storage/object/types.d.ts +17 -17
- package/dist/types/packages/strict/env/index.d.ts +12 -28
- package/dist/types/packages/strict/env/index.d.ts.map +1 -1
- package/dist/types/packages/strict/result/types.d.ts +6 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty");
|
|
4
3
|
const lodashEs = require("lodash-es");
|
|
5
4
|
const Fetch = require("axios");
|
|
6
5
|
const _sortInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/sort");
|
|
7
|
-
const
|
|
8
|
-
return
|
|
6
|
+
const getONESHostedBaseUrl = () => {
|
|
7
|
+
return process.env.ONES_HOSTED_BASE_URL;
|
|
9
8
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
return "instanceId";
|
|
9
|
+
const getONESHostedAppID = () => {
|
|
10
|
+
return process.env.ONES_HOSTED_APP_ID;
|
|
13
11
|
};
|
|
14
|
-
const
|
|
15
|
-
return
|
|
12
|
+
const getONESHostedToken = () => {
|
|
13
|
+
return process.env.ONES_HOSTED_TOKEN;
|
|
16
14
|
};
|
|
17
|
-
const getAppId = getApplicationId;
|
|
18
15
|
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
19
16
|
__proto__: null,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
getPlatformAPIHost,
|
|
24
|
-
getPlatformApiHost
|
|
17
|
+
getONESHostedAppID,
|
|
18
|
+
getONESHostedBaseUrl,
|
|
19
|
+
getONESHostedToken
|
|
25
20
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
26
21
|
var EntityWhereConditionEnum = /* @__PURE__ */ ((EntityWhereConditionEnum2) => {
|
|
27
22
|
EntityWhereConditionEnum2["beginsWith"] = "beginsWith";
|
|
@@ -123,24 +118,37 @@ const createErrorResult = (code, message, error) => {
|
|
|
123
118
|
}, error);
|
|
124
119
|
};
|
|
125
120
|
const fetch$1 = Fetch.create();
|
|
121
|
+
const buildAuthHeaders$1 = () => {
|
|
122
|
+
const token = getONESHostedToken();
|
|
123
|
+
if (token) {
|
|
124
|
+
return {
|
|
125
|
+
Authorization: `Bearer ${token}`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {};
|
|
129
|
+
};
|
|
126
130
|
const fetchBase$1 = (path, params, config) => {
|
|
127
|
-
return Promise.all([
|
|
128
|
-
let [base,
|
|
129
|
-
if (base &&
|
|
130
|
-
|
|
131
|
+
return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
|
|
132
|
+
let [base, appId] = _ref;
|
|
133
|
+
if (base && appId) {
|
|
134
|
+
var _config$headers;
|
|
135
|
+
const url = `${base}/hosted_ability/storage/${appId}${path}`;
|
|
131
136
|
const data = {
|
|
132
|
-
...params
|
|
133
|
-
instance_id
|
|
137
|
+
...params
|
|
134
138
|
};
|
|
135
139
|
return fetch$1({
|
|
136
140
|
...config,
|
|
141
|
+
headers: {
|
|
142
|
+
...(_config$headers = config === null || config === void 0 ? void 0 : config.headers) !== null && _config$headers !== void 0 ? _config$headers : {},
|
|
143
|
+
...buildAuthHeaders$1()
|
|
144
|
+
},
|
|
137
145
|
url,
|
|
138
146
|
data
|
|
139
147
|
});
|
|
140
148
|
}
|
|
141
149
|
throw new Error(JSON.stringify({
|
|
142
150
|
base,
|
|
143
|
-
|
|
151
|
+
appId
|
|
144
152
|
}));
|
|
145
153
|
}).then((response) => {
|
|
146
154
|
return response.data;
|
|
@@ -157,22 +165,22 @@ const fetchBase$1 = (path, params, config) => {
|
|
|
157
165
|
});
|
|
158
166
|
};
|
|
159
167
|
const fetchPost = (params) => {
|
|
160
|
-
return fetchBase$1(
|
|
168
|
+
return fetchBase$1(`/entity_data`, params, {
|
|
161
169
|
method: "post"
|
|
162
170
|
});
|
|
163
171
|
};
|
|
164
172
|
const fetchDelete$1 = (params) => {
|
|
165
|
-
return fetchBase$1(
|
|
173
|
+
return fetchBase$1(`/entity_data`, params, {
|
|
166
174
|
method: "delete"
|
|
167
175
|
});
|
|
168
176
|
};
|
|
169
177
|
const fetchQuery = (params) => {
|
|
170
|
-
return fetchBase$1(
|
|
178
|
+
return fetchBase$1(`/entity_data/get_many`, params, {
|
|
171
179
|
method: "post"
|
|
172
180
|
});
|
|
173
181
|
};
|
|
174
182
|
const fetchCount = (params) => {
|
|
175
|
-
return fetchBase$1(
|
|
183
|
+
return fetchBase$1(`/entity_data/count`, params, {
|
|
176
184
|
method: "post"
|
|
177
185
|
});
|
|
178
186
|
};
|
|
@@ -190,12 +198,12 @@ const defaultEntityQueryIndex = defaultEntityQuery.index;
|
|
|
190
198
|
const defaultEntityQueryWhere = defaultEntityQuery.where;
|
|
191
199
|
class EntityQueryClass {
|
|
192
200
|
constructor(name) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
this._name = "";
|
|
202
|
+
this._cursor = [defaultEntityQueryCursor];
|
|
203
|
+
this._limit = [defaultEntityQueryLimit];
|
|
204
|
+
this._sort = [defaultEntityQuerySort];
|
|
205
|
+
this._index = [defaultEntityQueryIndex];
|
|
206
|
+
this._where = [defaultEntityQueryWhere];
|
|
199
207
|
this._name = name;
|
|
200
208
|
}
|
|
201
209
|
cursor(cursor) {
|
|
@@ -289,7 +297,7 @@ class EntityQueryClass {
|
|
|
289
297
|
}
|
|
290
298
|
class EntityClass {
|
|
291
299
|
constructor(name) {
|
|
292
|
-
|
|
300
|
+
this._name = "";
|
|
293
301
|
this._name = name;
|
|
294
302
|
}
|
|
295
303
|
async get(key) {
|
|
@@ -395,31 +403,38 @@ var ObjectErrorCode = /* @__PURE__ */ ((ObjectErrorCode2) => {
|
|
|
395
403
|
return ObjectErrorCode2;
|
|
396
404
|
})(ObjectErrorCode || {});
|
|
397
405
|
class ObjectError {
|
|
398
|
-
/**
|
|
399
|
-
* @description 错误载荷
|
|
400
|
-
*/
|
|
401
406
|
constructor(result) {
|
|
402
|
-
|
|
407
|
+
this.err_msg = "";
|
|
403
408
|
this.code = result.code;
|
|
404
409
|
this.err_msg = result.err_msg;
|
|
405
410
|
this.err_values = result.err_values;
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
413
|
const fetch = Fetch.create();
|
|
414
|
+
const buildAuthHeaders = () => {
|
|
415
|
+
const token = getONESHostedToken();
|
|
416
|
+
if (token) {
|
|
417
|
+
return {
|
|
418
|
+
Authorization: `Bearer ${token}`
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {};
|
|
422
|
+
};
|
|
409
423
|
const fetchBase = (path, params) => {
|
|
410
|
-
return Promise.all([
|
|
411
|
-
let [base,
|
|
412
|
-
if (base &&
|
|
413
|
-
const url = `${base}${path}`;
|
|
424
|
+
return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
|
|
425
|
+
let [base, appId] = _ref;
|
|
426
|
+
if (base && appId) {
|
|
427
|
+
const url = `${base}/hosted_ability/storage/${appId}${path}`;
|
|
414
428
|
const data = {
|
|
415
|
-
...params
|
|
416
|
-
instance_id
|
|
429
|
+
...params
|
|
417
430
|
};
|
|
418
|
-
return fetch.post(url, data
|
|
431
|
+
return fetch.post(url, data, {
|
|
432
|
+
headers: buildAuthHeaders()
|
|
433
|
+
});
|
|
419
434
|
}
|
|
420
435
|
throw new Error(JSON.stringify({
|
|
421
436
|
base,
|
|
422
|
-
|
|
437
|
+
appId
|
|
423
438
|
}));
|
|
424
439
|
}).then((response) => {
|
|
425
440
|
return response.data;
|
|
@@ -436,16 +451,16 @@ const fetchBase = (path, params) => {
|
|
|
436
451
|
});
|
|
437
452
|
};
|
|
438
453
|
const fetchUpload = (params) => {
|
|
439
|
-
return fetchBase(
|
|
454
|
+
return fetchBase(`/object/get_upload_policy_info`, params);
|
|
440
455
|
};
|
|
441
456
|
const fetchDownload = (params) => {
|
|
442
|
-
return fetchBase(
|
|
457
|
+
return fetchBase(`/object/get_download_pre_signed_url`, params);
|
|
443
458
|
};
|
|
444
459
|
const fetchDelete = (params) => {
|
|
445
|
-
return fetchBase(
|
|
460
|
+
return fetchBase(`/object/delete`, params);
|
|
446
461
|
};
|
|
447
462
|
const fetchMetadata = (params) => {
|
|
448
|
-
return fetchBase(
|
|
463
|
+
return fetchBase(`/object/get_metadata`, params);
|
|
449
464
|
};
|
|
450
465
|
const object = {
|
|
451
466
|
ObjectError,
|
|
@@ -455,7 +470,8 @@ const object = {
|
|
|
455
470
|
object_key: key
|
|
456
471
|
});
|
|
457
472
|
if (result.code === "OK") {
|
|
458
|
-
|
|
473
|
+
var _result$data;
|
|
474
|
+
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.url) {
|
|
459
475
|
const {
|
|
460
476
|
url,
|
|
461
477
|
fields
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
1
|
import { isNull, isUndefined, isSymbol, set } from "lodash-es";
|
|
3
2
|
import Fetch, { AxiosError } from "axios";
|
|
4
3
|
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
|
5
|
-
const
|
|
6
|
-
return
|
|
4
|
+
const getONESHostedBaseUrl = () => {
|
|
5
|
+
return process.env.ONES_HOSTED_BASE_URL;
|
|
7
6
|
};
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
return "instanceId";
|
|
7
|
+
const getONESHostedAppID = () => {
|
|
8
|
+
return process.env.ONES_HOSTED_APP_ID;
|
|
11
9
|
};
|
|
12
|
-
const
|
|
13
|
-
return
|
|
10
|
+
const getONESHostedToken = () => {
|
|
11
|
+
return process.env.ONES_HOSTED_TOKEN;
|
|
14
12
|
};
|
|
15
|
-
const getAppId = getApplicationId;
|
|
16
13
|
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17
14
|
__proto__: null,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
getPlatformAPIHost,
|
|
22
|
-
getPlatformApiHost
|
|
15
|
+
getONESHostedAppID,
|
|
16
|
+
getONESHostedBaseUrl,
|
|
17
|
+
getONESHostedToken
|
|
23
18
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
24
19
|
var EntityWhereConditionEnum = /* @__PURE__ */ ((EntityWhereConditionEnum2) => {
|
|
25
20
|
EntityWhereConditionEnum2["beginsWith"] = "beginsWith";
|
|
@@ -121,24 +116,37 @@ const createErrorResult = (code, message, error) => {
|
|
|
121
116
|
}, error);
|
|
122
117
|
};
|
|
123
118
|
const fetch$1 = Fetch.create();
|
|
119
|
+
const buildAuthHeaders$1 = () => {
|
|
120
|
+
const token = getONESHostedToken();
|
|
121
|
+
if (token) {
|
|
122
|
+
return {
|
|
123
|
+
Authorization: `Bearer ${token}`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {};
|
|
127
|
+
};
|
|
124
128
|
const fetchBase$1 = (path, params, config) => {
|
|
125
|
-
return Promise.all([
|
|
126
|
-
let [base,
|
|
127
|
-
if (base &&
|
|
128
|
-
|
|
129
|
+
return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
|
|
130
|
+
let [base, appId] = _ref;
|
|
131
|
+
if (base && appId) {
|
|
132
|
+
var _config$headers;
|
|
133
|
+
const url = `${base}/hosted_ability/storage/${appId}${path}`;
|
|
129
134
|
const data = {
|
|
130
|
-
...params
|
|
131
|
-
instance_id
|
|
135
|
+
...params
|
|
132
136
|
};
|
|
133
137
|
return fetch$1({
|
|
134
138
|
...config,
|
|
139
|
+
headers: {
|
|
140
|
+
...(_config$headers = config === null || config === void 0 ? void 0 : config.headers) !== null && _config$headers !== void 0 ? _config$headers : {},
|
|
141
|
+
...buildAuthHeaders$1()
|
|
142
|
+
},
|
|
135
143
|
url,
|
|
136
144
|
data
|
|
137
145
|
});
|
|
138
146
|
}
|
|
139
147
|
throw new Error(JSON.stringify({
|
|
140
148
|
base,
|
|
141
|
-
|
|
149
|
+
appId
|
|
142
150
|
}));
|
|
143
151
|
}).then((response) => {
|
|
144
152
|
return response.data;
|
|
@@ -155,22 +163,22 @@ const fetchBase$1 = (path, params, config) => {
|
|
|
155
163
|
});
|
|
156
164
|
};
|
|
157
165
|
const fetchPost = (params) => {
|
|
158
|
-
return fetchBase$1(
|
|
166
|
+
return fetchBase$1(`/entity_data`, params, {
|
|
159
167
|
method: "post"
|
|
160
168
|
});
|
|
161
169
|
};
|
|
162
170
|
const fetchDelete$1 = (params) => {
|
|
163
|
-
return fetchBase$1(
|
|
171
|
+
return fetchBase$1(`/entity_data`, params, {
|
|
164
172
|
method: "delete"
|
|
165
173
|
});
|
|
166
174
|
};
|
|
167
175
|
const fetchQuery = (params) => {
|
|
168
|
-
return fetchBase$1(
|
|
176
|
+
return fetchBase$1(`/entity_data/get_many`, params, {
|
|
169
177
|
method: "post"
|
|
170
178
|
});
|
|
171
179
|
};
|
|
172
180
|
const fetchCount = (params) => {
|
|
173
|
-
return fetchBase$1(
|
|
181
|
+
return fetchBase$1(`/entity_data/count`, params, {
|
|
174
182
|
method: "post"
|
|
175
183
|
});
|
|
176
184
|
};
|
|
@@ -188,12 +196,12 @@ const defaultEntityQueryIndex = defaultEntityQuery.index;
|
|
|
188
196
|
const defaultEntityQueryWhere = defaultEntityQuery.where;
|
|
189
197
|
class EntityQueryClass {
|
|
190
198
|
constructor(name) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
this._name = "";
|
|
200
|
+
this._cursor = [defaultEntityQueryCursor];
|
|
201
|
+
this._limit = [defaultEntityQueryLimit];
|
|
202
|
+
this._sort = [defaultEntityQuerySort];
|
|
203
|
+
this._index = [defaultEntityQueryIndex];
|
|
204
|
+
this._where = [defaultEntityQueryWhere];
|
|
197
205
|
this._name = name;
|
|
198
206
|
}
|
|
199
207
|
cursor(cursor) {
|
|
@@ -287,7 +295,7 @@ class EntityQueryClass {
|
|
|
287
295
|
}
|
|
288
296
|
class EntityClass {
|
|
289
297
|
constructor(name) {
|
|
290
|
-
|
|
298
|
+
this._name = "";
|
|
291
299
|
this._name = name;
|
|
292
300
|
}
|
|
293
301
|
async get(key) {
|
|
@@ -393,31 +401,38 @@ var ObjectErrorCode = /* @__PURE__ */ ((ObjectErrorCode2) => {
|
|
|
393
401
|
return ObjectErrorCode2;
|
|
394
402
|
})(ObjectErrorCode || {});
|
|
395
403
|
class ObjectError {
|
|
396
|
-
/**
|
|
397
|
-
* @description 错误载荷
|
|
398
|
-
*/
|
|
399
404
|
constructor(result) {
|
|
400
|
-
|
|
405
|
+
this.err_msg = "";
|
|
401
406
|
this.code = result.code;
|
|
402
407
|
this.err_msg = result.err_msg;
|
|
403
408
|
this.err_values = result.err_values;
|
|
404
409
|
}
|
|
405
410
|
}
|
|
406
411
|
const fetch = Fetch.create();
|
|
412
|
+
const buildAuthHeaders = () => {
|
|
413
|
+
const token = getONESHostedToken();
|
|
414
|
+
if (token) {
|
|
415
|
+
return {
|
|
416
|
+
Authorization: `Bearer ${token}`
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {};
|
|
420
|
+
};
|
|
407
421
|
const fetchBase = (path, params) => {
|
|
408
|
-
return Promise.all([
|
|
409
|
-
let [base,
|
|
410
|
-
if (base &&
|
|
411
|
-
const url = `${base}${path}`;
|
|
422
|
+
return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
|
|
423
|
+
let [base, appId] = _ref;
|
|
424
|
+
if (base && appId) {
|
|
425
|
+
const url = `${base}/hosted_ability/storage/${appId}${path}`;
|
|
412
426
|
const data = {
|
|
413
|
-
...params
|
|
414
|
-
instance_id
|
|
427
|
+
...params
|
|
415
428
|
};
|
|
416
|
-
return fetch.post(url, data
|
|
429
|
+
return fetch.post(url, data, {
|
|
430
|
+
headers: buildAuthHeaders()
|
|
431
|
+
});
|
|
417
432
|
}
|
|
418
433
|
throw new Error(JSON.stringify({
|
|
419
434
|
base,
|
|
420
|
-
|
|
435
|
+
appId
|
|
421
436
|
}));
|
|
422
437
|
}).then((response) => {
|
|
423
438
|
return response.data;
|
|
@@ -434,16 +449,16 @@ const fetchBase = (path, params) => {
|
|
|
434
449
|
});
|
|
435
450
|
};
|
|
436
451
|
const fetchUpload = (params) => {
|
|
437
|
-
return fetchBase(
|
|
452
|
+
return fetchBase(`/object/get_upload_policy_info`, params);
|
|
438
453
|
};
|
|
439
454
|
const fetchDownload = (params) => {
|
|
440
|
-
return fetchBase(
|
|
455
|
+
return fetchBase(`/object/get_download_pre_signed_url`, params);
|
|
441
456
|
};
|
|
442
457
|
const fetchDelete = (params) => {
|
|
443
|
-
return fetchBase(
|
|
458
|
+
return fetchBase(`/object/delete`, params);
|
|
444
459
|
};
|
|
445
460
|
const fetchMetadata = (params) => {
|
|
446
|
-
return fetchBase(
|
|
461
|
+
return fetchBase(`/object/get_metadata`, params);
|
|
447
462
|
};
|
|
448
463
|
const object = {
|
|
449
464
|
ObjectError,
|
|
@@ -453,7 +468,8 @@ const object = {
|
|
|
453
468
|
object_key: key
|
|
454
469
|
});
|
|
455
470
|
if (result.code === "OK") {
|
|
456
|
-
|
|
471
|
+
var _result$data;
|
|
472
|
+
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.url) {
|
|
457
473
|
const {
|
|
458
474
|
url,
|
|
459
475
|
fields
|
|
@@ -7,55 +7,55 @@ export type BaseIndexesStructValue = null | StringOrNumberOrBoolean[] | [StringO
|
|
|
7
7
|
export type BaseIndexesStruct<IndexesStruct> = SetFieldType<IndexesStruct, keyof IndexesStruct, BaseIndexesStructValue>;
|
|
8
8
|
export type UnionIndexesStruct<IndexesStruct> = BaseIndexesStruct<IndexesStruct> | EmptyObject | null;
|
|
9
9
|
/**
|
|
10
|
-
* @description
|
|
11
|
-
* @typedef EntityStruct
|
|
12
|
-
* @typedef IndexesStruct
|
|
10
|
+
* @description Entity operation object
|
|
11
|
+
* @typedef EntityStruct Entity data structure
|
|
12
|
+
* @typedef IndexesStruct Entity index structure
|
|
13
13
|
*/
|
|
14
14
|
export interface Entity<EntityStruct extends BaseEntityStruct<EntityStruct>, IndexesStruct extends UnionIndexesStruct<IndexesStruct>> {
|
|
15
15
|
/**
|
|
16
|
-
* @description
|
|
17
|
-
* @param key
|
|
18
|
-
* @returns
|
|
16
|
+
* @description Get one entity record
|
|
17
|
+
* @param key Entity data key
|
|
18
|
+
* @returns Entity data value
|
|
19
19
|
*/
|
|
20
20
|
get<Key extends string>(key: NotEmptyString<Key>): Promise<EntityStruct | undefined>;
|
|
21
21
|
/**
|
|
22
|
-
* @description
|
|
23
|
-
* @param key
|
|
24
|
-
* @param value
|
|
22
|
+
* @description Create or update one entity record
|
|
23
|
+
* @param key Entity data key
|
|
24
|
+
* @param value Entity data value
|
|
25
25
|
*/
|
|
26
26
|
set<Key extends string>(key: NotEmptyString<Key>, value: Partial<EntityStruct>): Promise<void>;
|
|
27
27
|
/**
|
|
28
|
-
* @description
|
|
29
|
-
* @param key
|
|
28
|
+
* @description Delete one entity record
|
|
29
|
+
* @param key Entity data key
|
|
30
30
|
*/
|
|
31
31
|
delete<Key extends string>(key: NotEmptyString<Key>): Promise<void>;
|
|
32
32
|
/**
|
|
33
|
-
* @description
|
|
33
|
+
* @description Create entity query object
|
|
34
34
|
* @returns EntityQuery
|
|
35
35
|
*/
|
|
36
36
|
query(): IfNull<IndexesStruct, BaseEntityQuery<EntityStruct, EmptyObject>, IfEmptyObject<IndexesStruct, InputIndexEntityQuery<EntityStruct, EmptyObject>, InferIndexEntityQuery<EntityStruct, Exclude<IndexesStruct, EmptyObject | null>>>>;
|
|
37
37
|
/**
|
|
38
|
-
* @description
|
|
39
|
-
* @param items
|
|
38
|
+
* @description Batch create or update entity data
|
|
39
|
+
* @param items Array of items
|
|
40
40
|
*/
|
|
41
41
|
batchSet<Items extends EntityBatchSetItem<EntityStruct>[]>(items: NotEmptyArray<Items>): Promise<void>;
|
|
42
42
|
/**
|
|
43
|
-
* @description
|
|
44
|
-
* @param keys
|
|
43
|
+
* @description Batch delete entity data
|
|
44
|
+
* @param keys Array of entity data keys
|
|
45
45
|
*/
|
|
46
46
|
batchDelete<Keys extends string[]>(keys: NotEmptyArray<Keys>): Promise<void>;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* @description
|
|
50
|
-
* @typedef EntityStruct
|
|
49
|
+
* @description Item for batch create or update entity data
|
|
50
|
+
* @typedef EntityStruct Entity data structure
|
|
51
51
|
*/
|
|
52
52
|
export interface EntityBatchSetItem<EntityStruct extends BaseEntityStruct<EntityStruct>> {
|
|
53
53
|
/**
|
|
54
|
-
* @description
|
|
54
|
+
* @description Entity data key
|
|
55
55
|
*/
|
|
56
56
|
key: string;
|
|
57
57
|
/**
|
|
58
|
-
* @description
|
|
58
|
+
* @description Entity data value
|
|
59
59
|
*/
|
|
60
60
|
value: Partial<EntityStruct>;
|
|
61
61
|
}
|
|
@@ -1,126 +1,126 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @enum EntityErrorCode
|
|
3
|
-
* @description
|
|
3
|
+
* @description Entity error code enum
|
|
4
4
|
*/
|
|
5
5
|
export declare enum EntityErrorCode {
|
|
6
6
|
/**
|
|
7
|
-
* @description
|
|
7
|
+
* @description Entity name is empty / contains invalid characters / exceeds max length
|
|
8
8
|
* @satisfies /^[_a-z0-9]{1,32}$/
|
|
9
9
|
*/
|
|
10
10
|
EntityNameInvalid = "EntityNameInvalid",
|
|
11
11
|
/**
|
|
12
|
-
* @description
|
|
12
|
+
* @description Entity name does not exist (not defined in config)
|
|
13
13
|
*/
|
|
14
14
|
EntityNotFound = "EntityNotFound",
|
|
15
15
|
/**
|
|
16
|
-
* @description
|
|
16
|
+
* @description Entity data cannot be empty
|
|
17
17
|
*/
|
|
18
18
|
EntityDataEmpty = "EntityDataEmpty",
|
|
19
19
|
/**
|
|
20
|
-
* @description
|
|
20
|
+
* @description Too many entity data items
|
|
21
21
|
* @satisfies maximum 100 items
|
|
22
22
|
*/
|
|
23
23
|
EntityDataBatchLimit = "EntityDataBatchLimit",
|
|
24
24
|
/**
|
|
25
|
-
* @description key
|
|
25
|
+
* @description key is empty / contains invalid characters / exceeds max length
|
|
26
26
|
* @satisfies /^[_a-z0-9]{1,64}$/
|
|
27
27
|
*/
|
|
28
28
|
EntityDataKeyInvalid = "EntityDataKeyInvalid",
|
|
29
29
|
/**
|
|
30
|
-
* @description key
|
|
30
|
+
* @description Duplicate key
|
|
31
31
|
*/
|
|
32
32
|
EntityDataKeyDuplicate = "EntityDataKeyDuplicate",
|
|
33
33
|
/**
|
|
34
|
-
* @description
|
|
34
|
+
* @description Attribute name is empty / contains invalid characters / exceeds max length
|
|
35
35
|
* @satisfies /^[_a-z0-9]{1,64}$/
|
|
36
36
|
*/
|
|
37
37
|
EntityDataValueAttrInvalid = "EntityDataValueAttrInvalid",
|
|
38
38
|
/**
|
|
39
|
-
* @description
|
|
39
|
+
* @description Attribute name does not exist (not defined in config)
|
|
40
40
|
*/
|
|
41
41
|
EntityDataValueAttrNotFound = "EntityDataValueAttrNotFound",
|
|
42
42
|
/**
|
|
43
|
-
* @description
|
|
43
|
+
* @description Value cannot be empty
|
|
44
44
|
*/
|
|
45
45
|
EntityDataValueEmpty = "EntityDataValueEmpty",
|
|
46
46
|
/**
|
|
47
|
-
* @description
|
|
47
|
+
* @description Invalid value
|
|
48
48
|
*/
|
|
49
49
|
EntityDataValueInvalid = "EntityDataValueInvalid",
|
|
50
50
|
/**
|
|
51
|
-
* @description string
|
|
51
|
+
* @description Value of string attribute exceeds max length
|
|
52
52
|
*/
|
|
53
53
|
EntityDataStringValueTooLong = "EntityDataStringValueTooLong",
|
|
54
54
|
/**
|
|
55
|
-
* @description text
|
|
55
|
+
* @description Value of text attribute exceeds max length
|
|
56
56
|
* @satisfies maximum 32768 characters
|
|
57
57
|
*/
|
|
58
58
|
EntityDataTextValueTooLong = "EntityDataTextValueTooLong",
|
|
59
59
|
/**
|
|
60
|
-
* @description
|
|
60
|
+
* @description Missing required attribute
|
|
61
61
|
*/
|
|
62
62
|
EntityDataAttrRequired = "EntityDataAttrRequired",
|
|
63
63
|
/**
|
|
64
|
-
* @description
|
|
64
|
+
* @description Attribute value type does not match definition
|
|
65
65
|
*/
|
|
66
66
|
EntityDataValueTypeInvalid = "EntityDataValueTypeInvalid",
|
|
67
67
|
/**
|
|
68
|
-
* @description
|
|
68
|
+
* @description Index cannot be empty
|
|
69
69
|
*/
|
|
70
70
|
EntityDataIndexEmpty = "EntityDataIndexEmpty",
|
|
71
71
|
/**
|
|
72
|
-
* @description
|
|
72
|
+
* @description Index is empty / contains invalid characters / exceeds max length
|
|
73
73
|
* @satisfies /^[_a-z0-9]{1,64}$/
|
|
74
74
|
*/
|
|
75
75
|
EntityDataIndexNameInvalid = "EntityDataIndexNameInvalid",
|
|
76
76
|
/**
|
|
77
|
-
* @description
|
|
77
|
+
* @description Index does not exist (not defined in config)
|
|
78
78
|
*/
|
|
79
79
|
EntityDataIndexNotFound = "EntityDataIndexNotFound",
|
|
80
80
|
/**
|
|
81
|
-
* @description
|
|
81
|
+
* @description Attribute value in custom index is empty or invalid
|
|
82
82
|
*/
|
|
83
83
|
EntityDataPartitionValueInvalid = "EntityDataPartitionValueInvalid",
|
|
84
84
|
/**
|
|
85
|
-
* @description
|
|
85
|
+
* @description Attribute value type in custom index does not match definition
|
|
86
86
|
*/
|
|
87
87
|
EntityDataPartitionValueTypeInvalid = "EntityDataPartitionValueTypeInvalid",
|
|
88
88
|
/**
|
|
89
|
-
* @description
|
|
89
|
+
* @description Attribute value in custom index exceeds max length
|
|
90
90
|
*/
|
|
91
91
|
EntityDataPartitionValueTooLong = "EntityDataPartitionValueTooLong",
|
|
92
92
|
/**
|
|
93
|
-
* @description
|
|
93
|
+
* @description Unique constraint violation
|
|
94
94
|
*/
|
|
95
95
|
EntityDataUniqueConstraintFailed = "EntityDataUniqueConstraintFailed",
|
|
96
96
|
/**
|
|
97
|
-
* @description
|
|
97
|
+
* @description Attribute value type in entity query condition clause does not match
|
|
98
98
|
*/
|
|
99
99
|
EntityDataWhereConditionValueTypeInvalid = "EntityDataWhereConditionValueTypeInvalid",
|
|
100
100
|
/**
|
|
101
|
-
* @description
|
|
101
|
+
* @description Attribute value in entity query condition clause exceeds max length
|
|
102
102
|
*/
|
|
103
103
|
EntityDataWhereConditionValueTooLong = "EntityDataWhereConditionValueTooLong",
|
|
104
104
|
/**
|
|
105
|
-
* @description
|
|
105
|
+
* @description Entity query cursor value is invalid
|
|
106
106
|
*/
|
|
107
107
|
EntityDataPageCursorInvalid = "EntityDataPageCursorInvalid",
|
|
108
108
|
/**
|
|
109
|
-
* @description
|
|
109
|
+
* @description Entity query sort value is invalid
|
|
110
110
|
* @satisfies EntitySortEnum
|
|
111
111
|
*/
|
|
112
112
|
EntityDataSortValueInvalid = "EntityDataSortValueInvalid",
|
|
113
113
|
/**
|
|
114
|
-
* @description
|
|
114
|
+
* @description Entity query page limit value is invalid
|
|
115
115
|
* @satisfies [1, 1000]
|
|
116
116
|
*/
|
|
117
117
|
EntityDataPageLimitNotInRange = "EntityDataPageLimitNotInRange",
|
|
118
118
|
/**
|
|
119
|
-
* @description
|
|
119
|
+
* @description Entity operation or query timeout
|
|
120
120
|
*/
|
|
121
121
|
EntityDataAPITimeOut = "EntityDataAPITimeOut",
|
|
122
122
|
/**
|
|
123
|
-
* @description JSON
|
|
123
|
+
* @description JSON serialization failed
|
|
124
124
|
*/
|
|
125
125
|
MalformedJSON = "Malformed.JSON"
|
|
126
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/entity/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,oBAAoB,EAEpB,qBAAqB,EAErB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/entity/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,oBAAoB,EAEpB,qBAAqB,EAErB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;AA2DvB,eAAO,MAAM,SAAS,EAAE,mBAIvB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAYxB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAIxB,CAAA"}
|