@eide/uniformgen 0.1.1 → 0.1.3

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":"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
 
@@ -2746,6 +2746,43 @@ export type EntityReferencesDebug = {
2746
2746
  pages: Array<Scalars['ID']['output']>;
2747
2747
  products: Array<Scalars['ID']['output']>;
2748
2748
  };
2749
+ /** Route information for a single entity */
2750
+ export type EntityRouteInfo = {
2751
+ __typename?: 'EntityRouteInfo';
2752
+ /**
2753
+ * Child entity routes (only on getEntityRoutes with includeChildren: true).
2754
+ * E.g., products under a collection, pages under a parent page.
2755
+ */
2756
+ children?: Maybe<Array<EntityRouteInfo>>;
2757
+ /** Entity record ID (if found) */
2758
+ entityId?: Maybe<Scalars['ID']['output']>;
2759
+ /** Whether the entity was found */
2760
+ found: Scalars['Boolean']['output'];
2761
+ /** Entity record metadata (badges, labels, flags, etc.) */
2762
+ metadata?: Maybe<Scalars['JSON']['output']>;
2763
+ /** The natural key that was requested */
2764
+ naturalKey: Scalars['String']['output'];
2765
+ /** All routes for this entity across all contexts */
2766
+ routes: Array<EntityRouteWithContext>;
2767
+ };
2768
+ /** Route with context dimensions */
2769
+ export type EntityRouteWithContext = {
2770
+ __typename?: 'EntityRouteWithContext';
2771
+ /** Alias handling strategy if not canonical ('redirect' or 'canonical-tag') */
2772
+ aliasStrategy?: Maybe<Scalars['String']['output']>;
2773
+ /** Canonical path (if this is an alias) */
2774
+ canonicalPath?: Maybe<Scalars['String']['output']>;
2775
+ /**
2776
+ * Context dimensions for this route.
2777
+ * Generic key-value pairs (market, locale, brand, region, etc.)
2778
+ * Empty object means default/global route.
2779
+ */
2780
+ contexts: Scalars['JSON']['output'];
2781
+ /** Whether this is the canonical route for this context */
2782
+ isCanonical: Scalars['Boolean']['output'];
2783
+ /** The full URL path */
2784
+ path: Scalars['String']['output'];
2785
+ };
2749
2786
  /** Unified entity search result - works for any entity model */
2750
2787
  export type EntitySearchResult = {
2751
2788
  __typename?: 'EntitySearchResult';
@@ -3429,6 +3466,34 @@ export type GenerateShopifyInstallUrlInput = {
3429
3466
  redirectUri: Scalars['String']['input'];
3430
3467
  shopDomain: Scalars['String']['input'];
3431
3468
  };
3469
+ /** Input for batch route lookup */
3470
+ export type GetEntitiesRoutesInput = {
3471
+ /** Entity model key */
3472
+ modelKey: Scalars['String']['input'];
3473
+ /** Array of natural keys to look up */
3474
+ naturalKeys: Array<Scalars['String']['input']>;
3475
+ };
3476
+ /** Result of batch route lookup */
3477
+ export type GetEntitiesRoutesResult = {
3478
+ __typename?: 'GetEntitiesRoutesResult';
3479
+ /** Natural keys that were not found */
3480
+ notFound: Array<Scalars['String']['output']>;
3481
+ /** Results in same order as input naturalKeys */
3482
+ results: Array<EntityRouteInfo>;
3483
+ };
3484
+ /** Input for getting routes for a single entity */
3485
+ export type GetEntityRoutesInput = {
3486
+ /** Filter children routes to specific contexts */
3487
+ childContexts?: InputMaybe<Scalars['JSON']['input']>;
3488
+ /** Filter children to specific model key */
3489
+ childModelKey?: InputMaybe<Scalars['String']['input']>;
3490
+ /** Include child entity routes (e.g., products under a collection) */
3491
+ includeChildren?: InputMaybe<Scalars['Boolean']['input']>;
3492
+ /** Entity model key (e.g., 'shopify-product', 'page') */
3493
+ modelKey: Scalars['String']['input'];
3494
+ /** Entity natural key (e.g., product handle, page slug) */
3495
+ naturalKey: Scalars['String']['input'];
3496
+ };
3432
3497
  /** Unified global search results */
3433
3498
  export type GlobalSearchResult = {
3434
3499
  __typename?: 'GlobalSearchResult';
@@ -5686,6 +5751,18 @@ export type Query = {
5686
5751
  /** Get frontend URL for sitemap generation */
5687
5752
  frontendUrl?: Maybe<Scalars['String']['output']>;
5688
5753
  getApiKey?: Maybe<ApiKey>;
5754
+ /**
5755
+ * Get routes for multiple entities (batch).
5756
+ * No children - use getEntityRoutes for that.
5757
+ * Optimized for product cards, search results, recommendations.
5758
+ */
5759
+ getEntitiesRoutes: GetEntitiesRoutesResult;
5760
+ /**
5761
+ * Get routes for a single entity with optional children.
5762
+ * Use for collection pages, parent pages, etc.
5763
+ * Children are determined by route tree structure (parentRoute prefix matching).
5764
+ */
5765
+ getEntityRoutes?: Maybe<EntityRouteInfo>;
5689
5766
  /**
5690
5767
  * Global search across all entity records and media.
5691
5768
  *
@@ -5813,8 +5890,8 @@ export type Query = {
5813
5890
  recentlyOpened: Array<RecentlyOpenedItem>;
5814
5891
  /** Get a single redirect by ID */
5815
5892
  redirect?: Maybe<Redirect>;
5816
- /** List all redirects for the project */
5817
- redirects: Array<Redirect>;
5893
+ /** List all redirects for the project with pagination */
5894
+ redirects: RedirectsConnection;
5818
5895
  /**
5819
5896
  * Get all repeatable (cron) jobs across all queues.
5820
5897
  * Platform admin only.
@@ -5825,6 +5902,12 @@ export type Query = {
5825
5902
  * Uses headers for project context.
5826
5903
  */
5827
5904
  resolutionDistribution: ResolutionDistribution;
5905
+ /**
5906
+ * Batch resolve entity content by natural key.
5907
+ * Returns full resolved content with variant selection.
5908
+ * Use when you need content with templates, zones, layouts.
5909
+ */
5910
+ resolveEntities: ResolveEntitiesResult;
5828
5911
  /**
5829
5912
  * Resolve entity by model key and natural key (CMS-enriched).
5830
5913
  * Returns full content with templates, zones, layouts, breadcrumbs, gridConfig.
@@ -5896,6 +5979,8 @@ export type Query = {
5896
5979
  tenant?: Maybe<Tenant>;
5897
5980
  tenantBillingStatus: TenantBillingStatusResult;
5898
5981
  tenants: TenantList;
5982
+ /** List unified redirects (manual + route aliases) with pagination */
5983
+ unifiedRedirects: UnifiedRedirectsConnection;
5899
5984
  /**
5900
5985
  * Get unread notification count for badge.
5901
5986
  * Uses headers for user context.
@@ -6164,6 +6249,12 @@ export type QueryFilesArgs = {
6164
6249
  export type QueryGetApiKeyArgs = {
6165
6250
  id: Scalars['ID']['input'];
6166
6251
  };
6252
+ export type QueryGetEntitiesRoutesArgs = {
6253
+ input: GetEntitiesRoutesInput;
6254
+ };
6255
+ export type QueryGetEntityRoutesArgs = {
6256
+ input: GetEntityRoutesInput;
6257
+ };
6167
6258
  export type QueryGlobalSearchArgs = {
6168
6259
  includeMedia?: InputMaybe<Scalars['Boolean']['input']>;
6169
6260
  limit?: InputMaybe<Scalars['Int']['input']>;
@@ -6285,11 +6376,15 @@ export type QueryRedirectsArgs = {
6285
6376
  activeOnly?: InputMaybe<Scalars['Boolean']['input']>;
6286
6377
  limit?: InputMaybe<Scalars['Int']['input']>;
6287
6378
  offset?: InputMaybe<Scalars['Int']['input']>;
6379
+ search?: InputMaybe<Scalars['String']['input']>;
6288
6380
  };
6289
6381
  export type QueryResolutionDistributionArgs = {
6290
6382
  dateRange: DateRangeInput;
6291
6383
  dimension: ResolutionDimension;
6292
6384
  };
6385
+ export type QueryResolveEntitiesArgs = {
6386
+ input: ResolveEntitiesInput;
6387
+ };
6293
6388
  export type QueryResolveEntityArgs = {
6294
6389
  contexts?: InputMaybe<Scalars['JSON']['input']>;
6295
6390
  includeTemplate?: InputMaybe<Scalars['Boolean']['input']>;
@@ -6374,6 +6469,12 @@ export type QueryTenantsArgs = {
6374
6469
  offset?: InputMaybe<Scalars['Int']['input']>;
6375
6470
  search?: InputMaybe<Scalars['String']['input']>;
6376
6471
  };
6472
+ export type QueryUnifiedRedirectsArgs = {
6473
+ limit?: InputMaybe<Scalars['Int']['input']>;
6474
+ offset?: InputMaybe<Scalars['Int']['input']>;
6475
+ search?: InputMaybe<Scalars['String']['input']>;
6476
+ type?: InputMaybe<UnifiedRedirectType>;
6477
+ };
6377
6478
  export type QueryValidateInvitationArgs = {
6378
6479
  token: Scalars['String']['input'];
6379
6480
  };
@@ -6553,6 +6654,16 @@ export type Redirect = {
6553
6654
  targetPattern: Scalars['String']['output'];
6554
6655
  updatedAt: Scalars['DateTime']['output'];
6555
6656
  };
6657
+ /** Connection type for paginated redirects */
6658
+ export type RedirectsConnection = {
6659
+ __typename?: 'RedirectsConnection';
6660
+ /** Whether there are more items to fetch */
6661
+ hasMore: Scalars['Boolean']['output'];
6662
+ /** List of redirects */
6663
+ items: Array<Redirect>;
6664
+ /** Total count of redirects matching the filter */
6665
+ total: Scalars['Int']['output'];
6666
+ };
6556
6667
  /** Reference resolution options */
6557
6668
  export type ReferenceResolutionOptionsInput = {
6558
6669
  /** Maximum depth for nested resolution (null = unlimited with cycle detection) */
@@ -6680,6 +6791,31 @@ export type ResolutionEvent = {
6680
6791
  path: Scalars['String']['output'];
6681
6792
  timestamp: Scalars['String']['output'];
6682
6793
  };
6794
+ /** Input for batch entity content resolution */
6795
+ export type ResolveEntitiesInput = {
6796
+ /** Context dimensions for variant resolution */
6797
+ contexts?: InputMaybe<Scalars['JSON']['input']>;
6798
+ /** Include template/zone layout info */
6799
+ includeTemplate?: InputMaybe<Scalars['Boolean']['input']>;
6800
+ /** Locale for field translations */
6801
+ locale?: InputMaybe<Scalars['String']['input']>;
6802
+ /** Entity model key */
6803
+ modelKey: Scalars['String']['input'];
6804
+ /** Array of natural keys to resolve */
6805
+ naturalKeys: Array<Scalars['String']['input']>;
6806
+ /** Reference resolution options */
6807
+ referenceOptions?: InputMaybe<ReferenceResolutionOptionsInput>;
6808
+ };
6809
+ /** Result of batch entity resolution */
6810
+ export type ResolveEntitiesResult = {
6811
+ __typename?: 'ResolveEntitiesResult';
6812
+ /** Natural keys that were not found */
6813
+ notFound: Array<Scalars['String']['output']>;
6814
+ /** Resolution context used */
6815
+ resolvedWith: ResolutionContextOutput;
6816
+ /** Results in same order as input naturalKeys */
6817
+ results: Array<ResolvedEntityBatchResult>;
6818
+ };
6683
6819
  export type ResolveNoteInput = {
6684
6820
  noteId: Scalars['ID']['input'];
6685
6821
  resolutionNote?: InputMaybe<Scalars['String']['input']>;
@@ -6703,6 +6839,16 @@ export type ResolvedContent = {
6703
6839
  /** Template reference (null if no template assigned) */
6704
6840
  template?: Maybe<ResolvedTemplateRef>;
6705
6841
  };
6842
+ /** Single entity resolution result in batch */
6843
+ export type ResolvedEntityBatchResult = {
6844
+ __typename?: 'ResolvedEntityBatchResult';
6845
+ /** Whether the entity was found and resolved */
6846
+ found: Scalars['Boolean']['output'];
6847
+ /** The natural key that was requested */
6848
+ naturalKey: Scalars['String']['output'];
6849
+ /** Full resolution result (same structure as resolveEntity) */
6850
+ resolution?: Maybe<ResolvedEntityContent>;
6851
+ };
6706
6852
  /**
6707
6853
  * Resolved entity content (unified output format)
6708
6854
  * Works for ANY entity type - now uses the same structure as public resolveRoute
@@ -7678,6 +7824,55 @@ export type TypographyVariantInput = {
7678
7824
  name: Scalars['String']['input'];
7679
7825
  textTransform?: InputMaybe<Scalars['String']['input']>;
7680
7826
  };
7827
+ /** Unified redirect record combining manual redirects and route aliases */
7828
+ export type UnifiedRedirect = {
7829
+ __typename?: 'UnifiedRedirect';
7830
+ /** Entity type (route alias only) */
7831
+ entityType?: Maybe<Scalars['String']['output']>;
7832
+ /** Number of times this redirect has been used (manual only) */
7833
+ hitCount?: Maybe<Scalars['Int']['output']>;
7834
+ /** Unique identifier */
7835
+ id: Scalars['ID']['output'];
7836
+ /** Last time this redirect was matched (manual only) */
7837
+ lastHitAt?: Maybe<Scalars['DateTime']['output']>;
7838
+ /** Priority for matching (manual only) */
7839
+ priority?: Maybe<Scalars['Int']['output']>;
7840
+ /** Optional reason/note (manual only) */
7841
+ reason?: Maybe<Scalars['String']['output']>;
7842
+ /** Source URL pattern */
7843
+ source: Scalars['String']['output'];
7844
+ /** HTTP status code */
7845
+ statusCode: Scalars['Int']['output'];
7846
+ /** Target URL pattern */
7847
+ target: Scalars['String']['output'];
7848
+ /** Type of redirect */
7849
+ type: UnifiedRedirectType;
7850
+ };
7851
+ /** Counts of redirects by type */
7852
+ export type UnifiedRedirectCounts = {
7853
+ __typename?: 'UnifiedRedirectCounts';
7854
+ /** Number of manual redirects */
7855
+ manual: Scalars['Int']['output'];
7856
+ /** Number of route aliases */
7857
+ routeAlias: Scalars['Int']['output'];
7858
+ };
7859
+ /** Type of redirect */
7860
+ export declare enum UnifiedRedirectType {
7861
+ Manual = "MANUAL",
7862
+ RouteAlias = "ROUTE_ALIAS"
7863
+ }
7864
+ /** Connection type for unified redirects with pagination */
7865
+ export type UnifiedRedirectsConnection = {
7866
+ __typename?: 'UnifiedRedirectsConnection';
7867
+ /** Counts by type */
7868
+ counts: UnifiedRedirectCounts;
7869
+ /** Whether there are more items */
7870
+ hasMore: Scalars['Boolean']['output'];
7871
+ /** List of unified redirects */
7872
+ items: Array<UnifiedRedirect>;
7873
+ /** Total count matching the filter */
7874
+ total: Scalars['Int']['output'];
7875
+ };
7681
7876
  /** Input for unpublishing an entity record variant */
7682
7877
  export type UnpublishEntityRecordVariantInput = {
7683
7878
  variantId: Scalars['ID']['input'];