@plyaz/types 1.13.17 → 1.14.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.
@@ -42,13 +42,17 @@ var AUTH_PROVIDER_TYPE = /* @__PURE__ */ ((AUTH_PROVIDER_TYPE2) => {
42
42
  AUTH_PROVIDER_TYPE2["InternalDb"] = "INTERNAL_DB";
43
43
  return AUTH_PROVIDER_TYPE2;
44
44
  })(AUTH_PROVIDER_TYPE || {});
45
- var loginCredentialsSchema = z.object({
46
- // The user's email address. Must be a valid email format.
47
- email: z.string().email("Invalid email format"),
48
- // The user's password. No format constraints applied here.
49
- password: z.string()
45
+ var DEFAULT_PASSWORD = 8;
46
+ var ContactUsFormSchema = z.object({
47
+ name: z.string({ error: "errors.form.missingField" }).min(1, "errors.form.nameMissing"),
48
+ email: z.email({ error: "errors.form.emailInvalid" })
49
+ });
50
+ var SignupFormSchema = z.object({
51
+ name: z.string({ error: "errors.form.missingField" }).min(1, "errors.form.nameMissing"),
52
+ email: z.email({ error: "errors.form.emailInvalid" }),
53
+ password: z.string({ error: "errors.form.missingField" }).min(DEFAULT_PASSWORD, "errors.form.passwordTooShort")
50
54
  });
51
55
 
52
- export { AUTH_PROVIDER, AUTH_PROVIDER_TYPE, USER_ROLE, USER_STATUS, loginCredentialsSchema };
56
+ export { AUTH_PROVIDER, AUTH_PROVIDER_TYPE, ContactUsFormSchema, SignupFormSchema, USER_ROLE, USER_STATUS };
53
57
  //# sourceMappingURL=index.js.map
54
58
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/enums.ts","../../src/auth/schemas.ts"],"names":["AUTH_PROVIDER_TYPE"],"mappings":";;;;;AAYO,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,UAAA,EAAY;AACd;AAcO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,SAAA,EAAW,WAAA;AAAA;AAAA,EAGX,MAAA,EAAQ;AACV;AAcO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,MAAA,EAAQ;AACV;AAEO,IAAK,kBAAA,qBAAAA,mBAAAA,KAAL;AACL,EAAAA,oBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,EAAAA,oBAAA,YAAA,CAAA,GAAa,aAAA;AAFH,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA;ACvEL,IAAM,sBAAA,GAAyB,EAAE,MAAA,CAAO;AAAA;AAAA,EAE7C,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,MAAM,sBAAsB,CAAA;AAAA;AAAA,EAG9C,QAAA,EAAU,EAAE,MAAA;AACd,CAAC","file":"index.js","sourcesContent":["/**\n * Enum representing the different roles a user can have within the system.\n * @description Roles are used to determine access levels, permissions, and user-specific experiences.\n *\n * @example\n * ```typescript\n * import { USER_ROLE } from '@plyaz/types';\n *\n * const userRole = USER_ROLE.Athlete; // 'athlete'\n * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;\n * ```\n */\nexport const USER_ROLE = {\n /** A user who is an athlete and participates in sports activities. */\n Athlete: 'athlete',\n\n /** A user who scouts and discovers talent. */\n Scout: 'scout',\n\n /** A user who acts as an agent representing athletes or clubs. */\n Agent: 'agent',\n\n /** A user representing a sports club or organization. */\n Club: 'club',\n\n /** A fan or supporter of athletes or clubs. */\n Fan: 'fan',\n\n /** A system administrator with access to management tools. */\n Admin: 'admin',\n\n /** A super admin with the highest level of access and control. */\n SuperAdmin: 'super.admin',\n} as const;\n\n/**\n * Enum representing the current status of a user account.\n * @description Statuses are used to determine login availability, visibility, and user flow.\n *\n * @example\n * ```typescript\n * import { USER_STATUS } from '@plyaz/types';\n *\n * const isAccessible = status === USER_STATUS.Active;\n * const needsReview = status === USER_STATUS.Pending;\n * ```\n */\nexport const USER_STATUS = {\n /** Active user with full access. */\n Active: 'active',\n\n /** Inactive user, typically not currently using the platform. */\n Inactive: 'inactive',\n\n /** User account is awaiting approval or completion of setup. */\n Pending: 'pending',\n\n /** User has been temporarily suspended due to policy violations or manual review. */\n Suspended: 'suspended',\n\n /** User has been permanently banned from the platform. */\n Banned: 'banned',\n} as const;\n\n/**\n * Enum representing the supported authentication providers for user login.\n * @description Auth Providers allowed such as Email, Wallet, etc.\n *\n * @example\n * ```typescript\n * import { AUTH_PROVIDER } from '@plyaz/types';\n *\n * const provider = AUTH_PROVIDER.Wallet; // 'wallet'\n * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;\n * ```\n */\nexport const AUTH_PROVIDER = {\n /** Authentication via email and password. */\n Email: 'email',\n\n /** Authentication via connected blockchain wallet. */\n Wallet: 'wallet',\n} as const;\n\nexport enum AUTH_PROVIDER_TYPE {\n ClerkSupabase = 'CLERK_SUPABASE',\n InternalDb = 'INTERNAL_DB',\n}\n","import { z } from 'zod';\n\n/**\n * Zod schema for validating user login credentials.\n * @description Ensures the input object contains a valid email address and a password string.\n * @example\n * ```ts\n * LoginCredentialsSchema.parse({\n * email: \"user@example.com\",\n * password: \"\"\n * });\n * ```\n */\nexport const loginCredentialsSchema = z.object({\n // The user's email address. Must be a valid email format.\n email: z.string().email('Invalid email format'),\n\n // The user's password. No format constraints applied here.\n password: z.string(),\n});\n\n/**\n * Type inferred from {@link loginCredentialsSchema}.\n * @description Represents the shape of validated login credentials input.\n */\nexport type LoginCredentialsInput = z.infer<typ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EACvC,IAAA,EAAM,CAAA,CAAE,MAAA,CAAO,EAAE,KAAA,EAAO,4BAA4B,CAAA,CAAE,GAAA,CAAI,CAAA,EAAG,yBAAyB,CAAA;AAAA,EACtF,OAAO,CAAA,CAAE,KAAA,CAAM,EAAE,KAAA,EAAO,4BAA4B,CAAA;AAAA,EACpD,QAAA,EAAU,CAAA,CACP,MAAA,CAAO,EAAE,KAAA,EAAO,4BAA4B,CAAA,CAC5C,GAAA,CAAI,gBAAA,EAAkB,8BAA8B;AACzD,CAAC","file":"index.js","sourcesContent":["/**\n * Enum representing the different roles a user can have within the system.\n * @description Roles are used to determine access levels, permissions, and user-specific experiences.\n *\n * @example\n * ```typescript\n * import { USER_ROLE } from '@plyaz/types';\n *\n * const userRole = USER_ROLE.Athlete; // 'athlete'\n * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;\n * ```\n */\nexport const USER_ROLE = {\n /** A user who is an athlete and participates in sports activities. */\n Athlete: 'athlete',\n\n /** A user who scouts and discovers talent. */\n Scout: 'scout',\n\n /** A user who acts as an agent representing athletes or clubs. */\n Agent: 'agent',\n\n /** A user representing a sports club or organization. */\n Club: 'club',\n\n /** A fan or supporter of athletes or clubs. */\n Fan: 'fan',\n\n /** A system administrator with access to management tools. */\n Admin: 'admin',\n\n /** A super admin with the highest level of access and control. */\n SuperAdmin: 'super.admin',\n} as const;\n\n/**\n * Enum representing the current status of a user account.\n * @description Statuses are used to determine login availability, visibility, and user flow.\n *\n * @example\n * ```typescript\n * import { USER_STATUS } from '@plyaz/types';\n *\n * const isAccessible = status === USER_STATUS.Active;\n * const needsReview = status === USER_STATUS.Pending;\n * ```\n */\nexport const USER_STATUS = {\n /** Active user with full access. */\n Active: 'active',\n\n /** Inactive user, typically not currently using the platform. */\n Inactive: 'inactive',\n\n /** User account is awaiting approval or completion of setup. */\n Pending: 'pending',\n\n /** User has been temporarily suspended due to policy violations or manual review. */\n Suspended: 'suspended',\n\n /** User has been permanently banned from the platform. */\n Banned: 'banned',\n} as const;\n\n/**\n * Enum representing the supported authentication providers for user login.\n * @description Auth Providers allowed such as Email, Wallet, etc.\n *\n * @example\n * ```typescript\n * import { AUTH_PROVIDER } from '@plyaz/types';\n *\n * const provider = AUTH_PROVIDER.Wallet; // 'wallet'\n * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;\n * ```\n */\nexport const AUTH_PROVIDER = {\n /** Authentication via email and password. */\n Email: 'email',\n\n /** Authentication via connected blockchain wallet. */\n Wallet: 'wallet',\n} as const;\n\nexport enum AUTH_PROVIDER_TYPE {\n ClerkSupabase = 'CLERK_SUPABASE',\n InternalDb = 'INTERNAL_DB',\n}\n","import { z } from 'zod';\n\n/**\n * Password minimum character length\n */\nconst DEFAULT_PASSWORD = 8;\n\n/**\n * Contact Us Form Schema\n * Validates contact form submissions\n */\nexport const ContactUsFormSchema = z.object({\n name: z.string({ error: 'errors.form.missingField' }).min(1, 'errors.form.nameMissing'),\n email: z.email({ error: 'errors.form.emailInvalid' }),\n});\n\n/**\n * Contact Us Form Type\n */\nexport type ContactUsForm = z.infer<typeof ContactUsFormSchema>;\n\n/**\n * Signup Form Schema\n * Validates user registration form submissions\n */\nexport const SignupFormSchema = z.object({\n name: z.string({ error: 'errors.form.missingField' }).min(1, 'errors.form.nameMissing'),\n email: z.email({ error: 'errors.form.emailInvalid' }),\n password: z\n .string({ error: 'errors.form.missingField' })\n .min(DEFAULT_PASSWORD, 'errors.form.passwordTooShort'),\n});\n\n/**\n * Signup Form Type\n */\nexport type SignupForm = z.infer<typeof SignupFormSchema>;\n"]}
@@ -1,27 +1,26 @@
1
1
  import { z } from 'zod';
2
2
  /**
3
- * Zod schema for validating user login credentials.
4
- * @description Ensures the input object contains a valid email address and a password string.
5
- * @example
6
- * ```ts
7
- * LoginCredentialsSchema.parse({
8
- * email: "user@example.com",
9
- * password: ""
10
- * });
11
- * ```
3
+ * Contact Us Form Schema
4
+ * Validates contact form submissions
12
5
  */
13
- export declare const loginCredentialsSchema: z.ZodObject<{
14
- email: z.ZodString;
6
+ export declare const ContactUsFormSchema: z.ZodObject<{
7
+ name: z.ZodString;
8
+ email: z.ZodEmail;
9
+ }, z.core.$strip>;
10
+ /**
11
+ * Contact Us Form Type
12
+ */
13
+ export type ContactUsForm = z.infer<typeof ContactUsFormSchema>;
14
+ /**
15
+ * Signup Form Schema
16
+ * Validates user registration form submissions
17
+ */
18
+ export declare const SignupFormSchema: z.ZodObject<{
19
+ name: z.ZodString;
20
+ email: z.ZodEmail;
15
21
  password: z.ZodString;
16
- }, "strip", z.ZodTypeAny, {
17
- email?: string;
18
- password?: string;
19
- }, {
20
- email?: string;
21
- password?: string;
22
- }>;
22
+ }, z.core.$strip>;
23
23
  /**
24
- * Type inferred from {@link loginCredentialsSchema}.
25
- * @description Represents the shape of validated login credentials input.
24
+ * Signup Form Type
26
25
  */
27
- export type LoginCredentialsInput = z.infer<typeof loginCredentialsSchema>;
26
+ export type SignupForm = z.infer<typeof SignupFormSchema>;
@@ -306,7 +306,7 @@ export interface PackageErrorLike extends Error {
306
306
  /** Convert error to string representation */
307
307
  toString(): string;
308
308
  /** Get user-friendly message for display to end users */
309
- getUserMessage(): string;
309
+ getUserMessage(locale?: string): string;
310
310
  }
311
311
  export type AsyncMiddleware<TReturn = void> = (req: Request, res: Response, next: NextFunction) => Promise<TReturn>;
312
312
  export type MiddlewareWrapper = <TReturn>(fn: AsyncMiddleware<TReturn>) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -531,9 +531,10 @@ export interface ApiPackageErrorOptions<TEndpoints = unknown, TClient = ApiClien
531
531
  metadata?: Record<string, string | number | boolean | null>;
532
532
  }
533
533
  /**
534
- * Configuration for ApiPackageError class
534
+ * Generic configuration for package error classes
535
+ * Used by all @plyaz packages (api, notifications, errors, etc.)
535
536
  */
536
- export interface ApiPackageErrorConfig {
537
+ export interface PackageErrorConfig {
537
538
  /** Package namespace for event emission */
538
539
  namespace?: string;
539
540
  /** Event factory for scoped events */
@@ -697,3 +698,41 @@ export type StatusCodeValue = number | InternalStatusCodeValue;
697
698
  export interface I18nContext {
698
699
  [key: string]: string | number | boolean | null | undefined;
699
700
  }
701
+ /**
702
+ * ===== Sanitization Configuration =====
703
+ */
704
+ /**
705
+ * Configuration for value sanitization in error messages
706
+ * Used to prevent injection attacks when interpolating values into error messages
707
+ *
708
+ * @example
709
+ * ```typescript
710
+ * const config: SanitizeConfig = {
711
+ * maxLength: 500,
712
+ * stripHtml: true,
713
+ * escapeNewlines: true
714
+ * };
715
+ * ```
716
+ */
717
+ export interface SanitizeConfig {
718
+ /**
719
+ * Maximum length for interpolated string values
720
+ * @default 1000
721
+ */
722
+ maxLength?: number;
723
+ /**
724
+ * Whether to strip all HTML tags
725
+ * @default true
726
+ */
727
+ stripHtml?: boolean;
728
+ /**
729
+ * Whether to escape newlines to prevent log injection
730
+ * @default true
731
+ */
732
+ escapeNewlines?: boolean;
733
+ /**
734
+ * Whether to limit object/array string representation
735
+ * @default true
736
+ */
737
+ limitComplexTypes?: boolean;
738
+ }