@swell/apps-sdk 1.0.141 → 1.0.143
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/LICENSE +22 -0
- package/README.md +304 -0
- package/dist/index.cjs +254 -62
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +252 -62
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +253 -62
- package/dist/index.mjs.map +4 -4
- package/dist/src/compatibility/shopify-objects/collection.d.ts +1 -1
- package/dist/src/resources/product.d.ts +13 -0
- package/dist/src/theme.d.ts +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/logger.d.ts +21 -0
- package/dist/types/shopify.d.ts +3 -3
- package/dist/types/swell.d.ts +2 -0
- package/package.json +1 -1
|
@@ -4,4 +4,4 @@ import type { ShopifyCompatibility } from '../shopify';
|
|
|
4
4
|
import type { SwellCollection, SwellData, SwellRecord } from 'types/swell';
|
|
5
5
|
import type { ShopifyCollection } from 'types/shopify';
|
|
6
6
|
export default function ShopifyCollection(instance: ShopifyCompatibility, category: StorefrontResource | SwellRecord): ShopifyResource<ShopifyCollection>;
|
|
7
|
-
export declare function makeProductsCollectionResolve<T extends SwellData>(object: StorefrontResource | SwellRecord, mapper: (product: SwellData) => T): () => Promise<SwellCollection<T> | null | undefined>;
|
|
7
|
+
export declare function makeProductsCollectionResolve<T extends SwellData>(instance: ShopifyCompatibility, object: StorefrontResource | SwellRecord, mapper: (product: SwellData) => T): () => Promise<SwellCollection<T> | null | undefined>;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import type { Swell } from '@/api';
|
|
2
2
|
import { SwellStorefrontRecord } from '@/resources';
|
|
3
3
|
import type { StorefrontResourceGetter, SwellData, SwellRecord } from 'types/swell';
|
|
4
|
+
export declare const SORT_OPTIONS: ({
|
|
5
|
+
value: string;
|
|
6
|
+
name: string;
|
|
7
|
+
query?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
value: string;
|
|
10
|
+
name: string;
|
|
11
|
+
query: string;
|
|
12
|
+
})[];
|
|
4
13
|
export declare class SwellProduct<T extends SwellData = SwellRecord> extends SwellStorefrontRecord<T> {
|
|
5
14
|
_params: SwellData;
|
|
6
15
|
constructor(swell: Swell, id: string, query?: SwellData, getter?: StorefrontResourceGetter<T>);
|
|
7
16
|
_transformResult(result?: T | null): T | null | undefined;
|
|
8
17
|
}
|
|
18
|
+
export declare function productQueryWithFilters(swell: Swell, query?: SwellData): {
|
|
19
|
+
sort: string | undefined;
|
|
20
|
+
$filters: any;
|
|
21
|
+
};
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare class SwellTheme {
|
|
|
42
42
|
settings: ThemeSettings;
|
|
43
43
|
request: SwellPageRequest;
|
|
44
44
|
page: ThemePage;
|
|
45
|
-
cart: SwellStorefrontSingleton
|
|
45
|
+
cart: SwellStorefrontSingleton;
|
|
46
46
|
account: SwellStorefrontSingleton | null;
|
|
47
47
|
customer?: SwellStorefrontSingleton | null;
|
|
48
48
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CURRENCY_COUNTRIES } from '../constants';
|
|
2
2
|
import type { SwellData, SwellLocale, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema, ThemeSettings } from 'types/swell';
|
|
3
3
|
export * from './md5';
|
|
4
|
+
export { configureSdkLogger, type SdkLoggerConfig } from './logger';
|
|
4
5
|
export declare function getAllSections(themeConfigs: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<ThemeSectionSchema | undefined>): Promise<ThemePageSectionSchema[]>;
|
|
5
6
|
export declare function getLayoutSectionGroups(allSections: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeLayoutSectionGroupConfig[]>;
|
|
6
7
|
export declare function getPageSections(sectionGroup: ThemeSectionGroup, getSchema: (type: string) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeSectionConfig[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const logLevels: {
|
|
2
|
+
readonly error: 0;
|
|
3
|
+
readonly warn: 1;
|
|
4
|
+
readonly info: 2;
|
|
5
|
+
readonly debug: 3;
|
|
6
|
+
};
|
|
7
|
+
export type LogLevel = keyof typeof logLevels;
|
|
8
|
+
export type TimestampFormat = 'off' | 'iso' | 'unix';
|
|
9
|
+
export interface SdkLoggerConfig {
|
|
10
|
+
level?: LogLevel;
|
|
11
|
+
timestamp?: TimestampFormat;
|
|
12
|
+
structured?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function configureSdkLogger(config?: SdkLoggerConfig): void;
|
|
15
|
+
export declare const logger: {
|
|
16
|
+
error: (...args: any[]) => void;
|
|
17
|
+
warn: (...args: any[]) => void;
|
|
18
|
+
info: (...args: any[]) => void;
|
|
19
|
+
debug: (...args: any[]) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function createTraceId(data?: string): string;
|
package/dist/types/shopify.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SwellData, ThemeSectionEnabledDisabled } from './swell';
|
|
1
|
+
import type { SwellData, SwellCollection, ThemeSectionEnabledDisabled } from './swell';
|
|
2
2
|
import type { ShopifyResource } from '../src/compatibility/shopify-objects/resource';
|
|
3
3
|
import type { ShopifyCompatibility } from '../src/compatibility/shopify';
|
|
4
|
-
import type { StorefrontResource } from '../src/resources';
|
|
4
|
+
import type { StorefrontResource, SwellStorefrontCollection } from '../src/resources';
|
|
5
5
|
export type ShopifyBasicInputType = 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'number' | 'range';
|
|
6
6
|
export type ShopifySpecializedInputType = 'article' | 'blog' | 'collection' | 'collection_list' | 'color' | 'color_background' | 'color_scheme' | 'color_scheme_group' | 'font_picker' | 'header' | 'paragraph' | 'html' | 'image_picker' | 'inline_richtext' | 'link_list' | 'liquid' | 'page' | 'product' | 'product_list' | 'richtext' | 'text_alignment' | 'url' | 'video' | 'video_url';
|
|
7
7
|
export interface ShopifyBgStyleSchema {
|
|
@@ -446,7 +446,7 @@ export interface ShopifyCollection {
|
|
|
446
446
|
metafields: Record<string, unknown>;
|
|
447
447
|
next_product?: ShopifyProduct;
|
|
448
448
|
previous_product?: ShopifyProduct;
|
|
449
|
-
products: ShopifyProduct
|
|
449
|
+
products: SwellStorefrontCollection<SwellCollection<ShopifyResource<ShopifyProduct>>>;
|
|
450
450
|
products_count: number;
|
|
451
451
|
published_at: string;
|
|
452
452
|
sort_by?: string;
|
package/dist/types/swell.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { FormatInput } from 'swell-js';
|
|
|
2
2
|
import type { SwellStorefrontRecord, SwellStorefrontResource, SwellStorefrontSingleton } from '../src/resources';
|
|
3
3
|
import type { Swell, SwellStorefrontCollection, StorefrontResource } from '../src/api';
|
|
4
4
|
import type { ShopifySettingRoleSchema, ShopifySettingsData, ShopifySettingsSchema } from './shopify';
|
|
5
|
+
import type { SdkLoggerConfig } from '../src/utils/logger';
|
|
5
6
|
export interface SwellApiParams {
|
|
6
7
|
url: URL | string;
|
|
7
8
|
config?: SwellAppConfig;
|
|
@@ -13,6 +14,7 @@ export interface SwellApiParams {
|
|
|
13
14
|
workerEnv?: CFThemeEnv;
|
|
14
15
|
workerCtx?: CFWorkerContext;
|
|
15
16
|
isEditor?: boolean;
|
|
17
|
+
logger?: SdkLoggerConfig;
|
|
16
18
|
getCookie?: (name: string) => string | undefined;
|
|
17
19
|
setCookie?: (name: string, value: string, options: object | undefined, swell: Swell) => void;
|
|
18
20
|
resourceLoadingIndicator?: (isLoading: boolean) => void;
|