@things-factory/id-rule-base 5.0.7 → 6.0.0-alpha.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 +2 -15
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/constants/sequence-type.js.map +1 -1
- package/dist-server/controllers/id-generator.js +6 -5
- package/dist-server/controllers/id-generator.js.map +1 -1
- package/dist-server/controllers/index.js +2 -15
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/index.js +5 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/id-rule/id-rule-mutation.js +19 -30
- package/dist-server/service/id-rule/id-rule-mutation.js.map +1 -1
- package/dist-server/service/id-rule/id-rule-query.js +17 -29
- package/dist-server/service/id-rule/id-rule-query.js.map +1 -1
- package/dist-server/service/id-rule/id-rule-types.js +11 -19
- package/dist-server/service/id-rule/id-rule-types.js.map +1 -1
- package/dist-server/service/id-rule/id-rule.js +17 -25
- package/dist-server/service/id-rule/id-rule.js.map +1 -1
- package/dist-server/service/id-rule/index.js.map +1 -1
- package/dist-server/service/index.js +4 -17
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/sequence/index.js.map +1 -1
- package/dist-server/service/sequence/sequence-mutation.js +14 -25
- package/dist-server/service/sequence/sequence-mutation.js.map +1 -1
- package/dist-server/service/sequence/sequence.js +22 -27
- package/dist-server/service/sequence/sequence.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -6
- package/server/controllers/id-generator.ts +7 -5
- package/server/service/id-rule/id-rule-mutation.ts +3 -2
- package/server/service/id-rule/id-rule-query.ts +4 -5
- package/server/service/id-rule/id-rule.ts +3 -2
- package/server/service/sequence/sequence-mutation.ts +4 -3
- package/server/service/sequence/sequence.ts +13 -1
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./sequence-type"), exports);
|
|
18
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;AAAA,0DAA+B","sourcesContent":["export * from './sequence-type'\n"]}
|
|
@@ -1 +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"}
|
|
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","sourcesContent":["export const SEQUENCE_TYPE = {\n PRODUCT_LABEL_COUNTER: 'PRODUCT_LABEL_COUNTER'\n}\n"]}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNext = exports.generateId = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
const shell_1 = require("@things-factory/shell");
|
|
5
6
|
const id_rule_1 = require("../service/id-rule/id-rule");
|
|
6
7
|
const sequence_1 = require("../service/sequence/sequence");
|
|
7
8
|
async function generateId({ domain, type, seed }) {
|
|
8
|
-
const idRuleRepo = (0,
|
|
9
|
+
const idRuleRepo = (0, shell_1.getRepository)(id_rule_1.IdRule);
|
|
9
10
|
const rule = await idRuleRepo.findOne({
|
|
10
11
|
where: {
|
|
11
|
-
domain,
|
|
12
|
+
domain: { id: domain.id },
|
|
12
13
|
type
|
|
13
14
|
}
|
|
14
15
|
});
|
|
@@ -22,10 +23,10 @@ async function generateId({ domain, type, seed }) {
|
|
|
22
23
|
}
|
|
23
24
|
exports.generateId = generateId;
|
|
24
25
|
async function getNext({ domain, pattern, expirationDate }) {
|
|
25
|
-
const seqRepo = (0,
|
|
26
|
+
const seqRepo = (0, shell_1.getRepository)(sequence_1.Sequence);
|
|
26
27
|
const now = new Date();
|
|
27
|
-
let last = await seqRepo.
|
|
28
|
-
domain,
|
|
28
|
+
let last = await seqRepo.findOneBy({
|
|
29
|
+
domain: { id: domain.id },
|
|
29
30
|
pattern,
|
|
30
31
|
expiresAt: (0, typeorm_1.MoreThan)(now)
|
|
31
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../server/controllers/id-generator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../server/controllers/id-generator.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAElC,iDAA6D;AAE7D,wDAAmD;AACnD,2DAAuD;AAQhD,KAAK,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IACrD,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,gBAAM,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QACpC,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;YACzB,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;AAEM,KAAK,UAAU,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAe;IAC5E,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,IAAI,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC;QACjC,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;QACzB,OAAO;QACP,SAAS,EAAE,IAAA,kBAAQ,EAAC,GAAG,CAAC;KACzB,CAAC,CAAA;IAEF,IAAI,SAAS,GAAG,cAAc,CAAA;IAC9B,IAAI,CAAC,cAAc;QAAE,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IAE3E,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,GAAG,EAAE,CAAA;QACV,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACzB;SAAM;QACL,IAAI,CAAC,cAAc;YAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;QAErD,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,MAAM;YACN,OAAO;YACP,GAAG,EAAE,CAAC;YACN,SAAS;SACV,CAAC,CAAA;KACH;IAED,OAAO,IAAI,CAAC,GAAG,CAAA;AACjB,CAAC;AA5BD,0BA4BC","sourcesContent":["import { MoreThan } from 'typeorm'\n\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { IdRule } from '../service/id-rule/id-rule'\nimport { Sequence } from '../service/sequence/sequence'\n\ntype getNextArgs = {\n domain: Domain\n pattern: string\n expirationDate?: Date\n}\n\nexport async function generateId({ domain, type, seed }) {\n const idRuleRepo = getRepository(IdRule)\n const rule = await idRuleRepo.findOne({\n where: {\n domain: { id: domain.id },\n type\n }\n })\n\n if (!rule) throw Error('Rule not found')\n\n let evalFunc = eval(`async (domain, seed) => {\n ${rule.rule}\n }`)\n\n const nextId = await evalFunc(domain, {\n ...seed\n })\n\n return nextId\n}\n\nexport async function getNext({ domain, pattern, expirationDate }: getNextArgs) {\n const seqRepo = getRepository(Sequence)\n const now = new Date()\n let last = await seqRepo.findOneBy({\n domain: { id: domain.id },\n pattern,\n expiresAt: MoreThan(now)\n })\n\n var expiresAt = expirationDate\n if (!expirationDate) expiresAt = new Date(now.setMonth(now.getMonth() + 6))\n\n if (last) {\n last.seq++\n last.expiresAt = expiresAt\n await seqRepo.save(last)\n } else {\n if (!expirationDate) now.setMonth(now.getMonth() + 6)\n\n last = await seqRepo.save({\n domain,\n pattern,\n seq: 1,\n expiresAt\n })\n }\n\n return last.seq\n}\n"]}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./id-generator"), exports);
|
|
18
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B","sourcesContent":["export * from './id-generator'\n"]}
|
package/dist-server/index.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
17
4
|
require("./routes");
|
|
18
|
-
__exportStar(require("./service"), exports);
|
|
19
|
-
__exportStar(require("./migrations"), exports);
|
|
20
|
-
__exportStar(require("./controllers"), exports);
|
|
21
|
-
__exportStar(require("./constants"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./service"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./migrations"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./controllers"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
22
9
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oBAAiB;AAEjB,oDAAyB;AACzB,uDAA4B;AAC5B,wDAA6B;AAC7B,sDAA2B","sourcesContent":["import './routes'\n\nexport * from './service'\nexport * from './migrations'\nexport * from './controllers'\nexport * from './constants'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA","sourcesContent":["const glob = require('glob')\nconst path = require('path')\n\nexport var migrations = []\n\nglob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {\n if (file.indexOf('index.js') !== -1) return\n migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6DAAuD;AAEvD,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACzE;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;QAEvC,IAAI,EAAE,GAAG,MAAM,IAAA,yBAAU,EAAC;YACxB,MAAM;YACN,IAAI;YACJ,IAAI,EAAE;gBACJ,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,IAAI;aACf;SACF,CAAC,CAAA;QAEF,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6DAAuD;AAEvD,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACzE;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;QAEvC,IAAI,EAAE,GAAG,MAAM,IAAA,yBAAU,EAAC;YACxB,MAAM;YACN,IAAI;YACJ,IAAI,EAAE;gBACJ,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,IAAI;aACf;SACF,CAAC,CAAA;QAEF,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { generateId } from './controllers/id-generator'\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, routes) => {\n /*\n * koa application에 routes 를 추가할 수 있다.\n *\n * ex) routes.get('/path', async(context, next) => {})\n * ex) routes.post('/path', async(context, next) => {})\n */\n routes.get('/get-next-pattern/:type/:domain', async (context, next) => {\n const { type, domain } = context.params\n\n var id = await generateId({\n domain,\n type,\n seed: {\n productId: 'ASUS',\n receiver: 'LA'\n }\n })\n\n context.status = 200\n context.body = id\n })\n})\n"]}
|
|
@@ -1,52 +1,41 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.IdRuleMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const type_graphql_1 = require("type-graphql");
|
|
17
|
-
const
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
18
7
|
const id_rule_1 = require("./id-rule");
|
|
19
8
|
const id_rule_types_1 = require("./id-rule-types");
|
|
20
9
|
let IdRuleMutation = class IdRuleMutation {
|
|
21
10
|
async createIdRule(idRule, context) {
|
|
22
|
-
return await (0,
|
|
11
|
+
return await (0, shell_1.getRepository)(id_rule_1.IdRule).save(Object.assign(Object.assign({}, idRule), { domain: context.state.domain }));
|
|
23
12
|
}
|
|
24
13
|
async updateIdRule(type, patch, context) {
|
|
25
|
-
const repository = (0,
|
|
14
|
+
const repository = (0, shell_1.getRepository)(id_rule_1.IdRule);
|
|
26
15
|
const idRule = await repository.findOne({
|
|
27
|
-
where: { type, domain: context.state.domain }
|
|
16
|
+
where: { type: type, domain: { id: context.state.domain } }
|
|
28
17
|
});
|
|
29
18
|
return await repository.save(Object.assign(Object.assign({}, idRule), patch));
|
|
30
19
|
}
|
|
31
20
|
};
|
|
32
|
-
__decorate([
|
|
21
|
+
tslib_1.__decorate([
|
|
33
22
|
(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)
|
|
23
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('idRule')),
|
|
24
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
25
|
+
tslib_1.__metadata("design:type", Function),
|
|
26
|
+
tslib_1.__metadata("design:paramtypes", [id_rule_types_1.NewIdRule, Object]),
|
|
27
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
39
28
|
], IdRuleMutation.prototype, "createIdRule", null);
|
|
40
|
-
__decorate([
|
|
29
|
+
tslib_1.__decorate([
|
|
41
30
|
(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)
|
|
31
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('type')),
|
|
32
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
33
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
34
|
+
tslib_1.__metadata("design:type", Function),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [String, id_rule_types_1.IdRulePatch, Object]),
|
|
36
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
48
37
|
], IdRuleMutation.prototype, "updateIdRule", null);
|
|
49
|
-
IdRuleMutation = __decorate([
|
|
38
|
+
IdRuleMutation = tslib_1.__decorate([
|
|
50
39
|
(0, type_graphql_1.Resolver)(id_rule_1.IdRule)
|
|
51
40
|
], IdRuleMutation);
|
|
52
41
|
exports.IdRuleMutation = IdRuleMutation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-rule-mutation.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-mutation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"id-rule-mutation.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAE3D,iDAAqD;AAErD,uCAAkC;AAClC,mDAAwD;AAGxD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEzB,KAAK,CAAC,YAAY,CAAgB,MAAiB,EAAS,OAAY;QACtE,OAAO,MAAM,IAAA,qBAAa,EAAC,gBAAM,CAAC,CAAC,IAAI,iCAClC,MAAM,KACT,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,IAC5B,CAAA;IACJ,CAAC;IAGD,KAAK,CAAC,YAAY,CACH,IAAY,EACX,KAAkB,EACzB,OAAY;QAEnB,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,gBAAM,CAAC,CAAA;QACxC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACtC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAW,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE;SACnE,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,iCACvB,MAAM,GACN,KAAK,EACR,CAAA;IACJ,CAAC;CACF,CAAA;AAvBC;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAM,CAAC;IACR,mBAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,yBAAS;;kDAKlD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAM,CAAC;IAEzB,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,2BAAW;;kDAYjC;AAxBU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,gBAAM,CAAC;GACJ,cAAc,CAyB1B;AAzBY,wCAAc","sourcesContent":["import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { IdRule } from './id-rule'\nimport { IdRulePatch, NewIdRule } from './id-rule-types'\n\n@Resolver(IdRule)\nexport class IdRuleMutation {\n @Mutation(returns => IdRule)\n async createIdRule(@Arg('idRule') idRule: NewIdRule, @Ctx() context: any) {\n return await getRepository(IdRule).save({\n ...idRule,\n domain: context.state.domain\n })\n }\n\n @Mutation(returns => IdRule)\n async updateIdRule(\n @Arg('type') type: string,\n @Arg('patch') patch: IdRulePatch,\n @Ctx() context: any\n ): Promise<IdRule> {\n const repository = getRepository(IdRule)\n const idRule = await repository.findOne({\n where: { type: type as any, domain: { id: context.state.domain } }\n })\n\n return await repository.save({\n ...idRule,\n ...patch\n })\n }\n}\n"]}
|
|
@@ -1,52 +1,40 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.IdRuleQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const type_graphql_1 = require("type-graphql");
|
|
17
|
-
const typeorm_1 = require("typeorm");
|
|
18
6
|
const shell_1 = require("@things-factory/shell");
|
|
19
7
|
const id_rule_1 = require("./id-rule");
|
|
20
8
|
let IdRuleQuery = class IdRuleQuery {
|
|
21
9
|
async idRule(type, context) {
|
|
22
|
-
const rule = await (0,
|
|
10
|
+
const rule = await (0, shell_1.getRepository)(id_rule_1.IdRule).findOne({
|
|
23
11
|
where: {
|
|
24
|
-
domain: context.state.domain,
|
|
25
|
-
type
|
|
12
|
+
domain: { id: context.state.domain.id },
|
|
13
|
+
type: type
|
|
26
14
|
}
|
|
27
15
|
});
|
|
28
16
|
return rule;
|
|
29
17
|
}
|
|
30
18
|
async domain(idRule) {
|
|
31
|
-
return await (0,
|
|
19
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: idRule.domainId });
|
|
32
20
|
}
|
|
33
21
|
};
|
|
34
|
-
__decorate([
|
|
22
|
+
tslib_1.__decorate([
|
|
35
23
|
(0, type_graphql_1.Query)(returns => id_rule_1.IdRule, { nullable: true }),
|
|
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)
|
|
24
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('type')),
|
|
25
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
26
|
+
tslib_1.__metadata("design:type", Function),
|
|
27
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
28
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
41
29
|
], IdRuleQuery.prototype, "idRule", null);
|
|
42
|
-
__decorate([
|
|
30
|
+
tslib_1.__decorate([
|
|
43
31
|
(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)
|
|
32
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
33
|
+
tslib_1.__metadata("design:type", Function),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [id_rule_1.IdRule]),
|
|
35
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
48
36
|
], IdRuleQuery.prototype, "domain", null);
|
|
49
|
-
IdRuleQuery = __decorate([
|
|
37
|
+
IdRuleQuery = tslib_1.__decorate([
|
|
50
38
|
(0, type_graphql_1.Resolver)(id_rule_1.IdRule)
|
|
51
39
|
], IdRuleQuery);
|
|
52
40
|
exports.IdRuleQuery = IdRuleQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-rule-query.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"id-rule-query.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAE7E,iDAA6D;AAE7D,uCAAkC;AAGlC,IAAa,WAAW,GAAxB,MAAa,WAAW;IAEtB,KAAK,CAAC,MAAM,CAAc,IAAY,EAAS,OAAY;QACzD,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,gBAAM,CAAC,CAAC,OAAO,CAAC;YAC/C,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE;gBACvC,IAAI,EAAE,IAAW;aAClB;SACF,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAGD,KAAK,CAAC,MAAM,CAAS,MAAc;QACjC,OAAO,MAAM,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IACvE,CAAC;CACF,CAAA;AAfC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/B,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;yCAS7C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAS,gBAAM;;yCAElC;AAhBU,WAAW;IADvB,IAAA,uBAAQ,EAAC,gBAAM,CAAC;GACJ,WAAW,CAiBvB;AAjBY,kCAAW","sourcesContent":["import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { IdRule } from './id-rule'\n\n@Resolver(IdRule)\nexport class IdRuleQuery {\n @Query(returns => IdRule, { nullable: true })\n async idRule(@Arg('type') type: string, @Ctx() context: any): Promise<IdRule> {\n const rule = await getRepository(IdRule).findOne({\n where: {\n domain: { id: context.state.domain.id },\n type: type as any\n }\n })\n\n return rule\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() idRule: IdRule) {\n return await getRepository(Domain).findOneBy({ id: idRule.domainId })\n }\n}\n"]}
|
|
@@ -1,42 +1,34 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.NewIdRule = exports.IdRulePatch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
13
5
|
const type_graphql_1 = require("type-graphql");
|
|
14
6
|
const id_rule_1 = require("./id-rule");
|
|
15
7
|
let IdRulePatch = class IdRulePatch {
|
|
16
8
|
};
|
|
17
|
-
__decorate([
|
|
9
|
+
tslib_1.__decorate([
|
|
18
10
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
19
|
-
__metadata("design:type", String)
|
|
11
|
+
tslib_1.__metadata("design:type", String)
|
|
20
12
|
], IdRulePatch.prototype, "type", void 0);
|
|
21
|
-
__decorate([
|
|
13
|
+
tslib_1.__decorate([
|
|
22
14
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
23
|
-
__metadata("design:type", String)
|
|
15
|
+
tslib_1.__metadata("design:type", String)
|
|
24
16
|
], IdRulePatch.prototype, "rule", void 0);
|
|
25
|
-
IdRulePatch = __decorate([
|
|
17
|
+
IdRulePatch = tslib_1.__decorate([
|
|
26
18
|
(0, type_graphql_1.InputType)()
|
|
27
19
|
], IdRulePatch);
|
|
28
20
|
exports.IdRulePatch = IdRulePatch;
|
|
29
21
|
let NewIdRule = class NewIdRule {
|
|
30
22
|
};
|
|
31
|
-
__decorate([
|
|
23
|
+
tslib_1.__decorate([
|
|
32
24
|
(0, type_graphql_1.Field)(),
|
|
33
|
-
__metadata("design:type", String)
|
|
25
|
+
tslib_1.__metadata("design:type", String)
|
|
34
26
|
], NewIdRule.prototype, "type", void 0);
|
|
35
|
-
__decorate([
|
|
27
|
+
tslib_1.__decorate([
|
|
36
28
|
(0, type_graphql_1.Field)(),
|
|
37
|
-
__metadata("design:type", String)
|
|
29
|
+
tslib_1.__metadata("design:type", String)
|
|
38
30
|
], NewIdRule.prototype, "rule", void 0);
|
|
39
|
-
NewIdRule = __decorate([
|
|
31
|
+
NewIdRule = tslib_1.__decorate([
|
|
40
32
|
(0, type_graphql_1.InputType)()
|
|
41
33
|
], NewIdRule);
|
|
42
34
|
exports.NewIdRule = NewIdRule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-rule-types.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule-types.ts"],"names":[],"mappings":"
|
|
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","sourcesContent":["import { Field, InputType } from 'type-graphql'\n\nimport { IdRuleType } from './id-rule'\n\n@InputType()\nexport class IdRulePatch {\n @Field({ nullable: true })\n type?: IdRuleType\n\n @Field({ nullable: true })\n rule?: string\n}\n\n@InputType()\nexport class NewIdRule {\n @Field()\n type: IdRuleType\n\n @Field()\n rule: string\n}\n"]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
3
|
exports.IdRule = exports.IdRuleType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
14
5
|
const type_graphql_1 = require("type-graphql");
|
|
15
6
|
const typeorm_1 = require("typeorm");
|
|
16
7
|
const env_1 = require("@things-factory/env");
|
|
@@ -30,25 +21,26 @@ var IdRuleType;
|
|
|
30
21
|
IdRuleType["GAN_NUMBER"] = "gan_number";
|
|
31
22
|
IdRuleType["GRN_NUMBER"] = "grn_number";
|
|
32
23
|
IdRuleType["RO_NUMBER"] = "ro_number";
|
|
24
|
+
IdRuleType["PO_NUMBER"] = "po_number";
|
|
33
25
|
IdRuleType["LOT_NO"] = "lot_no";
|
|
34
26
|
})(IdRuleType = exports.IdRuleType || (exports.IdRuleType = {}));
|
|
35
27
|
let IdRule = class IdRule {
|
|
36
28
|
};
|
|
37
|
-
__decorate([
|
|
29
|
+
tslib_1.__decorate([
|
|
38
30
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
39
31
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
40
|
-
__metadata("design:type", String)
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
41
33
|
], IdRule.prototype, "id", void 0);
|
|
42
|
-
__decorate([
|
|
34
|
+
tslib_1.__decorate([
|
|
43
35
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
44
36
|
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
|
45
|
-
__metadata("design:type",
|
|
37
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
46
38
|
], IdRule.prototype, "domain", void 0);
|
|
47
|
-
__decorate([
|
|
39
|
+
tslib_1.__decorate([
|
|
48
40
|
(0, typeorm_1.RelationId)((idRule) => idRule.domain),
|
|
49
|
-
__metadata("design:type", String)
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
50
42
|
], IdRule.prototype, "domainId", void 0);
|
|
51
|
-
__decorate([
|
|
43
|
+
tslib_1.__decorate([
|
|
52
44
|
(0, typeorm_1.Column)({
|
|
53
45
|
nullable: false,
|
|
54
46
|
type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
@@ -60,24 +52,24 @@ __decorate([
|
|
|
60
52
|
default: IdRuleType.PALLET_ID
|
|
61
53
|
}),
|
|
62
54
|
(0, type_graphql_1.Field)(),
|
|
63
|
-
__metadata("design:type", String)
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
64
56
|
], IdRule.prototype, "type", void 0);
|
|
65
|
-
__decorate([
|
|
57
|
+
tslib_1.__decorate([
|
|
66
58
|
(0, typeorm_1.Column)(),
|
|
67
59
|
(0, type_graphql_1.Field)(),
|
|
68
|
-
__metadata("design:type", String)
|
|
60
|
+
tslib_1.__metadata("design:type", String)
|
|
69
61
|
], IdRule.prototype, "rule", void 0);
|
|
70
|
-
__decorate([
|
|
62
|
+
tslib_1.__decorate([
|
|
71
63
|
(0, typeorm_1.CreateDateColumn)(),
|
|
72
64
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
73
|
-
__metadata("design:type", Date)
|
|
65
|
+
tslib_1.__metadata("design:type", Date)
|
|
74
66
|
], IdRule.prototype, "createdAt", void 0);
|
|
75
|
-
__decorate([
|
|
67
|
+
tslib_1.__decorate([
|
|
76
68
|
(0, typeorm_1.UpdateDateColumn)(),
|
|
77
69
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
78
|
-
__metadata("design:type", Date)
|
|
70
|
+
tslib_1.__metadata("design:type", Date)
|
|
79
71
|
], IdRule.prototype, "updatedAt", void 0);
|
|
80
|
-
IdRule = __decorate([
|
|
72
|
+
IdRule = tslib_1.__decorate([
|
|
81
73
|
(0, typeorm_1.Entity)(),
|
|
82
74
|
(0, typeorm_1.Index)('ix_id_rule_0', (idRule) => [idRule.domain, idRule.type], { unique: true }),
|
|
83
75
|
(0, typeorm_1.Index)('ix_id_rule_1', (idRule) => [idRule.domain]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-rule.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"id-rule.js","sourceRoot":"","sources":["../../../server/service/id-rule/id-rule.ts"],"names":[],"mappings":";;;;AAAA,+CAIqB;AACrB,qCASgB;AAEhB,6CAA4C;AAC5C,iDAA8C;AAE9C,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,UAcX;AAdD,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;IACvB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;AACnB,CAAC,EAdW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAcrB;AAOD,IAAa,MAAM,GAAnB,MAAa,MAAM;CAqClB,CAAA;AAlCC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;kCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACd,cAAM;sCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;wCAC9B;AAchB;IAZC,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;gBACzB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU;QAClB,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;sCACf,IAAI;yCAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,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","sourcesContent":["import {\n Field,\n ID,\n ObjectType\n} from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum IdRuleType {\n PALLET_ID = 'pallet_id',\n ADJUSTMENT_PALLET_ID = 'adjustment_pallet_id',\n ADJUSTMENT_CARTON_ID = 'adjustment_carton_id',\n INBOUND_PALLET_ID = 'inbound_pallet_id',\n INBOUND_CARTON_ID = 'inbound_carton_id',\n VAS_PALLET_ID = 'vas_pallet_id',\n DO_NUMBER = 'do_number',\n TASK_NO = 'task_number',\n GAN_NUMBER = 'gan_number',\n GRN_NUMBER = 'grn_number',\n RO_NUMBER = 'ro_number',\n PO_NUMBER = 'po_number',\n LOT_NO = 'lot_no'\n}\n\n@Entity()\n@Index('ix_id_rule_0', (idRule: IdRule) => [idRule.domain, idRule.type], { unique: true })\n@Index('ix_id_rule_1', (idRule: IdRule) => [idRule.domain])\n@Index('ix_id_rule_2', (idRule: IdRule) => [idRule.type])\n@ObjectType()\nexport class IdRule {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain: Domain\n\n @RelationId((idRule: IdRule) => idRule.domain)\n domainId: string\n\n @Column({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: IdRuleType,\n default: IdRuleType.PALLET_ID\n })\n @Field()\n type: IdRuleType\n\n @Column()\n @Field()\n rule: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n}\n"]}
|
|
@@ -1 +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"}
|
|
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","sourcesContent":["import { IdRule } from './id-rule'\nimport { IdRuleMutation } from './id-rule-mutation'\nimport { IdRuleQuery } from './id-rule-query'\n\nexport const entities = [IdRule]\nexport const resolvers = [IdRuleQuery, IdRuleMutation]\n"]}
|
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
3
|
exports.schema = exports.entities = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
18
5
|
const id_rule_1 = require("./id-rule");
|
|
19
6
|
const sequence_1 = require("./sequence");
|
|
20
7
|
/* EXPORT ENTITY TYPES */
|
|
21
|
-
__exportStar(require("./id-rule/id-rule"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./id-rule/id-rule"), exports);
|
|
22
9
|
/* EXPORT TYPES */
|
|
23
|
-
__exportStar(require("./id-rule/id-rule-types"), exports);
|
|
24
|
-
__exportStar(require("./sequence/sequence"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./id-rule/id-rule-types"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./sequence/sequence"), exports);
|
|
25
12
|
exports.entities = [...id_rule_1.entities, ...sequence_1.entities];
|
|
26
13
|
exports.schema = {
|
|
27
14
|
resolverClasses: [...id_rule_1.resolvers, ...sequence_1.resolvers]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,uCAAoF;AACpF,yCAAyF;AAEzF,yBAAyB;AACzB,4DAAiC;AACjC,kBAAkB;AAClB,kEAAuC;AACvC,8DAAmC;AAEtB,QAAA,QAAQ,GAAG,CAAC,GAAG,kBAAc,EAAE,GAAG,mBAAgB,CAAC,CAAA;AAEnD,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE,CAAC,GAAG,mBAAe,EAAE,GAAG,oBAAiB,CAAC;CAC5D,CAAA","sourcesContent":["import { entities as IdRuleEntities, resolvers as IdRuleResolvers } from './id-rule'\nimport { entities as SequenceEntities, resolvers as SequenceResolvers } from './sequence'\n\n/* EXPORT ENTITY TYPES */\nexport * from './id-rule/id-rule'\n/* EXPORT TYPES */\nexport * from './id-rule/id-rule-types'\nexport * from './sequence/sequence'\n\nexport const entities = [...IdRuleEntities, ...SequenceEntities]\n\nexport const schema = {\n resolverClasses: [...IdRuleResolvers, ...SequenceResolvers]\n}\n"]}
|
|
@@ -1 +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"}
|
|
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","sourcesContent":["import { Sequence } from './sequence'\nimport { SequenceMutation } from './sequence-mutation'\n\nexport const entities = [Sequence]\nexport const resolvers = [SequenceMutation]\n"]}
|
|
@@ -1,26 +1,15 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.SequenceMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const type_graphql_1 = require("type-graphql");
|
|
17
|
-
const
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
18
7
|
const constants_1 = require("../../constants");
|
|
19
8
|
const sequence_1 = require("./sequence");
|
|
20
9
|
let SequenceMutation = class SequenceMutation {
|
|
21
10
|
async upsertSequence(type, counter, bizplaceId, context) {
|
|
22
11
|
const { domain } = context.state;
|
|
23
|
-
const seqRepo = (0,
|
|
12
|
+
const seqRepo = (0, shell_1.getRepository)(sequence_1.Sequence);
|
|
24
13
|
const now = new Date();
|
|
25
14
|
const expiresAt = new Date(now.setMonth(now.getMonth() + 12));
|
|
26
15
|
const patternObj = {
|
|
@@ -30,7 +19,7 @@ let SequenceMutation = class SequenceMutation {
|
|
|
30
19
|
};
|
|
31
20
|
const pattern = JSON.stringify(patternObj);
|
|
32
21
|
const foundSeq = await seqRepo.findOne({
|
|
33
|
-
where: { pattern, type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain }
|
|
22
|
+
where: { pattern, type: constants_1.SEQUENCE_TYPE.PRODUCT_LABEL_COUNTER, domain: { id: domain.id } }
|
|
34
23
|
});
|
|
35
24
|
if (foundSeq) {
|
|
36
25
|
await seqRepo.update({ id: foundSeq.id }, {
|
|
@@ -39,7 +28,7 @@ let SequenceMutation = class SequenceMutation {
|
|
|
39
28
|
expiresAt,
|
|
40
29
|
updatedAt: now
|
|
41
30
|
});
|
|
42
|
-
return await seqRepo.
|
|
31
|
+
return await seqRepo.findOneBy({ id: foundSeq.id });
|
|
43
32
|
}
|
|
44
33
|
else {
|
|
45
34
|
return await seqRepo.save({
|
|
@@ -52,17 +41,17 @@ let SequenceMutation = class SequenceMutation {
|
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
43
|
};
|
|
55
|
-
__decorate([
|
|
44
|
+
tslib_1.__decorate([
|
|
56
45
|
(0, type_graphql_1.Mutation)(returns => sequence_1.Sequence),
|
|
57
|
-
__param(0, (0, type_graphql_1.Arg)('type')),
|
|
58
|
-
__param(1, (0, type_graphql_1.Arg)('counter')),
|
|
59
|
-
__param(2, (0, type_graphql_1.Arg)('bizplaceId')),
|
|
60
|
-
__param(3, (0, type_graphql_1.Ctx)()),
|
|
61
|
-
__metadata("design:type", Function),
|
|
62
|
-
__metadata("design:paramtypes", [String, Number, String, Object]),
|
|
63
|
-
__metadata("design:returntype", Promise)
|
|
46
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('type')),
|
|
47
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('counter')),
|
|
48
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('bizplaceId')),
|
|
49
|
+
tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
|
|
50
|
+
tslib_1.__metadata("design:type", Function),
|
|
51
|
+
tslib_1.__metadata("design:paramtypes", [String, Number, String, Object]),
|
|
52
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
64
53
|
], SequenceMutation.prototype, "upsertSequence", null);
|
|
65
|
-
SequenceMutation = __decorate([
|
|
54
|
+
SequenceMutation = tslib_1.__decorate([
|
|
66
55
|
(0, type_graphql_1.Resolver)(sequence_1.Sequence)
|
|
67
56
|
], SequenceMutation);
|
|
68
57
|
exports.SequenceMutation = SequenceMutation;
|