@swell/apps-sdk 1.0.144 → 1.0.146

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/src/api.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import SwellJS from 'swell-js';
2
2
  import qs from 'qs';
3
- import type { SwellApiParams, SwellAppConfig, SwellErrorOptions, SwellMenu, SwellData, CFThemeEnv, CFWorkerContext, SwellAppShopifyCompatibilityConfig } from '../types/swell';
3
+ import type { SwellApiParams, SwellAppConfig, SwellErrorOptions, SwellMenu, SwellData, SwellAppShopifyCompatibilityConfig } from '../types/swell';
4
+ import type { CFThemeEnv, CFWorkerContext } from '../types/cloudflare';
4
5
  export * from './resources';
5
6
  export * from './resources/index';
6
7
  export declare class Swell {
@@ -1,5 +1,5 @@
1
1
  import { type CreateCacheOptions as OriginalCreateCacheOptions } from 'cache-manager';
2
- import type { CFWorkerKV, CFWorkerContext } from 'types/swell';
2
+ import type { CFWorkerKV, CFWorkerContext } from 'types/cloudflare';
3
3
  export type CreateCacheOptions = OriginalCreateCacheOptions & {
4
4
  kvStore?: CFWorkerKV;
5
5
  workerCtx?: CFWorkerContext;
@@ -1,5 +1,5 @@
1
1
  import type { KeyvStoreAdapter } from 'keyv';
2
- import type { CFWorkerKV } from 'types/swell';
2
+ import type { CFWorkerKV } from 'types/cloudflare';
3
3
  /**
4
4
  * CloudFlare Workers KV adapter for Keyv.
5
5
  * Includes namespacing to prevent conflicts within shared storage.
@@ -1,5 +1,8 @@
1
1
  import type { SwellData } from 'types/swell';
2
2
  import type { SwellProduct, SwellProductOption, SwellProductOptionValue, SwellProductPurchaseOptions, SwellVariant } from './swell_types';
3
+ export declare function isGiftcard(product: SwellProduct): boolean;
4
+ export declare function isOptionAvailable(product: SwellProduct, option: SwellProductOption): boolean;
5
+ export declare function isProductAvailable(product: SwellProduct, variant?: SwellVariant): boolean;
3
6
  export declare function getAvailableVariants(product: SwellProduct): SwellVariant[];
4
7
  export declare function isOptionValueAvailable(option: SwellProductOption, value: SwellProductOptionValue, product: SwellProduct, availableVariants?: SwellVariant[]): boolean;
5
8
  export declare function isOptionValueSelected(option: SwellProductOption, value: SwellProductOptionValue, product: SwellProduct, queryParams: SwellData, selectedVariant?: SwellVariant): boolean;
@@ -62,9 +62,12 @@ export interface SwellProductPurchaseOptions {
62
62
  export interface SwellProduct {
63
63
  id: string;
64
64
  price: number;
65
+ type: string;
65
66
  options?: SwellProductOption[];
66
67
  selected_option_values?: string[];
67
68
  purchase_options?: SwellProductPurchaseOptions;
69
+ stock_purchasable?: boolean;
70
+ stock_status?: string;
68
71
  variants: {
69
72
  results: SwellVariant[];
70
73
  };
@@ -0,0 +1,50 @@
1
+ export interface CFWorkerContext {
2
+ waitUntil(promise: Promise<unknown>): void;
3
+ passThroughOnException(): void;
4
+ }
5
+ export interface CFThemeEnv {
6
+ THEME?: CFWorkerKV;
7
+ }
8
+ export type CFWorkerKVGetType = 'text' | 'json' | 'arrayBuffer' | 'stream';
9
+ export interface CFWorkerKVGetOptions<T extends CFWorkerKVGetType> {
10
+ cacheTtl: number;
11
+ type: T;
12
+ }
13
+ export interface CFWorkerKVGetMetadataResponse<T> {
14
+ value: T | null;
15
+ metadata: string | null;
16
+ }
17
+ export interface CFWorkerKVPutOptions {
18
+ expiration?: number;
19
+ expirationTtl?: number;
20
+ metadata?: object;
21
+ }
22
+ export interface CFWorkerKVListOptions {
23
+ prefix?: string;
24
+ limit?: string;
25
+ cursor?: string;
26
+ }
27
+ export interface CFWorkerKVKeyInfo {
28
+ name: string;
29
+ expiration?: number;
30
+ metadata?: object;
31
+ }
32
+ export interface CFWorkerKVListResponse {
33
+ keys: CFWorkerKVKeyInfo[];
34
+ list_complete: boolean;
35
+ cursor: string;
36
+ }
37
+ export interface CFWorkerKV {
38
+ get(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<string | null>;
39
+ get(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<ArrayBuffer | null>;
40
+ get(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<ReadableStream<Uint8Array> | null>;
41
+ get<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<T | null>;
42
+ getWithMetadata(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<CFWorkerKVGetMetadataResponse<string>>;
43
+ getWithMetadata(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<CFWorkerKVGetMetadataResponse<ArrayBuffer>>;
44
+ getWithMetadata(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<CFWorkerKVGetMetadataResponse<ReadableStream<Uint8Array>>>;
45
+ getWithMetadata<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<CFWorkerKVGetMetadataResponse<T>>;
46
+ put(key: string, value: string | ReadableStream | ArrayBuffer, options?: CFWorkerKVPutOptions): Promise<void>;
47
+ delete(key: string): Promise<void>;
48
+ list(options?: CFWorkerKVListOptions): Promise<CFWorkerKVListResponse>;
49
+ }
50
+ export type CFCache = Cache;
@@ -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 { CFThemeEnv, CFWorkerContext } from './cloudflare';
5
6
  import type { SdkLoggerConfig } from '../src/utils/logger';
6
7
  export interface SwellApiParams {
7
8
  url: URL | string;
@@ -535,53 +536,4 @@ export interface ThemeFormErrorMessage {
535
536
  field_label?: string;
536
537
  }
537
538
  export type ThemeFormErrorMessages = Array<ThemeFormErrorMessage>;
538
- export type CFWorkerKVGetType = 'text' | 'json' | 'arrayBuffer' | 'stream';
539
- export interface CFWorkerKVGetOptions<T extends CFWorkerKVGetType> {
540
- cacheTtl: number;
541
- type: T;
542
- }
543
- export interface CFWorkerKVGetMetadataResponse<T> {
544
- value: T | null;
545
- metadata: string | null;
546
- }
547
- export interface CFWorkerKVPutOptions {
548
- expiration?: number;
549
- expirationTtl?: number;
550
- metadata?: object;
551
- }
552
- export interface CFWorkerKVListOptions {
553
- prefix?: string;
554
- limit?: string;
555
- cursor?: string;
556
- }
557
- export interface CFWorkerKVKeyInfo {
558
- name: string;
559
- expiration?: number;
560
- metadata?: object;
561
- }
562
- export interface CFWorkerKVListResponse {
563
- keys: CFWorkerKVKeyInfo[];
564
- list_complete: boolean;
565
- cursor: string;
566
- }
567
- export interface CFWorkerKV {
568
- get(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<string | null>;
569
- get(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<ArrayBuffer | null>;
570
- get(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<ReadableStream<Uint8Array> | null>;
571
- get<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<T | null>;
572
- getWithMetadata(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<CFWorkerKVGetMetadataResponse<string>>;
573
- getWithMetadata(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<CFWorkerKVGetMetadataResponse<ArrayBuffer>>;
574
- getWithMetadata(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<CFWorkerKVGetMetadataResponse<ReadableStream<Uint8Array>>>;
575
- getWithMetadata<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<CFWorkerKVGetMetadataResponse<T>>;
576
- put(key: string, value: string | ReadableStream | ArrayBuffer, options?: CFWorkerKVPutOptions): Promise<void>;
577
- delete(key: string): Promise<void>;
578
- list(options?: CFWorkerKVListOptions): Promise<CFWorkerKVListResponse>;
579
- }
580
- export interface CFThemeEnv {
581
- THEME?: CFWorkerKV;
582
- }
583
- export interface CFWorkerContext {
584
- waitUntil(promise: Promise<unknown>): void;
585
- passThroughOnException(): void;
586
- }
587
539
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swell/apps-sdk",
3
3
  "type": "module",
4
- "version": "1.0.144",
4
+ "version": "1.0.146",
5
5
  "description": "Swell SDK for building isomorphic apps.",
6
6
  "author": "Swell",
7
7
  "license": "MIT",
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from '../dist/types/swell';
2
2
  export * from '../dist/types/shopify';
3
+ export * from '../dist/types/cloudflare';
3
4
  export * from '../dist/src/index';