@unchainedshop/core-warehousing 5.0.0-alpha.1 → 5.0.0-alpha.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildDbIndexes
|
|
1
|
+
import { buildDbIndexes } from '@unchainedshop/mongodb';
|
|
2
2
|
export const TokenStatus = {
|
|
3
3
|
CENTRALIZED: 'CENTRALIZED',
|
|
4
4
|
EXPORTING: 'EXPORTING',
|
|
@@ -6,53 +6,36 @@ export const TokenStatus = {
|
|
|
6
6
|
};
|
|
7
7
|
export const TokenSurrogateCollection = async (db) => {
|
|
8
8
|
const TokenSurrogates = db.collection('token_surrogates');
|
|
9
|
-
if (!isDocumentDBCompatModeEnabled()) {
|
|
10
|
-
await buildDbIndexes(TokenSurrogates, [
|
|
11
|
-
{
|
|
12
|
-
index: {
|
|
13
|
-
tokenSerialNumber: 'text',
|
|
14
|
-
userId: 'text',
|
|
15
|
-
productId: 'text',
|
|
16
|
-
_id: 'text',
|
|
17
|
-
walletAddress: 'text',
|
|
18
|
-
contractAddress: 'text',
|
|
19
|
-
},
|
|
20
|
-
options: {
|
|
21
|
-
weights: {
|
|
22
|
-
_id: 9,
|
|
23
|
-
tokenSerialNumber: 8,
|
|
24
|
-
userId: 3,
|
|
25
|
-
productId: 6,
|
|
26
|
-
contractAddress: 5,
|
|
27
|
-
walletAddress: 4,
|
|
28
|
-
status: 1,
|
|
29
|
-
},
|
|
30
|
-
name: 'token_fulltext_search',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
], { rebuild: true });
|
|
34
|
-
}
|
|
35
9
|
await buildDbIndexes(TokenSurrogates, [
|
|
36
10
|
{
|
|
37
11
|
index: {
|
|
38
|
-
tokenSerialNumber:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
index: {
|
|
48
|
-
productId: 1,
|
|
12
|
+
tokenSerialNumber: 'text',
|
|
13
|
+
userId: 'text',
|
|
14
|
+
productId: 'text',
|
|
15
|
+
_id: 'text',
|
|
16
|
+
walletAddress: 'text',
|
|
17
|
+
contractAddress: 'text',
|
|
49
18
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
19
|
+
options: {
|
|
20
|
+
weights: {
|
|
21
|
+
_id: 9,
|
|
22
|
+
tokenSerialNumber: 8,
|
|
23
|
+
userId: 3,
|
|
24
|
+
productId: 6,
|
|
25
|
+
contractAddress: 5,
|
|
26
|
+
walletAddress: 4,
|
|
27
|
+
status: 1,
|
|
28
|
+
},
|
|
29
|
+
name: 'token_fulltext_search',
|
|
54
30
|
},
|
|
55
31
|
},
|
|
32
|
+
], { rebuild: true });
|
|
33
|
+
await buildDbIndexes(TokenSurrogates, [
|
|
34
|
+
{ index: { tokenSerialNumber: 1 } },
|
|
35
|
+
{ index: { userId: 1 } },
|
|
36
|
+
{ index: { orderPositionId: 1 } },
|
|
37
|
+
{ index: { walletAddress: 1 }, options: { sparse: true } },
|
|
38
|
+
{ index: { productId: 1, 'meta.cancelled': 1 }, options: { sparse: true } },
|
|
56
39
|
]);
|
|
57
40
|
return TokenSurrogates;
|
|
58
41
|
};
|
|
@@ -6,21 +6,8 @@ export const WarehousingProviderType = {
|
|
|
6
6
|
export const WarehousingProvidersCollection = async (db) => {
|
|
7
7
|
const WarehousingProviders = db.collection('warehousing-providers');
|
|
8
8
|
await buildDbIndexes(WarehousingProviders, [
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
type: 1,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
index: {
|
|
16
|
-
created: 1,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
index: {
|
|
21
|
-
deleted: 1,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
9
|
+
{ index: { deleted: 1, type: 1 } },
|
|
10
|
+
{ index: { deleted: 1, created: 1 } },
|
|
24
11
|
]);
|
|
25
12
|
return WarehousingProviders;
|
|
26
13
|
};
|
|
@@ -45,7 +45,7 @@ export declare const configureWarehousingModule: ({ db }: ModuleInput<Record<str
|
|
|
45
45
|
walletAddress: string;
|
|
46
46
|
}) => Promise<mongodb.WithId<TokenSurrogate> | null>;
|
|
47
47
|
invalidateToken: (tokenId: string) => Promise<mongodb.WithId<TokenSurrogate> | null>;
|
|
48
|
-
|
|
48
|
+
buildAccessKeyFromToken: (token: TokenSurrogate) => Promise<string>;
|
|
49
49
|
create: (doc: Omit<WarehousingProvider, "_id" | "created"> & Pick<Partial<WarehousingProvider>, "_id">) => Promise<WarehousingProvider>;
|
|
50
50
|
update: (warehousingProviderId: string, doc: Partial<WarehousingProvider>) => Promise<mongodb.WithId<WarehousingProvider> | null>;
|
|
51
51
|
delete: (providerId: string) => Promise<mongodb.WithId<WarehousingProvider> | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
2
|
-
import { generateDbFilterById, generateDbObjectId, escapeRegexString,
|
|
2
|
+
import { generateDbFilterById, generateDbObjectId, escapeRegexString, } from '@unchainedshop/mongodb';
|
|
3
3
|
import { WarehousingProvidersCollection, } from "../db/WarehousingProvidersCollection.js";
|
|
4
4
|
import { TokenSurrogateCollection } from "../db/TokenSurrogateCollection.js";
|
|
5
5
|
import { memoizeWithTTL } from '@unchainedshop/utils';
|
|
@@ -28,7 +28,6 @@ export const buildFindSelector = ({ includeDeleted = false, queryString, warehou
|
|
|
28
28
|
export const buildTokenFindSelector = ({ queryString, walletAddressExists, ...rest }) => {
|
|
29
29
|
const selector = { ...(rest || {}) };
|
|
30
30
|
if (queryString) {
|
|
31
|
-
assertDocumentDBCompatMode();
|
|
32
31
|
selector.$text = { $search: queryString };
|
|
33
32
|
}
|
|
34
33
|
if (walletAddressExists !== undefined) {
|
|
@@ -129,10 +128,7 @@ export const configureWarehousingModule = async ({ db }) => {
|
|
|
129
128
|
await emit('TOKEN_INVALIDATED', { token });
|
|
130
129
|
return token;
|
|
131
130
|
},
|
|
132
|
-
|
|
133
|
-
const token = await TokenSurrogates.findOne(generateDbFilterById(tokenId));
|
|
134
|
-
if (!token)
|
|
135
|
-
return null;
|
|
131
|
+
buildAccessKeyFromToken: async (token) => {
|
|
136
132
|
const payload = [
|
|
137
133
|
token._id,
|
|
138
134
|
token.walletAddress || token.userId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-warehousing",
|
|
3
3
|
"description": "Inventory and stock management module for the Unchained Engine",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.2",
|
|
5
5
|
"main": "lib/warehousing-index.js",
|
|
6
6
|
"types": "lib/warehousing-index.d.ts",
|
|
7
7
|
"type": "module",
|