@vitnode/core 1.2.0-canary.48 → 1.2.0-canary.49

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.
Files changed (125) hide show
  1. package/dist/scripts/plugin.d.ts.map +1 -1
  2. package/dist/scripts/prepare-database.d.ts.map +1 -1
  3. package/dist/scripts/prepare-plugins-files.d.ts +1 -1
  4. package/dist/scripts/prepare-plugins-files.d.ts.map +1 -1
  5. package/dist/scripts/scripts.js +4 -4
  6. package/dist/src/api/config.d.ts.map +1 -1
  7. package/dist/src/api/config.js +3 -1
  8. package/dist/src/api/lib/check-plugin-id.d.ts.map +1 -1
  9. package/dist/src/api/lib/check-plugin-id.js +2 -0
  10. package/dist/src/api/lib/with-pagination.d.ts +2 -24
  11. package/dist/src/api/lib/with-pagination.d.ts.map +1 -1
  12. package/dist/src/api/middlewares/global.middleware.d.ts +7 -1
  13. package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
  14. package/dist/src/api/middlewares/global.middleware.js +6 -2
  15. package/dist/src/api/models/email.d.ts +3 -1
  16. package/dist/src/api/models/email.d.ts.map +1 -1
  17. package/dist/src/api/models/email.js +25 -2
  18. package/dist/src/api/modules/admin/admin.module.d.ts +41 -288
  19. package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -1
  20. package/dist/src/api/modules/admin/debug/debug.admin.module.d.ts +23 -131
  21. package/dist/src/api/modules/admin/debug/debug.admin.module.d.ts.map +1 -1
  22. package/dist/src/api/modules/admin/debug/routes/logs.route.d.ts +23 -131
  23. package/dist/src/api/modules/admin/debug/routes/logs.route.d.ts.map +1 -1
  24. package/dist/src/api/modules/admin/routes/session.route.d.ts +2 -52
  25. package/dist/src/api/modules/admin/routes/session.route.d.ts.map +1 -1
  26. package/dist/src/api/modules/admin/users/routes/list.route.d.ts +16 -105
  27. package/dist/src/api/modules/admin/users/routes/list.route.d.ts.map +1 -1
  28. package/dist/src/api/modules/admin/users/routes/users.route.d.ts +18 -105
  29. package/dist/src/api/modules/admin/users/routes/users.route.d.ts.map +1 -1
  30. package/dist/src/api/modules/admin/users/users.admin.module.d.ts +16 -105
  31. package/dist/src/api/modules/admin/users/users.admin.module.d.ts.map +1 -1
  32. package/dist/src/api/modules/middleware/middleware.module.d.ts +7 -36
  33. package/dist/src/api/modules/middleware/middleware.module.d.ts.map +1 -1
  34. package/dist/src/api/modules/middleware/route.d.ts +14 -72
  35. package/dist/src/api/modules/middleware/route.d.ts.map +1 -1
  36. package/dist/src/api/modules/users/routes/session.route.d.ts +2 -54
  37. package/dist/src/api/modules/users/routes/session.route.d.ts.map +1 -1
  38. package/dist/src/api/modules/users/routes/sign-in.route.d.ts +5 -27
  39. package/dist/src/api/modules/users/routes/sign-in.route.d.ts.map +1 -1
  40. package/dist/src/api/modules/users/routes/sign-in.route.js +1 -1
  41. package/dist/src/api/modules/users/routes/sign-out.route.d.ts +1 -5
  42. package/dist/src/api/modules/users/routes/sign-out.route.d.ts.map +1 -1
  43. package/dist/src/api/modules/users/routes/sign-up.route.d.ts +8 -36
  44. package/dist/src/api/modules/users/routes/sign-up.route.d.ts.map +1 -1
  45. package/dist/src/api/modules/users/routes/sign-up.route.js +2 -2
  46. package/dist/src/api/modules/users/routes/test.route.js +1 -1
  47. package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +3 -19
  48. package/dist/src/api/modules/users/sso/routes/callback.route.d.ts.map +1 -1
  49. package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +2 -10
  50. package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts.map +1 -1
  51. package/dist/src/api/modules/users/sso/sso.module.d.ts +5 -29
  52. package/dist/src/api/modules/users/sso/sso.module.d.ts.map +1 -1
  53. package/dist/src/api/modules/users/users.module.d.ts +16 -128
  54. package/dist/src/api/modules/users/users.module.d.ts.map +1 -1
  55. package/dist/src/components/form/auto-form.d.ts +28 -6
  56. package/dist/src/components/form/auto-form.d.ts.map +1 -1
  57. package/dist/src/components/form/auto-form.js +46 -12
  58. package/dist/src/components/form/fields/checkbox.d.ts +3 -7
  59. package/dist/src/components/form/fields/checkbox.d.ts.map +1 -1
  60. package/dist/src/components/form/fields/checkbox.js +5 -4
  61. package/dist/src/components/form/fields/combobox-async.d.ts +3 -6
  62. package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -1
  63. package/dist/src/components/form/fields/combobox-async.js +4 -4
  64. package/dist/src/components/form/fields/combobox.d.ts +3 -6
  65. package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
  66. package/dist/src/components/form/fields/combobox.js +4 -5
  67. package/dist/src/components/form/fields/input.d.ts +3 -8
  68. package/dist/src/components/form/fields/input.d.ts.map +1 -1
  69. package/dist/src/components/form/fields/input.js +8 -4
  70. package/dist/src/components/form/fields/radio-group.d.ts +3 -6
  71. package/dist/src/components/form/fields/radio-group.d.ts.map +1 -1
  72. package/dist/src/components/form/fields/radio-group.js +4 -5
  73. package/dist/src/components/form/fields/select.d.ts +3 -6
  74. package/dist/src/components/form/fields/select.d.ts.map +1 -1
  75. package/dist/src/components/form/fields/select.js +4 -5
  76. package/dist/src/components/form/fields/switch.d.ts +2 -6
  77. package/dist/src/components/form/fields/switch.d.ts.map +1 -1
  78. package/dist/src/components/form/fields/switch.js +9 -9
  79. package/dist/src/components/form/fields/textarea.d.ts +3 -4
  80. package/dist/src/components/form/fields/textarea.d.ts.map +1 -1
  81. package/dist/src/components/form/fields/textarea.js +5 -3
  82. package/dist/src/components/ui/button-client.d.ts +3 -0
  83. package/dist/src/components/ui/button-client.d.ts.map +1 -0
  84. package/dist/src/components/ui/button-client.js +57 -0
  85. package/dist/src/components/ui/button.d.ts +2 -3
  86. package/dist/src/components/ui/button.d.ts.map +1 -1
  87. package/dist/src/components/ui/button.js +5 -39
  88. package/dist/src/components/ui/form.d.ts +2 -2
  89. package/dist/src/components/ui/form.d.ts.map +1 -1
  90. package/dist/src/components/ui/form.js +2 -2
  91. package/dist/src/components/ui/loader.js +1 -1
  92. package/dist/src/emails/default-template.d.ts +5 -1
  93. package/dist/src/emails/default-template.d.ts.map +1 -1
  94. package/dist/src/emails/default-template.js +10 -11
  95. package/dist/src/lib/api/get-middleware-api.d.ts +1 -1
  96. package/dist/src/lib/api/get-session-admin-api.d.ts +2 -2
  97. package/dist/src/lib/api/get-session-api.d.ts +2 -2
  98. package/dist/src/lib/helpers/auto-form.d.ts +18 -8
  99. package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
  100. package/dist/src/lib/helpers/auto-form.js +90 -86
  101. package/dist/src/lib/helpers/auto-form.test.js +299 -138
  102. package/dist/src/lib/navigation.d.ts +5 -5
  103. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts +9 -9
  104. package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.d.ts +10 -10
  105. package/dist/src/views/admin/views/core/test.d.ts.map +1 -1
  106. package/dist/src/views/admin/views/core/test.js +6 -6
  107. package/dist/src/views/auth/components/password-input.d.ts +2 -1
  108. package/dist/src/views/auth/components/password-input.d.ts.map +1 -1
  109. package/dist/src/views/auth/components/password-input.js +15 -8
  110. package/dist/src/views/auth/sign-in/form/use-form.d.ts +4 -16
  111. package/dist/src/views/auth/sign-in/form/use-form.d.ts.map +1 -1
  112. package/dist/src/views/auth/sign-in/form/use-form.js +1 -1
  113. package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -1
  114. package/dist/src/views/auth/sign-up/form/form.js +22 -9
  115. package/dist/src/views/auth/sign-up/form/mutation-api.d.ts +1 -1
  116. package/dist/src/views/auth/sign-up/form/use-form.d.ts +18 -36
  117. package/dist/src/views/auth/sign-up/form/use-form.d.ts.map +1 -1
  118. package/dist/src/views/auth/sign-up/form/use-form.js +10 -7
  119. package/dist/src/vitnode.config.d.ts +3 -0
  120. package/dist/src/vitnode.config.d.ts.map +1 -1
  121. package/dist/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +21 -18
  123. package/dist/src/components/form/fields/item.d.ts +0 -14
  124. package/dist/src/components/form/fields/item.d.ts.map +0 -1
  125. package/dist/src/components/form/fields/item.js +0 -22
@@ -1,10 +1,10 @@
1
1
  export declare const getSessionApi: () => Promise<{
2
2
  user: {
3
- email: string;
4
3
  id: number;
4
+ email: string;
5
5
  name: string;
6
- createdAt: Date;
7
6
  nameCode: string;
7
+ createdAt: Date;
8
8
  newsletter: boolean;
9
9
  avatarColor: string;
10
10
  emailVerified: boolean;
@@ -1,10 +1,20 @@
1
1
  import type { DefaultValues } from 'react-hook-form';
2
- import { z } from 'zod';
3
- export declare const getShapeFromSchema: (schema: z.ZodEffects<z.ZodObject<z.ZodRawShape>> | z.ZodObject<z.ZodRawShape>, id: string) => null | z.ZodAny;
4
- export type ZodObjectOrWrapped = z.Schema<any, any>;
5
- export declare function getObjectFormSchema(schema: ZodObjectOrWrapped): z.ZodObject<any, any>;
6
- export declare function getBaseSchema<T extends z.ZodTypeAny>(schema: T | z.ZodEffects<T>, isArray?: boolean): null | T;
7
- export declare const getBaseType: (schema: z.ZodTypeAny) => string;
8
- export declare function getDefaultValueInZodStack(schema: z.ZodTypeAny): unknown;
9
- export declare function getDefaultValues<Schema extends z.ZodObject<any, any>>(schema: Schema): DefaultValues<Partial<z.TypeOf<Schema>>>;
2
+ import type { z } from 'zod';
3
+ export declare function getDefaults<T extends z.ZodType>(jsonSchema?: z.core.JSONSchema.JSONSchema): DefaultValues<z.input<T>>;
4
+ export interface InputParams {
5
+ [key: string]: InputParams | {
6
+ description?: string;
7
+ enum?: string[];
8
+ maxLength?: number;
9
+ minLength?: number;
10
+ pattern?: string;
11
+ patterns?: string[];
12
+ required?: boolean;
13
+ type?: string;
14
+ };
15
+ }
16
+ export declare function getZodInputParams(jsonSchema?: z.core.JSONSchema.JSONSchema, parentRequired?: string[]): InputParams;
17
+ type NestedParamValue = InputParams[string] | undefined;
18
+ export declare function getNestedParam(obj: InputParams, path: string): NestedParamValue;
19
+ export {};
10
20
  //# sourceMappingURL=auto-form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC7E,IAAI,MAAM,KACT,IAAI,GAAG,CAAC,CAAC,MAMX,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAEzB,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAUvB;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAClD,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI,GAAG,CAAC,CAYV;AAMD,eAAO,MAAM,WAAW,GAAI,QAAQ,CAAC,CAAC,UAAU,KAAG,MAIlD,CAAC;AAKF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO,CA2CvE;AAMD,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EACnE,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CA8B1C"}
1
+ {"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAC7C,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,GACxC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CA6B3B;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GACR,WAAW,GACX;QACE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAEhB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACP;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EACzC,cAAc,GAAE,MAAM,EAAO,GAC5B,WAAW,CA0Eb;AAED,KAAK,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AAExD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,GACX,gBAAgB,CAkBlB"}
@@ -1,94 +1,98 @@
1
- import { z } from "zod";
2
- export const getShapeFromSchema = (schema, id)=>{
3
- if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
4
- return schema._def.schema.shape[id];
1
+ export function getDefaults(jsonSchema) {
2
+ if (!jsonSchema?.properties) {
3
+ return {};
5
4
  }
6
- return schema.shape[id];
7
- };
8
- export function getObjectFormSchema(schema) {
9
- if (schema._def.typeName === 'ZodEffects') {
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- const typedSchema = schema;
12
- return getObjectFormSchema(typedSchema._def.schema);
13
- }
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- return schema;
16
- }
17
- /**
18
- * Get the lowest level Zod type.
19
- * This will unpack optionals, refinements, etc.
20
- */ export function getBaseSchema(schema, isArray) {
21
- if ('innerType' in schema._def) {
22
- return getBaseSchema(schema._def.innerType, isArray);
23
- }
24
- if ('schema' in schema._def) {
25
- return getBaseSchema(schema._def.schema, isArray);
26
- }
27
- if ('type' in schema._def && isArray) {
28
- return getBaseSchema(schema._def.type, isArray);
5
+ const defaultValues = {};
6
+ // Iterate over each property in the schema
7
+ for(const key in jsonSchema.properties){
8
+ const prop = jsonSchema.properties[key];
9
+ // Case 1: The property has a 'default' key.
10
+ if (prop.default !== undefined) {
11
+ defaultValues[key] = prop.default;
12
+ continue; // Move to the next property
13
+ }
14
+ // Case 2: The property is a nested object. Recurse into it.
15
+ if (prop.type === 'object' && prop.properties) {
16
+ const nestedDefaults = getDefaults(prop);
17
+ // Only add the nested object if it contains default values.
18
+ if (Object.keys(nestedDefaults).length > 0) {
19
+ defaultValues[key] = nestedDefaults;
20
+ }
21
+ }
29
22
  }
30
- return schema;
23
+ return defaultValues;
31
24
  }
32
- /**
33
- * Get the type name of the lowest level Zod type.
34
- * This will unpack optionals, refinements, etc.
35
- */ export const getBaseType = (schema)=>{
36
- const baseSchema = getBaseSchema(schema);
37
- return baseSchema ? baseSchema._def.typeName : '';
38
- };
39
- /**
40
- * Search for a "ZodDefault" in the Zod stack and return its value.
41
- */ export function getDefaultValueInZodStack(schema) {
42
- // Check if this is a ZodDefault and return its value
43
- if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
44
- const defaultValue = schema._def.defaultValue();
45
- // If defaultValue is a function, call it to get the actual value
46
- return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
47
- }
48
- // Traverse through ZodEffects (like refinements) - check this first as it wraps the actual schema
49
- if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
50
- return getDefaultValueInZodStack(schema._def.schema);
51
- }
52
- // Traverse through other types that have schema property
53
- if ('schema' in schema._def) {
54
- return getDefaultValueInZodStack(schema._def.schema);
25
+ export function getZodInputParams(jsonSchema, parentRequired = []) {
26
+ // Base case: If there's no schema or properties, return an empty object.
27
+ if (!jsonSchema?.properties) {
28
+ return {};
55
29
  }
56
- // Traverse through ZodOptional, ZodNullable, etc.
57
- if ('innerType' in schema._def) {
58
- return getDefaultValueInZodStack(schema._def.innerType);
59
- }
60
- // Traverse through ZodArray's element type
61
- if ('type' in schema._def && schema._def.typeName === z.ZodFirstPartyTypeKind.ZodArray) {
62
- const innerDefault = getDefaultValueInZodStack(schema._def.type);
63
- return innerDefault !== undefined ? [
64
- innerDefault
65
- ] : undefined;
66
- }
67
- return undefined;
68
- }
69
- /**
70
- * Get all default values from a Zod schema.
71
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- export function getDefaultValues(schema) {
73
- const { shape } = schema;
74
- const defaultValues = {};
75
- if (!shape) return defaultValues;
76
- for (const key of Object.keys(shape)){
77
- const item = shape[key];
78
- // First, try to get any default value from the current item (including nested defaults)
79
- const defaultValue = getDefaultValueInZodStack(item);
80
- if (defaultValue !== undefined) {
81
- defaultValues[key] = defaultValue;
82
- } else if (getBaseType(item) === 'ZodObject') {
83
- // Only recurse into object shape if there's no default value at the current level
84
- const baseSchema = getBaseSchema(item);
85
- if (baseSchema && 'shape' in baseSchema._def) {
86
- const defaultItems = getDefaultValues(baseSchema);
87
- if (defaultItems && Object.keys(defaultItems).length > 0) {
88
- defaultValues[key] = defaultItems;
30
+ const extractedParams = {};
31
+ const requiredFields = new Set(jsonSchema.required ?? parentRequired);
32
+ // Iterate over each property in the current schema level.
33
+ for(const key in jsonSchema.properties){
34
+ const prop = jsonSchema.properties[key];
35
+ const fieldParams = {};
36
+ // 1. Handle 'required' status
37
+ if (requiredFields.has(key)) {
38
+ fieldParams.required = true;
39
+ }
40
+ // 2. Handle standard string constraints
41
+ if (prop.minLength !== undefined) {
42
+ fieldParams.minLength = prop.minLength;
43
+ }
44
+ if (prop.maxLength !== undefined) {
45
+ fieldParams.maxLength = prop.maxLength;
46
+ }
47
+ if (prop.pattern !== undefined) {
48
+ fieldParams.pattern = prop.pattern;
49
+ }
50
+ if (prop.enum) {
51
+ fieldParams.enum = prop.enum;
52
+ }
53
+ // 3. Handle complex patterns from `allOf` (used for password)
54
+ if (prop.allOf) {
55
+ fieldParams.patterns = prop.allOf.map((p)=>p.pattern).filter(Boolean); // Filter out any undefined patterns
56
+ }
57
+ if (prop.description) {
58
+ fieldParams.description = prop.description;
59
+ }
60
+ // 4. Determine the input type based on schema type and format
61
+ switch(prop.type){
62
+ case 'boolean':
63
+ fieldParams.type = 'checkbox';
64
+ break;
65
+ case 'integer':
66
+ case 'number':
67
+ fieldParams.type = 'number';
68
+ break;
69
+ case 'string':
70
+ // Check format for special string types
71
+ if (prop.format === 'email') {
72
+ fieldParams.type = 'email';
73
+ } else if (key.toLowerCase().includes('password')) {
74
+ // Infer password type by key name for better UX
75
+ fieldParams.type = 'password';
76
+ } else {
77
+ fieldParams.type = 'text';
89
78
  }
90
- }
79
+ break;
80
+ }
81
+ // 5. Handle nested objects by making a recursive call
82
+ if (prop.type === 'object') {
83
+ // Pass the 'required' array from the nested object itself.
84
+ extractedParams[key] = getZodInputParams(prop, prop.required);
85
+ } else {
86
+ extractedParams[key] = fieldParams;
91
87
  }
92
88
  }
93
- return defaultValues;
89
+ return extractedParams;
90
+ }
91
+ export function getNestedParam(obj, path) {
92
+ return path.split('.').reduce((acc, key)=>{
93
+ if (acc && typeof acc === 'object' && !Array.isArray(acc) && key in acc) {
94
+ return acc[key];
95
+ }
96
+ return undefined;
97
+ }, obj);
94
98
  }