@fyul/embed-sdk 1.2.2 โ 2.0.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.
- package/README.md +2 -193
- package/dist/cjs/modules/catalog/catalogModule.d.ts +4 -3
- package/dist/cjs/modules/catalog/catalogModule.js +8 -9
- package/dist/cjs/modules/catalog/catalogService.d.ts +5 -3
- package/dist/cjs/modules/catalog/catalogService.js +16 -4
- package/dist/cjs/modules/catalog/events.d.ts +2 -0
- package/dist/cjs/modules/catalog/events.js +1 -0
- package/dist/cjs/modules/catalog/types/data.types.d.ts +2 -0
- package/dist/cjs/modules/catalog/types/event/actionEvent.types.d.ts +3 -2
- package/dist/cjs/modules/catalog/types/event/actionEventPayload.types.d.ts +6 -2
- package/dist/cjs/modules/eventTypes.d.ts +1 -1
- package/dist/cjs/modules/events.d.ts +2 -0
- package/dist/cjs/modules/mockup-generation/types/event/actionEventPayload.types.d.ts +8 -6
- package/dist/cjs/modules/product-publish/types/event/actionEventPayload.types.d.ts +4 -2
- package/dist/cjs/types/event/action/actionEvent.types.d.ts +2 -2
- package/dist/cjs/types/module/module.types.d.ts +4 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/modules/catalog/catalogModule.d.ts +4 -3
- package/dist/esm/modules/catalog/catalogModule.js +8 -9
- package/dist/esm/modules/catalog/catalogService.d.ts +5 -3
- package/dist/esm/modules/catalog/catalogService.js +16 -4
- package/dist/esm/modules/catalog/events.d.ts +2 -0
- package/dist/esm/modules/catalog/events.js +1 -0
- package/dist/esm/modules/catalog/types/data.types.d.ts +2 -0
- package/dist/esm/modules/catalog/types/event/actionEvent.types.d.ts +3 -2
- package/dist/esm/modules/catalog/types/event/actionEventPayload.types.d.ts +6 -2
- package/dist/esm/modules/eventTypes.d.ts +1 -1
- package/dist/esm/modules/events.d.ts +2 -0
- package/dist/esm/modules/mockup-generation/types/event/actionEventPayload.types.d.ts +8 -6
- package/dist/esm/modules/product-publish/types/event/actionEventPayload.types.d.ts +4 -2
- package/dist/esm/types/event/action/actionEvent.types.d.ts +2 -2
- package/dist/esm/types/module/module.types.d.ts +4 -3
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,198 +1,7 @@
|
|
|
1
|
-
# @
|
|
2
|
-
|
|
3
|
-
A TypeScript SDK for integrating with Printful services via iframe-based cross-origin communication. The SDK provides a modular architecture for catalog browsing, mockup generation, and other Printful services through secure iframe messaging.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- ๐ฏ **Modular Architecture**: Separate modules for different services (Catalog, Mockup Generation, SDK core)
|
|
8
|
-
- ๐ **Secure Communication**: iframe-based cross-origin messaging with correlation ID tracking
|
|
9
|
-
- ๐ฆ **Dual Package Support**: Both ESM and CommonJS builds included
|
|
10
|
-
- ๐งช **Fully Tested**: Comprehensive Jest test suite with 130+ tests and ~90% coverage
|
|
11
|
-
- ๐จ **TypeScript First**: Complete type safety with extensive type definitions
|
|
12
|
-
- ๐ง **Development Ready**: ESLint, Prettier, and modern tooling configured
|
|
1
|
+
# @fyul/embed-sdk
|
|
13
2
|
|
|
14
3
|
## Installation
|
|
15
4
|
|
|
16
5
|
```bash
|
|
17
|
-
npm install @
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Embed } from '@fyulorg/embed-sdk';
|
|
24
|
-
|
|
25
|
-
// Create SDK instance with your authentication nonce
|
|
26
|
-
const embedSdk = new Embed('your-nonce-here', {
|
|
27
|
-
targetOrigin: 'https://your-domain.com',
|
|
28
|
-
modules: [
|
|
29
|
-
{ name: 'catalog', data: { apiKey: 'your-api-key' } },
|
|
30
|
-
{ name: 'mockupGeneration', data: { timeout: 30000 } }
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Initialize connection
|
|
35
|
-
await embedSdk.init();
|
|
36
|
-
|
|
37
|
-
// Use catalog service
|
|
38
|
-
const products = await embedSdk.catalog.getProducts(123);
|
|
39
|
-
console.log('Products:', products);
|
|
40
|
-
|
|
41
|
-
// Use mockup service
|
|
42
|
-
const imageFile = new File(['...'], 'design.png', { type: 'image/png' });
|
|
43
|
-
const mockups = await embedSdk.mockup.getMockups(imageFile, [1, 2, 3]);
|
|
44
|
-
console.log('Generated mockups:', mockups);
|
|
45
|
-
|
|
46
|
-
// Clean up when done
|
|
47
|
-
embedSdk.destroy();
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## API Reference
|
|
51
|
-
|
|
52
|
-
### `new Embed(nonce, config?)`
|
|
53
|
-
|
|
54
|
-
Creates a new SDK instance.
|
|
55
|
-
|
|
56
|
-
**Parameters:**
|
|
57
|
-
- `nonce` (string): Authentication token from your backend
|
|
58
|
-
- `config` (optional): Configuration object
|
|
59
|
-
- `targetOrigin` (string): Target origin for iframe messages
|
|
60
|
-
- `modules` (array): Module configurations to initialize
|
|
61
|
-
|
|
62
|
-
### Core Methods
|
|
63
|
-
|
|
64
|
-
#### `embed.init(): Promise<void>`
|
|
65
|
-
Initializes the SDK, creates iframe, and establishes communication channel.
|
|
66
|
-
|
|
67
|
-
#### `embed.destroy(): void`
|
|
68
|
-
Cleans up resources, removes iframe, and clears all pending messages.
|
|
69
|
-
|
|
70
|
-
### Services
|
|
71
|
-
|
|
72
|
-
#### Catalog Service (`embed.catalog`)
|
|
73
|
-
```typescript
|
|
74
|
-
// Get products by category
|
|
75
|
-
const products = await embed.catalog.getProducts(categoryId);
|
|
76
|
-
|
|
77
|
-
// Get all categories
|
|
78
|
-
const categories = await embed.catalog.getCategories();
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### Mockup Service (`embed.mockup`)
|
|
82
|
-
```typescript
|
|
83
|
-
// Generate mockups from design file
|
|
84
|
-
const mockups = await embed.mockup.getMockups(
|
|
85
|
-
designFile, // Blob | File
|
|
86
|
-
productIds // number[] (optional)
|
|
87
|
-
);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Module System
|
|
91
|
-
|
|
92
|
-
The SDK uses a modular architecture where different services are loaded as separate modules:
|
|
93
|
-
|
|
94
|
-
- **SDK Module**: Core functionality and initialization
|
|
95
|
-
- **Catalog Module**: Product and category browsing
|
|
96
|
-
- **Mockup Generation Module**: Design-to-mockup conversion
|
|
97
|
-
|
|
98
|
-
Each module can be configured independently and loaded on-demand.
|
|
99
|
-
|
|
100
|
-
## Event System
|
|
101
|
-
|
|
102
|
-
The SDK implements a comprehensive event system for iframe communication:
|
|
103
|
-
|
|
104
|
-
- **Action Events**: Commands sent to the iframe (e.g., initialize, load module)
|
|
105
|
-
- **Result Events**: Successful responses from iframe operations
|
|
106
|
-
- **Notification Events**: Status updates and error notifications
|
|
107
|
-
|
|
108
|
-
All events include correlation IDs for request/response tracking.
|
|
109
|
-
|
|
110
|
-
## TypeScript Support
|
|
111
|
-
|
|
112
|
-
Full TypeScript support with extensive type definitions:
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import {
|
|
116
|
-
Embed,
|
|
117
|
-
CatalogModule,
|
|
118
|
-
MockupGenerationModule,
|
|
119
|
-
NotificationEvent,
|
|
120
|
-
ResultEvent,
|
|
121
|
-
handleResponse
|
|
122
|
-
} from '@fyulorg/embed-sdk';
|
|
123
|
-
|
|
124
|
-
// All types are fully typed
|
|
125
|
-
const embed = new Embed('nonce');
|
|
126
|
-
const result: CatalogModule.GetProductsResult = await embed.catalog.getProducts(1);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Development
|
|
130
|
-
|
|
131
|
-
### Setup
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
# Install dependencies
|
|
135
|
-
npm install
|
|
136
|
-
|
|
137
|
-
# Run tests
|
|
138
|
-
npm test
|
|
139
|
-
npm run test:watch
|
|
140
|
-
npm run test:coverage
|
|
141
|
-
|
|
142
|
-
# Build
|
|
143
|
-
npm run build
|
|
144
|
-
|
|
145
|
-
# Lint and format
|
|
146
|
-
npm run lint
|
|
147
|
-
npm run prettier
|
|
148
|
-
npm run lint:fix
|
|
149
|
-
npm run prettier:fix
|
|
6
|
+
npm install @fyul/embed-sdk
|
|
150
7
|
```
|
|
151
|
-
|
|
152
|
-
### Project Structure
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
src/
|
|
156
|
-
โโโ index.ts # Main SDK export
|
|
157
|
-
โโโ services/ # Core services
|
|
158
|
-
โ โโโ embedCommunicator.ts
|
|
159
|
-
โ โโโ iFrameManager.ts
|
|
160
|
-
โ โโโ messagebroker.ts
|
|
161
|
-
โ โโโ moduleLoaderService.ts
|
|
162
|
-
โโโ modules/ # Feature modules
|
|
163
|
-
โ โโโ catalog/
|
|
164
|
-
โ โโโ mockup-generation/
|
|
165
|
-
โ โโโ sdk/
|
|
166
|
-
โโโ types/ # Shared type definitions
|
|
167
|
-
โ โโโ event/
|
|
168
|
-
โ โโโ module/
|
|
169
|
-
โโโ helpers/ # Utility functions
|
|
170
|
-
|
|
171
|
-
tests/ # Test files (mirrors src structure)
|
|
172
|
-
โโโ services/
|
|
173
|
-
โโโ modules/
|
|
174
|
-
โโโ helpers/
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Import Aliases
|
|
178
|
-
|
|
179
|
-
The project uses `~` aliases for clean imports:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
import { EmbedCommunicator } from '~/services/embedCommunicator';
|
|
183
|
-
import { CatalogModule } from '~/modules/catalog/catalogModule';
|
|
184
|
-
import { Event } from '~/types/event/event.types';
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Building
|
|
188
|
-
|
|
189
|
-
The project builds to both ESM and CommonJS formats:
|
|
190
|
-
|
|
191
|
-
- **ESM**: `dist/esm/` - Modern ES modules
|
|
192
|
-
- **CJS**: `dist/cjs/` - Compatible CommonJS modules
|
|
193
|
-
|
|
194
|
-
The build process uses TypeScript compilation followed by `tsc-alias` for path resolution.
|
|
195
|
-
|
|
196
|
-
## License
|
|
197
|
-
|
|
198
|
-
ISC
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ICatalogModule } from '../../types/module/module.types';
|
|
2
2
|
import { BaseModule } from '../../modules/baseModule';
|
|
3
|
-
import { GetCatalogCategoriesResultPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductResultPayload } from './types';
|
|
3
|
+
import { GetCatalogCategoriesResultPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductPayload, GetSingleCatalogProductResultPayload } from './types';
|
|
4
4
|
import { WithHandledResponses } from '../../helpers/typeHelper.types';
|
|
5
5
|
export declare class CatalogModule extends BaseModule implements WithHandledResponses<ICatalogModule> {
|
|
6
|
-
getProducts(
|
|
7
|
-
|
|
6
|
+
getProducts(data: GetCatalogProductsPayload): Promise<import("../..").HandledResponse<GetCatalogProductsResultPayload, Error>>;
|
|
7
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): Promise<import("../..").HandledResponse<GetCatalogProductsResultPayload, Error>>;
|
|
8
|
+
getProduct(data: GetSingleCatalogProductPayload): Promise<import("../..").HandledResponse<GetSingleCatalogProductResultPayload, Error>>;
|
|
8
9
|
getCategories(): Promise<import("../..").HandledResponse<GetCatalogCategoriesResultPayload, Error>>;
|
|
9
10
|
}
|
|
@@ -5,17 +5,16 @@ const baseModule_1 = require("../../modules/baseModule");
|
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const responseHandler_1 = require("../../helpers/responseHandler");
|
|
7
7
|
class CatalogModule extends baseModule_1.BaseModule {
|
|
8
|
-
async getProducts(
|
|
9
|
-
const response = await this.sendRequest(types_1.EVENTS_ACTION.GET_CATALOG_PRODUCTS,
|
|
10
|
-
categoryId,
|
|
11
|
-
page,
|
|
12
|
-
}).catch((e) => e);
|
|
8
|
+
async getProducts(data) {
|
|
9
|
+
const response = await this.sendRequest(types_1.EVENTS_ACTION.GET_CATALOG_PRODUCTS, data).catch((e) => e);
|
|
13
10
|
return (0, responseHandler_1.handleResponse)(response, 'Failed to get catalog products');
|
|
14
11
|
}
|
|
15
|
-
async
|
|
16
|
-
const response = await this.sendRequest(types_1.EVENTS_ACTION.
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
async getProductsByIds(data) {
|
|
13
|
+
const response = await this.sendRequest(types_1.EVENTS_ACTION.GET_CATALOG_PRODUCTS_BY_IDS, data).catch((e) => e);
|
|
14
|
+
return (0, responseHandler_1.handleResponse)(response, 'Failed to get catalog products');
|
|
15
|
+
}
|
|
16
|
+
async getProduct(data) {
|
|
17
|
+
const response = await this.sendRequest(types_1.EVENTS_ACTION.GET_SINGLE_CATALOG_PRODUCT, data).catch((e) => e);
|
|
19
18
|
return (0, responseHandler_1.handleResponse)(response, 'Failed to get catalog products');
|
|
20
19
|
}
|
|
21
20
|
async getCategories() {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseModuleService } from '../../modules/baseModuleService';
|
|
2
|
+
import { GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../modules/catalog/types';
|
|
2
3
|
export declare class CatalogService extends BaseModuleService {
|
|
3
4
|
private getCatalogModule;
|
|
4
|
-
getCategories(): Promise<import("../..").HandledResponse<import("
|
|
5
|
-
getProducts(
|
|
6
|
-
|
|
5
|
+
getCategories(): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogCategoriesResultPayload, Error>>;
|
|
6
|
+
getProducts(data: GetCatalogProductsPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogProductsResultPayload, Error>>;
|
|
7
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogProductsResultPayload, Error> | null>;
|
|
8
|
+
getProduct(data: GetSingleCatalogProductPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetSingleCatalogProductResultPayload, Error>>;
|
|
7
9
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CatalogService = void 0;
|
|
4
4
|
const baseModuleService_1 = require("../../modules/baseModuleService");
|
|
5
5
|
const modules_1 = require("../../modules/modules");
|
|
6
|
+
const messageLogger_1 = require("../../helpers/messageLogger");
|
|
6
7
|
class CatalogService extends baseModuleService_1.BaseModuleService {
|
|
7
8
|
async getCatalogModule() {
|
|
8
9
|
return this.ensureModuleLoaded(modules_1.MODULE_NAMES.CATALOG);
|
|
@@ -11,13 +12,24 @@ class CatalogService extends baseModuleService_1.BaseModuleService {
|
|
|
11
12
|
const module = await this.getCatalogModule();
|
|
12
13
|
return module.getCategories();
|
|
13
14
|
}
|
|
14
|
-
async getProducts(
|
|
15
|
+
async getProducts(data) {
|
|
15
16
|
const module = await this.getCatalogModule();
|
|
16
|
-
return module.getProducts(
|
|
17
|
+
return module.getProducts(data);
|
|
17
18
|
}
|
|
18
|
-
async
|
|
19
|
+
async getProductsByIds(data) {
|
|
20
|
+
if (!data.productIds.length) {
|
|
21
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
22
|
+
logType: messageLogger_1.LOG_TYPES.ERROR,
|
|
23
|
+
message: 'Empty productIds argument!',
|
|
24
|
+
});
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
19
27
|
const module = await this.getCatalogModule();
|
|
20
|
-
return module.
|
|
28
|
+
return module.getProductsByIds(data);
|
|
29
|
+
}
|
|
30
|
+
async getProduct(data) {
|
|
31
|
+
const module = await this.getCatalogModule();
|
|
32
|
+
return module.getProduct(data);
|
|
21
33
|
}
|
|
22
34
|
}
|
|
23
35
|
exports.CatalogService = CatalogService;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const EVENTS_ACTION: {
|
|
2
2
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
3
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
3
4
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
4
5
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
5
6
|
};
|
|
@@ -21,6 +22,7 @@ export declare const EVENTS: {
|
|
|
21
22
|
readonly GET_SINGLE_CATALOG_PRODUCT_FAILURE: "actionGetSingleCatalogProductFailure";
|
|
22
23
|
readonly GET_CATALOG_CATEGORIES_FAILURE: "actionGetCatalogCategoriesFailure";
|
|
23
24
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
25
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
24
26
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
25
27
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
26
28
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EVENTS = exports.EVENTS_RESULT = exports.EVENTS_NOTIFICATION = exports.EVENTS_ACTION = void 0;
|
|
4
4
|
exports.EVENTS_ACTION = {
|
|
5
5
|
GET_CATALOG_PRODUCTS: 'actionGetCatalogProducts',
|
|
6
|
+
GET_CATALOG_PRODUCTS_BY_IDS: 'actionGetCatalogProductsByIds',
|
|
6
7
|
GET_SINGLE_CATALOG_PRODUCT: 'actionGetSingleCatalogProduct',
|
|
7
8
|
GET_CATALOG_CATEGORIES: 'actionGetCatalogCategories',
|
|
8
9
|
};
|
|
@@ -3,6 +3,7 @@ export interface CatalogProduct {
|
|
|
3
3
|
productId: number;
|
|
4
4
|
title: string;
|
|
5
5
|
price?: number;
|
|
6
|
+
priceWithTax?: number;
|
|
6
7
|
currency?: string;
|
|
7
8
|
urlImage?: string;
|
|
8
9
|
colorsSizes: {
|
|
@@ -82,6 +83,7 @@ export interface ProductVariant {
|
|
|
82
83
|
}
|
|
83
84
|
export interface VariantPriceData {
|
|
84
85
|
price: number;
|
|
86
|
+
priceWithTax: number;
|
|
85
87
|
currency: string;
|
|
86
88
|
currencySymbol: string;
|
|
87
89
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EVENTS_ACTION } from '../../../../modules/catalog/events';
|
|
2
|
-
import type { GetCatalogCategoriesPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../../../modules/catalog/types';
|
|
2
|
+
import type { GetCatalogCategoriesPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../../../modules/catalog/types';
|
|
3
3
|
import { BaseActionEvent } from '../../../../types/event/action/actionEvent.types';
|
|
4
4
|
export type GetCatalogProductsAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_PRODUCTS, GetCatalogProductsPayload>;
|
|
5
|
+
export type GetCatalogProductsByIdsAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_PRODUCTS_BY_IDS, GetCatalogProductsByIdsPayload>;
|
|
5
6
|
export type GetSingleCatalogProductAction = BaseActionEvent<typeof EVENTS_ACTION.GET_SINGLE_CATALOG_PRODUCT, GetSingleCatalogProductPayload>;
|
|
6
7
|
export type GetCatalogCategoriesAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_CATEGORIES, GetCatalogCategoriesPayload>;
|
|
7
|
-
export type ActionEvent = GetCatalogCategoriesAction | GetCatalogProductsAction | GetSingleCatalogProductAction;
|
|
8
|
+
export type ActionEvent = GetCatalogCategoriesAction | GetCatalogProductsByIdsAction | GetCatalogProductsAction | GetSingleCatalogProductAction;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export interface GetCatalogProductsPayload {
|
|
2
2
|
categoryId: number;
|
|
3
|
-
page
|
|
3
|
+
page?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface GetCatalogProductsByIdsPayload {
|
|
6
|
+
productIds: number[];
|
|
7
|
+
page?: number;
|
|
4
8
|
}
|
|
5
9
|
export interface GetSingleCatalogProductPayload {
|
|
6
10
|
productId: number;
|
|
@@ -8,4 +12,4 @@ export interface GetSingleCatalogProductPayload {
|
|
|
8
12
|
export interface GetCatalogCategoriesPayload {
|
|
9
13
|
level: number;
|
|
10
14
|
}
|
|
11
|
-
export type ActionEventPayload = GetCatalogCategoriesPayload | GetCatalogProductsPayload | GetSingleCatalogProductPayload;
|
|
15
|
+
export type ActionEventPayload = GetCatalogProductsByIdsPayload | GetCatalogCategoriesPayload | GetCatalogProductsPayload | GetSingleCatalogProductPayload;
|
|
@@ -4,6 +4,6 @@ export declare const EVENT_TYPES: {
|
|
|
4
4
|
readonly NOTIFICATION: "notification";
|
|
5
5
|
readonly RESULT: "result";
|
|
6
6
|
};
|
|
7
|
-
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./product-publish/types").GetProductPublishAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction;
|
|
7
|
+
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./product-publish/types").GetProductPublishAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsByIdsAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction;
|
|
8
8
|
export declare function isNotification(event: AnyEvent): event is import("..").NotificationEvent;
|
|
9
9
|
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./mockup-generation/types").GetMockupsResultEvent;
|
|
@@ -2,6 +2,7 @@ export declare const ALL_ACTION_EVENTS: {
|
|
|
2
2
|
readonly PRODUCT_PUBLISH: "actionProductPublish";
|
|
3
3
|
readonly GET_MOCKUPS: "actionGetMockups";
|
|
4
4
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
5
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
5
6
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
6
7
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
7
8
|
readonly INITIALIZE_SDK: "actionInitializeSdk";
|
|
@@ -37,6 +38,7 @@ export declare const ALL_EVENTS: {
|
|
|
37
38
|
readonly PRODUCT_PUBLISH: "actionProductPublish";
|
|
38
39
|
readonly GET_MOCKUPS: "actionGetMockups";
|
|
39
40
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
41
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
40
42
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
41
43
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
42
44
|
readonly INITIALIZE_SDK: "actionInitializeSdk";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export interface InitializeMockupDataPayload {
|
|
2
|
-
productIds: number[];
|
|
3
|
-
}
|
|
4
1
|
export interface GetMockupsPayload {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** File from which to generate mockups */
|
|
3
|
+
file: Blob;
|
|
4
|
+
/** List of all products and their variants to fetch mockups for */
|
|
5
|
+
products: {
|
|
7
6
|
productId: number;
|
|
8
7
|
variantIds: number[];
|
|
9
8
|
}[];
|
|
9
|
+
/** Optional mapping of productId โ selected variantId.
|
|
10
|
+
* If not provided, the first variant from each product will be used. */
|
|
11
|
+
selectedVariants?: Record<string, number>;
|
|
10
12
|
}
|
|
11
|
-
export type ActionEventPayload = GetMockupsPayload
|
|
13
|
+
export type ActionEventPayload = GetMockupsPayload;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface GetProductPublishPayload {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
file: Blob;
|
|
3
|
+
/** List of all products and their variants to generate templates for */
|
|
4
|
+
products: {
|
|
4
5
|
productId: number;
|
|
6
|
+
/** Should not be empty, otherwise will fail to publish */
|
|
5
7
|
variantIds: number[];
|
|
6
8
|
}[];
|
|
7
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionEvent as SdkActionEvent
|
|
1
|
+
import { ActionEvent as SdkActionEvent } from '../../../modules/sdk/types/event/actionEvent.types';
|
|
2
2
|
import { ActionEvent as CatalogActionEvent } from '../../../modules/catalog/types/event/actionEvent.types';
|
|
3
3
|
import { ActionEvent as MockupGenerationActionEvent } from '../../../modules/mockup-generation/types/event/actionEvent.types';
|
|
4
4
|
import { ActionEvent as ProductPublishActionEvent } from '../../../modules/product-publish/types/event/actionEvent.types';
|
|
@@ -8,4 +8,4 @@ import { EVENT_TYPES } from '../../../modules/eventTypes';
|
|
|
8
8
|
import { ActionEventPayload } from './actionEventPayload.types';
|
|
9
9
|
export type ActionEventName = (typeof ALL_ACTION_EVENTS)[keyof typeof ALL_ACTION_EVENTS];
|
|
10
10
|
export type BaseActionEvent<TName extends ActionEventName, TPayload extends ActionEventPayload> = Event<TName, typeof EVENT_TYPES.ACTION, TPayload>;
|
|
11
|
-
export type ActionEvent =
|
|
11
|
+
export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MODULE_NAMES } from '../../modules/modules';
|
|
2
2
|
import { GetMockupsPayload, GetMockupsResultPayload } from '../../modules/mockup-generation/types';
|
|
3
3
|
import { SdkModuleConfigData } from '../../modules/sdk/types';
|
|
4
|
-
import { GetCatalogCategoriesResultPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductResultPayload } from '../../modules/catalog/types';
|
|
4
|
+
import { GetCatalogCategoriesResultPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductPayload, GetSingleCatalogProductResultPayload } from '../../modules/catalog/types';
|
|
5
5
|
import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
|
|
6
6
|
import { GetProductPublishPayload, ProductPublishData } from '../../modules/product-publish/types';
|
|
7
7
|
/** This file ensures that Iframe and SDK has the same source of truth for return values */
|
|
@@ -10,8 +10,9 @@ export interface ISdkModule {
|
|
|
10
10
|
setup(config?: SdkModuleConfigData): Promise<NotificationEventPayload> | Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export interface ICatalogModule {
|
|
13
|
-
getProducts(
|
|
14
|
-
|
|
13
|
+
getProducts(data: GetCatalogProductsPayload): GetCatalogProductsResultPayload;
|
|
14
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): GetCatalogProductsResultPayload;
|
|
15
|
+
getProduct(data: GetSingleCatalogProductPayload): GetSingleCatalogProductResultPayload;
|
|
15
16
|
getCategories(): GetCatalogCategoriesResultPayload;
|
|
16
17
|
}
|
|
17
18
|
export interface IMockupGenerationModule {
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION: "
|
|
1
|
+
export declare const VERSION: "2.0.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ICatalogModule } from '../../types/module/module.types';
|
|
2
2
|
import { BaseModule } from '../../modules/baseModule';
|
|
3
|
-
import { GetCatalogCategoriesResultPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductResultPayload } from './types';
|
|
3
|
+
import { GetCatalogCategoriesResultPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductPayload, GetSingleCatalogProductResultPayload } from './types';
|
|
4
4
|
import { WithHandledResponses } from '../../helpers/typeHelper.types';
|
|
5
5
|
export declare class CatalogModule extends BaseModule implements WithHandledResponses<ICatalogModule> {
|
|
6
|
-
getProducts(
|
|
7
|
-
|
|
6
|
+
getProducts(data: GetCatalogProductsPayload): Promise<import("../..").HandledResponse<GetCatalogProductsResultPayload, Error>>;
|
|
7
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): Promise<import("../..").HandledResponse<GetCatalogProductsResultPayload, Error>>;
|
|
8
|
+
getProduct(data: GetSingleCatalogProductPayload): Promise<import("../..").HandledResponse<GetSingleCatalogProductResultPayload, Error>>;
|
|
8
9
|
getCategories(): Promise<import("../..").HandledResponse<GetCatalogCategoriesResultPayload, Error>>;
|
|
9
10
|
}
|
|
@@ -2,17 +2,16 @@ import { BaseModule } from '../../modules/baseModule';
|
|
|
2
2
|
import { EVENTS_ACTION, } from './types';
|
|
3
3
|
import { handleResponse } from '../../helpers/responseHandler';
|
|
4
4
|
export class CatalogModule extends BaseModule {
|
|
5
|
-
async getProducts(
|
|
6
|
-
const response = await this.sendRequest(EVENTS_ACTION.GET_CATALOG_PRODUCTS,
|
|
7
|
-
categoryId,
|
|
8
|
-
page,
|
|
9
|
-
}).catch((e) => e);
|
|
5
|
+
async getProducts(data) {
|
|
6
|
+
const response = await this.sendRequest(EVENTS_ACTION.GET_CATALOG_PRODUCTS, data).catch((e) => e);
|
|
10
7
|
return handleResponse(response, 'Failed to get catalog products');
|
|
11
8
|
}
|
|
12
|
-
async
|
|
13
|
-
const response = await this.sendRequest(EVENTS_ACTION.
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
async getProductsByIds(data) {
|
|
10
|
+
const response = await this.sendRequest(EVENTS_ACTION.GET_CATALOG_PRODUCTS_BY_IDS, data).catch((e) => e);
|
|
11
|
+
return handleResponse(response, 'Failed to get catalog products');
|
|
12
|
+
}
|
|
13
|
+
async getProduct(data) {
|
|
14
|
+
const response = await this.sendRequest(EVENTS_ACTION.GET_SINGLE_CATALOG_PRODUCT, data).catch((e) => e);
|
|
16
15
|
return handleResponse(response, 'Failed to get catalog products');
|
|
17
16
|
}
|
|
18
17
|
async getCategories() {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseModuleService } from '../../modules/baseModuleService';
|
|
2
|
+
import { GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../modules/catalog/types';
|
|
2
3
|
export declare class CatalogService extends BaseModuleService {
|
|
3
4
|
private getCatalogModule;
|
|
4
|
-
getCategories(): Promise<import("../..").HandledResponse<import("
|
|
5
|
-
getProducts(
|
|
6
|
-
|
|
5
|
+
getCategories(): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogCategoriesResultPayload, Error>>;
|
|
6
|
+
getProducts(data: GetCatalogProductsPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogProductsResultPayload, Error>>;
|
|
7
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetCatalogProductsResultPayload, Error> | null>;
|
|
8
|
+
getProduct(data: GetSingleCatalogProductPayload): Promise<import("../..").HandledResponse<import("../../modules/catalog/types").GetSingleCatalogProductResultPayload, Error>>;
|
|
7
9
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseModuleService } from '../../modules/baseModuleService';
|
|
2
2
|
import { MODULE_NAMES } from '../../modules/modules';
|
|
3
|
+
import { LOG_TYPES, logEmbedMessage } from '../../helpers/messageLogger';
|
|
3
4
|
export class CatalogService extends BaseModuleService {
|
|
4
5
|
async getCatalogModule() {
|
|
5
6
|
return this.ensureModuleLoaded(MODULE_NAMES.CATALOG);
|
|
@@ -8,12 +9,23 @@ export class CatalogService extends BaseModuleService {
|
|
|
8
9
|
const module = await this.getCatalogModule();
|
|
9
10
|
return module.getCategories();
|
|
10
11
|
}
|
|
11
|
-
async getProducts(
|
|
12
|
+
async getProducts(data) {
|
|
12
13
|
const module = await this.getCatalogModule();
|
|
13
|
-
return module.getProducts(
|
|
14
|
+
return module.getProducts(data);
|
|
14
15
|
}
|
|
15
|
-
async
|
|
16
|
+
async getProductsByIds(data) {
|
|
17
|
+
if (!data.productIds.length) {
|
|
18
|
+
logEmbedMessage({
|
|
19
|
+
logType: LOG_TYPES.ERROR,
|
|
20
|
+
message: 'Empty productIds argument!',
|
|
21
|
+
});
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
16
24
|
const module = await this.getCatalogModule();
|
|
17
|
-
return module.
|
|
25
|
+
return module.getProductsByIds(data);
|
|
26
|
+
}
|
|
27
|
+
async getProduct(data) {
|
|
28
|
+
const module = await this.getCatalogModule();
|
|
29
|
+
return module.getProduct(data);
|
|
18
30
|
}
|
|
19
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const EVENTS_ACTION: {
|
|
2
2
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
3
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
3
4
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
4
5
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
5
6
|
};
|
|
@@ -21,6 +22,7 @@ export declare const EVENTS: {
|
|
|
21
22
|
readonly GET_SINGLE_CATALOG_PRODUCT_FAILURE: "actionGetSingleCatalogProductFailure";
|
|
22
23
|
readonly GET_CATALOG_CATEGORIES_FAILURE: "actionGetCatalogCategoriesFailure";
|
|
23
24
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
25
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
24
26
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
25
27
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
26
28
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const EVENTS_ACTION = {
|
|
2
2
|
GET_CATALOG_PRODUCTS: 'actionGetCatalogProducts',
|
|
3
|
+
GET_CATALOG_PRODUCTS_BY_IDS: 'actionGetCatalogProductsByIds',
|
|
3
4
|
GET_SINGLE_CATALOG_PRODUCT: 'actionGetSingleCatalogProduct',
|
|
4
5
|
GET_CATALOG_CATEGORIES: 'actionGetCatalogCategories',
|
|
5
6
|
};
|
|
@@ -3,6 +3,7 @@ export interface CatalogProduct {
|
|
|
3
3
|
productId: number;
|
|
4
4
|
title: string;
|
|
5
5
|
price?: number;
|
|
6
|
+
priceWithTax?: number;
|
|
6
7
|
currency?: string;
|
|
7
8
|
urlImage?: string;
|
|
8
9
|
colorsSizes: {
|
|
@@ -82,6 +83,7 @@ export interface ProductVariant {
|
|
|
82
83
|
}
|
|
83
84
|
export interface VariantPriceData {
|
|
84
85
|
price: number;
|
|
86
|
+
priceWithTax: number;
|
|
85
87
|
currency: string;
|
|
86
88
|
currencySymbol: string;
|
|
87
89
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EVENTS_ACTION } from '../../../../modules/catalog/events';
|
|
2
|
-
import type { GetCatalogCategoriesPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../../../modules/catalog/types';
|
|
2
|
+
import type { GetCatalogCategoriesPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetSingleCatalogProductPayload } from '../../../../modules/catalog/types';
|
|
3
3
|
import { BaseActionEvent } from '../../../../types/event/action/actionEvent.types';
|
|
4
4
|
export type GetCatalogProductsAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_PRODUCTS, GetCatalogProductsPayload>;
|
|
5
|
+
export type GetCatalogProductsByIdsAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_PRODUCTS_BY_IDS, GetCatalogProductsByIdsPayload>;
|
|
5
6
|
export type GetSingleCatalogProductAction = BaseActionEvent<typeof EVENTS_ACTION.GET_SINGLE_CATALOG_PRODUCT, GetSingleCatalogProductPayload>;
|
|
6
7
|
export type GetCatalogCategoriesAction = BaseActionEvent<typeof EVENTS_ACTION.GET_CATALOG_CATEGORIES, GetCatalogCategoriesPayload>;
|
|
7
|
-
export type ActionEvent = GetCatalogCategoriesAction | GetCatalogProductsAction | GetSingleCatalogProductAction;
|
|
8
|
+
export type ActionEvent = GetCatalogCategoriesAction | GetCatalogProductsByIdsAction | GetCatalogProductsAction | GetSingleCatalogProductAction;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export interface GetCatalogProductsPayload {
|
|
2
2
|
categoryId: number;
|
|
3
|
-
page
|
|
3
|
+
page?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface GetCatalogProductsByIdsPayload {
|
|
6
|
+
productIds: number[];
|
|
7
|
+
page?: number;
|
|
4
8
|
}
|
|
5
9
|
export interface GetSingleCatalogProductPayload {
|
|
6
10
|
productId: number;
|
|
@@ -8,4 +12,4 @@ export interface GetSingleCatalogProductPayload {
|
|
|
8
12
|
export interface GetCatalogCategoriesPayload {
|
|
9
13
|
level: number;
|
|
10
14
|
}
|
|
11
|
-
export type ActionEventPayload = GetCatalogCategoriesPayload | GetCatalogProductsPayload | GetSingleCatalogProductPayload;
|
|
15
|
+
export type ActionEventPayload = GetCatalogProductsByIdsPayload | GetCatalogCategoriesPayload | GetCatalogProductsPayload | GetSingleCatalogProductPayload;
|
|
@@ -4,6 +4,6 @@ export declare const EVENT_TYPES: {
|
|
|
4
4
|
readonly NOTIFICATION: "notification";
|
|
5
5
|
readonly RESULT: "result";
|
|
6
6
|
};
|
|
7
|
-
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./product-publish/types").GetProductPublishAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction;
|
|
7
|
+
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./product-publish/types").GetProductPublishAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsByIdsAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction;
|
|
8
8
|
export declare function isNotification(event: AnyEvent): event is import("..").NotificationEvent;
|
|
9
9
|
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./mockup-generation/types").GetMockupsResultEvent;
|
|
@@ -2,6 +2,7 @@ export declare const ALL_ACTION_EVENTS: {
|
|
|
2
2
|
readonly PRODUCT_PUBLISH: "actionProductPublish";
|
|
3
3
|
readonly GET_MOCKUPS: "actionGetMockups";
|
|
4
4
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
5
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
5
6
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
6
7
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
7
8
|
readonly INITIALIZE_SDK: "actionInitializeSdk";
|
|
@@ -37,6 +38,7 @@ export declare const ALL_EVENTS: {
|
|
|
37
38
|
readonly PRODUCT_PUBLISH: "actionProductPublish";
|
|
38
39
|
readonly GET_MOCKUPS: "actionGetMockups";
|
|
39
40
|
readonly GET_CATALOG_PRODUCTS: "actionGetCatalogProducts";
|
|
41
|
+
readonly GET_CATALOG_PRODUCTS_BY_IDS: "actionGetCatalogProductsByIds";
|
|
40
42
|
readonly GET_SINGLE_CATALOG_PRODUCT: "actionGetSingleCatalogProduct";
|
|
41
43
|
readonly GET_CATALOG_CATEGORIES: "actionGetCatalogCategories";
|
|
42
44
|
readonly INITIALIZE_SDK: "actionInitializeSdk";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export interface InitializeMockupDataPayload {
|
|
2
|
-
productIds: number[];
|
|
3
|
-
}
|
|
4
1
|
export interface GetMockupsPayload {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** File from which to generate mockups */
|
|
3
|
+
file: Blob;
|
|
4
|
+
/** List of all products and their variants to fetch mockups for */
|
|
5
|
+
products: {
|
|
7
6
|
productId: number;
|
|
8
7
|
variantIds: number[];
|
|
9
8
|
}[];
|
|
9
|
+
/** Optional mapping of productId โ selected variantId.
|
|
10
|
+
* If not provided, the first variant from each product will be used. */
|
|
11
|
+
selectedVariants?: Record<string, number>;
|
|
10
12
|
}
|
|
11
|
-
export type ActionEventPayload = GetMockupsPayload
|
|
13
|
+
export type ActionEventPayload = GetMockupsPayload;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface GetProductPublishPayload {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
file: Blob;
|
|
3
|
+
/** List of all products and their variants to generate templates for */
|
|
4
|
+
products: {
|
|
4
5
|
productId: number;
|
|
6
|
+
/** Should not be empty, otherwise will fail to publish */
|
|
5
7
|
variantIds: number[];
|
|
6
8
|
}[];
|
|
7
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionEvent as SdkActionEvent
|
|
1
|
+
import { ActionEvent as SdkActionEvent } from '../../../modules/sdk/types/event/actionEvent.types';
|
|
2
2
|
import { ActionEvent as CatalogActionEvent } from '../../../modules/catalog/types/event/actionEvent.types';
|
|
3
3
|
import { ActionEvent as MockupGenerationActionEvent } from '../../../modules/mockup-generation/types/event/actionEvent.types';
|
|
4
4
|
import { ActionEvent as ProductPublishActionEvent } from '../../../modules/product-publish/types/event/actionEvent.types';
|
|
@@ -8,4 +8,4 @@ import { EVENT_TYPES } from '../../../modules/eventTypes';
|
|
|
8
8
|
import { ActionEventPayload } from './actionEventPayload.types';
|
|
9
9
|
export type ActionEventName = (typeof ALL_ACTION_EVENTS)[keyof typeof ALL_ACTION_EVENTS];
|
|
10
10
|
export type BaseActionEvent<TName extends ActionEventName, TPayload extends ActionEventPayload> = Event<TName, typeof EVENT_TYPES.ACTION, TPayload>;
|
|
11
|
-
export type ActionEvent =
|
|
11
|
+
export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MODULE_NAMES } from '../../modules/modules';
|
|
2
2
|
import { GetMockupsPayload, GetMockupsResultPayload } from '../../modules/mockup-generation/types';
|
|
3
3
|
import { SdkModuleConfigData } from '../../modules/sdk/types';
|
|
4
|
-
import { GetCatalogCategoriesResultPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductResultPayload } from '../../modules/catalog/types';
|
|
4
|
+
import { GetCatalogCategoriesResultPayload, GetCatalogProductsByIdsPayload, GetCatalogProductsPayload, GetCatalogProductsResultPayload, GetSingleCatalogProductPayload, GetSingleCatalogProductResultPayload } from '../../modules/catalog/types';
|
|
5
5
|
import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
|
|
6
6
|
import { GetProductPublishPayload, ProductPublishData } from '../../modules/product-publish/types';
|
|
7
7
|
/** This file ensures that Iframe and SDK has the same source of truth for return values */
|
|
@@ -10,8 +10,9 @@ export interface ISdkModule {
|
|
|
10
10
|
setup(config?: SdkModuleConfigData): Promise<NotificationEventPayload> | Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export interface ICatalogModule {
|
|
13
|
-
getProducts(
|
|
14
|
-
|
|
13
|
+
getProducts(data: GetCatalogProductsPayload): GetCatalogProductsResultPayload;
|
|
14
|
+
getProductsByIds(data: GetCatalogProductsByIdsPayload): GetCatalogProductsResultPayload;
|
|
15
|
+
getProduct(data: GetSingleCatalogProductPayload): GetSingleCatalogProductResultPayload;
|
|
15
16
|
getCategories(): GetCatalogCategoriesResultPayload;
|
|
16
17
|
}
|
|
17
18
|
export interface IMockupGenerationModule {
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION: "
|
|
1
|
+
export declare const VERSION: "2.0.0";
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// AUTO-GENERATED
|
|
2
|
-
export const VERSION = '
|
|
2
|
+
export const VERSION = '2.0.0';
|