@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.cjs CHANGED
@@ -2912,41 +2912,68 @@ var SupabaseSessionMapper = class {
2912
2912
 
2913
2913
  // src/infrastructure/validators/base-schema.constant.ts
2914
2914
  var import_zod = require("zod");
2915
- var baseCommandZodSchema = import_zod.z.object({
2916
- intent: import_zod.z.string().min(1, "Intent is required"),
2917
- type: import_zod.z.literal(REQUEST_TYPE.COMMAND)
2918
- });
2919
- var queryZodSchema = import_zod.z.object({
2920
- intent: import_zod.z.string().min(1, "Intent is required"),
2921
- type: import_zod.z.literal(REQUEST_TYPE.QUERY)
2922
- });
2923
- var cacheableOptionsZodSchema = import_zod.z.object({
2924
- cacheKey: import_zod.z.string().min(1, "Cache key is required"),
2925
- ttl: import_zod.z.number().int().positive().optional(),
2926
- bypassCache: import_zod.z.boolean().optional(),
2927
- consistentRead: import_zod.z.boolean().optional()
2928
- });
2929
- var baseQueryZodSchema = queryZodSchema.extend({
2930
- cacheOptions: cacheableOptionsZodSchema
2931
- });
2915
+ var baseZodSchema = {
2916
+ get(intent, type) {
2917
+ return import_zod.z.object({
2918
+ intent: import_zod.z.literal(intent),
2919
+ type: import_zod.z.literal(type)
2920
+ });
2921
+ }
2922
+ };
2923
+ var cacheableOptionsZodSchema = {
2924
+ get() {
2925
+ return import_zod.z.object({
2926
+ cacheKey: import_zod.z.string().min(1, "Cache key is required"),
2927
+ ttl: import_zod.z.number().int().positive().optional(),
2928
+ bypassCache: import_zod.z.boolean().optional(),
2929
+ consistentRead: import_zod.z.boolean().optional(),
2930
+ isUserScoped: import_zod.z.boolean()
2931
+ });
2932
+ }
2933
+ };
2934
+ var baseCommandZodSchema = {
2935
+ /**
2936
+ * @description Gets the base schema for a command with the given intent.
2937
+ * @param intent The intent of the command.
2938
+ * @returns The base schema for the command.
2939
+ */
2940
+ get(intent) {
2941
+ return baseZodSchema.get(intent, REQUEST_TYPE.COMMAND);
2942
+ }
2943
+ };
2944
+ var baseQueryZodSchema = {
2945
+ /**
2946
+ * @description Gets the base schema for a query with the given intent and chache key.
2947
+ * @param intent The intent of the query.
2948
+ * @returns The base schema for the query.
2949
+ */
2950
+ get(intent) {
2951
+ const baseSchema = baseZodSchema.get(intent, REQUEST_TYPE.QUERY);
2952
+ return baseSchema.extend({
2953
+ cacheOptions: cacheableOptionsZodSchema.get()
2954
+ });
2955
+ }
2956
+ };
2932
2957
 
2933
2958
  // src/infrastructure/validators/schema-zod.utils.ts
2934
2959
  var ZodUtils = Object.freeze({
2935
2960
  /**
2936
2961
  * @description Creates a Zod schema for a command by extending the base command schema with additional properties.
2962
+ * @param intent - The intent of the command.
2937
2963
  * @param additionalSchema - An object representing additional properties to be added to the command schema.
2938
2964
  * @returns A Zod schema for the command.
2939
2965
  */
2940
- createCommandSchema: (additionalSchema) => {
2941
- return baseCommandZodSchema.extend(additionalSchema).strict();
2966
+ createCommandSchema: (intent, additionalSchema) => {
2967
+ return baseCommandZodSchema.get(intent).extend(additionalSchema).strict();
2942
2968
  },
2943
2969
  /**
2944
2970
  * @description Creates a Zod schema for a query by extending the base query schema with additional properties.
2971
+ * @param intent - The intent of the query.
2945
2972
  * @param additionalSchema - An object representing additional properties to be added to the query schema.
2946
2973
  * @returns A Zod schema for the query.
2947
2974
  */
2948
- createQuerySchema: (additionalSchema) => {
2949
- return baseQueryZodSchema.extend(additionalSchema).strict();
2975
+ createQuerySchema: (intent, additionalSchema) => {
2976
+ return baseQueryZodSchema.get(intent).extend(additionalSchema).strict();
2950
2977
  }
2951
2978
  });
2952
2979