@things-factory/id-rule-base 4.1.1 → 4.1.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.
Files changed (29) hide show
  1. package/dist-server/entities/id-rule.js +75 -0
  2. package/dist-server/entities/id-rule.js.map +1 -0
  3. package/dist-server/entities/index.js +10 -0
  4. package/dist-server/entities/index.js.map +1 -0
  5. package/dist-server/entities/sequence.js +59 -0
  6. package/dist-server/entities/sequence.js.map +1 -0
  7. package/dist-server/graphql/index.js +30 -0
  8. package/dist-server/graphql/index.js.map +1 -0
  9. package/dist-server/graphql/resolvers/create-id-rule.js +11 -0
  10. package/dist-server/graphql/resolvers/create-id-rule.js.map +1 -0
  11. package/dist-server/graphql/resolvers/id-rule.js +17 -0
  12. package/dist-server/graphql/resolvers/id-rule.js.map +1 -0
  13. package/dist-server/graphql/resolvers/index.js +12 -0
  14. package/dist-server/graphql/resolvers/index.js.map +1 -0
  15. package/dist-server/graphql/resolvers/update-id-rule.js +15 -0
  16. package/dist-server/graphql/resolvers/update-id-rule.js.map +1 -0
  17. package/dist-server/graphql/resolvers/update-insert-sequence.js +41 -0
  18. package/dist-server/graphql/resolvers/update-insert-sequence.js.map +1 -0
  19. package/dist-server/graphql/types/id-rule-patch.js +14 -0
  20. package/dist-server/graphql/types/id-rule-patch.js.map +1 -0
  21. package/dist-server/graphql/types/id-rule.js +17 -0
  22. package/dist-server/graphql/types/id-rule.js.map +1 -0
  23. package/dist-server/graphql/types/index.js +34 -0
  24. package/dist-server/graphql/types/index.js.map +1 -0
  25. package/dist-server/graphql/types/new-id-rule.js +14 -0
  26. package/dist-server/graphql/types/new-id-rule.js.map +1 -0
  27. package/dist-server/graphql/types/sequence.js +18 -0
  28. package/dist-server/graphql/types/sequence.js.map +1 -0
  29. package/package.json +6 -6
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.IdRule = exports.IdRuleType = void 0;
14
+ const env_1 = require("@things-factory/env");
15
+ const shell_1 = require("@things-factory/shell");
16
+ const typeorm_1 = require("typeorm");
17
+ const ORMCONFIG = env_1.config.get('ormconfig', {});
18
+ const DATABASE_TYPE = ORMCONFIG.type;
19
+ var IdRuleType;
20
+ (function (IdRuleType) {
21
+ IdRuleType["PALLET_ID"] = "pallet_id";
22
+ IdRuleType["ADJUSTMENT_PALLET_ID"] = "adjustment_pallet_id";
23
+ IdRuleType["ADJUSTMENT_CARTON_ID"] = "adjustment_carton_id";
24
+ IdRuleType["INBOUND_PALLET_ID"] = "inbound_pallet_id";
25
+ IdRuleType["INBOUND_CARTON_ID"] = "inbound_carton_id";
26
+ IdRuleType["VAS_PALLET_ID"] = "vas_pallet_id";
27
+ IdRuleType["DO_NUMBER"] = "do_number";
28
+ IdRuleType["TASK_NO"] = "task_number";
29
+ IdRuleType["GAN_NUMBER"] = "gan_number";
30
+ IdRuleType["GRN_NUMBER"] = "grn_number";
31
+ IdRuleType["RO_NUMBER"] = "ro_number";
32
+ })(IdRuleType = exports.IdRuleType || (exports.IdRuleType = {}));
33
+ let IdRule = class IdRule {
34
+ };
35
+ __decorate([
36
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
37
+ __metadata("design:type", String)
38
+ ], IdRule.prototype, "id", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
41
+ __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
42
+ ], IdRule.prototype, "domain", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({
45
+ nullable: false,
46
+ type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
47
+ ? 'enum'
48
+ : DATABASE_TYPE == 'oracle'
49
+ ? 'varchar2'
50
+ : 'smallint',
51
+ enum: IdRuleType,
52
+ default: IdRuleType.PALLET_ID
53
+ }),
54
+ __metadata("design:type", String)
55
+ ], IdRule.prototype, "type", void 0);
56
+ __decorate([
57
+ (0, typeorm_1.Column)(),
58
+ __metadata("design:type", String)
59
+ ], IdRule.prototype, "rule", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.CreateDateColumn)(),
62
+ __metadata("design:type", Date)
63
+ ], IdRule.prototype, "createdAt", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.UpdateDateColumn)(),
66
+ __metadata("design:type", Date)
67
+ ], IdRule.prototype, "updatedAt", void 0);
68
+ IdRule = __decorate([
69
+ (0, typeorm_1.Entity)(),
70
+ (0, typeorm_1.Index)('ix_id_rule_0', (idRule) => [idRule.domain, idRule.type], { unique: true }),
71
+ (0, typeorm_1.Index)('ix_id_rule_1', (idRule) => [idRule.domain]),
72
+ (0, typeorm_1.Index)('ix_id_rule_2', (idRule) => [idRule.type])
73
+ ], IdRule);
74
+ exports.IdRule = IdRule;
75
+ //# sourceMappingURL=id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule.js","sourceRoot":"","sources":["../../server/entities/id-rule.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,iDAA8C;AAC9C,qCAAsH;AACtH,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,2DAA6C,CAAA;IAC7C,2DAA6C,CAAA;IAC7C,qDAAuC,CAAA;IACvC,qDAAuC,CAAA;IACvC,6CAA+B,CAAA;IAC/B,qCAAuB,CAAA;IACvB,qCAAuB,CAAA;IACvB,uCAAyB,CAAA;IACzB,uCAAyB,CAAA;IACzB,qCAAuB,CAAA;AACzB,CAAC,EAZW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAYrB;AAMD,IAAa,MAAM,GAAnB,MAAa,MAAM;CA4BlB,CAAA;AA1BC;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;kCACrB;AAGV;IADC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;kDAClB,cAAM,oBAAN,cAAM;sCAAA;AAad;IAXC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,KAAK;QACf,IAAI,EACF,aAAa,IAAI,UAAU,IAAI,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS;YACnF,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,aAAa,IAAI,QAAQ;gBAC3B,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU,CAAC,SAAS;KAC9B,CAAC;;oCACc;AAGhB;IADC,IAAA,gBAAM,GAAE;;oCACG;AAGZ;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;yCAAA;AA3BJ,MAAM;IAJlB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACzF,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;GAC5C,MAAM,CA4BlB;AA5BY,wBAAM"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sequence = exports.IdRuleType = exports.IdRule = exports.entities = void 0;
4
+ const id_rule_1 = require("./id-rule");
5
+ Object.defineProperty(exports, "IdRule", { enumerable: true, get: function () { return id_rule_1.IdRule; } });
6
+ Object.defineProperty(exports, "IdRuleType", { enumerable: true, get: function () { return id_rule_1.IdRuleType; } });
7
+ const sequence_1 = require("./sequence");
8
+ Object.defineProperty(exports, "Sequence", { enumerable: true, get: function () { return sequence_1.Sequence; } });
9
+ exports.entities = [id_rule_1.IdRule, sequence_1.Sequence];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAKrC,uFALA,gBAAM,OAKA;AAAE,2FALA,oBAAU,OAKA;AAJ3B,yCAAqC;AAIR,yFAJpB,mBAAQ,OAIoB;AAFxB,QAAA,QAAQ,GAAG,CAAC,gBAAM,EAAE,mBAAQ,CAAC,CAAA"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Sequence = void 0;
14
+ const typeorm_1 = require("typeorm");
15
+ const shell_1 = require("@things-factory/shell");
16
+ let Sequence = class Sequence {
17
+ };
18
+ __decorate([
19
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
20
+ __metadata("design:type", String)
21
+ ], Sequence.prototype, "id", void 0);
22
+ __decorate([
23
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
24
+ __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
25
+ ], Sequence.prototype, "domain", void 0);
26
+ __decorate([
27
+ (0, typeorm_1.Column)(),
28
+ __metadata("design:type", String)
29
+ ], Sequence.prototype, "pattern", void 0);
30
+ __decorate([
31
+ (0, typeorm_1.Column)({
32
+ type: 'smallint'
33
+ }),
34
+ __metadata("design:type", Number)
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);
40
+ __decorate([
41
+ (0, typeorm_1.Column)(),
42
+ __metadata("design:type", Date)
43
+ ], Sequence.prototype, "expiresAt", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.CreateDateColumn)(),
46
+ __metadata("design:type", Date)
47
+ ], Sequence.prototype, "createdAt", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.UpdateDateColumn)(),
50
+ __metadata("design:type", Date)
51
+ ], Sequence.prototype, "updatedAt", void 0);
52
+ Sequence = __decorate([
53
+ (0, typeorm_1.Entity)(),
54
+ (0, typeorm_1.Index)('ix_sequence_0', (seq) => [seq.domain, seq.pattern], { unique: true }),
55
+ (0, typeorm_1.Index)('ix_sequence_1', (seq) => [seq.pattern]),
56
+ (0, typeorm_1.Index)('ix_sequence_2', (seq) => [seq.expiresAt])
57
+ ], Sequence);
58
+ exports.Sequence = Sequence;
59
+ //# sourceMappingURL=sequence.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,30 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.schema = void 0;
23
+ const utils_1 = require("@things-factory/utils");
24
+ const resolvers = __importStar(require("./resolvers"));
25
+ const typeDefs = __importStar(require("./types"));
26
+ exports.schema = {
27
+ typeDefs,
28
+ resolvers: utils_1.deepMerge.apply(null, Object.values(resolvers))
29
+ };
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/graphql/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiD;AAEjD,uDAAwC;AACxC,kDAAmC;AAEtB,QAAA,MAAM,GAAG;IACpB,QAAQ;IACR,SAAS,EAAE,iBAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;CAC3D,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIdRule = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../entities");
6
+ exports.createIdRule = {
7
+ async createIdRule(_, { idRule }, context) {
8
+ return await (0, typeorm_1.getRepository)(entities_1.IdRule).save(Object.assign(Object.assign({}, idRule), { domain: context.state.domain, creator: context.state.user, updater: context.state.user }));
9
+ }
10
+ };
11
+ //# sourceMappingURL=create-id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-id-rule.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/create-id-rule.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,6CAAuC;AAE1B,QAAA,YAAY,GAAG;IAC1B,KAAK,CAAC,YAAY,CAAC,CAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAY;QACjD,OAAO,MAAM,IAAA,uBAAa,EAAC,iBAAM,CAAC,CAAC,IAAI,iCAClC,MAAM,KACT,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAC5B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAC3B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.idRuleResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../entities");
6
+ exports.idRuleResolver = {
7
+ async idRule(_, { type }, context) {
8
+ const rule = await (0, typeorm_1.getRepository)(entities_1.IdRule).findOne({
9
+ where: {
10
+ domain: context.state.domain,
11
+ type
12
+ }
13
+ });
14
+ return rule;
15
+ }
16
+ };
17
+ //# sourceMappingURL=id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/id-rule.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,6CAAuC;AAE1B,QAAA,cAAc,GAAG;IAC5B,KAAK,CAAC,MAAM,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAY;QACzC,MAAM,IAAI,GAAG,MAAM,IAAA,uBAAa,EAAC,iBAAM,CAAC,CAAC,OAAO,CAAC;YAC/C,KAAK,EAAE;gBACL,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;gBAC5B,IAAI;aACL;SACF,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdRuleResolver = void 0;
4
+ const create_id_rule_1 = require("./create-id-rule");
5
+ const id_rule_1 = require("./id-rule");
6
+ const update_id_rule_1 = require("./update-id-rule");
7
+ const update_insert_sequence_1 = require("./update-insert-sequence");
8
+ exports.IdRuleResolver = {
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.updateInsertSequence)
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,qEAA+D;AAElD,QAAA,cAAc,GAAG;IAC5B,KAAK,oBACA,wBAAc,CAClB;IACD,QAAQ,gDACH,6BAAY,GACZ,6BAAY,GACZ,6CAAoB,CACxB;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateIdRule = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../entities");
6
+ exports.updateIdRule = {
7
+ async updateIdRule(_, { type, patch }, context) {
8
+ const repository = (0, typeorm_1.getRepository)(entities_1.IdRule);
9
+ const idRule = await repository.findOne({
10
+ where: { type, domain: context.state.domain }
11
+ });
12
+ return await repository.save(Object.assign(Object.assign(Object.assign({}, idRule), patch), { updater: context.state.user }));
13
+ }
14
+ };
15
+ //# sourceMappingURL=update-id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-id-rule.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/update-id-rule.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,6CAAuC;AAE1B,QAAA,YAAY,GAAG;IAC1B,KAAK,CAAC,YAAY,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAY;QACtD,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,iBAAM,CAAC,CAAA;QACxC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACtC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE;SAC9C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,MAAM,GACN,KAAK,KACR,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateInsertSequence = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const constants_1 = require("../../constants");
6
+ const entities_1 = require("../../entities");
7
+ exports.updateInsertSequence = {
8
+ async updateInsertSequence(_, { type, counter, bizplaceId }, context) {
9
+ const domain = context.state.domain;
10
+ const seqRepo = (0, typeorm_1.getRepository)(entities_1.Sequence);
11
+ const now = new Date();
12
+ const expiresAt = new Date(now.setMonth(now.getMonth() + 12));
13
+ const patternObj = {
14
+ type,
15
+ date: new Date().toISOString().split('T')[0],
16
+ bizplaceId
17
+ };
18
+ const pattern = JSON.stringify(patternObj);
19
+ const foundSeq = await seqRepo.findOne({
20
+ where: { pattern, type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
21
+ });
22
+ if (foundSeq) {
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
+ });
29
+ }
30
+ else {
31
+ return await seqRepo.save({
32
+ domain,
33
+ pattern,
34
+ seq: counter || 1,
35
+ expiresAt,
36
+ type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER
37
+ });
38
+ }
39
+ }
40
+ };
41
+ //# sourceMappingURL=update-insert-sequence.js.map
@@ -0,0 +1 @@
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,oBAAoB,GAAG;IAClC,KAAK,CAAC,oBAAoB,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,OAAY;QAC5E,MAAM,MAAM,GAAW,OAAO,CAAC,KAAK,CAAC,MAAM,CAAA;QAC3C,MAAM,OAAO,GAAG,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAA;QACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAE7D,MAAM,UAAU,GAAQ;YACtB,IAAI;YACJ,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5C,UAAU;SACX,CAAA;QAED,MAAM,OAAO,GAAW,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAElD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC;YACrC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,yBAAa,CAAC,qBAAqB,EAAE,MAAM,EAAE;SACtE,CAAC,CAAA;QAEF,IAAI,QAAQ,EAAE;YACZ,OAAO,MAAM,OAAO,CAAC,MAAM,CACzB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EACnB;gBACE,OAAO;gBACP,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,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"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IdRulePatch = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.IdRulePatch = (0, graphql_tag_1.default) `
9
+ input IdRulePatch {
10
+ type: String
11
+ rule: String
12
+ }
13
+ `;
14
+ //# sourceMappingURL=id-rule-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule-patch.js","sourceRoot":"","sources":["../../../server/graphql/types/id-rule-patch.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,WAAW,GAAG,IAAA,qBAAG,EAAA;;;;;CAK7B,CAAA"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IdRule = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.IdRule = (0, graphql_tag_1.default) `
9
+ type IdRule {
10
+ id: String
11
+ type: String
12
+ rule: String
13
+ createdAt: String
14
+ updatedAt: String
15
+ }
16
+ `;
17
+ //# sourceMappingURL=id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule.js","sourceRoot":"","sources":["../../../server/graphql/types/id-rule.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,MAAM,GAAG,IAAA,qBAAG,EAAA;;;;;;;;CAQxB,CAAA"}
@@ -0,0 +1,34 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.IdRuleResolver = void 0;
17
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
18
+ __exportStar(require("./id-rule"), exports);
19
+ __exportStar(require("./id-rule-patch"), exports);
20
+ __exportStar(require("./new-id-rule"), exports);
21
+ __exportStar(require("./sequence"), exports);
22
+ exports.IdRuleResolver = (0, graphql_tag_1.default) `
23
+ extend type Mutation {
24
+ createIdRule(idRule: NewIdRule!): IdRule
25
+
26
+ updateIdRule(type: String!, patch: IdRulePatch): IdRule
27
+ updateInsertSequence(type: String!, counter: Int, bizplaceId: String!): Sequence
28
+ }
29
+
30
+ extend type Query {
31
+ idRule(type: String!): IdRule
32
+ }
33
+ `;
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/graphql/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA6B;AAE7B,4CAAyB;AACzB,kDAA+B;AAC/B,gDAA6B;AAC7B,6CAA0B;AAEb,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;CAWhC,CAAA"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NewIdRule = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.NewIdRule = (0, graphql_tag_1.default) `
9
+ input NewIdRule {
10
+ type: String
11
+ rule: String
12
+ }
13
+ `;
14
+ //# sourceMappingURL=new-id-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-id-rule.js","sourceRoot":"","sources":["../../../server/graphql/types/new-id-rule.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,SAAS,GAAG,IAAA,qBAAG,EAAA;;;;;CAK3B,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Sequence = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ exports.Sequence = (0, graphql_tag_1.default) `
9
+ type Sequence {
10
+ id: String
11
+ pattern: String
12
+ seq: String
13
+ expiresAt: String
14
+ createdAt: String
15
+ updatedAt: String
16
+ }
17
+ `;
18
+ //# sourceMappingURL=sequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../../server/graphql/types/sequence.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AAEhB,QAAA,QAAQ,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;CAS1B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/id-rule-base",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
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.1.1",
28
- "@things-factory/i18n-base": "^4.1.1",
29
- "@things-factory/setting-base": "^4.1.1",
30
- "@things-factory/shell": "^4.1.1",
27
+ "@things-factory/grist-ui": "^4.1.2",
28
+ "@things-factory/i18n-base": "^4.1.2",
29
+ "@things-factory/setting-base": "^4.1.2",
30
+ "@things-factory/shell": "^4.1.2",
31
31
  "codemirror": "^5.59.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/codemirror": "^0.0.105"
35
35
  },
36
- "gitHead": "09378a57e788038c086c6c40e6135cf14082b185"
36
+ "gitHead": "46164ac6b9b2a15c4ff6af5d83d0435f28fff80a"
37
37
  }