nucleus-core-ts 0.10.137 → 0.10.139

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/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.137
1
+ 0.10.139
@@ -156,7 +156,11 @@ export function NucleusEntityShowcase({ entity, apiActions, title, description,
156
156
  const refTable = column.references.table;
157
157
  if (loadedRefsRef.current.has(refTable)) return;
158
158
  loadedRefsRef.current.add(refTable);
159
- const endpointKey = `GET_${refTable.toUpperCase()}`;
159
+ // The generator's own spelling (toUpperSnakeCase): an underscore where a
160
+ // lower-case letter meets an upper-case one. Plain toUpperCase() named a
161
+ // key the runtime never registers for a camelCase table
162
+ // (verificationFlows -> GET_VERIFICATIONFLOWS), so its options never loaded.
163
+ const endpointKey = `GET_${refTable.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase()}`;
160
164
  const action = apiActions[endpointKey];
161
165
  if (action) {
162
166
  action.start({
@@ -61,8 +61,23 @@ type EntityMethodMap = {
61
61
  DELETE: 'DELETE';
62
62
  };
63
63
  type Singularize<S extends string> = S extends `${infer Base}ies` ? `${Base}y` : S extends `${infer Base}ses` ? `${Base}s` : S extends `${infer Base}s` ? Base : S;
64
- export type EntityEndpointKey<TTableName extends string, TMethod extends keyof EntityMethodMap> = TMethod extends 'GET' ? `GET_${Uppercase<TTableName>}` : `${EntityMethodMap[TMethod]}_${Uppercase<Singularize<TTableName>>}`;
65
- export type BulkEndpointKey<TTableName extends string, TMethod extends 'POST' | 'PUT' | 'DELETE'> = `BULK_${EntityMethodMap[TMethod]}_${Uppercase<TTableName>}`;
64
+ type LowerAlpha = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
65
+ type UpperAlpha = Uppercase<LowerAlpha>;
66
+ /**
67
+ * The type-level twin of the generator's `toUpperSnakeCase`: an underscore
68
+ * where a lower-case letter meets an upper-case one, then upper case.
69
+ *
70
+ * The key used to be `Uppercase<TTableName>`, which agrees with the runtime
71
+ * only for snake_case names. For a camelCase system table the two split:
72
+ * `verificationInstances` was typed `GET_VERIFICATIONINSTANCES` while the
73
+ * generator registers `GET_VERIFICATION_INSTANCES`. Measured on a host: a
74
+ * screen called `actions.GET_VERIFICATIONINSTANCES`, type-checked green, and
75
+ * got `undefined` at runtime on every open — "Onay kayıtları okunamadı" with
76
+ * no request ever sent.
77
+ */
78
+ export type ToUpperSnake<S extends string, Prev extends string = ''> = S extends `${infer C}${infer Rest}` ? `${Prev extends LowerAlpha ? (C extends UpperAlpha ? '_' : '') : ''}${C extends ' ' | '-' ? '_' : Uppercase<C>}${ToUpperSnake<Rest, C>}` : '';
79
+ export type EntityEndpointKey<TTableName extends string, TMethod extends keyof EntityMethodMap> = TMethod extends 'GET' ? `GET_${ToUpperSnake<TTableName>}` : `${EntityMethodMap[TMethod]}_${ToUpperSnake<Singularize<TTableName>>}`;
80
+ export type BulkEndpointKey<TTableName extends string, TMethod extends 'POST' | 'PUT' | 'DELETE'> = `BULK_${EntityMethodMap[TMethod]}_${ToUpperSnake<TTableName>}`;
66
81
  export interface LoginPayload {
67
82
  email: string;
68
83
  password: string;
@@ -2626,7 +2641,7 @@ export type EntityRecord = Record<string, unknown>;
2626
2641
  export type GenerateEntityEndpoints<TTable extends NucleusTable> = {
2627
2642
  [K in EntityEndpointKey<TTable['table_name'], 'GET'>]: EndpointDefinition<StandardQueryParams, ListResponse<EntityRecord>, BaseErrorResponse>;
2628
2643
  } & {
2629
- [K in `GET_${Uppercase<Singularize<TTable['table_name']>>}_BY_ID`]: EndpointDefinition<{
2644
+ [K in `GET_${ToUpperSnake<Singularize<TTable['table_name']>>}_BY_ID`]: EndpointDefinition<{
2630
2645
  id: string;
2631
2646
  }, SingleResponse<EntityRecord>, BaseErrorResponse>;
2632
2647
  } & {
@@ -2732,8 +2747,8 @@ export interface ApiCallerConfig<TConfig extends NucleusConfigOptions, TExtra ex
2732
2747
  type ExtractTableNames<T extends readonly {
2733
2748
  table_name: string;
2734
2749
  }[]> = T[number]['table_name'];
2735
- type GenerateEntityEndpointKeys<TTableName extends string> = `GET_${Uppercase<TTableName>}` | `GET_${Uppercase<Singularize<TTableName>>}_BY_ID` | `GET_${Uppercase<TTableName>}_DISTINCT` | `ADD_${Uppercase<Singularize<TTableName>>}` | `UPDATE_${Uppercase<Singularize<TTableName>>}` | `PATCH_${Uppercase<Singularize<TTableName>>}` | `DELETE_${Uppercase<Singularize<TTableName>>}`;
2736
- type GenerateBulkEndpointKeys<TTableName extends string> = `BULK_ADD_${Uppercase<TTableName>}` | `BULK_UPDATE_${Uppercase<TTableName>}` | `BULK_DELETE_${Uppercase<TTableName>}`;
2750
+ type GenerateEntityEndpointKeys<TTableName extends string> = `GET_${ToUpperSnake<TTableName>}` | `GET_${ToUpperSnake<Singularize<TTableName>>}_BY_ID` | `GET_${ToUpperSnake<TTableName>}_DISTINCT` | `ADD_${ToUpperSnake<Singularize<TTableName>>}` | `UPDATE_${ToUpperSnake<Singularize<TTableName>>}` | `PATCH_${ToUpperSnake<Singularize<TTableName>>}` | `DELETE_${ToUpperSnake<Singularize<TTableName>>}`;
2751
+ type GenerateBulkEndpointKeys<TTableName extends string> = `BULK_ADD_${ToUpperSnake<TTableName>}` | `BULK_UPDATE_${ToUpperSnake<TTableName>}` | `BULK_DELETE_${ToUpperSnake<TTableName>}`;
2737
2752
  type EntityEndpointDefinitionFor<TKey extends string> = TKey extends `GET_${string}_BY_ID` ? EndpointDefinition<{
2738
2753
  id: string;
2739
2754
  }, SingleResponse<EntityRecord>, BaseErrorResponse> : TKey extends `GET_${string}_DISTINCT` ? EndpointDefinition<{
@@ -2844,35 +2859,35 @@ type EntityConstraint = readonly {
2844
2859
  is_form_data?: boolean;
2845
2860
  }[];
2846
2861
  type GetListEndpoints<TEntities extends EntityConstraint> = {
2847
- [TN in ExtractTableNames<TEntities> as `GET_${Uppercase<TN>}`]: EndpointDefinition<StandardQueryParams | undefined, ListResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2862
+ [TN in ExtractTableNames<TEntities> as `GET_${ToUpperSnake<TN>}`]: EndpointDefinition<StandardQueryParams | undefined, ListResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2848
2863
  };
2849
2864
  type GetByIdEndpoints<TEntities extends EntityConstraint> = {
2850
- [TN in ExtractTableNames<TEntities> as `GET_${Uppercase<Singularize<TN>>}_BY_ID`]: EndpointDefinition<{
2865
+ [TN in ExtractTableNames<TEntities> as `GET_${ToUpperSnake<Singularize<TN>>}_BY_ID`]: EndpointDefinition<{
2851
2866
  id: string;
2852
2867
  }, SingleResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2853
2868
  };
2854
2869
  type GetDistinctEndpoints<TEntities extends EntityConstraint> = {
2855
- [TN in ExtractTableNames<TEntities> as `GET_${Uppercase<TN>}_DISTINCT`]: EndpointDefinition<{
2870
+ [TN in ExtractTableNames<TEntities> as `GET_${ToUpperSnake<TN>}_DISTINCT`]: EndpointDefinition<{
2856
2871
  field: string;
2857
2872
  }, StandardReturn<{
2858
2873
  value: unknown;
2859
2874
  }[]>, BaseErrorResponse>;
2860
2875
  };
2861
2876
  type AddEndpoints<TEntities extends EntityConstraint> = {
2862
- [TN in ExtractTableNames<TEntities> as `ADD_${Uppercase<Singularize<TN>>}`]: EndpointDefinition<FormData | Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>>, MutationResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2877
+ [TN in ExtractTableNames<TEntities> as `ADD_${ToUpperSnake<Singularize<TN>>}`]: EndpointDefinition<FormData | Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>>, MutationResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2863
2878
  };
2864
2879
  type UpdateEndpoints<TEntities extends EntityConstraint> = {
2865
- [TN in ExtractTableNames<TEntities> as `UPDATE_${Uppercase<Singularize<TN>>}`]: EndpointDefinition<FormData | (Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>> & {
2880
+ [TN in ExtractTableNames<TEntities> as `UPDATE_${ToUpperSnake<Singularize<TN>>}`]: EndpointDefinition<FormData | (Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>> & {
2866
2881
  id: string;
2867
2882
  }), MutationResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2868
2883
  };
2869
2884
  type PatchEndpoints<TEntities extends EntityConstraint> = {
2870
- [TN in ExtractTableNames<TEntities> as `PATCH_${Uppercase<Singularize<TN>>}`]: EndpointDefinition<Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>> & {
2885
+ [TN in ExtractTableNames<TEntities> as `PATCH_${ToUpperSnake<Singularize<TN>>}`]: EndpointDefinition<Partial<EntityFromConfig<FindEntityByName<TEntities, TN>>> & {
2871
2886
  id: string;
2872
2887
  }, MutationResponse<EntityFromConfig<FindEntityByName<TEntities, TN>>>, BaseErrorResponse>;
2873
2888
  };
2874
2889
  type DeleteEndpoints<TEntities extends EntityConstraint> = {
2875
- [TN in ExtractTableNames<TEntities> as `DELETE_${Uppercase<Singularize<TN>>}`]: EndpointDefinition<{
2890
+ [TN in ExtractTableNames<TEntities> as `DELETE_${ToUpperSnake<Singularize<TN>>}`]: EndpointDefinition<{
2876
2891
  id: string;
2877
2892
  }, DeleteResponse, BaseErrorResponse>;
2878
2893
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.10.137",
3
+ "version": "0.10.139",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",