@abpjs/text-template-management 3.1.0 → 3.2.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/dist/index.js CHANGED
@@ -172,74 +172,85 @@ var TEXT_TEMPLATE_MANAGEMENT_ROUTES = {
172
172
  ]
173
173
  };
174
174
 
175
- // src/services/template-definition.service.ts
175
+ // src/proxy/text-templates/template-definition.service.ts
176
176
  var TemplateDefinitionService = class {
177
177
  constructor(restService) {
178
178
  this.restService = restService;
179
179
  /**
180
180
  * API name for multi-API configurations
181
- * @since 2.7.0
181
+ * @since 3.2.0
182
182
  */
183
183
  this.apiName = "default";
184
184
  }
185
185
  /**
186
- * Get list of template definitions
187
- * @param params Query parameters for filtering and pagination
188
- * @returns Promise with list of template definitions
186
+ * Get a template definition by name
187
+ * @param name Template name
188
+ * @returns Promise with template definition
189
189
  */
190
- async getList(params = {}) {
190
+ async get(name) {
191
+ return this.restService.request({
192
+ method: "GET",
193
+ url: `/api/text-template-management/template-definitions/${name}`
194
+ });
195
+ }
196
+ /**
197
+ * Get paginated list of template definitions
198
+ * @param input Query parameters for filtering and pagination
199
+ * @returns Promise with paginated template definitions response
200
+ */
201
+ async getList(input = {}) {
191
202
  return this.restService.request({
192
203
  method: "GET",
193
204
  url: "/api/text-template-management/template-definitions",
194
- params
205
+ params: input
195
206
  });
196
207
  }
197
208
  };
198
209
 
199
- // src/services/template-content.service.ts
210
+ // src/proxy/text-templates/template-content.service.ts
200
211
  var TemplateContentService = class {
201
212
  constructor(restService) {
202
213
  this.restService = restService;
203
214
  /**
204
215
  * API name for multi-API configurations
205
- * @since 2.7.0
216
+ * @since 3.2.0
206
217
  */
207
218
  this.apiName = "default";
208
219
  }
209
220
  /**
210
- * Get template content by input parameters
211
- * @param params Input parameters containing template name and optional culture name
221
+ * Get template content
222
+ * @param input Input containing template name and culture name
212
223
  * @returns Promise with template content
213
224
  */
214
- async getByInput(params) {
225
+ async get(input) {
215
226
  return this.restService.request({
216
227
  method: "GET",
217
228
  url: "/api/text-template-management/template-contents",
218
- params
229
+ params: input
219
230
  });
220
231
  }
221
232
  /**
222
233
  * Restore template content to default
223
- * @param body Input containing template name and culture name to restore
234
+ * @param input Input containing template name and culture name
224
235
  * @returns Promise that resolves when restore is complete
225
236
  */
226
- async restoreToDefaultByInput(body) {
237
+ async restoreToDefault(input) {
227
238
  return this.restService.request({
228
239
  method: "PUT",
229
240
  url: "/api/text-template-management/template-contents/restore-to-default",
230
- body
241
+ body: input
231
242
  });
232
243
  }
233
244
  /**
234
245
  * Update template content
235
- * @param body DTO containing template name, culture name, and new content
246
+ * @param input Input containing template name, culture name, and content
236
247
  * @returns Promise with updated template content
237
248
  */
238
- async updateByInput(body) {
249
+ async update(input) {
239
250
  return this.restService.request({
240
251
  method: "PUT",
241
252
  url: "/api/text-template-management/template-contents",
242
- body
253
+ body: input
243
254
  });
244
255
  }
245
256
  };
@@ -289,21 +300,28 @@ var TextTemplateManagementStateService = class {
289
300
  /**
290
301
  * Dispatch action to fetch template definitions
291
302
  * @param params Query parameters for filtering and pagination
292
- * @returns Promise with list result
303
+ * @returns Promise with paged result
304
+ * @updated 3.2.0 - Now returns PagedResultDto instead of ListResultDto
293
305
  */
294
306
  async dispatchGetTemplateDefinitions(params = {}) {
295
307
  const result = await this.templateDefinitionService.getList(params);
296
308
  this._state.templateDefinitions = result.items || [];
297
- this._state.totalCount = this._state.templateDefinitions.length;
309
+ this._state.totalCount = result.totalCount ?? this._state.templateDefinitions.length;
298
310
  return result;
299
311
  }
300
312
  /**
301
313
  * Dispatch action to get template content
302
- * @param params Input containing template name and optional culture name
314
+ * @param params Input containing template name and culture name
303
315
  * @returns Promise with template content
304
316
  */
305
317
  async dispatchGetTemplateContent(params) {
306
- const result = await this.templateContentService.getByInput(params);
318
+ if (!params.cultureName) {
319
+ throw new Error("cultureName is required for getting template content");
320
+ }
321
+ const result = await this.templateContentService.get({
322
+ templateName: params.templateName,
323
+ cultureName: params.cultureName
324
+ });
307
325
  this._state.templateContent = result;
308
326
  return result;
309
327
  }
@@ -313,7 +331,11 @@ var TextTemplateManagementStateService = class {
313
331
  * @returns Promise with updated template content
314
332
  */
315
333
  async dispatchUpdateTemplateContent(body) {
316
- const result = await this.templateContentService.updateByInput(body);
334
+ const result = await this.templateContentService.update({
335
+ templateName: body.templateName,
336
+ cultureName: body.cultureName,
337
+ content: body.content
338
+ });
317
339
  this._state.templateContent = result;
318
340
  return result;
319
341
  }
@@ -323,10 +345,14 @@ var TextTemplateManagementStateService = class {
323
345
  * @returns Promise that resolves when restore is complete
324
346
  */
325
347
  async dispatchRestoreToDefault(body) {
326
- await this.templateContentService.restoreToDefaultByInput(body);
327
- if (body.cultureName) {
328
- await this.dispatchGetTemplateContent(body);
348
+ if (!body.cultureName) {
349
+ throw new Error("cultureName is required for restoring template content");
329
350
  }
351
+ await this.templateContentService.restoreToDefault({
352
+ templateName: body.templateName,
353
+ cultureName: body.cultureName
354
+ });
355
+ await this.dispatchGetTemplateContent(body);
330
356
  }
331
357
  /**
332
358
  * Set the selected template
@@ -401,14 +427,88 @@ var TEXT_TEMPLATE_MANAGEMENT_ENTITY_PROP_CONTRIBUTORS = /* @__PURE__ */ Symbol(
401
427
  // src/hooks/useTextTemplates.ts
402
428
  var import_react2 = require("react");
403
429
  var import_core = require("@abpjs/core");
430
+
431
+ // src/services/template-definition.service.ts
432
+ var TemplateDefinitionService2 = class {
433
+ constructor(restService) {
434
+ this.restService = restService;
435
+ /**
436
+ * API name for multi-API configurations
437
+ * @since 2.7.0
438
+ */
439
+ this.apiName = "default";
440
+ }
441
+ /**
442
+ * Get list of template definitions
443
+ * @param params Query parameters for filtering and pagination
444
+ * @returns Promise with list of template definitions
445
+ */
446
+ async getList(params = {}) {
447
+ return this.restService.request({
448
+ method: "GET",
449
+ url: "/api/text-template-management/template-definitions",
450
+ params
451
+ });
452
+ }
453
+ };
454
+
455
+ // src/services/template-content.service.ts
456
+ var TemplateContentService2 = class {
457
+ constructor(restService) {
458
+ this.restService = restService;
459
+ /**
460
+ * API name for multi-API configurations
461
+ * @since 2.7.0
462
+ */
463
+ this.apiName = "default";
464
+ }
465
+ /**
466
+ * Get template content by input parameters
467
+ * @param params Input parameters containing template name and optional culture name
468
+ * @returns Promise with template content
469
+ */
470
+ async getByInput(params) {
471
+ return this.restService.request({
472
+ method: "GET",
473
+ url: "/api/text-template-management/template-contents",
474
+ params
475
+ });
476
+ }
477
+ /**
478
+ * Restore template content to default
479
+ * @param body Input containing template name and culture name to restore
480
+ * @returns Promise that resolves when restore is complete
481
+ */
482
+ async restoreToDefaultByInput(body) {
483
+ return this.restService.request({
484
+ method: "PUT",
485
+ url: "/api/text-template-management/template-contents/restore-to-default",
486
+ body
487
+ });
488
+ }
489
+ /**
490
+ * Update template content
491
+ * @param body DTO containing template name, culture name, and new content
492
+ * @returns Promise with updated template content
493
+ */
494
+ async updateByInput(body) {
495
+ return this.restService.request({
496
+ method: "PUT",
497
+ url: "/api/text-template-management/template-contents",
498
+ body
499
+ });
500
+ }
501
+ };
502
+
503
+ // src/hooks/useTextTemplates.ts
404
504
  function useTextTemplates() {
405
505
  const restService = (0, import_core.useRestService)();
406
506
  const templateDefinitionService = (0, import_react2.useMemo)(
407
- () => new TemplateDefinitionService(restService),
507
+ () => new TemplateDefinitionService2(restService),
408
508
  [restService]
409
509
  );
410
510
  const templateContentService = (0, import_react2.useMemo)(
411
- () => new TemplateContentService(restService),
511
+ () => new TemplateContentService2(restService),
412
512
  [restService]
413
513
  );
414
514
  const [templateDefinitions, setTemplateDefinitions] = (0, import_react2.useState)([]);
package/dist/index.mjs CHANGED
@@ -120,74 +120,85 @@ var TEXT_TEMPLATE_MANAGEMENT_ROUTES = {
120
120
  ]
121
121
  };
122
122
 
123
- // src/services/template-definition.service.ts
123
+ // src/proxy/text-templates/template-definition.service.ts
124
124
  var TemplateDefinitionService = class {
125
125
  constructor(restService) {
126
126
  this.restService = restService;
127
127
  /**
128
128
  * API name for multi-API configurations
129
- * @since 2.7.0
129
+ * @since 3.2.0
130
130
  */
131
131
  this.apiName = "default";
132
132
  }
133
133
  /**
134
- * Get list of template definitions
135
- * @param params Query parameters for filtering and pagination
136
- * @returns Promise with list of template definitions
134
+ * Get a template definition by name
135
+ * @param name Template name
136
+ * @returns Promise with template definition
137
137
  */
138
- async getList(params = {}) {
138
+ async get(name) {
139
+ return this.restService.request({
140
+ method: "GET",
141
+ url: `/api/text-template-management/template-definitions/${name}`
142
+ });
143
+ }
144
+ /**
145
+ * Get paginated list of template definitions
146
+ * @param input Query parameters for filtering and pagination
147
+ * @returns Promise with paginated template definitions response
148
+ */
149
+ async getList(input = {}) {
139
150
  return this.restService.request({
140
151
  method: "GET",
141
152
  url: "/api/text-template-management/template-definitions",
142
- params
153
+ params: input
143
154
  });
144
155
  }
145
156
  };
146
157
 
147
- // src/services/template-content.service.ts
158
+ // src/proxy/text-templates/template-content.service.ts
148
159
  var TemplateContentService = class {
149
160
  constructor(restService) {
150
161
  this.restService = restService;
151
162
  /**
152
163
  * API name for multi-API configurations
153
- * @since 2.7.0
164
+ * @since 3.2.0
154
165
  */
155
166
  this.apiName = "default";
156
167
  }
157
168
  /**
158
- * Get template content by input parameters
159
- * @param params Input parameters containing template name and optional culture name
169
+ * Get template content
170
+ * @param input Input containing template name and culture name
160
171
  * @returns Promise with template content
161
172
  */
162
- async getByInput(params) {
173
+ async get(input) {
163
174
  return this.restService.request({
164
175
  method: "GET",
165
176
  url: "/api/text-template-management/template-contents",
166
- params
177
+ params: input
167
178
  });
168
179
  }
169
180
  /**
170
181
  * Restore template content to default
171
- * @param body Input containing template name and culture name to restore
182
+ * @param input Input containing template name and culture name
172
183
  * @returns Promise that resolves when restore is complete
173
184
  */
174
- async restoreToDefaultByInput(body) {
185
+ async restoreToDefault(input) {
175
186
  return this.restService.request({
176
187
  method: "PUT",
177
188
  url: "/api/text-template-management/template-contents/restore-to-default",
178
- body
189
+ body: input
179
190
  });
180
191
  }
181
192
  /**
182
193
  * Update template content
183
- * @param body DTO containing template name, culture name, and new content
194
+ * @param input Input containing template name, culture name, and content
184
195
  * @returns Promise with updated template content
185
196
  */
186
- async updateByInput(body) {
197
+ async update(input) {
187
198
  return this.restService.request({
188
199
  method: "PUT",
189
200
  url: "/api/text-template-management/template-contents",
190
- body
201
+ body: input
191
202
  });
192
203
  }
193
204
  };
@@ -237,21 +248,28 @@ var TextTemplateManagementStateService = class {
237
248
  /**
238
249
  * Dispatch action to fetch template definitions
239
250
  * @param params Query parameters for filtering and pagination
240
- * @returns Promise with list result
251
+ * @returns Promise with paged result
252
+ * @updated 3.2.0 - Now returns PagedResultDto instead of ListResultDto
241
253
  */
242
254
  async dispatchGetTemplateDefinitions(params = {}) {
243
255
  const result = await this.templateDefinitionService.getList(params);
244
256
  this._state.templateDefinitions = result.items || [];
245
- this._state.totalCount = this._state.templateDefinitions.length;
257
+ this._state.totalCount = result.totalCount ?? this._state.templateDefinitions.length;
246
258
  return result;
247
259
  }
248
260
  /**
249
261
  * Dispatch action to get template content
250
- * @param params Input containing template name and optional culture name
262
+ * @param params Input containing template name and culture name
251
263
  * @returns Promise with template content
252
264
  */
253
265
  async dispatchGetTemplateContent(params) {
254
- const result = await this.templateContentService.getByInput(params);
266
+ if (!params.cultureName) {
267
+ throw new Error("cultureName is required for getting template content");
268
+ }
269
+ const result = await this.templateContentService.get({
270
+ templateName: params.templateName,
271
+ cultureName: params.cultureName
272
+ });
255
273
  this._state.templateContent = result;
256
274
  return result;
257
275
  }
@@ -261,7 +279,11 @@ var TextTemplateManagementStateService = class {
261
279
  * @returns Promise with updated template content
262
280
  */
263
281
  async dispatchUpdateTemplateContent(body) {
264
- const result = await this.templateContentService.updateByInput(body);
282
+ const result = await this.templateContentService.update({
283
+ templateName: body.templateName,
284
+ cultureName: body.cultureName,
285
+ content: body.content
286
+ });
265
287
  this._state.templateContent = result;
266
288
  return result;
267
289
  }
@@ -271,10 +293,14 @@ var TextTemplateManagementStateService = class {
271
293
  * @returns Promise that resolves when restore is complete
272
294
  */
273
295
  async dispatchRestoreToDefault(body) {
274
- await this.templateContentService.restoreToDefaultByInput(body);
275
- if (body.cultureName) {
276
- await this.dispatchGetTemplateContent(body);
296
+ if (!body.cultureName) {
297
+ throw new Error("cultureName is required for restoring template content");
277
298
  }
299
+ await this.templateContentService.restoreToDefault({
300
+ templateName: body.templateName,
301
+ cultureName: body.cultureName
302
+ });
303
+ await this.dispatchGetTemplateContent(body);
278
304
  }
279
305
  /**
280
306
  * Set the selected template
@@ -349,14 +375,88 @@ var TEXT_TEMPLATE_MANAGEMENT_ENTITY_PROP_CONTRIBUTORS = /* @__PURE__ */ Symbol(
349
375
  // src/hooks/useTextTemplates.ts
350
376
  import { useState as useState2, useCallback, useMemo } from "react";
351
377
  import { useRestService } from "@abpjs/core";
378
+
379
+ // src/services/template-definition.service.ts
380
+ var TemplateDefinitionService2 = class {
381
+ constructor(restService) {
382
+ this.restService = restService;
383
+ /**
384
+ * API name for multi-API configurations
385
+ * @since 2.7.0
386
+ */
387
+ this.apiName = "default";
388
+ }
389
+ /**
390
+ * Get list of template definitions
391
+ * @param params Query parameters for filtering and pagination
392
+ * @returns Promise with list of template definitions
393
+ */
394
+ async getList(params = {}) {
395
+ return this.restService.request({
396
+ method: "GET",
397
+ url: "/api/text-template-management/template-definitions",
398
+ params
399
+ });
400
+ }
401
+ };
402
+
403
+ // src/services/template-content.service.ts
404
+ var TemplateContentService2 = class {
405
+ constructor(restService) {
406
+ this.restService = restService;
407
+ /**
408
+ * API name for multi-API configurations
409
+ * @since 2.7.0
410
+ */
411
+ this.apiName = "default";
412
+ }
413
+ /**
414
+ * Get template content by input parameters
415
+ * @param params Input parameters containing template name and optional culture name
416
+ * @returns Promise with template content
417
+ */
418
+ async getByInput(params) {
419
+ return this.restService.request({
420
+ method: "GET",
421
+ url: "/api/text-template-management/template-contents",
422
+ params
423
+ });
424
+ }
425
+ /**
426
+ * Restore template content to default
427
+ * @param body Input containing template name and culture name to restore
428
+ * @returns Promise that resolves when restore is complete
429
+ */
430
+ async restoreToDefaultByInput(body) {
431
+ return this.restService.request({
432
+ method: "PUT",
433
+ url: "/api/text-template-management/template-contents/restore-to-default",
434
+ body
435
+ });
436
+ }
437
+ /**
438
+ * Update template content
439
+ * @param body DTO containing template name, culture name, and new content
440
+ * @returns Promise with updated template content
441
+ */
442
+ async updateByInput(body) {
443
+ return this.restService.request({
444
+ method: "PUT",
445
+ url: "/api/text-template-management/template-contents",
446
+ body
447
+ });
448
+ }
449
+ };
450
+
451
+ // src/hooks/useTextTemplates.ts
352
452
  function useTextTemplates() {
353
453
  const restService = useRestService();
354
454
  const templateDefinitionService = useMemo(
355
- () => new TemplateDefinitionService(restService),
455
+ () => new TemplateDefinitionService2(restService),
356
456
  [restService]
357
457
  );
358
458
  const templateContentService = useMemo(
359
- () => new TemplateContentService(restService),
459
+ () => new TemplateContentService2(restService),
360
460
  [restService]
361
461
  );
362
462
  const [templateDefinitions, setTemplateDefinitions] = useState2([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/text-template-management",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "ABP Framework text-template-management components for React - translated from @volo/abp.ng.text-template-management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,11 +25,11 @@
25
25
  "dependencies": {
26
26
  "@chakra-ui/react": "^3.2.0",
27
27
  "@emotion/react": "^11.11.0",
28
- "@abpjs/core": "3.1.0",
29
- "@abpjs/theme-shared": "3.1.0"
28
+ "@abpjs/core": "3.2.0",
29
+ "@abpjs/theme-shared": "3.2.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@volo/abp.ng.text-template-management": "3.1.0",
32
+ "@volo/abp.ng.text-template-management": "3.2.0",
33
33
  "@testing-library/jest-dom": "^6.9.1",
34
34
  "@testing-library/react": "^14.0.0",
35
35
  "@testing-library/user-event": "^14.6.1",