@nodehive/nextjs 0.5.3 → 0.6.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.
@@ -3,6 +3,7 @@ import type { Config } from '@puckeditor/core';
3
3
  import type { NodeHiveClient } from 'nodehive-js';
4
4
  import type { PuckContentModel, PuckContentModelInput } from '../content-model.js';
5
5
  import type { RoutableLink } from '../fields/link-picker/types.js';
6
+ import type { BuiltinTemplate } from '../plugins/templates-plugin/templates.js';
6
7
  export type PuckPublishPageSettings = {
7
8
  title?: string;
8
9
  metadataTitle?: string;
@@ -65,6 +66,8 @@ export type PuckApiConfig = {
65
66
  * generator warnings.
66
67
  */
67
68
  puckConfigs?: Record<string, Config>;
69
+ /** Built-in templates exposed by the public schema endpoint. */
70
+ builtinTemplates?: BuiltinTemplate[];
68
71
  };
69
72
  /** Config plus the resolved content model, as handed to the handlers. */
70
73
  export type PuckApiRuntime = PuckApiConfig & {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../../../src/puck-editor/internal/api/config.ts"],"sourcesContent":["import type { NextRequest, NextResponse } from 'next/server';\nimport type { Config } from '@puckeditor/core';\nimport type { NodeHiveClient } from 'nodehive-js';\n\nimport type {\n PuckContentModel,\n PuckContentModelInput,\n} from '../content-model.ts';\nimport type { RoutableLink } from '../fields/link-picker/types.ts';\n\nexport type PuckPublishPageSettings = {\n title?: string;\n metadataTitle?: string;\n metadataDescription?: string;\n metadataImage?: {\n id?: string;\n type?: string;\n name?: string;\n thumbnailImage?: string;\n } | null;\n published?: boolean;\n urlAlias?: string;\n};\n\nexport type PuckPublishPayload = {\n path?: string;\n type: string;\n data: unknown;\n nodeId: string;\n fieldName: string;\n lang?: string;\n pageSettings?: PuckPublishPageSettings;\n};\n\nexport type PuckPublishContext = {\n request: NextRequest;\n model: PuckContentModel;\n createUserClient: () => NodeHiveClient;\n};\n\nexport type PuckApiConfig = {\n /** Default client: user when a session token is present, else anon. */\n createClient: () => Promise<NodeHiveClient> | NodeHiveClient;\n /** Client that deliberately acts as the logged-in user. */\n createUserClient: () => NodeHiveClient;\n /** NodeHive space new pages and templates are assigned to. */\n spaceId?: string;\n /** Internally-routable pages offered by the link picker. */\n getLinks?: (lang: string) => Promise<RoutableLink[]>;\n /**\n * Called before the publish write. Return the (optionally mutated) payload to\n * continue, or a NextResponse to abort the publish with that response (e.g. a\n * 4xx for custom validation or business rules).\n */\n onBeforePublish?: (\n payload: PuckPublishPayload,\n ctx: PuckPublishContext\n ) =>\n | PuckPublishPayload\n | NextResponse\n | Promise<PuckPublishPayload | NextResponse>;\n /** Called after a successful publish, e.g. for project cache-tag invalidation. */\n onPublished?: (info: {\n nodeId: string;\n path?: string;\n lang?: string;\n }) => void | Promise<void>;\n /**\n * Drupal content-model overrides (puck-enabled bundles, templates, media\n * upload limit). Pass the same value to the client's PuckEditorConfig.\n */\n contentModel?: PuckContentModelInput;\n /**\n * Server-safe Puck Config per bundle type. Enables GET /schema, which\n * exports the component structure for backend consumers (search indexing,\n * translation). The endpoint is served without auth so a Drupal backend can\n * fetch it server-to-server; the response exposes component and prop names,\n * their semantic kinds, each bundle's Drupal data field machine name, and\n * generator warnings.\n */\n puckConfigs?: Record<string, Config>;\n};\n\n/** Config plus the resolved content model, as handed to the handlers. */\nexport type PuckApiRuntime = PuckApiConfig & { model: PuckContentModel };\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../../src/puck-editor/internal/api/config.ts"],"sourcesContent":["import type { NextRequest, NextResponse } from 'next/server';\nimport type { Config } from '@puckeditor/core';\nimport type { NodeHiveClient } from 'nodehive-js';\n\nimport type {\n PuckContentModel,\n PuckContentModelInput,\n} from '../content-model.ts';\nimport type { RoutableLink } from '../fields/link-picker/types.ts';\nimport type { BuiltinTemplate } from '../plugins/templates-plugin/templates.ts';\n\nexport type PuckPublishPageSettings = {\n title?: string;\n metadataTitle?: string;\n metadataDescription?: string;\n metadataImage?: {\n id?: string;\n type?: string;\n name?: string;\n thumbnailImage?: string;\n } | null;\n published?: boolean;\n urlAlias?: string;\n};\n\nexport type PuckPublishPayload = {\n path?: string;\n type: string;\n data: unknown;\n nodeId: string;\n fieldName: string;\n lang?: string;\n pageSettings?: PuckPublishPageSettings;\n};\n\nexport type PuckPublishContext = {\n request: NextRequest;\n model: PuckContentModel;\n createUserClient: () => NodeHiveClient;\n};\n\nexport type PuckApiConfig = {\n /** Default client: user when a session token is present, else anon. */\n createClient: () => Promise<NodeHiveClient> | NodeHiveClient;\n /** Client that deliberately acts as the logged-in user. */\n createUserClient: () => NodeHiveClient;\n /** NodeHive space new pages and templates are assigned to. */\n spaceId?: string;\n /** Internally-routable pages offered by the link picker. */\n getLinks?: (lang: string) => Promise<RoutableLink[]>;\n /**\n * Called before the publish write. Return the (optionally mutated) payload to\n * continue, or a NextResponse to abort the publish with that response (e.g. a\n * 4xx for custom validation or business rules).\n */\n onBeforePublish?: (\n payload: PuckPublishPayload,\n ctx: PuckPublishContext\n ) =>\n | PuckPublishPayload\n | NextResponse\n | Promise<PuckPublishPayload | NextResponse>;\n /** Called after a successful publish, e.g. for project cache-tag invalidation. */\n onPublished?: (info: {\n nodeId: string;\n path?: string;\n lang?: string;\n }) => void | Promise<void>;\n /**\n * Drupal content-model overrides (puck-enabled bundles, templates, media\n * upload limit). Pass the same value to the client's PuckEditorConfig.\n */\n contentModel?: PuckContentModelInput;\n /**\n * Server-safe Puck Config per bundle type. Enables GET /schema, which\n * exports the component structure for backend consumers (search indexing,\n * translation). The endpoint is served without auth so a Drupal backend can\n * fetch it server-to-server; the response exposes component and prop names,\n * their semantic kinds, each bundle's Drupal data field machine name, and\n * generator warnings.\n */\n puckConfigs?: Record<string, Config>;\n /** Built-in templates exposed by the public schema endpoint. */\n builtinTemplates?: BuiltinTemplate[];\n};\n\n/** Config plus the resolved content model, as handed to the handlers. */\nexport type PuckApiRuntime = PuckApiConfig & { model: PuckContentModel };\n"],"mappings":"","ignoreList":[]}
@@ -30,7 +30,7 @@ export function handleSchema(config) {
30
30
  configWarnings.push(`${key}: puckConfigs key matches no contentModel bundle, config ignored`);
31
31
  }
32
32
  }
33
- const schema = generatePuckSchema(inputs);
33
+ const schema = generatePuckSchema(inputs, config.builtinTemplates ?? []);
34
34
  schema.warnings.push(...configWarnings);
35
35
  return NextResponse.json(schema, {
36
36
  headers: {
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["NextResponse","generatePuckSchema","handleSchema","config","puckConfigs","Object","keys","length","json","status","message","inputs","configWarnings","bundle","model","bundles","puckConfig","type","push","dataField","bundleTypes","Set","map","b","key","has","schema","warnings","headers"],"sources":["../../../../../src/puck-editor/internal/api/handlers/schema.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nimport { generatePuckSchema } from '../../schema.ts';\nimport type { PuckApiRuntime } from '../config.ts';\n\nexport function handleSchema(config: PuckApiRuntime) {\n const puckConfigs = config.puckConfigs ?? {};\n if (Object.keys(puckConfigs).length === 0) {\n return NextResponse.json(\n {\n status: 'error',\n message:\n 'Schema export is not configured. Pass puckConfigs ({ [bundleType]: puckConfig }) to createPuckApi.',\n },\n { status: 501 }\n );\n }\n const inputs = [];\n const configWarnings: string[] = [];\n for (const bundle of config.model.bundles) {\n const puckConfig = puckConfigs[bundle.type];\n if (!puckConfig) {\n configWarnings.push(\n `${bundle.type}: no Puck config passed to createPuckApi, bundle missing from schema`\n );\n continue;\n }\n inputs.push({\n type: bundle.type,\n dataField: bundle.dataField,\n config: puckConfig,\n });\n }\n const bundleTypes = new Set(config.model.bundles.map((b) => b.type));\n for (const key of Object.keys(puckConfigs)) {\n if (!bundleTypes.has(key)) {\n configWarnings.push(\n `${key}: puckConfigs key matches no contentModel bundle, config ignored`\n );\n }\n }\n const schema = generatePuckSchema(inputs);\n schema.warnings.push(...configWarnings);\n return NextResponse.json(schema, {\n headers: { 'Cache-Control': 'public, max-age=300' },\n });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;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,QAAQ,CAACT,IAAI,CAAC,GAAGN,cAAc,CAAC;EACvC,OAAOZ,YAAY,CAACQ,IAAI,CAACkB,MAAM,EAAE;IAC/BE,OAAO,EAAE;MAAE,eAAe,EAAE;IAAsB;EACpD,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["NextResponse","generatePuckSchema","handleSchema","config","puckConfigs","Object","keys","length","json","status","message","inputs","configWarnings","bundle","model","bundles","puckConfig","type","push","dataField","bundleTypes","Set","map","b","key","has","schema","builtinTemplates","warnings","headers"],"sources":["../../../../../src/puck-editor/internal/api/handlers/schema.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nimport { generatePuckSchema } from '../../schema.ts';\nimport type { PuckApiRuntime } from '../config.ts';\n\nexport function handleSchema(config: PuckApiRuntime) {\n const puckConfigs = config.puckConfigs ?? {};\n if (Object.keys(puckConfigs).length === 0) {\n return NextResponse.json(\n {\n status: 'error',\n message:\n 'Schema export is not configured. Pass puckConfigs ({ [bundleType]: puckConfig }) to createPuckApi.',\n },\n { status: 501 }\n );\n }\n const inputs = [];\n const configWarnings: string[] = [];\n for (const bundle of config.model.bundles) {\n const puckConfig = puckConfigs[bundle.type];\n if (!puckConfig) {\n configWarnings.push(\n `${bundle.type}: no Puck config passed to createPuckApi, bundle missing from schema`\n );\n continue;\n }\n inputs.push({\n type: bundle.type,\n dataField: bundle.dataField,\n config: puckConfig,\n });\n }\n const bundleTypes = new Set(config.model.bundles.map((b) => b.type));\n for (const key of Object.keys(puckConfigs)) {\n if (!bundleTypes.has(key)) {\n configWarnings.push(\n `${key}: puckConfigs key matches no contentModel bundle, config ignored`\n );\n }\n }\n const schema = generatePuckSchema(inputs, config.builtinTemplates ?? []);\n schema.warnings.push(...configWarnings);\n return NextResponse.json(schema, {\n headers: { 'Cache-Control': 'public, max-age=300' },\n });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;AAE1C,SAASC,kBAAkB,QAAQ,iBAAiB;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E,QAAQ,CAACV,IAAI,CAAC,GAAGN,cAAc,CAAC;EACvC,OAAOZ,YAAY,CAACQ,IAAI,CAACkB,MAAM,EAAE;IAC/BG,OAAO,EAAE;MAAE,eAAe,EAAE;IAAsB;EACpD,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,13 +1,36 @@
1
1
  import type { Config } from '@puckeditor/core';
2
+ import type { BuiltinTemplate } from './plugins/templates-plugin/templates.js';
2
3
  export declare const PUCK_SCHEMA_VERSION = 1;
3
4
  declare const KINDS: readonly ["text", "richtext", "slot", "array", "object", "media", "entity", "link", "value", "opaque"];
4
5
  export type PuckSchemaPropKind = (typeof KINDS)[number];
6
+ export type PuckSchemaAi = {
7
+ description?: string;
8
+ instructions?: string;
9
+ exclude?: boolean;
10
+ bind?: string;
11
+ };
5
12
  export type PuckSchemaProp = {
6
13
  kind: PuckSchemaPropKind;
14
+ /** Original Puck field type, label and select/radio options. */
15
+ type?: string;
16
+ label?: string;
17
+ options?: unknown;
18
+ defaultValue?: unknown;
19
+ metadata?: {
20
+ ai?: PuckSchemaAi | string;
21
+ };
22
+ excluded?: boolean;
7
23
  fields?: Record<string, PuckSchemaProp>;
8
24
  };
9
25
  export type PuckSchemaComponent = {
26
+ label?: string;
10
27
  props: Record<string, PuckSchemaProp>;
28
+ defaultProps?: Record<string, unknown>;
29
+ metadata?: {
30
+ ai?: PuckSchemaAi | string;
31
+ };
32
+ /** AI-excluded components remain in the validation schema. */
33
+ excluded?: boolean;
11
34
  };
12
35
  export type PuckSchemaBundle = {
13
36
  dataField: string;
@@ -17,6 +40,7 @@ export type PuckSchemaBundle = {
17
40
  export type PuckSchema = {
18
41
  version: number;
19
42
  bundles: Record<string, PuckSchemaBundle>;
43
+ templates: BuiltinTemplate[];
20
44
  warnings: string[];
21
45
  };
22
46
  export type PuckSchemaBundleInput = {
@@ -24,5 +48,5 @@ export type PuckSchemaBundleInput = {
24
48
  dataField: string;
25
49
  config: Config;
26
50
  };
27
- export declare function generatePuckSchema(bundles: PuckSchemaBundleInput[]): PuckSchema;
51
+ export declare function generatePuckSchema(bundles: PuckSchemaBundleInput[], templates?: BuiltinTemplate[]): PuckSchema;
28
52
  export {};
@@ -1,5 +1,21 @@
1
1
  export const PUCK_SCHEMA_VERSION = 1;
2
+ const MAX_TEMPLATE_BYTES = 1_000_000;
2
3
  const KINDS = ['text', 'richtext', 'slot', 'array', 'object', 'media', 'entity', 'link', 'value', 'opaque'];
4
+ const toJson = value => {
5
+ if (value === undefined) return undefined;
6
+ try {
7
+ return JSON.parse(JSON.stringify(value));
8
+ } catch {
9
+ return undefined;
10
+ }
11
+ };
12
+ function aiOf(value) {
13
+ const ai = value?.ai;
14
+ if (typeof ai === 'string') return ai;
15
+ if (!ai || typeof ai !== 'object') return undefined;
16
+ const plain = toJson(ai);
17
+ return plain && typeof plain === 'object' ? plain : undefined;
18
+ }
3
19
  function isKind(value) {
4
20
  return KINDS.includes(value);
5
21
  }
@@ -18,32 +34,50 @@ function declaredKind(field) {
18
34
  }
19
35
  function propFromField(field, path, warnings) {
20
36
  const declared = declaredKind(field);
21
- if (declared !== undefined && !isKind(declared)) {
37
+ const validDeclaredKind = declared === undefined || isKind(declared);
38
+ if (!validDeclaredKind) {
22
39
  warnings.push(`${path}: declared kind "${String(declared)}" is unknown, exported as opaque`);
23
- return {
24
- kind: 'opaque'
25
- };
26
40
  }
27
- const kind = declared ?? DIRECT_KINDS[field.type];
41
+ const kind = validDeclaredKind ? declared ?? DIRECT_KINDS[field.type] : undefined;
42
+ const ai = aiOf(field.metadata);
43
+ const projected = {
44
+ kind: kind ?? 'opaque',
45
+ type: field.type,
46
+ ...(typeof field.label === 'string' ? {
47
+ label: field.label
48
+ } : {}),
49
+ ...('options' in field && field.options !== undefined ? {
50
+ options: toJson(field.options)
51
+ } : {}),
52
+ ...('defaultValue' in field && field.defaultValue !== undefined ? {
53
+ defaultValue: toJson(field.defaultValue)
54
+ } : {}),
55
+ ...(ai !== undefined ? {
56
+ metadata: {
57
+ ai
58
+ }
59
+ } : {}),
60
+ ...(typeof ai === 'object' && ai.exclude === true ? {
61
+ excluded: true
62
+ } : {})
63
+ };
28
64
  if (field.type === 'array') {
29
65
  return {
66
+ ...projected,
30
67
  kind: kind ?? 'array',
31
68
  fields: propsFromFields(field.arrayFields, path, warnings)
32
69
  };
33
70
  }
34
71
  if (field.type === 'object') {
35
72
  return {
73
+ ...projected,
36
74
  kind: kind ?? 'object',
37
75
  fields: propsFromFields(field.objectFields, path, warnings)
38
76
  };
39
77
  }
40
- if (kind) return {
41
- kind
42
- };
78
+ if (kind) return projected;
43
79
  warnings.push(`${path}: "${field.type}" field without nodehive kind metadata, exported as opaque`);
44
- return {
45
- kind: 'opaque'
46
- };
80
+ return projected;
47
81
  }
48
82
  function propsFromFields(fields, path, warnings) {
49
83
  const props = {};
@@ -52,7 +86,42 @@ function propsFromFields(fields, path, warnings) {
52
86
  }
53
87
  return props;
54
88
  }
55
- export function generatePuckSchema(bundles) {
89
+ function boundedTemplates(templates) {
90
+ const result = [];
91
+ let bytes = 0;
92
+ for (const template of templates) {
93
+ const encoded = toJson(template);
94
+ if (encoded === undefined) continue;
95
+ const size = new TextEncoder().encode(JSON.stringify(encoded)).byteLength;
96
+ if (bytes + size > MAX_TEMPLATE_BYTES) break;
97
+ bytes += size;
98
+ result.push(encoded);
99
+ }
100
+ return result;
101
+ }
102
+ function componentFromConfig(source, path, warnings) {
103
+ const component = source ?? {};
104
+ const ai = aiOf(component.metadata);
105
+ const excluded = typeof ai === 'object' && ai.exclude === true;
106
+ return {
107
+ ...(typeof component.label === 'string' ? {
108
+ label: component.label
109
+ } : {}),
110
+ props: propsFromFields(component.fields, path, warnings),
111
+ ...(component.defaultProps !== undefined ? {
112
+ defaultProps: toJson(component.defaultProps)
113
+ } : {}),
114
+ ...(ai !== undefined ? {
115
+ metadata: {
116
+ ai
117
+ }
118
+ } : {}),
119
+ ...(excluded ? {
120
+ excluded: true
121
+ } : {})
122
+ };
123
+ }
124
+ export function generatePuckSchema(bundles, templates = []) {
56
125
  const warnings = [];
57
126
  const schemaBundles = {};
58
127
  for (const {
@@ -62,21 +131,18 @@ export function generatePuckSchema(bundles) {
62
131
  } of bundles) {
63
132
  const components = {};
64
133
  for (const [name, component] of Object.entries(config.components ?? {})) {
65
- components[name] = {
66
- props: propsFromFields(component.fields, `${type}: ${name}`, warnings)
67
- };
134
+ components[name] = componentFromConfig(component, `${type}: ${name}`, warnings);
68
135
  }
69
136
  schemaBundles[type] = {
70
137
  dataField,
71
- root: {
72
- props: propsFromFields(config.root?.fields, `${type}: root`, warnings)
73
- },
138
+ root: componentFromConfig(config.root, `${type}: root`, warnings),
74
139
  components
75
140
  };
76
141
  }
77
142
  return {
78
143
  version: PUCK_SCHEMA_VERSION,
79
144
  bundles: schemaBundles,
145
+ templates: boundedTemplates(templates),
80
146
  warnings
81
147
  };
82
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":["PUCK_SCHEMA_VERSION","KINDS","isKind","value","includes","DIRECT_KINDS","text","textarea","richtext","select","radio","number","slot","declaredKind","field","metadata","nodehive","kind","propFromField","path","warnings","declared","undefined","push","String","type","fields","propsFromFields","arrayFields","objectFields","props","name","Object","entries","generatePuckSchema","bundles","schemaBundles","dataField","config","components","component","root","version"],"sources":["../../../src/puck-editor/internal/schema.ts"],"sourcesContent":["import type { Config, Field } from '@puckeditor/core';\n\nexport const PUCK_SCHEMA_VERSION = 1;\n\nconst KINDS = [\n 'text',\n 'richtext',\n 'slot',\n 'array',\n 'object',\n 'media',\n 'entity',\n 'link',\n 'value',\n 'opaque',\n] as const;\n\nexport type PuckSchemaPropKind = (typeof KINDS)[number];\n\nexport type PuckSchemaProp = {\n kind: PuckSchemaPropKind;\n fields?: Record<string, PuckSchemaProp>;\n};\n\nexport type PuckSchemaComponent = {\n props: Record<string, PuckSchemaProp>;\n};\n\nexport type PuckSchemaBundle = {\n dataField: string;\n root: PuckSchemaComponent;\n components: Record<string, PuckSchemaComponent>;\n};\n\nexport type PuckSchema = {\n version: number;\n bundles: Record<string, PuckSchemaBundle>;\n warnings: string[];\n};\n\nexport type PuckSchemaBundleInput = {\n type: string;\n dataField: string;\n config: Config;\n};\n\nfunction isKind(value: unknown): value is PuckSchemaPropKind {\n return KINDS.includes(value as PuckSchemaPropKind);\n}\n\nconst DIRECT_KINDS: Record<string, PuckSchemaPropKind> = {\n text: 'text',\n textarea: 'text',\n richtext: 'richtext',\n select: 'value',\n radio: 'value',\n number: 'value',\n slot: 'slot',\n};\n\nfunction declaredKind(field: Field): unknown {\n const metadata = field.metadata as\n { nodehive?: { kind?: unknown } } | undefined;\n return metadata?.nodehive?.kind;\n}\n\nfunction propFromField(\n field: Field,\n path: string,\n warnings: string[]\n): PuckSchemaProp {\n const declared = declaredKind(field);\n if (declared !== undefined && !isKind(declared)) {\n warnings.push(\n `${path}: declared kind \"${String(declared)}\" is unknown, exported as opaque`\n );\n return { kind: 'opaque' };\n }\n const kind = declared ?? DIRECT_KINDS[field.type];\n if (field.type === 'array') {\n return {\n kind: kind ?? 'array',\n fields: propsFromFields(field.arrayFields, path, warnings),\n };\n }\n if (field.type === 'object') {\n return {\n kind: kind ?? 'object',\n fields: propsFromFields(field.objectFields, path, warnings),\n };\n }\n if (kind) return { kind };\n warnings.push(\n `${path}: \"${field.type}\" field without nodehive kind metadata, exported as opaque`\n );\n return { kind: 'opaque' };\n}\n\nfunction propsFromFields(\n fields: Record<string, Field> | undefined,\n path: string,\n warnings: string[]\n): Record<string, PuckSchemaProp> {\n const props: Record<string, PuckSchemaProp> = {};\n for (const [name, field] of Object.entries(fields ?? {})) {\n props[name] = propFromField(field, `${path}.${name}`, warnings);\n }\n return props;\n}\n\nexport function generatePuckSchema(\n bundles: PuckSchemaBundleInput[]\n): PuckSchema {\n const warnings: string[] = [];\n const schemaBundles: Record<string, PuckSchemaBundle> = {};\n for (const { type, dataField, config } of bundles) {\n const components: Record<string, PuckSchemaComponent> = {};\n for (const [name, component] of Object.entries(config.components ?? {})) {\n components[name] = {\n props: propsFromFields(\n component.fields as Record<string, Field> | undefined,\n `${type}: ${name}`,\n warnings\n ),\n };\n }\n schemaBundles[type] = {\n dataField,\n root: {\n props: propsFromFields(\n config.root?.fields as Record<string, Field> | undefined,\n `${type}: root`,\n warnings\n ),\n },\n components,\n };\n }\n return { version: PUCK_SCHEMA_VERSION, bundles: schemaBundles, warnings };\n}\n"],"mappings":"AAEA,OAAO,MAAMA,mBAAmB,GAAG,CAAC;AAEpC,MAAMC,KAAK,GAAG,CACZ,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,CACA;AA+BV,SAASC,MAAMA,CAACC,KAAc,EAA+B;EAC3D,OAAOF,KAAK,CAACG,QAAQ,CAACD,KAA2B,CAAC;AACpD;AAEA,MAAME,YAAgD,GAAG;EACvDC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE,MAAM;EAChBC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE,OAAO;EACfC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE,OAAO;EACfC,IAAI,EAAE;AACR,CAAC;AAED,SAASC,YAAYA,CAACC,KAAY,EAAW;EAC3C,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QACwB;EAC/C,OAAOA,QAAQ,EAAEC,QAAQ,EAAEC,IAAI;AACjC;AAEA,SAASC,aAAaA,CACpBJ,KAAY,EACZK,IAAY,EACZC,QAAkB,EACF;EAChB,MAAMC,QAAQ,GAAGR,YAAY,CAACC,KAAK,CAAC;EACpC,IAAIO,QAAQ,KAAKC,SAAS,IAAI,CAACpB,MAAM,CAACmB,QAAQ,CAAC,EAAE;IAC/CD,QAAQ,CAACG,IAAI,CACX,GAAGJ,IAAI,oBAAoBK,MAAM,CAACH,QAAQ,CAAC,kCAC7C,CAAC;IACD,OAAO;MAAEJ,IAAI,EAAE;IAAS,CAAC;EAC3B;EACA,MAAMA,IA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AG,CAAC,CAAC;IAC1D,KAAK,MAAM,CAACR,IAAI,EAAES,SAAS,CAAC,IAAIR,MAAM,CAACC,OAAO,CAACK,MAAM,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;MACvEA,UAAU,CAACR,IAAI,CAAC,GAAG;QACjBD,KAAK,EAAEH,eAAe,CACpBa,SAAS,CAACd,MAAM,EAChB,GAAGD,IAAI,KAAKM,IAAI,EAAE,EAClBX,QACF;MACF,CAAC;IACH;IACAgB,aAAa,CAACX,IAAI,CAAC,GAAG;MACpBY,SAAS;MACTI,IAAI,EAAE;QACJX,KAAK,EAAEH,eAAe,CACpBW,MAAM,CAACG,IAAI,EAAEf,MAAM,EACnB,GAAGD,IAAI,QAAQ,EACfL,QACF;MACF,CAAC;MACDmB;IACF,CAAC;EACH;EACA,OAAO;IAAEG,OAAO,EAAE1C,mBAAmB;IAAEmC,OAAO,EAAEC,aAAa;IAAEhB;EAAS,CAAC;AAC3E","ignoreList":[]}
1
+ {"version":3,"file":"schema.js","names":["PUCK_SCHEMA_VERSION","MAX_TEMPLATE_BYTES","KINDS","toJson","value","undefined","JSON","parse","stringify","aiOf","ai","plain","isKind","includes","DIRECT_KINDS","text","textarea","richtext","select","radio","number","slot","declaredKind","field","metadata","nodehive","kind","propFromField","path","warnings","declared","validDeclaredKind","push","String","type","projected","label","options","defaultValue","exclude","excluded","fields","propsFromFields","arrayFields","objectFields","props","name","Object","entries","boundedTemplates","templates","result","bytes","template","encoded","size","TextEncoder","encode","byteLength","componentFromConfig","source","component","defaultProps","generatePuckSchema","bundles","schemaBundles","dataField","config","components","root","version"],"sources":["../../../src/puck-editor/internal/schema.ts"],"sourcesContent":["import type { Config, Field } from '@puckeditor/core';\n\nimport type { BuiltinTemplate } from './plugins/templates-plugin/templates.ts';\n\nexport const PUCK_SCHEMA_VERSION = 1;\nconst MAX_TEMPLATE_BYTES = 1_000_000;\n\nconst KINDS = [\n 'text',\n 'richtext',\n 'slot',\n 'array',\n 'object',\n 'media',\n 'entity',\n 'link',\n 'value',\n 'opaque',\n] as const;\n\nexport type PuckSchemaPropKind = (typeof KINDS)[number];\n\nexport type PuckSchemaAi = {\n description?: string;\n instructions?: string;\n exclude?: boolean;\n bind?: string;\n};\n\nexport type PuckSchemaProp = {\n kind: PuckSchemaPropKind;\n /** Original Puck field type, label and select/radio options. */\n type?: string;\n label?: string;\n options?: unknown;\n defaultValue?: unknown;\n metadata?: { ai?: PuckSchemaAi | string };\n excluded?: boolean;\n fields?: Record<string, PuckSchemaProp>;\n};\n\nexport type PuckSchemaComponent = {\n label?: string;\n props: Record<string, PuckSchemaProp>;\n defaultProps?: Record<string, unknown>;\n metadata?: { ai?: PuckSchemaAi | string };\n /** AI-excluded components remain in the validation schema. */\n excluded?: boolean;\n};\n\nexport type PuckSchemaBundle = {\n dataField: string;\n root: PuckSchemaComponent;\n components: Record<string, PuckSchemaComponent>;\n};\n\nexport type PuckSchema = {\n version: number;\n bundles: Record<string, PuckSchemaBundle>;\n templates: BuiltinTemplate[];\n warnings: string[];\n};\n\nexport type PuckSchemaBundleInput = {\n type: string;\n dataField: string;\n config: Config;\n};\n\nconst toJson = <T>(value: T): T | undefined => {\n if (value === undefined) return undefined;\n try {\n return JSON.parse(JSON.stringify(value)) as T;\n } catch {\n return undefined;\n }\n};\n\nfunction aiOf(value: unknown): PuckSchemaAi | string | undefined {\n const ai = (value as { ai?: unknown } | undefined)?.ai;\n if (typeof ai === 'string') return ai;\n if (!ai || typeof ai !== 'object') return undefined;\n const plain = toJson(ai);\n return plain && typeof plain === 'object'\n ? (plain as PuckSchemaAi)\n : undefined;\n}\n\nfunction isKind(value: unknown): value is PuckSchemaPropKind {\n return KINDS.includes(value as PuckSchemaPropKind);\n}\n\nconst DIRECT_KINDS: Record<string, PuckSchemaPropKind> = {\n text: 'text',\n textarea: 'text',\n richtext: 'richtext',\n select: 'value',\n radio: 'value',\n number: 'value',\n slot: 'slot',\n};\n\nfunction declaredKind(field: Field): unknown {\n const metadata = field.metadata as\n { nodehive?: { kind?: unknown } } | undefined;\n return metadata?.nodehive?.kind;\n}\n\nfunction propFromField(\n field: Field,\n path: string,\n warnings: string[]\n): PuckSchemaProp {\n const declared = declaredKind(field);\n const validDeclaredKind = declared === undefined || isKind(declared);\n if (!validDeclaredKind) {\n warnings.push(\n `${path}: declared kind \"${String(declared)}\" is unknown, exported as opaque`\n );\n }\n const kind = validDeclaredKind\n ? (declared ?? DIRECT_KINDS[field.type])\n : undefined;\n const ai = aiOf(field.metadata);\n const projected: PuckSchemaProp = {\n kind: kind ?? 'opaque',\n type: field.type,\n ...(typeof field.label === 'string' ? { label: field.label } : {}),\n ...('options' in field && field.options !== undefined\n ? { options: toJson(field.options) }\n : {}),\n ...('defaultValue' in field && field.defaultValue !== undefined\n ? { defaultValue: toJson(field.defaultValue) }\n : {}),\n ...(ai !== undefined ? { metadata: { ai } } : {}),\n ...(typeof ai === 'object' && ai.exclude === true\n ? { excluded: true }\n : {}),\n };\n if (field.type === 'array') {\n return {\n ...projected,\n kind: kind ?? 'array',\n fields: propsFromFields(field.arrayFields, path, warnings),\n };\n }\n if (field.type === 'object') {\n return {\n ...projected,\n kind: kind ?? 'object',\n fields: propsFromFields(field.objectFields, path, warnings),\n };\n }\n if (kind) return projected;\n warnings.push(\n `${path}: \"${field.type}\" field without nodehive kind metadata, exported as opaque`\n );\n return projected;\n}\n\nfunction propsFromFields(\n fields: Record<string, Field> | undefined,\n path: string,\n warnings: string[]\n): Record<string, PuckSchemaProp> {\n const props: Record<string, PuckSchemaProp> = {};\n for (const [name, field] of Object.entries(fields ?? {})) {\n props[name] = propFromField(field, `${path}.${name}`, warnings);\n }\n return props;\n}\n\ntype SchemaComponentSource = {\n label?: unknown;\n fields?: Record<string, Field>;\n defaultProps?: Record<string, unknown>;\n metadata?: unknown;\n};\n\nfunction boundedTemplates(templates: BuiltinTemplate[]): BuiltinTemplate[] {\n const result: BuiltinTemplate[] = [];\n let bytes = 0;\n for (const template of templates) {\n const encoded = toJson(template);\n if (encoded === undefined) continue;\n const size = new TextEncoder().encode(JSON.stringify(encoded)).byteLength;\n if (bytes + size > MAX_TEMPLATE_BYTES) break;\n bytes += size;\n result.push(encoded);\n }\n return result;\n}\n\nfunction componentFromConfig(\n source: SchemaComponentSource | undefined,\n path: string,\n warnings: string[]\n): PuckSchemaComponent {\n const component = source ?? {};\n const ai = aiOf(component.metadata);\n const excluded = typeof ai === 'object' && ai.exclude === true;\n return {\n ...(typeof component.label === 'string' ? { label: component.label } : {}),\n props: propsFromFields(component.fields, path, warnings),\n ...(component.defaultProps !== undefined\n ? { defaultProps: toJson(component.defaultProps) }\n : {}),\n ...(ai !== undefined ? { metadata: { ai } } : {}),\n ...(excluded ? { excluded: true } : {}),\n };\n}\n\nexport function generatePuckSchema(\n bundles: PuckSchemaBundleInput[],\n templates: BuiltinTemplate[] = []\n): PuckSchema {\n const warnings: string[] = [];\n const schemaBundles: Record<string, PuckSchemaBundle> = {};\n for (const { type, dataField, config } of bundles) {\n const components: Record<string, PuckSchemaComponent> = {};\n for (const [name, component] of Object.entries(config.components ?? {})) {\n components[name] = componentFromConfig(\n component as unknown as SchemaComponentSource,\n `${type}: ${name}`,\n warnings\n );\n }\n schemaBundles[type] = {\n dataField,\n root: componentFromConfig(\n config.root as unknown as SchemaComponentSource | undefined,\n `${type}: root`,\n warnings\n ),\n components,\n };\n }\n return {\n version: PUCK_SCHEMA_VERSION,\n bundles: schemaBundles,\n templates: boundedTemplates(templates),\n warnings,\n };\n}\n"],"mappings":"AAIA,OAAO,MAAMA,mBAAmB,GAAG,CAAC;AACpC,MAAMC,kBAAkB,GAAG,SAAS;AAEpC,MAAMC,KAAK,GAAG,CACZ,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,CACA;AAmDV,MAAMC,MAAM,GAAOC,KAAQ,IAAoB;EAC7C,IAAIA,KAAK,KAAKC,SAAS,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AAM,CAACtB,IAAI,EAAEe,SAAS,CAAC,IAAId,MAAM,CAACC,OAAO,CAACmB,MAAM,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;MACvEA,UAAU,CAACtB,IAAI,CAAC,GAAGa,mBAAmB,CACpCE,SAAS,EACT,GAAG3B,IAAI,KAAKY,IAAI,EAAE,EAClBjB,QACF,CAAC;IACH;IACAoC,aAAa,CAAC/B,IAAI,CAAC,GAAG;MACpBgC,SAAS;MACTG,IAAI,EAAEV,mBAAmB,CACvBQ,MAAM,CAACE,IAAI,EACX,GAAGnC,IAAI,QAAQ,EACfL,QACF,CAAC;MACDuC;IACF,CAAC;EACH;EACA,OAAO;IACLE,OAAO,EAAEtE,mBAAmB;IAC5BgE,OAAO,EAAEC,aAAa;IACtBf,SAAS,EAAED,gBAAgB,CAACC,SAAS,CAAC;IACtCrB;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  export type { PuckApiConfig, PuckPublishContext, PuckPublishPageSettings, PuckPublishPayload, } from './internal/api/config.js';
2
2
  export { createPuckApi } from './internal/api/create-puck-api.js';
3
3
  export type { PuckBundleConfig, PuckContentModelInput, PuckTemplatesConfig, } from './internal/content-model.js';
4
- export { generatePuckSchema, PUCK_SCHEMA_VERSION, type PuckSchema, type PuckSchemaBundle, type PuckSchemaBundleInput, type PuckSchemaComponent, type PuckSchemaProp, type PuckSchemaPropKind, } from './internal/schema.js';
4
+ export { generatePuckSchema, PUCK_SCHEMA_VERSION, type PuckSchema, type PuckSchemaAi, type PuckSchemaBundle, type PuckSchemaBundleInput, type PuckSchemaComponent, type PuckSchemaProp, type PuckSchemaPropKind, } from './internal/schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["createPuckApi","generatePuckSchema","PUCK_SCHEMA_VERSION"],"sources":["../../src/puck-editor/server.ts"],"sourcesContent":["// Server entry: the handler factory for the catch-all API mount.\nexport type {\n PuckApiConfig,\n PuckPublishContext,\n PuckPublishPageSettings,\n PuckPublishPayload,\n} from './internal/api/config.ts';\nexport { createPuckApi } from './internal/api/create-puck-api.ts';\nexport type {\n PuckBundleConfig,\n PuckContentModelInput,\n PuckTemplatesConfig,\n} from './internal/content-model.ts';\nexport {\n generatePuckSchema,\n PUCK_SCHEMA_VERSION,\n type PuckSchema,\n type PuckSchemaBundle,\n type PuckSchemaBundleInput,\n type PuckSchemaComponent,\n type PuckSchemaProp,\n type PuckSchemaPropKind,\n} from './internal/schema.ts';\n"],"mappings":"AAAA;;AAOA,SAASA,aAAa,QAAQ,mCAAmC;AAMjE,SACEC,kBAAkB,EAClBC,mBAAmB,QAOd,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"server.js","names":["createPuckApi","generatePuckSchema","PUCK_SCHEMA_VERSION"],"sources":["../../src/puck-editor/server.ts"],"sourcesContent":["// Server entry: the handler factory for the catch-all API mount.\nexport type {\n PuckApiConfig,\n PuckPublishContext,\n PuckPublishPageSettings,\n PuckPublishPayload,\n} from './internal/api/config.ts';\nexport { createPuckApi } from './internal/api/create-puck-api.ts';\nexport type {\n PuckBundleConfig,\n PuckContentModelInput,\n PuckTemplatesConfig,\n} from './internal/content-model.ts';\nexport {\n generatePuckSchema,\n PUCK_SCHEMA_VERSION,\n type PuckSchema,\n type PuckSchemaAi,\n type PuckSchemaBundle,\n type PuckSchemaBundleInput,\n type PuckSchemaComponent,\n type PuckSchemaProp,\n type PuckSchemaPropKind,\n} from './internal/schema.ts';\n"],"mappings":"AAAA;;AAOA,SAASA,aAAa,QAAQ,mCAAmC;AAMjE,SACEC,kBAAkB,EAClBC,mBAAmB,QAQd,sBAAsB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodehive/nextjs",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "NodeHive Next.js infrastructure modules: auth, puck-editor, visual-editor, smart-actions",
5
5
  "license": "MIT",
6
6
  "author": "NETNODE AG <info@netnode.ch>",