includio-cms 0.0.49 → 0.0.51

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.
@@ -6,7 +6,7 @@
6
6
  import type { DbEntryVersion, RawEntry } from '../../../types/entries.js';
7
7
  import { onMount } from 'svelte';
8
8
  import { defaults, superForm, type SuperForm } from 'sveltekit-superforms';
9
- import { zod, zodClient } from 'sveltekit-superforms/adapters';
9
+ import { zod4, zod4Client } from 'sveltekit-superforms/adapters';
10
10
 
11
11
  const contentLanguage = getContentLanguage();
12
12
  const remotes = getRemotes();
@@ -24,8 +24,8 @@
24
24
  onMount(() => {
25
25
  let collectionSchema = generateZodSchemaFromFields(collection.fields, contentLanguage.all);
26
26
 
27
- form = superForm(defaults(version.data, zod(collectionSchema)), {
28
- validators: zodClient(collectionSchema),
27
+ form = superForm(defaults(version.data, zod4(collectionSchema)), {
28
+ validators: zod4Client(collectionSchema),
29
29
  SPA: true,
30
30
  dataType: 'json',
31
31
  resetForm: false
@@ -154,10 +154,16 @@
154
154
  const data = await form.validateForm();
155
155
 
156
156
  if (data.valid) {
157
+ const updatedData = await remotes.populatePreviewData({
158
+ data: data.data,
159
+ slug: collection.slug,
160
+ language: contentLanguage.current
161
+ });
162
+
157
163
  window.postMessage(
158
164
  {
159
165
  type: 'preview-update',
160
- data: data.data
166
+ data: updatedData
161
167
  },
162
168
  '*'
163
169
  );
@@ -2,7 +2,7 @@
2
2
  import * as Form from '../../../components/ui/form/index.js';
3
3
 
4
4
  import { defaults, superForm } from 'sveltekit-superforms';
5
- import { zod, zodClient } from 'sveltekit-superforms/adapters';
5
+ import { zod4, zod4Client } from 'sveltekit-superforms/adapters';
6
6
  import { loginSchema } from './schema.js';
7
7
  import Input from '../../../components/ui/input/input.svelte';
8
8
  import Button from '../../../components/ui/button/button.svelte';
@@ -15,8 +15,8 @@
15
15
  const remotes = getRemotes();
16
16
  let interfaceLanguage = useInterfaceLanguage();
17
17
 
18
- const form = superForm(defaults(zod(loginSchema)), {
19
- validators: zodClient(loginSchema),
18
+ const form = superForm(defaults(zod4(loginSchema)), {
19
+ validators: zod4Client(loginSchema),
20
20
  SPA: true,
21
21
  onUpdate: async ({ form }) => {
22
22
  if (form.valid) {
@@ -2,10 +2,4 @@ import { z } from 'zod';
2
2
  export declare const loginSchema: z.ZodObject<{
3
3
  email: z.ZodString;
4
4
  password: z.ZodString;
5
- }, "strip", z.ZodTypeAny, {
6
- email: string;
7
- password: string;
8
- }, {
9
- email: string;
10
- password: string;
11
- }>;
5
+ }, z.core.$strip>;
@@ -2,10 +2,4 @@ import z from 'zod';
2
2
  export declare const createFolderSchema: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
5
- }, "strip", z.ZodTypeAny, {
6
- name: string;
7
- parentId?: string | null | undefined;
8
- }, {
9
- name: string;
10
- parentId?: string | null | undefined;
11
- }>;
5
+ }, z.z.core.$strip>;
@@ -1,37 +1,37 @@
1
1
  import { type RawEntry } from '../../types/entries.js';
2
2
  export declare const getRawEntries: import("@sveltejs/kit").RemoteQueryFunction<{
3
- slug?: string | undefined;
4
3
  ids?: string[] | undefined;
4
+ slug?: string | undefined;
5
5
  }, RawEntry[]>;
6
6
  export declare const getEntries: import("@sveltejs/kit").RemoteQueryFunction<{
7
- slug?: string | undefined;
8
- status?: "draft" | "published" | "scheduled" | undefined;
9
7
  ids?: string[] | undefined;
10
- language?: string | undefined;
11
8
  dataValues?: Record<string, unknown> | undefined;
12
9
  dataLike?: Record<string, unknown> | undefined;
10
+ language?: string | undefined;
11
+ status?: "draft" | "published" | "scheduled" | undefined;
12
+ slug?: string | undefined;
13
13
  }, import("../../types/entries.js").Entry[]>;
14
14
  export declare const getEntry: import("@sveltejs/kit").RemoteQueryFunction<{
15
- slug?: string | undefined;
16
15
  id?: string | undefined;
17
- status?: "draft" | "published" | "scheduled" | undefined;
18
- language?: string | undefined;
19
16
  dataValues?: Record<string, unknown> | undefined;
20
17
  dataLike?: Record<string, unknown> | undefined;
18
+ language?: string | undefined;
19
+ status?: "draft" | "published" | "scheduled" | undefined;
20
+ slug?: string | undefined;
21
21
  }, import("../../types/entries.js").Entry | null>;
22
22
  export declare const createEntry: import("@sveltejs/kit").RemoteCommand<{
23
23
  slug: string;
24
24
  type: "collection" | "singleton";
25
25
  }, Promise<import("../../types/entries.js").DbEntry>>;
26
26
  export declare const getRawEntry: import("@sveltejs/kit").RemoteQueryFunction<{
27
- slug?: string | undefined;
28
27
  id?: string | undefined;
28
+ slug?: string | undefined;
29
29
  }, RawEntry | null>;
30
30
  export declare const getEntryForEntryPage: import("@sveltejs/kit").RemoteQueryFunction<string, RawEntry>;
31
31
  export declare const updateEntryVersionCommand: import("@sveltejs/kit").RemoteCommand<{
32
- type: "draft" | "published-now" | "cancel-published";
33
- data: Record<string, unknown>;
34
32
  entryId: string;
33
+ data: Record<string, unknown>;
34
+ type: "draft" | "published-now" | "cancel-published";
35
35
  }, Promise<void | import("../../types/entries.js").DbEntryVersion>>;
36
36
  export declare const updateEntryCommand: import("@sveltejs/kit").RemoteCommand<{
37
37
  id: string;
@@ -15,8 +15,8 @@ export const getRawEntries = query(z.object({
15
15
  });
16
16
  export const getEntries = query(z.object({
17
17
  ids: z.array(z.string().uuid()).optional(),
18
- dataValues: z.record(z.unknown()).optional(),
19
- dataLike: z.record(z.unknown()).optional(),
18
+ dataValues: z.record(z.string(), z.unknown()).optional(),
19
+ dataLike: z.record(z.string(), z.unknown()).optional(),
20
20
  language: z.string().optional(),
21
21
  status: z.enum(entryVersionStatuses).optional(),
22
22
  slug: z.string().optional()
@@ -25,8 +25,8 @@ export const getEntries = query(z.object({
25
25
  });
26
26
  export const getEntry = query(z.object({
27
27
  id: z.string().uuid().optional(),
28
- dataValues: z.record(z.unknown()).optional(),
29
- dataLike: z.record(z.unknown()).optional(),
28
+ dataValues: z.record(z.string(), z.unknown()).optional(),
29
+ dataLike: z.record(z.string(), z.unknown()).optional(),
30
30
  language: z.string().optional(),
31
31
  status: z.enum(entryVersionStatuses).optional(),
32
32
  slug: z.string().optional()
@@ -62,7 +62,7 @@ export const getEntryForEntryPage = query(z.string(), async (id) => {
62
62
  });
63
63
  const updateEntryVersionCommandSchema = z.object({
64
64
  entryId: z.string().uuid(),
65
- data: z.record(z.unknown()),
65
+ data: z.record(z.string(), z.unknown()),
66
66
  type: z.enum(updateEntryVersionCommandTypes)
67
67
  });
68
68
  export const updateEntryVersionCommand = command(updateEntryVersionCommandSchema, async (input) => {
@@ -6,3 +6,4 @@ export * from './record.remote.js';
6
6
  export * from './languages.remote.js';
7
7
  export * from './form.remote.js';
8
8
  export * from './ai.remote.js';
9
+ export * from './preview.remote.js';
@@ -6,3 +6,4 @@ export * from './record.remote.js';
6
6
  export * from './languages.remote.js';
7
7
  export * from './form.remote.js';
8
8
  export * from './ai.remote.js';
9
+ export * from './preview.remote.js';
@@ -4,12 +4,12 @@ export declare const getAltOverview: import("@sveltejs/kit").RemoteQueryFunction
4
4
  filesWithoutAlt: number;
5
5
  }>;
6
6
  export declare const setMediaFileAlt: import("@sveltejs/kit").RemoteCommand<{
7
- alt: string | null;
8
7
  fileId: string;
8
+ alt: string | null;
9
9
  }, Promise<void>>;
10
10
  export declare const setMediaFileFolder: import("@sveltejs/kit").RemoteCommand<{
11
- folderId: string | null;
12
11
  fileId: string;
12
+ folderId: string | null;
13
13
  }, Promise<import("../../types/media.js").MediaFile>>;
14
14
  export declare const createFolder: import("@sveltejs/kit").RemoteCommand<{
15
15
  name: string;
@@ -18,8 +18,8 @@ export declare const createFolder: import("@sveltejs/kit").RemoteCommand<{
18
18
  export declare const getMedia: import("@sveltejs/kit").RemoteQueryFunction<void, import("../../types/media.js").MediaFile[]>;
19
19
  export declare const getMediaFiles: import("@sveltejs/kit").RemoteQueryFunction<{
20
20
  data: {
21
- folderId?: string | undefined;
22
21
  ids?: string[] | undefined;
22
+ folderId?: string | undefined;
23
23
  mimeTypes?: string[] | undefined;
24
24
  };
25
25
  }, import("../../types/media.js").MediaFile[]>;
@@ -0,0 +1,5 @@
1
+ export declare const populatePreviewData: import("@sveltejs/kit").RemoteCommand<{
2
+ data: Record<string, unknown>;
3
+ slug: string;
4
+ language: string;
5
+ }, Promise<import("../../types/entries.js").PopulatedEntryData>>;
@@ -0,0 +1,13 @@
1
+ import { command } from '$app/server';
2
+ import { getCMS } from '../../core/cms.js';
3
+ import { populateEntryData } from '../../core/server/fields/populateEntry.js';
4
+ import z from 'zod';
5
+ const schema = z.object({
6
+ data: z.record(z.string(), z.unknown()),
7
+ slug: z.string(),
8
+ language: z.string()
9
+ });
10
+ export const populatePreviewData = command(schema, async ({ data, slug, language }) => {
11
+ const config = getCMS().getBySlug(slug);
12
+ return populateEntryData(data, config.fields, language);
13
+ });
@@ -1,8 +1,9 @@
1
1
  import type { Field } from '../../types/fields.js';
2
- import { type ZodTypeAny } from 'zod';
2
+ import { z } from 'zod';
3
+ type AnyZodObject = z.ZodObject<any, any>;
3
4
  interface GenerateZodSchemaOptions {
4
5
  parentRequired?: boolean;
5
6
  }
6
- export declare function generateZodSchemaFromField(field: Field, languages: string[], options?: GenerateZodSchemaOptions): ZodTypeAny;
7
- export declare function generateZodSchemaFromFields(fields: Field[], languages: string[], options?: GenerateZodSchemaOptions): ZodTypeAny;
7
+ export declare function generateZodSchemaFromField(field: Field, languages: string[], options?: GenerateZodSchemaOptions): z.ZodType;
8
+ export declare function generateZodSchemaFromFields(fields: Field[], languages: string[], options?: GenerateZodSchemaOptions): AnyZodObject;
8
9
  export {};
@@ -57,20 +57,20 @@ export function generateZodSchemaFromField(field, languages, options = {
57
57
  return field.multiple ? z.array(baseSchema).default([]) : baseSchema;
58
58
  }
59
59
  case 'object': {
60
- let data = generateZodSchemaFromFields(field.fields, languages, {
60
+ const data = generateZodSchemaFromFields(field.fields, languages, {
61
61
  parentRequired: field.required
62
62
  });
63
- if (!field.required) {
64
- data = data.partial().optional();
65
- }
63
+ const finalData = !field.required ? data.partial().optional() : data;
66
64
  return z.object({
67
65
  slug: z.literal(field.slug),
68
- data
66
+ data: finalData
69
67
  });
70
68
  }
71
69
  case 'array': {
72
70
  const schemas = field.of.map((f) => generateZodSchemaFromField(f, languages, { parentRequired: field.required }));
73
- const itemSchema = schemas.length > 1 ? z.discriminatedUnion('slug', schemas) : schemas[0];
71
+ const itemSchema = schemas.length > 1
72
+ ? z.discriminatedUnion('slug', schemas)
73
+ : schemas[0];
74
74
  let schema = z.array(itemSchema);
75
75
  if (field.minItems !== undefined)
76
76
  schema = schema.min(field.minItems);
@@ -1,4 +1,4 @@
1
1
  import type { FormField } from '../../types/formFields.js';
2
- import { type ZodTypeAny } from 'zod';
3
- export declare function generateZodSchemaFromFormField(field: FormField): ZodTypeAny;
4
- export declare function generateZodSchemaFromFormFields(fields: FormField[]): ZodTypeAny;
2
+ import { z } from 'zod';
3
+ export declare function generateZodSchemaFromFormField(field: FormField): z.ZodType;
4
+ export declare function generateZodSchemaFromFormFields(fields: FormField[]): z.ZodType;
@@ -2,13 +2,10 @@ import { type DbEntry, type DbEntryInsert, type DbEntryVersion, type DbEntryVers
2
2
  import z from 'zod';
3
3
  export declare const createEntrySchema: z.ZodObject<{
4
4
  slug: z.ZodString;
5
- type: z.ZodEnum<["collection", "singleton"]>;
6
- }, "strip", z.ZodTypeAny, {
7
- slug: string;
8
- type: "collection" | "singleton";
9
- }, {
10
- slug: string;
11
- type: "collection" | "singleton";
12
- }>;
5
+ type: z.ZodEnum<{
6
+ collection: "collection";
7
+ singleton: "singleton";
8
+ }>;
9
+ }, z.z.core.$strip>;
13
10
  export declare const createEntry: (data: DbEntryInsert) => Promise<DbEntry>;
14
11
  export declare const createEntryVersion: (data: DbEntryVersionInsert) => Promise<DbEntryVersion>;
@@ -1,29 +1,15 @@
1
1
  import type { DbEntry, DbEntryVersion } from '../../../../types/entries.js';
2
2
  import z from 'zod';
3
3
  export declare const updateEntrySchema: z.ZodObject<{
4
- availableLocales: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
4
+ availableLocales: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
5
  archivedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
6
- }, "strip", z.ZodTypeAny, {
7
- availableLocales?: string[] | undefined;
8
- archivedAt?: Date | null | undefined;
9
- }, {
10
- availableLocales?: string[] | undefined;
11
- archivedAt?: Date | null | undefined;
12
- }>;
6
+ }, z.z.core.$strip>;
13
7
  export declare const updateEntry: (id: string, data: Partial<DbEntry>) => Promise<DbEntry>;
14
8
  export declare const updateEntryVersionSchema: z.ZodObject<{
15
9
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
16
10
  publishedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
17
11
  publishedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
- }, "strip", z.ZodTypeAny, {
19
- data?: Record<string, unknown> | undefined;
20
- publishedAt?: Date | null | undefined;
21
- publishedBy?: string | null | undefined;
22
- }, {
23
- data?: Record<string, unknown> | undefined;
24
- publishedAt?: Date | null | undefined;
25
- publishedBy?: string | null | undefined;
26
- }>;
12
+ }, z.z.core.$strip>;
27
13
  export declare const updateEntryVersion: (id: string, data: Partial<DbEntryVersion>) => Promise<DbEntryVersion>;
28
14
  export declare const updateEntryVersionCommandTypes: readonly ["draft", "published-now", "cancel-published"];
29
15
  export type UpdateEntryVersionCommandType = (typeof updateEntryVersionCommandTypes)[number];
@@ -29,7 +29,7 @@ export const updateEntry = async (id, data) => {
29
29
  return updatedEntry;
30
30
  };
31
31
  export const updateEntryVersionSchema = z.object({
32
- data: z.record(z.unknown()).optional(),
32
+ data: z.record(z.string(), z.unknown()).optional(),
33
33
  publishedAt: z.date().nullable().optional(),
34
34
  publishedBy: z.string().nullable().optional()
35
35
  });
@@ -2,20 +2,8 @@ import z from 'zod';
2
2
  export declare const urlFieldDataSchema: z.ZodObject<{
3
3
  id: z.ZodOptional<z.ZodString>;
4
4
  url: z.ZodRecord<z.ZodString, z.ZodString>;
5
- }, "strip", z.ZodTypeAny, {
6
- url: Record<string, string>;
7
- id?: string | undefined;
8
- }, {
9
- url: Record<string, string>;
10
- id?: string | undefined;
11
- }>;
5
+ }, z.z.core.$strip>;
12
6
  export declare const urlFieldDataWithRelationSchema: z.ZodObject<{
13
7
  id: z.ZodString;
14
8
  url: z.ZodRecord<z.ZodString, z.ZodString>;
15
- }, "strip", z.ZodTypeAny, {
16
- url: Record<string, string>;
17
- id: string;
18
- }, {
19
- url: Record<string, string>;
20
- id: string;
21
- }>;
9
+ }, z.z.core.$strip>;
@@ -1,9 +1,9 @@
1
1
  import z from 'zod';
2
2
  export const urlFieldDataSchema = z.object({
3
3
  id: z.string().optional(),
4
- url: z.record(z.string())
4
+ url: z.record(z.string(), z.string())
5
5
  });
6
6
  export const urlFieldDataWithRelationSchema = z.object({
7
7
  id: z.string().uuid(),
8
- url: z.record(z.string())
8
+ url: z.record(z.string(), z.string())
9
9
  });
@@ -9,5 +9,5 @@ export interface SingleConfigWithType extends SingleConfig {
9
9
  }
10
10
  export interface SingleCMSData {
11
11
  config: SingleConfigWithType;
12
- schema: z.ZodTypeAny;
12
+ schema: z.ZodType;
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "includio-cms",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",
@@ -103,7 +103,7 @@
103
103
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
104
104
  "svelte": "^5.43.0",
105
105
  "vite": "^7.2.0",
106
- "zod": "^3.25.57"
106
+ "zod": "^4.0.0"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@chromatic-com/storybook": "^4",
@@ -186,13 +186,13 @@
186
186
  "slugify": "^1.6.6",
187
187
  "svelte-sonner": "^1.0.5",
188
188
  "sveltekit-flash-message": "^2.4.6",
189
- "sveltekit-superforms": "^2.26.1",
189
+ "sveltekit-superforms": "^2.28.1",
190
190
  "tailwind-merge": "^3.3.1",
191
191
  "tailwind-variants": "^3.1.1",
192
192
  "tailwindcss": "^4.1.13",
193
193
  "tw-animate-css": "^1.3.4",
194
194
  "uuid": "^11.1.0",
195
- "zod": "^3.25.57"
195
+ "zod": "^4.0.0"
196
196
  },
197
197
  "pnpm": {
198
198
  "onlyBuiltDependencies": [