@classytic/pos 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/commands/index.d.mts +2 -0
  3. package/dist/commands/index.mjs +1 -0
  4. package/dist/commands/pos-commands.d.mts +228 -0
  5. package/dist/commands/pos-commands.mjs +355 -0
  6. package/dist/domain/enums/cash-movement-reason.enum.d.mts +3 -4
  7. package/dist/domain/enums/closed-by.enum.d.mts +3 -4
  8. package/dist/domain/enums/payment-method.enum.d.mts +6 -7
  9. package/dist/domain/enums/shift-state.enum.d.mts +7 -8
  10. package/dist/domain/errors/pos.errors.d.mts +82 -13
  11. package/dist/domain/errors/pos.errors.mjs +111 -1
  12. package/dist/domain/index.d.mts +11 -3
  13. package/dist/domain/index.mjs +10 -3
  14. package/dist/domain/ports/common.d.mts +2 -3
  15. package/dist/domain/ports/ledger.bridge.d.mts +6 -7
  16. package/dist/domain/ports/notification.bridge.d.mts +5 -6
  17. package/dist/domain/ports/policy.bridge.d.mts +2 -3
  18. package/dist/domain/sale/discount.d.mts +62 -0
  19. package/dist/domain/sale/discount.mjs +58 -0
  20. package/dist/domain/sale/price-override.d.mts +51 -0
  21. package/dist/domain/sale/price-override.mjs +51 -0
  22. package/dist/domain/sale/quick-cash.d.mts +10 -0
  23. package/dist/domain/sale/quick-cash.mjs +27 -0
  24. package/dist/domain/sale/service-line.d.mts +7 -0
  25. package/dist/domain/sale/service-line.mjs +10 -0
  26. package/dist/domain/sale/tender.d.mts +256 -0
  27. package/dist/domain/sale/tender.mjs +242 -0
  28. package/dist/domain/shift/shift-decisions.d.mts +52 -0
  29. package/dist/domain/shift/shift-decisions.mjs +93 -0
  30. package/dist/domain/shift/shift-report.d.mts +127 -0
  31. package/dist/domain/shift/shift-report.mjs +95 -0
  32. package/dist/domain/shift/shift.types.d.mts +109 -0
  33. package/dist/domain/state-machines/shift.fsm.d.mts +6 -7
  34. package/dist/domain/value-objects/cash-movement.vo.d.mts +7 -3
  35. package/dist/domain/value-objects/payment-breakdown.vo.d.mts +4 -5
  36. package/dist/domain/value-objects/shift-policy.vo.d.mts +11 -7
  37. package/dist/domain/value-objects/shift-policy.vo.mjs +12 -1
  38. package/dist/engine/define-pos.d.mts +2 -3
  39. package/dist/engine/define-pos.mjs +13 -2
  40. package/dist/engine/engine-types.d.mts +24 -9
  41. package/dist/engine/index.mjs +1 -2
  42. package/dist/events/event-catalog.d.mts +18 -14
  43. package/dist/events/event-catalog.mjs +10 -4
  44. package/dist/events/event-constants.d.mts +3 -4
  45. package/dist/events/event-payloads.d.mts +9 -10
  46. package/dist/events/helpers.d.mts +6 -3
  47. package/dist/events/helpers.mjs +12 -2
  48. package/dist/events/in-process-bus.d.mts +3 -4
  49. package/dist/events/index.mjs +1 -1
  50. package/dist/grant/till-grant.d.mts +50 -0
  51. package/dist/grant/till-grant.mjs +47 -0
  52. package/dist/index.d.mts +14 -4
  53. package/dist/index.mjs +12 -4
  54. package/dist/models/create-models.d.mts +10 -6
  55. package/dist/models/create-models.mjs +16 -3
  56. package/dist/models/register.model.d.mts +7 -6
  57. package/dist/models/shift-sale-dedupe.model.d.mts +4 -5
  58. package/dist/models/shift.model.d.mts +4 -111
  59. package/dist/models/shift.model.mjs +26 -2
  60. package/dist/models/till-grant.model.d.mts +19 -0
  61. package/dist/models/till-grant.model.mjs +52 -0
  62. package/dist/repositories/register.repository.d.mts +3 -4
  63. package/dist/repositories/shift.repository.d.mts +71 -30
  64. package/dist/repositories/shift.repository.mjs +295 -108
  65. package/dist/repositories/till-grant.repository.d.mts +22 -0
  66. package/dist/repositories/till-grant.repository.mjs +41 -0
  67. package/dist/schemas/index.mjs +1 -2
  68. package/dist/schemas/shift.d.mts +9 -10
  69. package/dist/testing/fixtures.d.mts +4 -5
  70. package/dist/testing/index.mjs +1 -2
  71. package/package.json +50 -19
@@ -0,0 +1,41 @@
1
+ import { Repository } from "@classytic/mongokit";
2
+ //#region src/repositories/till-grant.repository.ts
3
+ /**
4
+ * Issued till grants: `record` when the server signs one, `forTill` when a synced command names
5
+ * one. A grant is found only in its tenant and only for the till it was issued to.
6
+ */
7
+ var TillGrantRepository = class extends Repository {
8
+ constructor(config) {
9
+ super(config.model, config.plugins ?? []);
10
+ }
11
+ /** The server's record of a grant it signed. */
12
+ async record(grant, ctx) {
13
+ await this.create({
14
+ _id: grant.jti,
15
+ sn: grant.sub,
16
+ registerId: grant.reg,
17
+ issuedAt: /* @__PURE__ */ new Date(grant.iat * 1e3),
18
+ expiresAt: /* @__PURE__ */ new Date(grant.exp * 1e3),
19
+ discount: grant.discount,
20
+ counterSaleGoodsInHand: grant.counterSaleGoodsInHand
21
+ }, {
22
+ organizationId: ctx.organizationId,
23
+ ...ctx.session !== void 0 ? { session: ctx.session } : {}
24
+ });
25
+ }
26
+ /** The grant `jti` names, if this tenant issued it to this till; else null. */
27
+ async forTill(jti, sn, ctx) {
28
+ const [grant] = await this.findAll({
29
+ _id: jti,
30
+ sn
31
+ }, {
32
+ organizationId: ctx.organizationId,
33
+ limit: 1,
34
+ lean: true,
35
+ ...ctx.session !== void 0 ? { session: ctx.session } : {}
36
+ });
37
+ return grant ?? null;
38
+ }
39
+ };
40
+ //#endregion
41
+ export { TillGrantRepository };
@@ -1,2 +1 @@
1
- import { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody } from "./shift.mjs";
2
- export { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody };
1
+ export { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody } from "./shift.mjs";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  //#region src/schemas/shift.d.ts
3
- declare const objectIdString: z.ZodString;
4
- declare const openShiftBody: z.ZodObject<{
3
+ export declare const objectIdString: z.ZodString;
4
+ export declare const openShiftBody: z.ZodObject<{
5
5
  registerId: z.ZodString;
6
6
  businessDate: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>;
7
7
  openingCashierId: z.ZodString;
@@ -9,7 +9,7 @@ declare const openShiftBody: z.ZodObject<{
9
9
  openingCash: z.ZodNumber;
10
10
  notes: z.ZodOptional<z.ZodString>;
11
11
  }, z.core.$strip>;
12
- declare const recordCashMovementBody: z.ZodObject<{
12
+ export declare const recordCashMovementBody: z.ZodObject<{
13
13
  type: z.ZodEnum<{
14
14
  in: "in";
15
15
  out: "out";
@@ -29,13 +29,13 @@ declare const recordCashMovementBody: z.ZodObject<{
29
29
  cashierName: z.ZodString;
30
30
  timestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
31
31
  }, z.core.$strip>;
32
- declare const blindCloseBody: z.ZodObject<{
32
+ export declare const blindCloseBody: z.ZodObject<{
33
33
  countedByMethod: z.ZodRecord<z.ZodString, z.ZodNumber>;
34
34
  closingCashierId: z.ZodString;
35
35
  closingCashierName: z.ZodString;
36
36
  notes: z.ZodOptional<z.ZodString>;
37
37
  }, z.core.$strip>;
38
- declare const closeBody: z.ZodObject<{
38
+ export declare const closeBody: z.ZodObject<{
39
39
  countedByMethod: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
40
40
  varianceOverride: z.ZodOptional<z.ZodObject<{
41
41
  overriddenBy: z.ZodString;
@@ -47,10 +47,9 @@ declare const closeBody: z.ZodObject<{
47
47
  system_auto: "system_auto";
48
48
  }>;
49
49
  }, z.core.$strip>;
50
- declare const pauseBody: z.ZodObject<{}, z.core.$strict>;
51
- declare const resumeBody: z.ZodObject<{}, z.core.$strict>;
52
- declare const forceCloseBody: z.ZodObject<{
50
+ export declare const pauseBody: z.ZodObject<{}, z.core.$strict>;
51
+ export declare const resumeBody: z.ZodObject<{}, z.core.$strict>;
52
+ export declare const forceCloseBody: z.ZodObject<{
53
53
  reason: z.ZodOptional<z.ZodString>;
54
54
  }, z.core.$strict>;
55
- //#endregion
56
- export { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody };
55
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  import { ShiftPolicy } from "../domain/value-objects/shift-policy.vo.mjs";
2
2
  import { OpenShiftInput } from "../repositories/shift.repository.mjs";
3
3
  //#region src/testing/fixtures.d.ts
4
- declare const TEST_ORG_ID: string;
5
- declare function makePolicy(overrides?: Partial<ShiftPolicy>): ShiftPolicy;
6
- declare function makeOpenShiftInput(overrides?: Partial<OpenShiftInput>): OpenShiftInput;
7
- //#endregion
8
- export { TEST_ORG_ID, makeOpenShiftInput, makePolicy };
4
+ export declare const TEST_ORG_ID: string;
5
+ export declare function makePolicy(overrides?: Partial<ShiftPolicy>): ShiftPolicy;
6
+ export declare function makeOpenShiftInput(overrides?: Partial<OpenShiftInput>): OpenShiftInput;
7
+ //#endregion
@@ -1,2 +1 @@
1
- import { TEST_ORG_ID, makeOpenShiftInput, makePolicy } from "./fixtures.mjs";
2
- export { TEST_ORG_ID, makeOpenShiftInput, makePolicy };
1
+ export { TEST_ORG_ID, makeOpenShiftInput, makePolicy } from "./fixtures.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/pos",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Multi-vertical POS / register-session kernel for MongoDB — shift lifecycle, cash-drawer reconciliation, payment-method breakdown, variance detection, FSM. Works for retail, restaurant, clinic, service-booking, car-wash and any vertical with a 'shift opens, shift closes, money is reconciled' workflow.",
5
5
  "author": "Classytic",
6
6
  "type": "module",
@@ -13,26 +13,42 @@
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
+ "@classytic/source": "./src/index.ts",
16
17
  "types": "./dist/index.d.mts",
17
18
  "default": "./dist/index.mjs"
18
19
  },
19
20
  "./engine": {
21
+ "@classytic/source": "./src/engine/index.ts",
20
22
  "types": "./dist/engine/index.d.mts",
21
23
  "default": "./dist/engine/index.mjs"
22
24
  },
23
25
  "./events": {
26
+ "@classytic/source": "./src/events/index.ts",
24
27
  "types": "./dist/events/index.d.mts",
25
28
  "default": "./dist/events/index.mjs"
26
29
  },
27
30
  "./domain": {
31
+ "@classytic/source": "./src/domain/index.ts",
28
32
  "types": "./dist/domain/index.d.mts",
29
33
  "default": "./dist/domain/index.mjs"
30
34
  },
35
+ "./grant": {
36
+ "@classytic/source": "./src/grant/till-grant.ts",
37
+ "types": "./dist/grant/till-grant.d.mts",
38
+ "default": "./dist/grant/till-grant.mjs"
39
+ },
40
+ "./commands": {
41
+ "@classytic/source": "./src/commands/index.ts",
42
+ "types": "./dist/commands/index.d.mts",
43
+ "default": "./dist/commands/index.mjs"
44
+ },
31
45
  "./schemas": {
46
+ "@classytic/source": "./src/schemas/index.ts",
32
47
  "types": "./dist/schemas/index.d.mts",
33
48
  "default": "./dist/schemas/index.mjs"
34
49
  },
35
50
  "./testing": {
51
+ "@classytic/source": "./src/testing/index.ts",
36
52
  "types": "./dist/testing/index.d.mts",
37
53
  "default": "./dist/testing/index.mjs"
38
54
  }
@@ -71,28 +87,43 @@
71
87
  "release": "npm run push -- main && npm run release:tag && npm publish"
72
88
  },
73
89
  "peerDependencies": {
74
- "@classytic/mongokit": ">=3.36.0",
75
- "@classytic/primitives": ">=0.26.4",
76
- "@classytic/repo-core": ">=0.26.0",
77
- "@classytic/validation": ">=0.2.0",
78
- "mongoose": ">=9.4.1",
90
+ "@classytic/mongokit": ">=3.41.0",
91
+ "@classytic/order": ">=0.19.0",
92
+ "@classytic/primitives": ">=0.32.0",
93
+ "@classytic/repo-core": ">=0.31.0",
94
+ "@classytic/tax-core": ">=0.6.0",
95
+ "@classytic/validation": ">=0.6.0",
96
+ "mongoose": ">=9.11.0",
79
97
  "zod": ">=4.0.0"
80
98
  },
99
+ "peerDependenciesMeta": {
100
+ "@classytic/mongokit": {
101
+ "optional": true
102
+ },
103
+ "@classytic/validation": {
104
+ "optional": true
105
+ },
106
+ "mongoose": {
107
+ "optional": true
108
+ }
109
+ },
81
110
  "devDependencies": {
82
- "@classytic/dev-tools": "^0.2.0",
83
- "@classytic/mongokit": "^3.36.0",
84
- "@classytic/primitives": ">=0.26.4",
85
- "@classytic/repo-core": ">=0.26.0",
86
- "@classytic/validation": ">=0.4.0",
87
- "@types/node": "^25.5.0",
88
- "@vitest/coverage-v8": "^3.2.4",
89
- "mongodb-memory-server": "^10.2.3",
90
- "mongoose": "^9.4.1",
91
- "publint": "^0.3.23",
92
- "tsdown": "^0.22.14",
111
+ "@classytic/dev-tools": "^0.2.1",
112
+ "@classytic/mongokit": "^3.43.0",
113
+ "@classytic/order": "^0.19.0",
114
+ "@classytic/primitives": "^0.34.0",
115
+ "@classytic/repo-core": "^0.31.1",
116
+ "@classytic/tax-core": "^0.6.0",
117
+ "@classytic/validation": "^0.6.0",
118
+ "@types/node": "^26.6.5",
119
+ "@vitest/coverage-v8": "^5.0.5",
120
+ "mongodb-memory-server": "^11.3.0",
121
+ "mongoose": "^9.11.2",
122
+ "publint": "^0.3.25",
123
+ "tsdown": "^0.23.1",
93
124
  "typescript": "^7.0.2",
94
- "vitest": "^3.0.0",
95
- "zod": "^4.3.6"
125
+ "vitest": "^5.0.5",
126
+ "zod": "^4.6.7"
96
127
  },
97
128
  "keywords": [
98
129
  "pos",