@kematjaya/crud-ui-generator 0.2.0 → 0.2.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.
@@ -1,13 +1,17 @@
1
1
  import { displayFields } from '../naming.js';
2
2
  /**
3
3
  * Fresh-file bootstrap, only used when src/types/api.ts doesn't exist yet. In the boilerplate
4
- * app this file already exists (written for the Notes feature) with these same JsonLd/Json
5
- * helpers and the `paths`/`components` import from the OpenAPI-generated `./api.generated` —
6
- * this header is only a fallback for a from-scratch project that hasn't set that up yet.
4
+ * app this file already exists (written for the Notes feature) with this same Json helper
5
+ * and the `paths`/`components` import from the OpenAPI-generated `./api.generated` — this
6
+ * header is only a fallback for a from-scratch project that hasn't set that up yet.
7
+ *
8
+ * Extracts the `application/json` (not `application/ld+json`/Hydra) response shape, matching
9
+ * how `lib/bff.ts`'s `authedBackend()` calls the API Platform backend — plain JSON, so
10
+ * collections come back as `{ totalItems, member }` rather than a Hydra-wrapped `hydra:member`.
7
11
  */
8
12
  export const typesApiFileHeader = `import type { components, paths } from './api.generated';
9
13
 
10
- type JsonLd<T> = T extends { 'application/ld+json': infer V } ? V : never;
14
+ type Json<T> = T extends { 'application/json': infer V } ? V : never;
11
15
  `;
12
16
  export function typesApiMarker(entityPascal) {
13
17
  return `export type ${entityPascal} =`;
@@ -28,9 +32,9 @@ export function typesApiBlock(spec, names) {
28
32
  return `
29
33
  type ${entitiesPascal}CollectionResponses = paths['/api/${entitiesKebab}']['get']['responses'];
30
34
  type ${entityPascal}PostResponses = paths['/api/${entitiesKebab}']['post']['responses'];
31
- type Generated${entityPascal} = NonNullable<JsonLd<${entityPascal}PostResponses[201]['content']>>;
35
+ type Generated${entityPascal} = NonNullable<Json<${entityPascal}PostResponses[201]['content']>>;
32
36
  type Generated${entitiesPascal}Collection = NonNullable<
33
- JsonLd<${entitiesPascal}CollectionResponses[200]['content']>
37
+ Json<${entitiesPascal}CollectionResponses[200]['content']>
34
38
  >;
35
39
 
36
40
  export type ${entityPascal}Input = components['schemas']['${entityPascal}.${entityPascal}Input'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kematjaya/crud-ui-generator",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Next.js CRUD frontend generator that reads crud-specs/{Entity}.json sidecars written by kematjaya/crud-maker-bundle's make:kmj-api-crud and generates pages, components, and BFF routes matching the boilerplate's hand-written Notes feature.",
5
5
  "type": "module",
6
6
  "license": "MIT",