@xeno-js/shared 0.2.1 → 2.0.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.
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -32,7 +22,6 @@ var index_exports = {};
32
22
  __export(index_exports, {
33
23
  AbortSignalHelper: () => AbortSignalHelper,
34
24
  AppError: () => AppError,
35
- AxiosFactory: () => AxiosFactory,
36
25
  AxiosHttpClient: () => AxiosHttpClient,
37
26
  BaseLogger: () => BaseLogger,
38
27
  CacheKeyBuilder: () => CacheKeyBuilder,
@@ -2784,9 +2773,6 @@ var CacheKeyBuilder = class {
2784
2773
  }
2785
2774
  };
2786
2775
 
2787
- // src/infrastructure/factories/axios.factory.ts
2788
- var import_axios2 = __toESM(require("axios"), 1);
2789
-
2790
2776
  // src/infrastructure/http/axios.http.ts
2791
2777
  var import_axios = require("axios");
2792
2778
  var AxiosHttpClient = class {
@@ -2892,22 +2878,6 @@ var AxiosHttpClient = class {
2892
2878
  }
2893
2879
  };
2894
2880
 
2895
- // src/infrastructure/factories/axios.factory.ts
2896
- var AxiosFactory = class {
2897
- create(config) {
2898
- const axiosInstance = import_axios2.default.create({
2899
- baseURL: config.baseURL,
2900
- headers: config.defaultHeaders,
2901
- timeout: config.timeoutMs,
2902
- maxRedirects: config.maxRedirects ?? 5,
2903
- decompress: config.decompress ?? true,
2904
- proxy: config.proxy,
2905
- withCredentials: config.withCredentials
2906
- });
2907
- return new AxiosHttpClient(axiosInstance);
2908
- }
2909
- };
2910
-
2911
2881
  // src/infrastructure/mappers/supabase-claims.mapper.ts
2912
2882
  var SupabaseClaimsMapper = class {
2913
2883
  map(user) {
@@ -2942,41 +2912,67 @@ var SupabaseSessionMapper = class {
2942
2912
 
2943
2913
  // src/infrastructure/validators/base-schema.constant.ts
2944
2914
  var import_zod = require("zod");
2945
- var baseCommandZodSchema = import_zod.z.object({
2946
- intent: import_zod.z.string().min(1, "Intent is required"),
2947
- type: import_zod.z.literal(REQUEST_TYPE.COMMAND)
2948
- });
2949
- var queryZodSchema = import_zod.z.object({
2950
- intent: import_zod.z.string().min(1, "Intent is required"),
2951
- type: import_zod.z.literal(REQUEST_TYPE.QUERY)
2952
- });
2953
- var cacheableOptionsZodSchema = import_zod.z.object({
2954
- cacheKey: import_zod.z.string().min(1, "Cache key is required"),
2955
- ttl: import_zod.z.number().int().positive().optional(),
2956
- bypassCache: import_zod.z.boolean().optional(),
2957
- consistentRead: import_zod.z.boolean().optional()
2958
- });
2959
- var baseQueryZodSchema = queryZodSchema.extend({
2960
- cacheOptions: cacheableOptionsZodSchema
2961
- });
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
+ });
2931
+ }
2932
+ };
2933
+ var baseCommandZodSchema = {
2934
+ /**
2935
+ * @description Gets the base schema for a command with the given intent.
2936
+ * @param intent The intent of the command.
2937
+ * @returns The base schema for the command.
2938
+ */
2939
+ get(intent) {
2940
+ return baseZodSchema.get(intent, REQUEST_TYPE.COMMAND);
2941
+ }
2942
+ };
2943
+ var baseQueryZodSchema = {
2944
+ /**
2945
+ * @description Gets the base schema for a query with the given intent and chache key.
2946
+ * @param intent The intent of the query.
2947
+ * @returns The base schema for the query.
2948
+ */
2949
+ get(intent) {
2950
+ const baseSchema = baseZodSchema.get(intent, REQUEST_TYPE.QUERY);
2951
+ return baseSchema.extend({
2952
+ cacheOptions: cacheableOptionsZodSchema.get()
2953
+ });
2954
+ }
2955
+ };
2962
2956
 
2963
2957
  // src/infrastructure/validators/schema-zod.utils.ts
2964
2958
  var ZodUtils = Object.freeze({
2965
2959
  /**
2966
2960
  * @description Creates a Zod schema for a command by extending the base command schema with additional properties.
2961
+ * @param intent - The intent of the command.
2967
2962
  * @param additionalSchema - An object representing additional properties to be added to the command schema.
2968
2963
  * @returns A Zod schema for the command.
2969
2964
  */
2970
- createCommandSchema: (additionalSchema) => {
2971
- return baseCommandZodSchema.extend(additionalSchema).strict();
2965
+ createCommandSchema: (intent, additionalSchema) => {
2966
+ return baseCommandZodSchema.get(intent).extend(additionalSchema).strict();
2972
2967
  },
2973
2968
  /**
2974
2969
  * @description Creates a Zod schema for a query by extending the base query schema with additional properties.
2970
+ * @param intent - The intent of the query.
2975
2971
  * @param additionalSchema - An object representing additional properties to be added to the query schema.
2976
2972
  * @returns A Zod schema for the query.
2977
2973
  */
2978
- createQuerySchema: (additionalSchema) => {
2979
- return baseQueryZodSchema.extend(additionalSchema).strict();
2974
+ createQuerySchema: (intent, additionalSchema) => {
2975
+ return baseQueryZodSchema.get(intent).extend(additionalSchema).strict();
2980
2976
  }
2981
2977
  });
2982
2978
 
@@ -3029,7 +3025,6 @@ var ZodValidatorService = class _ZodValidatorService {
3029
3025
  0 && (module.exports = {
3030
3026
  AbortSignalHelper,
3031
3027
  AppError,
3032
- AxiosFactory,
3033
3028
  AxiosHttpClient,
3034
3029
  BaseLogger,
3035
3030
  CacheKeyBuilder,