@classytic/pos 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -350
- package/dist/commands/index.d.mts +2 -0
- package/dist/commands/index.mjs +1 -0
- package/dist/commands/pos-commands.d.mts +230 -0
- package/dist/commands/pos-commands.mjs +357 -0
- package/dist/domain/enums/cash-movement-reason.enum.d.mts +3 -4
- package/dist/domain/enums/closed-by.enum.d.mts +3 -4
- package/dist/domain/enums/payment-method.enum.d.mts +6 -7
- package/dist/domain/enums/payment-method.enum.mjs +2 -2
- package/dist/domain/enums/shift-state.enum.d.mts +7 -8
- package/dist/domain/errors/pos.errors.d.mts +82 -34
- package/dist/domain/errors/pos.errors.mjs +108 -23
- package/dist/domain/index.d.mts +11 -3
- package/dist/domain/index.mjs +10 -3
- package/dist/domain/ports/common.d.mts +2 -3
- package/dist/domain/ports/ledger.bridge.d.mts +6 -7
- package/dist/domain/ports/notification.bridge.d.mts +5 -6
- package/dist/domain/ports/policy.bridge.d.mts +2 -3
- package/dist/domain/sale/discount.d.mts +62 -0
- package/dist/domain/sale/discount.mjs +58 -0
- package/dist/domain/sale/price-override.d.mts +51 -0
- package/dist/domain/sale/price-override.mjs +51 -0
- package/dist/domain/sale/quick-cash.d.mts +10 -0
- package/dist/domain/sale/quick-cash.mjs +27 -0
- package/dist/domain/sale/service-line.d.mts +7 -0
- package/dist/domain/sale/service-line.mjs +10 -0
- package/dist/domain/sale/tender.d.mts +256 -0
- package/dist/domain/sale/tender.mjs +242 -0
- package/dist/domain/shift/shift-decisions.d.mts +51 -0
- package/dist/domain/shift/shift-decisions.mjs +93 -0
- package/dist/domain/shift/shift-report.d.mts +127 -0
- package/dist/domain/shift/shift-report.mjs +95 -0
- package/dist/domain/shift/shift.types.d.mts +107 -0
- package/dist/domain/state-machines/shift.fsm.d.mts +6 -7
- package/dist/domain/value-objects/cash-movement.vo.d.mts +7 -3
- package/dist/domain/value-objects/payment-breakdown.vo.d.mts +4 -5
- package/dist/domain/value-objects/shift-policy.vo.d.mts +12 -13
- package/dist/domain/value-objects/shift-policy.vo.mjs +13 -7
- package/dist/engine/capability.errors.d.mts +23 -0
- package/dist/engine/capability.errors.mjs +28 -0
- package/dist/engine/define-pos.d.mts +2 -3
- package/dist/engine/define-pos.mjs +14 -3
- package/dist/engine/engine-types.d.mts +24 -9
- package/dist/engine/index.d.mts +2 -1
- package/dist/engine/index.mjs +2 -1
- package/dist/events/event-catalog.d.mts +18 -14
- package/dist/events/event-catalog.mjs +10 -4
- package/dist/events/event-constants.d.mts +3 -4
- package/dist/events/event-payloads.d.mts +9 -10
- package/dist/events/helpers.d.mts +6 -3
- package/dist/events/helpers.mjs +12 -2
- package/dist/events/in-process-bus.d.mts +3 -4
- package/dist/events/index.mjs +1 -1
- package/dist/grant/till-grant.d.mts +50 -0
- package/dist/grant/till-grant.mjs +47 -0
- package/dist/index.d.mts +15 -4
- package/dist/index.mjs +13 -4
- package/dist/models/create-models.d.mts +10 -6
- package/dist/models/create-models.mjs +16 -3
- package/dist/models/register.model.d.mts +7 -6
- package/dist/models/shift-sale-dedupe.model.d.mts +4 -5
- package/dist/models/shift.model.d.mts +4 -111
- package/dist/models/shift.model.mjs +27 -3
- package/dist/models/till-grant.model.d.mts +19 -0
- package/dist/models/till-grant.model.mjs +52 -0
- package/dist/repositories/register.repository.d.mts +3 -4
- package/dist/repositories/shift.repository.d.mts +90 -60
- package/dist/repositories/shift.repository.mjs +323 -150
- package/dist/repositories/till-grant.repository.d.mts +22 -0
- package/dist/repositories/till-grant.repository.mjs +41 -0
- package/dist/schemas/index.mjs +1 -2
- package/dist/schemas/shift.d.mts +9 -10
- package/dist/testing/fixtures.d.mts +4 -5
- package/dist/testing/index.mjs +1 -2
- package/package.json +50 -19
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ITillGrant } from "../models/till-grant.model.mjs";
|
|
2
|
+
import { TillGrant } from "../grant/till-grant.mjs";
|
|
3
|
+
import { PluginType, Repository } from "@classytic/mongokit";
|
|
4
|
+
import { Model } from "mongoose";
|
|
5
|
+
//#region src/repositories/till-grant.repository.d.ts
|
|
6
|
+
export declare class TillGrantRepository extends Repository<ITillGrant> {
|
|
7
|
+
constructor(config: {
|
|
8
|
+
model: Model<ITillGrant>;
|
|
9
|
+
plugins?: PluginType[] | undefined;
|
|
10
|
+
});
|
|
11
|
+
/** The server's record of a grant it signed. */
|
|
12
|
+
record(grant: TillGrant, ctx: {
|
|
13
|
+
organizationId: string;
|
|
14
|
+
session?: unknown;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/** The grant `jti` names, if this tenant issued it to this till; else null. */
|
|
17
|
+
forTill(jti: string, sn: string, ctx: {
|
|
18
|
+
organizationId: string;
|
|
19
|
+
session?: unknown;
|
|
20
|
+
}): Promise<ITillGrant | null>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
@@ -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 };
|
package/dist/schemas/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody };
|
|
1
|
+
export { blindCloseBody, closeBody, forceCloseBody, objectIdString, openShiftBody, pauseBody, recordCashMovementBody, resumeBody } from "./shift.mjs";
|
package/dist/schemas/shift.d.mts
CHANGED
|
@@ -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
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
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.
|
|
3
|
+
"version": "0.8.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.
|
|
75
|
-
"@classytic/
|
|
76
|
-
"@classytic/
|
|
77
|
-
"@classytic/
|
|
78
|
-
"
|
|
90
|
+
"@classytic/mongokit": ">=3.47.0",
|
|
91
|
+
"@classytic/order": ">=0.24.0",
|
|
92
|
+
"@classytic/primitives": ">=0.39.0",
|
|
93
|
+
"@classytic/repo-core": ">=0.39.0",
|
|
94
|
+
"@classytic/tax-core": ">=0.7.0",
|
|
95
|
+
"@classytic/validation": ">=0.6.0",
|
|
96
|
+
"mongoose": ">=9.13.1",
|
|
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.
|
|
83
|
-
"@classytic/mongokit": "^3.
|
|
84
|
-
"@classytic/
|
|
85
|
-
"@classytic/
|
|
86
|
-
"@classytic/
|
|
87
|
-
"@
|
|
88
|
-
"@
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
111
|
+
"@classytic/dev-tools": "^0.2.1",
|
|
112
|
+
"@classytic/mongokit": "^3.47.0",
|
|
113
|
+
"@classytic/order": "^0.24.0",
|
|
114
|
+
"@classytic/primitives": "^0.39.0",
|
|
115
|
+
"@classytic/repo-core": "^0.39.0",
|
|
116
|
+
"@classytic/tax-core": "^0.7.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.13.1",
|
|
122
|
+
"publint": "^0.3.25",
|
|
123
|
+
"tsdown": "^0.23.1",
|
|
93
124
|
"typescript": "^7.0.2",
|
|
94
|
-
"vitest": "^
|
|
95
|
-
"zod": "^4.
|
|
125
|
+
"vitest": "^5.0.5",
|
|
126
|
+
"zod": "^4.6.7"
|
|
96
127
|
},
|
|
97
128
|
"keywords": [
|
|
98
129
|
"pos",
|