commerce-kit 0.16.2 → 0.18.0

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.
@@ -6319,6 +6319,38 @@ type APICollectionGetByIdResult = {
6319
6319
  type APICollectionGetByIdParams = {
6320
6320
  idOrSlug: string;
6321
6321
  };
6322
+ type APICollectionCreateBody = {
6323
+ name: string;
6324
+ slug?: string;
6325
+ description?: string | null;
6326
+ image?: string | null;
6327
+ filter?: {
6328
+ type: "manual";
6329
+ } | {
6330
+ type: "dynamicPrice";
6331
+ min?: number | null;
6332
+ max?: number | null;
6333
+ };
6334
+ active?: boolean;
6335
+ };
6336
+ type APICollectionCreateResult = {
6337
+ id: string;
6338
+ name: string;
6339
+ slug: string;
6340
+ description: JSONContent | null;
6341
+ image: string | null;
6342
+ filter: {
6343
+ type: "manual";
6344
+ } | {
6345
+ type: "dynamicPrice";
6346
+ min?: number | null | undefined;
6347
+ max?: number | null | undefined;
6348
+ };
6349
+ active: boolean;
6350
+ createdAt: string;
6351
+ updatedAt: string;
6352
+ storeId: string;
6353
+ };
6322
6354
  type APIMeGetResult = {
6323
6355
  store: NonNullable<{
6324
6356
  settings: {
@@ -6458,10 +6490,15 @@ type APIMeGetResult = {
6458
6490
  settings?: Record<string, unknown> | undefined;
6459
6491
  }[];
6460
6492
  } | null | undefined;
6493
+ emailTracking?: {
6494
+ trackClicks: boolean;
6495
+ trackOpens: boolean;
6496
+ } | null | undefined;
6461
6497
  } | null | undefined;
6462
6498
  flags: {
6463
6499
  verifyPKD?: boolean | null | undefined;
6464
6500
  gold?: boolean | null | undefined;
6501
+ showReferralBadge?: boolean | null | undefined;
6465
6502
  } | undefined;
6466
6503
  id: string;
6467
6504
  name: string;
@@ -6496,6 +6533,7 @@ type APIMeGetResult = {
6496
6533
  method: "internal";
6497
6534
  sandboxId: string;
6498
6535
  sandboxUrl: string;
6536
+ wsUrl?: string | undefined;
6499
6537
  vercelProjectId: string;
6500
6538
  gitHubDeployKey: string;
6501
6539
  styles?: {
@@ -6565,5 +6603,417 @@ type APIMeGetResult = {
6565
6603
  storeBaseUrl: string;
6566
6604
  publicUrl: string;
6567
6605
  };
6606
+ type APIPostsBrowseResult = {
6607
+ data: {
6608
+ id: string;
6609
+ image: string | null;
6610
+ createdAt: string;
6611
+ slug: string;
6612
+ active: boolean;
6613
+ title: string;
6614
+ content: JSONContent;
6615
+ tag: string | null;
6616
+ filters: unknown;
6617
+ publishedAt: string | null;
6618
+ }[];
6619
+ meta: {
6620
+ count: number;
6621
+ offset: number;
6622
+ limit: number;
6623
+ };
6624
+ };
6625
+ type APIPostsBrowseQueryParams = {
6626
+ offset?: number;
6627
+ limit?: number;
6628
+ query?: string;
6629
+ active?: boolean;
6630
+ tag?: string;
6631
+ };
6632
+ type APIPostGetByIdResult = {
6633
+ id: string;
6634
+ image: string | null;
6635
+ createdAt: string;
6636
+ updatedAt: string;
6637
+ slug: string;
6638
+ active: boolean;
6639
+ storeId: string;
6640
+ title: string;
6641
+ seo: {
6642
+ title?: string | null | undefined;
6643
+ description?: string | null | undefined;
6644
+ canonical?: string | null | undefined;
6645
+ } | null;
6646
+ content: JSONContent;
6647
+ tag: string | null;
6648
+ filters: unknown;
6649
+ publishedAt: string | null;
6650
+ } | null | undefined;
6651
+ type APIPostGetByIdParams = {
6652
+ idOrSlug: string;
6653
+ };
6654
+ type APIPostCreateBody = {
6655
+ title: string;
6656
+ slug: string;
6657
+ content: Record<string, unknown>;
6658
+ image?: string | null;
6659
+ tag?: string | null;
6660
+ filters?: Record<string, string>;
6661
+ active?: boolean;
6662
+ publishedAt?: string;
6663
+ seo?: {
6664
+ title?: string | null;
6665
+ description?: string | null;
6666
+ canonical?: string | null;
6667
+ };
6668
+ };
6669
+ type APIPostCreateResult = {
6670
+ id: string;
6671
+ image: string | null;
6672
+ createdAt: string;
6673
+ updatedAt: string;
6674
+ slug: string;
6675
+ active: boolean;
6676
+ storeId: string;
6677
+ title: string;
6678
+ seo: {
6679
+ title?: string | null | undefined;
6680
+ description?: string | null | undefined;
6681
+ canonical?: string | null | undefined;
6682
+ } | null;
6683
+ content: JSONContent;
6684
+ tag: string | null;
6685
+ filters: unknown;
6686
+ publishedAt: string | null;
6687
+ } | null | undefined;
6688
+ type APIPostUpdateBody = {
6689
+ title?: string;
6690
+ slug?: string;
6691
+ content?: Record<string, unknown>;
6692
+ image?: string | null;
6693
+ tag?: string | null;
6694
+ filters?: Record<string, string>;
6695
+ active?: boolean;
6696
+ publishedAt?: string | null;
6697
+ seo?: {
6698
+ title?: string | null;
6699
+ description?: string | null;
6700
+ canonical?: string | null;
6701
+ };
6702
+ };
6703
+ type APIPostUpdateResult = {
6704
+ id: string;
6705
+ image: string | null;
6706
+ createdAt: string;
6707
+ updatedAt: string;
6708
+ slug: string;
6709
+ active: boolean;
6710
+ storeId: string;
6711
+ title: string;
6712
+ seo: {
6713
+ title?: string | null | undefined;
6714
+ description?: string | null | undefined;
6715
+ canonical?: string | null | undefined;
6716
+ } | null;
6717
+ content: JSONContent;
6718
+ tag: string | null;
6719
+ filters: unknown;
6720
+ publishedAt: string | null;
6721
+ } | null | undefined;
6722
+ type APIPostDeleteResult = {
6723
+ message: string;
6724
+ };
6725
+ type APICustomersBrowseResult = {
6726
+ items: Array<{
6727
+ id: string;
6728
+ email: string | null;
6729
+ name: string | null;
6730
+ createdAt: string;
6731
+ }>;
6732
+ pagination: {
6733
+ total: number;
6734
+ offset: number;
6735
+ limit: number;
6736
+ hasMore: boolean;
6737
+ };
6738
+ };
6739
+ type APICustomersBrowseQueryParams = {
6740
+ limit?: number;
6741
+ offset?: number;
6742
+ search?: string;
6743
+ };
6744
+ type APICustomerGetByIdResult = {
6745
+ id: string;
6746
+ email: string | null;
6747
+ name: string | null;
6748
+ phone: string | null;
6749
+ addresses: Array<{
6750
+ id: string;
6751
+ line1: string | null;
6752
+ line2: string | null;
6753
+ city: string | null;
6754
+ postalCode: string | null;
6755
+ country: string | null;
6756
+ state: string | null;
6757
+ name: string | null;
6758
+ company: string | null;
6759
+ phone: string | null;
6760
+ }>;
6761
+ createdAt: string;
6762
+ };
6763
+ type APICustomerGetByIdParams = {
6764
+ id: string;
6765
+ };
6766
+ type APICustomerUpdateBody = {
6767
+ name?: string;
6768
+ phone?: string;
6769
+ marketingOptIn?: boolean;
6770
+ };
6771
+ type APICustomerUpdateResult = {
6772
+ id: string;
6773
+ message: string;
6774
+ };
6775
+ type APICustomerAddressCreateBody = {
6776
+ line1: string;
6777
+ line2?: string;
6778
+ city: string;
6779
+ postalCode: string;
6780
+ country?: string;
6781
+ state?: string;
6782
+ name?: string;
6783
+ company?: string;
6784
+ phone?: string;
6785
+ label?: string;
6786
+ };
6787
+ type APICustomerAddressCreateResult = {
6788
+ id: string;
6789
+ line1: string | null;
6790
+ line2: string | null;
6791
+ city: string | null;
6792
+ postalCode: string | null;
6793
+ country: string | null;
6794
+ state: string | null;
6795
+ name: string | null;
6796
+ company: string | null;
6797
+ phone: string | null;
6798
+ };
6799
+ type APICustomerOrdersBrowseResult = {
6800
+ items: Array<{
6801
+ id: string;
6802
+ orderNumber: string | null;
6803
+ status: string;
6804
+ totalCents: number;
6805
+ currency: string;
6806
+ createdAt: string;
6807
+ }>;
6808
+ pagination: {
6809
+ total: number;
6810
+ offset: number;
6811
+ limit: number;
6812
+ hasMore: boolean;
6813
+ };
6814
+ };
6815
+ type APICustomerOrdersBrowseQueryParams = {
6816
+ limit?: number;
6817
+ offset?: number;
6818
+ };
6819
+ type APIInventoryBrowseResult = {
6820
+ items: Array<{
6821
+ sku: string | null;
6822
+ onHand: number;
6823
+ reserved: number;
6824
+ available: number;
6825
+ }>;
6826
+ pagination: {
6827
+ cursor: string | null;
6828
+ hasMore: boolean;
6829
+ };
6830
+ };
6831
+ type APIInventoryBrowseQueryParams = {
6832
+ limit?: number;
6833
+ cursor?: string;
6834
+ lowStock?: number;
6835
+ };
6836
+ type APIInventoryAdjustBody = {
6837
+ delta: number;
6838
+ reason: "restock" | "correction" | "damaged" | "return";
6839
+ };
6840
+ type APIInventoryAdjustResult = {
6841
+ sku: string | null;
6842
+ previousStock: number;
6843
+ adjustment: number;
6844
+ newStock: number | null;
6845
+ reason: string;
6846
+ };
6847
+ type APIVariantGetByIdResult = {
6848
+ id: string;
6849
+ sku: string | null;
6850
+ title: string | null;
6851
+ priceCents: number;
6852
+ imageUrl: string | null;
6853
+ stock: number | null;
6854
+ productId: string;
6855
+ product: {
6856
+ id: string;
6857
+ name: string;
6858
+ slug: string;
6859
+ images: string[];
6860
+ };
6861
+ };
6862
+ type APIVariantGetByIdParams = {
6863
+ idOrSku: string;
6864
+ };
6865
+ type APIVariantUpdateBody = {
6866
+ sku?: string;
6867
+ title?: string;
6868
+ priceCents?: number;
6869
+ imageUrl?: string | null;
6870
+ stock?: number;
6871
+ };
6872
+ type APIVariantUpdateResult = {
6873
+ id: string;
6874
+ sku: string | null;
6875
+ title: string | null;
6876
+ priceCents: number;
6877
+ imageUrl: string | null;
6878
+ stock: number | null;
6879
+ productId: string;
6880
+ };
6881
+ type APIVariantCreateBody = {
6882
+ sku: string;
6883
+ title: string;
6884
+ priceCents: number;
6885
+ imageUrl?: string;
6886
+ stock?: number;
6887
+ };
6888
+ type APIVariantCreateResult = {
6889
+ id: string;
6890
+ sku: string | null;
6891
+ title: string | null;
6892
+ priceCents: number;
6893
+ imageUrl: string | null;
6894
+ stock: number | null;
6895
+ };
6896
+ type APISubscriberCreateBody = {
6897
+ email: string;
6898
+ name?: string;
6899
+ };
6900
+ type APISubscriberCreateResult = {
6901
+ id: string;
6902
+ name: string | null;
6903
+ email: string;
6904
+ createdAt: string;
6905
+ updatedAt: string;
6906
+ storeId: string;
6907
+ location: string | null;
6908
+ unsubscribed: boolean;
6909
+ unsubscribedAt: string | null;
6910
+ unsubscribeToken: string | null;
6911
+ } | undefined;
6912
+ type APISubscriberDeleteResult = {
6913
+ status: "unsubscribed";
6914
+ };
6915
+ type APIProductCreateBody = {
6916
+ name: string;
6917
+ slug: string;
6918
+ description?: string;
6919
+ price: number;
6920
+ images?: string[];
6921
+ category?: string;
6922
+ quantity?: number;
6923
+ };
6924
+ type APIProductCreateResult = {
6925
+ message: string;
6926
+ product: {
6927
+ id: string;
6928
+ name: string;
6929
+ slug: string;
6930
+ description?: string;
6931
+ category?: string;
6932
+ images: string[];
6933
+ variant: {
6934
+ id: string;
6935
+ price: string;
6936
+ stock: number | null;
6937
+ } | null;
6938
+ };
6939
+ };
6940
+ type APIProductUpdateBody = {
6941
+ title?: string;
6942
+ description?: string;
6943
+ status?: "active" | "draft";
6944
+ };
6945
+ type APIProductUpdateResult = {
6946
+ id: string;
6947
+ title: string;
6948
+ description: string | null;
6949
+ status: "active" | "draft";
6950
+ };
6951
+ type APIProductDeleteResult = {
6952
+ message: string;
6953
+ };
6954
+ type APICategoryCreateBody = {
6955
+ name: string;
6956
+ slug?: string;
6957
+ description?: string;
6958
+ image?: string;
6959
+ parentId?: string;
6960
+ active?: boolean;
6961
+ };
6962
+ type APICategoryCreateResult = {
6963
+ id: string;
6964
+ name: string;
6965
+ image: string | null;
6966
+ createdAt: string;
6967
+ updatedAt: string;
6968
+ slug: string;
6969
+ active: boolean;
6970
+ storeId: string;
6971
+ description: JSONContent | null;
6972
+ position: string;
6973
+ seo: {
6974
+ title?: string | null | undefined;
6975
+ description?: string | null | undefined;
6976
+ canonical?: string | null | undefined;
6977
+ } | null;
6978
+ longDescription: JSONContent | null;
6979
+ parentId: string | null;
6980
+ };
6981
+ type APICategoryUpdateBody = {
6982
+ name?: string;
6983
+ slug?: string;
6984
+ description?: string | null;
6985
+ image?: string | null;
6986
+ parentId?: string | null;
6987
+ active?: boolean;
6988
+ };
6989
+ type APICategoryUpdateResult = {
6990
+ id: string;
6991
+ name: string;
6992
+ image: string | null;
6993
+ createdAt: string;
6994
+ updatedAt: string;
6995
+ slug: string;
6996
+ active: boolean;
6997
+ storeId: string;
6998
+ description: JSONContent | null;
6999
+ position: string;
7000
+ seo: {
7001
+ title?: string | null | undefined;
7002
+ description?: string | null | undefined;
7003
+ canonical?: string | null | undefined;
7004
+ } | null;
7005
+ longDescription: JSONContent | null;
7006
+ parentId: string | null;
7007
+ };
7008
+ type APIOrderUpdateBody = {
7009
+ status?: "processing" | "shipped" | "delivered" | "canceled";
7010
+ trackingNumber?: string;
7011
+ trackingUrl?: string;
7012
+ };
7013
+ type APIOrderUpdateResult = {
7014
+ id: string;
7015
+ status: string;
7016
+ trackingNumber: string | null;
7017
+ };
6568
7018
 
6569
- export type { APICartAddBody, APICartAddResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, JSONContent };
7019
+ export type { APICartAddBody, APICartAddResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoryUpdateBody, APICategoryUpdateResult, APICollectionCreateBody, APICollectionCreateResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrderUpdateBody, APIOrderUpdateResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIPostCreateBody, APIPostCreateResult, APIPostDeleteResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostUpdateBody, APIPostUpdateResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIProductCreateBody, APIProductCreateResult, APIProductDeleteResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductUpdateBody, APIProductUpdateResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIVariantCreateBody, APIVariantCreateResult, APIVariantGetByIdParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, JSONContent };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { APIMeGetResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult } from './api-types.js';
1
+ import { APIMeGetResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APICartCreateBody, APICartCreateResult, APICartGetResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APICollectionCreateBody, APICollectionCreateResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostCreateBody, APIPostCreateResult, APIPostUpdateBody, APIPostUpdateResult, APIPostDeleteResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIVariantGetByIdParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, APIVariantCreateBody, APIVariantCreateResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIProductCreateBody, APIProductCreateResult, APIProductUpdateBody, APIProductUpdateResult, APIProductDeleteResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryUpdateBody, APICategoryUpdateResult, APIOrderUpdateBody, APIOrderUpdateResult } from './api-types.js';
2
2
  export { APICartAddBody, APICartAddResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, JSONContent } from './api-types.js';
3
3
 
4
4
  interface CommerceConfig {
@@ -26,8 +26,37 @@ declare class YNSProvider {
26
26
  }): Promise<APICartGetResult | null>;
27
27
  collectionGet(params: APICollectionGetByIdParams): Promise<APICollectionGetByIdResult | null>;
28
28
  collectionBrowse(params: APICollectionsBrowseQueryParams): Promise<APICollectionsBrowseResult>;
29
+ collectionCreate(body: APICollectionCreateBody): Promise<APICollectionCreateResult>;
29
30
  categoryGet(params: APICategoryGetByIdParams): Promise<APICategoryGetByIdResult | null>;
30
31
  categoriesBrowse(params: APICategoriesBrowseQueryParams): Promise<APICategoriesBrowseResult>;
32
+ postBrowse(params?: APIPostsBrowseQueryParams): Promise<APIPostsBrowseResult>;
33
+ postGet(params: APIPostGetByIdParams): Promise<APIPostGetByIdResult | null>;
34
+ postCreate(body: APIPostCreateBody): Promise<APIPostCreateResult>;
35
+ postUpdate(params: APIPostGetByIdParams, body: APIPostUpdateBody): Promise<APIPostUpdateResult>;
36
+ postDelete(params: APIPostGetByIdParams): Promise<APIPostDeleteResult>;
37
+ customerBrowse(params?: APICustomersBrowseQueryParams): Promise<APICustomersBrowseResult>;
38
+ customerGet(params: APICustomerGetByIdParams): Promise<APICustomerGetByIdResult | null>;
39
+ customerUpdate(params: APICustomerGetByIdParams, body: APICustomerUpdateBody): Promise<APICustomerUpdateResult>;
40
+ customerAddressCreate(params: APICustomerGetByIdParams, body: APICustomerAddressCreateBody): Promise<APICustomerAddressCreateResult>;
41
+ customerAddressDelete(params: {
42
+ customerId: string;
43
+ addressId: string;
44
+ }): Promise<void>;
45
+ customerOrdersBrowse(params: APICustomerGetByIdParams, queryParams?: APICustomerOrdersBrowseQueryParams): Promise<APICustomerOrdersBrowseResult>;
46
+ inventoryBrowse(params?: APIInventoryBrowseQueryParams): Promise<APIInventoryBrowseResult>;
47
+ inventoryAdjust(sku: string, body: APIInventoryAdjustBody): Promise<APIInventoryAdjustResult>;
48
+ variantGet(params: APIVariantGetByIdParams): Promise<APIVariantGetByIdResult | null>;
49
+ variantUpdate(params: APIVariantGetByIdParams, body: APIVariantUpdateBody): Promise<APIVariantUpdateResult>;
50
+ variantDelete(params: APIVariantGetByIdParams): Promise<void>;
51
+ variantCreate(productId: string, body: APIVariantCreateBody): Promise<APIVariantCreateResult>;
52
+ subscriberCreate(body: APISubscriberCreateBody): Promise<APISubscriberCreateResult>;
53
+ subscriberDelete(email: string): Promise<APISubscriberDeleteResult>;
54
+ productCreate(body: APIProductCreateBody): Promise<APIProductCreateResult>;
55
+ productUpdate(params: APIProductGetByIdParams, body: APIProductUpdateBody): Promise<APIProductUpdateResult>;
56
+ productDelete(params: APIProductGetByIdParams): Promise<APIProductDeleteResult>;
57
+ categoryCreate(body: APICategoryCreateBody): Promise<APICategoryCreateResult>;
58
+ categoryUpdate(params: APICategoryGetByIdParams, body: APICategoryUpdateBody): Promise<APICategoryUpdateResult>;
59
+ orderUpdate(params: APIOrderGetByIdParams, body: APIOrderUpdateBody): Promise<APIOrderUpdateResult>;
31
60
  /**
32
61
  * Make a raw API request to any endpoint.
33
62
  * Use this for new API features not yet supported by typed methods.
@@ -59,4 +88,4 @@ declare class YNSProvider {
59
88
 
60
89
  declare function Commerce(config?: CommerceConfig): YNSProvider;
61
90
 
62
- export { APICartCreateBody, APICartCreateResult, APICartGetResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, Commerce, type CommerceConfig, YNSProvider };
91
+ export { APICartCreateBody, APICartCreateResult, APICartGetResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryGetByIdParams, APICategoryGetByIdResult, APICategoryUpdateBody, APICategoryUpdateResult, APICollectionCreateBody, APICollectionCreateResult, APICollectionGetByIdParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrderUpdateBody, APIOrderUpdateResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIPostCreateBody, APIPostCreateResult, APIPostDeleteResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostUpdateBody, APIPostUpdateResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIProductCreateBody, APIProductCreateResult, APIProductDeleteResult, APIProductGetByIdParams, APIProductGetByIdResult, APIProductUpdateBody, APIProductUpdateResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIVariantCreateBody, APIVariantCreateResult, APIVariantGetByIdParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, Commerce, type CommerceConfig, YNSProvider };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunk-PNKB6P4V.js";var p=process.env.YNS_API_KEY,m={YNS_API_KEY:p};var i={DEBUG:0,LOG:1,WARN:2,ERROR:3},R=process.env.NEXT_PUBLIC_LOG_LEVEL||"LOG",a=i[R],P="\x1B[0m",B="\x1B[34m",w="\x1B[32m",A="\x1B[33m",h="\x1B[31m",E="\u23F1\uFE0F",C="\u{1F41B}",G="\u2714\uFE0F",$="\u26A0\uFE0F",S="\u274C",I=`${E} `,L=`${B}${C}${P} `,v=`${w}${G}${P} `,O=`${A}${$}${P} `,T=`${h}${S}${P} `,g=c=>{let e=c?`[${c}] `:"";return{getLogger(t){return g([c,t].filter(Boolean).join(" > "))},time(t){a>i.DEBUG||console.time([I,e,t].filter(Boolean).join(" "))},timeEnd(t){a>i.DEBUG||console.timeEnd([I,e,t].filter(Boolean).join(" "))},debug(...t){a>i.DEBUG||console.log(...[L,e,...t].filter(Boolean))},log(...t){a>i.LOG||console.log(...[v,e,...t].filter(Boolean))},dir(t,r){a>i.LOG||console.dir(t,r)},warn(...t){a>i.WARN||console.warn(...[O,e,...t].filter(Boolean))},error(...t){a>i.ERROR||console.error(...[T,e,...t].filter(Boolean))}}},b=g();var l=class{#r;#t=g("YNSProvider");constructor(e={}){let t=e.token??m.YNS_API_KEY,r=m.YNS_API_KEY?.startsWith("sk-s-");if(!t)throw new Error("YNS API key is required. Set YNS_API_KEY environment variable or pass token in config.");let s=e.endpoint??(r?"https://yns.cx":"https://yns.store");this.#r={version:"v1",...e,token:t,endpoint:s},this.#t.debug("YNSProvider initialized",{endpoint:s,token:e.token?"from config":"from env"})}async#e(e,t="GET",r){let s=this.#t.getLogger("#restRequest"),n=`${this.#r.endpoint}/api/${this.#r.version}${e}`;s.debug(`Making ${t} request to YNS API: ${n}`);let o=await fetch(n,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#r.token}`},body:r?JSON.stringify(r):void 0});if(!o.ok){let f=o.headers.get("content-type"),d=`YNS REST request failed: ${t} ${n} ${o.status} ${o.statusText}`;if(f?.includes("application/json"))try{let u=await o.json();d=u.error||u.message||d}catch(u){s.error("Failed to parse YNS error response as JSON",u)}else{let u=await o.text();s.error(`YNS API request failed: ${o.status} ${o.statusText}`,d,u)}throw new Error(d)}let y=o.headers.get("content-type");if(!y?.includes("application/json"))throw new Error(`YNS API returned ${y} instead of JSON for ${e}`);return o.json()}async meGet(){let e=this.#t.getLogger("meGet");e.debug("Fetching my information");let r=await this.#e("/me");return e.debug("Received my information:",r),r}async productBrowse(e){let t=this.#t.getLogger("productBrowse");t.debug("Browsing products with params:",e);let r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.offset&&r.append("offset",e.offset.toString()),e.category&&r.append("category",e.category),e.query&&r.append("query",e.query),e.active!==void 0&&r.append("active",e.active.toString()),e.orderBy&&r.append("orderBy",e.orderBy),e.orderDirection&&r.append("orderDirection",e.orderDirection);let n=`/products${r.size?`?${r}`:""}`;t.debug("Constructed pathname:",n);let o=await this.#e(n);return t.debug("Received product browse result:",{meta:o.meta}),o}async productGet(e){let t=`/products/${e.idOrSlug}`,r=await this.#e(t);return r||null}async orderBrowse(e){let t=this.#t.getLogger("orderBrowse");t.debug("Browsing orders with params:",e);let r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.offset&&r.append("offset",e.offset.toString());let n=`/orders${r.size?`?${r}`:""}`;t.debug("Constructed pathname:",n);let o=await this.#e(n);return t.debug("Received orders browse result:",{meta:o.meta}),o}async orderGet(e){let t=`/orders/${e.id}`,r=await this.#e(t);return r||null}async cartUpsert(e){return await this.#e("/carts","POST",e)}async cartRemoveItem(e){let t=`/carts/${e.cartId}/line-items/${e.variantId}`,r=await this.#e(t,"DELETE");return null}async cartGet(e){let t=`/carts/${e.cartId}`;return await this.#e(t)}async collectionGet(e){let t=`/collections/${e.idOrSlug}`;return await this.#e(t)}async collectionBrowse(e){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.query&&t.append("query",e.query),e.active!==void 0&&t.append("active",e.active.toString());let s=`/collections${t.size?`?${t}`:""}`;return await this.#e(s)}async categoryGet(e){let t=`/categories/${e.idOrSlug}`;return await this.#e(t)}async categoriesBrowse(e){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.query&&t.append("query",e.query),e.active!==void 0&&t.append("active",e.active.toString());let s=`/categories${t.size?`?${t}`:""}`;return await this.#e(s)}async request(e,t){let r=t?.query?`?${new URLSearchParams(Object.entries(t.query).map(([s,n])=>[s,String(n)]))}`:"";return this.#e(`${e}${r}`,t?.method??"GET",t?.body)}};function q(c={}){return new l(c)}export{q as Commerce,l as YNSProvider};
1
+ import"./chunk-PNKB6P4V.js";var g=process.env.YNS_API_KEY,m={YNS_API_KEY:g};var a={DEBUG:0,LOG:1,WARN:2,ERROR:3},R=process.env.NEXT_PUBLIC_LOG_LEVEL||"LOG",i=a[R],l="\x1B[0m",B="\x1B[34m",C="\x1B[32m",f="\x1B[33m",h="\x1B[31m",w="\u23F1\uFE0F",S="\u{1F41B}",G="\u2714\uFE0F",$="\u26A0\uFE0F",E="\u274C",A=`${w} `,U=`${B}${S}${l} `,v=`${C}${G}${l} `,O=`${f}${$}${l} `,L=`${h}${E}${l} `,I=u=>{let e=u?`[${u}] `:"";return{getLogger(t){return I([u,t].filter(Boolean).join(" > "))},time(t){i>a.DEBUG||console.time([A,e,t].filter(Boolean).join(" "))},timeEnd(t){i>a.DEBUG||console.timeEnd([A,e,t].filter(Boolean).join(" "))},debug(...t){i>a.DEBUG||console.log(...[U,e,...t].filter(Boolean))},log(...t){i>a.LOG||console.log(...[v,e,...t].filter(Boolean))},dir(t,s){i>a.LOG||console.dir(t,s)},warn(...t){i>a.WARN||console.warn(...[O,e,...t].filter(Boolean))},error(...t){i>a.ERROR||console.error(...[L,e,...t].filter(Boolean))}}},D=I();var c=class{#s;#t=I("YNSProvider");constructor(e={}){let t=e.token??m.YNS_API_KEY,s=m.YNS_API_KEY?.startsWith("sk-s-");if(!t)throw new Error("YNS API key is required. Set YNS_API_KEY environment variable or pass token in config.");let r=e.endpoint??(s?"https://yns.cx":"https://yns.store");this.#s={version:"v1",...e,token:t,endpoint:r},this.#t.debug("YNSProvider initialized",{endpoint:r,token:e.token?"from config":"from env"})}async#e(e,t="GET",s){let r=this.#t.getLogger("#restRequest"),n=`${this.#s.endpoint}/api/${this.#s.version}${e}`;r.debug(`Making ${t} request to YNS API: ${n}`);let o=await fetch(n,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#s.token}`},body:s?JSON.stringify(s):void 0});if(!o.ok){let p=o.headers.get("content-type"),d=`YNS REST request failed: ${t} ${n} ${o.status} ${o.statusText}`;if(p?.includes("application/json"))try{let P=await o.json();d=P.error||P.message||d}catch(P){r.error("Failed to parse YNS error response as JSON",P)}else{let P=await o.text();r.error(`YNS API request failed: ${o.status} ${o.statusText}`,d,P)}throw new Error(d)}let y=o.headers.get("content-type");if(!y?.includes("application/json"))throw new Error(`YNS API returned ${y} instead of JSON for ${e}`);return o.json()}async meGet(){let e=this.#t.getLogger("meGet");e.debug("Fetching my information");let s=await this.#e("/me");return e.debug("Received my information:",s),s}async productBrowse(e){let t=this.#t.getLogger("productBrowse");t.debug("Browsing products with params:",e);let s=new URLSearchParams;e.limit&&s.append("limit",e.limit.toString()),e.offset&&s.append("offset",e.offset.toString()),e.category&&s.append("category",e.category),e.query&&s.append("query",e.query),e.active!==void 0&&s.append("active",e.active.toString()),e.orderBy&&s.append("orderBy",e.orderBy),e.orderDirection&&s.append("orderDirection",e.orderDirection);let n=`/products${s.size?`?${s}`:""}`;t.debug("Constructed pathname:",n);let o=await this.#e(n);return t.debug("Received product browse result:",{meta:o.meta}),o}async productGet(e){let t=`/products/${e.idOrSlug}`,s=await this.#e(t);return s||null}async orderBrowse(e){let t=this.#t.getLogger("orderBrowse");t.debug("Browsing orders with params:",e);let s=new URLSearchParams;e.limit&&s.append("limit",e.limit.toString()),e.offset&&s.append("offset",e.offset.toString());let n=`/orders${s.size?`?${s}`:""}`;t.debug("Constructed pathname:",n);let o=await this.#e(n);return t.debug("Received orders browse result:",{meta:o.meta}),o}async orderGet(e){let t=`/orders/${e.id}`,s=await this.#e(t);return s||null}async cartUpsert(e){return await this.#e("/carts","POST",e)}async cartRemoveItem(e){let t=`/carts/${e.cartId}/line-items/${e.variantId}`,s=await this.#e(t,"DELETE");return null}async cartGet(e){let t=`/carts/${e.cartId}`;return await this.#e(t)}async collectionGet(e){let t=`/collections/${e.idOrSlug}`;return await this.#e(t)}async collectionBrowse(e){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.query&&t.append("query",e.query),e.active!==void 0&&t.append("active",e.active.toString());let r=`/collections${t.size?`?${t}`:""}`;return await this.#e(r)}async collectionCreate(e){return this.#e("/collections","POST",e)}async categoryGet(e){let t=`/categories/${e.idOrSlug}`;return await this.#e(t)}async categoriesBrowse(e){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.query&&t.append("query",e.query),e.active!==void 0&&t.append("active",e.active.toString());let r=`/categories${t.size?`?${t}`:""}`;return await this.#e(r)}async postBrowse(e={}){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.query&&t.append("query",e.query),e.active!==void 0&&t.append("active",e.active.toString()),e.tag&&t.append("tag",e.tag);let r=`/posts${t.size?`?${t}`:""}`;return this.#e(r)}async postGet(e){let t=`/posts/${e.idOrSlug}`;return this.#e(t)}async postCreate(e){return this.#e("/posts","POST",e)}async postUpdate(e,t){let s=`/posts/${e.idOrSlug}`;return this.#e(s,"PUT",t)}async postDelete(e){let t=`/posts/${e.idOrSlug}`;return this.#e(t,"DELETE")}async customerBrowse(e={}){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.offset&&t.append("offset",e.offset.toString()),e.search&&t.append("search",e.search);let r=`/customers${t.size?`?${t}`:""}`;return this.#e(r)}async customerGet(e){let t=`/customers/${e.id}`;return this.#e(t)}async customerUpdate(e,t){let s=`/customers/${e.id}`;return this.#e(s,"PUT",t)}async customerAddressCreate(e,t){let s=`/customers/${e.id}/addresses`;return this.#e(s,"POST",t)}async customerAddressDelete(e){let t=`/customers/${e.customerId}/addresses/${e.addressId}`;await this.#e(t,"DELETE")}async customerOrdersBrowse(e,t={}){let s=new URLSearchParams;t.limit&&s.append("limit",t.limit.toString()),t.offset&&s.append("offset",t.offset.toString());let r=s.size?`?${s}`:"",n=`/customers/${e.id}/orders${r}`;return this.#e(n)}async inventoryBrowse(e={}){let t=new URLSearchParams;e.limit&&t.append("limit",e.limit.toString()),e.cursor&&t.append("cursor",e.cursor),e.lowStock!==void 0&&t.append("lowStock",e.lowStock.toString());let r=`/inventory${t.size?`?${t}`:""}`;return this.#e(r)}async inventoryAdjust(e,t){let s=`/inventory/${encodeURIComponent(e)}/adjust`;return this.#e(s,"POST",t)}async variantGet(e){let t=`/variants/${e.idOrSku}`;return this.#e(t)}async variantUpdate(e,t){let s=`/variants/${e.idOrSku}`;return this.#e(s,"PUT",t)}async variantDelete(e){let t=`/variants/${e.idOrSku}`;await this.#e(t,"DELETE")}async variantCreate(e,t){let s=`/products/${e}/variants`;return this.#e(s,"POST",t)}async subscriberCreate(e){return this.#e("/subscribers","POST",e)}async subscriberDelete(e){let t=`/subscribers?email=${encodeURIComponent(e)}`;return this.#e(t,"DELETE")}async productCreate(e){return this.#e("/products","POST",e)}async productUpdate(e,t){let s=`/products/${e.idOrSlug}`;return this.#e(s,"PUT",t)}async productDelete(e){let t=`/products/${e.idOrSlug}`;return this.#e(t,"DELETE")}async categoryCreate(e){return this.#e("/categories","POST",e)}async categoryUpdate(e,t){let s=`/categories/${e.idOrSlug}`;return this.#e(s,"PUT",t)}async orderUpdate(e,t){let s=`/orders/${e.id}`;return this.#e(s,"PUT",t)}async request(e,t){let s=t?.query?`?${new URLSearchParams(Object.entries(t.query).map(([r,n])=>[r,String(n)]))}`:"";return this.#e(`${e}${s}`,t?.method??"GET",t?.body)}};function T(u={}){return new c(u)}export{T as Commerce,c as YNSProvider};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/env.ts","../src/logger.ts","../src/providers/yns.ts","../src/commerce.ts"],"sourcesContent":["const YNS_API_KEY = process.env.YNS_API_KEY;\n\nexport const env = {\n\tYNS_API_KEY,\n};\n","import type { InspectOptions } from \"node:util\";\n\ntype LogParms = [message: unknown, ...optionalParams: unknown[]];\n\n/**\n * Vercel only supports 3 levels of logging. We're adding additional DEBUG level.\n * https://vercel.com/docs/observability/runtime-logs#level\n *\n * ERROR - Fatal for a particular request. Should be fixed sooner than later.\n *\n * WARN - A note on something that should probably be looked at eventually.\n *\n * LOG - Detail on regular operation.\n *\n * DEBUG - Debug only info as well as time and timeEnd functions.\n */\nconst LogLevel = {\n\tDEBUG: 0,\n\tLOG: 1,\n\tWARN: 2,\n\tERROR: 3,\n} as const;\ntype LogLevel = keyof typeof LogLevel;\n\nconst strLogLevel = (process.env.NEXT_PUBLIC_LOG_LEVEL || \"LOG\") as LogLevel;\nconst valueLogLevel = LogLevel[strLogLevel];\n\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\n\nconst TIME = `⏱️`;\nconst DEBUG = `🐛`;\nconst OK = `✔️`;\nconst WARN = `⚠️`;\nconst ERROR = `❌`;\n\nconst PREFIX_TIME = `${TIME} `;\nconst PREFIX_DEBUG = `${BLUE}${DEBUG}${RESET} `;\nconst PREFIX_OK = `${GREEN}${OK}${RESET} `;\nconst PREFIX_WARN = `${YELLOW}${WARN}${RESET} `;\nconst PREFIX_ERROR = `${RED}${ERROR}${RESET} `;\n\nexport const getLogger = (groupLabel?: string) => {\n\tconst PREFIX = groupLabel ? `[${groupLabel}] ` : \"\";\n\treturn {\n\t\tgetLogger(subGroupLabel: string) {\n\t\t\treturn getLogger([groupLabel, subGroupLabel].filter(Boolean).join(\" > \"));\n\t\t},\n\t\ttime(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.time([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\ttimeEnd(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.timeEnd([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\tdebug(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.log(...[PREFIX_DEBUG, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tlog(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.log(...[PREFIX_OK, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tdir(item?: unknown, options?: InspectOptions) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.dir(item, options);\n\t\t},\n\t\twarn(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.WARN) return;\n\t\t\tconsole.warn(...[PREFIX_WARN, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\terror(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.ERROR) return;\n\t\t\tconsole.error(...[PREFIX_ERROR, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t};\n};\n\nexport const logger = getLogger();\n","import type {\n\tAPICartCreateBody,\n\tAPICartCreateResult,\n\tAPICartGetResult,\n\tAPICategoriesBrowseQueryParams,\n\tAPICategoriesBrowseResult,\n\tAPICategoryGetByIdParams,\n\tAPICategoryGetByIdResult,\n\tAPICollectionGetByIdParams,\n\tAPICollectionGetByIdResult,\n\tAPICollectionsBrowseQueryParams,\n\tAPICollectionsBrowseResult,\n\tAPIMeGetResult,\n\tAPIOrderGetByIdParams,\n\tAPIOrderGetByIdResult,\n\tAPIOrdersBrowseQueryParams,\n\tAPIOrdersBrowseResult,\n\tAPIProductGetByIdParams,\n\tAPIProductGetByIdResult,\n\tAPIProductsBrowseQueryParams,\n\tAPIProductsBrowseResult,\n} from \"../api-types\";\nimport { env } from \"../env\";\nimport { getLogger } from \"../logger\";\nimport type { CommerceConfig } from \"../types\";\n\nexport class YNSProvider {\n\t#config: CommerceConfig;\n\t#logger = getLogger(\"YNSProvider\");\n\n\tconstructor(config: CommerceConfig = {}) {\n\t\tconst token = config.token ?? env.YNS_API_KEY;\n\t\tconst isStaging = env.YNS_API_KEY?.startsWith(\"sk-s-\");\n\n\t\tif (!token) {\n\t\t\tthrow new Error(\n\t\t\t\t\"YNS API key is required. Set YNS_API_KEY environment variable or pass token in config.\",\n\t\t\t);\n\t\t}\n\t\tconst endpoint = config.endpoint ?? (isStaging ? \"https://yns.cx\" : \"https://yns.store\");\n\n\t\tthis.#config = { version: \"v1\", ...config, token, endpoint };\n\n\t\tthis.#logger.debug(\"YNSProvider initialized\", {\n\t\t\tendpoint,\n\t\t\ttoken: config.token ? `from config` : \"from env\",\n\t\t});\n\t}\n\n\tasync #restRequest<T>(\n\t\tpathname: `/${string}`,\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" = \"GET\",\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst logger = this.#logger.getLogger(\"#restRequest\");\n\n\t\tconst endpoint = `${this.#config.endpoint}/api/${this.#config.version}${pathname}`;\n\t\tlogger.debug(`Making ${method} request to YNS API: ${endpoint}`);\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tAuthorization: `Bearer ${this.#config.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// Handle different error types\n\t\t\tconst contentType = response.headers.get(\"content-type\");\n\t\t\tlet errorMessage = `YNS REST request failed: ${method} ${endpoint} ${response.status} ${response.statusText}`;\n\n\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = await response.json();\n\t\t\t\t\terrorMessage = errorData.error || errorData.message || errorMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(\"Failed to parse YNS error response as JSON\", error);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tlogger.error(\n\t\t\t\t\t`YNS API request failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\terrorMessage,\n\t\t\t\t\terrorText,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\t// Check if response is JSON before parsing\n\t\tconst contentType = response.headers.get(\"content-type\");\n\t\tif (!contentType?.includes(\"application/json\")) {\n\t\t\tthrow new Error(`YNS API returned ${contentType} instead of JSON for ${pathname}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync meGet(): Promise<APIMeGetResult> {\n\t\tconst logger = this.#logger.getLogger(\"meGet\");\n\t\tlogger.debug(\"Fetching my information\");\n\n\t\tconst pathname = `/me` as const;\n\t\tconst result = await this.#restRequest<APIMeGetResult>(pathname);\n\t\tlogger.debug(\"Received my information:\", result);\n\t\treturn result;\n\t}\n\n\tasync productBrowse(params: APIProductsBrowseQueryParams): Promise<APIProductsBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"productBrowse\");\n\t\tlogger.debug(\"Browsing products with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.category) queryParams.append(\"category\", params.category);\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.orderBy) queryParams.append(\"orderBy\", params.orderBy);\n\t\tif (params.orderDirection) queryParams.append(\"orderDirection\", params.orderDirection);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/products${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIProductsBrowseResult>(pathname);\n\t\tlogger.debug(\"Received product browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APIProductGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync orderBrowse(params: APIOrdersBrowseQueryParams): Promise<APIOrdersBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"orderBrowse\");\n\t\tlogger.debug(\"Browsing orders with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/orders${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIOrdersBrowseResult>(pathname);\n\t\tlogger.debug(\"Received orders browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync orderGet(params: APIOrderGetByIdParams): Promise<APIOrderGetByIdResult | null> {\n\t\tconst pathname = `/orders/${params.id}` as const;\n\n\t\tconst result = await this.#restRequest<APIOrderGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// @todo\n\t// async cartAdd(params: APICartAddBody): Promise<APICartAddResult> {\n\t// \tconst body = {\n\t// \t\tvariantId: params.variantId,\n\t// \t\tcartId: params.cartId,\n\t// \t\tquantity: params.quantity,\n\t// \t\tsubscriptionId: params.subscriptionId,\n\t// \t};\n\n\t// \tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"PUT\", body);\n\t// \treturn result;\n\t// }\n\n\tasync cartUpsert(body: APICartCreateBody): Promise<APICartCreateResult> {\n\t\tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"POST\", body);\n\t\treturn result;\n\t}\n\n\tasync cartRemoveItem(params: { cartId: string; variantId: string }): Promise<null> {\n\t\tconst pathname = `/carts/${params.cartId}/line-items/${params.variantId}` as const;\n\t\tconst result = await this.#restRequest<unknown>(pathname, \"DELETE\");\n\t\t// return result;\n\t\treturn null;\n\t}\n\n\tasync cartGet(params: { cartId: string }): Promise<APICartGetResult | null> {\n\t\tconst pathname = `/carts/${params.cartId}` as const;\n\t\tconst result = await this.#restRequest<APICartGetResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync collectionGet(params: APICollectionGetByIdParams): Promise<APICollectionGetByIdResult | null> {\n\t\tconst pathname = `/collections/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APICollectionGetByIdResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync collectionBrowse(params: APICollectionsBrowseQueryParams): Promise<APICollectionsBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/collections${searchParams}` as const;\n\n\t\tconst result = await this.#restRequest<APICollectionsBrowseResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync categoryGet(params: APICategoryGetByIdParams): Promise<APICategoryGetByIdResult | null> {\n\t\tconst pathname = `/categories/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APICategoryGetByIdResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync categoriesBrowse(params: APICategoriesBrowseQueryParams): Promise<APICategoriesBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/categories${searchParams}` as const;\n\n\t\tconst result = await this.#restRequest<APICategoriesBrowseResult>(pathname);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Make a raw API request to any endpoint.\n\t * Use this for new API features not yet supported by typed methods.\n\t *\n\t * @example\n\t * // GET request (default method)\n\t * const webhooks = await provider.request<Webhook[]>('/webhooks');\n\t *\n\t * // POST with typed body\n\t * const webhook = await provider.request<Webhook, CreateWebhookBody>('/webhooks', {\n\t * method: 'POST',\n\t * body: { url: 'https://...' }\n\t * });\n\t *\n\t * // GET with query parameters\n\t * const products = await provider.request<Product[]>('/products', {\n\t * query: { limit: 10, category: 'shoes' }\n\t * });\n\t *\n\t * // Path parameters via template literals\n\t * const product = await provider.request<Product>(`/products/${id}`);\n\t */\n\tasync request<TResponse = unknown, TBody = unknown>(\n\t\tpathname: `/${string}`,\n\t\toptions?: {\n\t\t\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\t\t\tbody?: TBody;\n\t\t\tquery?: Record<string, string | number | boolean>;\n\t\t},\n\t) {\n\t\tconst queryString = options?.query\n\t\t\t? `?${new URLSearchParams(Object.entries(options.query).map(([k, v]) => [k, String(v)]))}`\n\t\t\t: \"\";\n\n\t\treturn this.#restRequest<TResponse>(`${pathname}${queryString}`, options?.method ?? \"GET\", options?.body);\n\t}\n}\n","import { YNSProvider } from \"./providers/yns\";\nimport type { CommerceConfig } from \"./types\";\n\nexport function Commerce(config: CommerceConfig = {}): YNSProvider {\n\treturn new YNSProvider(config);\n}\n"],"mappings":"4BAAA,IAAMA,EAAc,QAAQ,IAAI,YAEnBC,EAAM,CAClB,YAAAD,CACD,ECYA,IAAME,EAAW,CAChB,MAAO,EACP,IAAK,EACL,KAAM,EACN,MAAO,CACR,EAGMC,EAAe,QAAQ,IAAI,uBAAyB,MACpDC,EAAgBF,EAASC,CAAW,EAEpCE,EAAQ,UACRC,EAAO,WACPC,EAAQ,WACRC,EAAS,WACTC,EAAM,WAENC,EAAO,eACPC,EAAQ,YACRC,EAAK,eACLC,EAAO,eACPC,EAAQ,SAERC,EAAc,GAAGL,CAAI,IACrBM,EAAe,GAAGV,CAAI,GAAGK,CAAK,GAAGN,CAAK,IACtCY,EAAY,GAAGV,CAAK,GAAGK,CAAE,GAAGP,CAAK,IACjCa,EAAc,GAAGV,CAAM,GAAGK,CAAI,GAAGR,CAAK,IACtCc,EAAe,GAAGV,CAAG,GAAGK,CAAK,GAAGT,CAAK,IAE9Be,EAAaC,GAAwB,CACjD,IAAMC,EAASD,EAAa,IAAIA,CAAU,KAAO,GACjD,MAAO,CACN,UAAUE,EAAuB,CAChC,OAAOH,EAAU,CAACC,EAAYE,CAAa,EAAE,OAAO,OAAO,EAAE,KAAK,KAAK,CAAC,CACzE,EACA,KAAKC,EAAe,CACfpB,EAAgBF,EAAS,OAC7B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AW,eADIY,EAAY,KAAO,IAAIA,CAAW,GAAK,EAChB,GAG5C,OADe,MAAM,KAAKb,GAAyCC,CAAQ,CAE5E,CAEA,MAAM,YAAYW,EAA4E,CAC7F,IAAMX,EAAW,eAAeW,EAAO,QAAQ,GAG/C,OADe,MAAM,KAAKZ,GAAuCC,CAAQ,CAE1E,CAEA,MAAM,iBAAiBW,EAA4E,CAClG,IAAMC,EAAc,IAAI,gBACpBD,EAAO,OAAOC,EAAY,OAAO,QAASD,EAAO,MAAM,SAAS,CAAC,EACjEA,EAAO,QAAQC,EAAY,OAAO,SAAUD,EAAO,OAAO,SAAS,CAAC,EACpEA,EAAO,OAAOC,EAAY,OAAO,QAASD,EAAO,KAAK,EACtDA,EAAO,SAAW,QAAWC,EAAY,OAAO,SAAUD,EAAO,OAAO,SAAS,CAAC,EAGtF,IAAMX,EAAW,cADIY,EAAY,KAAO,IAAIA,CAAW,GAAK,EACjB,GAG3C,OADe,MAAM,KAAKb,GAAwCC,CAAQ,CAE3E,CAwBA,MAAM,QACLA,EACAa,EAKC,CACD,IAAMC,EAAcD,GAAS,MAC1B,IAAI,IAAI,gBAAgB,OAAO,QAAQA,EAAQ,KAAK,EAAE,IAAI,CAAC,CAACE,EAAGC,CAAC,IAAM,CAACD,EAAG,OAAOC,CAAC,CAAC,CAAC,CAAC,CAAC,GACtF,GAEH,OAAO,KAAKjB,GAAwB,GAAGC,CAAQ,GAAGc,CAAW,GAAID,GAAS,QAAU,MAAOA,GAAS,IAAI,CACzG,CACD,ECtRO,SAASI,EAASC,EAAyB,CAAC,EAAgB,CAClE,OAAO,IAAIC,EAAYD,CAAM,CAC9B","names":["YNS_API_KEY","env","LogLevel","strLogLevel","valueLogLevel","RESET","BLUE","GREEN","YELLOW","RED","TIME","DEBUG","OK","WARN","ERROR","PREFIX_TIME","PREFIX_DEBUG","PREFIX_OK","PREFIX_WARN","PREFIX_ERROR","getLogger","groupLabel","PREFIX","subGroupLabel","label","args","item","options","logger","YNSProvider","#config","#logger","getLogger","config","token","env","isStaging","endpoint","#restRequest","pathname","method","body","logger","response","contentType","errorMessage","errorData","error","errorText","result","params","queryParams","options","queryString","k","v","Commerce","config","YNSProvider"]}
1
+ {"version":3,"sources":["../src/env.ts","../src/logger.ts","../src/providers/yns.ts","../src/commerce.ts"],"sourcesContent":["const YNS_API_KEY = process.env.YNS_API_KEY;\n\nexport const env = {\n\tYNS_API_KEY,\n};\n","import type { InspectOptions } from \"node:util\";\n\ntype LogParms = [message: unknown, ...optionalParams: unknown[]];\n\n/**\n * Vercel only supports 3 levels of logging. We're adding additional DEBUG level.\n * https://vercel.com/docs/observability/runtime-logs#level\n *\n * ERROR - Fatal for a particular request. Should be fixed sooner than later.\n *\n * WARN - A note on something that should probably be looked at eventually.\n *\n * LOG - Detail on regular operation.\n *\n * DEBUG - Debug only info as well as time and timeEnd functions.\n */\nconst LogLevel = {\n\tDEBUG: 0,\n\tLOG: 1,\n\tWARN: 2,\n\tERROR: 3,\n} as const;\ntype LogLevel = keyof typeof LogLevel;\n\nconst strLogLevel = (process.env.NEXT_PUBLIC_LOG_LEVEL || \"LOG\") as LogLevel;\nconst valueLogLevel = LogLevel[strLogLevel];\n\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\n\nconst TIME = `⏱️`;\nconst DEBUG = `🐛`;\nconst OK = `✔️`;\nconst WARN = `⚠️`;\nconst ERROR = `❌`;\n\nconst PREFIX_TIME = `${TIME} `;\nconst PREFIX_DEBUG = `${BLUE}${DEBUG}${RESET} `;\nconst PREFIX_OK = `${GREEN}${OK}${RESET} `;\nconst PREFIX_WARN = `${YELLOW}${WARN}${RESET} `;\nconst PREFIX_ERROR = `${RED}${ERROR}${RESET} `;\n\nexport const getLogger = (groupLabel?: string) => {\n\tconst PREFIX = groupLabel ? `[${groupLabel}] ` : \"\";\n\treturn {\n\t\tgetLogger(subGroupLabel: string) {\n\t\t\treturn getLogger([groupLabel, subGroupLabel].filter(Boolean).join(\" > \"));\n\t\t},\n\t\ttime(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.time([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\ttimeEnd(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.timeEnd([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\tdebug(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.log(...[PREFIX_DEBUG, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tlog(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.log(...[PREFIX_OK, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tdir(item?: unknown, options?: InspectOptions) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.dir(item, options);\n\t\t},\n\t\twarn(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.WARN) return;\n\t\t\tconsole.warn(...[PREFIX_WARN, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\terror(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.ERROR) return;\n\t\t\tconsole.error(...[PREFIX_ERROR, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t};\n};\n\nexport const logger = getLogger();\n","import type {\n\tAPICartCreateBody,\n\tAPICartCreateResult,\n\tAPICartGetResult,\n\tAPICategoriesBrowseQueryParams,\n\tAPICategoriesBrowseResult,\n\tAPICategoryCreateBody,\n\tAPICategoryCreateResult,\n\tAPICategoryGetByIdParams,\n\tAPICategoryGetByIdResult,\n\tAPICategoryUpdateBody,\n\tAPICategoryUpdateResult,\n\tAPICollectionCreateBody,\n\tAPICollectionCreateResult,\n\tAPICollectionGetByIdParams,\n\tAPICollectionGetByIdResult,\n\tAPICollectionsBrowseQueryParams,\n\tAPICollectionsBrowseResult,\n\tAPICustomerAddressCreateBody,\n\tAPICustomerAddressCreateResult,\n\tAPICustomerGetByIdParams,\n\tAPICustomerGetByIdResult,\n\tAPICustomerOrdersBrowseQueryParams,\n\tAPICustomerOrdersBrowseResult,\n\tAPICustomersBrowseQueryParams,\n\tAPICustomersBrowseResult,\n\tAPICustomerUpdateBody,\n\tAPICustomerUpdateResult,\n\tAPIInventoryAdjustBody,\n\tAPIInventoryAdjustResult,\n\tAPIInventoryBrowseQueryParams,\n\tAPIInventoryBrowseResult,\n\tAPIMeGetResult,\n\tAPIOrderGetByIdParams,\n\tAPIOrderGetByIdResult,\n\tAPIOrdersBrowseQueryParams,\n\tAPIOrdersBrowseResult,\n\tAPIOrderUpdateBody,\n\tAPIOrderUpdateResult,\n\tAPIPostCreateBody,\n\tAPIPostCreateResult,\n\tAPIPostDeleteResult,\n\tAPIPostGetByIdParams,\n\tAPIPostGetByIdResult,\n\tAPIPostsBrowseQueryParams,\n\tAPIPostsBrowseResult,\n\tAPIPostUpdateBody,\n\tAPIPostUpdateResult,\n\tAPIProductCreateBody,\n\tAPIProductCreateResult,\n\tAPIProductDeleteResult,\n\tAPIProductGetByIdParams,\n\tAPIProductGetByIdResult,\n\tAPIProductsBrowseQueryParams,\n\tAPIProductsBrowseResult,\n\tAPIProductUpdateBody,\n\tAPIProductUpdateResult,\n\tAPISubscriberCreateBody,\n\tAPISubscriberCreateResult,\n\tAPISubscriberDeleteResult,\n\tAPIVariantCreateBody,\n\tAPIVariantCreateResult,\n\tAPIVariantGetByIdParams,\n\tAPIVariantGetByIdResult,\n\tAPIVariantUpdateBody,\n\tAPIVariantUpdateResult,\n} from \"../api-types\";\nimport { env } from \"../env\";\nimport { getLogger } from \"../logger\";\nimport type { CommerceConfig } from \"../types\";\n\nexport class YNSProvider {\n\t#config: CommerceConfig;\n\t#logger = getLogger(\"YNSProvider\");\n\n\tconstructor(config: CommerceConfig = {}) {\n\t\tconst token = config.token ?? env.YNS_API_KEY;\n\t\tconst isStaging = env.YNS_API_KEY?.startsWith(\"sk-s-\");\n\n\t\tif (!token) {\n\t\t\tthrow new Error(\n\t\t\t\t\"YNS API key is required. Set YNS_API_KEY environment variable or pass token in config.\",\n\t\t\t);\n\t\t}\n\t\tconst endpoint = config.endpoint ?? (isStaging ? \"https://yns.cx\" : \"https://yns.store\");\n\n\t\tthis.#config = { version: \"v1\", ...config, token, endpoint };\n\n\t\tthis.#logger.debug(\"YNSProvider initialized\", {\n\t\t\tendpoint,\n\t\t\ttoken: config.token ? `from config` : \"from env\",\n\t\t});\n\t}\n\n\tasync #restRequest<T>(\n\t\tpathname: `/${string}`,\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" = \"GET\",\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst logger = this.#logger.getLogger(\"#restRequest\");\n\n\t\tconst endpoint = `${this.#config.endpoint}/api/${this.#config.version}${pathname}`;\n\t\tlogger.debug(`Making ${method} request to YNS API: ${endpoint}`);\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tAuthorization: `Bearer ${this.#config.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// Handle different error types\n\t\t\tconst contentType = response.headers.get(\"content-type\");\n\t\t\tlet errorMessage = `YNS REST request failed: ${method} ${endpoint} ${response.status} ${response.statusText}`;\n\n\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = await response.json();\n\t\t\t\t\terrorMessage = errorData.error || errorData.message || errorMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(\"Failed to parse YNS error response as JSON\", error);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tlogger.error(\n\t\t\t\t\t`YNS API request failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\terrorMessage,\n\t\t\t\t\terrorText,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\t// Check if response is JSON before parsing\n\t\tconst contentType = response.headers.get(\"content-type\");\n\t\tif (!contentType?.includes(\"application/json\")) {\n\t\t\tthrow new Error(`YNS API returned ${contentType} instead of JSON for ${pathname}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync meGet(): Promise<APIMeGetResult> {\n\t\tconst logger = this.#logger.getLogger(\"meGet\");\n\t\tlogger.debug(\"Fetching my information\");\n\n\t\tconst pathname = `/me` as const;\n\t\tconst result = await this.#restRequest<APIMeGetResult>(pathname);\n\t\tlogger.debug(\"Received my information:\", result);\n\t\treturn result;\n\t}\n\n\tasync productBrowse(params: APIProductsBrowseQueryParams): Promise<APIProductsBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"productBrowse\");\n\t\tlogger.debug(\"Browsing products with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.category) queryParams.append(\"category\", params.category);\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.orderBy) queryParams.append(\"orderBy\", params.orderBy);\n\t\tif (params.orderDirection) queryParams.append(\"orderDirection\", params.orderDirection);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/products${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIProductsBrowseResult>(pathname);\n\t\tlogger.debug(\"Received product browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APIProductGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync orderBrowse(params: APIOrdersBrowseQueryParams): Promise<APIOrdersBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"orderBrowse\");\n\t\tlogger.debug(\"Browsing orders with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/orders${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIOrdersBrowseResult>(pathname);\n\t\tlogger.debug(\"Received orders browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync orderGet(params: APIOrderGetByIdParams): Promise<APIOrderGetByIdResult | null> {\n\t\tconst pathname = `/orders/${params.id}` as const;\n\n\t\tconst result = await this.#restRequest<APIOrderGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// @todo\n\t// async cartAdd(params: APICartAddBody): Promise<APICartAddResult> {\n\t// \tconst body = {\n\t// \t\tvariantId: params.variantId,\n\t// \t\tcartId: params.cartId,\n\t// \t\tquantity: params.quantity,\n\t// \t\tsubscriptionId: params.subscriptionId,\n\t// \t};\n\n\t// \tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"PUT\", body);\n\t// \treturn result;\n\t// }\n\n\tasync cartUpsert(body: APICartCreateBody): Promise<APICartCreateResult> {\n\t\tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"POST\", body);\n\t\treturn result;\n\t}\n\n\tasync cartRemoveItem(params: { cartId: string; variantId: string }): Promise<null> {\n\t\tconst pathname = `/carts/${params.cartId}/line-items/${params.variantId}` as const;\n\t\tconst result = await this.#restRequest<unknown>(pathname, \"DELETE\");\n\t\t// return result;\n\t\treturn null;\n\t}\n\n\tasync cartGet(params: { cartId: string }): Promise<APICartGetResult | null> {\n\t\tconst pathname = `/carts/${params.cartId}` as const;\n\t\tconst result = await this.#restRequest<APICartGetResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync collectionGet(params: APICollectionGetByIdParams): Promise<APICollectionGetByIdResult | null> {\n\t\tconst pathname = `/collections/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APICollectionGetByIdResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync collectionBrowse(params: APICollectionsBrowseQueryParams): Promise<APICollectionsBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/collections${searchParams}` as const;\n\n\t\tconst result = await this.#restRequest<APICollectionsBrowseResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync collectionCreate(body: APICollectionCreateBody): Promise<APICollectionCreateResult> {\n\t\treturn this.#restRequest<APICollectionCreateResult>(\"/collections\", \"POST\", body);\n\t}\n\n\tasync categoryGet(params: APICategoryGetByIdParams): Promise<APICategoryGetByIdResult | null> {\n\t\tconst pathname = `/categories/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APICategoryGetByIdResult>(pathname);\n\t\treturn result;\n\t}\n\n\tasync categoriesBrowse(params: APICategoriesBrowseQueryParams): Promise<APICategoriesBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/categories${searchParams}` as const;\n\n\t\tconst result = await this.#restRequest<APICategoriesBrowseResult>(pathname);\n\t\treturn result;\n\t}\n\n\t// ============================================\n\t// Posts\n\t// ============================================\n\n\tasync postBrowse(params: APIPostsBrowseQueryParams = {}): Promise<APIPostsBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.tag) queryParams.append(\"tag\", params.tag);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/posts${searchParams}` as const;\n\n\t\treturn this.#restRequest<APIPostsBrowseResult>(pathname);\n\t}\n\n\tasync postGet(params: APIPostGetByIdParams): Promise<APIPostGetByIdResult | null> {\n\t\tconst pathname = `/posts/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APIPostGetByIdResult>(pathname);\n\t}\n\n\tasync postCreate(body: APIPostCreateBody): Promise<APIPostCreateResult> {\n\t\treturn this.#restRequest<APIPostCreateResult>(\"/posts\", \"POST\", body);\n\t}\n\n\tasync postUpdate(params: APIPostGetByIdParams, body: APIPostUpdateBody): Promise<APIPostUpdateResult> {\n\t\tconst pathname = `/posts/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APIPostUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\tasync postDelete(params: APIPostGetByIdParams): Promise<APIPostDeleteResult> {\n\t\tconst pathname = `/posts/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APIPostDeleteResult>(pathname, \"DELETE\");\n\t}\n\n\t// ============================================\n\t// Customers\n\t// ============================================\n\n\tasync customerBrowse(params: APICustomersBrowseQueryParams = {}): Promise<APICustomersBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.search) queryParams.append(\"search\", params.search);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/customers${searchParams}` as const;\n\n\t\treturn this.#restRequest<APICustomersBrowseResult>(pathname);\n\t}\n\n\tasync customerGet(params: APICustomerGetByIdParams): Promise<APICustomerGetByIdResult | null> {\n\t\tconst pathname = `/customers/${params.id}` as const;\n\t\treturn this.#restRequest<APICustomerGetByIdResult>(pathname);\n\t}\n\n\tasync customerUpdate(\n\t\tparams: APICustomerGetByIdParams,\n\t\tbody: APICustomerUpdateBody,\n\t): Promise<APICustomerUpdateResult> {\n\t\tconst pathname = `/customers/${params.id}` as const;\n\t\treturn this.#restRequest<APICustomerUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\tasync customerAddressCreate(\n\t\tparams: APICustomerGetByIdParams,\n\t\tbody: APICustomerAddressCreateBody,\n\t): Promise<APICustomerAddressCreateResult> {\n\t\tconst pathname = `/customers/${params.id}/addresses` as const;\n\t\treturn this.#restRequest<APICustomerAddressCreateResult>(pathname, \"POST\", body);\n\t}\n\n\tasync customerAddressDelete(params: { customerId: string; addressId: string }): Promise<void> {\n\t\tconst pathname = `/customers/${params.customerId}/addresses/${params.addressId}` as const;\n\t\tawait this.#restRequest<unknown>(pathname, \"DELETE\");\n\t}\n\n\tasync customerOrdersBrowse(\n\t\tparams: APICustomerGetByIdParams,\n\t\tqueryParams: APICustomerOrdersBrowseQueryParams = {},\n\t): Promise<APICustomerOrdersBrowseResult> {\n\t\tconst urlParams = new URLSearchParams();\n\t\tif (queryParams.limit) urlParams.append(\"limit\", queryParams.limit.toString());\n\t\tif (queryParams.offset) urlParams.append(\"offset\", queryParams.offset.toString());\n\n\t\tconst searchParams = urlParams.size ? `?${urlParams}` : \"\";\n\t\tconst pathname = `/customers/${params.id}/orders${searchParams}` as const;\n\n\t\treturn this.#restRequest<APICustomerOrdersBrowseResult>(pathname);\n\t}\n\n\t// ============================================\n\t// Inventory\n\t// ============================================\n\n\tasync inventoryBrowse(params: APIInventoryBrowseQueryParams = {}): Promise<APIInventoryBrowseResult> {\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.cursor) queryParams.append(\"cursor\", params.cursor);\n\t\tif (params.lowStock !== undefined) queryParams.append(\"lowStock\", params.lowStock.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/inventory${searchParams}` as const;\n\n\t\treturn this.#restRequest<APIInventoryBrowseResult>(pathname);\n\t}\n\n\tasync inventoryAdjust(sku: string, body: APIInventoryAdjustBody): Promise<APIInventoryAdjustResult> {\n\t\tconst pathname = `/inventory/${encodeURIComponent(sku)}/adjust` as const;\n\t\treturn this.#restRequest<APIInventoryAdjustResult>(pathname, \"POST\", body);\n\t}\n\n\t// ============================================\n\t// Variants\n\t// ============================================\n\n\tasync variantGet(params: APIVariantGetByIdParams): Promise<APIVariantGetByIdResult | null> {\n\t\tconst pathname = `/variants/${params.idOrSku}` as const;\n\t\treturn this.#restRequest<APIVariantGetByIdResult>(pathname);\n\t}\n\n\tasync variantUpdate(\n\t\tparams: APIVariantGetByIdParams,\n\t\tbody: APIVariantUpdateBody,\n\t): Promise<APIVariantUpdateResult> {\n\t\tconst pathname = `/variants/${params.idOrSku}` as const;\n\t\treturn this.#restRequest<APIVariantUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\tasync variantDelete(params: APIVariantGetByIdParams): Promise<void> {\n\t\tconst pathname = `/variants/${params.idOrSku}` as const;\n\t\tawait this.#restRequest<unknown>(pathname, \"DELETE\");\n\t}\n\n\tasync variantCreate(productId: string, body: APIVariantCreateBody): Promise<APIVariantCreateResult> {\n\t\tconst pathname = `/products/${productId}/variants` as const;\n\t\treturn this.#restRequest<APIVariantCreateResult>(pathname, \"POST\", body);\n\t}\n\n\t// ============================================\n\t// Subscribers\n\t// ============================================\n\n\tasync subscriberCreate(body: APISubscriberCreateBody): Promise<APISubscriberCreateResult> {\n\t\treturn this.#restRequest<APISubscriberCreateResult>(\"/subscribers\", \"POST\", body);\n\t}\n\n\tasync subscriberDelete(email: string): Promise<APISubscriberDeleteResult> {\n\t\tconst pathname = `/subscribers?email=${encodeURIComponent(email)}` as const;\n\t\treturn this.#restRequest<APISubscriberDeleteResult>(pathname, \"DELETE\");\n\t}\n\n\t// ============================================\n\t// Product mutations\n\t// ============================================\n\n\tasync productCreate(body: APIProductCreateBody): Promise<APIProductCreateResult> {\n\t\treturn this.#restRequest<APIProductCreateResult>(\"/products\", \"POST\", body);\n\t}\n\n\tasync productUpdate(\n\t\tparams: APIProductGetByIdParams,\n\t\tbody: APIProductUpdateBody,\n\t): Promise<APIProductUpdateResult> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APIProductUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\tasync productDelete(params: APIProductGetByIdParams): Promise<APIProductDeleteResult> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APIProductDeleteResult>(pathname, \"DELETE\");\n\t}\n\n\t// ============================================\n\t// Category mutations\n\t// ============================================\n\n\tasync categoryCreate(body: APICategoryCreateBody): Promise<APICategoryCreateResult> {\n\t\treturn this.#restRequest<APICategoryCreateResult>(\"/categories\", \"POST\", body);\n\t}\n\n\tasync categoryUpdate(\n\t\tparams: APICategoryGetByIdParams,\n\t\tbody: APICategoryUpdateBody,\n\t): Promise<APICategoryUpdateResult> {\n\t\tconst pathname = `/categories/${params.idOrSlug}` as const;\n\t\treturn this.#restRequest<APICategoryUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\t// ============================================\n\t// Order mutations\n\t// ============================================\n\n\tasync orderUpdate(params: APIOrderGetByIdParams, body: APIOrderUpdateBody): Promise<APIOrderUpdateResult> {\n\t\tconst pathname = `/orders/${params.id}` as const;\n\t\treturn this.#restRequest<APIOrderUpdateResult>(pathname, \"PUT\", body);\n\t}\n\n\t/**\n\t * Make a raw API request to any endpoint.\n\t * Use this for new API features not yet supported by typed methods.\n\t *\n\t * @example\n\t * // GET request (default method)\n\t * const webhooks = await provider.request<Webhook[]>('/webhooks');\n\t *\n\t * // POST with typed body\n\t * const webhook = await provider.request<Webhook, CreateWebhookBody>('/webhooks', {\n\t * method: 'POST',\n\t * body: { url: 'https://...' }\n\t * });\n\t *\n\t * // GET with query parameters\n\t * const products = await provider.request<Product[]>('/products', {\n\t * query: { limit: 10, category: 'shoes' }\n\t * });\n\t *\n\t * // Path parameters via template literals\n\t * const product = await provider.request<Product>(`/products/${id}`);\n\t */\n\tasync request<TResponse = unknown, TBody = unknown>(\n\t\tpathname: `/${string}`,\n\t\toptions?: {\n\t\t\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\t\t\tbody?: TBody;\n\t\t\tquery?: Record<string, string | number | boolean>;\n\t\t},\n\t) {\n\t\tconst queryString = options?.query\n\t\t\t? `?${new URLSearchParams(Object.entries(options.query).map(([k, v]) => [k, String(v)]))}`\n\t\t\t: \"\";\n\n\t\treturn this.#restRequest<TResponse>(`${pathname}${queryString}`, options?.method ?? \"GET\", options?.body);\n\t}\n}\n","import { YNSProvider } from \"./providers/yns\";\nimport type { CommerceConfig } from \"./types\";\n\nexport function Commerce(config: CommerceConfig = {}): YNSProvider {\n\treturn new YNSProvider(config);\n}\n"],"mappings":"4BAAA,IAAMA,EAAc,QAAQ,IAAI,YAEnBC,EAAM,CAClB,YAAAD,CACD,ECYA,IAAME,EAAW,CAChB,MAAO,EACP,IAAK,EACL,KAAM,EACN,MAAO,CACR,EAGMC,EAAe,QAAQ,IAAI,uBAAyB,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eAAeE,EAA+D,CACnF,OAAO,KAAKH,GAAsC,cAAe,OAAQG,CAAI,CAC9E,CAEA,MAAM,eACLS,EACAT,EACmC,CACnC,IAAMF,EAAW,eAAeW,EAAO,QAAQ,GAC/C,OAAO,KAAKZ,GAAsCC,EAAU,MAAOE,CAAI,CACxE,CAMA,MAAM,YAAYS,EAA+BT,EAAyD,CACzG,IAAMF,EAAW,WAAWW,EAAO,EAAE,GACrC,OAAO,KAAKZ,GAAmCC,EAAU,MAAOE,CAAI,CACrE,CAwBA,MAAM,QACLF,EACAkB,EAKC,CACD,IAAMC,EAAcD,GAAS,MAC1B,IAAI,IAAI,gBAAgB,OAAO,QAAQA,EAAQ,KAAK,EAAE,IAAI,CAAC,CAACE,EAAGC,CAAC,IAAM,CAACD,EAAG,OAAOC,CAAC,CAAC,CAAC,CAAC,CAAC,GACtF,GAEH,OAAO,KAAKtB,GAAwB,GAAGC,CAAQ,GAAGmB,CAAW,GAAID,GAAS,QAAU,MAAOA,GAAS,IAAI,CACzG,CACD,EC/gBO,SAASI,EAASC,EAAyB,CAAC,EAAgB,CAClE,OAAO,IAAIC,EAAYD,CAAM,CAC9B","names":["YNS_API_KEY","env","LogLevel","strLogLevel","valueLogLevel","RESET","BLUE","GREEN","YELLOW","RED","TIME","DEBUG","OK","WARN","ERROR","PREFIX_TIME","PREFIX_DEBUG","PREFIX_OK","PREFIX_WARN","PREFIX_ERROR","getLogger","groupLabel","PREFIX","subGroupLabel","label","args","item","options","logger","YNSProvider","#config","#logger","getLogger","config","token","env","isStaging","endpoint","#restRequest","pathname","method","body","logger","response","contentType","errorMessage","errorData","error","errorText","result","params","queryParams","urlParams","searchParams","sku","productId","email","options","queryString","k","v","Commerce","config","YNSProvider"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "commerce-kit",
4
- "version": "0.16.2",
4
+ "version": "0.18.0",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
7
7
  "keywords": [
@@ -41,22 +41,22 @@
41
41
  "prepare": "bun husky"
42
42
  },
43
43
  "devDependencies": {
44
- "@biomejs/biome": "2.3.8",
45
- "@types/node": "^24.10.1",
46
- "@typescript/native-preview": "7.0.0-dev.20251130.1",
44
+ "@biomejs/biome": "2.3.14",
45
+ "@types/node": "^24.10.10",
46
+ "@typescript/native-preview": "7.0.0-dev.20260203.1",
47
47
  "husky": "9.1.7",
48
48
  "lint-staged": "16.2.7",
49
49
  "rimraf": "6.1.2",
50
50
  "tsup": "8.5.1",
51
51
  "tsx": "^4.21.0",
52
52
  "typescript": "5.9.3",
53
- "zod": "^4.1.13"
53
+ "zod": "^4.3.6"
54
54
  },
55
55
  "peerDependencies": {
56
- "@types/node": "^24.3.0",
56
+ "@types/node": "^24.10.10",
57
57
  "typescript": "5.9.3",
58
58
  "@typescript/native-preview": "7.0.0-dev.20251022.1",
59
- "zod": "^4.1.5"
59
+ "zod": "^4.3.6"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "typescript": {