@decaf-ts/for-fabric 0.1.40 → 0.1.42
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/for-fabric.cjs +1 -1
- package/dist/for-fabric.cjs.map +1 -1
- package/dist/for-fabric.js +1 -1
- package/dist/for-fabric.js.map +1 -1
- package/lib/cli-module.cjs +2 -1
- package/lib/cli-module.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +7 -1
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/contract/BatchContract.cjs +30 -0
- package/lib/contract/BatchContract.d.ts +5 -0
- package/lib/contract/BatchContract.js.map +1 -0
- package/lib/contract/ProductContract.cjs +1 -4
- package/lib/contract/ProductContract.d.ts +1 -1
- package/lib/contract/ProductContract.js.map +1 -1
- package/lib/contract/index.cjs +2 -0
- package/lib/contract/index.js.map +1 -1
- package/lib/contract/models/Audit.cjs +83 -0
- package/lib/contract/models/Audit.d.ts +12 -0
- package/lib/contract/models/Audit.js.map +1 -0
- package/lib/contract/models/BaseIdentifiedModel.cjs +37 -0
- package/lib/contract/models/BaseIdentifiedModel.d.ts +7 -0
- package/lib/contract/models/BaseIdentifiedModel.js.map +1 -0
- package/lib/contract/models/BaseModel.cjs +42 -0
- package/lib/contract/models/BaseModel.d.ts +7 -0
- package/lib/contract/models/BaseModel.js.map +1 -0
- package/lib/contract/models/Batch.cjs +174 -0
- package/lib/contract/models/Batch.d.ts +18 -0
- package/lib/contract/models/Batch.js.map +1 -0
- package/lib/contract/models/Leaflet.cjs +95 -0
- package/lib/contract/models/Leaflet.d.ts +12 -0
- package/lib/contract/models/Leaflet.js.map +1 -0
- package/lib/contract/models/LeafletFile.cjs +58 -0
- package/lib/contract/models/LeafletFile.d.ts +9 -0
- package/lib/contract/models/LeafletFile.js.map +1 -0
- package/lib/contract/models/Market.cjs +75 -0
- package/lib/contract/models/Market.d.ts +12 -0
- package/lib/contract/models/Market.js.map +1 -0
- package/lib/contract/models/Product.cjs +77 -0
- package/lib/contract/models/Product.d.ts +15 -0
- package/lib/contract/models/Product.js.map +1 -0
- package/lib/contract/models/ProductStrength.cjs +60 -0
- package/lib/contract/models/ProductStrength.d.ts +10 -0
- package/lib/contract/models/ProductStrength.js.map +1 -0
- package/lib/contract/models/constants.cjs +30 -0
- package/lib/contract/models/constants.d.ts +24 -0
- package/lib/contract/models/constants.js.map +1 -0
- package/lib/contract/models/decorators.cjs +54 -0
- package/lib/contract/models/decorators.d.ts +8 -0
- package/lib/contract/models/decorators.js.map +1 -0
- package/lib/contract/models/gtin.cjs +88 -0
- package/lib/contract/models/gtin.d.ts +8 -0
- package/lib/contract/models/gtin.js.map +1 -0
- package/lib/contracts/ContractAdapter.cjs +22 -25
- package/lib/contracts/ContractAdapter.d.ts +1 -7
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/FabricContractPaginator.js.map +1 -1
- package/lib/contracts/FabricContractRepository.cjs +0 -46
- package/lib/contracts/FabricContractRepository.d.ts +1 -1
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/FabricContractSequence.cjs +93 -58
- package/lib/contracts/FabricContractSequence.d.ts +2 -2
- package/lib/contracts/FabricContractSequence.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +4 -1
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/index.cjs +0 -1
- package/lib/contracts/index.d.ts +0 -1
- package/lib/contracts/index.js.map +1 -1
- package/lib/esm/cli-module.js +2 -1
- package/lib/esm/cli-module.js.map +1 -1
- package/lib/esm/client/FabricClientAdapter.js +8 -2
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/contract/BatchContract.d.ts +5 -0
- package/lib/esm/contract/BatchContract.js +27 -0
- package/lib/esm/contract/BatchContract.js.map +1 -0
- package/lib/esm/contract/ProductContract.d.ts +1 -1
- package/lib/esm/contract/ProductContract.js +1 -4
- package/lib/esm/contract/ProductContract.js.map +1 -1
- package/lib/esm/contract/index.js +2 -0
- package/lib/esm/contract/index.js.map +1 -1
- package/lib/esm/contract/models/Audit.d.ts +12 -0
- package/lib/esm/contract/models/Audit.js +80 -0
- package/lib/esm/contract/models/Audit.js.map +1 -0
- package/lib/esm/contract/models/BaseIdentifiedModel.d.ts +7 -0
- package/lib/esm/contract/models/BaseIdentifiedModel.js +34 -0
- package/lib/esm/contract/models/BaseIdentifiedModel.js.map +1 -0
- package/lib/esm/contract/models/BaseModel.d.ts +7 -0
- package/lib/esm/contract/models/BaseModel.js +39 -0
- package/lib/esm/contract/models/BaseModel.js.map +1 -0
- package/lib/esm/contract/models/Batch.d.ts +18 -0
- package/lib/esm/contract/models/Batch.js +171 -0
- package/lib/esm/contract/models/Batch.js.map +1 -0
- package/lib/esm/contract/models/Leaflet.d.ts +12 -0
- package/lib/esm/contract/models/Leaflet.js +92 -0
- package/lib/esm/contract/models/Leaflet.js.map +1 -0
- package/lib/esm/contract/models/LeafletFile.d.ts +9 -0
- package/lib/esm/contract/models/LeafletFile.js +55 -0
- package/lib/esm/contract/models/LeafletFile.js.map +1 -0
- package/lib/esm/contract/models/Market.d.ts +12 -0
- package/lib/esm/contract/models/Market.js +72 -0
- package/lib/esm/contract/models/Market.js.map +1 -0
- package/lib/esm/contract/models/Product.d.ts +15 -0
- package/lib/esm/contract/models/Product.js +74 -0
- package/lib/esm/contract/models/Product.js.map +1 -0
- package/lib/esm/contract/models/ProductStrength.d.ts +10 -0
- package/lib/esm/contract/models/ProductStrength.js +57 -0
- package/lib/esm/contract/models/ProductStrength.js.map +1 -0
- package/lib/esm/contract/models/constants.d.ts +24 -0
- package/lib/esm/contract/models/constants.js +27 -0
- package/lib/esm/contract/models/constants.js.map +1 -0
- package/lib/esm/contract/models/decorators.d.ts +8 -0
- package/lib/esm/contract/models/decorators.js +48 -0
- package/lib/esm/contract/models/decorators.js.map +1 -0
- package/lib/esm/contract/models/gtin.d.ts +8 -0
- package/lib/esm/contract/models/gtin.js +82 -0
- package/lib/esm/contract/models/gtin.js.map +1 -0
- package/lib/esm/contracts/ContractAdapter.d.ts +1 -7
- package/lib/esm/contracts/ContractAdapter.js +22 -25
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/FabricContractPaginator.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.d.ts +1 -1
- package/lib/esm/contracts/FabricContractRepository.js +1 -47
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/FabricContractSequence.d.ts +2 -2
- package/lib/esm/contracts/FabricContractSequence.js +93 -58
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.js +4 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/index.d.ts +0 -1
- package/lib/esm/contracts/index.js +0 -1
- package/lib/esm/contracts/index.js.map +1 -1
- package/lib/esm/shared/errors.d.ts +9 -0
- package/lib/esm/shared/errors.js +15 -0
- package/lib/esm/shared/errors.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/errors.cjs +19 -1
- package/lib/shared/errors.d.ts +9 -0
- package/lib/shared/errors.js.map +1 -1
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +3 -2
- package/workdocs/assets/slogans.json +182 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { maxlength, minlength, model, required, } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { TableNames } from "./constants.js";
|
|
12
|
+
import { column, index, OrderDirection, pk, table } from "@decaf-ts/core";
|
|
13
|
+
import { composed } from "@decaf-ts/db-decorators";
|
|
14
|
+
import { description, uses } from "@decaf-ts/decoration";
|
|
15
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel.js";
|
|
16
|
+
import { gtin } from "./gtin.js";
|
|
17
|
+
import { FabricFlavour } from "./../../shared/index.js";
|
|
18
|
+
let Market = class Market extends BaseIdentifiedModel {
|
|
19
|
+
constructor(model) {
|
|
20
|
+
super(model);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
pk({ type: "String", generated: false }),
|
|
25
|
+
composed(["productCode", "marketId"], ":", true),
|
|
26
|
+
description("Unique identifier composed of product code and market ID."),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], Market.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
column(),
|
|
31
|
+
required(),
|
|
32
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
33
|
+
description("Identifier of the market where the product is registered or sold."),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], Market.prototype, "marketId", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
column(),
|
|
38
|
+
gtin(),
|
|
39
|
+
required(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], Market.prototype, "productCode", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
column(),
|
|
44
|
+
minlength(2),
|
|
45
|
+
maxlength(2),
|
|
46
|
+
description("Two-letter national code (ISO format) representing the market's country."),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], Market.prototype, "nationalCode", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
column(),
|
|
51
|
+
description("Name of the Marketing Authorization Holder (MAH)."),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], Market.prototype, "mahName", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
column(),
|
|
56
|
+
description("Name of the legal entity responsible for the product in this market."),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], Market.prototype, "legalEntityName", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
column(),
|
|
61
|
+
description("Address of the Marketing Authorization Holder or responsible legal entity."),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], Market.prototype, "mahAddress", void 0);
|
|
64
|
+
Market = __decorate([
|
|
65
|
+
description("Links a product to a specific market."),
|
|
66
|
+
uses(FabricFlavour),
|
|
67
|
+
table(TableNames.Market),
|
|
68
|
+
model(),
|
|
69
|
+
__metadata("design:paramtypes", [Object])
|
|
70
|
+
], Market);
|
|
71
|
+
export { Market };
|
|
72
|
+
//# sourceMappingURL=Market.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Market.js","sourceRoot":"","sources":["../../../../src/contract/models/Market.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,uBAAoB;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,aAAa,EAAE,gCAA2B;AAM5C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,mBAAmB;IA2C7C,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF,CAAA;AA1CC;IAHC,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxC,QAAQ,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC;IAChD,WAAW,CAAC,2DAA2D,CAAC;;kCAC7D;AAQZ;IANC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/C,WAAW,CACV,mEAAmE,CACpE;;wCACiB;AAKlB;IAHC,MAAM,EAAE;IACR,IAAI,EAAE;IACN,QAAQ,EAAE;;2CACU;AAQrB;IANC,MAAM,EAAE;IACR,SAAS,CAAC,CAAC,CAAC;IACZ,SAAS,CAAC,CAAC,CAAC;IACZ,WAAW,CACV,0EAA0E,CAC3E;;4CACqB;AAItB;IAFC,MAAM,EAAE;IACR,WAAW,CAAC,mDAAmD,CAAC;;uCAChD;AAMjB;IAJC,MAAM,EAAE;IACR,WAAW,CACV,sEAAsE,CACvE;;+CACwB;AAMzB;IAJC,MAAM,EAAE;IACR,WAAW,CACV,4EAA4E,CAC7E;;0CACmB;AAzCT,MAAM;IAJlB,WAAW,CAAC,uCAAuC,CAAC;IACpD,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;IACxB,KAAK,EAAE;;GACK,MAAM,CA8ClB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelArg } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { ProductStrength } from "./ProductStrength";
|
|
3
|
+
import { Market } from "./Market";
|
|
4
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel";
|
|
5
|
+
export declare class Product extends BaseIdentifiedModel {
|
|
6
|
+
productCode: string;
|
|
7
|
+
inventedName: string;
|
|
8
|
+
nameMedicinalProduct: string;
|
|
9
|
+
internalMaterialCode?: string;
|
|
10
|
+
productRecall: boolean;
|
|
11
|
+
counter?: number;
|
|
12
|
+
strengths: ProductStrength[];
|
|
13
|
+
markets: Market[];
|
|
14
|
+
constructor(args?: ModelArg<Product>);
|
|
15
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { model, required } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { Cascade, column, index, oneToMany, OrderDirection, pk, table, } from "@decaf-ts/core";
|
|
12
|
+
// import {BlockOperations, OperationKeys, readonly} from "@decaf-ts/db-decorators";
|
|
13
|
+
import { uses } from "@decaf-ts/decoration";
|
|
14
|
+
import { ProductStrength } from "./ProductStrength.js";
|
|
15
|
+
import { Market } from "./Market.js";
|
|
16
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel.js";
|
|
17
|
+
import { gtin } from "./gtin.js";
|
|
18
|
+
import { audit } from "./decorators.js";
|
|
19
|
+
import { FabricFlavour } from "./../../shared/index.js";
|
|
20
|
+
let Product = class Product extends BaseIdentifiedModel {
|
|
21
|
+
constructor(args) {
|
|
22
|
+
super(args);
|
|
23
|
+
this.productRecall = false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
__decorate([
|
|
27
|
+
gtin(),
|
|
28
|
+
audit(),
|
|
29
|
+
pk({ type: String, generated: false }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], Product.prototype, "productCode", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
column(),
|
|
34
|
+
required(),
|
|
35
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], Product.prototype, "inventedName", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
column(),
|
|
40
|
+
required(),
|
|
41
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], Product.prototype, "nameMedicinalProduct", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
column(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], Product.prototype, "internalMaterialCode", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
column(),
|
|
50
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
51
|
+
__metadata("design:type", Boolean)
|
|
52
|
+
], Product.prototype, "productRecall", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
column(),
|
|
55
|
+
__metadata("design:type", Number)
|
|
56
|
+
], Product.prototype, "counter", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
oneToMany(() => ProductStrength, { update: Cascade.CASCADE, delete: Cascade.CASCADE }, false),
|
|
59
|
+
__metadata("design:type", Array)
|
|
60
|
+
], Product.prototype, "strengths", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
oneToMany(() => Market, { update: Cascade.NONE, delete: Cascade.NONE }, false),
|
|
63
|
+
__metadata("design:type", Array)
|
|
64
|
+
], Product.prototype, "markets", void 0);
|
|
65
|
+
Product = __decorate([
|
|
66
|
+
uses(FabricFlavour)
|
|
67
|
+
// @BlockOperations([OperationKeys.DELETE])
|
|
68
|
+
,
|
|
69
|
+
table(),
|
|
70
|
+
model(),
|
|
71
|
+
__metadata("design:paramtypes", [Object])
|
|
72
|
+
], Product);
|
|
73
|
+
export { Product };
|
|
74
|
+
//# sourceMappingURL=Product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Product.js","sourceRoot":"","sources":["../../../../src/contract/models/Product.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EACT,cAAc,EACd,EAAE,EACF,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,oFAAoF;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,6BAA0B;AACpD,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAClC,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAe;AAE9B,OAAO,EAAE,KAAK,EAAE,wBAAqB;AACrC,OAAO,EAAE,aAAa,EAAE,gCAA2B;AAM5C,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,mBAAmB;IA2D9C,YAAY,IAAwB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;QAvCd,kBAAa,GAAY,KAAK,CAAC;IAwC/B,CAAC;CACF,CAAA;AA1DC;IAHC,IAAI,EAAE;IACN,KAAK,EAAE;IACP,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;4CAClB;AAKrB;IAHC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;6CAC1B;AAKtB;IAHC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;qDAClB;AAG9B;IADC,MAAM,EAAE;;qDACqB;AAI9B;IAFC,MAAM,EAAE;IACR,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;;8CACjB;AAsB/B;IADC,MAAM,EAAE;;wCACQ;AAOjB;IALC,SAAS,CACR,GAAG,EAAE,CAAC,eAAe,EACrB,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,EACpD,KAAK,CACN;;0CAC6B;AAO9B;IALC,SAAS,CACR,GAAG,EAAE,CAAC,MAAM,EACZ,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,EAC9C,KAAK,CACN;;wCACkB;AAzDR,OAAO;IAJnB,IAAI,CAAC,aAAa,CAAC;IACpB,2CAA2C;;IAC1C,KAAK,EAAE;IACP,KAAK,EAAE;;GACK,OAAO,CA8DnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModelArg } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel";
|
|
3
|
+
export declare class ProductStrength extends BaseIdentifiedModel {
|
|
4
|
+
id: number;
|
|
5
|
+
productCode: string;
|
|
6
|
+
strength: string;
|
|
7
|
+
substance?: string;
|
|
8
|
+
legalEntityName?: string;
|
|
9
|
+
constructor(model?: ModelArg<ProductStrength>);
|
|
10
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { model, required } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { column, index, OrderDirection, pk, table } from "@decaf-ts/core";
|
|
12
|
+
import { TableNames } from "./constants.js";
|
|
13
|
+
import { description, uses } from "@decaf-ts/decoration";
|
|
14
|
+
import { BaseIdentifiedModel } from "./BaseIdentifiedModel.js";
|
|
15
|
+
import { FabricFlavour } from "./../../shared/index.js";
|
|
16
|
+
let ProductStrength = class ProductStrength extends BaseIdentifiedModel {
|
|
17
|
+
constructor(model) {
|
|
18
|
+
super(model);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
__decorate([
|
|
22
|
+
pk({ type: Number, generated: true }),
|
|
23
|
+
description("Unique identifier of the product strength."),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], ProductStrength.prototype, "id", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
28
|
+
description("Product code associated with this strength entry."),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], ProductStrength.prototype, "productCode", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
column(),
|
|
33
|
+
required(),
|
|
34
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
35
|
+
description("Product concentration or dosage (e.g., 500mg, 10%)."),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ProductStrength.prototype, "strength", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
column(),
|
|
40
|
+
index([OrderDirection.ASC, OrderDirection.DSC]),
|
|
41
|
+
description("Active substance related to this product strength."),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], ProductStrength.prototype, "substance", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
column(),
|
|
46
|
+
description("Legal entity name responsible for the product."),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], ProductStrength.prototype, "legalEntityName", void 0);
|
|
49
|
+
ProductStrength = __decorate([
|
|
50
|
+
uses(FabricFlavour),
|
|
51
|
+
table(TableNames.ProductStrength),
|
|
52
|
+
model(),
|
|
53
|
+
description("Represents the product’s strength and composition details."),
|
|
54
|
+
__metadata("design:paramtypes", [Object])
|
|
55
|
+
], ProductStrength);
|
|
56
|
+
export { ProductStrength };
|
|
57
|
+
//# sourceMappingURL=ProductStrength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductStrength.js","sourceRoot":"","sources":["../../../../src/contract/models/ProductStrength.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,uBAAoB;AACzC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAE5D,OAAO,EAAE,aAAa,EAAE,gCAA2B;AAM5C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,mBAAmB;IA6BtD,YAAY,KAAiC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF,CAAA;AA7BC;IAFC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACrC,WAAW,CAAC,4CAA4C,CAAC;;2CAC9C;AASZ;IAFC,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/C,WAAW,CAAC,mDAAmD,CAAC;;oDAC5C;AAMrB;IAJC,MAAM,EAAE;IACR,QAAQ,EAAE;IACV,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/C,WAAW,CAAC,qDAAqD,CAAC;;iDACjD;AAKlB;IAHC,MAAM,EAAE;IACR,KAAK,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/C,WAAW,CAAC,oDAAoD,CAAC;;kDAC/C;AAInB;IAFC,MAAM,EAAE;IACR,WAAW,CAAC,gDAAgD,CAAC;;wDACrC;AA3Bd,eAAe;IAJ3B,IAAI,CAAC,aAAa,CAAC;IACnB,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC;IACjC,KAAK,EAAE;IACP,WAAW,CAAC,4DAA4D,CAAC;;GAC7D,eAAe,CAgC3B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const DatePattern = "yyyy-MM-dd";
|
|
2
|
+
export declare const BatchPattern: RegExp;
|
|
3
|
+
export declare enum TableNames {
|
|
4
|
+
Audit = "audit",
|
|
5
|
+
Batch = "batch",
|
|
6
|
+
GtinOwner = "gtin_owner",
|
|
7
|
+
Leaflet = "leaflet",
|
|
8
|
+
LeafletFile = "leaflet_file",
|
|
9
|
+
Product = "product",
|
|
10
|
+
Market = "market",
|
|
11
|
+
ProductStrength = "product_strength"
|
|
12
|
+
}
|
|
13
|
+
export declare enum AuditOperations {
|
|
14
|
+
REMOVE = "Remove user",
|
|
15
|
+
ADD = "Add user",
|
|
16
|
+
DEACTIVATE = "Deactivate user",
|
|
17
|
+
LOGIN = "Access wallet",
|
|
18
|
+
SHARED_ENCLAVE_CREATE = "Create identity",
|
|
19
|
+
BREAK_GLASS_RECOVERY = "Wallet recovered with the break Glass Recovery Code",
|
|
20
|
+
AUTHORIZE = "Authorize integration user",
|
|
21
|
+
REVOKE = "Revoke integration user",
|
|
22
|
+
DATA_RECOVERY = "Use of the Data Recovery Key",
|
|
23
|
+
RECOVERY_KEY_COPIED = "Copy Data Recovery Key"
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const DatePattern = "yyyy-MM-dd";
|
|
2
|
+
export const BatchPattern = /^[a-zA-Z0-9/-]{1,20}$/;
|
|
3
|
+
export var TableNames;
|
|
4
|
+
(function (TableNames) {
|
|
5
|
+
TableNames["Audit"] = "audit";
|
|
6
|
+
TableNames["Batch"] = "batch";
|
|
7
|
+
TableNames["GtinOwner"] = "gtin_owner";
|
|
8
|
+
TableNames["Leaflet"] = "leaflet";
|
|
9
|
+
TableNames["LeafletFile"] = "leaflet_file";
|
|
10
|
+
TableNames["Product"] = "product";
|
|
11
|
+
TableNames["Market"] = "market";
|
|
12
|
+
TableNames["ProductStrength"] = "product_strength";
|
|
13
|
+
})(TableNames || (TableNames = {}));
|
|
14
|
+
export var AuditOperations;
|
|
15
|
+
(function (AuditOperations) {
|
|
16
|
+
AuditOperations["REMOVE"] = "Remove user";
|
|
17
|
+
AuditOperations["ADD"] = "Add user";
|
|
18
|
+
AuditOperations["DEACTIVATE"] = "Deactivate user";
|
|
19
|
+
AuditOperations["LOGIN"] = "Access wallet";
|
|
20
|
+
AuditOperations["SHARED_ENCLAVE_CREATE"] = "Create identity";
|
|
21
|
+
AuditOperations["BREAK_GLASS_RECOVERY"] = "Wallet recovered with the break Glass Recovery Code";
|
|
22
|
+
AuditOperations["AUTHORIZE"] = "Authorize integration user";
|
|
23
|
+
AuditOperations["REVOKE"] = "Revoke integration user";
|
|
24
|
+
AuditOperations["DATA_RECOVERY"] = "Use of the Data Recovery Key";
|
|
25
|
+
AuditOperations["RECOVERY_KEY_COPIED"] = "Copy Data Recovery Key";
|
|
26
|
+
})(AuditOperations || (AuditOperations = {}));
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/contract/models/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAEpD,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,6BAAe,CAAA;IACf,sCAAwB,CAAA;IACxB,iCAAmB,CAAA;IACnB,0CAA4B,CAAA;IAC5B,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,kDAAoC,CAAA;AACtC,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,yCAAsB,CAAA;IACtB,mCAAgB,CAAA;IAChB,iDAA8B,CAAA;IAC9B,0CAAuB,CAAA;IACvB,4DAAyC,CAAA;IACzC,+FAA4E,CAAA;IAC5E,2DAAwC,CAAA;IACxC,qDAAkC,CAAA;IAClC,iEAA8C,CAAA;IAC9C,iEAA8C,CAAA;AAChD,CAAC,EAXW,eAAe,KAAf,eAAe,QAW1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { IRepository } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { Repository } from "@decaf-ts/core";
|
|
4
|
+
import { FabricContractContext } from "../../contracts/index";
|
|
5
|
+
export declare function createAuditHandler<M extends Model, R extends Repository<M, any>, V>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
|
|
6
|
+
export declare function updateAuditHandler<M extends Model, R extends IRepository<M, any>, V>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M, oldModel: M): Promise<void>;
|
|
7
|
+
export declare function deleteAuditHandler<M extends Model, R extends IRepository<M, any>, V>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
|
|
8
|
+
export declare function audit(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { metadata, apply } from "@decaf-ts/decoration";
|
|
3
|
+
import { afterCreate, afterDelete, afterUpdate, InternalError, OperationKeys, } from "@decaf-ts/db-decorators";
|
|
4
|
+
import { Audit } from "./Audit.js";
|
|
5
|
+
import { Repository } from "@decaf-ts/core";
|
|
6
|
+
export async function createAuditHandler(context, data, key, model) {
|
|
7
|
+
const repo = Repository.forModel(Audit);
|
|
8
|
+
if (!context.identity || !context.identity.getID)
|
|
9
|
+
throw new InternalError(`Lost context apprently. no getId in identity`);
|
|
10
|
+
const toCreate = new Audit({
|
|
11
|
+
userGroup: context.identity.getID(),
|
|
12
|
+
userId: context.identity.getID(),
|
|
13
|
+
action: OperationKeys.CREATE,
|
|
14
|
+
diffs: new this.class().compare(model),
|
|
15
|
+
});
|
|
16
|
+
const audit = await repo.create(toCreate, context);
|
|
17
|
+
context.logger.info(`Audit log for ${OperationKeys.CREATE} of ${Model.tableName(this.class)} created: ${audit.id}: ${JSON.stringify(audit, undefined, 2)}`);
|
|
18
|
+
}
|
|
19
|
+
export async function updateAuditHandler(context, data, key, model, oldModel) {
|
|
20
|
+
if (!context.identity || !context.identity.getID)
|
|
21
|
+
throw new InternalError(`Lost context apprently. no getId in identity`);
|
|
22
|
+
const toCreate = new Audit({
|
|
23
|
+
userGroup: context.identity.getID(),
|
|
24
|
+
userId: context.identity.getID(),
|
|
25
|
+
action: OperationKeys.UPDATE,
|
|
26
|
+
diffs: model.compare(oldModel),
|
|
27
|
+
});
|
|
28
|
+
const repo = Repository.forModel(Audit);
|
|
29
|
+
const audit = await repo.create(toCreate, context);
|
|
30
|
+
context.logger.info(`Audit log for ${OperationKeys.UPDATE} of ${Model.tableName(this.class)} created: ${JSON.stringify(audit, undefined, 2)}`);
|
|
31
|
+
}
|
|
32
|
+
export async function deleteAuditHandler(context, data, key, model) {
|
|
33
|
+
if (!context.identity || !context.identity.getID)
|
|
34
|
+
throw new InternalError(`Lost context apprently. no getId in identity`);
|
|
35
|
+
const toCreate = new Audit({
|
|
36
|
+
userGroup: context.identity.getID(),
|
|
37
|
+
userId: context.identity.getID(),
|
|
38
|
+
action: OperationKeys.DELETE,
|
|
39
|
+
diffs: model.compare(new this.class()),
|
|
40
|
+
});
|
|
41
|
+
const repo = Repository.forModel(Audit);
|
|
42
|
+
const audit = await repo.create(toCreate, context);
|
|
43
|
+
context.logger.info(`Audit log for ${OperationKeys.DELETE} of ${Model.tableName(this.class)} created: ${JSON.stringify(audit, undefined, 2)}`);
|
|
44
|
+
}
|
|
45
|
+
export function audit() {
|
|
46
|
+
return apply(afterCreate(createAuditHandler, {}), afterUpdate(updateAuditHandler, {}), afterDelete(deleteAuditHandler, {}), metadata("audit", true));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/contract/models/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EAEb,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAMtC,OAA8B,EAC9B,IAAO,EACP,GAAY,EACZ,KAAQ;IAER,MAAM,IA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,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAC1H,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,OAAO,KAAK,CACV,WAAW,CAAC,kBAAyB,EAAE,EAAE,CAAC,EAC1C,WAAW,CAAC,kBAAyB,EAAE,EAAE,CAAC,EAC1C,WAAW,CAAC,kBAAyB,EAAE,EAAE,CAAC,EAC1C,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Validator, ValidatorOptions } from "@decaf-ts/decorator-validation";
|
|
2
|
+
export declare class GtinValidator extends Validator {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
hasErrors(value: number | string, options?: ValidatorOptions): string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare const gtin: (message?: string) => (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
|
|
7
|
+
export declare function generateGtin(): string;
|
|
8
|
+
export declare function getBatch(): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { innerValidationDecorator, required, Validator, validator, } from "@decaf-ts/decorator-validation";
|
|
11
|
+
import { readonly } from "@decaf-ts/db-decorators";
|
|
12
|
+
import { apply } from "@decaf-ts/decoration";
|
|
13
|
+
const GTIN_VALIDATION_KEY = "gtin";
|
|
14
|
+
const GTIN_VALIDATION_ERROR_MESSAGE = "Not a valid Gtin";
|
|
15
|
+
let GtinValidator = class GtinValidator extends Validator {
|
|
16
|
+
constructor(message = GTIN_VALIDATION_ERROR_MESSAGE) {
|
|
17
|
+
super(message, "string", "number");
|
|
18
|
+
}
|
|
19
|
+
hasErrors(value, options) {
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
return;
|
|
22
|
+
const { message } = options || {};
|
|
23
|
+
const gtin = value + "";
|
|
24
|
+
if (!gtin.match(/\d{14}/g))
|
|
25
|
+
return this.getMessage(message || this.message);
|
|
26
|
+
const digits = gtin.slice(0, 13);
|
|
27
|
+
const checksum = calculateGtinCheckSum(digits);
|
|
28
|
+
return parseInt(checksum) === parseInt(gtin.charAt(13))
|
|
29
|
+
? undefined
|
|
30
|
+
: this.getMessage(message || this.message);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
GtinValidator = __decorate([
|
|
34
|
+
validator(GTIN_VALIDATION_KEY),
|
|
35
|
+
__metadata("design:paramtypes", [String])
|
|
36
|
+
], GtinValidator);
|
|
37
|
+
export { GtinValidator };
|
|
38
|
+
export const gtin = (message = GTIN_VALIDATION_ERROR_MESSAGE) => {
|
|
39
|
+
return apply(required(), readonly(), innerValidationDecorator(gtin, GTIN_VALIDATION_KEY, {
|
|
40
|
+
message: message,
|
|
41
|
+
async: false,
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
// https://www.gs1.org/services/how-calculate-check-digit-manually
|
|
45
|
+
function calculateGtinCheckSum(digits) {
|
|
46
|
+
digits = "" + digits;
|
|
47
|
+
if (digits.length !== 13)
|
|
48
|
+
throw new Error("needs to received 13 digits");
|
|
49
|
+
const multiplier = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3];
|
|
50
|
+
let sum = 0;
|
|
51
|
+
try {
|
|
52
|
+
// multiply each digit for its multiplier according to the table
|
|
53
|
+
for (let i = 0; i < 13; i++)
|
|
54
|
+
sum += parseInt(digits.charAt(i)) * multiplier[i];
|
|
55
|
+
// Find the nearest equal or higher multiple of ten
|
|
56
|
+
const remainder = sum % 10;
|
|
57
|
+
let nearest;
|
|
58
|
+
if (remainder === 0)
|
|
59
|
+
nearest = sum;
|
|
60
|
+
else
|
|
61
|
+
nearest = sum - remainder + 10;
|
|
62
|
+
return nearest - sum + "";
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new Error(`Did this received numbers? ${e}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function generateGtin() {
|
|
69
|
+
function pad(num, width, padding = "0") {
|
|
70
|
+
const n = num + "";
|
|
71
|
+
return n.length >= width
|
|
72
|
+
? n
|
|
73
|
+
: new Array(width - n.length + 1).join(padding) + n;
|
|
74
|
+
}
|
|
75
|
+
const beforeChecksum = pad(Math.floor(Math.random() * 9999999999999), 13); // has to be 13. the checksum is the 4th digit
|
|
76
|
+
const checksum = calculateGtinCheckSum(beforeChecksum);
|
|
77
|
+
return `${beforeChecksum}${checksum}`;
|
|
78
|
+
}
|
|
79
|
+
export function getBatch() {
|
|
80
|
+
return Math.random().toString(36).replace(".", "").toUpperCase().slice(5);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=gtin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtin.js","sourceRoot":"","sources":["../../../../src/contract/models/gtin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,wBAAwB,EACxB,QAAQ,EACR,SAAS,EACT,SAAS,GAEV,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AA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ACH,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,8CAA8C;IACzH,MAAM,QAAQ,GAAG,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACvD,OAAO,GAAG,cAAc,GAAG,QAAQ,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -124,12 +124,6 @@ export declare class FabricContractAdapter extends CouchDBAdapter<any, void, Fab
|
|
|
124
124
|
*/
|
|
125
125
|
repository<R extends Repository<any, Adapter<any, void, MangoQuery, Context<FabricContractFlags>>>>(): Constructor<R>;
|
|
126
126
|
Paginator<M extends Model>(query: MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
|
|
127
|
-
/**
|
|
128
|
-
* @description Creates a sequence generator
|
|
129
|
-
* @summary Factory method that creates a sequence generator for generating sequential values
|
|
130
|
-
* @param {SequenceOptions} options - Configuration options for the sequence
|
|
131
|
-
* @return {Promise<Sequence>} A promise that resolves to a new sequence instance
|
|
132
|
-
*/
|
|
133
127
|
Sequence(options: SequenceOptions): Promise<Sequence>;
|
|
134
128
|
/**
|
|
135
129
|
* @description Creates a new FabricContractAdapter instance
|
|
@@ -179,7 +173,7 @@ export declare class FabricContractAdapter extends CouchDBAdapter<any, void, Fab
|
|
|
179
173
|
* @return {Promise<Record<string, any>>} Promise resolving to the deleted record
|
|
180
174
|
*/
|
|
181
175
|
delete<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<FabricContractFlags>>): Promise<Record<string, any>>;
|
|
182
|
-
protected deleteState(id: string,
|
|
176
|
+
protected deleteState(id: string, context: FabricContractContext): Promise<void>;
|
|
183
177
|
forPrivate(collection: string): FabricContractAdapter;
|
|
184
178
|
protected putState(id: string, model: Record<string, any>, ctx: FabricContractContext): Promise<Record<string, any>>;
|
|
185
179
|
protected readState(id: string, ctx: FabricContractContext): Promise<any>;
|