@eide/uniformgen 0.1.3 → 0.1.5
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/commands/login.js +6 -6
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +44 -6
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +15 -4
- package/dist/fetcher/fetch-schemas.d.ts.map +1 -1
- package/dist/fetcher/fetch-schemas.js +6 -4
- package/dist/generators/admin/queries.d.ts.map +1 -1
- package/dist/generators/admin/queries.js +15 -12
- package/dist/generators/documents/entity-models.d.ts.map +1 -1
- package/dist/generators/documents/entity-models.js +2 -1
- package/dist/generators/types/entity-models.d.ts.map +1 -1
- package/dist/generators/types/entity-models.js +2 -1
- package/dist/graphql/generated/graphql.d.ts +87 -371
- package/dist/graphql/generated/graphql.d.ts.map +1 -1
- package/dist/graphql/generated/graphql.js +0 -6
- package/dist/utils/field-mapping.d.ts.map +1 -1
- package/dist/utils/field-mapping.js +24 -5
- package/package.json +14 -14
|
@@ -493,12 +493,6 @@ export var TrendGranularity;
|
|
|
493
493
|
TrendGranularity["Monthly"] = "monthly";
|
|
494
494
|
TrendGranularity["Weekly"] = "weekly";
|
|
495
495
|
})(TrendGranularity || (TrendGranularity = {}));
|
|
496
|
-
/** Type of redirect */
|
|
497
|
-
export var UnifiedRedirectType;
|
|
498
|
-
(function (UnifiedRedirectType) {
|
|
499
|
-
UnifiedRedirectType["Manual"] = "MANUAL";
|
|
500
|
-
UnifiedRedirectType["RouteAlias"] = "ROUTE_ALIAS";
|
|
501
|
-
})(UnifiedRedirectType || (UnifiedRedirectType = {}));
|
|
502
496
|
export var UserRole;
|
|
503
497
|
(function (UserRole) {
|
|
504
498
|
UserRole["PlatformAdmin"] = "PLATFORM_ADMIN";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../src/utils/field-mapping.ts"],"names":[],"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CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,GAC7C,GAAG,CAAC,MAAM,CAAC,CAmBb;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,GAC7C,GAAG,CAAC,MAAM,CAAC,CAmBb;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWtD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAqFjE"}
|
|
@@ -151,6 +151,11 @@ export const FIELD_TYPE_MAPPING = {
|
|
|
151
151
|
* Get TypeScript type for a field
|
|
152
152
|
*/
|
|
153
153
|
export function getFieldType(field, mode = 'output') {
|
|
154
|
+
// Defensive null check
|
|
155
|
+
if (!field?.type) {
|
|
156
|
+
console.warn(`Field has no type, defaulting to 'unknown'`);
|
|
157
|
+
return 'unknown';
|
|
158
|
+
}
|
|
154
159
|
const mapping = FIELD_TYPE_MAPPING[field.type];
|
|
155
160
|
// If not a primitive type, it's an inline schema reference
|
|
156
161
|
if (!mapping) {
|
|
@@ -238,12 +243,16 @@ export function getInlineSchemaReferences(fields) {
|
|
|
238
243
|
* Convert field ID to camelCase
|
|
239
244
|
*/
|
|
240
245
|
export function toCamelCase(str) {
|
|
246
|
+
if (!str)
|
|
247
|
+
return 'unknown';
|
|
241
248
|
return str.replace(/[-_]([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
242
249
|
}
|
|
243
250
|
/**
|
|
244
251
|
* Convert field ID to PascalCase
|
|
245
252
|
*/
|
|
246
253
|
export function toPascalCase(str) {
|
|
254
|
+
if (!str)
|
|
255
|
+
return 'Unknown';
|
|
247
256
|
const camel = toCamelCase(str);
|
|
248
257
|
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
249
258
|
}
|
|
@@ -253,6 +262,8 @@ export function toPascalCase(str) {
|
|
|
253
262
|
* Prefixes with underscore if name starts with a number.
|
|
254
263
|
*/
|
|
255
264
|
export function sanitizeFieldName(name) {
|
|
265
|
+
if (!name)
|
|
266
|
+
return '_unknown';
|
|
256
267
|
// Replace all non-alphanumeric and non-underscore characters with underscores
|
|
257
268
|
let sanitized = name.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
258
269
|
// If starts with a number, prefix with underscore
|
|
@@ -267,10 +278,13 @@ export function sanitizeFieldName(name) {
|
|
|
267
278
|
*/
|
|
268
279
|
export function generateFieldDef(field) {
|
|
269
280
|
const parts = [];
|
|
270
|
-
// Required properties
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
281
|
+
// Required properties (with defensive null checks)
|
|
282
|
+
const fieldKey = field.key ?? 'unknown';
|
|
283
|
+
const fieldType = field.type ?? 'text';
|
|
284
|
+
const fieldLabel = field.label ?? field.key ?? 'Unknown';
|
|
285
|
+
parts.push(`key: '${fieldKey}'`);
|
|
286
|
+
parts.push(`type: '${fieldType}'`);
|
|
287
|
+
parts.push(`label: '${fieldLabel.replace(/'/g, "\\'")}'`);
|
|
274
288
|
// Optional properties
|
|
275
289
|
if (field.required) {
|
|
276
290
|
parts.push('required: true');
|
|
@@ -301,7 +315,12 @@ export function generateFieldDef(field) {
|
|
|
301
315
|
if ((field.type === 'select' || field.type === 'multiselect') && field.options?.options) {
|
|
302
316
|
const options = field.options.options;
|
|
303
317
|
const optionsStr = options
|
|
304
|
-
.
|
|
318
|
+
.filter((o) => o.value !== undefined) // Skip options without values
|
|
319
|
+
.map((o) => {
|
|
320
|
+
const label = (o.label ?? o.value ?? '').replace(/'/g, "\\'");
|
|
321
|
+
const value = (o.value ?? '').replace(/'/g, "\\'");
|
|
322
|
+
return `{ label: '${label}', value: '${value}' }`;
|
|
323
|
+
})
|
|
305
324
|
.join(', ');
|
|
306
325
|
parts.push(`options: [${optionsStr}]`);
|
|
307
326
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eide/uniformgen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Type-safe code generator for Foir - generates TypeScript types and GraphQL operations from your project schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"dist",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"dev": "echo 'UniformGen is a CLI tool. Use ./test-uniformgen.sh to test it locally.'",
|
|
25
|
+
"dev:cli": "tsx src/cli.ts",
|
|
26
|
+
"dev:watch": "tsx watch src/cli.ts",
|
|
27
|
+
"check-types": "tsc --noEmit",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest watch",
|
|
30
|
+
"codegen": "graphql-codegen --config codegen.ts"
|
|
31
|
+
},
|
|
22
32
|
"keywords": [
|
|
23
33
|
"foir",
|
|
24
34
|
"eide",
|
|
@@ -44,6 +54,7 @@
|
|
|
44
54
|
"zod": "^3.24.1"
|
|
45
55
|
},
|
|
46
56
|
"devDependencies": {
|
|
57
|
+
"@foir/config": "workspace:*",
|
|
47
58
|
"@graphql-codegen/cli": "^5.0.7",
|
|
48
59
|
"@graphql-codegen/client-preset": "^4.8.3",
|
|
49
60
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
@@ -51,20 +62,9 @@
|
|
|
51
62
|
"@types/node": "^22.5.0",
|
|
52
63
|
"tsx": "^4.20.0",
|
|
53
64
|
"typescript": "5.9.2",
|
|
54
|
-
"vitest": "^3.2.4"
|
|
55
|
-
"@foir/config": "0.0.1"
|
|
65
|
+
"vitest": "^3.2.4"
|
|
56
66
|
},
|
|
57
67
|
"engines": {
|
|
58
68
|
"node": ">=18.0.0"
|
|
59
|
-
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "tsc",
|
|
62
|
-
"dev": "echo 'UniformGen is a CLI tool. Use ./test-uniformgen.sh to test it locally.'",
|
|
63
|
-
"dev:cli": "tsx src/cli.ts",
|
|
64
|
-
"dev:watch": "tsx watch src/cli.ts",
|
|
65
|
-
"check-types": "tsc --noEmit",
|
|
66
|
-
"test": "vitest run",
|
|
67
|
-
"test:watch": "vitest watch",
|
|
68
|
-
"codegen": "graphql-codegen --config codegen.ts"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|