@things-factory/id-rule-base 4.0.11 → 4.0.12
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-server/constants/index.js +14 -0
- package/dist-server/constants/index.js.map +1 -0
- package/dist-server/constants/sequence-type.js +7 -0
- package/dist-server/constants/sequence-type.js.map +1 -0
- package/dist-server/service/sequence/sequence-mutation.js +21 -18
- package/dist-server/service/sequence/sequence-mutation.js.map +1 -1
- package/dist-server/service/sequence/sequence.js +5 -0
- package/dist-server/service/sequence/sequence.js.map +1 -1
- package/package.json +6 -6
- package/server/constants/index.ts +1 -0
- package/server/constants/sequence-type.ts +3 -0
- package/server/service/sequence/sequence-mutation.ts +26 -22
- package/server/service/sequence/sequence.ts +5 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./sequence-type"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-type.js","sourceRoot":"","sources":["../../server/constants/sequence-type.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B,qBAAqB,EAAE,uBAAuB;CAC/C,CAAA"}
|
|
@@ -15,51 +15,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.SequenceMutation = void 0;
|
|
16
16
|
const type_graphql_1 = require("type-graphql");
|
|
17
17
|
const typeorm_1 = require("typeorm");
|
|
18
|
+
const constants_1 = require("../../constants");
|
|
18
19
|
const sequence_1 = require("./sequence");
|
|
19
20
|
let SequenceMutation = class SequenceMutation {
|
|
20
|
-
async upsertSequence(
|
|
21
|
+
async upsertSequence(type, counter, bizplaceId, context) {
|
|
21
22
|
const { domain } = context.state;
|
|
22
23
|
const seqRepo = (0, typeorm_1.getRepository)(sequence_1.Sequence);
|
|
23
24
|
const now = new Date();
|
|
24
25
|
const expiresAt = new Date(now.setMonth(now.getMonth() + 12));
|
|
25
|
-
|
|
26
|
+
const patternObj = {
|
|
27
|
+
type,
|
|
28
|
+
date: new Date().toISOString().split('T')[0],
|
|
29
|
+
bizplaceId
|
|
30
|
+
};
|
|
31
|
+
const pattern = JSON.stringify(patternObj);
|
|
26
32
|
const foundSeq = await seqRepo.findOne({
|
|
27
|
-
where: { pattern, domain }
|
|
33
|
+
where: { pattern, type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
|
|
28
34
|
});
|
|
29
35
|
if (foundSeq) {
|
|
30
|
-
return await seqRepo.
|
|
36
|
+
return await seqRepo.update({ id: foundSeq.id }, {
|
|
37
|
+
pattern,
|
|
38
|
+
seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1,
|
|
39
|
+
expiresAt,
|
|
40
|
+
updatedAt: now
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
43
|
else {
|
|
33
44
|
return await seqRepo.save({
|
|
34
45
|
domain,
|
|
35
46
|
pattern,
|
|
36
47
|
seq: counter || 1,
|
|
37
|
-
expiresAt
|
|
48
|
+
expiresAt,
|
|
49
|
+
type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER
|
|
38
50
|
});
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
};
|
|
42
54
|
__decorate([
|
|
43
55
|
(0, type_graphql_1.Mutation)(returns => sequence_1.Sequence),
|
|
44
|
-
__param(0, (0, type_graphql_1.Arg)('
|
|
56
|
+
__param(0, (0, type_graphql_1.Arg)('type')),
|
|
45
57
|
__param(1, (0, type_graphql_1.Arg)('counter')),
|
|
46
|
-
__param(2, (0, type_graphql_1.
|
|
58
|
+
__param(2, (0, type_graphql_1.Arg)('bizplaceId')),
|
|
59
|
+
__param(3, (0, type_graphql_1.Ctx)()),
|
|
47
60
|
__metadata("design:type", Function),
|
|
48
|
-
__metadata("design:paramtypes", [String, Number, Object]),
|
|
61
|
+
__metadata("design:paramtypes", [String, Number, String, Object]),
|
|
49
62
|
__metadata("design:returntype", Promise)
|
|
50
63
|
], SequenceMutation.prototype, "upsertSequence", null);
|
|
51
64
|
SequenceMutation = __decorate([
|
|
52
65
|
(0, type_graphql_1.Resolver)(sequence_1.Sequence)
|
|
53
66
|
], SequenceMutation);
|
|
54
67
|
exports.SequenceMutation = SequenceMutation;
|
|
55
|
-
function getDateStr() {
|
|
56
|
-
const today = new Date();
|
|
57
|
-
const year = today.getFullYear();
|
|
58
|
-
const month = today.getMonth();
|
|
59
|
-
const day = today.getDate();
|
|
60
|
-
const yy = String(year).substr(String(year).length - 2);
|
|
61
|
-
const mm = String(month + 1).padStart(2, '0');
|
|
62
|
-
const dd = String(day).padStart(2, '0');
|
|
63
|
-
return yy + mm + dd;
|
|
64
|
-
}
|
|
65
68
|
//# sourceMappingURL=sequence-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence-mutation.js","sourceRoot":"","sources":["../../../server/service/sequence/sequence-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,qCAAuC;AAEvC,yCA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,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBACxD,SAAS;gBACT,SAAS,EAAE,GAAG;aACf,CACF,CAAA;SACF;aAAM;YACL,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACxB,MAAM;gBACN,OAAO;gBACP,GAAG,EAAE,OAAO,IAAI,CAAC;gBACjB,SAAS;gBACT,IAAI,EAAE,yBAAa,CAAC,qBAAqB;aAC1C,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA;AA3CC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,CAAC;IAE3B,WAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,WAAA,IAAA,kBAAG,EAAC,SAAS,CAAC,CAAA;IACd,WAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;sDAsCP;AA5CU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA6C5B;AA7CY,4CAAgB"}
|
|
@@ -38,6 +38,11 @@ __decorate([
|
|
|
38
38
|
(0, type_graphql_1.Field)(),
|
|
39
39
|
__metadata("design:type", Number)
|
|
40
40
|
], Sequence.prototype, "seq", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
43
|
+
(0, type_graphql_1.Field)(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], Sequence.prototype, "type", void 0);
|
|
41
46
|
__decorate([
|
|
42
47
|
(0, typeorm_1.Column)(),
|
|
43
48
|
(0, type_graphql_1.Field)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../../server/service/sequence/sequence.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCAAsH;AAEtH,iDAA8C;AAO9C,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,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACtF,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,GAAa,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxD,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,GAAa,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAA,yBAAU,GAAE;GACA,QAAQ,CAmCpB;AAnCY,4BAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/id-rule-base",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/grist-ui": "^4.0.
|
|
28
|
-
"@things-factory/i18n-base": "^4.0.
|
|
29
|
-
"@things-factory/setting-base": "^4.0.
|
|
30
|
-
"@things-factory/shell": "^4.0.
|
|
27
|
+
"@things-factory/grist-ui": "^4.0.12",
|
|
28
|
+
"@things-factory/i18n-base": "^4.0.12",
|
|
29
|
+
"@things-factory/setting-base": "^4.0.12",
|
|
30
|
+
"@things-factory/shell": "^4.0.12",
|
|
31
31
|
"codemirror": "^5.59.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/codemirror": "^0.0.105"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "29d59ff95fcb473cb43c6f798cd04f3ec3a779a0"
|
|
37
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sequence-type'
|
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
|
|
2
2
|
import { getRepository } from 'typeorm'
|
|
3
3
|
|
|
4
|
+
import { SEQUENCE_TYPE } from '../../constants'
|
|
4
5
|
import { Sequence } from './sequence'
|
|
5
6
|
|
|
6
7
|
@Resolver(Sequence)
|
|
7
8
|
export class SequenceMutation {
|
|
8
9
|
@Mutation(returns => Sequence)
|
|
9
|
-
async upsertSequence(
|
|
10
|
+
async upsertSequence(
|
|
11
|
+
@Arg('type') type: string,
|
|
12
|
+
@Arg('counter') counter: number,
|
|
13
|
+
@Arg('bizplaceId') bizplaceId: string,
|
|
14
|
+
@Ctx() context: any
|
|
15
|
+
) {
|
|
10
16
|
const { domain } = context.state
|
|
11
17
|
const seqRepo = getRepository(Sequence)
|
|
12
18
|
const now = new Date()
|
|
13
19
|
const expiresAt = new Date(now.setMonth(now.getMonth() + 12))
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
const patternObj: any = {
|
|
22
|
+
type,
|
|
23
|
+
date: new Date().toISOString().split('T')[0],
|
|
24
|
+
bizplaceId
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const pattern: string = JSON.stringify(patternObj)
|
|
16
28
|
|
|
17
29
|
const foundSeq = await seqRepo.findOne({
|
|
18
|
-
where: { pattern, domain }
|
|
30
|
+
where: { pattern, type: SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
|
|
19
31
|
})
|
|
20
32
|
|
|
21
33
|
if (foundSeq) {
|
|
22
|
-
return await seqRepo.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
return await seqRepo.update(
|
|
35
|
+
{ id: foundSeq.id },
|
|
36
|
+
{
|
|
37
|
+
pattern,
|
|
38
|
+
seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1,
|
|
39
|
+
expiresAt,
|
|
40
|
+
updatedAt: now
|
|
41
|
+
}
|
|
42
|
+
)
|
|
27
43
|
} else {
|
|
28
44
|
return await seqRepo.save({
|
|
29
45
|
domain,
|
|
30
46
|
pattern,
|
|
31
47
|
seq: counter || 1,
|
|
32
|
-
expiresAt
|
|
48
|
+
expiresAt,
|
|
49
|
+
type: SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER
|
|
33
50
|
})
|
|
34
51
|
}
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
|
-
|
|
38
|
-
function getDateStr() {
|
|
39
|
-
const today = new Date()
|
|
40
|
-
const year = today.getFullYear()
|
|
41
|
-
const month = today.getMonth()
|
|
42
|
-
const day = today.getDate()
|
|
43
|
-
|
|
44
|
-
const yy = String(year).substr(String(year).length - 2)
|
|
45
|
-
const mm = String(month + 1).padStart(2, '0')
|
|
46
|
-
const dd = String(day).padStart(2, '0')
|
|
47
|
-
|
|
48
|
-
return yy + mm + dd
|
|
49
|
-
}
|