@things-factory/id-rule-base 4.0.0-y.0 → 4.0.5

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 (66) hide show
  1. package/dist-server/controllers/id-generator.js +4 -3
  2. package/dist-server/controllers/id-generator.js.map +1 -1
  3. package/dist-server/index.js +2 -3
  4. package/dist-server/index.js.map +1 -1
  5. package/dist-server/service/id-rule/id-rule-mutation.js +53 -0
  6. package/dist-server/service/id-rule/id-rule-mutation.js.map +1 -0
  7. package/dist-server/service/id-rule/id-rule-query.js +53 -0
  8. package/dist-server/service/id-rule/id-rule-query.js.map +1 -0
  9. package/dist-server/service/id-rule/id-rule-types.js +43 -0
  10. package/dist-server/service/id-rule/id-rule-types.js.map +1 -0
  11. package/dist-server/{entities → service/id-rule}/id-rule.js +14 -2
  12. package/dist-server/service/id-rule/id-rule.js.map +1 -0
  13. package/dist-server/service/id-rule/index.js +9 -0
  14. package/dist-server/service/id-rule/index.js.map +1 -0
  15. package/dist-server/service/index.js +23 -0
  16. package/dist-server/service/index.js.map +1 -0
  17. package/dist-server/service/sequence/index.js +8 -0
  18. package/dist-server/service/sequence/index.js.map +1 -0
  19. package/dist-server/service/sequence/sequence-mutation.js +65 -0
  20. package/dist-server/service/sequence/sequence-mutation.js.map +1 -0
  21. package/dist-server/{entities → service/sequence}/sequence.js +11 -2
  22. package/dist-server/service/sequence/sequence.js.map +1 -0
  23. package/package.json +6 -6
  24. package/server/controllers/id-generator.ts +3 -1
  25. package/server/index.ts +3 -4
  26. package/server/service/id-rule/id-rule-mutation.ts +33 -0
  27. package/server/service/id-rule/id-rule-query.ts +26 -0
  28. package/server/service/id-rule/id-rule-types.ts +21 -0
  29. package/server/{entities → service/id-rule}/id-rule.ts +24 -2
  30. package/server/service/id-rule/index.ts +6 -0
  31. package/server/service/index.ts +15 -0
  32. package/server/service/sequence/index.ts +5 -0
  33. package/server/service/sequence/sequence-mutation.ts +49 -0
  34. package/server/{entities → service/sequence}/sequence.ts +12 -2
  35. package/dist-server/entities/id-rule.js.map +0 -1
  36. package/dist-server/entities/index.js +0 -10
  37. package/dist-server/entities/index.js.map +0 -1
  38. package/dist-server/entities/sequence.js.map +0 -1
  39. package/dist-server/graphql/index.js +0 -30
  40. package/dist-server/graphql/index.js.map +0 -1
  41. package/dist-server/graphql/resolvers/create-id-rule.js +0 -11
  42. package/dist-server/graphql/resolvers/create-id-rule.js.map +0 -1
  43. package/dist-server/graphql/resolvers/id-rule.js +0 -17
  44. package/dist-server/graphql/resolvers/id-rule.js.map +0 -1
  45. package/dist-server/graphql/resolvers/index.js +0 -11
  46. package/dist-server/graphql/resolvers/index.js.map +0 -1
  47. package/dist-server/graphql/resolvers/update-id-rule.js +0 -15
  48. package/dist-server/graphql/resolvers/update-id-rule.js.map +0 -1
  49. package/dist-server/graphql/types/id-rule-patch.js +0 -14
  50. package/dist-server/graphql/types/id-rule-patch.js.map +0 -1
  51. package/dist-server/graphql/types/id-rule.js +0 -17
  52. package/dist-server/graphql/types/id-rule.js.map +0 -1
  53. package/dist-server/graphql/types/index.js +0 -32
  54. package/dist-server/graphql/types/index.js.map +0 -1
  55. package/dist-server/graphql/types/new-id-rule.js +0 -14
  56. package/dist-server/graphql/types/new-id-rule.js.map +0 -1
  57. package/server/entities/index.ts +0 -6
  58. package/server/graphql/index.ts +0 -9
  59. package/server/graphql/resolvers/create-id-rule.ts +0 -13
  60. package/server/graphql/resolvers/id-rule.ts +0 -15
  61. package/server/graphql/resolvers/index.ts +0 -13
  62. package/server/graphql/resolvers/update-id-rule.ts +0 -17
  63. package/server/graphql/types/id-rule-patch.ts +0 -8
  64. package/server/graphql/types/id-rule.ts +0 -11
  65. package/server/graphql/types/index.ts +0 -17
  66. package/server/graphql/types/new-id-rule.ts +0 -8
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateId = void 0;
4
4
  const typeorm_1 = require("typeorm");
5
- const entities_1 = require("../entities");
5
+ const id_rule_1 = require("../service/id-rule/id-rule");
6
+ const sequence_1 = require("../service/sequence/sequence");
6
7
  async function generateId({ domain, type, seed }) {
7
- const idRuleRepo = (0, typeorm_1.getRepository)(entities_1.IdRule);
8
+ const idRuleRepo = (0, typeorm_1.getRepository)(id_rule_1.IdRule);
8
9
  const rule = await idRuleRepo.findOne({
9
10
  where: {
10
11
  domain,
@@ -21,7 +22,7 @@ async function generateId({ domain, type, seed }) {
21
22
  }
22
23
  exports.generateId = generateId;
23
24
  async function getNext({ domain, pattern, expirationDate }) {
24
- const seqRepo = (0, typeorm_1.getRepository)(entities_1.Sequence);
25
+ const seqRepo = (0, typeorm_1.getRepository)(sequence_1.Sequence);
25
26
  const now = new Date();
26
27
  let last = await seqRepo.findOne({
27
28
  domain,
@@ -1 +1 @@
1
- {"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../server/controllers/id-generator.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,0CAA8C;AAQvC,KAAK,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IACrD,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,iBAAM,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QACpC,KAAK,EAAE;YACL,MAAM;YACN,IAAI;SACL;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,IAAI;QAAE,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAExC,IAAI,QAAQ,GAAG,IAAI,CAAC;MAChB,IAAI,CAAC,IAAI;IACX,CAAC,CAAA;IAEH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,oBAC/B,IAAI,EACP,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AApBD,gCAoBC;AAED,KAAK,UAAU,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAe;IACrE,MAAM,OAAO,GAAG,IAAA,uBA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@ 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
- __exportStar(require("./entities"), exports);
13
+ require("./routes");
14
+ __exportStar(require("./service"), exports);
14
15
  __exportStar(require("./migrations"), exports);
15
- __exportStar(require("./graphql"), exports);
16
16
  __exportStar(require("./controllers"), exports);
17
- require("./routes");
18
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,+CAA4B;AAC5B,4CAAyB;AACzB,gDAA6B;AAE7B,oBAAiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oBAAiB;AAEjB,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B"}
@@ -0,0 +1,53 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.IdRuleMutation = void 0;
16
+ const type_graphql_1 = require("type-graphql");
17
+ const typeorm_1 = require("typeorm");
18
+ const id_rule_1 = require("./id-rule");
19
+ const id_rule_types_1 = require("./id-rule-types");
20
+ let IdRuleMutation = class IdRuleMutation {
21
+ async createIdRule(idRule, context) {
22
+ return await (0, typeorm_1.getRepository)(id_rule_1.IdRule).save(Object.assign(Object.assign({}, idRule), { domain: context.state.domain }));
23
+ }
24
+ async updateIdRule(type, patch, context) {
25
+ const repository = (0, typeorm_1.getRepository)(id_rule_1.IdRule);
26
+ const idRule = await repository.findOne({
27
+ where: { type, domain: context.state.domain }
28
+ });
29
+ return await repository.save(Object.assign(Object.assign({}, idRule), patch));
30
+ }
31
+ };
32
+ __decorate([
33
+ (0, type_graphql_1.Mutation)(returns => id_rule_1.IdRule),
34
+ __param(0, (0, type_graphql_1.Arg)('idRule')),
35
+ __param(1, (0, type_graphql_1.Ctx)()),
36
+ __metadata("design:type", Function),
37
+ __metadata("design:paramtypes", [id_rule_types_1.NewIdRule, Object]),
38
+ __metadata("design:returntype", Promise)
39
+ ], IdRuleMutation.prototype, "createIdRule", null);
40
+ __decorate([
41
+ (0, type_graphql_1.Mutation)(returns => id_rule_1.IdRule),
42
+ __param(0, (0, type_graphql_1.Arg)('type')),
43
+ __param(1, (0, type_graphql_1.Arg)('patch')),
44
+ __param(2, (0, type_graphql_1.Ctx)()),
45
+ __metadata("design:type", Function),
46
+ __metadata("design:paramtypes", [String, id_rule_types_1.IdRulePatch, Object]),
47
+ __metadata("design:returntype", Promise)
48
+ ], IdRuleMutation.prototype, "updateIdRule", null);
49
+ IdRuleMutation = __decorate([
50
+ (0, type_graphql_1.Resolver)(id_rule_1.IdRule)
51
+ ], IdRuleMutation);
52
+ exports.IdRuleMutation = IdRuleMutation;
53
+ //# sourceMappingURL=id-rule-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule-mutation.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-mutation.ts"],"names":[],"mappings":";;;;;;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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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.IdRuleQuery = void 0;
16
+ const type_graphql_1 = require("type-graphql");
17
+ const typeorm_1 = require("typeorm");
18
+ const shell_1 = require("@things-factory/shell");
19
+ const id_rule_1 = require("./id-rule");
20
+ let IdRuleQuery = class IdRuleQuery {
21
+ async idRule(type, context) {
22
+ const rule = await (0, typeorm_1.getRepository)(id_rule_1.IdRule).findOne({
23
+ where: {
24
+ domain: context.state.domain,
25
+ type
26
+ }
27
+ });
28
+ return rule;
29
+ }
30
+ async domain(idRule) {
31
+ return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(idRule.domainId);
32
+ }
33
+ };
34
+ __decorate([
35
+ (0, type_graphql_1.Query)(returns => id_rule_1.IdRule),
36
+ __param(0, (0, type_graphql_1.Arg)('type')),
37
+ __param(1, (0, type_graphql_1.Ctx)()),
38
+ __metadata("design:type", Function),
39
+ __metadata("design:paramtypes", [String, Object]),
40
+ __metadata("design:returntype", Promise)
41
+ ], IdRuleQuery.prototype, "idRule", null);
42
+ __decorate([
43
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
44
+ __param(0, (0, type_graphql_1.Root)()),
45
+ __metadata("design:type", Function),
46
+ __metadata("design:paramtypes", [id_rule_1.IdRule]),
47
+ __metadata("design:returntype", Promise)
48
+ ], IdRuleQuery.prototype, "domain", null);
49
+ IdRuleQuery = __decorate([
50
+ (0, type_graphql_1.Resolver)(id_rule_1.IdRule)
51
+ ], IdRuleQuery);
52
+ exports.IdRuleQuery = IdRuleQuery;
53
+ //# sourceMappingURL=id-rule-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule-query.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA6E;AAC7E,qCAAuC;AAEvC,iDAA8C;AAE9C,uCAAkC;AAGlC,IAAa,WAAW,GAAxB,MAAa,WAAW;IAEtB,KAAK,CAAC,MAAM,CAAc,IAAY,EAAS,OAAY;QACzD,MAAM,IAAI,GAAG,MAAM,IAAA,uBAAa,EAAC,gBAAM,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;IAGD,KAAK,CAAC,MAAM,CAAS,MAAc;QACjC,OAAO,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7D,CAAC;CACF,CAAA;AAfC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAM,CAAC;IACX,WAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;yCAS7C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAS,gBAAM;;yCAElC;AAhBU,WAAW;IADvB,IAAA,uBAAQ,EAAC,gBAAM,CAAC;GACJ,WAAW,CAiBvB;AAjBY,kCAAW"}
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NewIdRule = exports.IdRulePatch = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ const id_rule_1 = require("./id-rule");
15
+ let IdRulePatch = class IdRulePatch {
16
+ };
17
+ __decorate([
18
+ (0, type_graphql_1.Field)({ nullable: true }),
19
+ __metadata("design:type", String)
20
+ ], IdRulePatch.prototype, "type", void 0);
21
+ __decorate([
22
+ (0, type_graphql_1.Field)({ nullable: true }),
23
+ __metadata("design:type", String)
24
+ ], IdRulePatch.prototype, "rule", void 0);
25
+ IdRulePatch = __decorate([
26
+ (0, type_graphql_1.InputType)()
27
+ ], IdRulePatch);
28
+ exports.IdRulePatch = IdRulePatch;
29
+ let NewIdRule = class NewIdRule {
30
+ };
31
+ __decorate([
32
+ (0, type_graphql_1.Field)(),
33
+ __metadata("design:type", String)
34
+ ], NewIdRule.prototype, "type", void 0);
35
+ __decorate([
36
+ (0, type_graphql_1.Field)(),
37
+ __metadata("design:type", String)
38
+ ], NewIdRule.prototype, "rule", void 0);
39
+ NewIdRule = __decorate([
40
+ (0, type_graphql_1.InputType)()
41
+ ], NewIdRule);
42
+ exports.NewIdRule = NewIdRule;
43
+ //# sourceMappingURL=id-rule-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-rule-types.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+C;AAE/C,uCAAsC;AAGtC,IAAa,WAAW,GAAxB,MAAa,WAAW;CAMvB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACb;AALF,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAMvB;AANY,kCAAW;AASxB,IAAa,SAAS,GAAtB,MAAa,SAAS;CAMrB,CAAA;AAJC;IADC,IAAA,oBAAK,GAAE;;uCACQ;AAGhB;IADC,IAAA,oBAAK,GAAE;;uCACI;AALD,SAAS;IADrB,IAAA,wBAAS,GAAE;GACC,SAAS,CAMrB;AANY,8BAAS"}
@@ -11,9 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var _a;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.IdRule = exports.IdRuleType = void 0;
14
+ const type_graphql_1 = require("type-graphql");
15
+ const typeorm_1 = require("typeorm");
14
16
  const env_1 = require("@things-factory/env");
15
17
  const shell_1 = require("@things-factory/shell");
16
- const typeorm_1 = require("typeorm");
17
18
  const ORMCONFIG = env_1.config.get('ormconfig', {});
18
19
  const DATABASE_TYPE = ORMCONFIG.type;
19
20
  var IdRuleType;
@@ -34,12 +35,18 @@ let IdRule = class IdRule {
34
35
  };
35
36
  __decorate([
36
37
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
38
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
37
39
  __metadata("design:type", String)
38
40
  ], IdRule.prototype, "id", void 0);
39
41
  __decorate([
40
42
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
43
+ (0, type_graphql_1.Field)(type => shell_1.Domain),
41
44
  __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
42
45
  ], IdRule.prototype, "domain", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.RelationId)((idRule) => idRule.domain),
48
+ __metadata("design:type", String)
49
+ ], IdRule.prototype, "domainId", void 0);
43
50
  __decorate([
44
51
  (0, typeorm_1.Column)({
45
52
  nullable: false,
@@ -51,25 +58,30 @@ __decorate([
51
58
  enum: IdRuleType,
52
59
  default: IdRuleType.PALLET_ID
53
60
  }),
61
+ (0, type_graphql_1.Field)(),
54
62
  __metadata("design:type", String)
55
63
  ], IdRule.prototype, "type", void 0);
56
64
  __decorate([
57
65
  (0, typeorm_1.Column)(),
66
+ (0, type_graphql_1.Field)(),
58
67
  __metadata("design:type", String)
59
68
  ], IdRule.prototype, "rule", void 0);
60
69
  __decorate([
61
70
  (0, typeorm_1.CreateDateColumn)(),
71
+ (0, type_graphql_1.Field)({ nullable: true }),
62
72
  __metadata("design:type", Date)
63
73
  ], IdRule.prototype, "createdAt", void 0);
64
74
  __decorate([
65
75
  (0, typeorm_1.UpdateDateColumn)(),
76
+ (0, type_graphql_1.Field)({ nullable: true }),
66
77
  __metadata("design:type", Date)
67
78
  ], IdRule.prototype, "updatedAt", void 0);
68
79
  IdRule = __decorate([
69
80
  (0, typeorm_1.Entity)(),
70
81
  (0, typeorm_1.Index)('ix_id_rule_0', (idRule) => [idRule.domain, idRule.type], { unique: true }),
71
82
  (0, typeorm_1.Index)('ix_id_rule_1', (idRule) => [idRule.domain]),
72
- (0, typeorm_1.Index)('ix_id_rule_2', (idRule) => [idRule.type])
83
+ (0, typeorm_1.Index)('ix_id_rule_2', (idRule) => [idRule.type]),
84
+ (0, type_graphql_1.ObjectType)()
73
85
  ], IdRule);
74
86
  exports.IdRule = IdRule;
75
87
  //# sourceMappingURL=id-rule.js.map
@@ -0,0 +1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AC3B,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU,CAAC,SAAS;KAC9B,CAAC;IACD,IAAA,oBAAK,GAAE;;oCACQ;AAIhB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;oCACI;AAIZ;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;yCAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACf,IAAI;yCAAA;AApCJ,MAAM;IALlB,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;IACxD,IAAA,yBAAU,GAAE;GACA,MAAM,CAqClB;AArCY,wBAAM"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.entities = void 0;
4
+ const id_rule_1 = require("./id-rule");
5
+ const id_rule_mutation_1 = require("./id-rule-mutation");
6
+ const id_rule_query_1 = require("./id-rule-query");
7
+ exports.entities = [id_rule_1.IdRule];
8
+ exports.resolvers = [id_rule_query_1.IdRuleQuery, id_rule_mutation_1.IdRuleMutation];
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/id-rule/index.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,yDAAmD;AACnD,mDAA6C;AAEhC,QAAA,QAAQ,GAAG,CAAC,gBAAM,CAAC,CAAA;AACnB,QAAA,SAAS,GAAG,CAAC,2BAAW,EAAE,iCAAc,CAAC,CAAA"}
@@ -0,0 +1,23 @@
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
+ exports.schema = exports.entities = void 0;
14
+ const id_rule_1 = require("./id-rule");
15
+ const sequence_1 = require("./sequence");
16
+ /* EXPORT ENTITY TYPES */
17
+ __exportStar(require("./id-rule/id-rule"), exports);
18
+ /* EXPORT TYPES */
19
+ __exportStar(require("./id-rule/id-rule-types"), exports);
20
+ __exportStar(require("./sequence/sequence"), exports);
21
+ exports.entities = [...id_rule_1.entities, ...sequence_1.entities];
22
+ exports.schema = Object.assign(Object.assign({}, id_rule_1.resolvers), sequence_1.resolvers);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAAoF;AACpF,yCAAyF;AAEzF,yBAAyB;AACzB,oDAAiC;AACjC,kBAAkB;AAClB,0DAAuC;AACvC,sDAAmC;AAEtB,QAAA,QAAQ,GAAG,CAAC,GAAG,kBAAc,EAAE,GAAG,mBAAgB,CAAC,CAAA;AAEnD,QAAA,MAAM,mCACd,mBAAe,GACf,oBAAiB,EACrB"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.entities = void 0;
4
+ const sequence_1 = require("./sequence");
5
+ const sequence_mutation_1 = require("./sequence-mutation");
6
+ exports.entities = [sequence_1.Sequence];
7
+ exports.resolvers = [sequence_mutation_1.SequenceMutation];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/sequence/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,2DAAsD;AAEzC,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,oCAAgB,CAAC,CAAA"}
@@ -0,0 +1,65 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SequenceMutation = void 0;
16
+ const type_graphql_1 = require("type-graphql");
17
+ const typeorm_1 = require("typeorm");
18
+ const sequence_1 = require("./sequence");
19
+ let SequenceMutation = class SequenceMutation {
20
+ async upsertSequence(pattern, counter, context) {
21
+ const { domain } = context.state;
22
+ const seqRepo = (0, typeorm_1.getRepository)(sequence_1.Sequence);
23
+ const now = new Date();
24
+ const expiresAt = new Date(now.setMonth(now.getMonth() + 12));
25
+ pattern = `${pattern} [${getDateStr()}]`;
26
+ const foundSeq = await seqRepo.findOne({
27
+ where: { pattern, domain }
28
+ });
29
+ if (foundSeq) {
30
+ return await seqRepo.save(Object.assign(Object.assign({}, foundSeq), { seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1, expiresAt }));
31
+ }
32
+ else {
33
+ return await seqRepo.save({
34
+ domain,
35
+ pattern,
36
+ seq: counter || 1,
37
+ expiresAt
38
+ });
39
+ }
40
+ }
41
+ };
42
+ __decorate([
43
+ (0, type_graphql_1.Mutation)(returns => sequence_1.Sequence),
44
+ __param(0, (0, type_graphql_1.Arg)('pattern')),
45
+ __param(1, (0, type_graphql_1.Arg)('counter')),
46
+ __param(2, (0, type_graphql_1.Ctx)()),
47
+ __metadata("design:type", Function),
48
+ __metadata("design:paramtypes", [String, Number, Object]),
49
+ __metadata("design:returntype", Promise)
50
+ ], SequenceMutation.prototype, "upsertSequence", null);
51
+ SequenceMutation = __decorate([
52
+ (0, type_graphql_1.Resolver)(sequence_1.Sequence)
53
+ ], SequenceMutation);
54
+ 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
+ //# sourceMappingURL=sequence-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence-mutation.js","sourceRoot":"","sources":["../../../server/service/sequence/sequence-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,qCAAuC;AAEvC,yCAAqC;AAG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AAC,mBAAQ,CAAC;GACN,gBAAgB,CA6B5B;AA7BY,4CAAgB;AA+B7B,SAAS,UAAU;IACjB,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAA;IACxB,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;IAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,EAAE,CAAA;IAE3B,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACvD,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC7C,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAEvC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;AACrB,CAAC"}
@@ -11,45 +11,54 @@ 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");
14
+ const type_graphql_1 = require("type-graphql");
15
15
  const typeorm_1 = require("typeorm");
16
+ const shell_1 = require("@things-factory/shell");
16
17
  let Sequence = class Sequence {
17
18
  };
18
19
  __decorate([
19
20
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
21
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
20
22
  __metadata("design:type", String)
21
23
  ], Sequence.prototype, "id", void 0);
22
24
  __decorate([
23
25
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
26
+ (0, type_graphql_1.Field)(type => shell_1.Domain),
24
27
  __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
25
28
  ], Sequence.prototype, "domain", void 0);
26
29
  __decorate([
27
30
  (0, typeorm_1.Column)(),
31
+ (0, type_graphql_1.Field)(),
28
32
  __metadata("design:type", String)
29
33
  ], Sequence.prototype, "pattern", void 0);
30
34
  __decorate([
31
35
  (0, typeorm_1.Column)({
32
36
  type: 'smallint'
33
37
  }),
38
+ (0, type_graphql_1.Field)(),
34
39
  __metadata("design:type", Number)
35
40
  ], Sequence.prototype, "seq", void 0);
36
41
  __decorate([
37
42
  (0, typeorm_1.Column)(),
43
+ (0, type_graphql_1.Field)(),
38
44
  __metadata("design:type", Date)
39
45
  ], Sequence.prototype, "expiresAt", void 0);
40
46
  __decorate([
41
47
  (0, typeorm_1.CreateDateColumn)(),
48
+ (0, type_graphql_1.Field)({ nullable: true }),
42
49
  __metadata("design:type", Date)
43
50
  ], Sequence.prototype, "createdAt", void 0);
44
51
  __decorate([
45
52
  (0, typeorm_1.UpdateDateColumn)(),
53
+ (0, type_graphql_1.Field)({ nullable: true }),
46
54
  __metadata("design:type", Date)
47
55
  ], Sequence.prototype, "updatedAt", void 0);
48
56
  Sequence = __decorate([
49
57
  (0, typeorm_1.Entity)(),
50
58
  (0, typeorm_1.Index)('ix_sequence_0', (seq) => [seq.domain, seq.pattern], { unique: true }),
51
59
  (0, typeorm_1.Index)('ix_sequence_1', (seq) => [seq.pattern]),
52
- (0, typeorm_1.Index)('ix_sequence_2', (seq) => [seq.expiresAt])
60
+ (0, typeorm_1.Index)('ix_sequence_2', (seq) => [seq.expiresAt]),
61
+ (0, type_graphql_1.ObjectType)()
53
62
  ], Sequence);
54
63
  exports.Sequence = Sequence;
55
64
  //# sourceMappingURL=sequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../../server/service/sequence/sequence.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCAAsH;AAEtH,iDAA8C;AAO9C,IAAa,QAA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A9BY,4BAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/id-rule-base",
3
- "version": "4.0.0-y.0",
3
+ "version": "4.0.5",
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.0-y.0",
28
- "@things-factory/i18n-base": "^4.0.0-y.0",
29
- "@things-factory/setting-base": "^4.0.0-y.0",
30
- "@things-factory/shell": "^4.0.0-y.0",
27
+ "@things-factory/grist-ui": "^4.0.5",
28
+ "@things-factory/i18n-base": "^4.0.5",
29
+ "@things-factory/setting-base": "^4.0.5",
30
+ "@things-factory/shell": "^4.0.5",
31
31
  "codemirror": "^5.59.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/codemirror": "^0.0.105"
35
35
  },
36
- "gitHead": "64ee0f6547f90b1386024b975efc3b31a5e381cb"
36
+ "gitHead": "b7b2976818dceab74a34903499d408eed5d45b04"
37
37
  }
@@ -1,5 +1,7 @@
1
1
  import { getRepository, MoreThan } from 'typeorm'
2
- import { IdRule, Sequence } from '../entities'
2
+
3
+ import { IdRule } from '../service/id-rule/id-rule'
4
+ import { Sequence } from '../service/sequence/sequence'
3
5
 
4
6
  type getNextArgs = {
5
7
  domain: string
package/server/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- export * from './entities'
1
+ import './routes'
2
+
3
+ export * from './service'
2
4
  export * from './migrations'
3
- export * from './graphql'
4
5
  export * from './controllers'
5
-
6
- import './routes'
@@ -0,0 +1,33 @@
1
+ import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
2
+ import { getRepository } from 'typeorm'
3
+
4
+ import { IdRule } from './id-rule'
5
+ import { IdRulePatch, NewIdRule } from './id-rule-types'
6
+
7
+ @Resolver(IdRule)
8
+ export class IdRuleMutation {
9
+ @Mutation(returns => IdRule)
10
+ async createIdRule(@Arg('idRule') idRule: NewIdRule, @Ctx() context: any) {
11
+ return await getRepository(IdRule).save({
12
+ ...idRule,
13
+ domain: context.state.domain
14
+ })
15
+ }
16
+
17
+ @Mutation(returns => IdRule)
18
+ async updateIdRule(
19
+ @Arg('type') type: string,
20
+ @Arg('patch') patch: IdRulePatch,
21
+ @Ctx() context: any
22
+ ): Promise<IdRule> {
23
+ const repository = getRepository(IdRule)
24
+ const idRule = await repository.findOne({
25
+ where: { type, domain: context.state.domain }
26
+ })
27
+
28
+ return await repository.save({
29
+ ...idRule,
30
+ ...patch
31
+ })
32
+ }
33
+ }
@@ -0,0 +1,26 @@
1
+ import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
+ import { getRepository } from 'typeorm'
3
+
4
+ import { Domain } from '@things-factory/shell'
5
+
6
+ import { IdRule } from './id-rule'
7
+
8
+ @Resolver(IdRule)
9
+ export class IdRuleQuery {
10
+ @Query(returns => IdRule)
11
+ async idRule(@Arg('type') type: string, @Ctx() context: any): Promise<IdRule> {
12
+ const rule = await getRepository(IdRule).findOne({
13
+ where: {
14
+ domain: context.state.domain,
15
+ type
16
+ }
17
+ })
18
+
19
+ return rule
20
+ }
21
+
22
+ @FieldResolver(type => Domain)
23
+ async domain(@Root() idRule: IdRule) {
24
+ return await getRepository(Domain).findOne(idRule.domainId)
25
+ }
26
+ }
@@ -0,0 +1,21 @@
1
+ import { Field, InputType } from 'type-graphql'
2
+
3
+ import { IdRuleType } from './id-rule'
4
+
5
+ @InputType()
6
+ export class IdRulePatch {
7
+ @Field({ nullable: true })
8
+ type?: IdRuleType
9
+
10
+ @Field({ nullable: true })
11
+ rule?: string
12
+ }
13
+
14
+ @InputType()
15
+ export class NewIdRule {
16
+ @Field()
17
+ type: IdRuleType
18
+
19
+ @Field()
20
+ rule: string
21
+ }
@@ -1,6 +1,18 @@
1
+ import { Field, ID, ObjectType } from 'type-graphql'
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ Entity,
6
+ Index,
7
+ ManyToOne,
8
+ PrimaryGeneratedColumn,
9
+ RelationId,
10
+ UpdateDateColumn
11
+ } from 'typeorm'
12
+
1
13
  import { config } from '@things-factory/env'
2
14
  import { Domain } from '@things-factory/shell'
3
- import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
15
+
4
16
  const ORMCONFIG = config.get('ormconfig', {})
5
17
  const DATABASE_TYPE = ORMCONFIG.type
6
18
 
@@ -22,13 +34,19 @@ export enum IdRuleType {
22
34
  @Index('ix_id_rule_0', (idRule: IdRule) => [idRule.domain, idRule.type], { unique: true })
23
35
  @Index('ix_id_rule_1', (idRule: IdRule) => [idRule.domain])
24
36
  @Index('ix_id_rule_2', (idRule: IdRule) => [idRule.type])
37
+ @ObjectType()
25
38
  export class IdRule {
26
39
  @PrimaryGeneratedColumn('uuid')
27
- id: string
40
+ @Field(type => ID)
41
+ readonly id: string
28
42
 
29
43
  @ManyToOne(type => Domain)
44
+ @Field(type => Domain)
30
45
  domain: Domain
31
46
 
47
+ @RelationId((idRule: IdRule) => idRule.domain)
48
+ domainId: string
49
+
32
50
  @Column({
33
51
  nullable: false,
34
52
  type:
@@ -40,14 +58,18 @@ export class IdRule {
40
58
  enum: IdRuleType,
41
59
  default: IdRuleType.PALLET_ID
42
60
  })
61
+ @Field()
43
62
  type: IdRuleType
44
63
 
45
64
  @Column()
65
+ @Field()
46
66
  rule: string
47
67
 
48
68
  @CreateDateColumn()
69
+ @Field({ nullable: true })
49
70
  createdAt: Date
50
71
 
51
72
  @UpdateDateColumn()
73
+ @Field({ nullable: true })
52
74
  updatedAt: Date
53
75
  }
@@ -0,0 +1,6 @@
1
+ import { IdRule } from './id-rule'
2
+ import { IdRuleMutation } from './id-rule-mutation'
3
+ import { IdRuleQuery } from './id-rule-query'
4
+
5
+ export const entities = [IdRule]
6
+ export const resolvers = [IdRuleQuery, IdRuleMutation]
@@ -0,0 +1,15 @@
1
+ import { entities as IdRuleEntities, resolvers as IdRuleResolvers } from './id-rule'
2
+ import { entities as SequenceEntities, resolvers as SequenceResolvers } from './sequence'
3
+
4
+ /* EXPORT ENTITY TYPES */
5
+ export * from './id-rule/id-rule'
6
+ /* EXPORT TYPES */
7
+ export * from './id-rule/id-rule-types'
8
+ export * from './sequence/sequence'
9
+
10
+ export const entities = [...IdRuleEntities, ...SequenceEntities]
11
+
12
+ export const schema = {
13
+ ...IdRuleResolvers,
14
+ ...SequenceResolvers
15
+ }
@@ -0,0 +1,5 @@
1
+ import { Sequence } from './sequence'
2
+ import { SequenceMutation } from './sequence-mutation'
3
+
4
+ export const entities = [Sequence]
5
+ export const resolvers = [SequenceMutation]
@@ -0,0 +1,49 @@
1
+ import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
2
+ import { getRepository } from 'typeorm'
3
+
4
+ import { Sequence } from './sequence'
5
+
6
+ @Resolver(Sequence)
7
+ export class SequenceMutation {
8
+ @Mutation(returns => Sequence)
9
+ async upsertSequence(@Arg('pattern') pattern: string, @Arg('counter') counter: number, @Ctx() context: any) {
10
+ const { domain } = context.state
11
+ const seqRepo = getRepository(Sequence)
12
+ const now = new Date()
13
+ const expiresAt = new Date(now.setMonth(now.getMonth() + 12))
14
+
15
+ pattern = `${pattern} [${getDateStr()}]`
16
+
17
+ const foundSeq = await seqRepo.findOne({
18
+ where: { pattern, domain }
19
+ })
20
+
21
+ if (foundSeq) {
22
+ return await seqRepo.save({
23
+ ...foundSeq,
24
+ seq: counter ? foundSeq.seq + counter : foundSeq.seq + 1,
25
+ expiresAt
26
+ })
27
+ } else {
28
+ return await seqRepo.save({
29
+ domain,
30
+ pattern,
31
+ seq: counter || 1,
32
+ expiresAt
33
+ })
34
+ }
35
+ }
36
+ }
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
+ }
@@ -1,31 +1,41 @@
1
- import { Domain } from '@things-factory/shell'
1
+ import { Field, ID, ObjectType } from 'type-graphql'
2
2
  import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
3
3
 
4
+ import { Domain } from '@things-factory/shell'
5
+
4
6
  @Entity()
5
7
  @Index('ix_sequence_0', (seq: Sequence) => [seq.domain, seq.pattern], { unique: true })
6
8
  @Index('ix_sequence_1', (seq: Sequence) => [seq.pattern])
7
9
  @Index('ix_sequence_2', (seq: Sequence) => [seq.expiresAt])
10
+ @ObjectType()
8
11
  export class Sequence {
9
12
  @PrimaryGeneratedColumn('uuid')
10
- id: string
13
+ @Field(type => ID)
14
+ readonly id: string
11
15
 
12
16
  @ManyToOne(type => Domain)
17
+ @Field(type => Domain)
13
18
  domain: Domain
14
19
 
15
20
  @Column()
21
+ @Field()
16
22
  pattern: string
17
23
 
18
24
  @Column({
19
25
  type: 'smallint'
20
26
  })
27
+ @Field()
21
28
  seq: number
22
29
 
23
30
  @Column()
31
+ @Field()
24
32
  expiresAt: Date
25
33
 
26
34
  @CreateDateColumn()
35
+ @Field({ nullable: true })
27
36
  createdAt: Date
28
37
 
29
38
  @UpdateDateColumn()
39
+ @Field({ nullable: true })
30
40
  updatedAt: Date
31
41
  }
@@ -1 +0,0 @@
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;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C,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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../../server/entities/sequence.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAA8C;AAC9C,qCAAsH;AAMtH,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAuBpB,CAAA;AArBC;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;AAGX;IADC,IAAA,gBAAM,GAAE;8BACE,IAAI;2CAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;2CAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;2CAAA;AAtBJ,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,CAuBpB;AAvBY,4BAAQ"}
@@ -1,30 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,17 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdRuleResolver = void 0;
4
- const id_rule_1 = require("./id-rule");
5
- const create_id_rule_1 = require("./create-id-rule");
6
- const update_id_rule_1 = require("./update-id-rule");
7
- exports.IdRuleResolver = {
8
- Query: Object.assign({}, id_rule_1.idRuleResolver),
9
- Mutation: Object.assign(Object.assign({}, create_id_rule_1.createIdRule), update_id_rule_1.updateIdRule)
10
- };
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/graphql/resolvers/index.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,qDAA+C;AAC/C,qDAA+C;AAElC,QAAA,cAAc,GAAG;IAC5B,KAAK,oBACA,wBAAc,CAClB;IACD,QAAQ,kCACH,6BAAY,GACZ,6BAAY,CAChB;CACF,CAAA"}
@@ -1,15 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,17 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,32 +0,0 @@
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
- exports.IdRuleResolver = (0, graphql_tag_1.default) `
22
- extend type Mutation {
23
- createIdRule(idRule: NewIdRule!): IdRule
24
-
25
- updateIdRule(type: String!, patch: IdRulePatch): IdRule
26
- }
27
-
28
- extend type Query {
29
- idRule(type: String!): IdRule
30
- }
31
- `;
32
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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;AAEhB,QAAA,cAAc,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;CAUhC,CAAA"}
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- import { IdRule, IdRuleType } from './id-rule'
2
- import { Sequence } from './sequence'
3
-
4
- export const entities = [IdRule, Sequence]
5
-
6
- export { IdRule, IdRuleType, Sequence }
@@ -1,9 +0,0 @@
1
- import { deepMerge } from '@things-factory/utils'
2
-
3
- import * as resolvers from './resolvers'
4
- import * as typeDefs from './types'
5
-
6
- export const schema = {
7
- typeDefs,
8
- resolvers: deepMerge.apply(null, Object.values(resolvers))
9
- }
@@ -1,13 +0,0 @@
1
- import { getRepository } from 'typeorm'
2
- import { IdRule } from '../../entities'
3
-
4
- export const createIdRule = {
5
- async createIdRule(_: any, { idRule }, context: any) {
6
- return await getRepository(IdRule).save({
7
- ...idRule,
8
- domain: context.state.domain,
9
- creator: context.state.user,
10
- updater: context.state.user
11
- })
12
- }
13
- }
@@ -1,15 +0,0 @@
1
- import { getRepository } from 'typeorm'
2
- import { IdRule } from '../../entities'
3
-
4
- export const idRuleResolver = {
5
- async idRule(_: any, { type }, context: any) {
6
- const rule = await getRepository(IdRule).findOne({
7
- where: {
8
- domain: context.state.domain,
9
- type
10
- }
11
- })
12
-
13
- return rule
14
- }
15
- }
@@ -1,13 +0,0 @@
1
- import { idRuleResolver } from './id-rule'
2
- import { createIdRule } from './create-id-rule'
3
- import { updateIdRule } from './update-id-rule'
4
-
5
- export const IdRuleResolver = {
6
- Query: {
7
- ...idRuleResolver
8
- },
9
- Mutation: {
10
- ...createIdRule,
11
- ...updateIdRule
12
- }
13
- }
@@ -1,17 +0,0 @@
1
- import { getRepository } from 'typeorm'
2
- import { IdRule } from '../../entities'
3
-
4
- export const updateIdRule = {
5
- async updateIdRule(_: any, { type, patch }, context: any) {
6
- const repository = getRepository(IdRule)
7
- const idRule = await repository.findOne({
8
- where: { type, domain: context.state.domain }
9
- })
10
-
11
- return await repository.save({
12
- ...idRule,
13
- ...patch,
14
- updater: context.state.user
15
- })
16
- }
17
- }
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const IdRulePatch = gql`
4
- input IdRulePatch {
5
- type: String
6
- rule: String
7
- }
8
- `
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const IdRule = gql`
4
- type IdRule {
5
- id: String
6
- type: String
7
- rule: String
8
- createdAt: String
9
- updatedAt: String
10
- }
11
- `
@@ -1,17 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export * from './id-rule'
4
- export * from './id-rule-patch'
5
- export * from './new-id-rule'
6
-
7
- export const IdRuleResolver = gql`
8
- extend type Mutation {
9
- createIdRule(idRule: NewIdRule!): IdRule
10
-
11
- updateIdRule(type: String!, patch: IdRulePatch): IdRule
12
- }
13
-
14
- extend type Query {
15
- idRule(type: String!): IdRule
16
- }
17
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const NewIdRule = gql`
4
- input NewIdRule {
5
- type: String
6
- rule: String
7
- }
8
- `