@yimingliao/cms 0.0.22 → 0.0.24

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.
@@ -612,7 +612,7 @@ interface ServerActionOptions {
612
612
  key?: RawCacheKey;
613
613
  ttl?: number;
614
614
  }
615
- declare function createExecuteAction({ initI18n, cacheResult, cache, logger, }: CreateServerActionOptions): Promise<(<D = void>(fn: Action<D>, options?: ServerActionOptions) => Promise<Result<D>>)>;
615
+ declare function createExecuteAction({ initI18n, cacheResult, cache, logger, }: CreateServerActionOptions): <D = void>(fn: Action<D>, options?: ServerActionOptions) => Promise<Result<D>>;
616
616
 
617
617
  declare const normalizeError: (error: unknown, translator: BaseTranslator<LocaleMessages>) => {
618
618
  message: string;
@@ -629,6 +629,14 @@ declare class ServerError extends Error {
629
629
  i18nKey?: string;
630
630
  statusCode?: number;
631
631
  });
632
+ /** 401 Unauthorized */
633
+ static unauthorized(): ServerError;
634
+ /** 403 Forbidden */
635
+ static forbidden(): ServerError;
636
+ /** 404 Not found */
637
+ static notFound(): ServerError;
638
+ /** 500 Internal Server Error */
639
+ static internalServerError(): ServerError;
632
640
  }
633
641
 
634
642
  export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, type RawCacheKey, ServerError, createAdminCommandRepository, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenQueryRepository, createArgon2Service, createCache, createCacheResult, createCookieService, createCryptoService, createExecuteAction, createFileCommandRepository, createFileQueryRepository, createFolderCommandRepository, createFolderQueryRepository, createIpRateLimiter, createJwtService, createPostCommandRepository, createPostQueryRepository, createSeoMetadataCommandRepository, normalizeCacheKey, normalizeError };
@@ -1423,7 +1423,7 @@ function createSeoMetadataCommandRepository(prisma) {
1423
1423
  }
1424
1424
 
1425
1425
  // src/server/server-error.ts
1426
- var ServerError = class extends Error {
1426
+ var ServerError = class _ServerError extends Error {
1427
1427
  i18nKey;
1428
1428
  statusCode;
1429
1429
  constructor({
@@ -1436,6 +1436,25 @@ var ServerError = class extends Error {
1436
1436
  if (i18nKey) this.i18nKey = i18nKey;
1437
1437
  if (statusCode) this.statusCode = statusCode;
1438
1438
  }
1439
+ /** 401 Unauthorized */
1440
+ static unauthorized() {
1441
+ return new _ServerError({ i18nKey: "error.unauthorized", statusCode: 401 });
1442
+ }
1443
+ /** 403 Forbidden */
1444
+ static forbidden() {
1445
+ return new _ServerError({ i18nKey: "error.forbidden", statusCode: 403 });
1446
+ }
1447
+ /** 404 Not found */
1448
+ static notFound() {
1449
+ return new _ServerError({ i18nKey: "error.not-found", statusCode: 404 });
1450
+ }
1451
+ /** 500 Internal Server Error */
1452
+ static internalServerError() {
1453
+ return new _ServerError({
1454
+ i18nKey: "error.internal-server-error",
1455
+ statusCode: 500
1456
+ });
1457
+ }
1439
1458
  };
1440
1459
 
1441
1460
  // src/server/interfaces/execute-action/normalize-error.ts
@@ -1469,7 +1488,7 @@ var normalizeError = (error, translator) => {
1469
1488
  };
1470
1489
 
1471
1490
  // src/server/interfaces/execute-action/create-execute-action.ts
1472
- async function createExecuteAction({
1491
+ function createExecuteAction({
1473
1492
  initI18n,
1474
1493
  cacheResult,
1475
1494
  cache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",