@xeno-js/shared 1.0.0 → 2.0.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/index.d.cts CHANGED
@@ -6057,18 +6057,20 @@ declare class SupabaseSessionMapper implements IBaseMapper<Session$1, Session> {
6057
6057
  declare const ZodUtils: Readonly<{
6058
6058
  /**
6059
6059
  * @description Creates a Zod schema for a command by extending the base command schema with additional properties.
6060
+ * @param intent - The intent of the command.
6060
6061
  * @param additionalSchema - An object representing additional properties to be added to the command schema.
6061
6062
  * @returns A Zod schema for the command.
6062
6063
  */
6063
- createCommandSchema: (additionalSchema: z.ZodRawShape) => z.ZodObject<{
6064
+ createCommandSchema: (intent: string, additionalSchema: z.ZodRawShape) => z.ZodObject<{
6064
6065
  [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
6065
6066
  }, z.core.$strict>;
6066
6067
  /**
6067
6068
  * @description Creates a Zod schema for a query by extending the base query schema with additional properties.
6069
+ * @param intent - The intent of the query.
6068
6070
  * @param additionalSchema - An object representing additional properties to be added to the query schema.
6069
6071
  * @returns A Zod schema for the query.
6070
6072
  */
6071
- createQuerySchema: (additionalSchema: z.ZodRawShape) => z.ZodObject<{
6073
+ createQuerySchema: (intent: string, additionalSchema: z.ZodRawShape) => z.ZodObject<{
6072
6074
  [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
6073
6075
  }, z.core.$strict>;
6074
6076
  }>;
package/dist/index.d.ts CHANGED
@@ -6057,18 +6057,20 @@ declare class SupabaseSessionMapper implements IBaseMapper<Session$1, Session> {
6057
6057
  declare const ZodUtils: Readonly<{
6058
6058
  /**
6059
6059
  * @description Creates a Zod schema for a command by extending the base command schema with additional properties.
6060
+ * @param intent - The intent of the command.
6060
6061
  * @param additionalSchema - An object representing additional properties to be added to the command schema.
6061
6062
  * @returns A Zod schema for the command.
6062
6063
  */
6063
- createCommandSchema: (additionalSchema: z.ZodRawShape) => z.ZodObject<{
6064
+ createCommandSchema: (intent: string, additionalSchema: z.ZodRawShape) => z.ZodObject<{
6064
6065
  [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
6065
6066
  }, z.core.$strict>;
6066
6067
  /**
6067
6068
  * @description Creates a Zod schema for a query by extending the base query schema with additional properties.
6069
+ * @param intent - The intent of the query.
6068
6070
  * @param additionalSchema - An object representing additional properties to be added to the query schema.
6069
6071
  * @returns A Zod schema for the query.
6070
6072
  */
6071
- createQuerySchema: (additionalSchema: z.ZodRawShape) => z.ZodObject<{
6073
+ createQuerySchema: (intent: string, additionalSchema: z.ZodRawShape) => z.ZodObject<{
6072
6074
  [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
6073
6075
  }, z.core.$strict>;
6074
6076
  }>;
package/dist/index.js CHANGED
@@ -2844,41 +2844,68 @@ var SupabaseSessionMapper = class {
2844
2844
 
2845
2845
  // src/infrastructure/validators/base-schema.constant.ts
2846
2846
  import { z } from "zod";
2847
- var baseCommandZodSchema = z.object({
2848
- intent: z.string().min(1, "Intent is required"),
2849
- type: z.literal(REQUEST_TYPE.COMMAND)
2850
- });
2851
- var queryZodSchema = z.object({
2852
- intent: z.string().min(1, "Intent is required"),
2853
- type: z.literal(REQUEST_TYPE.QUERY)
2854
- });
2855
- var cacheableOptionsZodSchema = z.object({
2856
- cacheKey: z.string().min(1, "Cache key is required"),
2857
- ttl: z.number().int().positive().optional(),
2858
- bypassCache: z.boolean().optional(),
2859
- consistentRead: z.boolean().optional()
2860
- });
2861
- var baseQueryZodSchema = queryZodSchema.extend({
2862
- cacheOptions: cacheableOptionsZodSchema
2863
- });
2847
+ var baseZodSchema = {
2848
+ get(intent, type) {
2849
+ return z.object({
2850
+ intent: z.literal(intent),
2851
+ type: z.literal(type)
2852
+ });
2853
+ }
2854
+ };
2855
+ var cacheableOptionsZodSchema = {
2856
+ get() {
2857
+ return z.object({
2858
+ cacheKey: z.string().min(1, "Cache key is required"),
2859
+ ttl: z.number().int().positive().optional(),
2860
+ bypassCache: z.boolean().optional(),
2861
+ consistentRead: z.boolean().optional(),
2862
+ isUserScoped: z.boolean()
2863
+ });
2864
+ }
2865
+ };
2866
+ var baseCommandZodSchema = {
2867
+ /**
2868
+ * @description Gets the base schema for a command with the given intent.
2869
+ * @param intent The intent of the command.
2870
+ * @returns The base schema for the command.
2871
+ */
2872
+ get(intent) {
2873
+ return baseZodSchema.get(intent, REQUEST_TYPE.COMMAND);
2874
+ }
2875
+ };
2876
+ var baseQueryZodSchema = {
2877
+ /**
2878
+ * @description Gets the base schema for a query with the given intent and chache key.
2879
+ * @param intent The intent of the query.
2880
+ * @returns The base schema for the query.
2881
+ */
2882
+ get(intent) {
2883
+ const baseSchema = baseZodSchema.get(intent, REQUEST_TYPE.QUERY);
2884
+ return baseSchema.extend({
2885
+ cacheOptions: cacheableOptionsZodSchema.get()
2886
+ });
2887
+ }
2888
+ };
2864
2889
 
2865
2890
  // src/infrastructure/validators/schema-zod.utils.ts
2866
2891
  var ZodUtils = Object.freeze({
2867
2892
  /**
2868
2893
  * @description Creates a Zod schema for a command by extending the base command schema with additional properties.
2894
+ * @param intent - The intent of the command.
2869
2895
  * @param additionalSchema - An object representing additional properties to be added to the command schema.
2870
2896
  * @returns A Zod schema for the command.
2871
2897
  */
2872
- createCommandSchema: (additionalSchema) => {
2873
- return baseCommandZodSchema.extend(additionalSchema).strict();
2898
+ createCommandSchema: (intent, additionalSchema) => {
2899
+ return baseCommandZodSchema.get(intent).extend(additionalSchema).strict();
2874
2900
  },
2875
2901
  /**
2876
2902
  * @description Creates a Zod schema for a query by extending the base query schema with additional properties.
2903
+ * @param intent - The intent of the query.
2877
2904
  * @param additionalSchema - An object representing additional properties to be added to the query schema.
2878
2905
  * @returns A Zod schema for the query.
2879
2906
  */
2880
- createQuerySchema: (additionalSchema) => {
2881
- return baseQueryZodSchema.extend(additionalSchema).strict();
2907
+ createQuerySchema: (intent, additionalSchema) => {
2908
+ return baseQueryZodSchema.get(intent).extend(additionalSchema).strict();
2882
2909
  }
2883
2910
  });
2884
2911