@eide/uniformgen 0.1.1 → 0.1.2

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 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/generators/cms/route.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAEtE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CA2L/E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAmM/E"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/generators/cms/route.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAEtE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAsM/E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CA0M/E"}
@@ -35,6 +35,7 @@ export function generateResolveRouteReact(routableModels) {
35
35
  * @generated by UniformGen - DO NOT EDIT MANUALLY
36
36
  */
37
37
 
38
+ import { useMemo } from 'react';
38
39
  import { useQuery, type QueryHookOptions } from '@apollo/client';
39
40
  import { gql } from '@apollo/client';
40
41
  import type {
@@ -181,12 +182,22 @@ export function useResolveRoute(
181
182
  ) {
182
183
  const { queryOptions, referenceOptions } = options ?? {};
183
184
 
185
+ // Build contexts object from variant context fields
186
+ // NOTE: Security-sensitive fields (authenticated, customerId, userData) are injected server-side
187
+ const contexts = useMemo(() => {
188
+ const ctx: Record<string, unknown> = {};
189
+ if (context?.device) ctx.device = context.device;
190
+ if (context?.region) ctx.region = context.region;
191
+ if (context?.contexts) Object.assign(ctx, context.contexts);
192
+ return Object.keys(ctx).length > 0 ? ctx : undefined;
193
+ }, [context?.device, context?.region, context?.contexts]);
194
+
184
195
  const result = useQuery(RESOLVE_ROUTE_QUERY, {
185
196
  ...queryOptions,
186
197
  variables: {
187
198
  path,
188
199
  locale: context?.locale,
189
- contexts: context?.contexts,
200
+ contexts,
190
201
  referenceOptions,
191
202
  },
192
203
  skip: !path,
@@ -384,12 +395,19 @@ export async function resolveRoute(
384
395
  referenceOptions?: ReferenceResolutionOptions;
385
396
  }
386
397
  ): Promise<ResolvedRoute | null> {
398
+ // Build contexts object from variant context fields
399
+ // NOTE: Security-sensitive fields (authenticated, customerId, userData) are injected server-side
400
+ const contexts: Record<string, unknown> = {};
401
+ if (context?.device) contexts.device = context.device;
402
+ if (context?.region) contexts.region = context.region;
403
+ if (context?.contexts) Object.assign(contexts, context.contexts);
404
+
387
405
  const result = await client.request<{ resolveRoute: ResolvedRoute | null }>(
388
406
  RESOLVE_ROUTE_QUERY,
389
407
  {
390
408
  path,
391
409
  locale: context?.locale,
392
- contexts: context?.contexts,
410
+ contexts: Object.keys(contexts).length > 0 ? contexts : undefined,
393
411
  referenceOptions: options?.referenceOptions,
394
412
  }
395
413
  );
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/generators/resolve/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gCAAgC,CAAC;AA6FvF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CAyMR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CAwIR;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAoC/E;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAyC/E"}
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/generators/resolve/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gCAAgC,CAAC;AA6FvF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CAoNR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,WAAW,EAAE,GACxB,MAAM,CA+IR;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAoC/E;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAyC/E"}
@@ -112,6 +112,7 @@ export function generatePlatformResolveReact(model, _allModels) {
112
112
  lines.push(` */`);
113
113
  lines.push('');
114
114
  // Imports
115
+ lines.push(`import { useMemo } from 'react';`);
115
116
  lines.push(`import { useQuery, type QueryHookOptions } from '@apollo/client';`);
116
117
  lines.push(`import { gql } from '@apollo/client';`);
117
118
  lines.push(`import type { ${dataTypeName} } from '../../types/models/${model.key}.js';`);
@@ -261,12 +262,22 @@ export function generatePlatformResolveReact(model, _allModels) {
261
262
  lines.push(` context?: VariantContext,`);
262
263
  lines.push(` options?: Omit<QueryHookOptions, 'variables'>`);
263
264
  lines.push(`) {`);
265
+ lines.push(` // Build contexts object from variant context fields`);
266
+ lines.push(` // NOTE: Security-sensitive fields (authenticated, customerId, userData) are injected server-side`);
267
+ lines.push(` const contexts = useMemo(() => {`);
268
+ lines.push(` const ctx: Record<string, unknown> = {};`);
269
+ lines.push(` if (context?.device) ctx.device = context.device;`);
270
+ lines.push(` if (context?.region) ctx.region = context.region;`);
271
+ lines.push(` if (context?.contexts) Object.assign(ctx, context.contexts);`);
272
+ lines.push(` return Object.keys(ctx).length > 0 ? ctx : undefined;`);
273
+ lines.push(` }, [context?.device, context?.region, context?.contexts]);`);
274
+ lines.push('');
264
275
  lines.push(` const result = useQuery(RESOLVE_${typeName.toUpperCase()}_QUERY, {`);
265
276
  lines.push(` ...options,`);
266
277
  lines.push(` variables: {`);
267
278
  lines.push(` naturalKey,`);
268
279
  lines.push(` locale: context?.locale,`);
269
- lines.push(` contexts: context?.contexts,`);
280
+ lines.push(` contexts,`);
270
281
  lines.push(` },`);
271
282
  lines.push(` skip: !naturalKey,`);
272
283
  lines.push(` });`);
@@ -386,10 +397,17 @@ export function generatePlatformResolveRemix(model, _allModels) {
386
397
  lines.push(` naturalKey: string,`);
387
398
  lines.push(` context?: VariantContext`);
388
399
  lines.push(`): Promise<Resolved${typeName} | null> {`);
400
+ lines.push(` // Build contexts object from variant context fields`);
401
+ lines.push(` // NOTE: Security-sensitive fields (authenticated, customerId, userData) are injected server-side`);
402
+ lines.push(` const contexts: Record<string, unknown> = {};`);
403
+ lines.push(` if (context?.device) contexts.device = context.device;`);
404
+ lines.push(` if (context?.region) contexts.region = context.region;`);
405
+ lines.push(` if (context?.contexts) Object.assign(contexts, context.contexts);`);
406
+ lines.push('');
389
407
  lines.push(` const result = await client.request<{ resolveEntity: any }>(RESOLVE_${typeName.toUpperCase()}_QUERY, {`);
390
408
  lines.push(` naturalKey,`);
391
409
  lines.push(` locale: context?.locale,`);
392
- lines.push(` contexts: context?.contexts,`);
410
+ lines.push(` contexts: Object.keys(contexts).length > 0 ? contexts : undefined,`);
393
411
  lines.push(` });`);
394
412
  lines.push(` if (!result.resolveEntity) return null;`);
395
413
  lines.push(` const data = result.resolveEntity;`);
@@ -1 +1 @@
1
- {"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/generators/types/field-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,sBAAsB,IAAI,MAAM,CAmoB/C"}
1
+ {"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/generators/types/field-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,sBAAsB,IAAI,MAAM,CA2oB/C"}
@@ -219,12 +219,20 @@ export interface SortInput {
219
219
  * Used to select the appropriate variant based on user context
220
220
  *
221
221
  * Context dimensions are configured in the CMS as "context" entities.
222
- * Common contexts include: device, region, market, customerId, etc.
222
+ * You can pass common contexts as top-level properties for convenience,
223
+ * or use the generic \`contexts\` object for custom context dimensions.
224
+ *
225
+ * NOTE: Security-sensitive fields (authenticated, customerId, userData) are
226
+ * injected server-side by middleware and should NOT be passed from the client.
223
227
  */
224
228
  export interface VariantContext {
225
229
  /** Locale code for translation resolution (e.g., 'en-US', 'ja-JP') */
226
230
  locale?: string;
227
- /** Context dimensions for variant selection (dynamic, configured in CMS) */
231
+ /** Device type for variant selection (e.g., 'mobile', 'desktop', 'tablet') */
232
+ device?: string;
233
+ /** Region for variant selection (e.g., 'us', 'eu', 'apac') */
234
+ region?: string;
235
+ /** Generic context dimensions for variant selection (custom contexts configured in CMS) */
228
236
  contexts?: Record<string, unknown>;
229
237
  }
230
238
 
@@ -923,14 +923,14 @@ export type BillingOverviewMetrics = {
923
923
  export type BillingPackageLimit = {
924
924
  __typename?: 'BillingPackageLimit';
925
925
  id: Scalars['ID']['output'];
926
- includedQuantity?: Maybe<Scalars['Int']['output']>;
927
- maxQuantity?: Maybe<Scalars['Int']['output']>;
926
+ includedQuantity?: Maybe<Scalars['Float']['output']>;
927
+ maxQuantity?: Maybe<Scalars['Float']['output']>;
928
928
  metric: BillingMetric;
929
929
  overagePriceCents?: Maybe<Scalars['Int']['output']>;
930
930
  };
931
931
  export type BillingPackageLimitInput = {
932
- includedQuantity?: InputMaybe<Scalars['Int']['input']>;
933
- maxQuantity?: InputMaybe<Scalars['Int']['input']>;
932
+ includedQuantity?: InputMaybe<Scalars['Float']['input']>;
933
+ maxQuantity?: InputMaybe<Scalars['Float']['input']>;
934
934
  metric: BillingMetric;
935
935
  overagePriceCents?: InputMaybe<Scalars['Int']['input']>;
936
936
  };
@@ -958,16 +958,16 @@ export type BillingPlan = {
958
958
  export type BillingPlanLimit = {
959
959
  __typename?: 'BillingPlanLimit';
960
960
  id: Scalars['ID']['output'];
961
- includedQuantity: Scalars['Int']['output'];
962
- maxQuantity?: Maybe<Scalars['Int']['output']>;
961
+ includedQuantity: Scalars['Float']['output'];
962
+ maxQuantity?: Maybe<Scalars['Float']['output']>;
963
963
  metric: BillingMetric;
964
964
  overagePriceCents?: Maybe<Scalars['Int']['output']>;
965
965
  overageUnitSize: Scalars['Int']['output'];
966
966
  stripePriceId?: Maybe<Scalars['String']['output']>;
967
967
  };
968
968
  export type BillingPlanLimitInput = {
969
- includedQuantity: Scalars['Int']['input'];
970
- maxQuantity?: InputMaybe<Scalars['Int']['input']>;
969
+ includedQuantity: Scalars['Float']['input'];
970
+ maxQuantity?: InputMaybe<Scalars['Float']['input']>;
971
971
  metric: BillingMetric;
972
972
  overagePriceCents?: InputMaybe<Scalars['Int']['input']>;
973
973
  overageUnitSize?: InputMaybe<Scalars['Int']['input']>;
@@ -5394,8 +5394,8 @@ export type PublicBillingPlan = {
5394
5394
  };
5395
5395
  export type PublicBillingPlanLimit = {
5396
5396
  __typename?: 'PublicBillingPlanLimit';
5397
- includedQuantity: Scalars['Int']['output'];
5398
- maxQuantity?: Maybe<Scalars['Int']['output']>;
5397
+ includedQuantity: Scalars['Float']['output'];
5398
+ maxQuantity?: Maybe<Scalars['Float']['output']>;
5399
5399
  metric: BillingMetric;
5400
5400
  };
5401
5401
  /** A publish batch containing multiple versions to publish together */
@@ -5813,8 +5813,8 @@ export type Query = {
5813
5813
  recentlyOpened: Array<RecentlyOpenedItem>;
5814
5814
  /** Get a single redirect by ID */
5815
5815
  redirect?: Maybe<Redirect>;
5816
- /** List all redirects for the project */
5817
- redirects: Array<Redirect>;
5816
+ /** List all redirects for the project with pagination */
5817
+ redirects: RedirectsConnection;
5818
5818
  /**
5819
5819
  * Get all repeatable (cron) jobs across all queues.
5820
5820
  * Platform admin only.
@@ -5896,6 +5896,8 @@ export type Query = {
5896
5896
  tenant?: Maybe<Tenant>;
5897
5897
  tenantBillingStatus: TenantBillingStatusResult;
5898
5898
  tenants: TenantList;
5899
+ /** List unified redirects (manual + route aliases) with pagination */
5900
+ unifiedRedirects: UnifiedRedirectsConnection;
5899
5901
  /**
5900
5902
  * Get unread notification count for badge.
5901
5903
  * Uses headers for user context.
@@ -6285,6 +6287,7 @@ export type QueryRedirectsArgs = {
6285
6287
  activeOnly?: InputMaybe<Scalars['Boolean']['input']>;
6286
6288
  limit?: InputMaybe<Scalars['Int']['input']>;
6287
6289
  offset?: InputMaybe<Scalars['Int']['input']>;
6290
+ search?: InputMaybe<Scalars['String']['input']>;
6288
6291
  };
6289
6292
  export type QueryResolutionDistributionArgs = {
6290
6293
  dateRange: DateRangeInput;
@@ -6374,6 +6377,12 @@ export type QueryTenantsArgs = {
6374
6377
  offset?: InputMaybe<Scalars['Int']['input']>;
6375
6378
  search?: InputMaybe<Scalars['String']['input']>;
6376
6379
  };
6380
+ export type QueryUnifiedRedirectsArgs = {
6381
+ limit?: InputMaybe<Scalars['Int']['input']>;
6382
+ offset?: InputMaybe<Scalars['Int']['input']>;
6383
+ search?: InputMaybe<Scalars['String']['input']>;
6384
+ type?: InputMaybe<UnifiedRedirectType>;
6385
+ };
6377
6386
  export type QueryValidateInvitationArgs = {
6378
6387
  token: Scalars['String']['input'];
6379
6388
  };
@@ -6553,6 +6562,16 @@ export type Redirect = {
6553
6562
  targetPattern: Scalars['String']['output'];
6554
6563
  updatedAt: Scalars['DateTime']['output'];
6555
6564
  };
6565
+ /** Connection type for paginated redirects */
6566
+ export type RedirectsConnection = {
6567
+ __typename?: 'RedirectsConnection';
6568
+ /** Whether there are more items to fetch */
6569
+ hasMore: Scalars['Boolean']['output'];
6570
+ /** List of redirects */
6571
+ items: Array<Redirect>;
6572
+ /** Total count of redirects matching the filter */
6573
+ total: Scalars['Int']['output'];
6574
+ };
6556
6575
  /** Reference resolution options */
6557
6576
  export type ReferenceResolutionOptionsInput = {
6558
6577
  /** Maximum depth for nested resolution (null = unlimited with cycle detection) */
@@ -7678,6 +7697,55 @@ export type TypographyVariantInput = {
7678
7697
  name: Scalars['String']['input'];
7679
7698
  textTransform?: InputMaybe<Scalars['String']['input']>;
7680
7699
  };
7700
+ /** Unified redirect record combining manual redirects and route aliases */
7701
+ export type UnifiedRedirect = {
7702
+ __typename?: 'UnifiedRedirect';
7703
+ /** Entity type (route alias only) */
7704
+ entityType?: Maybe<Scalars['String']['output']>;
7705
+ /** Number of times this redirect has been used (manual only) */
7706
+ hitCount?: Maybe<Scalars['Int']['output']>;
7707
+ /** Unique identifier */
7708
+ id: Scalars['ID']['output'];
7709
+ /** Last time this redirect was matched (manual only) */
7710
+ lastHitAt?: Maybe<Scalars['DateTime']['output']>;
7711
+ /** Priority for matching (manual only) */
7712
+ priority?: Maybe<Scalars['Int']['output']>;
7713
+ /** Optional reason/note (manual only) */
7714
+ reason?: Maybe<Scalars['String']['output']>;
7715
+ /** Source URL pattern */
7716
+ source: Scalars['String']['output'];
7717
+ /** HTTP status code */
7718
+ statusCode: Scalars['Int']['output'];
7719
+ /** Target URL pattern */
7720
+ target: Scalars['String']['output'];
7721
+ /** Type of redirect */
7722
+ type: UnifiedRedirectType;
7723
+ };
7724
+ /** Counts of redirects by type */
7725
+ export type UnifiedRedirectCounts = {
7726
+ __typename?: 'UnifiedRedirectCounts';
7727
+ /** Number of manual redirects */
7728
+ manual: Scalars['Int']['output'];
7729
+ /** Number of route aliases */
7730
+ routeAlias: Scalars['Int']['output'];
7731
+ };
7732
+ /** Type of redirect */
7733
+ export declare enum UnifiedRedirectType {
7734
+ Manual = "MANUAL",
7735
+ RouteAlias = "ROUTE_ALIAS"
7736
+ }
7737
+ /** Connection type for unified redirects with pagination */
7738
+ export type UnifiedRedirectsConnection = {
7739
+ __typename?: 'UnifiedRedirectsConnection';
7740
+ /** Counts by type */
7741
+ counts: UnifiedRedirectCounts;
7742
+ /** Whether there are more items */
7743
+ hasMore: Scalars['Boolean']['output'];
7744
+ /** List of unified redirects */
7745
+ items: Array<UnifiedRedirect>;
7746
+ /** Total count matching the filter */
7747
+ total: Scalars['Int']['output'];
7748
+ };
7681
7749
  /** Input for unpublishing an entity record variant */
7682
7750
  export type UnpublishEntityRecordVariantInput = {
7683
7751
  variantId: Scalars['ID']['input'];
@@ -7938,9 +8006,9 @@ export type UsageLimitStatus = {
7938
8006
  };
7939
8007
  export type UsageMetricValue = {
7940
8008
  __typename?: 'UsageMetricValue';
7941
- current: Scalars['Int']['output'];
7942
- included: Scalars['Int']['output'];
7943
- max?: Maybe<Scalars['Int']['output']>;
8009
+ current: Scalars['Float']['output'];
8010
+ included: Scalars['Float']['output'];
8011
+ max?: Maybe<Scalars['Float']['output']>;
7944
8012
  metric: BillingMetric;
7945
8013
  percentUsed: Scalars['Float']['output'];
7946
8014
  };