@pvh-afl/core 1.1.19 → 1.1.20

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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Injects the authenticated customer resolved by {@link CustomerAuthGuard}
3
+ * (`req.customer`), or `undefined` when the request is unauthenticated and
4
+ * enforcement is disabled. Works in both GraphQL resolvers and REST controllers.
5
+ */
6
+ export declare const CurrentCustomer: (...dataOrPipes: unknown[]) => ParameterDecorator;
7
+ //# sourceMappingURL=current-customer.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-customer.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/current-customer.decorator.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,eAAe,mDAU3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CurrentCustomer = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const graphql_1 = require("@nestjs/graphql");
6
+ /**
7
+ * Injects the authenticated customer resolved by {@link CustomerAuthGuard}
8
+ * (`req.customer`), or `undefined` when the request is unauthenticated and
9
+ * enforcement is disabled. Works in both GraphQL resolvers and REST controllers.
10
+ */
11
+ exports.CurrentCustomer = (0, common_1.createParamDecorator)((_data, context) => {
12
+ let req;
13
+ if (context.getType() === 'graphql') {
14
+ req = graphql_1.GqlExecutionContext.create(context).getContext()?.req;
15
+ }
16
+ else if (context.getType() === 'http') {
17
+ req = context.switchToHttp().getRequest();
18
+ }
19
+ return req?.customer;
20
+ });
21
+ //# sourceMappingURL=current-customer.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-customer.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/current-customer.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,6CAAsE;AAGtE;;;;GAIG;AACU,QAAA,eAAe,GAAG,IAAA,6BAAoB,EACjD,CAAC,KAAc,EAAE,OAAyB,EAAqC,EAAE;IAC/E,IAAI,GAAqD,CAAC;IAC1D,IAAI,OAAO,CAAC,OAAO,EAAkB,KAAK,SAAS,EAAE,CAAC;QACpD,GAAG,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC;IAC9D,CAAC;SAAM,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QACxC,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,EAAE,QAAQ,CAAC;AACvB,CAAC,CACF,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Metadata key marking a resolver/route as requiring an authenticated customer.
3
+ */
4
+ export declare const REQUIRE_CUSTOMER_KEY = "require_customer";
5
+ /**
6
+ * Metadata key marking a resolver/route as customer-aware but not customer-gated:
7
+ * the guard attaches `req.customer` when a valid token is present, but never blocks
8
+ * the request when it is absent (used for endpoints that also serve anonymous/guest
9
+ * traffic, e.g. wishlist by guest session).
10
+ */
11
+ export declare const OPTIONAL_CUSTOMER_KEY = "optional_customer";
12
+ /**
13
+ * Marks a GraphQL resolver or REST route as customer-scoped. The globally
14
+ * registered {@link CustomerAuthGuard} validates the Shopify customerAccessToken
15
+ * and attaches `req.customer` for handlers carrying this marker; handlers without it
16
+ * (public catalog, webhooks, health) are passed through untouched.
17
+ */
18
+ export declare const RequireCustomer: () => import("@nestjs/common").CustomDecorator<string>;
19
+ /**
20
+ * Marks a route as customer-aware but still reachable anonymously. The guard
21
+ * attaches `req.customer` when a valid token is supplied and otherwise lets the
22
+ * request through, leaving the handler to decide how to treat unauthenticated calls.
23
+ */
24
+ export declare const OptionalCustomer: () => import("@nestjs/common").CustomDecorator<string>;
25
+ //# sourceMappingURL=require-customer.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-customer.decorator.d.ts","sourceRoot":"","sources":["../../../src/common/decorators/require-customer.decorator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,wDAAgD,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,wDAAiD,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptionalCustomer = exports.RequireCustomer = exports.OPTIONAL_CUSTOMER_KEY = exports.REQUIRE_CUSTOMER_KEY = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * Metadata key marking a resolver/route as requiring an authenticated customer.
7
+ */
8
+ exports.REQUIRE_CUSTOMER_KEY = 'require_customer';
9
+ /**
10
+ * Metadata key marking a resolver/route as customer-aware but not customer-gated:
11
+ * the guard attaches `req.customer` when a valid token is present, but never blocks
12
+ * the request when it is absent (used for endpoints that also serve anonymous/guest
13
+ * traffic, e.g. wishlist by guest session).
14
+ */
15
+ exports.OPTIONAL_CUSTOMER_KEY = 'optional_customer';
16
+ /**
17
+ * Marks a GraphQL resolver or REST route as customer-scoped. The globally
18
+ * registered {@link CustomerAuthGuard} validates the Shopify customerAccessToken
19
+ * and attaches `req.customer` for handlers carrying this marker; handlers without it
20
+ * (public catalog, webhooks, health) are passed through untouched.
21
+ */
22
+ const RequireCustomer = () => (0, common_1.SetMetadata)(exports.REQUIRE_CUSTOMER_KEY, true);
23
+ exports.RequireCustomer = RequireCustomer;
24
+ /**
25
+ * Marks a route as customer-aware but still reachable anonymously. The guard
26
+ * attaches `req.customer` when a valid token is supplied and otherwise lets the
27
+ * request through, leaving the handler to decide how to treat unauthenticated calls.
28
+ */
29
+ const OptionalCustomer = () => (0, common_1.SetMetadata)(exports.OPTIONAL_CUSTOMER_KEY, true);
30
+ exports.OptionalCustomer = OptionalCustomer;
31
+ //# sourceMappingURL=require-customer.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-customer.decorator.js","sourceRoot":"","sources":["../../../src/common/decorators/require-customer.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C;;GAEG;AACU,QAAA,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAEzD;;;;;GAKG;AACI,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,4BAAoB,EAAE,IAAI,CAAC,CAAC;AAAhE,QAAA,eAAe,mBAAiD;AAE7E;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,6BAAqB,EAAE,IAAI,CAAC,CAAC;AAAlE,QAAA,gBAAgB,oBAAkD"}
@@ -0,0 +1,54 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ import { ConfigService } from '../../config/config.service';
4
+ import { IntegrationFactory } from '../../integrations/integration.factory';
5
+ /**
6
+ * Whether customer authentication is enforced for a brand. Enforcement is on when
7
+ * `CUSTOMER_AUTH_ENFORCE=true` (global) or the brand sets
8
+ * `features.customerAuthEnforce`. Shared so guards and brand controllers agree.
9
+ */
10
+ export declare function isCustomerAuthEnforced(configService: ConfigService, brand?: string): boolean;
11
+ /**
12
+ * The authenticated customer resolved from a validated Shopify Storefront
13
+ * customerAccessToken. Attached to the request as `req.customer` by
14
+ * {@link CustomerAuthGuard} and read via the `@CurrentCustomer()` decorator.
15
+ */
16
+ export interface AuthenticatedCustomer {
17
+ id: string;
18
+ phone: string | null;
19
+ email: string | null;
20
+ name: string | null;
21
+ }
22
+ /**
23
+ * CustomerAuthGuard
24
+ *
25
+ * Authenticates the caller by validating a Shopify Storefront customerAccessToken
26
+ * (the same mechanism the customer API already uses via `getCustomer`). On success
27
+ * it attaches `req.customer = { id, phone, email }` so resolvers/controllers derive
28
+ * identity from the verified token instead of trusting a client-supplied
29
+ * `mobile`/`orderId`/`customerId` argument.
30
+ *
31
+ * Token sources (in order): `Authorization: Bearer <token>`, then the
32
+ * `X-Shopify-Customer-Access-Token` header.
33
+ *
34
+ * Registered once as a global `APP_GUARD`. It only acts on handlers marked with
35
+ * `@RequireCustomer()`; everything else (public catalog, webhooks, health) passes
36
+ * through untouched.
37
+ *
38
+ * Enforcement is per-brand (migration-friendly): when a brand sets
39
+ * `features.customerAuthEnforce` (or env `CUSTOMER_AUTH_ENFORCE=true`), a missing or
40
+ * invalid token is rejected with 401. Otherwise the guard attaches identity when a
41
+ * valid token is present but does NOT block unauthenticated calls — it only logs a
42
+ * warning — so brands that have not migrated their clients keep working. Resolvers
43
+ * fall back to their legacy identifier argument only while enforcement is off.
44
+ */
45
+ export declare class CustomerAuthGuard implements CanActivate {
46
+ private readonly reflector;
47
+ private readonly configService;
48
+ private readonly integrationFactory;
49
+ constructor(reflector: Reflector, configService: ConfigService, integrationFactory: IntegrationFactory);
50
+ canActivate(context: ExecutionContext): Promise<boolean>;
51
+ private extractToken;
52
+ private getRequest;
53
+ }
54
+ //# sourceMappingURL=customer-auth.guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-auth.guard.d.ts","sourceRoot":"","sources":["../../../src/common/guards/customer-auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAQ5E;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAQ5F;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAQD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,iBAAkB,YAAW,WAAW;IAEjD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAFlB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB;IAGnD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA8D9D,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,UAAU;CASnB"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerAuthGuard = void 0;
4
+ exports.isCustomerAuthEnforced = isCustomerAuthEnforced;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const core_1 = require("@nestjs/core");
8
+ const graphql_1 = require("@nestjs/graphql");
9
+ const config_service_1 = require("../../config/config.service");
10
+ const integration_factory_1 = require("../../integrations/integration.factory");
11
+ const require_customer_decorator_1 = require("../decorators/require-customer.decorator");
12
+ const logger_1 = require("../logger");
13
+ /**
14
+ * Whether customer authentication is enforced for a brand. Enforcement is on when
15
+ * `CUSTOMER_AUTH_ENFORCE=true` (global) or the brand sets
16
+ * `features.customerAuthEnforce`. Shared so guards and brand controllers agree.
17
+ */
18
+ function isCustomerAuthEnforced(configService, brand) {
19
+ if (process.env.CUSTOMER_AUTH_ENFORCE === 'true') {
20
+ return true;
21
+ }
22
+ if (!brand) {
23
+ return false;
24
+ }
25
+ return configService.getBrand(brand)?.features?.customerAuthEnforce === true;
26
+ }
27
+ /**
28
+ * CustomerAuthGuard
29
+ *
30
+ * Authenticates the caller by validating a Shopify Storefront customerAccessToken
31
+ * (the same mechanism the customer API already uses via `getCustomer`). On success
32
+ * it attaches `req.customer = { id, phone, email }` so resolvers/controllers derive
33
+ * identity from the verified token instead of trusting a client-supplied
34
+ * `mobile`/`orderId`/`customerId` argument.
35
+ *
36
+ * Token sources (in order): `Authorization: Bearer <token>`, then the
37
+ * `X-Shopify-Customer-Access-Token` header.
38
+ *
39
+ * Registered once as a global `APP_GUARD`. It only acts on handlers marked with
40
+ * `@RequireCustomer()`; everything else (public catalog, webhooks, health) passes
41
+ * through untouched.
42
+ *
43
+ * Enforcement is per-brand (migration-friendly): when a brand sets
44
+ * `features.customerAuthEnforce` (or env `CUSTOMER_AUTH_ENFORCE=true`), a missing or
45
+ * invalid token is rejected with 401. Otherwise the guard attaches identity when a
46
+ * valid token is present but does NOT block unauthenticated calls — it only logs a
47
+ * warning — so brands that have not migrated their clients keep working. Resolvers
48
+ * fall back to their legacy identifier argument only while enforcement is off.
49
+ */
50
+ let CustomerAuthGuard = class CustomerAuthGuard {
51
+ reflector;
52
+ configService;
53
+ integrationFactory;
54
+ constructor(reflector, configService, integrationFactory) {
55
+ this.reflector = reflector;
56
+ this.configService = configService;
57
+ this.integrationFactory = integrationFactory;
58
+ }
59
+ async canActivate(context) {
60
+ const required = this.reflector.getAllAndOverride(require_customer_decorator_1.REQUIRE_CUSTOMER_KEY, [
61
+ context.getHandler(),
62
+ context.getClass(),
63
+ ]);
64
+ const optional = this.reflector.getAllAndOverride(require_customer_decorator_1.OPTIONAL_CUSTOMER_KEY, [
65
+ context.getHandler(),
66
+ context.getClass(),
67
+ ]);
68
+ if (!required && !optional) {
69
+ // Endpoint is not customer-scoped (public catalog, webhooks, health).
70
+ return true;
71
+ }
72
+ const req = this.getRequest(context);
73
+ if (!req) {
74
+ // Non HTTP/GraphQL execution context — nothing to authenticate.
75
+ return true;
76
+ }
77
+ const brand = req.brand ?? this.configService.getActiveBrand() ?? undefined;
78
+ const enforced = isCustomerAuthEnforced(this.configService, brand);
79
+ const token = this.extractToken(req);
80
+ if (token && brand) {
81
+ const commerce = this.integrationFactory.get(brand, 'commerce');
82
+ const result = commerce ? await commerce.getCustomer(token) : null;
83
+ if (result?.success && result.data) {
84
+ req.customer = {
85
+ id: result.data.id,
86
+ phone: result.data.phone,
87
+ email: result.data.email,
88
+ name: result.data.displayName ?? null,
89
+ };
90
+ return true;
91
+ }
92
+ // A token was supplied but did not validate. Optional endpoints treat this as
93
+ // an anonymous request; required endpoints reject when enforcing.
94
+ if (required && enforced) {
95
+ throw new common_1.UnauthorizedException('Invalid or expired customer token');
96
+ }
97
+ logger_1.logger.warn('Customer token present but invalid; treating as unauthenticated', { brand });
98
+ return true;
99
+ }
100
+ // No usable token.
101
+ if (required && enforced) {
102
+ throw new common_1.UnauthorizedException('Customer authentication required');
103
+ }
104
+ if (required) {
105
+ logger_1.logger.warn('Customer-scoped endpoint accessed without authentication (enforcement disabled)', { brand });
106
+ }
107
+ return true;
108
+ }
109
+ extractToken(req) {
110
+ const headers = req.headers ?? {};
111
+ const authHeader = headers['authorization'];
112
+ const auth = Array.isArray(authHeader) ? authHeader[0] : authHeader;
113
+ if (auth && auth.startsWith('Bearer ')) {
114
+ const token = auth.slice(7).trim();
115
+ if (token)
116
+ return token;
117
+ }
118
+ const custHeader = headers['x-shopify-customer-access-token'];
119
+ const cust = Array.isArray(custHeader) ? custHeader[0] : custHeader;
120
+ if (cust && cust.trim()) {
121
+ return cust.trim();
122
+ }
123
+ return null;
124
+ }
125
+ getRequest(context) {
126
+ if (context.getType() === 'graphql') {
127
+ return graphql_1.GqlExecutionContext.create(context).getContext()?.req ?? null;
128
+ }
129
+ if (context.getType() === 'http') {
130
+ return context.switchToHttp().getRequest();
131
+ }
132
+ return null;
133
+ }
134
+ };
135
+ exports.CustomerAuthGuard = CustomerAuthGuard;
136
+ exports.CustomerAuthGuard = CustomerAuthGuard = tslib_1.__decorate([
137
+ (0, common_1.Injectable)(),
138
+ tslib_1.__metadata("design:paramtypes", [core_1.Reflector,
139
+ config_service_1.ConfigService,
140
+ integration_factory_1.IntegrationFactory])
141
+ ], CustomerAuthGuard);
142
+ //# sourceMappingURL=customer-auth.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-auth.guard.js","sourceRoot":"","sources":["../../../src/common/guards/customer-auth.guard.ts"],"names":[],"mappings":";;;AAsBA,wDAQC;;AA9BD,2CAKwB;AACxB,uCAAyC;AACzC,6CAAsE;AACtE,gEAA4D;AAC5D,gFAA4E;AAE5E,yFAGkD;AAClD,sCAAmC;AAEnC;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,aAA4B,EAAE,KAAc;IACjF,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAC/E,CAAC;AAoBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAET;IACA;IACA;IAHnB,YACmB,SAAoB,EACpB,aAA4B,EAC5B,kBAAsC;QAFtC,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAe;QAC5B,uBAAkB,GAAlB,kBAAkB,CAAoB;IACtD,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,iDAAoB,EAAE;YAC/E,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;Q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AAC;QACpE,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,UAAU,CAAC,OAAyB;QAC1C,IAAI,OAAO,CAAC,OAAO,EAAkB,KAAK,SAAS,EAAE,CAAC;YACpD,OAAO,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,GAAG,IAAI,IAAI,CAAC;QACvE,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;YACjC,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAhGY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;6CAGmB,gBAAS;QACL,8BAAa;QACR,wCAAkB;GAJ9C,iBAAiB,CAgG7B"}
@@ -1,7 +1,7 @@
1
- import { CacheService } from '../cache/cache.service';
2
- import { ConfigService } from '../config/config.service';
3
- import { ShopifyThemeService } from '../integrations/shopify-theme';
4
- import { IThemeCollectionService, IThemeProductService } from './theme-content.interfaces';
1
+ import { CacheService } from "../cache/cache.service";
2
+ import { ConfigService } from "../config/config.service";
3
+ import { ShopifyThemeService } from "../integrations/shopify-theme";
4
+ import { IThemeCollectionService, IThemeProductService } from "./theme-content.interfaces";
5
5
  interface CuratedBlock {
6
6
  type: string;
7
7
  settings?: Record<string, unknown>;
@@ -85,6 +85,7 @@ export declare class ThemeContentService {
85
85
  private readonly shopifyThemeService;
86
86
  private readonly collectionService?;
87
87
  private readonly productService?;
88
+ private static readonly MEDIA_QUERY_BATCH_SIZE;
88
89
  private refreshInProgress;
89
90
  constructor(cacheService: CacheService, configService: ConfigService, shopifyThemeService: ShopifyThemeService, collectionService?: IThemeCollectionService | undefined, productService?: IThemeProductService | undefined);
90
91
  /**
@@ -191,6 +192,12 @@ export declare class ThemeContentService {
191
192
  private fetchMediaUrls;
192
193
  private resolveShopImages;
193
194
  private resolveFilesApiMedia;
195
+ /**
196
+ * Build a Shopify Files search query that matches any of the given filenames
197
+ * for a media type, e.g.
198
+ * media_type:IMAGE status:READY (filename:'a.png' OR filename:'b.jpg')
199
+ */
200
+ private buildFilenameSearchQuery;
194
201
  private readonly mediaFieldNames;
195
202
  private isMediaUrl;
196
203
  private replaceMediaReferences;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-content.service.d.ts","sourceRoot":"","sources":["../../src/theme/theme-content.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EAIrB,MAAM,4BAA4B,CAAC;AAqBpC,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,C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