@xeno-js/shared 1.0.0 → 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/README.md +678 -678
- package/dist/index.cjs +47 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +47 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2912,41 +2912,67 @@ var SupabaseSessionMapper = class {
|
|
|
2912
2912
|
|
|
2913
2913
|
// src/infrastructure/validators/base-schema.constant.ts
|
|
2914
2914
|
var import_zod = require("zod");
|
|
2915
|
-
var
|
|
2916
|
-
intent
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
}
|
|
2923
|
-
var cacheableOptionsZodSchema =
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
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
|
+
});
|
|
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
|
+
};
|
|
2932
2956
|
|
|
2933
2957
|
// src/infrastructure/validators/schema-zod.utils.ts
|
|
2934
2958
|
var ZodUtils = Object.freeze({
|
|
2935
2959
|
/**
|
|
2936
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.
|
|
2937
2962
|
* @param additionalSchema - An object representing additional properties to be added to the command schema.
|
|
2938
2963
|
* @returns A Zod schema for the command.
|
|
2939
2964
|
*/
|
|
2940
|
-
createCommandSchema: (additionalSchema) => {
|
|
2941
|
-
return baseCommandZodSchema.extend(additionalSchema).strict();
|
|
2965
|
+
createCommandSchema: (intent, additionalSchema) => {
|
|
2966
|
+
return baseCommandZodSchema.get(intent).extend(additionalSchema).strict();
|
|
2942
2967
|
},
|
|
2943
2968
|
/**
|
|
2944
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.
|
|
2945
2971
|
* @param additionalSchema - An object representing additional properties to be added to the query schema.
|
|
2946
2972
|
* @returns A Zod schema for the query.
|
|
2947
2973
|
*/
|
|
2948
|
-
createQuerySchema: (additionalSchema) => {
|
|
2949
|
-
return baseQueryZodSchema.extend(additionalSchema).strict();
|
|
2974
|
+
createQuerySchema: (intent, additionalSchema) => {
|
|
2975
|
+
return baseQueryZodSchema.get(intent).extend(additionalSchema).strict();
|
|
2950
2976
|
}
|
|
2951
2977
|
});
|
|
2952
2978
|
|