@yimingliao/cms 0.0.165 → 0.0.168

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.
Files changed (17) hide show
  1. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +1 -1
  2. package/dist/src/server/infrastructure/cookie/cookie.service.js +2 -2
  3. package/dist/src/server/infrastructure/zod/schemas/schemas.js +0 -8
  4. package/dist/src/server/interfaces/actions/resources/admin/commands/create/admin-create-validator.js +1 -1
  5. package/dist/src/server/interfaces/actions/resources/admin/commands/update/admin-update-validator.js +1 -1
  6. package/dist/src/server/interfaces/actions/resources/file/commands/create/file-create-validator.js +1 -1
  7. package/dist/src/server/interfaces/actions/resources/file/commands/create-many/file-create-many-validator.js +1 -1
  8. package/dist/src/server/interfaces/actions/resources/file/commands/update/file-update-validator.js +1 -1
  9. package/dist/src/server/interfaces/actions/resources/post/commands/create/post-create-validator.js +1 -1
  10. package/dist/src/server/interfaces/actions/resources/post/commands/update/post-update-validator.js +1 -1
  11. package/dist/src/server/interfaces/actions/resources/seo-metadata/commands/upsert/seo-metadata-upsert-validator.js +1 -1
  12. package/dist/src/server/interfaces/apis/file-upload/validator.js +1 -1
  13. package/dist/types/src/server/infrastructure/cookie/cookie.service.d.ts +6 -1
  14. package/dist/types/src/server/infrastructure/cookie/cookie.service.d.ts.map +1 -1
  15. package/dist/types/src/server/infrastructure/zod/schemas/schemas.d.ts +1 -3
  16. package/dist/types/src/server/infrastructure/zod/schemas/schemas.d.ts.map +1 -1
  17. package/package.json +1 -1
@@ -44,7 +44,7 @@ function createFilePicker({
44
44
  duration: null
45
45
  }));
46
46
  return Object.assign(file2, {
47
- id: crypto.randomUUID(),
47
+ id: Math.random().toString(36).slice(2),
48
48
  width: mediaInfo.width,
49
49
  height: mediaInfo.height,
50
50
  duration: mediaInfo.duration
@@ -6,14 +6,14 @@ const DEFAULT_OPTIONS = {
6
6
  sameSite: "strict",
7
7
  path: "/"
8
8
  };
9
- function createCookieService(nextCookies, cryptoService) {
9
+ function createCookieService(nextCookies, cryptoService, options = DEFAULT_OPTIONS) {
10
10
  async function set({
11
11
  name,
12
12
  value,
13
13
  expireSeconds
14
14
  }) {
15
15
  const cookieStore = await nextCookies();
16
- cookieStore.set(name, value, { ...DEFAULT_OPTIONS, maxAge: expireSeconds });
16
+ cookieStore.set(name, value, { ...options, maxAge: expireSeconds });
17
17
  }
18
18
  async function setSignedCookie({
19
19
  name,
@@ -1,12 +1,10 @@
1
1
  function createSchemas({
2
2
  z,
3
- localeArray,
4
3
  exist
5
4
  }) {
6
5
  const trimmedString = () => z.string().trim();
7
6
  const MAX_NUMBER = 2147483647;
8
7
  const MAX_STRING = 1e5;
9
- const localeSet = new Set(localeArray);
10
8
  function text() {
11
9
  return trimmedString().max(MAX_STRING);
12
10
  }
@@ -55,11 +53,6 @@ function createSchemas({
55
53
  function pathSegment() {
56
54
  return trimmedString().min(1).regex(/^(?!\.\.?$)[^\u0000-\u001F/\\]+$/u).max(255);
57
55
  }
58
- function locale() {
59
- return trimmedString().refine((val) => localeSet.has(val), {
60
- error: "Invalid locale"
61
- });
62
- }
63
56
  function singleItem(options) {
64
57
  return z.object({
65
58
  id: id().refine((v) => exist(v, options), {
@@ -92,7 +85,6 @@ function createSchemas({
92
85
  sha256Hash,
93
86
  slug,
94
87
  pathSegment,
95
- locale,
96
88
  // item
97
89
  singleItem,
98
90
  multiItems
@@ -19,7 +19,7 @@ const adminCreateValidator = (schemas) => schemas.z.object({
19
19
  translations: schemas.array(
20
20
  schemas.z.object({
21
21
  // core
22
- locale: schemas.locale(),
22
+ locale: schemas.text(),
23
23
  // text
24
24
  name: schemas.text().nullable(),
25
25
  // better seo
@@ -22,7 +22,7 @@ const adminUpdateValidator = (schemas, id) => schemas.z.object({
22
22
  translations: schemas.array(
23
23
  schemas.z.object({
24
24
  // core
25
- locale: schemas.locale(),
25
+ locale: schemas.text(),
26
26
  // text
27
27
  name: schemas.text().nullable(),
28
28
  // better seo
@@ -26,7 +26,7 @@ const fileCreateValidator = (schemas) => schemas.z.object({
26
26
  translations: schemas.array(
27
27
  schemas.z.object({
28
28
  // core
29
- locale: schemas.locale(),
29
+ locale: schemas.text(),
30
30
  // text
31
31
  name: schemas.text().nullable(),
32
32
  alt: schemas.text().nullable()
@@ -20,7 +20,7 @@ const fileCreateManyValidator = (schemas) => schemas.z.object({
20
20
  translations: schemas.array(
21
21
  schemas.z.object({
22
22
  // core
23
- locale: schemas.locale(),
23
+ locale: schemas.text(),
24
24
  // text
25
25
  name: schemas.text().nullable(),
26
26
  alt: schemas.text().nullable()
@@ -24,7 +24,7 @@ const fileUpdateValidator = (schemas) => schemas.z.object({
24
24
  translations: schemas.array(
25
25
  schemas.z.object({
26
26
  // core
27
- locale: schemas.locale(),
27
+ locale: schemas.text(),
28
28
  // text
29
29
  name: schemas.text().nullable(),
30
30
  alt: schemas.text().nullable()
@@ -87,7 +87,7 @@ const postCreateValidator = ({
87
87
  // ----------------------------------------------------------------------------
88
88
  translations: schemas.array(
89
89
  schemas.z.object({
90
- locale: schemas.locale(),
90
+ locale: schemas.text(),
91
91
  // text
92
92
  title: schemas.text().nullable(),
93
93
  subtitle: schemas.text().nullable(),
@@ -89,7 +89,7 @@ const postUpdateValidator = ({
89
89
  // ----------------------------------------------------------------------------
90
90
  translations: schemas.array(
91
91
  schemas.z.object({
92
- locale: schemas.locale(),
92
+ locale: schemas.text(),
93
93
  // text
94
94
  title: schemas.text().nullable(),
95
95
  subtitle: schemas.text().nullable(),
@@ -13,7 +13,7 @@ const seoMetadataUpsertValidator = (schemas) => schemas.z.object({
13
13
  translations: schemas.array(
14
14
  schemas.z.object({
15
15
  // core
16
- locale: schemas.locale(),
16
+ locale: schemas.text(),
17
17
  // ---------------------------------------------------
18
18
  // Basic
19
19
  // ---------------------------------------------------
@@ -4,7 +4,7 @@ const fileUploadValidator = (schemas) => schemas.z.object({
4
4
  //====== Translations ======
5
5
  translations: schemas.array(
6
6
  schemas.z.object({
7
- locale: schemas.locale(),
7
+ locale: schemas.text(),
8
8
  name: schemas.text().nullable(),
9
9
  alt: schemas.text().nullable()
10
10
  })
@@ -1,6 +1,11 @@
1
1
  import type { createCryptoService } from "../crypto";
2
2
  import type { cookies } from "next/headers";
3
- export declare function createCookieService(nextCookies: () => Promise<Awaited<ReturnType<typeof cookies>>>, cryptoService: ReturnType<typeof createCryptoService>): {
3
+ export declare function createCookieService(nextCookies: () => Promise<Awaited<ReturnType<typeof cookies>>>, cryptoService: ReturnType<typeof createCryptoService>, options?: {
4
+ httpOnly: boolean;
5
+ secure: boolean;
6
+ sameSite: "strict";
7
+ path: string;
8
+ }): {
4
9
  set: ({ name, value, expireSeconds, }: {
5
10
  name: string;
6
11
  value: string;
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.service.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/cookie/cookie.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,EAC/D,aAAa,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC;2CASlD;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;KACvB;uDASE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;KACvB;oBAa4B;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;gCAMlC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;qCASjB;QAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;uBA2ChC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;EAgBvD"}
1
+ {"version":3,"file":"cookie.service.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/cookie/cookie.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,EAC/D,aAAa,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,EACrD,OAAO;;;;;CAAkB;2CAStB;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;KACvB;uDASE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;KACvB;oBAa4B;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;gCAMlC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;qCASjB;QAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;uBA2ChC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;EAgBvD"}
@@ -2,9 +2,8 @@ import type { createZod } from "../create-zod";
2
2
  import type { createExist, ExistOptions } from "../rules/exist";
3
3
  import type zod from "zod";
4
4
  import type { ZodType } from "zod";
5
- export declare function createSchemas({ z, localeArray, exist, }: {
5
+ export declare function createSchemas({ z, exist, }: {
6
6
  z: ReturnType<typeof createZod>;
7
- localeArray: string[];
8
7
  exist: ReturnType<typeof createExist>;
9
8
  }): {
10
9
  z: typeof zod;
@@ -20,7 +19,6 @@ export declare function createSchemas({ z, localeArray, exist, }: {
20
19
  sha256Hash: () => zod.ZodString;
21
20
  slug: () => zod.ZodString;
22
21
  pathSegment: () => zod.ZodString;
23
- locale: () => zod.ZodString;
24
22
  singleItem: (options: ExistOptions) => zod.ZodNullable<zod.ZodObject<{
25
23
  id: zod.ZodString;
26
24
  }, zod.core.$strip>>;
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/infrastructure/zod/schemas/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,wBAAgB,aAAa,CAAC,EAC5B,CAAC,EACD,WAAW,EACX,KAAK,GACN,EAAE;IACD,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;IAChC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;CACvC;;;;;;;;YA2CgB,CAAC,SAAS,OAAO,UAAU,CAAC;;;;;;;0BAyDd,YAAY;;;0BAUZ,YAAY;;;;;;;EA+B1C"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/infrastructure/zod/schemas/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,wBAAgB,aAAa,CAAC,EAC5B,CAAC,EACD,KAAK,GACN,EAAE;IACD,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;IAChC,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;CACvC;;;;;;;;YA0CgB,CAAC,SAAS,OAAO,UAAU,CAAC;;;;;;0BAkDd,YAAY;;;0BAUZ,YAAY;;;;;;;EA8B1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.165",
3
+ "version": "0.0.168",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",