@unchainedshop/utils 3.1.1 → 3.1.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 (60) hide show
  1. package/lib/build-obfuscated-fields-filter.d.ts.map +1 -1
  2. package/lib/calculation.d.ts.map +1 -1
  3. package/lib/ch/addressToString.d.ts.map +1 -1
  4. package/lib/ch/priceToString.d.ts.map +1 -1
  5. package/lib/director/BaseDirector.d.ts.map +1 -1
  6. package/lib/find-unused-slug.d.ts.map +1 -1
  7. package/lib/locale-helpers.d.ts.map +1 -1
  8. package/lib/object-invert.d.ts.map +1 -1
  9. package/lib/pipe-promises.d.ts.map +1 -1
  10. package/lib/sha1.d.ts +1 -1
  11. package/lib/sha1.d.ts.map +1 -1
  12. package/package.json +3 -4
  13. package/src/calculation.test.ts +31 -65
  14. package/src/director/base-director.test.ts +18 -24
  15. package/src/utils-index.test.ts +12 -10
  16. package/jest.config.js +0 -17
  17. package/lib/director/BaseDiscountAdapter.d.ts +0 -3
  18. package/lib/director/BaseDiscountAdapter.d.ts.map +0 -1
  19. package/lib/director/BaseDiscountAdapter.js +0 -48
  20. package/lib/director/BaseDiscountAdapter.js.map +0 -1
  21. package/lib/director/BaseDiscountDirector.d.ts +0 -3
  22. package/lib/director/BaseDiscountDirector.d.ts.map +0 -1
  23. package/lib/director/BaseDiscountDirector.js +0 -50
  24. package/lib/director/BaseDiscountDirector.js.map +0 -1
  25. package/lib/director/BasePricingAdapter.d.ts +0 -3
  26. package/lib/director/BasePricingAdapter.d.ts.map +0 -1
  27. package/lib/director/BasePricingAdapter.js +0 -25
  28. package/lib/director/BasePricingAdapter.js.map +0 -1
  29. package/lib/director/BasePricingDirector.d.ts +0 -3
  30. package/lib/director/BasePricingDirector.d.ts.map +0 -1
  31. package/lib/director/BasePricingDirector.js +0 -61
  32. package/lib/director/BasePricingDirector.js.map +0 -1
  33. package/lib/director/BasePricingSheet.d.ts +0 -3
  34. package/lib/director/BasePricingSheet.d.ts.map +0 -1
  35. package/lib/director/BasePricingSheet.js +0 -54
  36. package/lib/director/BasePricingSheet.js.map +0 -1
  37. package/lib/random-value-hex.d.ts +0 -2
  38. package/lib/random-value-hex.d.ts.map +0 -1
  39. package/lib/random-value-hex.js +0 -8
  40. package/lib/random-value-hex.js.map +0 -1
  41. package/lib/schemas/AddressSchema.d.ts +0 -3
  42. package/lib/schemas/AddressSchema.d.ts.map +0 -1
  43. package/lib/schemas/AddressSchema.js +0 -13
  44. package/lib/schemas/AddressSchema.js.map +0 -1
  45. package/lib/schemas/ContactSchema.d.ts +0 -3
  46. package/lib/schemas/ContactSchema.d.ts.map +0 -1
  47. package/lib/schemas/ContactSchema.js +0 -6
  48. package/lib/schemas/ContactSchema.js.map +0 -1
  49. package/lib/schemas/UsersSchema.d.ts +0 -5
  50. package/lib/schemas/UsersSchema.d.ts.map +0 -1
  51. package/lib/schemas/UsersSchema.js +0 -52
  52. package/lib/schemas/UsersSchema.js.map +0 -1
  53. package/lib/schemas/commonSchemaFields.d.ts +0 -35
  54. package/lib/schemas/commonSchemaFields.d.ts.map +0 -1
  55. package/lib/schemas/commonSchemaFields.js +0 -28
  56. package/lib/schemas/commonSchemaFields.js.map +0 -1
  57. package/lib/schemas/index.d.ts +0 -43
  58. package/lib/schemas/index.d.ts.map +0 -1
  59. package/lib/schemas/index.js +0 -14
  60. package/lib/schemas/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"build-obfuscated-fields-filter.d.ts","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,2BAA2B,0BAA0B,MAAM,EAAE,uBA2BlE,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"build-obfuscated-fields-filter.d.ts","sourceRoot":"","sources":["../src/build-obfuscated-fields-filter.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,2BAA2B,GAAI,uBAAsB,MAAM,EAAO,uBA2BvE,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"calculation.d.ts","sourceRoot":"","sources":["../src/calculation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,aAAa,MAAM,WAClB,CAAC;AAE3C,eAAO,MAAM,sBAAsB,kBAClB;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,UAC5C,MAAM,WAQf,CAAC;AAEF,eAAO,MAAM,SAAS,kBAAmB;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,wBAG7E,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,MAAM,QAAQ,MAAM,cAAc,OAAO,WAE5E,CAAC;AAEF,eAAO,MAAM,mBAAmB,0BACP;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,UACtD,MAAM,aAMf,CAAC;AAEF,eAAO,MAAM,6BAA6B,mCAQzC,CAAC"}
1
+ {"version":3,"file":"calculation.d.ts","sourceRoot":"","sources":["../src/calculation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,WAAW,MAAM,WAClB,CAAC;AAE3C,eAAO,MAAM,sBAAsB,GACjC,eAAe;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACpD,QAAQ,MAAM,WAQf,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,eAAe;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,WAAM,WAGrF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,EAAE,YAAY,OAAO,WAE5E,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,uBAAuB;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9D,QAAQ,MAAM,aAMf,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,WAAM,EAAE,WAAM,QAQ3D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"addressToString.d.ts","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,YAAa;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,WAYA,CAAC"}
1
+ {"version":3,"file":"addressToString.d.ts","sourceRoot":"","sources":["../../src/ch/addressToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,SAAS;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,WAYA,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"priceToString.d.ts","sourceRoot":"","sources":["../../src/ch/priceToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,yBAA0B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,WAGvF,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"priceToString.d.ts","sourceRoot":"","sources":["../../src/ch/priceToString.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,sBAAsB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,WAGvF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,YAAY;IACzD,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7F,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,YAAY,gBAC7C,MAAM,YACV;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KACA,aAAa,CAAC,WAAW,CAwB3B,CAAC"}
1
+ {"version":3,"file":"BaseDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,YAAY;IACzD,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7F,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAED,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,YAAY,EAC3D,cAAc,MAAM,EACpB,UAAU;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,KACA,aAAa,CAAC,WAAW,CAwB3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"find-unused-slug.d.ts","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"8CAcuB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,eAC1C;IAAE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,KAClD,CAAC,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAH5F,wBAuBE"}
1
+ {"version":3,"file":"find-unused-slug.d.ts","sourceRoot":"","sources":["../src/find-unused-slug.ts"],"names":[],"mappings":"yBAcE,qBAAqB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACvD,aAAa;IAAE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,KAClD,CAAC,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAH5F,wBAuBE"}
@@ -1 +1 @@
1
- {"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,aAA4D,CAAC;AAEtF,eAAO,MAAM,oBAAoB,mBACf,MAAM,oBACJ,KAAK,CAAC,MAAM,CAAC,kBACf,MAAM,KACrB,IAAI,CAAC,MAKP,CAAC;AAEF,eAAO,MAAM,kBAAkB,kBACd,MAAM,eACR,MAAM,aACR,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,WActC,CAAC;AAEF,eAAO,MAAM,mBAAmB,mBAAoB,MAAM,cAAc,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,WAcjG,CAAC"}
1
+ {"version":3,"file":"locale-helpers.d.ts","sourceRoot":"","sources":["../src/locale-helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,aAA4D,CAAC;AAEtF,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,MAAM,EACtB,kBAAkB,KAAK,CAAC,MAAM,CAAC,EAC/B,gBAAgB,MAAM,KACrB,IAAI,CAAC,MAKP,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,eAAe,MAAM,EACrB,aAAa,MAAM,EACnB,WAAW,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,WActC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,gBAAgB,MAAM,EAAE,YAAY,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,WAcjG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"object-invert.d.ts","sourceRoot":"","sources":["../src/object-invert.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,iBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAK7E,CAAC;AAET,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"object-invert.d.ts","sourceRoot":"","sources":["../src/object-invert.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,GAAI,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAK7E,CAAC;AAET,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pipe-promises.d.ts","sourceRoot":"","sources":["../src/pipe-promises.ts"],"names":[],"mappings":";AAAA,wBACuE"}
1
+ {"version":3,"file":"pipe-promises.d.ts","sourceRoot":"","sources":["../src/pipe-promises.ts"],"names":[],"mappings":"yBAAgB,QAAG,MAAM,iBAAY;AAArC,wBACuE"}
package/lib/sha1.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export default function sha1(message: any): Promise<Buffer<ArrayBufferLike>>;
1
+ export default function sha1(message: any): Promise<Buffer<ArrayBuffer>>;
2
2
  //# sourceMappingURL=sha1.d.ts.map
package/lib/sha1.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sha1.d.ts","sourceRoot":"","sources":["../src/sha1.ts"],"names":[],"mappings":"AAAA,wBAA8B,IAAI,CAAC,OAAO,KAAA,oCAIzC"}
1
+ {"version":3,"file":"sha1.d.ts","sourceRoot":"","sources":["../src/sha1.ts"],"names":[],"mappings":"AAAA,wBAA8B,IAAI,CAAC,OAAO,KAAA,gCAIzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/utils",
3
- "version": "3.1.1",
3
+ "version": "3.1.5",
4
4
  "main": "lib/utils-index.js",
5
5
  "types": "lib/utils-index.d.ts",
6
6
  "type": "module",
@@ -9,8 +9,8 @@
9
9
  "build": "tsc -b",
10
10
  "prepublishOnly": "npm run clean && npm run build",
11
11
  "watch": "tsc -w",
12
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
13
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --detectOpenHandles --forceExit"
12
+ "test": "tsx --test",
13
+ "test:watch": "tsx --test --watch"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -33,7 +33,6 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^22.13.4",
36
- "jest": "^29.7.0",
37
36
  "typescript": "^5.7.3"
38
37
  }
39
38
  }
@@ -1,3 +1,6 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import {
2
5
  applyRate,
3
6
  roundToNext,
@@ -8,63 +11,63 @@ import {
8
11
 
9
12
  describe('roundToNext', () => {
10
13
  it('rounds to the next multiple of precision correctly when the value is positive', () => {
11
- expect(roundToNext(5, 2)).toBe(6);
12
- expect(roundToNext(10, 5)).toBe(10);
13
- expect(roundToNext(13, 5)).toBe(15);
14
+ assert.strictEqual(roundToNext(5, 2), 6);
15
+ assert.strictEqual(roundToNext(10, 5), 10);
16
+ assert.strictEqual(roundToNext(13, 5), 15);
14
17
  });
15
18
 
16
19
  it('rounds to the next multiple of precision correctly when the value is negative', () => {
17
- expect(roundToNext(-5, 2)).toBe(-4);
18
- expect(roundToNext(-10, 5)).toBe(-10);
19
- expect(roundToNext(-13, 5)).toBe(-10);
20
+ assert.strictEqual(roundToNext(-5, 2), -4);
21
+ assert.strictEqual(roundToNext(-10, 5), -10);
22
+ assert.strictEqual(roundToNext(-13, 5), -10);
20
23
  });
21
24
 
22
25
  it('returns 0 when the value is 0', () => {
23
- expect(roundToNext(0, 5)).toBe(0);
26
+ assert.strictEqual(roundToNext(0, 5), 0);
24
27
  });
25
28
 
26
29
  it('returns the same value when the precision is 1', () => {
27
- expect(roundToNext(5, 1)).toBe(5);
30
+ assert.strictEqual(roundToNext(5, 1), 5);
28
31
  });
29
32
  });
30
33
 
31
34
  describe('resolveAmountAndTax', () => {
32
35
  it('ratio is 0 and taxDivisor is 0', () => {
33
36
  const result = resolveAmountAndTax({ ratio: 0, taxDivisor: 0 }, 100);
34
- expect(result).toEqual([0, 0]);
37
+ assert.deepStrictEqual(result, [0, 0]);
35
38
  });
36
39
 
37
40
  it('ratio is not 0 and taxDivisor is 0', () => {
38
41
  const result = resolveAmountAndTax({ ratio: 0.5, taxDivisor: 0 }, 100);
39
- expect(result).toEqual([50, 0]);
42
+ assert.deepStrictEqual(result, [50, 0]);
40
43
  });
41
44
 
42
45
  it('ratio is 0 and taxDivisor is not 0', () => {
43
46
  const result = resolveAmountAndTax({ ratio: 0, taxDivisor: 2 }, 100);
44
- expect(result).toEqual([0, 0]);
47
+ assert.deepStrictEqual(result, [0, 0]);
45
48
  });
46
49
 
47
50
  it('ratio and taxDivisor are not 0', () => {
48
51
  const result = resolveAmountAndTax({ ratio: 0.5, taxDivisor: 2 }, 100);
49
- expect(result).toEqual([50, 25]);
52
+ assert.deepStrictEqual(result, [50, 25]);
50
53
  });
51
54
 
52
55
  it('ratio and taxDivisor are not finite number', () => {
53
56
  const result = resolveAmountAndTax({ ratio: Number.NaN, taxDivisor: Number.NaN }, 100);
54
- expect(result).toEqual([0, 0]);
57
+ assert.deepStrictEqual(result, [0, 0]);
55
58
  });
56
59
  });
57
60
 
58
- describe('resolveAmountAndTax', () => {
61
+ describe('applyDiscountToMultipleShares', () => {
59
62
  it('shares are empty', () => {
60
63
  const result = applyDiscountToMultipleShares([], 100);
61
- expect(result).toEqual([0, 0]);
64
+ assert.deepStrictEqual(result, [0, 0]);
62
65
  });
63
66
 
64
67
  it('shares have one share', () => {
65
68
  const shares = [{ ratio: 0.5, taxDivisor: 2 }];
66
69
  const result = applyDiscountToMultipleShares(shares, 100);
67
- expect(result).toEqual([50, 25]);
70
+ assert.deepStrictEqual(result, [50, 25]);
68
71
  });
69
72
 
70
73
  it('shares have multiple shares', () => {
@@ -73,7 +76,7 @@ describe('resolveAmountAndTax', () => {
73
76
  { ratio: 0.2, taxDivisor: 1.5 },
74
77
  ];
75
78
  const result = applyDiscountToMultipleShares(shares, 100);
76
- expect(result).toEqual([70, 31.666666666666664]);
79
+ assert.deepStrictEqual(result, [70, 31.666666666666664]);
77
80
  });
78
81
  });
79
82
 
@@ -83,7 +86,7 @@ describe('applyRate', () => {
83
86
  rate: 0.1,
84
87
  };
85
88
  const amount = 100;
86
- expect(applyRate(configuration, amount)).toBe(10);
89
+ assert.strictEqual(applyRate(configuration, amount), 10);
87
90
  });
88
91
 
89
92
  it('applies the fixed rate correctly when a fixed rate is provided', () => {
@@ -91,7 +94,7 @@ describe('applyRate', () => {
91
94
  fixedRate: 50,
92
95
  };
93
96
  const amount = 100;
94
- expect(applyRate(configuration, amount)).toBe(50);
97
+ assert.strictEqual(applyRate(configuration, amount), 50);
95
98
  });
96
99
 
97
100
  it('applies the fixed rate correctly when a fixed rate is provided and the amount is less than fixed rate', () => {
@@ -99,7 +102,7 @@ describe('applyRate', () => {
99
102
  fixedRate: 150,
100
103
  };
101
104
  const amount = 100;
102
- expect(applyRate(configuration, amount)).toBe(100);
105
+ assert.strictEqual(applyRate(configuration, amount), 100);
103
106
  });
104
107
 
105
108
  it('applies the rate correctly when rate is less than or equal to 0', () => {
@@ -107,44 +110,7 @@ describe('applyRate', () => {
107
110
  rate: -0.1,
108
111
  };
109
112
  const amount = 100;
110
- expect(applyRate(configuration, amount)).toBe(-10);
111
- });
112
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
113
- const configuration = {
114
- rate: 0.1,
115
- };
116
- const amount = -100;
117
- expect(applyRate(configuration, amount)).toBe(-10);
118
- });
119
-
120
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
121
- const configuration = {
122
- rate: 0.1,
123
- };
124
- const amount = -100;
125
- expect(applyRate(configuration, amount)).toBe(-10);
126
- });
127
-
128
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
129
- const configuration = {
130
- rate: 0.1,
131
- };
132
- const amount = -100;
133
- expect(applyRate(configuration, amount)).toBe(-10);
134
- });
135
-
136
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
137
- const configuration = {
138
- rate: 0.1,
139
- };
140
- const amount = -100;
141
- expect(applyRate(configuration, amount)).toBe(-10);
142
- });
143
-
144
- it('returns 0 when rate and fixed rate are not provided', () => {
145
- const configuration = {};
146
- const amount = 100;
147
- expect(applyRate(configuration, amount)).toBe(0);
113
+ assert.strictEqual(applyRate(configuration, amount), -10);
148
114
  });
149
115
 
150
116
  it('applies the rate correctly when only rate is provided and amount is negative', () => {
@@ -152,13 +118,13 @@ describe('applyRate', () => {
152
118
  rate: 0.1,
153
119
  };
154
120
  const amount = -100;
155
- expect(applyRate(configuration, amount)).toBe(-10);
121
+ assert.strictEqual(applyRate(configuration, amount), -10);
156
122
  });
157
123
 
158
124
  it('returns 0 when rate and fixed rate are not provided', () => {
159
125
  const configuration = {};
160
126
  const amount = 100;
161
- expect(applyRate(configuration, amount)).toBe(0);
127
+ assert.strictEqual(applyRate(configuration, amount), 0);
162
128
  });
163
129
  });
164
130
 
@@ -168,7 +134,7 @@ describe('calculateAmountToSplit', () => {
168
134
  rate: 0.1,
169
135
  };
170
136
  const amount = 1000;
171
- expect(calculateAmountToSplit(configuration, amount)).toBe(100);
137
+ assert.strictEqual(calculateAmountToSplit(configuration, amount), 100);
172
138
  });
173
139
 
174
140
  it('calculates the correct amount to split when using a fixed rate', () => {
@@ -176,7 +142,7 @@ describe('calculateAmountToSplit', () => {
176
142
  fixedRate: 50,
177
143
  };
178
144
  const amount = 1000;
179
- expect(calculateAmountToSplit(configuration, amount)).toBe(50);
145
+ assert.strictEqual(calculateAmountToSplit(configuration, amount), 50);
180
146
  });
181
147
 
182
148
  it('returns 0 when the amount is less than or equal to 0', () => {
@@ -184,7 +150,7 @@ describe('calculateAmountToSplit', () => {
184
150
  rate: 0.1,
185
151
  };
186
152
  const amount = 0;
187
- expect(calculateAmountToSplit(configuration, amount)).toBe(0);
153
+ assert.strictEqual(calculateAmountToSplit(configuration, amount), 0);
188
154
  });
189
155
 
190
156
  it('returns 0 when amount is negative', () => {
@@ -192,7 +158,7 @@ describe('calculateAmountToSplit', () => {
192
158
  rate: 0.1,
193
159
  };
194
160
  const amount = -1000;
195
- expect(calculateAmountToSplit(configuration, amount)).toBe(0);
161
+ assert.strictEqual(calculateAmountToSplit(configuration, amount), 0);
196
162
  });
197
163
 
198
164
  it('returns 0 when configuration rate is negative', () => {
@@ -200,6 +166,6 @@ describe('calculateAmountToSplit', () => {
200
166
  rate: -0.1,
201
167
  };
202
168
  const amount = 1000;
203
- expect(calculateAmountToSplit(configuration, amount)).toBe(0);
169
+ assert.strictEqual(calculateAmountToSplit(configuration, amount), 0);
204
170
  });
205
171
  });
@@ -1,24 +1,26 @@
1
+ import { describe, it, beforeEach } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { BaseDirector } from './BaseDirector.js';
2
4
 
3
5
  const adapter1 = {
4
6
  key: 'adapter1',
5
7
  label: 'Adapter 1',
6
8
  version: '1',
7
- log: import.meta.jest.fn(),
9
+ log: () => ({}),
8
10
  };
9
11
 
10
12
  const adapter2 = {
11
13
  key: 'adapter2',
12
14
  label: 'Adapter 2',
13
15
  version: '2',
14
- log: import.meta.jest.fn(),
16
+ log: () => ({}),
15
17
  };
16
18
 
17
19
  const adapter3 = {
18
20
  key: 'adapter3',
19
21
  label: 'Adapter 3',
20
22
  version: '3',
21
- log: import.meta.jest.fn(),
23
+ log: () => ({}),
22
24
  };
23
25
 
24
26
  describe('BaseDirector', () => {
@@ -34,21 +36,16 @@ describe('BaseDirector', () => {
34
36
  describe('registerAdapter', () => {
35
37
  it('should add the adapter to the director', () => {
36
38
  director.registerAdapter(adapter1);
37
- expect(director.getAdapter(adapter1.key)).toBe(adapter1);
38
- });
39
-
40
- xit('should generate a log message when an adapter is registered', () => {
41
- const spy = import.meta.jest.spyOn(console, 'log');
42
- expect(spy).toHaveBeenCalledWith('TestDirector -> Registered adapter1 1.0.0 (Adapter 1)');
39
+ assert.strictEqual(director.getAdapter(adapter1.key), adapter1);
43
40
  });
44
41
 
45
42
  it('should allow multiple adapters to be registered', () => {
46
- expect(director.getAdapter(adapter1.key)).toBe(adapter1);
47
- expect(director.getAdapter(adapter2.key)).toBe(adapter2);
43
+ assert.strictEqual(director.getAdapter(adapter1.key), adapter1);
44
+ assert.strictEqual(director.getAdapter(adapter2.key), adapter2);
48
45
  });
49
46
 
50
47
  it('should register an adapter and add it to the internal map', () => {
51
- expect(director.getAdapter(adapter1.key)).toEqual(adapter1);
48
+ assert.deepStrictEqual(director.getAdapter(adapter1.key), adapter1);
52
49
  });
53
50
 
54
51
  it('should use the adapterKeyField specified in the options to store the adapter in the internal map', () => {
@@ -56,7 +53,7 @@ describe('BaseDirector', () => {
56
53
  adapterKeyField: 'label',
57
54
  });
58
55
  director.registerAdapter(adapter1);
59
- expect(director.getAdapter(adapter1.label)).toEqual(adapter1);
56
+ assert.deepStrictEqual(director.getAdapter(adapter1.label), adapter1);
60
57
  });
61
58
 
62
59
  it('should return the correct Adapter object', () => {
@@ -65,46 +62,43 @@ describe('BaseDirector', () => {
65
62
  director = BaseDirector(directorName, { adapterKeyField });
66
63
  director.registerAdapter(adapter1);
67
64
 
68
- expect(director.getAdapter(adapter1.key)).toEqual(adapter1);
65
+ assert.deepStrictEqual(director.getAdapter(adapter1.key), adapter1);
69
66
  });
70
67
 
71
68
  it('should return undefined if the Adapter does not exist', () => {
72
69
  const directorName = 'TestDirector';
73
70
  const adapterKeyField = 'key';
74
71
  director = BaseDirector(directorName, { adapterKeyField });
75
- expect(director.getAdapter(adapter1.key)).toBeUndefined();
72
+ assert.strictEqual(director.getAdapter(adapter1.key), undefined);
76
73
  });
77
74
  });
78
75
 
79
76
  describe('getAdapter', () => {
80
77
  it('should return the correct Adapter object for a given key', () => {
81
- // Expect that calling getAdapter with the key 'foo' returns the fooAdapter
82
- expect(director.getAdapter(adapter1.key)).toBe(adapter1);
78
+ assert.strictEqual(director.getAdapter(adapter1.key), adapter1);
83
79
  });
84
80
 
85
81
  it('should return undefined if no Adapter is registered with the given key', () => {
86
- // Expect that calling getAdapter with a key that has not been registered returns undefined
87
- expect(director.getAdapter('invalid-key')).toBeUndefined();
82
+ assert.strictEqual(director.getAdapter('invalid-key'), undefined);
88
83
  });
89
84
 
90
85
  it('should return the correct Adapter object when the keyField is set to a property other than "key"', () => {
91
- // Create a director with the keyField option set to 'label'
92
86
  director = BaseDirector('TestDirector', { adapterKeyField: 'label' });
93
87
  director.registerAdapter(adapter1);
94
- expect(director.getAdapter(adapter1.label)).toBe(adapter1);
88
+ assert.strictEqual(director.getAdapter(adapter1.label), adapter1);
95
89
  });
96
90
  });
97
91
 
98
92
  describe('getAdapters', () => {
99
93
  it('should return an array of registered Adapter objects', () => {
100
- expect(director.getAdapters()).toEqual([adapter1, adapter3, adapter2]);
94
+ assert.deepStrictEqual(director.getAdapters(), [adapter1, adapter3, adapter2]);
101
95
  });
102
96
 
103
97
  it('should return an empty array if no Adapter objects have been registered', () => {
104
98
  const directorName = 'TestDirector';
105
99
  const adapterKeyField = 'key';
106
100
  const baseDirector = BaseDirector(directorName, { adapterKeyField });
107
- expect(baseDirector.getAdapters()).toEqual([]);
101
+ assert.deepStrictEqual(baseDirector.getAdapters(), []);
108
102
  });
109
103
 
110
104
  it('should return an array of registered Adapter objects sorted by the adapterSortKey provided', () => {
@@ -112,7 +106,7 @@ describe('BaseDirector', () => {
112
106
  director.registerAdapter(adapter1);
113
107
  director.registerAdapter(adapter3);
114
108
  director.registerAdapter(adapter2);
115
- expect(director.getAdapters()).toEqual([adapter1, adapter2, adapter3]);
109
+ assert.deepStrictEqual(director.getAdapters(), [adapter1, adapter2, adapter3]);
116
110
  });
117
111
  });
118
112
  });
@@ -1,19 +1,21 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { resolveBestCountry, resolveBestSupported, slugify, systemLocale } from './utils-index.js';
2
4
  import generateHashId from './generate-random-hash.js';
3
5
 
4
6
  describe('Utils', () => {
5
7
  it('Locale', () => {
6
- expect(systemLocale).toBeDefined();
7
- expect(resolveBestCountry).toBeInstanceOf(Function);
8
- expect(resolveBestSupported).toBeInstanceOf(Function);
8
+ assert.ok(systemLocale);
9
+ assert.equal(typeof resolveBestCountry, 'function');
10
+ assert.equal(typeof resolveBestSupported, 'function');
9
11
  });
10
12
 
11
13
  describe('generateHashId', () => {
12
- it('should create a random hash ', () => {
14
+ it('should create a random hash', () => {
13
15
  const result = generateHashId();
14
16
 
15
- expect(typeof result).toBe('string');
16
- expect(result).toMatch(/^[A-Z0-9]+$/);
17
+ assert.equal(typeof result, 'string');
18
+ assert.match(result, /^[A-Z0-9]+$/);
17
19
  });
18
20
  });
19
21
 
@@ -24,7 +26,7 @@ describe('Utils', () => {
24
26
 
25
27
  const result = slugify(text);
26
28
 
27
- expect(result).toEqual(expected);
29
+ assert.equal(result, expected);
28
30
  });
29
31
 
30
32
  it('with a string containing special characters', () => {
@@ -33,7 +35,7 @@ describe('Utils', () => {
33
35
 
34
36
  const result = slugify(text);
35
37
 
36
- expect(result).toEqual(expected);
38
+ assert.equal(result, expected);
37
39
  });
38
40
 
39
41
  it('with a string containing multiple spaces', () => {
@@ -42,7 +44,7 @@ describe('Utils', () => {
42
44
 
43
45
  const result = slugify(text);
44
46
 
45
- expect(result).toEqual(expected);
47
+ assert.equal(result, expected);
46
48
  });
47
49
 
48
50
  it('with a string containing only special characters (leave underscore)', () => {
@@ -51,7 +53,7 @@ describe('Utils', () => {
51
53
 
52
54
  const result = slugify(text);
53
55
 
54
- expect(result).toEqual(expected);
56
+ assert.equal(result, expected);
55
57
  });
56
58
  });
57
59
  });
package/jest.config.js DELETED
@@ -1,17 +0,0 @@
1
- /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
- export default {
3
- preset: 'ts-jest/presets/default-esm', // or other ESM presets
4
- testEnvironment: 'node',
5
- extensionsToTreatAsEsm: ['.ts'],
6
- transform: {
7
- '^.+\\.tsx?$': [
8
- 'ts-jest',
9
- {
10
- useESM: true,
11
- },
12
- ],
13
- },
14
- moduleNameMapper: {
15
- '^(\\.{1,2}/.*)\\.js$': '$1',
16
- },
17
- };
@@ -1,3 +0,0 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
2
- export declare const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label' | 'version'>;
3
- //# sourceMappingURL=BaseDiscountAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseDiscountAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BaseDiscountAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAqD5F,CAAC"}
@@ -1,48 +0,0 @@
1
- import { log, LogLevel } from '@unchainedshop/logger';
2
- export const BaseDiscountAdapter = {
3
- orderIndex: 0,
4
- isManualAdditionAllowed: async () => {
5
- return false;
6
- },
7
- // return true if a discount is allowed to get removed manually by a user
8
- isManualRemovalAllowed: async () => {
9
- return false;
10
- },
11
- actions: async () => ({
12
- // return true if a discount is valid to be part of the order
13
- // without input of a user. that could be a time based global discount
14
- // like a 10% discount day
15
- // if you return false, this discount will
16
- // get removed from the order before any price calculation
17
- // takes place.
18
- // eslint-disable-next-line
19
- isValidForSystemTriggering: async () => {
20
- return false;
21
- },
22
- // return an arbitrary JSON serializable object with reservation data
23
- // this method is called when a discount is added through a manual code and let's
24
- // you manually deduct expendable discounts (coupon balances for ex.) before checkout
25
- reserve: async () => {
26
- return {};
27
- },
28
- // return void, allows you to free up any reservations in backend systems
29
- release: async () => {
30
- return null;
31
- },
32
- // return true if a discount is valid to be part of the order.
33
- // if you return false, this discount will
34
- // get removed from the order before any price calculation
35
- // takes place.
36
- isValidForCodeTriggering: async () => {
37
- return false;
38
- },
39
- // returns the appropriate discount context for a calculation adapter
40
- discountForPricingAdapterKey() {
41
- return null;
42
- },
43
- }),
44
- log(message, { level = LogLevel.Debug, ...options } = {}) {
45
- return log(message, { level, ...options });
46
- },
47
- };
48
- //# sourceMappingURL=BaseDiscountAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseDiscountAdapter.js","sourceRoot":"","sources":["../../src/director/BaseDiscountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,MAAM,CAAC,MAAM,mBAAmB,GAAiE;IAC/F,UAAU,EAAE,CAAC;IAEb,uBAAuB,EAAE,KAAK,IAAI,EAAE;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yEAAyE;IACzE,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,6DAA6D;QAC7D,sEAAsE;QACtE,0BAA0B;QAC1B,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,2BAA2B;QAC3B,0BAA0B,EAAE,KAAK,IAAI,EAAE;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,iFAAiF;QACjF,qFAAqF;QACrF,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,yEAAyE;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,8DAA8D;QAC9D,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,wBAAwB,EAAE,KAAK,IAAI,EAAE;YACnC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,4BAA4B;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
@@ -1,3 +0,0 @@
1
- import { IDiscountDirector } from '@unchainedshop/types/discount.js';
2
- export declare const BaseDiscountDirector: <DiscountConfigurationType>(directorName: string) => IDiscountDirector<DiscountConfigurationType>;
3
- //# sourceMappingURL=BaseDiscountDirector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseDiscountDirector.d.ts","sourceRoot":"","sources":["../../src/director/BaseDiscountDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAIvF,eAAO,MAAM,oBAAoB,GAAI,yBAAyB,gBAC9C,MAAM,KACnB,iBAAiB,CAAC,yBAAyB,CAyD7C,CAAC"}
@@ -1,50 +0,0 @@
1
- import { log } from '@unchainedshop/logger';
2
- import { BaseDirector } from './BaseDirector.js';
3
- export const BaseDiscountDirector = (directorName) => {
4
- const baseDirector = BaseDirector(directorName, {
5
- adapterSortKey: 'orderIndex',
6
- });
7
- return {
8
- ...baseDirector,
9
- actions: async (discountContext, unchainedAPI) => {
10
- const context = { ...discountContext, ...unchainedAPI };
11
- return {
12
- resolveDiscountKeyFromStaticCode: async (options) => {
13
- if (!context.order)
14
- return null;
15
- log(`DiscountDirector -> Find user discount for static code ${options?.code}`);
16
- const discounts = await Promise.all(baseDirector
17
- .getAdapters()
18
- .filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
19
- .map(async (Adapter) => {
20
- const adapter = await Adapter.actions({ context });
21
- return {
22
- key: Adapter.key,
23
- isValid: await adapter.isValidForCodeTriggering(options),
24
- };
25
- }));
26
- return discounts.find(({ isValid }) => isValid === true)?.key;
27
- },
28
- async findSystemDiscounts() {
29
- if (!context.order)
30
- return [];
31
- const discounts = await Promise.all(baseDirector.getAdapters().map(async (Adapter) => {
32
- const adapter = await Adapter.actions({ context });
33
- return {
34
- key: Adapter.key,
35
- isValid: await adapter.isValidForSystemTriggering(),
36
- };
37
- }));
38
- const validDiscounts = discounts
39
- .filter(({ isValid }) => isValid === true)
40
- .map(({ key }) => key);
41
- if (validDiscounts.length > 0) {
42
- log(`DiscountDirector -> Found ${validDiscounts.length} system discounts`);
43
- }
44
- return validDiscounts;
45
- },
46
- };
47
- },
48
- };
49
- };
50
- //# sourceMappingURL=BaseDiscountDirector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseDiscountDirector.js","sourceRoot":"","sources":["../../src/director/BaseDiscountDirector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAoB,EAC0B,EAAE;IAChD,MAAM,YAAY,GAAG,YAAY,CAA8C,YAAY,EAAE;QAC3F,cAAc,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,YAAY;QAEf,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,YAAY,EAAE,CAAC;YAExD,OAAO;gBACL,gCAAgC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBAClD,IAAI,CAAC,OAAO,CAAC,KAAK;wBAAE,OAAO,IAAI,CAAC;oBAEhC,GAAG,CAAC,0DAA0D,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;oBAE/E,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,YAAY;yBACT,WAAW,EAAE;yBACb,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;yBACnE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;wBACrB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;wBACnD,OAAO;4BACL,GAAG,EAAE,OAAO,CAAC,GAAG;4BAChB,OAAO,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC;yBACzD,CAAC;oBACJ,CAAC,CAAC,CACL,CAAC;oBAEF,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC;gBAChE,CAAC;gBAED,KAAK,CAAC,mBAAmB;oBACvB,IAAI,CAAC,OAAO,CAAC,KAAK;wBAAE,OAAO,EAAE,CAAC;oBAC9B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,YAAY,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;wBAC/C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;wBACnD,OAAO;4BACL,GAAG,EAAE,OAAO,CAAC,GAAG;4BAChB,OAAO,EAAE,MAAM,OAAO,CAAC,0BAA0B,EAAE;yBACpD,CAAC;oBACJ,CAAC,CAAC,CACH,CAAC;oBAEF,MAAM,cAAc,GAAG,SAAS;yBAC7B,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;yBACzC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;oBAEzB,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC9B,GAAG,CAAC,6BAA6B,cAAc,CAAC,MAAM,mBAAmB,CAAC,CAAC;oBAC7E,CAAC;oBACD,OAAO,cAAc,CAAC;gBACxB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { BasePricingAdapterContext, IPricingSheet, IPricingAdapter, PricingCalculation } from '@unchainedshop/types/pricing.js';
2
- export declare const BasePricingAdapter: <Context extends BasePricingAdapterContext, Calculation extends PricingCalculation>() => IPricingAdapter<Context, Calculation, IPricingSheet<Calculation>>;
3
- //# sourceMappingURL=BasePricingAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingAdapter.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,eAAe,EACf,kBAAkB,EAEnB,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,yBAAyB,EACzC,WAAW,SAAS,kBAAkB,OACnC,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CA4BnE,CAAC"}
@@ -1,25 +0,0 @@
1
- import { log, LogLevel } from '@unchainedshop/logger';
2
- export const BasePricingAdapter = () => ({
3
- key: '',
4
- label: '',
5
- version: '',
6
- orderIndex: 0,
7
- isActivatedFor: () => {
8
- return false;
9
- },
10
- actions: (params) => {
11
- const calculation = [];
12
- const actions = {
13
- calculate: async () => {
14
- return [];
15
- },
16
- getCalculation: () => calculation,
17
- getContext: () => params.context,
18
- };
19
- return actions;
20
- },
21
- log(message, { level = LogLevel.Debug, ...options } = {}) {
22
- return log(message, { level, ...options });
23
- },
24
- });
25
- //# sourceMappingURL=BasePricingAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingAdapter.js","sourceRoot":"","sources":["../../src/director/BasePricingAdapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAGqC,EAAE,CAAC,CAAC;IACzE,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,CAAC;IAEb,cAAc,EAAE,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;QAClB,MAAM,WAAW,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAiD;YAC5D,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,cAAc,EAAE,GAAG,EAAE,CAAC,WAAW;YACjC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO;SACjC,CAAC;QAEF,OAAO,OAEN,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { BasePricingAdapterContext, BasePricingContext, IPricingDirector, IPricingAdapter, IPricingSheet, PricingCalculation } from '@unchainedshop/types/pricing.js';
2
- export declare const BasePricingDirector: <DirectorContext extends BasePricingContext, AdapterContext extends BasePricingAdapterContext, Calculation extends PricingCalculation, PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>>(directorName: string) => IPricingDirector<DirectorContext, Calculation, AdapterContext, IPricingSheet<Calculation>, PricingAdapter>;
3
- //# sourceMappingURL=BasePricingDirector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingDirector.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingDirector.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,EAEnB,MAAM,iCAAiC,CAAC;AAIzC,eAAO,MAAM,mBAAmB,GAC9B,eAAe,SAAS,kBAAkB,EAC1C,cAAc,SAAS,yBAAyB,EAChD,WAAW,SAAS,kBAAkB,EACtC,cAAc,SAAS,eAAe,CAAC,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,gBAEjF,MAAM,KACnB,gBAAgB,CACjB,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,CAAC,WAAW,CAAC,EAC1B,cAAc,CAgFf,CAAC"}
@@ -1,61 +0,0 @@
1
- import { log, LogLevel } from '@unchainedshop/logger';
2
- import { BaseDirector } from './BaseDirector.js';
3
- export const BasePricingDirector = (directorName) => {
4
- const baseDirector = BaseDirector(directorName, {
5
- adapterSortKey: 'orderIndex',
6
- });
7
- const director = {
8
- ...baseDirector,
9
- buildPricingContext: async () => {
10
- return {};
11
- },
12
- actions: async (pricingContext, unchainedAPI, buildPricingContext) => {
13
- const context = await buildPricingContext(pricingContext, unchainedAPI);
14
- let calculation = [];
15
- const actions = {
16
- async calculate() {
17
- const Adapters = baseDirector.getAdapters({
18
- adapterFilter: (Adapter) => {
19
- return Adapter.isActivatedFor(context);
20
- },
21
- });
22
- calculation = await Adapters.reduce(async (previousPromise, Adapter) => {
23
- const resolvedCalculation = await previousPromise;
24
- if (!resolvedCalculation)
25
- return null;
26
- const discounts = await Promise.all(context.discounts.map(async (discount) => ({
27
- discountId: discount._id,
28
- configuration: await context.modules.orders.discounts.configurationForPricingAdapterKey(discount, Adapter.key, this.calculationSheet(), context),
29
- })));
30
- try {
31
- const adapter = Adapter.actions({
32
- context,
33
- calculationSheet: this.calculationSheet(),
34
- discounts: discounts.filter(({ configuration }) => configuration !== null),
35
- });
36
- const nextCalculationResult = await adapter.calculate();
37
- if (!nextCalculationResult)
38
- return null;
39
- calculation = resolvedCalculation.concat(nextCalculationResult);
40
- return calculation;
41
- }
42
- catch (error) {
43
- log(error, { level: LogLevel.Error });
44
- }
45
- return resolvedCalculation;
46
- }, Promise.resolve([]));
47
- return calculation;
48
- },
49
- getCalculation() {
50
- return calculation;
51
- },
52
- getContext() {
53
- return context;
54
- },
55
- };
56
- return actions;
57
- },
58
- };
59
- return director;
60
- };
61
- //# sourceMappingURL=BasePricingDirector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingDirector.js","sourceRoot":"","sources":["../../src/director/BasePricingDirector.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAMjC,YAAoB,EAOpB,EAAE;IACF,MAAM,YAAY,GAAG,YAAY,CAAiB,YAAY,EAAE;QAC9D,cAAc,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAMV;QACF,GAAG,YAAY;QACf,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAC9B,OAAO,EAAoB,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,EAAE;YACnE,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAExE,IAAI,WAAW,GAAuB,EAAE,CAAC;YAEzC,MAAM,OAAO,GAAwD;gBACnE,KAAK,CAAC,SAAS;oBACb,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC;wBACxC,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE;4BACzB,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;wBACzC,CAAC;qBACF,CAAC,CAAC;oBAEH,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE;wBACrE,MAAM,mBAAmB,GAAG,MAAM,eAAe,CAAC;wBAClD,IAAI,CAAC,mBAAmB;4BAAE,OAAO,IAAI,CAAC;wBAEtC,MAAM,SAAS,GAAyB,MAAM,OAAO,CAAC,GAAG,CACvD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;4BACzC,UAAU,EAAE,QAAQ,CAAC,GAAG;4BACxB,aAAa,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,iCAAiC,CACrF,QAAQ,EACR,OAAO,CAAC,GAAG,EACX,IAAI,CAAC,gBAAgB,EAAE,EACvB,OAAO,CACR;yBACF,CAAC,CAAC,CACJ,CAAC;wBAEF,IAAI,CAAC;4BACH,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;gCAC9B,OAAO;gCACP,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE;gCACzC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,aAAa,KAAK,IAAI,CAAC;6BAC3E,CAAC,CAAC;4BAEH,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC;4BACxD,IAAI,CAAC,qBAAqB;gCAAE,OAAO,IAAI,CAAC;4BACxC,WAAW,GAAG,mBAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;4BAChE,OAAO,WAAW,CAAC;wBACrB,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;wBACxC,CAAC;wBACD,OAAO,mBAAmB,CAAC;oBAC7B,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;oBAExB,OAAO,WAAW,CAAC;gBACrB,CAAC;gBACD,cAAc;oBACZ,OAAO,WAAW,CAAC;gBACrB,CAAC;gBACD,UAAU;oBACR,OAAO,OAAO,CAAC;gBACjB,CAAC;aACF,CAAC;YAEF,OAAO,OAEN,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { PricingCalculation, IBasePricingSheet, PricingSheetParams } from '@unchainedshop/types/pricing.js';
2
- export declare const BasePricingSheet: <Calculation extends PricingCalculation>(params: PricingSheetParams<Calculation>) => IBasePricingSheet<Calculation>;
3
- //# sourceMappingURL=BasePricingSheet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingSheet.d.ts","sourceRoot":"","sources":["../../src/director/BasePricingSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS,kBAAkB,UAC7D,kBAAkB,CAAC,WAAW,CAAC,KACtC,iBAAiB,CAAC,WAAW,CAwE/B,CAAC"}
@@ -1,54 +0,0 @@
1
- export const BasePricingSheet = (params) => {
2
- const pricingSheet = {
3
- calculation: params.calculation || [],
4
- currency: params.currency,
5
- quantity: params.quantity,
6
- getRawPricingSheet() {
7
- return this.calculation;
8
- },
9
- isValid() {
10
- return this.calculation.length > 0;
11
- },
12
- sum(filter) {
13
- return this.filterBy(filter)
14
- .filter(Boolean)
15
- .reduce((sum, calculationRow) => sum + calculationRow.amount, 0);
16
- },
17
- taxSum() {
18
- return 0;
19
- },
20
- gross() {
21
- // Sum contains taxes, thus it's gross when just suming everything
22
- return this.sum();
23
- },
24
- net() {
25
- // Remove all taxes from gross to get net
26
- return this.sum() - this.taxSum();
27
- },
28
- total({ category, useNetPrice, discountId } = { useNetPrice: false }) {
29
- const amount = this.sum({ category, discountId });
30
- const taxAmountForCategory = this.taxSum({ baseCategory: category, discountId });
31
- // Sum does not contain taxes when filtering by category, it's net in that case and gross if there is no category
32
- const netAmount = !category ? amount - taxAmountForCategory : amount;
33
- return {
34
- amount: Math.round(useNetPrice ? netAmount : netAmount + taxAmountForCategory),
35
- currency: this.currency,
36
- };
37
- },
38
- filterBy(filter) {
39
- const filteredCalculation = Object.keys(filter || {}).reduce((oldCalculation, filterKey) => oldCalculation.filter((row) => !!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey])), this.calculation);
40
- return filteredCalculation;
41
- },
42
- resetCalculation(calculationSheet) {
43
- calculationSheet.filterBy().forEach(({ amount, ...row }) => {
44
- this.calculation.push({
45
- ...row,
46
- amount: amount * -1,
47
- });
48
- });
49
- return this.calculation;
50
- },
51
- };
52
- return pricingSheet;
53
- };
54
- //# sourceMappingURL=BasePricingSheet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePricingSheet.js","sourceRoot":"","sources":["../../src/director/BasePricingSheet.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAuC,EACP,EAAE;IAClC,MAAM,YAAY,GAAmC;QACnD,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;QACrC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QAEzB,kBAAkB;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;QAED,OAAO;YACL,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,CAAC;QAED,GAAG,CAAC,MAAM;YACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;iBACzB,MAAM,CAAC,OAAO,CAAC;iBACf,MAAM,CAAC,CAAC,GAAW,EAAE,cAA2B,EAAE,EAAE,CAAC,GAAG,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC1F,CAAC;QAED,MAAM;YACJ,OAAO,CAAC,CAAC;QACX,CAAC;QAED,KAAK;YACH,kEAAkE;YAClE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;QAED,GAAG;YACD,yCAAyC;YACzC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACpC,CAAC;QAED,KAAK,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE;YAClE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAClD,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAEjF,iHAAiH;YACjH,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC;YAErE,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,oBAAoB,CAAC;gBAC9E,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC;QACJ,CAAC;QAED,QAAQ,CAAC,MAAM;YACb,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAC1D,CAAC,cAAc,EAAE,SAAS,EAAE,EAAE,CAC5B,cAAc,CAAC,MAAM,CACnB,CAAC,GAAgB,EAAE,EAAE,CACnB,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,CAAC,CACrF,EACH,IAAI,CAAC,WAAW,CACjB,CAAC;YAEF,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QAED,gBAAgB,CAAC,gBAAgB;YAC/B,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,EAAe,EAAE,EAAE;gBACtE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;oBACpB,GAAG,GAAG;oBACN,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;iBACL,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;KACF,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export default function randomValueHex(len: number): string;
2
- //# sourceMappingURL=random-value-hex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random-value-hex.d.ts","sourceRoot":"","sources":["../src/random-value-hex.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK1D"}
@@ -1,8 +0,0 @@
1
- import crypto from 'crypto';
2
- export default function randomValueHex(len) {
3
- return crypto
4
- .randomBytes(Math.ceil(len / 2))
5
- .toString('hex') // convert to hexadecimal format
6
- .slice(0, len); // return required number of characters
7
- }
8
- //# sourceMappingURL=random-value-hex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random-value-hex.js","sourceRoot":"","sources":["../src/random-value-hex.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAW;IAChD,OAAO,MAAM;SACV,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC,gCAAgC;SAChD,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,uCAAuC;AAC3D,CAAC"}
@@ -1,3 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export declare const AddressSchema: SimpleSchema;
3
- //# sourceMappingURL=AddressSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddressSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/AddressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,aAAa,cAazB,CAAC"}
@@ -1,13 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export const AddressSchema = new SimpleSchema({
3
- firstName: String,
4
- lastName: String,
5
- company: String,
6
- addressLine: String,
7
- addressLine2: String,
8
- city: String,
9
- postalCode: String,
10
- regionCode: String,
11
- countryCode: String,
12
- }, { requiredByDefault: false });
13
- //# sourceMappingURL=AddressSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddressSchema.js","sourceRoot":"","sources":["../../src/schemas/AddressSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;IACnB,YAAY,EAAE,MAAM;IACpB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;CACpB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1,3 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export declare const ContactSchema: SimpleSchema;
3
- //# sourceMappingURL=ContactSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContactSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/ContactSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,aAAa,cAMzB,CAAC"}
@@ -1,6 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export const ContactSchema = new SimpleSchema({
3
- telNumber: String,
4
- emailAddress: String,
5
- }, { requiredByDefault: false });
6
- //# sourceMappingURL=ContactSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContactSchema.js","sourceRoot":"","sources":["../../src/schemas/ContactSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1,5 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export declare const LastLoginSchema: SimpleSchema;
3
- export declare const LastContactSchema: SimpleSchema;
4
- export declare const UserSchema: SimpleSchema;
5
- //# sourceMappingURL=UsersSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UsersSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/UsersSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAexC,eAAO,MAAM,eAAe,cAU3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAM7B,CAAC;AAEF,eAAO,MAAM,UAAU,cA+BtB,CAAC"}
@@ -1,52 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- import { AddressSchema } from './AddressSchema.js';
3
- import { timestampFields } from './commonSchemaFields.js';
4
- const ProfileSchema = new SimpleSchema({
5
- displayName: String,
6
- birthday: Date,
7
- phoneMobile: String,
8
- gender: String,
9
- address: AddressSchema,
10
- }, { requiredByDefault: false });
11
- export const LastLoginSchema = new SimpleSchema({
12
- timestamp: Date,
13
- locale: String,
14
- countryCode: String,
15
- remoteAddress: String,
16
- remotePort: String,
17
- userAgent: String,
18
- }, { requiredByDefault: false });
19
- export const LastContactSchema = new SimpleSchema({
20
- telNumber: String,
21
- emailAddress: String,
22
- }, { requiredByDefault: false });
23
- export const UserSchema = new SimpleSchema({
24
- emails: Array,
25
- 'emails.$': Object,
26
- 'emails.$.address': String,
27
- 'emails.$.verified': Boolean,
28
- username: String,
29
- lastLogin: LastLoginSchema,
30
- profile: ProfileSchema,
31
- lastBillingAddress: AddressSchema,
32
- lastContact: LastContactSchema,
33
- guest: Boolean,
34
- initialPassword: Boolean,
35
- tags: Array,
36
- 'tags.$': String,
37
- avatarId: String,
38
- meta: {
39
- type: Object,
40
- optional: true,
41
- blackbox: true,
42
- },
43
- services: {
44
- type: Object,
45
- optional: true,
46
- blackbox: true,
47
- },
48
- roles: Array,
49
- 'roles.$': String,
50
- ...timestampFields,
51
- }, { requiredByDefault: false });
52
- //# sourceMappingURL=UsersSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UsersSchema.js","sourceRoot":"","sources":["../../src/schemas/UsersSchema.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,aAAa,GAAG,IAAI,YAAY,CACpC;IACE,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,aAAa;CACvB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,MAAM;IACnB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;CAClB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,YAAY,CAC/C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,YAAY,CACxC;IACE,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,MAAM;IAClB,kBAAkB,EAAE,MAAM;IAC1B,mBAAmB,EAAE,OAAO;IAC5B,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,aAAa;IACtB,kBAAkB,EAAE,aAAa;IACjC,WAAW,EAAE,iBAAiB;IAC9B,KAAK,EAAE,OAAO;IACd,eAAe,EAAE,OAAO;IACxB,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,MAAM;IACjB,GAAG,eAAe;CACnB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1,35 +0,0 @@
1
- export declare const contextFields: {
2
- context: {
3
- type: ObjectConstructor;
4
- blackbox: boolean;
5
- required: boolean;
6
- };
7
- };
8
- export declare const logFields: {
9
- log: ArrayConstructor;
10
- 'log.$': {
11
- type: ObjectConstructor;
12
- };
13
- 'log.$.date': {
14
- type: DateConstructor;
15
- };
16
- 'log.$.status': {
17
- type: StringConstructor;
18
- };
19
- 'log.$.info': {
20
- type: StringConstructor;
21
- };
22
- };
23
- export declare const timestampFields: {
24
- created: {
25
- type: DateConstructor;
26
- required: boolean;
27
- };
28
- updated: {
29
- type: DateConstructor;
30
- };
31
- deleted: {
32
- type: DateConstructor;
33
- };
34
- };
35
- //# sourceMappingURL=commonSchemaFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commonSchemaFields.d.ts","sourceRoot":"","sources":["../../src/schemas/commonSchemaFields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAcrB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;CAI3B,CAAC"}
@@ -1,28 +0,0 @@
1
- export const contextFields = {
2
- context: {
3
- type: Object,
4
- blackbox: true,
5
- required: false,
6
- },
7
- };
8
- export const logFields = {
9
- log: Array,
10
- 'log.$': {
11
- type: Object,
12
- },
13
- 'log.$.date': {
14
- type: Date,
15
- },
16
- 'log.$.status': {
17
- type: String,
18
- },
19
- 'log.$.info': {
20
- type: String,
21
- },
22
- };
23
- export const timestampFields = {
24
- created: { type: Date, required: true },
25
- updated: { type: Date },
26
- deleted: { type: Date },
27
- };
28
- //# sourceMappingURL=commonSchemaFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commonSchemaFields.js","sourceRoot":"","sources":["../../src/schemas/commonSchemaFields.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,IAAI;KACX;IACD,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM;KACb;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACvB,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;CACxB,CAAC"}
@@ -1,43 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- declare const Schemas: {
3
- timestampFields: {
4
- created: {
5
- type: DateConstructor;
6
- required: boolean;
7
- };
8
- updated: {
9
- type: DateConstructor;
10
- };
11
- deleted: {
12
- type: DateConstructor;
13
- };
14
- };
15
- contextFields: {
16
- context: {
17
- type: ObjectConstructor;
18
- blackbox: boolean;
19
- required: boolean;
20
- };
21
- };
22
- logFields: {
23
- log: ArrayConstructor;
24
- 'log.$': {
25
- type: ObjectConstructor;
26
- };
27
- 'log.$.date': {
28
- type: DateConstructor;
29
- };
30
- 'log.$.status': {
31
- type: StringConstructor;
32
- };
33
- 'log.$.info': {
34
- type: StringConstructor;
35
- };
36
- };
37
- Address: SimpleSchema;
38
- Contact: SimpleSchema;
39
- User: SimpleSchema;
40
- };
41
- export { Schemas };
42
- export type { SimpleSchema };
43
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAMxC,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOZ,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,YAAY,EAAE,YAAY,EAAE,CAAC"}
@@ -1,14 +0,0 @@
1
- import { timestampFields, contextFields, logFields } from './commonSchemaFields.js';
2
- import { AddressSchema } from './AddressSchema.js';
3
- import { ContactSchema } from './ContactSchema.js';
4
- import { UserSchema } from './UsersSchema.js';
5
- const Schemas = {
6
- timestampFields,
7
- contextFields,
8
- logFields,
9
- Address: AddressSchema,
10
- Contact: ContactSchema,
11
- User: UserSchema,
12
- };
13
- export { Schemas };
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG;IACd,eAAe;IACf,aAAa;IACb,SAAS;IACT,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}