@ptkl/sdk 1.3.2 → 1.4.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.
@@ -65,16 +65,17 @@ type Model = {
65
65
  [key: string]: any;
66
66
  };
67
67
  type UpdateOptions = {
68
- forceUpdateProtectedFields: boolean;
68
+ force_update_protected_fields: boolean;
69
69
  };
70
70
  type UpdateManyOptions = UpdateOptions & {
71
- rollbackOnError: boolean;
71
+ rollback_on_error: boolean;
72
72
  };
73
73
  type CreateManyOptions = {
74
- rollbackOnError: boolean;
74
+ rollback_on_error: boolean;
75
75
  };
76
76
  type ModifyOptions = {
77
77
  upsert: boolean;
78
+ force_update_protected_fields?: boolean;
78
79
  };
79
80
  type ComponentOptions = {
80
81
  version?: string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * PlatformFunctions is an open interface that serves as a registry of platform
3
+ * function signatures. It is empty by default and can be extended in two ways:
4
+ *
5
+ * 1. **At build time** — run `ptkl generate-types` to fetch your project's
6
+ * functions and emit a `.d.ts` file with a module augmentation block:
7
+ * ```ts
8
+ * declare module "@ptkl/sdk" {
9
+ * interface PlatformFunctions {
10
+ * "send_email": { input: { body: string; to: string }; output: { status: boolean } }
11
+ * }
12
+ * }
13
+ * ```
14
+ *
15
+ * 2. **At runtime in Monaco editors** — the editor auto-patches the interface
16
+ * from your project's live function signatures.
17
+ */
18
+ export interface PlatformFunctions {
19
+ }
20
+ /**
21
+ * Access a single platform function's signature type by name.
22
+ *
23
+ * @example
24
+ * type EmailSig = PlatformFunction<"send_email">
25
+ * // → { input: { body: string; to: string }; output: { status: boolean } }
26
+ */
27
+ export type PlatformFunction<K extends keyof PlatformFunctions> = PlatformFunctions[K];
28
+ /** Inferred input type for a registered function, falling back to a generic record. */
29
+ export type FunctionInput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
30
+ input: infer I;
31
+ } ? I : Record<string, any>;
32
+ /** Inferred output type for a registered function, falling back to any. */
33
+ export type FunctionOutput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
34
+ output: infer O;
35
+ } ? O : any;
36
+ /** Parameters shape for a typed function call. */
37
+ export type FunctionCallParams<K extends keyof PlatformFunctions> = {
38
+ input: FunctionInput<K>;
39
+ query?: Record<string, string>;
40
+ headers?: Record<string, string>;
41
+ };
@@ -0,0 +1,199 @@
1
+ export type IDNamePair = {
2
+ id: string;
3
+ name: string;
4
+ };
5
+ export type ShippingMethodsConfig = {
6
+ methods: IDNamePair[];
7
+ };
8
+ export type PaymentMethodsConfig = {
9
+ methods: IDNamePair[];
10
+ };
11
+ export type PaymentProvidersConfig = {
12
+ options?: IDNamePair;
13
+ };
14
+ export type CartSettings = {
15
+ shipping_methods: ShippingMethodsConfig;
16
+ payment_methods: PaymentMethodsConfig;
17
+ payment_providers: PaymentProvidersConfig;
18
+ };
19
+ export type PriceSettings = {
20
+ default_currency: IDNamePair;
21
+ };
22
+ export type I18nSettings = {
23
+ default_locale: IDNamePair;
24
+ locales: IDNamePair[];
25
+ };
26
+ export type LogoConfig = {
27
+ position: number;
28
+ src: string;
29
+ alt: string;
30
+ width: number;
31
+ height: number;
32
+ };
33
+ export type ItemsConfig = {
34
+ position: number;
35
+ menu: IDNamePair;
36
+ };
37
+ export type ActionsConfig = {
38
+ position: number;
39
+ icons: Record<string, any>;
40
+ };
41
+ export type HeaderSettings = {
42
+ logo: LogoConfig;
43
+ items: ItemsConfig;
44
+ actions: ActionsConfig;
45
+ };
46
+ export type HomepageSection = {
47
+ id: string;
48
+ type: string;
49
+ show: boolean;
50
+ settings: Record<string, any>;
51
+ };
52
+ export type HomepageSettings = {
53
+ sections: HomepageSection[];
54
+ };
55
+ export type CategoryInfoConfig = {
56
+ text_position: IDNamePair;
57
+ show_title: boolean;
58
+ show_description: boolean;
59
+ show_image: boolean;
60
+ };
61
+ export type CategoryHeaderConfig = {
62
+ use_breadcrumbs: boolean;
63
+ category_info: CategoryInfoConfig;
64
+ };
65
+ export type CategoryFiltersConfig = {
66
+ show: boolean;
67
+ type: IDNamePair;
68
+ use_accordion: boolean;
69
+ };
70
+ export type CategorySettings = {
71
+ header: CategoryHeaderConfig;
72
+ filters: CategoryFiltersConfig;
73
+ };
74
+ export type DisplayConfig = {
75
+ show: boolean;
76
+ text_position: IDNamePair;
77
+ position: number;
78
+ };
79
+ export type SimpleDisplayConfig = {
80
+ show: boolean;
81
+ };
82
+ export type InventoryConfig = {
83
+ show: boolean;
84
+ text_position: IDNamePair;
85
+ position: number;
86
+ allow_backorder: boolean;
87
+ };
88
+ export type ActionButtonConfig = {
89
+ icon: IDNamePair;
90
+ button_variant: IDNamePair;
91
+ show: boolean;
92
+ };
93
+ export type ProductActionsConfig = {
94
+ position: number;
95
+ align: IDNamePair;
96
+ add_to_cart: ActionButtonConfig;
97
+ add_to_wishlist: ActionButtonConfig;
98
+ };
99
+ export type QuantitySelectorConfig = {
100
+ show: boolean;
101
+ text_position: IDNamePair;
102
+ };
103
+ export type ProductInfoConfig = {
104
+ title: DisplayConfig;
105
+ sku: DisplayConfig;
106
+ stock_status: SimpleDisplayConfig;
107
+ inventory: InventoryConfig;
108
+ description: DisplayConfig;
109
+ variants: DisplayConfig;
110
+ price: DisplayConfig;
111
+ actions: ProductActionsConfig;
112
+ discount_badge?: SimpleDisplayConfig;
113
+ quantity_selector?: QuantitySelectorConfig;
114
+ specifications?: SimpleDisplayConfig;
115
+ };
116
+ export type ProductSettings = {
117
+ product_info: ProductInfoConfig;
118
+ };
119
+ export type FooterLogoConfig = {
120
+ src: string;
121
+ alt: string;
122
+ width: number;
123
+ height: number;
124
+ };
125
+ export type FooterColumnOne = {
126
+ logo: FooterLogoConfig;
127
+ socials: any[];
128
+ };
129
+ export type FooterSettings = {
130
+ column_one: FooterColumnOne;
131
+ };
132
+ export type EcommerceSettings = {
133
+ maintenance: boolean;
134
+ cart: CartSettings;
135
+ price: PriceSettings;
136
+ i18n: I18nSettings;
137
+ header: HeaderSettings;
138
+ homepage: HomepageSettings;
139
+ category: CategorySettings;
140
+ product: ProductSettings;
141
+ footer: FooterSettings;
142
+ theme?: any;
143
+ };
144
+ export type EcommEnvSettings = {
145
+ dev: EcommerceSettings | null;
146
+ live: EcommerceSettings | null;
147
+ };
148
+ export type CompanyInfo = {
149
+ vat_number: string;
150
+ legal_name: string;
151
+ company_name: string;
152
+ address: string;
153
+ city: string;
154
+ zip_code: string;
155
+ phone: string;
156
+ email: string;
157
+ legal_representative: string;
158
+ additional_info?: Record<string, any>;
159
+ };
160
+ export type Documentation = {
161
+ terms_of_service: string | null;
162
+ privacy_policy: string | null;
163
+ };
164
+ export type EcommerceIntegrationUser = {
165
+ project_uuid: string;
166
+ base_domain: string;
167
+ custom_domains: string[];
168
+ company: CompanyInfo;
169
+ merchant_description: string;
170
+ mcc: string[];
171
+ documentation: Documentation;
172
+ product_types: string[];
173
+ settings: EcommEnvSettings;
174
+ data: Record<string, any>;
175
+ created_at: string;
176
+ updated_at: string;
177
+ deleted_at?: string | null;
178
+ };
179
+ export type UpdateEcommerceSettingsRequest = {
180
+ base_domain?: string;
181
+ custom_domains?: string[];
182
+ company?: Partial<CompanyInfo>;
183
+ merchant_description?: string;
184
+ mcc?: string[];
185
+ product_types?: string[];
186
+ documentation?: Partial<Documentation>;
187
+ settings?: Partial<EcommEnvSettings>;
188
+ };
189
+ export type CheckDomainResponse = {
190
+ domain: string;
191
+ available: boolean;
192
+ };
193
+ export type AddDomainResponse = {
194
+ integration: EcommerceIntegrationUser;
195
+ verification_token: string;
196
+ };
197
+ export type DomainsResponse = {
198
+ domains: string[];
199
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
@@ -13,17 +13,17 @@
13
13
  ".": {
14
14
  "import": "./dist/v0.9/index.esm.js",
15
15
  "require": "./dist/v0.9/index.cjs.js",
16
- "types": "./dist/v0.9/index.d.ts"
16
+ "types": "./dist/v0.9/api/index.d.ts"
17
17
  },
18
18
  "./beta": {
19
19
  "import": "./dist/v0.10/index.esm.js",
20
20
  "require": "./dist/v0.10/index.cjs.js",
21
- "types": "./dist/v0.10/index.d.ts"
21
+ "types": "./dist/v0.10/api/index.d.ts"
22
22
  }
23
23
  },
24
24
  "main": "./dist/v0.10/index.cjs.js",
25
25
  "module": "./dist/v0.10/index.esm.js",
26
- "types": "./dist/v0.10/index.d.ts",
26
+ "types": "./dist/v0.10/api/index.d.ts",
27
27
  "author": "protokol.io",
28
28
  "license": "ISC",
29
29
  "type": "module",
@@ -44,6 +44,7 @@
44
44
  "typescript": "^5.6.3"
45
45
  },
46
46
  "dependencies": {
47
+ "@ptkl/sdk": "file:",
47
48
  "@rollup/plugin-replace": "^6.0.2",
48
49
  "axios": "^1.7.7",
49
50
  "dom-parser": "^1.1.5",