@veruna/api-contracts 1.0.39 → 1.0.41

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 (68) hide show
  1. package/build/controllers/index.d.ts +2 -0
  2. package/build/controllers/index.js +5 -1
  3. package/build/controllers/sitemap.controllers.d.ts +1 -0
  4. package/build/controllers/sitemap.controllers.js +4 -0
  5. package/build/controllers/wallet.controllers.d.ts +7 -0
  6. package/build/controllers/wallet.controllers.js +10 -0
  7. package/build/rest-api.d.ts +3 -0
  8. package/build/rest-api.js +4 -0
  9. package/build/routes/index.d.ts +2 -0
  10. package/build/routes/index.js +5 -1
  11. package/build/routes/sitemap.routes.d.ts +3 -0
  12. package/build/routes/sitemap.routes.js +6 -0
  13. package/build/routes/wallet.routes.d.ts +11 -0
  14. package/build/routes/wallet.routes.js +14 -0
  15. package/build/shared/common-schemas.d.ts +5 -0
  16. package/build/shared/common-schemas.js +9 -4
  17. package/build/shared/regex.d.ts +1 -0
  18. package/build/shared/regex.js +3 -1
  19. package/build/v1/blog/admin/commands/create-post.command.d.ts +4 -2
  20. package/build/v1/blog/admin/commands/update-post.command.d.ts +4 -2
  21. package/build/v1/blog/admin/queries/get-post.query.d.ts +2 -1
  22. package/build/v1/blog/admin/queries/get-posts.query.d.ts +2 -1
  23. package/build/v1/blog/public/queries/get-post-by-alias.query.d.ts +6 -1
  24. package/build/v1/blog/public/queries/get-post-by-alias.query.js +1 -1
  25. package/build/v1/blog/public/queries/get-posts.query.d.ts +2 -1
  26. package/build/v1/blog/schemas/blog-post-mark.enum.d.ts +7 -0
  27. package/build/v1/blog/schemas/blog-post-mark.enum.js +11 -0
  28. package/build/v1/blog/schemas/create-post-request.schema.d.ts +3 -1
  29. package/build/v1/blog/schemas/create-post-request.schema.js +6 -4
  30. package/build/v1/blog/schemas/index.d.ts +2 -0
  31. package/build/v1/blog/schemas/index.js +2 -0
  32. package/build/v1/blog/schemas/post-response.schema.d.ts +3 -1
  33. package/build/v1/blog/schemas/post-response.schema.js +3 -1
  34. package/build/v1/blog/schemas/public-post-response.schema.d.ts +44 -0
  35. package/build/v1/blog/schemas/public-post-response.schema.js +20 -0
  36. package/build/v1/blog/schemas/update-post-request.schema.d.ts +3 -1
  37. package/build/v1/blog/schemas/update-post-request.schema.js +6 -3
  38. package/build/v1/index.d.ts +2 -0
  39. package/build/v1/index.js +2 -0
  40. package/build/v1/sitemap/index.d.ts +1 -0
  41. package/build/v1/sitemap/index.js +5 -0
  42. package/build/v1/sitemap/sitemap-changefreq.enum.d.ts +9 -0
  43. package/build/v1/sitemap/sitemap-changefreq.enum.js +13 -0
  44. package/build/v1/wallet/index.d.ts +5 -0
  45. package/build/v1/wallet/index.js +25 -0
  46. package/build/v1/wallet/queries/get-balance-summary.query.d.ts +29 -0
  47. package/build/v1/wallet/queries/get-balance-summary.query.js +18 -0
  48. package/build/v1/wallet/queries/index.d.ts +1 -0
  49. package/build/v1/wallet/queries/index.js +5 -0
  50. package/build/v1/wallet/schemas/balance-response.schema.d.ts +40 -0
  51. package/build/v1/wallet/schemas/balance-response.schema.js +32 -0
  52. package/build/v1/wallet/schemas/balance-status.enum.d.ts +11 -0
  53. package/build/v1/wallet/schemas/balance-status.enum.js +15 -0
  54. package/build/v1/wallet/schemas/hold-status.enum.d.ts +10 -0
  55. package/build/v1/wallet/schemas/hold-status.enum.js +14 -0
  56. package/build/v1/wallet/schemas/index.d.ts +7 -0
  57. package/build/v1/wallet/schemas/index.js +25 -0
  58. package/build/v1/wallet/schemas/initiator-type.enum.d.ts +12 -0
  59. package/build/v1/wallet/schemas/initiator-type.enum.js +16 -0
  60. package/build/v1/wallet/schemas/metadata.schema.d.ts +29 -0
  61. package/build/v1/wallet/schemas/metadata.schema.js +105 -0
  62. package/build/v1/wallet/schemas/source-type.enum.d.ts +13 -0
  63. package/build/v1/wallet/schemas/source-type.enum.js +17 -0
  64. package/build/v1/wallet/schemas/transaction-type.enum.d.ts +17 -0
  65. package/build/v1/wallet/schemas/transaction-type.enum.js +21 -0
  66. package/build/v1/wallet/wallet.errors.d.ts +37 -0
  67. package/build/v1/wallet/wallet.errors.js +171 -0
  68. package/package.json +1 -1
@@ -4,6 +4,7 @@ exports.UpdatePostRequestSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const regex_1 = require("../../../shared/regex");
6
6
  const blog_post_status_enum_1 = require("./blog-post-status.enum");
7
+ const blog_post_mark_enum_1 = require("./blog-post-mark.enum");
7
8
  exports.UpdatePostRequestSchema = zod_1.z
8
9
  .object({
9
10
  alias: zod_1.z
@@ -14,6 +15,7 @@ exports.UpdatePostRequestSchema = zod_1.z
14
15
  .transform((val) => val.toLowerCase().trim())
15
16
  .optional(),
16
17
  title: zod_1.z.string().min(1).max(300).optional(),
18
+ description: zod_1.z.string().max(1000).optional(),
17
19
  metaTitle: zod_1.z.string().min(1).max(100).optional(),
18
20
  metaDescription: zod_1.z.string().min(1).max(200).optional(),
19
21
  content: zod_1.z.string().min(1).max(1000000).optional(),
@@ -22,15 +24,16 @@ exports.UpdatePostRequestSchema = zod_1.z
22
24
  categoryIds: zod_1.z.array(zod_1.z.string().regex(regex_1.UUID_REGEX)).min(1).optional(),
23
25
  status: zod_1.z.nativeEnum(blog_post_status_enum_1.BlogPostStatus).optional(),
24
26
  pageId: zod_1.z.string().regex(regex_1.UUID_REGEX).nullable().optional(),
25
- aiWidgetEnabled: zod_1.z.boolean().optional(),
27
+ marks: zod_1.z.array(zod_1.z.nativeEnum(blog_post_mark_enum_1.BlogPostMark)).optional(),
26
28
  aiWidgetPlaceholder: zod_1.z.string().max(500).nullable().optional(),
27
29
  aiWidgetPrompt: zod_1.z.string().max(2000).nullable().optional(),
28
30
  })
29
31
  .refine((data) => {
30
- if (data.aiWidgetEnabled === true) {
32
+ var _a;
33
+ if ((_a = data.marks) === null || _a === void 0 ? void 0 : _a.includes(blog_post_mark_enum_1.BlogPostMark.AI_WIDGET)) {
31
34
  return data.pageId && data.aiWidgetPlaceholder && data.aiWidgetPrompt;
32
35
  }
33
36
  return true;
34
37
  }, {
35
- message: 'pageId, aiWidgetPlaceholder and aiWidgetPrompt are required when aiWidgetEnabled is true',
38
+ message: 'pageId, aiWidgetPlaceholder and aiWidgetPrompt are required when AI_WIDGET mark is present',
36
39
  });
@@ -12,3 +12,5 @@ export * from './chat';
12
12
  export * from './message';
13
13
  export * from './ai';
14
14
  export * from './verification';
15
+ export * from './sitemap';
16
+ export * from './wallet';
package/build/v1/index.js CHANGED
@@ -28,3 +28,5 @@ __exportStar(require("./chat"), exports);
28
28
  __exportStar(require("./message"), exports);
29
29
  __exportStar(require("./ai"), exports);
30
30
  __exportStar(require("./verification"), exports);
31
+ __exportStar(require("./sitemap"), exports);
32
+ __exportStar(require("./wallet"), exports);
@@ -0,0 +1 @@
1
+ export { SitemapChangefreq } from './sitemap-changefreq.enum';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SitemapChangefreq = void 0;
4
+ var sitemap_changefreq_enum_1 = require("./sitemap-changefreq.enum");
5
+ Object.defineProperty(exports, "SitemapChangefreq", { enumerable: true, get: function () { return sitemap_changefreq_enum_1.SitemapChangefreq; } });
@@ -0,0 +1,9 @@
1
+ export declare enum SitemapChangefreq {
2
+ ALWAYS = "always",
3
+ HOURLY = "hourly",
4
+ DAILY = "daily",
5
+ WEEKLY = "weekly",
6
+ MONTHLY = "monthly",
7
+ YEARLY = "yearly",
8
+ NEVER = "never"
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SitemapChangefreq = void 0;
4
+ var SitemapChangefreq;
5
+ (function (SitemapChangefreq) {
6
+ SitemapChangefreq["ALWAYS"] = "always";
7
+ SitemapChangefreq["HOURLY"] = "hourly";
8
+ SitemapChangefreq["DAILY"] = "daily";
9
+ SitemapChangefreq["WEEKLY"] = "weekly";
10
+ SitemapChangefreq["MONTHLY"] = "monthly";
11
+ SitemapChangefreq["YEARLY"] = "yearly";
12
+ SitemapChangefreq["NEVER"] = "never";
13
+ })(SitemapChangefreq || (exports.SitemapChangefreq = SitemapChangefreq = {}));
@@ -0,0 +1,5 @@
1
+ export * from './schemas';
2
+ export * from './wallet.errors';
3
+ export * from './queries';
4
+ export { WALLET_CONTROLLER } from '../../controllers';
5
+ export { WALLET_ROUTES } from '../../routes';
@@ -0,0 +1,25 @@
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
+ exports.WALLET_ROUTES = exports.WALLET_CONTROLLER = void 0;
18
+ __exportStar(require("./schemas"), exports);
19
+ __exportStar(require("./wallet.errors"), exports);
20
+ __exportStar(require("./queries"), exports);
21
+ // Re-export from centralized locations
22
+ var controllers_1 = require("../../controllers");
23
+ Object.defineProperty(exports, "WALLET_CONTROLLER", { enumerable: true, get: function () { return controllers_1.WALLET_CONTROLLER; } });
24
+ var routes_1 = require("../../routes");
25
+ Object.defineProperty(exports, "WALLET_ROUTES", { enumerable: true, get: function () { return routes_1.WALLET_ROUTES; } });
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { HttpMethod } from '../../../shared/http-method';
3
+ /**
4
+ * Get Balance Summary Query
5
+ * Public API - returns user's balance summary
6
+ */
7
+ export declare namespace GetBalanceSummaryQuery {
8
+ const Request: z.ZodObject<{}, z.core.$strip>;
9
+ const Response: z.ZodObject<{
10
+ userId: z.ZodString;
11
+ totalAvailable: z.ZodString;
12
+ totalHeld: z.ZodString;
13
+ balances: z.ZodArray<z.ZodObject<{
14
+ id: z.ZodString;
15
+ typeCode: z.ZodString;
16
+ typeName: z.ZodString;
17
+ amount: z.ZodString;
18
+ held: z.ZodString;
19
+ available: z.ZodString;
20
+ status: z.ZodEnum<typeof import("../schemas").BalanceStatus>;
21
+ expiresAt: z.ZodNullable<z.ZodString>;
22
+ createdAt: z.ZodString;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ const URL: "/api/v1/wallet/balance";
26
+ const METHOD = HttpMethod.GET;
27
+ type RequestType = z.infer<typeof Request>;
28
+ type ResponseType = z.infer<typeof Response>;
29
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetBalanceSummaryQuery = void 0;
4
+ const zod_1 = require("zod");
5
+ const schemas_1 = require("../schemas");
6
+ const rest_api_1 = require("../../../rest-api");
7
+ const http_method_1 = require("../../../shared/http-method");
8
+ /**
9
+ * Get Balance Summary Query
10
+ * Public API - returns user's balance summary
11
+ */
12
+ var GetBalanceSummaryQuery;
13
+ (function (GetBalanceSummaryQuery) {
14
+ GetBalanceSummaryQuery.Request = zod_1.z.object({});
15
+ GetBalanceSummaryQuery.Response = schemas_1.BalanceSummaryResponseSchema;
16
+ GetBalanceSummaryQuery.URL = rest_api_1.REST_API.V1.WALLET.BALANCE;
17
+ GetBalanceSummaryQuery.METHOD = http_method_1.HttpMethod.GET;
18
+ })(GetBalanceSummaryQuery || (exports.GetBalanceSummaryQuery = GetBalanceSummaryQuery = {}));
@@ -0,0 +1 @@
1
+ export { GetBalanceSummaryQuery } from './get-balance-summary.query';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetBalanceSummaryQuery = void 0;
4
+ var get_balance_summary_query_1 = require("./get-balance-summary.query");
5
+ Object.defineProperty(exports, "GetBalanceSummaryQuery", { enumerable: true, get: function () { return get_balance_summary_query_1.GetBalanceSummaryQuery; } });
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ import { BalanceStatus } from './balance-status.enum';
3
+ /**
4
+ * Single Balance Item Response Schema
5
+ * Note: amount, held, available are strings to preserve BigInt precision
6
+ */
7
+ export declare const BalanceItemResponseSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ typeCode: z.ZodString;
10
+ typeName: z.ZodString;
11
+ amount: z.ZodString;
12
+ held: z.ZodString;
13
+ available: z.ZodString;
14
+ status: z.ZodEnum<typeof BalanceStatus>;
15
+ expiresAt: z.ZodNullable<z.ZodString>;
16
+ createdAt: z.ZodString;
17
+ }, z.core.$strip>;
18
+ /**
19
+ * Balance Summary Response Schema
20
+ * See WALLET_API.md section 4.6
21
+ * Note: totalAvailable, totalHeld are strings to preserve BigInt precision
22
+ */
23
+ export declare const BalanceSummaryResponseSchema: z.ZodObject<{
24
+ userId: z.ZodString;
25
+ totalAvailable: z.ZodString;
26
+ totalHeld: z.ZodString;
27
+ balances: z.ZodArray<z.ZodObject<{
28
+ id: z.ZodString;
29
+ typeCode: z.ZodString;
30
+ typeName: z.ZodString;
31
+ amount: z.ZodString;
32
+ held: z.ZodString;
33
+ available: z.ZodString;
34
+ status: z.ZodEnum<typeof BalanceStatus>;
35
+ expiresAt: z.ZodNullable<z.ZodString>;
36
+ createdAt: z.ZodString;
37
+ }, z.core.$strip>>;
38
+ }, z.core.$strip>;
39
+ export type BalanceItemResponse = z.infer<typeof BalanceItemResponseSchema>;
40
+ export type BalanceSummaryResponse = z.infer<typeof BalanceSummaryResponseSchema>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalanceSummaryResponseSchema = exports.BalanceItemResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const shared_1 = require("../../../shared");
6
+ const balance_status_enum_1 = require("./balance-status.enum");
7
+ /**
8
+ * Single Balance Item Response Schema
9
+ * Note: amount, held, available are strings to preserve BigInt precision
10
+ */
11
+ exports.BalanceItemResponseSchema = zod_1.z.object({
12
+ id: zod_1.z.string().uuid(),
13
+ typeCode: zod_1.z.string(),
14
+ typeName: zod_1.z.string(),
15
+ amount: shared_1.BigIntStringSchema,
16
+ held: shared_1.BigIntStringSchema,
17
+ available: shared_1.BigIntStringSchema,
18
+ status: zod_1.z.nativeEnum(balance_status_enum_1.BalanceStatus),
19
+ expiresAt: zod_1.z.string().datetime().nullable(),
20
+ createdAt: zod_1.z.string().datetime(),
21
+ });
22
+ /**
23
+ * Balance Summary Response Schema
24
+ * See WALLET_API.md section 4.6
25
+ * Note: totalAvailable, totalHeld are strings to preserve BigInt precision
26
+ */
27
+ exports.BalanceSummaryResponseSchema = zod_1.z.object({
28
+ userId: zod_1.z.string().uuid(),
29
+ totalAvailable: shared_1.BigIntStringSchema,
30
+ totalHeld: shared_1.BigIntStringSchema,
31
+ balances: zod_1.z.array(exports.BalanceItemResponseSchema),
32
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Balance Status Enum
3
+ * See WALLET_API.md section 2.2
4
+ */
5
+ export declare enum BalanceStatus {
6
+ ACTIVE = "ACTIVE",
7
+ DEPLETED = "DEPLETED",
8
+ EXPIRED = "EXPIRED",
9
+ CANCELLED = "CANCELLED",
10
+ SUSPENDED = "SUSPENDED"
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalanceStatus = void 0;
4
+ /**
5
+ * Balance Status Enum
6
+ * See WALLET_API.md section 2.2
7
+ */
8
+ var BalanceStatus;
9
+ (function (BalanceStatus) {
10
+ BalanceStatus["ACTIVE"] = "ACTIVE";
11
+ BalanceStatus["DEPLETED"] = "DEPLETED";
12
+ BalanceStatus["EXPIRED"] = "EXPIRED";
13
+ BalanceStatus["CANCELLED"] = "CANCELLED";
14
+ BalanceStatus["SUSPENDED"] = "SUSPENDED";
15
+ })(BalanceStatus || (exports.BalanceStatus = BalanceStatus = {}));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Hold Status Enum
3
+ * See WALLET_API.md section 2.3
4
+ */
5
+ export declare enum HoldStatus {
6
+ PENDING = "PENDING",
7
+ CONFIRMED = "CONFIRMED",
8
+ RELEASED = "RELEASED",
9
+ EXPIRED = "EXPIRED"
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HoldStatus = void 0;
4
+ /**
5
+ * Hold Status Enum
6
+ * See WALLET_API.md section 2.3
7
+ */
8
+ var HoldStatus;
9
+ (function (HoldStatus) {
10
+ HoldStatus["PENDING"] = "PENDING";
11
+ HoldStatus["CONFIRMED"] = "CONFIRMED";
12
+ HoldStatus["RELEASED"] = "RELEASED";
13
+ HoldStatus["EXPIRED"] = "EXPIRED";
14
+ })(HoldStatus || (exports.HoldStatus = HoldStatus = {}));
@@ -0,0 +1,7 @@
1
+ export { BalanceStatus } from './balance-status.enum';
2
+ export { HoldStatus } from './hold-status.enum';
3
+ export { TransactionType } from './transaction-type.enum';
4
+ export { SourceType } from './source-type.enum';
5
+ export { InitiatorType } from './initiator-type.enum';
6
+ export { BalanceItemResponseSchema, BalanceSummaryResponseSchema, type BalanceItemResponse, type BalanceSummaryResponse, } from './balance-response.schema';
7
+ export { MetadataSchema, validateMetadata, MAX_METADATA_SIZE, MAX_NESTING_DEPTH, MAX_METADATA_KEYS, type Metadata, } from './metadata.schema';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_METADATA_KEYS = exports.MAX_NESTING_DEPTH = exports.MAX_METADATA_SIZE = exports.validateMetadata = exports.MetadataSchema = exports.BalanceSummaryResponseSchema = exports.BalanceItemResponseSchema = exports.InitiatorType = exports.SourceType = exports.TransactionType = exports.HoldStatus = exports.BalanceStatus = void 0;
4
+ // Enums
5
+ var balance_status_enum_1 = require("./balance-status.enum");
6
+ Object.defineProperty(exports, "BalanceStatus", { enumerable: true, get: function () { return balance_status_enum_1.BalanceStatus; } });
7
+ var hold_status_enum_1 = require("./hold-status.enum");
8
+ Object.defineProperty(exports, "HoldStatus", { enumerable: true, get: function () { return hold_status_enum_1.HoldStatus; } });
9
+ var transaction_type_enum_1 = require("./transaction-type.enum");
10
+ Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return transaction_type_enum_1.TransactionType; } });
11
+ var source_type_enum_1 = require("./source-type.enum");
12
+ Object.defineProperty(exports, "SourceType", { enumerable: true, get: function () { return source_type_enum_1.SourceType; } });
13
+ var initiator_type_enum_1 = require("./initiator-type.enum");
14
+ Object.defineProperty(exports, "InitiatorType", { enumerable: true, get: function () { return initiator_type_enum_1.InitiatorType; } });
15
+ // Response schemas
16
+ var balance_response_schema_1 = require("./balance-response.schema");
17
+ Object.defineProperty(exports, "BalanceItemResponseSchema", { enumerable: true, get: function () { return balance_response_schema_1.BalanceItemResponseSchema; } });
18
+ Object.defineProperty(exports, "BalanceSummaryResponseSchema", { enumerable: true, get: function () { return balance_response_schema_1.BalanceSummaryResponseSchema; } });
19
+ // Metadata validation
20
+ var metadata_schema_1 = require("./metadata.schema");
21
+ Object.defineProperty(exports, "MetadataSchema", { enumerable: true, get: function () { return metadata_schema_1.MetadataSchema; } });
22
+ Object.defineProperty(exports, "validateMetadata", { enumerable: true, get: function () { return metadata_schema_1.validateMetadata; } });
23
+ Object.defineProperty(exports, "MAX_METADATA_SIZE", { enumerable: true, get: function () { return metadata_schema_1.MAX_METADATA_SIZE; } });
24
+ Object.defineProperty(exports, "MAX_NESTING_DEPTH", { enumerable: true, get: function () { return metadata_schema_1.MAX_NESTING_DEPTH; } });
25
+ Object.defineProperty(exports, "MAX_METADATA_KEYS", { enumerable: true, get: function () { return metadata_schema_1.MAX_METADATA_KEYS; } });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type of entity that initiated the wallet operation
3
+ * Used for audit tracking
4
+ */
5
+ export declare enum InitiatorType {
6
+ /** Operation initiated by end user */
7
+ USER = "user",
8
+ /** Operation initiated by system (background jobs, automated processes) */
9
+ SYSTEM = "system",
10
+ /** Operation initiated by admin */
11
+ ADMIN = "admin"
12
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitiatorType = void 0;
4
+ /**
5
+ * Type of entity that initiated the wallet operation
6
+ * Used for audit tracking
7
+ */
8
+ var InitiatorType;
9
+ (function (InitiatorType) {
10
+ /** Operation initiated by end user */
11
+ InitiatorType["USER"] = "user";
12
+ /** Operation initiated by system (background jobs, automated processes) */
13
+ InitiatorType["SYSTEM"] = "system";
14
+ /** Operation initiated by admin */
15
+ InitiatorType["ADMIN"] = "admin";
16
+ })(InitiatorType || (exports.InitiatorType = InitiatorType = {}));
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Maximum size of metadata JSON in bytes
4
+ */
5
+ export declare const MAX_METADATA_SIZE = 4096;
6
+ /**
7
+ * Maximum nesting depth for metadata objects
8
+ */
9
+ export declare const MAX_NESTING_DEPTH = 3;
10
+ /**
11
+ * Maximum number of keys in metadata
12
+ */
13
+ export declare const MAX_METADATA_KEYS = 20;
14
+ /**
15
+ * Metadata schema with all security validations
16
+ */
17
+ export declare const MetadataSchema: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>>;
18
+ export type Metadata = z.infer<typeof MetadataSchema>;
19
+ /**
20
+ * Validate metadata and return sanitized version or null
21
+ * Use this function in services before storing metadata
22
+ */
23
+ export declare function validateMetadata(metadata: unknown): {
24
+ valid: true;
25
+ data: Record<string, unknown> | null;
26
+ } | {
27
+ valid: false;
28
+ error: string;
29
+ };
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetadataSchema = exports.MAX_METADATA_KEYS = exports.MAX_NESTING_DEPTH = exports.MAX_METADATA_SIZE = void 0;
4
+ exports.validateMetadata = validateMetadata;
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * Maximum size of metadata JSON in bytes
8
+ */
9
+ exports.MAX_METADATA_SIZE = 4096; // 4KB
10
+ /**
11
+ * Maximum nesting depth for metadata objects
12
+ */
13
+ exports.MAX_NESTING_DEPTH = 3;
14
+ /**
15
+ * Maximum number of keys in metadata
16
+ */
17
+ exports.MAX_METADATA_KEYS = 20;
18
+ /**
19
+ * Forbidden keys that could be used for prototype pollution
20
+ */
21
+ const FORBIDDEN_KEYS = ['__proto__', 'constructor', 'prototype'];
22
+ /**
23
+ * Validate key names - alphanumeric, underscore, dash, starting with letter or underscore
24
+ */
25
+ const SafeKeySchema = zod_1.z.string().regex(/^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/);
26
+ /**
27
+ * Recursive schema for metadata values
28
+ */
29
+ const MetadataValueSchema = zod_1.z.lazy(() => zod_1.z.union([
30
+ zod_1.z.string().max(1000),
31
+ zod_1.z.number(),
32
+ zod_1.z.boolean(),
33
+ zod_1.z.null(),
34
+ zod_1.z.array(MetadataValueSchema).max(50),
35
+ zod_1.z.record(SafeKeySchema, MetadataValueSchema),
36
+ ]));
37
+ /**
38
+ * Check if object contains forbidden keys (prototype pollution protection)
39
+ * Note: Depth check is handled separately by getDepth(), so we just stop recursion here
40
+ */
41
+ function hasForbiddenKeys(obj, depth = 0) {
42
+ if (depth > exports.MAX_NESTING_DEPTH)
43
+ return false; // Stop recursion, let getDepth() handle depth validation
44
+ if (typeof obj !== 'object' || obj === null)
45
+ return false;
46
+ if (Array.isArray(obj)) {
47
+ return obj.some((item) => hasForbiddenKeys(item, depth + 1));
48
+ }
49
+ for (const key of Object.keys(obj)) {
50
+ if (FORBIDDEN_KEYS.includes(key))
51
+ return true;
52
+ const value = obj[key];
53
+ if (hasForbiddenKeys(value, depth + 1))
54
+ return true;
55
+ }
56
+ return false;
57
+ }
58
+ /**
59
+ * Calculate nesting depth of an object
60
+ */
61
+ function getDepth(obj, currentDepth = 0) {
62
+ if (currentDepth > exports.MAX_NESTING_DEPTH + 1)
63
+ return currentDepth;
64
+ if (typeof obj !== 'object' || obj === null)
65
+ return currentDepth;
66
+ if (Array.isArray(obj)) {
67
+ return Math.max(currentDepth, ...obj.map((item) => getDepth(item, currentDepth + 1)));
68
+ }
69
+ const depths = Object.values(obj).map((value) => getDepth(value, currentDepth + 1));
70
+ return Math.max(currentDepth, ...depths);
71
+ }
72
+ /**
73
+ * Metadata schema with all security validations
74
+ */
75
+ exports.MetadataSchema = zod_1.z
76
+ .record(SafeKeySchema, MetadataValueSchema)
77
+ .refine((obj) => JSON.stringify(obj).length <= exports.MAX_METADATA_SIZE, {
78
+ message: `Metadata must be less than ${exports.MAX_METADATA_SIZE} bytes`,
79
+ })
80
+ .refine((obj) => Object.keys(obj).length <= exports.MAX_METADATA_KEYS, {
81
+ message: `Metadata must have at most ${exports.MAX_METADATA_KEYS} keys`,
82
+ })
83
+ .refine((obj) => !hasForbiddenKeys(obj), {
84
+ message: 'Metadata contains forbidden keys',
85
+ })
86
+ .refine((obj) => getDepth(obj) <= exports.MAX_NESTING_DEPTH, {
87
+ message: `Metadata nesting depth must not exceed ${exports.MAX_NESTING_DEPTH}`,
88
+ })
89
+ .optional()
90
+ .nullable();
91
+ /**
92
+ * Validate metadata and return sanitized version or null
93
+ * Use this function in services before storing metadata
94
+ */
95
+ function validateMetadata(metadata) {
96
+ var _a, _b;
97
+ if (metadata === undefined || metadata === null) {
98
+ return { valid: true, data: null };
99
+ }
100
+ const result = exports.MetadataSchema.safeParse(metadata);
101
+ if (!result.success) {
102
+ return { valid: false, error: (_b = (_a = result.error.issues[0]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Invalid metadata' };
103
+ }
104
+ return { valid: true, data: result.data };
105
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Source Type Enum
3
+ * Indicates the origin of balance credit
4
+ * See WALLET_API.md section 2.2
5
+ */
6
+ export declare enum SourceType {
7
+ PURCHASE = "purchase",
8
+ PROMO = "promo",
9
+ REFERRAL = "referral",
10
+ ADMIN = "admin",
11
+ SUBSCRIPTION = "subscription",
12
+ REFUND = "refund"
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SourceType = void 0;
4
+ /**
5
+ * Source Type Enum
6
+ * Indicates the origin of balance credit
7
+ * See WALLET_API.md section 2.2
8
+ */
9
+ var SourceType;
10
+ (function (SourceType) {
11
+ SourceType["PURCHASE"] = "purchase";
12
+ SourceType["PROMO"] = "promo";
13
+ SourceType["REFERRAL"] = "referral";
14
+ SourceType["ADMIN"] = "admin";
15
+ SourceType["SUBSCRIPTION"] = "subscription";
16
+ SourceType["REFUND"] = "refund";
17
+ })(SourceType || (exports.SourceType = SourceType = {}));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Transaction Type Enum
3
+ * See WALLET_API.md section 2.5
4
+ */
5
+ export declare enum TransactionType {
6
+ CREDIT = "CREDIT",
7
+ DEBIT = "DEBIT",
8
+ HOLD_CREATE = "HOLD_CREATE",
9
+ HOLD_CONFIRM = "HOLD_CONFIRM",
10
+ HOLD_RELEASE = "HOLD_RELEASE",
11
+ HOLD_EXPIRE = "HOLD_EXPIRE",
12
+ BALANCE_EXPIRE = "BALANCE_EXPIRE",
13
+ REFUND = "REFUND",
14
+ ADJUSTMENT = "ADJUSTMENT",
15
+ TRANSFER_OUT = "TRANSFER_OUT",
16
+ TRANSFER_IN = "TRANSFER_IN"
17
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionType = void 0;
4
+ /**
5
+ * Transaction Type Enum
6
+ * See WALLET_API.md section 2.5
7
+ */
8
+ var TransactionType;
9
+ (function (TransactionType) {
10
+ TransactionType["CREDIT"] = "CREDIT";
11
+ TransactionType["DEBIT"] = "DEBIT";
12
+ TransactionType["HOLD_CREATE"] = "HOLD_CREATE";
13
+ TransactionType["HOLD_CONFIRM"] = "HOLD_CONFIRM";
14
+ TransactionType["HOLD_RELEASE"] = "HOLD_RELEASE";
15
+ TransactionType["HOLD_EXPIRE"] = "HOLD_EXPIRE";
16
+ TransactionType["BALANCE_EXPIRE"] = "BALANCE_EXPIRE";
17
+ TransactionType["REFUND"] = "REFUND";
18
+ TransactionType["ADJUSTMENT"] = "ADJUSTMENT";
19
+ TransactionType["TRANSFER_OUT"] = "TRANSFER_OUT";
20
+ TransactionType["TRANSFER_IN"] = "TRANSFER_IN";
21
+ })(TransactionType || (exports.TransactionType = TransactionType = {}));
@@ -0,0 +1,37 @@
1
+ import { ErrorMetadata } from '../../shared';
2
+ /**
3
+ * Wallet Error Codes
4
+ * See WALLET_API.md section 7 for error specifications
5
+ */
6
+ export declare enum WalletErrorCode {
7
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
8
+ BALANCE_NOT_FOUND = "BALANCE_NOT_FOUND",
9
+ BALANCE_TYPE_NOT_FOUND = "BALANCE_TYPE_NOT_FOUND",
10
+ BALANCE_NOT_ACTIVE = "BALANCE_NOT_ACTIVE",
11
+ BALANCE_HAS_PENDING_HOLD = "BALANCE_HAS_PENDING_HOLD",
12
+ HOLD_NOT_FOUND = "HOLD_NOT_FOUND",
13
+ HOLD_ALREADY_PROCESSED = "HOLD_ALREADY_PROCESSED",
14
+ HOLD_NOT_PENDING = "HOLD_NOT_PENDING",
15
+ HOLD_EXPIRED = "HOLD_EXPIRED",
16
+ DUPLICATE_HOLD = "DUPLICATE_HOLD",
17
+ INSUFFICIENT_AVAILABLE_BALANCE = "INSUFFICIENT_AVAILABLE_BALANCE",
18
+ BALANCE_STATE_CHANGED = "BALANCE_STATE_CHANGED",
19
+ INVALID_AMOUNT = "INVALID_AMOUNT",
20
+ AMOUNT_OVERFLOW = "AMOUNT_OVERFLOW",
21
+ INVALID_TTL = "INVALID_TTL",
22
+ INVALID_METADATA = "INVALID_METADATA",
23
+ INVALID_INITIATOR_TYPE = "INVALID_INITIATOR_TYPE",
24
+ INVALID_BALANCE_STATUS = "INVALID_BALANCE_STATUS",
25
+ INVALID_HOLD_STATUS = "INVALID_HOLD_STATUS",
26
+ INVALID_TRANSACTION_TYPE = "INVALID_TRANSACTION_TYPE",
27
+ INVALID_SOURCE_TYPE = "INVALID_SOURCE_TYPE",
28
+ INVALID_VERSION = "INVALID_VERSION",
29
+ INVALID_OPERATION_TYPE = "INVALID_OPERATION_TYPE",
30
+ INVALID_OPERATION_ID = "INVALID_OPERATION_ID",
31
+ INVALID_HOLD_ID = "INVALID_HOLD_ID",
32
+ INVALID_BALANCE_ID = "INVALID_BALANCE_ID",
33
+ DATA_INTEGRITY_ERROR = "DATA_INTEGRITY_ERROR",
34
+ CONCURRENT_MODIFICATION = "CONCURRENT_MODIFICATION",
35
+ DUPLICATE_IDEMPOTENCY_KEY = "DUPLICATE_IDEMPOTENCY_KEY"
36
+ }
37
+ export declare const WALLET_ERRORS: Record<WalletErrorCode, ErrorMetadata>;