@plyaz/types 1.13.17 → 1.14.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.
- package/dist/api/endpoints/infobip/types.d.ts +5 -0
- package/dist/auth/index.cjs +12 -4196
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +10 -6
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/schemas.d.ts +20 -21
- package/dist/db/databaseEventsType.d.ts +9 -0
- package/dist/db/eventEmitter.d.ts +43 -0
- package/dist/db/index.cjs +13 -0
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +13 -1
- package/dist/db/index.js.map +1 -1
- package/dist/errors/types.d.ts +42 -3
- package/dist/index.cjs +165 -4206
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +142 -6
- package/dist/index.js.map +1 -1
- package/dist/notifications/index.cjs +155 -4201
- package/dist/notifications/index.cjs.map +1 -1
- package/dist/notifications/index.d.ts +11 -0
- package/dist/notifications/index.js +133 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/schemas.d.ts +13 -3
- package/dist/notifications/types.d.ts +66 -24
- package/dist/notifications/webhooks.schemas.d.ts +278 -0
- package/package.json +4 -4
package/dist/auth/index.js
CHANGED
|
@@ -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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
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
|
package/dist/auth/index.js.map
CHANGED
|
@@ -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;
|
|
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;AC/EZ,IAAM,gBAAA,GAAmB,CAAA;AAMlB,IAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EAC1C,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;AACtD,CAAC;AAWM,IAAM,gBAAA,GAAmB,EAAE,MAAA,CAAO;AAAA,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"]}
|
package/dist/auth/schemas.d.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
14
|
-
|
|
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
|
-
},
|
|
17
|
-
email?: string;
|
|
18
|
-
password?: string;
|
|
19
|
-
}, {
|
|
20
|
-
email?: string;
|
|
21
|
-
password?: string;
|
|
22
|
-
}>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @description Represents the shape of validated login credentials input.
|
|
24
|
+
* Signup Form Type
|
|
26
25
|
*/
|
|
27
|
-
export type
|
|
26
|
+
export type SignupForm = z.infer<typeof SignupFormSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum DATABASE_EVENT_TYPE {
|
|
2
|
+
BeforeQuery = "beforeQuery",
|
|
3
|
+
AfterQuery = "afterQuery",
|
|
4
|
+
QueryError = "queryError",
|
|
5
|
+
BeforeTransaction = "beforeTransaction",
|
|
6
|
+
AfterTransaction = "afterTransaction",
|
|
7
|
+
TransactionRollback = "transactionRollback",
|
|
8
|
+
HealthChange = "healthChange"
|
|
9
|
+
}
|
|
@@ -65,4 +65,47 @@ export interface DatabaseEventEmitterType {
|
|
|
65
65
|
emitHealthChange<TDetails extends object = object>(previousStatus: boolean, currentStatus: boolean, details?: TDetails): void;
|
|
66
66
|
emitQueryError(options: EmitQueryErrorOptions): void;
|
|
67
67
|
}
|
|
68
|
+
export interface BeforeQueryEvent extends DatabaseEvent {
|
|
69
|
+
type: 'beforeQuery';
|
|
70
|
+
adapter: string;
|
|
71
|
+
table: string;
|
|
72
|
+
operation: DatabaseOperationType;
|
|
73
|
+
params?: Record<string, object>;
|
|
74
|
+
context?: ContextType;
|
|
75
|
+
}
|
|
76
|
+
export interface AfterQueryEvent extends DatabaseEvent {
|
|
77
|
+
type: 'afterQuery';
|
|
78
|
+
adapter: string;
|
|
79
|
+
table: string;
|
|
80
|
+
operation: DatabaseOperationType;
|
|
81
|
+
duration: number;
|
|
82
|
+
affectedRows?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface QueryErrorEvent extends DatabaseEvent {
|
|
85
|
+
type: 'queryError';
|
|
86
|
+
adapter: string;
|
|
87
|
+
table: string;
|
|
88
|
+
operation: DatabaseOperationType;
|
|
89
|
+
error: Error;
|
|
90
|
+
params?: Record<string, object>;
|
|
91
|
+
context?: ContextType;
|
|
92
|
+
}
|
|
93
|
+
export interface BeforeTransactionEvent extends DatabaseEvent {
|
|
94
|
+
type: 'beforeTransaction';
|
|
95
|
+
adapter: string;
|
|
96
|
+
transactionId: string;
|
|
97
|
+
context?: ContextType;
|
|
98
|
+
}
|
|
99
|
+
export interface AfterTransactionEvent extends DatabaseEvent {
|
|
100
|
+
type: 'afterTransaction';
|
|
101
|
+
adapter: string;
|
|
102
|
+
transactionId: string;
|
|
103
|
+
duration: number;
|
|
104
|
+
}
|
|
105
|
+
export interface TransactionRollbackEvent extends DatabaseEvent {
|
|
106
|
+
type: 'transactionRollback';
|
|
107
|
+
adapter: string;
|
|
108
|
+
transactionId: string;
|
|
109
|
+
error?: Error;
|
|
110
|
+
}
|
|
68
111
|
export {};
|
package/dist/db/index.cjs
CHANGED
|
@@ -20,7 +20,20 @@ var REPLICA_STRATEGY = /* @__PURE__ */ ((REPLICA_STRATEGY2) => {
|
|
|
20
20
|
return REPLICA_STRATEGY2;
|
|
21
21
|
})(REPLICA_STRATEGY || {});
|
|
22
22
|
|
|
23
|
+
// src/db/databaseEventsType.ts
|
|
24
|
+
var DATABASE_EVENT_TYPE = /* @__PURE__ */ ((DATABASE_EVENT_TYPE2) => {
|
|
25
|
+
DATABASE_EVENT_TYPE2["BeforeQuery"] = "beforeQuery";
|
|
26
|
+
DATABASE_EVENT_TYPE2["AfterQuery"] = "afterQuery";
|
|
27
|
+
DATABASE_EVENT_TYPE2["QueryError"] = "queryError";
|
|
28
|
+
DATABASE_EVENT_TYPE2["BeforeTransaction"] = "beforeTransaction";
|
|
29
|
+
DATABASE_EVENT_TYPE2["AfterTransaction"] = "afterTransaction";
|
|
30
|
+
DATABASE_EVENT_TYPE2["TransactionRollback"] = "transactionRollback";
|
|
31
|
+
DATABASE_EVENT_TYPE2["HealthChange"] = "healthChange";
|
|
32
|
+
return DATABASE_EVENT_TYPE2;
|
|
33
|
+
})(DATABASE_EVENT_TYPE || {});
|
|
34
|
+
|
|
23
35
|
exports.ADAPTERS = ADAPTERS;
|
|
36
|
+
exports.DATABASE_EVENT_TYPE = DATABASE_EVENT_TYPE;
|
|
24
37
|
exports.REPLICA_STRATEGY = REPLICA_STRATEGY;
|
|
25
38
|
//# sourceMappingURL=index.cjs.map
|
|
26
39
|
//# sourceMappingURL=index.cjs.map
|
package/dist/db/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/adapter.ts","../../src/db/replicaStrategy.ts"],"names":["ADAPTERS","REPLICA_STRATEGY"],"mappings":";;;;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;;;AC9EL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AAEL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AARA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"index.cjs","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n","/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/db/adapter.ts","../../src/db/replicaStrategy.ts","../../src/db/databaseEventsType.ts"],"names":["ADAPTERS","REPLICA_STRATEGY","DATABASE_EVENT_TYPE"],"mappings":";;;;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;;;AC9EL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AAEL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AARA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA;;;ACFL,IAAK,mBAAA,qBAAAC,oBAAAA,KAAL;AACL,EAAAA,qBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,mBAAA,CAAA,GAAoB,mBAAA;AACpB,EAAAA,qBAAA,kBAAA,CAAA,GAAmB,kBAAA;AACnB,EAAAA,qBAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,qBAAA,cAAA,CAAA,GAAe,cAAA;AAPL,EAAA,OAAAA,oBAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA","file":"index.cjs","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n","/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n","// Event type enum\nexport enum DATABASE_EVENT_TYPE {\n BeforeQuery = 'beforeQuery',\n AfterQuery = 'afterQuery',\n QueryError = 'queryError',\n BeforeTransaction = 'beforeTransaction',\n AfterTransaction = 'afterTransaction',\n TransactionRollback = 'transactionRollback',\n HealthChange = 'healthChange'\n}"]}
|
package/dist/db/index.d.ts
CHANGED
package/dist/db/index.js
CHANGED
|
@@ -18,6 +18,18 @@ var REPLICA_STRATEGY = /* @__PURE__ */ ((REPLICA_STRATEGY2) => {
|
|
|
18
18
|
return REPLICA_STRATEGY2;
|
|
19
19
|
})(REPLICA_STRATEGY || {});
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// src/db/databaseEventsType.ts
|
|
22
|
+
var DATABASE_EVENT_TYPE = /* @__PURE__ */ ((DATABASE_EVENT_TYPE2) => {
|
|
23
|
+
DATABASE_EVENT_TYPE2["BeforeQuery"] = "beforeQuery";
|
|
24
|
+
DATABASE_EVENT_TYPE2["AfterQuery"] = "afterQuery";
|
|
25
|
+
DATABASE_EVENT_TYPE2["QueryError"] = "queryError";
|
|
26
|
+
DATABASE_EVENT_TYPE2["BeforeTransaction"] = "beforeTransaction";
|
|
27
|
+
DATABASE_EVENT_TYPE2["AfterTransaction"] = "afterTransaction";
|
|
28
|
+
DATABASE_EVENT_TYPE2["TransactionRollback"] = "transactionRollback";
|
|
29
|
+
DATABASE_EVENT_TYPE2["HealthChange"] = "healthChange";
|
|
30
|
+
return DATABASE_EVENT_TYPE2;
|
|
31
|
+
})(DATABASE_EVENT_TYPE || {});
|
|
32
|
+
|
|
33
|
+
export { ADAPTERS, DATABASE_EVENT_TYPE, REPLICA_STRATEGY };
|
|
22
34
|
//# sourceMappingURL=index.js.map
|
|
23
35
|
//# sourceMappingURL=index.js.map
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/db/adapter.ts","../../src/db/replicaStrategy.ts"],"names":["ADAPTERS","REPLICA_STRATEGY"],"mappings":";;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;;;AC9EL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AAEL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AARA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"index.js","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n","/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/db/adapter.ts","../../src/db/replicaStrategy.ts","../../src/db/databaseEventsType.ts"],"names":["ADAPTERS","REPLICA_STRATEGY","DATABASE_EVENT_TYPE"],"mappings":";;;AAiFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AAEL,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,UAAA,UAAA,CAAA,GAAW,UAAA;AAGX,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAXI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;;;AC9EL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AAEL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AARA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA;;;ACFL,IAAK,mBAAA,qBAAAC,oBAAAA,KAAL;AACL,EAAAA,qBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,qBAAA,mBAAA,CAAA,GAAoB,mBAAA;AACpB,EAAAA,qBAAA,kBAAA,CAAA,GAAmB,kBAAA;AACnB,EAAAA,qBAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,qBAAA,cAAA,CAAA,GAAe,cAAA;AAPL,EAAA,OAAAA,oBAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA","file":"index.js","sourcesContent":["/**\n * @fileoverview Database adapter type definitions\n *\n * Defines the enumeration of supported database adapter types used throughout\n * the database package. This enum provides type-safe identification of different\n * database integrations and is used in configuration, factory methods, and\n * adapter selection logic.\n *\n * **Application Flow Context:**\n * ```\n * Configuration → ADAPTERS Enum → AdapterFactory → Concrete Adapter\n * ↓ ↓ ↓ ↓\n * User Config → Type Safety → Adapter Creation → Database Connection\n * ```\n *\n * **Adapter Types:**\n * - **DRIZZLE**: Type-safe ORM with excellent TypeScript support\n * - **SUPABASE**: Hosted PostgreSQL with real-time capabilities\n * - **SQL**: Raw SQL execution for maximum control\n * - **DATABASE**: Generic fallback adapter\n *\n * @example\n * ```typescript\n * // Adapter selection in configuration\n * const config = {\n * adapter: ADAPTERS.DRIZZLE,\n * connectionString: process.env.DATABASE_URL\n * };\n *\n * // Type-safe adapter factory usage\n * const adapter = AdapterFactory.create(ADAPTERS.SUPABASE, supabaseConfig);\n *\n * // Switch statement with exhaustive checking\n * switch (config.adapter) {\n * case ADAPTERS.DRIZZLE:\n * // Handle Drizzle-specific logic\n * break;\n * case ADAPTERS.SUPABASE:\n * // Handle Supabase-specific logic\n * break;\n * case ADAPTERS.SQL:\n * // Handle SQL-specific logic\n * break;\n * default:\n * // TypeScript ensures all cases are handled\n * throw new Error(`Unsupported adapter: ${config.adapter}`);\n * }\n * ```\n *\n */\n/**\n * @enum ADAPTERS\n * @description\n * Enumeration of supported database adapter types.\n *\n * This enum provides type-safe identification of different database integrations\n * and is used throughout the package for configuration, factory methods, and\n * adapter selection. Each adapter type represents a different approach to\n * database connectivity and operations.\n *\n * **Adapter Characteristics:**\n * - **DATABASE**: Generic fallback, minimal functionality\n * - **DRIZZLE**: Full ORM with type safety and query building\n * - **SUPABASE**: Hosted solution with real-time and auth features\n * - **SQL**: Raw SQL for performance-critical applications\n *\n * @example\n * ```typescript\n * // Configuration with adapter selection\n * const configs = {\n * development: { adapter: ADAPTERS.DRIZZLE },\n * production: { adapter: ADAPTERS.SUPABASE },\n * performance: { adapter: ADAPTERS.SQL }\n * };\n *\n * // Type-safe adapter validation\n * function validateAdapter(adapter: ADAPTERS): boolean {\n * return Object.values(ADAPTERS).includes(adapter);\n * }\n * ```\n */\nexport enum ADAPTERS {\n /** Generic database adapter (default when no specific integration is set) */\n DATABASE = 'database',\n\n /** Drizzle ORM adapter (PostgreSQL, MySQL, SQLite, etc.) */\n DRIZZLE = 'drizzle',\n\n /** Supabase adapter (PostgreSQL backend with REST + Realtime APIs) */\n SUPABASE = 'supabase',\n\n /** Raw SQL adapter (direct database queries without ORM) */\n SQL = 'sql',\n}\n","/**\n * Strategy options for replica selection.\n */\nexport enum REPLICA_STRATEGY {\n /** Always use primary database */\n PRIMARY = 'primary',\n /** Use any available replica */\n REPLICA = 'replica',\n /** Use geographically closest replica */\n CLOSEST = 'closest',\n /** Use fastest responding replica */\n FASTEST = 'fastest',\n}\n","// Event type enum\nexport enum DATABASE_EVENT_TYPE {\n BeforeQuery = 'beforeQuery',\n AfterQuery = 'afterQuery',\n QueryError = 'queryError',\n BeforeTransaction = 'beforeTransaction',\n AfterTransaction = 'afterTransaction',\n TransactionRollback = 'transactionRollback',\n HealthChange = 'healthChange'\n}"]}
|
package/dist/errors/types.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
534
|
+
* Generic configuration for package error classes
|
|
535
|
+
* Used by all @plyaz packages (api, notifications, errors, etc.)
|
|
535
536
|
*/
|
|
536
|
-
export interface
|
|
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
|
+
}
|