@canveletedotcom/sdk 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +2 -1
- package/dist/resources/render.d.ts +3 -1
- package/dist/resources/render.js +7 -3
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -16,7 +16,8 @@ export class CanveleteClient {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(options = {}) {
|
|
18
18
|
this.apiKey = options.apiKey || '';
|
|
19
|
-
|
|
19
|
+
// Default to backend API for direct rendering
|
|
20
|
+
this.baseUrl = (options.baseUrl || 'https://api.canvelete.com').replace(/\/$/, '');
|
|
20
21
|
this.timeout = options.timeout || 30000;
|
|
21
22
|
// Initialize resource handlers
|
|
22
23
|
this.designs = new DesignsResource(this);
|
|
@@ -7,6 +7,7 @@ export interface RenderOptions {
|
|
|
7
7
|
designId?: string;
|
|
8
8
|
templateId?: string;
|
|
9
9
|
dynamicData?: Record<string, any>;
|
|
10
|
+
dynamicElements?: Record<string, any>;
|
|
10
11
|
format?: 'png' | 'jpg' | 'jpeg' | 'pdf' | 'svg';
|
|
11
12
|
width?: number;
|
|
12
13
|
height?: number;
|
|
@@ -47,6 +48,7 @@ export declare class RenderResource {
|
|
|
47
48
|
constructor(client: CanveleteClient);
|
|
48
49
|
/**
|
|
49
50
|
* Create a synchronous render (waits for completion)
|
|
51
|
+
* Uses the backend API directly at /api/v1/render
|
|
50
52
|
*/
|
|
51
53
|
create(options: RenderOptions): Promise<ArrayBuffer>;
|
|
52
54
|
/**
|
|
@@ -80,7 +82,7 @@ export declare class RenderResource {
|
|
|
80
82
|
pollInterval?: number;
|
|
81
83
|
}): Promise<RenderRecord[]>;
|
|
82
84
|
/**
|
|
83
|
-
* List render history
|
|
85
|
+
* List render history
|
|
84
86
|
*/
|
|
85
87
|
list(options?: ListRenderOptions): Promise<PaginatedResponse<RenderRecord>>;
|
|
86
88
|
/**
|
package/dist/resources/render.js
CHANGED
|
@@ -9,6 +9,7 @@ export class RenderResource {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Create a synchronous render (waits for completion)
|
|
12
|
+
* Uses the backend API directly at /api/v1/render
|
|
12
13
|
*/
|
|
13
14
|
async create(options) {
|
|
14
15
|
if (!options.designId && !options.templateId) {
|
|
@@ -22,13 +23,16 @@ export class RenderResource {
|
|
|
22
23
|
data.designId = options.designId;
|
|
23
24
|
if (options.templateId)
|
|
24
25
|
data.templateId = options.templateId;
|
|
26
|
+
// Support both dynamicData and dynamicElements for flexibility
|
|
25
27
|
if (options.dynamicData)
|
|
26
28
|
data.dynamicData = options.dynamicData;
|
|
29
|
+
if (options.dynamicElements)
|
|
30
|
+
data.dynamicElements = options.dynamicElements;
|
|
27
31
|
if (options.width)
|
|
28
32
|
data.width = options.width;
|
|
29
33
|
if (options.height)
|
|
30
34
|
data.height = options.height;
|
|
31
|
-
const imageData = await this.client.request('POST', '/api/
|
|
35
|
+
const imageData = await this.client.request('POST', '/api/v1/render', {
|
|
32
36
|
json: data,
|
|
33
37
|
binary: true,
|
|
34
38
|
});
|
|
@@ -140,14 +144,14 @@ export class RenderResource {
|
|
|
140
144
|
throw new Error(`Batch render timed out after ${timeout}ms`);
|
|
141
145
|
}
|
|
142
146
|
/**
|
|
143
|
-
* List render history
|
|
147
|
+
* List render history
|
|
144
148
|
*/
|
|
145
149
|
async list(options = {}) {
|
|
146
150
|
const params = {
|
|
147
151
|
page: String(options.page || 1),
|
|
148
152
|
limit: String(options.limit || 20),
|
|
149
153
|
};
|
|
150
|
-
return await this.client.request('GET', '/api/
|
|
154
|
+
return await this.client.request('GET', '/api/v1/render/history', { params });
|
|
151
155
|
}
|
|
152
156
|
/**
|
|
153
157
|
* Iterate through all render records with automatic pagination
|