@things-factory/id-rule-base 3.7.0 → 3.8.0
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/entities/sequence.js +5 -1
- package/dist-server/entities/sequence.js.map +1 -1
- package/dist-server/graphql/resolvers/index.js +1 -1
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/update-insert-sequence.js +19 -17
- package/dist-server/graphql/resolvers/update-insert-sequence.js.map +1 -1
- package/dist-server/graphql/types/index.js +1 -1
- package/dist-server/index.js +2 -1
- package/dist-server/index.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/entities/sequence.ts +6 -1
- package/server/graphql/resolvers/index.ts +2 -2
- package/server/graphql/resolvers/update-insert-sequence.ts +22 -23
- package/server/graphql/types/index.ts +1 -1
- package/server/index.ts +3 -2
|
@@ -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"}
|
|
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var _a;
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.Sequence = void 0;
|
|
14
|
-
const shell_1 = require("@things-factory/shell");
|
|
15
14
|
const typeorm_1 = require("typeorm");
|
|
15
|
+
const shell_1 = require("@things-factory/shell");
|
|
16
16
|
let Sequence = class Sequence {
|
|
17
17
|
};
|
|
18
18
|
__decorate([
|
|
@@ -33,6 +33,10 @@ __decorate([
|
|
|
33
33
|
}),
|
|
34
34
|
__metadata("design:type", Number)
|
|
35
35
|
], Sequence.prototype, "seq", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], Sequence.prototype, "type", void 0);
|
|
36
40
|
__decorate([
|
|
37
41
|
(0, typeorm_1.Column)(),
|
|
38
42
|
__metadata("design:type", Date)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../server/entities/sequence.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../server/entities/sequence.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAsH;AAEtH,iDAA8C;AAM9C,IAAa,QAAQ,GAArB,MAAa,QAAQ;CA2BpB,CAAA;AAzBC;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;oCACrB;AAGV;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;kDAClB,cAAM,oBAAN,cAAM;wCAAA;AAGd;IADC,IAAA,gBAAM,GAAE;;yCACM;AAKf;IAHC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,UAAU;KACjB,CAAC;;qCACS;AAIX;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACf;AAGZ;IADC,IAAA,gBAAM,GAAE;8BACE,IAAI;2CAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;2CAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;2CAAA;AA1BJ,QAAQ;IAJpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,GAAa,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,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;GAC9C,QAAQ,CA2BpB;AA3BY,4BAAQ"}
|
|
@@ -7,6 +7,6 @@ const update_id_rule_1 = require("./update-id-rule");
|
|
|
7
7
|
const update_insert_sequence_1 = require("./update-insert-sequence");
|
|
8
8
|
exports.IdRuleResolver = {
|
|
9
9
|
Query: Object.assign({}, id_rule_1.idRuleResolver),
|
|
10
|
-
Mutation: Object.assign(Object.assign(Object.assign({}, create_id_rule_1.createIdRule), update_id_rule_1.updateIdRule), update_insert_sequence_1.
|
|
10
|
+
Mutation: Object.assign(Object.assign(Object.assign({}, create_id_rule_1.createIdRule), update_id_rule_1.updateIdRule), update_insert_sequence_1.updateInsertSequence)
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/index.ts"],"names":[],"mappings":";;;AAAA,qDAA+C;AAC/C,uCAA0C;AAC1C,qDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/index.ts"],"names":[],"mappings":";;;AAAA,qDAA+C;AAC/C,uCAA0C;AAC1C,qDAA+C;AAC/C,qEAA+D;AAElD,QAAA,cAAc,GAAG;IAC5B,KAAK,oBACA,wBAAc,CAClB;IACD,QAAQ,gDACH,6BAAY,GACZ,6BAAY,GACZ,6CAAoB,CACxB;CACF,CAAA"}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updateInsertSequence = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
5
6
|
const entities_1 = require("../../entities");
|
|
6
|
-
exports.
|
|
7
|
-
async
|
|
7
|
+
exports.updateInsertSequence = {
|
|
8
|
+
async updateInsertSequence(_, { type, counter, bizplaceId }, context) {
|
|
8
9
|
const domain = context.state.domain;
|
|
9
10
|
const seqRepo = (0, typeorm_1.getRepository)(entities_1.Sequence);
|
|
10
11
|
const now = new Date();
|
|
11
12
|
const expiresAt = new Date(now.setMonth(now.getMonth() + 12));
|
|
12
|
-
|
|
13
|
+
const patternObj = {
|
|
14
|
+
type,
|
|
15
|
+
date: new Date().toISOString().split('T')[0],
|
|
16
|
+
bizplaceId
|
|
17
|
+
};
|
|
18
|
+
const pattern = JSON.stringify(patternObj);
|
|
13
19
|
const foundSeq = await seqRepo.findOne({
|
|
14
|
-
where: { pattern, domain }
|
|
20
|
+
where: { pattern, type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
|
|
15
21
|
});
|
|
16
22
|
if (foundSeq) {
|
|
17
|
-
return await seqRepo.
|
|
23
|
+
return await seqRepo.update({ id: foundSeq.id }, {
|
|
24
|
+
pattern,
|
|
25
|
+
seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1,
|
|
26
|
+
expiresAt,
|
|
27
|
+
updatedAt: now
|
|
28
|
+
});
|
|
18
29
|
}
|
|
19
30
|
else {
|
|
20
31
|
return await seqRepo.save({
|
|
21
32
|
domain,
|
|
22
33
|
pattern,
|
|
23
34
|
seq: counter || 1,
|
|
24
|
-
expiresAt
|
|
35
|
+
expiresAt,
|
|
36
|
+
type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER
|
|
25
37
|
});
|
|
26
38
|
}
|
|
27
39
|
}
|
|
28
40
|
};
|
|
29
|
-
function getDateStr() {
|
|
30
|
-
const today = new Date();
|
|
31
|
-
const year = today.getFullYear();
|
|
32
|
-
const month = today.getMonth();
|
|
33
|
-
const day = today.getDate();
|
|
34
|
-
const yy = String(year).substr(String(year).length - 2);
|
|
35
|
-
const mm = String(month + 1).padStart(2, '0');
|
|
36
|
-
const dd = String(day).padStart(2, '0');
|
|
37
|
-
return yy + mm + dd;
|
|
38
|
-
}
|
|
39
41
|
//# sourceMappingURL=update-insert-sequence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-insert-sequence.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/update-insert-sequence.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAIvC,6CAAyC;AAE5B,QAAA,
|
|
1
|
+
{"version":3,"file":"update-insert-sequence.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/update-insert-sequence.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAIvC,+CAA+C;AAC/C,6CAAyC;AAE5B,QAAA,oBAAo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IAAI,EAAE,yBAAa,CAAC,qBAAqB;aAC1C,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
|
|
@@ -24,7 +24,7 @@ exports.IdRuleResolver = (0, graphql_tag_1.default) `
|
|
|
24
24
|
createIdRule(idRule: NewIdRule!): IdRule
|
|
25
25
|
|
|
26
26
|
updateIdRule(type: String!, patch: IdRulePatch): IdRule
|
|
27
|
-
|
|
27
|
+
updateInsertSequence(type: String!, counter: Int, bizplaceId: String!): Sequence
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
extend type Query {
|
package/dist-server/index.js
CHANGED
|
@@ -10,9 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
require("./routes");
|
|
13
14
|
__exportStar(require("./entities"), exports);
|
|
15
|
+
__exportStar(require("./constants"), exports);
|
|
14
16
|
__exportStar(require("./migrations"), exports);
|
|
15
17
|
__exportStar(require("./graphql"), exports);
|
|
16
18
|
__exportStar(require("./controllers"), exports);
|
|
17
|
-
require("./routes");
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,+CAA4B;AAC5B,4CAAyB;AACzB,gDAA6B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oBAAiB;AAEjB,6CAA0B;AAC1B,8CAA2B;AAC3B,+CAA4B;AAC5B,4CAAyB;AACzB,gDAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/id-rule-base",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
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": "^3.7.
|
|
28
|
-
"@things-factory/i18n-base": "^3.
|
|
29
|
-
"@things-factory/setting-base": "^3.
|
|
30
|
-
"@things-factory/shell": "^3.
|
|
27
|
+
"@things-factory/grist-ui": "^3.7.5",
|
|
28
|
+
"@things-factory/i18n-base": "^3.8.0",
|
|
29
|
+
"@things-factory/setting-base": "^3.8.0",
|
|
30
|
+
"@things-factory/shell": "^3.8.0",
|
|
31
31
|
"codemirror": "^5.59.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/codemirror": "^0.0.105"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d3a61edb1a77732db20185aedc47b2cce6dd1f82"
|
|
37
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sequence-type'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Domain } from '@things-factory/shell'
|
|
2
1
|
import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
3
2
|
|
|
3
|
+
import { Domain } from '@things-factory/shell'
|
|
4
|
+
|
|
4
5
|
@Entity()
|
|
5
6
|
@Index('ix_sequence_0', (seq: Sequence) => [seq.domain, seq.pattern], { unique: true })
|
|
6
7
|
@Index('ix_sequence_1', (seq: Sequence) => [seq.pattern])
|
|
@@ -20,6 +21,10 @@ export class Sequence {
|
|
|
20
21
|
})
|
|
21
22
|
seq: number
|
|
22
23
|
|
|
24
|
+
//// to differentiate between normal pattern sequence VS label counter ////
|
|
25
|
+
@Column({ nullable: true })
|
|
26
|
+
type: string
|
|
27
|
+
|
|
23
28
|
@Column()
|
|
24
29
|
expiresAt: Date
|
|
25
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createIdRule } from './create-id-rule'
|
|
2
2
|
import { idRuleResolver } from './id-rule'
|
|
3
3
|
import { updateIdRule } from './update-id-rule'
|
|
4
|
-
import {
|
|
4
|
+
import { updateInsertSequence } from './update-insert-sequence'
|
|
5
5
|
|
|
6
6
|
export const IdRuleResolver = {
|
|
7
7
|
Query: {
|
|
@@ -10,6 +10,6 @@ export const IdRuleResolver = {
|
|
|
10
10
|
Mutation: {
|
|
11
11
|
...createIdRule,
|
|
12
12
|
...updateIdRule,
|
|
13
|
-
...
|
|
13
|
+
...updateInsertSequence
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -2,47 +2,46 @@ import { getRepository } from 'typeorm'
|
|
|
2
2
|
|
|
3
3
|
import { Domain } from '@things-factory/shell'
|
|
4
4
|
|
|
5
|
+
import { SEQUENCE_TYPE } from '../../constants'
|
|
5
6
|
import { Sequence } from '../../entities'
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
async
|
|
8
|
+
export const updateInsertSequence = {
|
|
9
|
+
async updateInsertSequence(_: any, { type, counter, bizplaceId }, context: any) {
|
|
9
10
|
const domain: Domain = context.state.domain
|
|
10
11
|
const seqRepo = getRepository(Sequence)
|
|
11
12
|
const now = new Date()
|
|
12
13
|
const expiresAt = new Date(now.setMonth(now.getMonth() + 12))
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const patternObj: any = {
|
|
16
|
+
type,
|
|
17
|
+
date: new Date().toISOString().split('T')[0],
|
|
18
|
+
bizplaceId
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const pattern: string = JSON.stringify(patternObj)
|
|
15
22
|
|
|
16
23
|
const foundSeq = await seqRepo.findOne({
|
|
17
|
-
where: { pattern, domain }
|
|
24
|
+
where: { pattern, type: SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
|
|
18
25
|
})
|
|
19
26
|
|
|
20
27
|
if (foundSeq) {
|
|
21
|
-
return await seqRepo.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
return await seqRepo.update(
|
|
29
|
+
{ id: foundSeq.id },
|
|
30
|
+
{
|
|
31
|
+
pattern,
|
|
32
|
+
seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1,
|
|
33
|
+
expiresAt,
|
|
34
|
+
updatedAt: now
|
|
35
|
+
}
|
|
36
|
+
)
|
|
26
37
|
} else {
|
|
27
38
|
return await seqRepo.save({
|
|
28
39
|
domain,
|
|
29
40
|
pattern,
|
|
30
41
|
seq: counter || 1,
|
|
31
|
-
expiresAt
|
|
42
|
+
expiresAt,
|
|
43
|
+
type: SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER
|
|
32
44
|
})
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
|
-
|
|
37
|
-
function getDateStr() {
|
|
38
|
-
const today = new Date()
|
|
39
|
-
const year = today.getFullYear()
|
|
40
|
-
const month = today.getMonth()
|
|
41
|
-
const day = today.getDate()
|
|
42
|
-
|
|
43
|
-
const yy = String(year).substr(String(year).length - 2)
|
|
44
|
-
const mm = String(month + 1).padStart(2, '0')
|
|
45
|
-
const dd = String(day).padStart(2, '0')
|
|
46
|
-
|
|
47
|
-
return yy + mm + dd
|
|
48
|
-
}
|
|
@@ -10,7 +10,7 @@ export const IdRuleResolver = gql`
|
|
|
10
10
|
createIdRule(idRule: NewIdRule!): IdRule
|
|
11
11
|
|
|
12
12
|
updateIdRule(type: String!, patch: IdRulePatch): IdRule
|
|
13
|
-
|
|
13
|
+
updateInsertSequence(type: String!, counter: Int, bizplaceId: String!): Sequence
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
extend type Query {
|