@battle-racing/br-common-lib 6.2.0 → 6.2.1-rc.1

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 (29) hide show
  1. package/dist/domains/gameTrack/GameTrack.schema.d.ts +4 -4
  2. package/dist/domains/gameTrack/GameTrack.schema.js +2 -2
  3. package/package.json +1 -1
  4. package/src/domains/gameTrack/GameTrack.schema.ts +2 -2
  5. package/.claude/settings.local.json +0 -8
  6. package/dist/domains/arcade/Arcade.const.d.ts +0 -9
  7. package/dist/domains/arcade/Arcade.const.js +0 -12
  8. package/dist/domains/arcade/Arcade.schema.d.ts +0 -83
  9. package/dist/domains/arcade/Arcade.schema.js +0 -48
  10. package/dist/domains/arcade/Arcade.types.d.ts +0 -11
  11. package/dist/domains/arcade/Arcade.types.js +0 -2
  12. package/dist/domains/arcade/index.d.ts +0 -3
  13. package/dist/domains/arcade/index.js +0 -19
  14. package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.d.ts +0 -13
  15. package/dist/domains/socket/clientToServer/SocketArcadeMachineClientToServerEventsParams.js +0 -2
  16. package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.d.ts +0 -7
  17. package/dist/domains/socket/inputs/SocketArcadeMachineAuthInput.js +0 -10
  18. package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.d.ts +0 -9
  19. package/dist/domains/socket/serverToClient/SocketArcadeMachineServerToClientEventsParams.js +0 -2
  20. package/dist/domains/socket/utils/SocketParamsToEventsWithAck.d.ts +0 -5
  21. package/dist/domains/socket/utils/SocketParamsToEventsWithAck.js +0 -2
  22. package/dist/domains/wallet/Wallet.const.d.ts +0 -4
  23. package/dist/domains/wallet/Wallet.const.js +0 -7
  24. package/dist/domains/wallet/Wallet.schema.d.ts +0 -57
  25. package/dist/domains/wallet/Wallet.schema.js +0 -43
  26. package/dist/domains/wallet/Wallet.types.d.ts +0 -9
  27. package/dist/domains/wallet/Wallet.types.js +0 -2
  28. package/dist/domains/wallet/index.d.ts +0 -3
  29. package/dist/domains/wallet/index.js +0 -19
@@ -17,8 +17,8 @@ export declare const gameTrackKartsConfigSchema: z.ZodObject<{
17
17
  waitTimeAfterHit: z.ZodNumber;
18
18
  }, z.core.$strip>;
19
19
  lowSpeed: z.ZodNumber;
20
- tutorialSpeed: z.ZodNumber;
21
- tutorialReturnSpeed: z.ZodNumber;
20
+ tutorialSpeed: z.ZodOptional<z.ZodNumber>;
21
+ tutorialReturnSpeed: z.ZodOptional<z.ZodNumber>;
22
22
  }, z.core.$strip>;
23
23
  export declare const gameTrackKartConfigSchema: z.ZodObject<{
24
24
  gameTrackId: z.ZodString;
@@ -74,8 +74,8 @@ export declare const gameTrackSchema: z.ZodObject<{
74
74
  waitTimeAfterHit: z.ZodNumber;
75
75
  }, z.core.$strip>;
76
76
  lowSpeed: z.ZodNumber;
77
- tutorialSpeed: z.ZodNumber;
78
- tutorialReturnSpeed: z.ZodNumber;
77
+ tutorialSpeed: z.ZodOptional<z.ZodNumber>;
78
+ tutorialReturnSpeed: z.ZodOptional<z.ZodNumber>;
79
79
  }, z.core.$strip>;
80
80
  macAddress: z.ZodOptional<z.ZodString>;
81
81
  isConnected: z.ZodBoolean;
@@ -18,8 +18,8 @@ exports.gameTrackKartsConfigSchema = zod_1.z.object({
18
18
  diskSensorBallShooter: hardware_1.configDiskSensorBallShooterModuleOptionsSchema,
19
19
  ballSensorDiskThrower: hardware_1.configureBallSensorDiskThrowerModuleOptionsSchema,
20
20
  lowSpeed: zod_1.z.number().min(0).max(100),
21
- tutorialSpeed: zod_1.z.number().min(0).max(100),
22
- tutorialReturnSpeed: zod_1.z.number().min(0).max(100),
21
+ tutorialSpeed: zod_1.z.number().min(0).max(100).optional(),
22
+ tutorialReturnSpeed: zod_1.z.number().min(0).max(100).optional(),
23
23
  });
24
24
  exports.gameTrackKartConfigSchema = zod_1.z.object({
25
25
  gameTrackId: zod_1.z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@battle-racing/br-common-lib",
3
- "version": "6.2.0",
3
+ "version": "6.2.1-rc.1",
4
4
  "description": "Common library for all Battle Racing Repositorios",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -20,8 +20,8 @@ export const gameTrackKartsConfigSchema = z.object({
20
20
  diskSensorBallShooter: configDiskSensorBallShooterModuleOptionsSchema,
21
21
  ballSensorDiskThrower: configureBallSensorDiskThrowerModuleOptionsSchema,
22
22
  lowSpeed: z.number().min(0).max(100),
23
- tutorialSpeed: z.number().min(0).max(100),
24
- tutorialReturnSpeed: z.number().min(0).max(100),
23
+ tutorialSpeed: z.number().min(0).max(100).optional(),
24
+ tutorialReturnSpeed: z.number().min(0).max(100).optional(),
25
25
  });
26
26
 
27
27
  export const gameTrackKartConfigSchema = z.object({
@@ -1,8 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm whoami *)",
5
- "Bash(npm config *)"
6
- ]
7
- }
8
- }
@@ -1,9 +0,0 @@
1
- export declare const ARCADE_SESSION_STATUS: {
2
- readonly ACTIVE: "ACTIVE";
3
- readonly FINISHED: "FINISHED";
4
- readonly ABANDONED: "ABANDONED";
5
- };
6
- export declare const ARCADE_SESSION_ORIGIN: {
7
- readonly QR: "QR";
8
- readonly ANONYMOUS: "ANONYMOUS";
9
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ARCADE_SESSION_ORIGIN = exports.ARCADE_SESSION_STATUS = void 0;
4
- exports.ARCADE_SESSION_STATUS = {
5
- ACTIVE: 'ACTIVE',
6
- FINISHED: 'FINISHED',
7
- ABANDONED: 'ABANDONED',
8
- };
9
- exports.ARCADE_SESSION_ORIGIN = {
10
- QR: 'QR',
11
- ANONYMOUS: 'ANONYMOUS',
12
- };
@@ -1,83 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const arcadeSessionStatusSchema: z.ZodEnum<{
3
- readonly ACTIVE: "ACTIVE";
4
- readonly FINISHED: "FINISHED";
5
- readonly ABANDONED: "ABANDONED";
6
- }>;
7
- export declare const arcadeSessionOriginSchema: z.ZodEnum<{
8
- readonly QR: "QR";
9
- readonly ANONYMOUS: "ANONYMOUS";
10
- }>;
11
- /** Readable id printed in the machine QR, e.g. "marble-table-01" */
12
- export declare const arcadeMachineIdSchema: z.ZodString;
13
- export declare const arcadeMachineSchema: z.ZodObject<{
14
- id: z.ZodString;
15
- name: z.ZodString;
16
- maxCoinsDelta: z.ZodNumber;
17
- isActive: z.ZodDefault<z.ZodBoolean>;
18
- createdAt: z.ZodDate;
19
- }, z.core.$strip>;
20
- export declare const createArcadeMachineInputSchema: z.ZodObject<{
21
- id: z.ZodString;
22
- name: z.ZodString;
23
- maxCoinsDelta: z.ZodNumber;
24
- }, z.core.$strip>;
25
- export declare const qrArcadeSessionSchema: z.ZodObject<{
26
- id: z.ZodUUID;
27
- machineId: z.ZodString;
28
- status: z.ZodEnum<{
29
- readonly ACTIVE: "ACTIVE";
30
- readonly FINISHED: "FINISHED";
31
- readonly ABANDONED: "ABANDONED";
32
- }>;
33
- coinsDelta: z.ZodOptional<z.ZodNumber>;
34
- startedAt: z.ZodDate;
35
- finishedAt: z.ZodOptional<z.ZodDate>;
36
- origin: z.ZodLiteral<"QR">;
37
- userId: z.ZodUUID;
38
- startingBalance: z.ZodNumber;
39
- }, z.core.$strip>;
40
- export declare const anonymousArcadeSessionSchema: z.ZodObject<{
41
- id: z.ZodUUID;
42
- machineId: z.ZodString;
43
- status: z.ZodEnum<{
44
- readonly ACTIVE: "ACTIVE";
45
- readonly FINISHED: "FINISHED";
46
- readonly ABANDONED: "ABANDONED";
47
- }>;
48
- coinsDelta: z.ZodOptional<z.ZodNumber>;
49
- startedAt: z.ZodDate;
50
- finishedAt: z.ZodOptional<z.ZodDate>;
51
- origin: z.ZodLiteral<"ANONYMOUS">;
52
- }, z.core.$strip>;
53
- export declare const arcadeSessionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
- id: z.ZodUUID;
55
- machineId: z.ZodString;
56
- status: z.ZodEnum<{
57
- readonly ACTIVE: "ACTIVE";
58
- readonly FINISHED: "FINISHED";
59
- readonly ABANDONED: "ABANDONED";
60
- }>;
61
- coinsDelta: z.ZodOptional<z.ZodNumber>;
62
- startedAt: z.ZodDate;
63
- finishedAt: z.ZodOptional<z.ZodDate>;
64
- origin: z.ZodLiteral<"QR">;
65
- userId: z.ZodUUID;
66
- startingBalance: z.ZodNumber;
67
- }, z.core.$strip>, z.ZodObject<{
68
- id: z.ZodUUID;
69
- machineId: z.ZodString;
70
- status: z.ZodEnum<{
71
- readonly ACTIVE: "ACTIVE";
72
- readonly FINISHED: "FINISHED";
73
- readonly ABANDONED: "ABANDONED";
74
- }>;
75
- coinsDelta: z.ZodOptional<z.ZodNumber>;
76
- startedAt: z.ZodDate;
77
- finishedAt: z.ZodOptional<z.ZodDate>;
78
- origin: z.ZodLiteral<"ANONYMOUS">;
79
- }, z.core.$strip>], "origin">;
80
- export declare const finishArcadeSessionInputSchema: z.ZodObject<{
81
- sessionId: z.ZodUUID;
82
- coinsDelta: z.ZodNumber;
83
- }, z.core.$strip>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finishArcadeSessionInputSchema = exports.arcadeSessionSchema = exports.anonymousArcadeSessionSchema = exports.qrArcadeSessionSchema = exports.createArcadeMachineInputSchema = exports.arcadeMachineSchema = exports.arcadeMachineIdSchema = exports.arcadeSessionOriginSchema = exports.arcadeSessionStatusSchema = void 0;
4
- const zod_1 = require("zod");
5
- const wallet_1 = require("../wallet");
6
- const Arcade_const_1 = require("./Arcade.const");
7
- exports.arcadeSessionStatusSchema = zod_1.z.enum(Arcade_const_1.ARCADE_SESSION_STATUS);
8
- exports.arcadeSessionOriginSchema = zod_1.z.enum(Arcade_const_1.ARCADE_SESSION_ORIGIN);
9
- /** Readable id printed in the machine QR, e.g. "marble-table-01" */
10
- exports.arcadeMachineIdSchema = zod_1.z
11
- .string()
12
- .regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, 'Machine id must use lowercase letters, numbers and dashes');
13
- exports.arcadeMachineSchema = zod_1.z.object({
14
- id: exports.arcadeMachineIdSchema,
15
- name: zod_1.z.string().min(1),
16
- maxCoinsDelta: wallet_1.coinsAmountSchema.positive(),
17
- isActive: zod_1.z.boolean().default(true),
18
- createdAt: zod_1.z.date(),
19
- });
20
- exports.createArcadeMachineInputSchema = exports.arcadeMachineSchema.pick({
21
- id: true,
22
- name: true,
23
- maxCoinsDelta: true,
24
- });
25
- const baseArcadeSessionSchema = zod_1.z.object({
26
- id: zod_1.z.uuidv4(),
27
- machineId: exports.arcadeMachineIdSchema,
28
- status: exports.arcadeSessionStatusSchema,
29
- coinsDelta: wallet_1.coinsAmountSchema.optional(),
30
- startedAt: zod_1.z.date(),
31
- finishedAt: zod_1.z.date().optional(),
32
- });
33
- exports.qrArcadeSessionSchema = baseArcadeSessionSchema.extend({
34
- origin: zod_1.z.literal(Arcade_const_1.ARCADE_SESSION_ORIGIN.QR),
35
- userId: zod_1.z.uuidv4(),
36
- startingBalance: wallet_1.coinsAmountSchema.nonnegative(),
37
- });
38
- exports.anonymousArcadeSessionSchema = baseArcadeSessionSchema.extend({
39
- origin: zod_1.z.literal(Arcade_const_1.ARCADE_SESSION_ORIGIN.ANONYMOUS),
40
- });
41
- exports.arcadeSessionSchema = zod_1.z.discriminatedUnion('origin', [
42
- exports.qrArcadeSessionSchema,
43
- exports.anonymousArcadeSessionSchema,
44
- ]);
45
- exports.finishArcadeSessionInputSchema = zod_1.z.object({
46
- sessionId: zod_1.z.uuidv4(),
47
- coinsDelta: wallet_1.coinsAmountSchema,
48
- });
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- import { anonymousArcadeSessionSchema, arcadeMachineIdSchema, arcadeMachineSchema, arcadeSessionOriginSchema, arcadeSessionSchema, arcadeSessionStatusSchema, createArcadeMachineInputSchema, finishArcadeSessionInputSchema, qrArcadeSessionSchema } from './Arcade.schema';
3
- export type ArcadeSessionStatus = z.infer<typeof arcadeSessionStatusSchema>;
4
- export type ArcadeSessionOrigin = z.infer<typeof arcadeSessionOriginSchema>;
5
- export type ArcadeMachineId = z.infer<typeof arcadeMachineIdSchema>;
6
- export type ArcadeMachine = z.infer<typeof arcadeMachineSchema>;
7
- export type CreateArcadeMachineInput = z.infer<typeof createArcadeMachineInputSchema>;
8
- export type QrArcadeSession = z.infer<typeof qrArcadeSessionSchema>;
9
- export type AnonymousArcadeSession = z.infer<typeof anonymousArcadeSessionSchema>;
10
- export type ArcadeSession = z.infer<typeof arcadeSessionSchema>;
11
- export type FinishArcadeSessionInput = z.infer<typeof finishArcadeSessionInputSchema>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export * from './Arcade.const';
2
- export * from './Arcade.schema';
3
- export * from './Arcade.types';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Arcade.const"), exports);
18
- __exportStar(require("./Arcade.schema"), exports);
19
- __exportStar(require("./Arcade.types"), exports);
@@ -1,13 +0,0 @@
1
- import type { ArcadeSession, FinishArcadeSessionInput } from '../../arcade';
2
- import type { Response } from '../../response';
3
- import type { ArcadeSessionStartedPayload } from '../serverToClient';
4
- export interface SocketArcadeMachineClientToServerEventsParams {
5
- 'arcade-machine:session:start-anonymous': undefined;
6
- 'arcade-machine:session:finish': FinishArcadeSessionInput;
7
- }
8
- export interface SocketArcadeMachineClientToServerAckResponses {
9
- 'arcade-machine:session:start-anonymous': Response<ArcadeSessionStartedPayload>;
10
- 'arcade-machine:session:finish': Response<{
11
- session: ArcadeSession;
12
- }>;
13
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- /** Sent by the arcade machine in the socket.io handshake `auth` field */
3
- export declare const socketArcadeMachineAuthInputSchema: z.ZodObject<{
4
- machineId: z.ZodString;
5
- secret: z.ZodString;
6
- }, z.core.$strip>;
7
- export type SocketArcadeMachineAuthInput = z.infer<typeof socketArcadeMachineAuthInputSchema>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.socketArcadeMachineAuthInputSchema = void 0;
4
- const zod_1 = require("zod");
5
- const arcade_1 = require("../../arcade");
6
- /** Sent by the arcade machine in the socket.io handshake `auth` field */
7
- exports.socketArcadeMachineAuthInputSchema = zod_1.z.object({
8
- machineId: arcade_1.arcadeMachineIdSchema,
9
- secret: zod_1.z.string().min(1),
10
- });
@@ -1,9 +0,0 @@
1
- import type { ArcadeSession } from '../../arcade';
2
- export type ArcadeSessionStartedPayload = {
3
- session: ArcadeSession;
4
- playerName?: string;
5
- };
6
- export interface SocketArcadeMachineServerToClientEventsParams {
7
- /** A session was opened for this machine (e.g. a user scanned the machine QR) */
8
- 'arcade-machine:session:started': ArcadeSessionStartedPayload;
9
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export type SocketAck<Response> = (response: Response) => void;
2
- /** Like SocketParamsToEvents, but every event receives an ack callback as last argument */
3
- export type SocketParamsToEventsWithAck<Event, Ack extends Record<keyof Event, unknown>> = {
4
- [EventKey in keyof Event]: Event[EventKey] extends undefined ? (ack: SocketAck<Ack[EventKey]>) => void : (payload: Event[EventKey], ack: SocketAck<Ack[EventKey]>) => void;
5
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- export declare const WALLET_TRANSACTION_TYPE: {
2
- readonly ADMIN_ADJUSTMENT: "ADMIN_ADJUSTMENT";
3
- readonly ARCADE_SESSION: "ARCADE_SESSION";
4
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WALLET_TRANSACTION_TYPE = void 0;
4
- exports.WALLET_TRANSACTION_TYPE = {
5
- ADMIN_ADJUSTMENT: 'ADMIN_ADJUSTMENT',
6
- ARCADE_SESSION: 'ARCADE_SESSION',
7
- };
@@ -1,57 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const walletTransactionTypeSchema: z.ZodEnum<{
3
- readonly ADMIN_ADJUSTMENT: "ADMIN_ADJUSTMENT";
4
- readonly ARCADE_SESSION: "ARCADE_SESSION";
5
- }>;
6
- export declare const coinsAmountSchema: z.ZodNumber;
7
- export declare const walletSchema: z.ZodObject<{
8
- userId: z.ZodUUID;
9
- balance: z.ZodNumber;
10
- updatedAt: z.ZodDate;
11
- }, z.core.$strip>;
12
- export declare const adminAdjustmentTransactionSchema: z.ZodObject<{
13
- id: z.ZodUUID;
14
- userId: z.ZodUUID;
15
- amount: z.ZodNumber;
16
- balanceAfter: z.ZodNumber;
17
- createdAt: z.ZodDate;
18
- type: z.ZodLiteral<"ADMIN_ADJUSTMENT">;
19
- adminUserId: z.ZodUUID;
20
- reason: z.ZodString;
21
- }, z.core.$strip>;
22
- export declare const arcadeSessionTransactionSchema: z.ZodObject<{
23
- id: z.ZodUUID;
24
- userId: z.ZodUUID;
25
- amount: z.ZodNumber;
26
- balanceAfter: z.ZodNumber;
27
- createdAt: z.ZodDate;
28
- type: z.ZodLiteral<"ARCADE_SESSION">;
29
- arcadeSessionId: z.ZodUUID;
30
- }, z.core.$strip>;
31
- export declare const walletTransactionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
- id: z.ZodUUID;
33
- userId: z.ZodUUID;
34
- amount: z.ZodNumber;
35
- balanceAfter: z.ZodNumber;
36
- createdAt: z.ZodDate;
37
- type: z.ZodLiteral<"ADMIN_ADJUSTMENT">;
38
- adminUserId: z.ZodUUID;
39
- reason: z.ZodString;
40
- }, z.core.$strip>, z.ZodObject<{
41
- id: z.ZodUUID;
42
- userId: z.ZodUUID;
43
- amount: z.ZodNumber;
44
- balanceAfter: z.ZodNumber;
45
- createdAt: z.ZodDate;
46
- type: z.ZodLiteral<"ARCADE_SESSION">;
47
- arcadeSessionId: z.ZodUUID;
48
- }, z.core.$strip>], "type">;
49
- export declare const walletTransactionsFilterSchema: z.ZodObject<{
50
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
51
- cursor: z.ZodOptional<z.ZodISODateTime>;
52
- }, z.core.$strip>;
53
- export declare const walletAdjustmentInputSchema: z.ZodObject<{
54
- userId: z.ZodUUID;
55
- amount: z.ZodNumber;
56
- reason: z.ZodString;
57
- }, z.core.$strip>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.walletAdjustmentInputSchema = exports.walletTransactionsFilterSchema = exports.walletTransactionSchema = exports.arcadeSessionTransactionSchema = exports.adminAdjustmentTransactionSchema = exports.walletSchema = exports.coinsAmountSchema = exports.walletTransactionTypeSchema = void 0;
4
- const zod_1 = require("zod");
5
- const Wallet_const_1 = require("./Wallet.const");
6
- exports.walletTransactionTypeSchema = zod_1.z.enum(Wallet_const_1.WALLET_TRANSACTION_TYPE);
7
- exports.coinsAmountSchema = zod_1.z.number().int();
8
- exports.walletSchema = zod_1.z.object({
9
- userId: zod_1.z.uuidv4(),
10
- balance: exports.coinsAmountSchema.nonnegative(),
11
- updatedAt: zod_1.z.date(),
12
- });
13
- const baseWalletTransactionSchema = zod_1.z.object({
14
- id: zod_1.z.uuidv4(),
15
- userId: zod_1.z.uuidv4(),
16
- /** Positive adds coins, negative removes coins */
17
- amount: exports.coinsAmountSchema,
18
- balanceAfter: exports.coinsAmountSchema.nonnegative(),
19
- createdAt: zod_1.z.date(),
20
- });
21
- exports.adminAdjustmentTransactionSchema = baseWalletTransactionSchema.extend({
22
- type: zod_1.z.literal(Wallet_const_1.WALLET_TRANSACTION_TYPE.ADMIN_ADJUSTMENT),
23
- adminUserId: zod_1.z.uuidv4(),
24
- reason: zod_1.z.string().min(1),
25
- });
26
- exports.arcadeSessionTransactionSchema = baseWalletTransactionSchema.extend({
27
- type: zod_1.z.literal(Wallet_const_1.WALLET_TRANSACTION_TYPE.ARCADE_SESSION),
28
- arcadeSessionId: zod_1.z.uuidv4(),
29
- });
30
- exports.walletTransactionSchema = zod_1.z.discriminatedUnion('type', [
31
- exports.adminAdjustmentTransactionSchema,
32
- exports.arcadeSessionTransactionSchema,
33
- ]);
34
- exports.walletTransactionsFilterSchema = zod_1.z.object({
35
- limit: zod_1.z.coerce.number().int().min(1).max(100).default(20),
36
- /** `createdAt` of the last item from the previous page */
37
- cursor: zod_1.z.iso.datetime().optional(),
38
- });
39
- exports.walletAdjustmentInputSchema = zod_1.z.object({
40
- userId: zod_1.z.uuidv4(),
41
- amount: exports.coinsAmountSchema.refine((value) => value !== 0, { message: 'Amount must not be zero' }),
42
- reason: zod_1.z.string().min(1, 'Reason is required'),
43
- });
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- import { adminAdjustmentTransactionSchema, arcadeSessionTransactionSchema, walletAdjustmentInputSchema, walletSchema, walletTransactionSchema, walletTransactionTypeSchema, walletTransactionsFilterSchema } from './Wallet.schema';
3
- export type WalletTransactionType = z.infer<typeof walletTransactionTypeSchema>;
4
- export type Wallet = z.infer<typeof walletSchema>;
5
- export type AdminAdjustmentTransaction = z.infer<typeof adminAdjustmentTransactionSchema>;
6
- export type ArcadeSessionTransaction = z.infer<typeof arcadeSessionTransactionSchema>;
7
- export type WalletTransaction = z.infer<typeof walletTransactionSchema>;
8
- export type WalletAdjustmentInput = z.infer<typeof walletAdjustmentInputSchema>;
9
- export type WalletTransactionsFilter = z.infer<typeof walletTransactionsFilterSchema>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export * from './Wallet.const';
2
- export * from './Wallet.schema';
3
- export * from './Wallet.types';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Wallet.const"), exports);
18
- __exportStar(require("./Wallet.schema"), exports);
19
- __exportStar(require("./Wallet.types"), exports);