litestar-vite-plugin 0.15.0-beta.6 → 0.15.0-rc.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.
@@ -87,8 +87,20 @@ export interface FlashMessages {}
87
87
 
88
88
  `;
89
89
  }
90
- const sharedPropsContent = includeDefaultAuth || includeDefaultFlash ? ` auth?: AuthData
91
- flash?: FlashMessages` : "";
90
+ const defaultGeneratedSharedProps = {
91
+ errors: { type: "Record<string, string[]>", optional: true },
92
+ csrf_token: { type: "string", optional: true },
93
+ ...includeDefaultAuth || includeDefaultFlash ? {
94
+ auth: { type: "AuthData", optional: true },
95
+ flash: { type: "FlashMessages", optional: true }
96
+ } : {}
97
+ };
98
+ const generatedSharedProps = Object.keys(json.sharedProps ?? {}).length > 0 ? json.sharedProps : defaultGeneratedSharedProps;
99
+ const generatedSharedPropLines = Object.entries(generatedSharedProps).sort(([a], [b]) => a.localeCompare(b)).map(([key, def]) => {
100
+ const optional = def.optional ? "?" : "";
101
+ const safeKey = /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
102
+ return ` ${safeKey}${optional}: ${def.type}`;
103
+ });
92
104
  const allCustomTypes = /* @__PURE__ */ new Set();
93
105
  for (const data of Object.values(json.pages)) {
94
106
  if (data.tsType) {
@@ -98,6 +110,55 @@ export interface FlashMessages {}
98
110
  allCustomTypes.add(t);
99
111
  }
100
112
  }
113
+ const builtinTypes = /* @__PURE__ */ new Set([
114
+ "any",
115
+ "unknown",
116
+ "never",
117
+ "void",
118
+ "undefined",
119
+ "null",
120
+ "boolean",
121
+ "string",
122
+ "number",
123
+ "bigint",
124
+ "symbol",
125
+ "object",
126
+ "Record",
127
+ "Partial",
128
+ "Required",
129
+ "Readonly",
130
+ "Pick",
131
+ "Omit",
132
+ "Exclude",
133
+ "Extract",
134
+ "NonNullable",
135
+ "Parameters",
136
+ "ReturnType",
137
+ "InstanceType",
138
+ "Uppercase",
139
+ "Lowercase",
140
+ "Capitalize",
141
+ "Uncapitalize",
142
+ "Promise",
143
+ "Array",
144
+ "Map",
145
+ "Set",
146
+ "WeakMap",
147
+ "WeakSet",
148
+ "Date",
149
+ "RegExp",
150
+ "User",
151
+ "AuthData",
152
+ "FlashMessages"
153
+ ]);
154
+ for (const def of Object.values(generatedSharedProps)) {
155
+ for (const match of def.type.matchAll(/\b[A-Za-z_][A-Za-z0-9_]*\b/g)) {
156
+ const name = match[0];
157
+ if (!builtinTypes.has(name)) {
158
+ allCustomTypes.add(name);
159
+ }
160
+ }
161
+ }
101
162
  const apiTypesPath = path.join(outDir, "api", "types.gen.ts");
102
163
  const availableApiTypes = /* @__PURE__ */ new Set();
103
164
  if (fs.existsSync(apiTypesPath)) {
@@ -155,8 +216,7 @@ ${importStatement}${userTypes}${authTypes}${flashTypes}/**
155
216
  * Includes built-in props + static config props.
156
217
  */
157
218
  export interface GeneratedSharedProps {
158
- errors?: Record<string, string[]>
159
- csrf_token?: string
219
+ ${generatedSharedPropLines.join("\n")}
160
220
  }
161
221
 
162
222
  /**
@@ -177,7 +237,6 @@ export interface GeneratedSharedProps {
177
237
  * }
178
238
  */
179
239
  export interface SharedProps {
180
- ${sharedPropsContent}
181
240
  }
182
241
 
183
242
  /** Full shared props = generated + user-defined */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litestar-vite-plugin",
3
- "version": "0.15.0-beta.6",
3
+ "version": "0.15.0-rc.1",
4
4
  "type": "module",
5
5
  "description": "Litestar plugin for Vite.",
6
6
  "keywords": [