@phtngyn/cms 0.2.0-beta.1 → 0.2.0-beta.2
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/CHANGELOG.md +13 -0
- package/README.md +38 -45
- package/package.json +3 -1
- package/src/ApplicationTypes.d.ts +7 -5
- package/src/{Configuration-CjVUBBwa.js → Configuration-BU-UyGoH.js} +4 -4
- package/src/{Configuration-CjVUBBwa.js.map → Configuration-BU-UyGoH.js.map} +1 -1
- package/src/Configuration.d.ts +41 -24
- package/src/Configuration.js.map +1 -1
- package/src/Content.js +1 -1
- package/src/{ContentTransfer-CTzGGKFV.js → ContentTransfer-BhF9G56s.js} +2 -2
- package/src/{ContentTransfer-CTzGGKFV.js.map → ContentTransfer-BhF9G56s.js.map} +1 -1
- package/src/{DocumentEngine-BbhfnTAc.js → DocumentEngine-ClhFXW9M.js} +4 -4
- package/src/{DocumentEngine-BbhfnTAc.js.map → DocumentEngine-ClhFXW9M.js.map} +1 -1
- package/src/DocumentModel.d.ts +6 -1
- package/src/DocumentModel.js +4 -3
- package/src/DocumentModel.js.map +1 -1
- package/src/{Forms-CfcI3tPU.js → Forms-BbkE7QfC.js} +47 -16
- package/src/Forms-BbkE7QfC.js.map +1 -0
- package/src/{Forms-02-p8qEw.js → Forms-DoB56hfe.js} +24 -7
- package/src/Forms-DoB56hfe.js.map +1 -0
- package/src/{Forms-BorTcIlp.d.ts → Forms-R0HoTR-o.d.ts} +30 -9
- package/src/Forms.d.ts +16 -15
- package/src/Forms.js.map +1 -1
- package/src/{I18n-BXlVunfa.d.ts → I18n-zbqpWxki.d.ts} +3 -1
- package/src/I18n.d.ts +1 -1
- package/src/Module.js +4 -2
- package/src/Module.js.map +1 -1
- package/src/{S3MediaObjects-DC0c8sYC.js → S3MediaObjects-D5Ns4FM6.js} +14 -12
- package/src/S3MediaObjects-D5Ns4FM6.js.map +1 -0
- package/src/cli.js +60 -34
- package/src/cli.js.map +1 -1
- package/src/{connection-BPf4BQUZ.js → connection-D5S9Iph-.js} +2 -2
- package/src/{connection-BPf4BQUZ.js.map → connection-D5S9Iph-.js.map} +1 -1
- package/src/{dev-lifecycle-vQLxwCFq.js → dev-lifecycle-CZ7iCzG9.js} +129 -42
- package/src/dev-lifecycle-CZ7iCzG9.js.map +1 -0
- package/src/{installation-DsGst1BH.js → installation-BNuoRDOz.js} +43 -31
- package/src/installation-BNuoRDOz.js.map +1 -0
- package/src/internal/authoring-catalog.js +2 -2
- package/src/internal/authoring-metadata.js +1 -1
- package/src/internal/configuration.js +149 -50
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/dev-lifecycle.js +2 -2
- package/src/internal/diagnostics.js +47 -0
- package/src/internal/diagnostics.js.map +1 -0
- package/src/internal/document-model.js +2 -2
- package/src/internal/form-capabilities.js +1 -1
- package/src/internal/i18n.js +6 -1
- package/src/internal/i18n.js.map +1 -1
- package/src/{location-BgYhXEZp.js → location-CPX7oj0o.js} +2 -2
- package/src/{location-BgYhXEZp.js.map → location-CPX7oj0o.js.map} +1 -1
- package/src/{models-k2nXyD6q.js → models-C9kF9JlQ.js} +2 -2
- package/src/{models-k2nXyD6q.js.map → models-C9kF9JlQ.js.map} +1 -1
- package/src/{models-DgkGTFus.js → models-ChRxBChy.js} +4 -2
- package/src/{models-DgkGTFus.js.map → models-ChRxBChy.js.map} +1 -1
- package/src/runtime/delivery/context.js +1 -1
- package/src/runtime/delivery/plugin.js +3 -2
- package/src/runtime/delivery/plugin.js.map +1 -1
- package/src/runtime/forms/document.js +1 -1
- package/src/runtime/forms/useCmsForm.js +28 -24
- package/src/runtime/forms/useCmsForm.js.map +1 -1
- package/src/runtime/i18n/useCmsI18n.d.ts +1 -1
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +12 -4
- package/src/runtime/plugin.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +2 -2
- package/src/runtime/preview/plugin.client.js +3 -3
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/sitemap.js +1 -1
- package/src/{store-BYgSt7E3.js → store-B49J21NA.js} +3 -3
- package/src/{store-BYgSt7E3.js.map → store-B49J21NA.js.map} +1 -1
- package/studio/{CreateDocumentDialog-BdiM77bb.js → CreateDocumentDialog-DJ8c0WZb.js} +3 -3
- package/studio/{documentPlanning-B7fyUj9r.js → documentPlanning-CDb31mnl.js} +6417 -6358
- package/studio/host.css +1 -1
- package/studio/host.js +7608 -7250
- package/src/Forms-02-p8qEw.js.map +0 -1
- package/src/Forms-CfcI3tPU.js.map +0 -1
- package/src/S3MediaObjects-DC0c8sYC.js.map +0 -1
- package/src/dev-lifecycle-vQLxwCFq.js.map +0 -1
- package/src/installation-DsGst1BH.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Forms-02-p8qEw.js","names":["isJsonObject","jsonObject","CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/internal/comark/document-adapter.ts","../../../../document/src/internal/comark/bindings.ts","../../../../document/src/Forms.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type {\n ElementNodeAttributes,\n MarkdownDocument as ComarkMarkdownDocument,\n Node as ComarkNode,\n NodeRenderData,\n} from 'comark'\nimport { textContent } from 'comark/utils'\nimport { Predicate, Schema } from 'effect'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nexport function toComarkDocument(document: CmsMarkdownDocument): ComarkMarkdownDocument {\n return {\n frontmatter: mutableJsonObject(document.frontmatter),\n meta: mutableJsonObject(document.meta),\n nodes: document.nodes.map(toComarkNode),\n }\n}\n\nexport function createCmsComarkRenderData(document: CmsMarkdownDocument): NodeRenderData {\n return {\n data: {},\n frontmatter: mutableJsonObject(document.frontmatter),\n meta: mutableJsonObject(document.meta),\n props: {},\n }\n}\n\n/** Extracts inline text with Comark semantics, preserving punctuation between nested inline nodes. */\nexport function cmsComarkTextContent(node: MarkdownNode): string {\n return textContent(toComarkNode(node), { decodeUnicodeEntities: true })\n}\n\nexport function toMutableComarkAttributes(attributes: Schema.JsonObject): ElementNodeAttributes {\n const result: ElementNodeAttributes = {}\n\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== '$') result[name] = mutableJson(value)\n }\n\n const internal = jsonObject(attributes.$)\n const line = internal.line\n const html = binaryFlag(internal.html)\n const block = binaryFlag(internal.block)\n\n if (Predicate.isNumber(line) || html !== undefined || block !== undefined) {\n const metadata: Record<string, number> = {}\n\n if (Predicate.isNumber(line)) metadata.line = line\n\n if (html !== undefined) metadata.html = html\n\n if (block !== undefined) metadata.block = block\n result.$ = metadata\n }\n\n return result\n}\n\nexport function mutableJson(value: Schema.Json): Schema.Json {\n if (Array.isArray(value)) return value.map(mutableJson)\n\n if (isJsonObject(value)) return mutableJsonObject(value)\n\n return value\n}\n\nfunction toComarkNode(node: MarkdownNode): ComarkNode {\n if (Predicate.isString(node)) return node\n\n if (node[0] === null) return [null, toMutableComarkAttributes(node[1]), node[2]]\n const [tag, attributes, ...children] = node\n\n return [tag, toMutableComarkAttributes(attributes), ...children.map(toComarkNode)]\n}\n\nexport function mutableJsonObject(value: Schema.JsonObject): Record<string, Schema.Json> {\n return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, mutableJson(child)]))\n}\n\nfunction binaryFlag(value: Schema.Json | undefined): 0 | 1 | undefined {\n return value === 0 || value === 1 ? value : undefined\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n","import type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { NodeRenderData } from 'comark'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { resolveAttributes } from 'comark/utils'\nimport { Option, Predicate, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject, toMutableComarkAttributes } from './document-adapter'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nconst decodeJson = Schema.decodeUnknownOption(Schema.Json)\n\nexport type CmsComarkAttributeValue = Schema.Json | undefined\n\nexport type CmsComarkAttributes = ReadonlyMap<string, CmsComarkAttributeValue>\n\ninterface CmsEditorComponentProjection {\n readonly bindings: Schema.JsonObject\n readonly props: Schema.JsonObject\n readonly renderData: NodeRenderData\n}\n\n/** Normalizes bindings exactly as Comark's framework renderers do before passing props to a component. */\nexport function resolveCmsComarkAttributes(\n attributes: Schema.JsonObject,\n renderData: NodeRenderData,\n): CmsComarkAttributes {\n const resolved = new Map<string, CmsComarkAttributeValue>()\n\n for (const [name, value] of Object.entries(\n resolveAttributes(toMutableComarkAttributes(attributes), renderData, { parseJson: true }),\n )) {\n if (Predicate.isUndefined(value)) {\n resolved.set(name, undefined)\n continue\n }\n\n const decoded = decodeJson(value)\n\n if (Option.isNone(decoded)) throw new Error(`Comark resolved non-JSON attribute \"${name}\".`)\n resolved.set(name, decoded.value)\n }\n\n return resolved\n}\n\n/** Projects bindings to editable values while retaining enough metadata to reconstruct their authored form. */\nexport function projectCmsEditorComponentAttributes(\n attributes: Schema.JsonObject,\n renderData: NodeRenderData,\n): CmsEditorComponentProjection {\n const resolved = resolveCmsComarkAttributes(attributes, renderData)\n const props: Record<string, Schema.Json> = {}\n\n for (const [name, value] of resolved) {\n if (!Predicate.isUndefined(value)) props[name] = mutableJson(value)\n }\n\n const bindings: Record<string, Schema.Json> = {}\n\n for (const [authoredName, authoredValue] of Object.entries(attributes)) {\n if (!authoredName.startsWith(':') || authoredName.length === 1) continue\n const name = authoredName.slice(1)\n\n if (!resolved.has(name)) continue\n const literal = jsonLiteral(authoredValue)\n\n if (!Predicate.isString(authoredValue) || literal !== authoredValue) {\n bindings[name] = { kind: 'literal' }\n continue\n }\n\n const resolvedValue = resolved.get(name)\n bindings[name] = Object.assign(\n { expression: authoredValue, kind: 'expression' },\n Predicate.isUndefined(resolvedValue) ? undefined : { resolved: mutableJson(resolvedValue) },\n )\n }\n\n return { bindings, props, renderData: withCmsComarkProps(renderData, resolved) }\n}\n\n/** Reconstructs authored bindings, keeping expressions until a user replaces their resolved value. */\nexport function encodeCmsEditorComponentAttributes(\n props: Schema.JsonObject,\n bindings: Schema.JsonObject,\n): Schema.JsonObject {\n const attributes = mutableJsonObject(props)\n\n for (const [name, encodedBinding] of Object.entries(bindings)) {\n const binding = jsonObject(encodedBinding)\n const kind = binding.kind\n\n if (kind !== 'literal' && kind !== 'expression') continue\n const current = props[name]\n\n if (Predicate.isUndefined(current)) {\n const expression = binding.expression\n\n if (kind === 'expression' && Predicate.isString(expression)) attributes[`:${name}`] = expression\n continue\n }\n\n delete attributes[name]\n const expression = binding.expression\n const resolved = binding.resolved\n attributes[`:${name}`] =\n kind === 'expression' &&\n Predicate.isString(expression) &&\n Object.hasOwn(binding, 'resolved') &&\n sameJson(current, resolved)\n ? expression\n : mutableJson(current)\n }\n\n return attributes\n}\n\nexport function withCmsComarkProps(renderData: NodeRenderData, attributes: CmsComarkAttributes): NodeRenderData {\n return attributes.size > 0 ? { ...renderData, props: Object.fromEntries(attributes) } : renderData\n}\n\n/** Restores typed component bindings that Comark's block-YAML roundtrip can emit as plain attributes. */\nexport function normalizeCmsComponentBindings(\n document: CmsMarkdownDocument,\n components: ReadonlyMap<string, ComponentDefinition> | undefined,\n): CmsMarkdownDocument {\n if (!components) return document\n\n return CmsMarkdownDocumentSchema.make({\n frontmatter: document.frontmatter,\n meta: document.meta,\n nodes: document.nodes.map((node) => normalizeComponentNode(node, components)),\n })\n}\n\nexport function matchesCmsComponentPropType(\n value: CmsComarkAttributeValue,\n type: ComponentDefinition['authoring']['props'][number]['type'],\n): boolean {\n switch (type) {\n case 'object':\n return isJsonObject(value)\n case 'array':\n return Array.isArray(value)\n case 'boolean':\n return Predicate.isBoolean(value)\n case 'number':\n return Predicate.isNumber(value)\n case 'string':\n return Predicate.isString(value)\n }\n}\n\nfunction normalizeComponentNode(\n node: MarkdownNode,\n components: ReadonlyMap<string, ComponentDefinition>,\n): MarkdownNode {\n if (Predicate.isString(node) || node[0] === null) return node\n const [tag, originalAttributes, ...originalChildren] = node\n const attributes = mutableJsonObject(originalAttributes)\n const definition = components.get(tag.toLocaleLowerCase())\n\n if (definition) {\n for (const prop of definition.authoring.props) {\n if (prop.type === 'string' || `:${prop.name}` in attributes || !(prop.name in attributes)) continue\n const value = attributes[prop.name]\n\n if (Predicate.isUndefined(value)) continue\n const resolved = jsonLiteral(value)\n\n if (!matchesCmsComponentPropType(resolved, prop.type)) continue\n delete attributes[prop.name]\n attributes[`:${prop.name}`] = value\n }\n }\n\n return [tag, attributes, ...originalChildren.map((child) => normalizeComponentNode(child, components))]\n}\n\nfunction jsonLiteral(value: Schema.Json | undefined): CmsComarkAttributeValue {\n if (!Predicate.isString(value)) return value\n\n try {\n const decoded = decodeJson(JSON.parse(value))\n\n return Option.isSome(decoded) ? decoded.value : value\n } catch {\n return value\n }\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n\nfunction sameJson(left: Schema.Json, right: Schema.Json | undefined): boolean {\n return !Predicate.isUndefined(right) && JSON.stringify(left) === JSON.stringify(right)\n}\n","import { createCmsComarkRenderData } from './internal/comark/document-adapter'\nimport { projectCmsEditorComponentAttributes } from './internal/comark/bindings'\nimport type { NodeRenderData } from 'comark'\nimport type { BlockAuthoring, BlockProp } from '@internal/protocol/Authoring'\nimport type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { CmsMarkdownDocument } from '@internal/protocol/Documents'\nimport type { FormCapabilities, FormDefinition, FormField, FormStep, FormValues } from '@internal/protocol/Forms'\nimport { FORM_REVISION_MAX_BYTES, FormSteps } from '@internal/protocol/Forms'\nimport { Predicate, Result, Schema } from 'effect'\n\nexport function formStructureIssues(\n input: Schema.Json | undefined,\n capabilities: FormCapabilities,\n name: string,\n): string[] {\n const decoded = Schema.decodeUnknownResult(FormSteps)(input, { onExcessProperty: 'error' })\n\n if (Result.isFailure(decoded)) return ['Each form needs steps with a title and at least one valid question.']\n const issues: string[] = []\n const revisionBytes = new TextEncoder().encode(JSON.stringify(formRevision(name, capabilities, decoded.success)))\n\n if (revisionBytes.byteLength > FORM_REVISION_MAX_BYTES)\n issues.push('This form is too large. Reduce the number or size of questions.')\n const ids = new Set<string>()\n\n for (const step of decoded.success) {\n if (ids.has(step.id)) issues.push('Steps and questions must have unique identities.')\n ids.add(step.id)\n\n for (const field of step.fields) {\n if (ids.has(field.id)) issues.push('Steps and questions must have unique identities.')\n ids.add(field.id)\n\n if (['_form', '__proto__', 'constructor', 'prototype'].includes(field.id))\n issues.push('This question identity is reserved.')\n\n if (!capabilities.fieldTypes.includes(field.type))\n issues.push(`${field.label}: this question type is unavailable.`)\n\n for (const rule of ['required', 'minLength', 'maxLength', 'min', 'max'] as const) {\n if (field[rule] !== undefined && !capabilities.rules.includes(rule))\n issues.push(`${field.label}: ${rule} is unavailable.`)\n }\n\n const text = ['text', 'email', 'textarea'].includes(field.type)\n\n if (!text && (field.minLength !== undefined || field.maxLength !== undefined))\n issues.push(`${field.label}: length limits require a text question.`)\n\n if (field.type !== 'number' && (field.min !== undefined || field.max !== undefined))\n issues.push(`${field.label}: numeric limits require a number question.`)\n\n if (field.min !== undefined && field.max !== undefined && field.min > field.max)\n issues.push(`${field.label}: minimum exceeds maximum.`)\n\n if (field.minLength !== undefined && field.maxLength !== undefined && field.minLength > field.maxLength)\n issues.push(`${field.label}: minimum length exceeds maximum length.`)\n const options = field.options ?? []\n\n if (\n field.type === 'select' &&\n (!options.length || new Set(options.map((option) => option.id)).size !== options.length)\n )\n issues.push(`${field.label}: choices need unique identities and at least one option.`)\n\n if (field.type !== 'select' && options.length) issues.push(`${field.label}: choices require a select question.`)\n }\n }\n\n return issues\n}\n\nexport function validateFormValues(fields: ReadonlyArray<FormField>, values: FormValues): Record<string, string> {\n return Object.fromEntries(\n fields.flatMap((field) => {\n const issue = fieldIssue(field, Object.hasOwn(values, field.id) ? values[field.id] : undefined)\n\n return issue ? [[field.id, issue]] : []\n }),\n )\n}\n\nfunction fieldIssue(field: FormField, value: FormValues[string] | undefined): string | undefined {\n const empty = value === undefined || value === null || value === '' || (Predicate.isString(value) && !value.trim())\n\n if (empty) return field.required ? `${field.label} is required.` : undefined\n\n if (field.type === 'checkbox')\n return !Predicate.isBoolean(value)\n ? 'Choose yes or no.'\n : field.required && !value\n ? `${field.label} must be checked.`\n : undefined\n\n if (field.type === 'number') {\n if (!Predicate.isNumber(value) || !Number.isFinite(value)) return 'Enter a number.'\n\n if (field.min !== undefined && value < field.min) return `Enter at least ${field.min}.`\n\n if (field.max !== undefined && value > field.max) return `Enter at most ${field.max}.`\n\n return undefined\n }\n\n if (!Predicate.isString(value)) return 'Enter text.'\n\n if (field.type === 'select' && !field.options?.some((option) => option.id === value))\n return 'Choose an available option.'\n\n if (field.type === 'email' && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/u.test(value)) return 'Enter a valid email address.'\n\n if (field.minLength !== undefined && value.length < field.minLength)\n return `Enter at least ${field.minLength} characters.`\n\n if (field.maxLength !== undefined && value.length > field.maxLength)\n return `Enter at most ${field.maxLength} characters.`\n\n return undefined\n}\n\n/** Paths refer to authored nodes, never rendered Vue children. Revision comparison is exact. */\nexport function documentForms(\n document: { readonly id: FormDefinition['documentId']; readonly body: CmsMarkdownDocument },\n components: ReadonlyArray<ComponentDefinition>,\n preview = false,\n): FormDefinition[] {\n const forms: FormDefinition[] = []\n\n const visit = (nodes: CmsMarkdownDocument['nodes'], parent: number[], renderData: NodeRenderData) => {\n nodes.forEach((node, index) => {\n if (Predicate.isString(node) || node[0] === null) return\n const nodePath = [...parent, index]\n const projection = projectCmsEditorComponentAttributes(node[1], renderData)\n const capabilities = components.find((component) => component.name === node[0])?.authoring.form\n\n if (capabilities && !formStructureIssues(projection.props.steps, capabilities, node[0]).length) {\n const steps = Result.getOrThrow(Schema.decodeUnknownResult(FormSteps)(projection.props.steps))\n forms.push({\n name: node[0],\n documentId: document.id,\n nodePath,\n steps,\n preview,\n revision: formRevision(node[0], capabilities, steps),\n })\n }\n\n visit(node.slice(2).filter(isNode), nodePath, projection.renderData)\n })\n }\n\n visit(document.body.nodes, [], createCmsComarkRenderData(document.body))\n\n return forms\n}\n\nfunction formRevision(name: string, capabilities: FormCapabilities, steps: ReadonlyArray<FormStep>): string {\n return JSON.stringify([name, capabilities, steps])\n}\n\nfunction isNode(value: Schema.Json | undefined): value is CmsMarkdownDocument['nodes'][number] {\n return Predicate.isString(value) || Array.isArray(value)\n}\n\nexport function formAuthoring(capabilities: FormCapabilities): BlockAuthoring {\n const prop = (\n name: string,\n label: string,\n type: BlockProp['type'],\n input: BlockProp['input'],\n extra: Partial<BlockProp> = {},\n ): BlockProp => ({ name, label, type, input, required: false, nullable: false, options: [], ...extra })\n\n const question = [\n prop('label', 'Question', 'string', 'text', { required: true, defaultValue: 'New question' }),\n prop('type', 'Answer type', 'string', 'select', {\n required: true,\n defaultValue: capabilities.fieldTypes[0],\n options: capabilities.fieldTypes.map((value) => ({ value, label: value })),\n }),\n prop('help', 'Help text', 'string', 'textarea'),\n ...capabilities.rules.map((rule) =>\n prop(\n rule,\n {\n required: 'Required',\n minLength: 'Minimum characters',\n maxLength: 'Maximum characters',\n min: 'Minimum value',\n max: 'Maximum value',\n }[rule],\n rule === 'required' ? 'boolean' : 'number',\n rule === 'required' ? 'toggle' : 'number',\n ),\n ),\n prop('options', 'Choices', 'array', 'list', {\n fields: [prop('label', 'Choice', 'string', 'text', { required: true, defaultValue: 'New choice' })],\n }),\n ]\n\n return {\n version: 1,\n label: capabilities.label,\n group: 'Forms',\n form: capabilities,\n props: [\n prop('steps', 'Steps', 'array', 'list', {\n required: true,\n fields: [\n prop('title', 'Step title', 'string', 'text', { required: true, defaultValue: 'New step' }),\n prop('fields', 'Questions', 'array', 'list', { required: true, fields: question }),\n ],\n }),\n ],\n slots: [],\n initialProps: {\n steps: [\n {\n id: 'first-step',\n title: 'Your details',\n fields: [\n {\n id: 'first-question',\n label: 'Your answer',\n type: capabilities.fieldTypes[0] ?? 'text',\n ...(capabilities.fieldTypes[0] === 'select'\n ? { options: [{ id: 'first-choice', label: 'First choice' }] }\n : undefined),\n },\n ],\n },\n ],\n },\n }\n}\n"],"mappings":";;;;;;AAUA,MAAMA,iBAAe,OAAO,GAAG,OAAO,UAAU;AAEhD,SAAgB,iBAAiB,UAAuD;CACtF,OAAO;EACL,aAAa,kBAAkB,SAAS,WAAW;EACnD,MAAM,kBAAkB,SAAS,IAAI;EACrC,OAAO,SAAS,MAAM,IAAI,YAAY;CACxC;AACF;AAEA,SAAgB,0BAA0B,UAA+C;CACvF,OAAO;EACL,MAAM,CAAC;EACP,aAAa,kBAAkB,SAAS,WAAW;EACnD,MAAM,kBAAkB,SAAS,IAAI;EACrC,OAAO,CAAC;CACV;AACF;;AAGA,SAAgB,qBAAqB,MAA4B;CAC/D,OAAO,YAAY,aAAa,IAAI,GAAG,EAAE,uBAAuB,KAAK,CAAC;AACxE;AAEA,SAAgB,0BAA0B,YAAsD;CAC9F,MAAM,SAAgC,CAAC;CAEvC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,IAAI,SAAS,KAAK,OAAO,QAAQ,YAAY,KAAK;CAGpD,MAAM,WAAWC,aAAW,WAAW,CAAC;CACxC,MAAM,OAAO,SAAS;CACtB,MAAM,OAAO,WAAW,SAAS,IAAI;CACrC,MAAM,QAAQ,WAAW,SAAS,KAAK;CAEvC,IAAI,UAAU,SAAS,IAAI,KAAK,SAAS,UAAa,UAAU,QAAW;EACzE,MAAM,WAAmC,CAAC;EAE1C,IAAI,UAAU,SAAS,IAAI,GAAG,SAAS,OAAO;EAE9C,IAAI,SAAS,QAAW,SAAS,OAAO;EAExC,IAAI,UAAU,QAAW,SAAS,QAAQ;EAC1C,OAAO,IAAI;CACb;CAEA,OAAO;AACT;AAEA,SAAgB,YAAY,OAAiC;CAC3D,IAAI,MAAM,QAAQ,KAAK,GAA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F,KAAK,QAAQ,eAAe,UAAU,UAAU;GAC9C,UAAU;GACV,cAAc,aAAa,WAAW;GACtC,SAAS,aAAa,WAAW,KAAK,WAAW;IAAE;IAAO,OAAO;GAAM,EAAE;EAC3E,CAAC;EACD,KAAK,QAAQ,aAAa,UAAU,UAAU;EAC9C,GAAG,aAAa,MAAM,KAAK,SACzB,KACE,MACA;GACE,UAAU;GACV,WAAW;GACX,WAAW;GACX,KAAK;GACL,KAAK;EACP,EAAE,OACF,SAAS,aAAa,YAAY,UAClC,SAAS,aAAa,WAAW,QACnC,CACF;EACA,KAAK,WAAW,WAAW,SAAS,QAAQ,EAC1C,QAAQ,CAAC,KAAK,SAAS,UAAU,UAAU,QAAQ;GAAE,UAAU;GAAM,cAAc;EAAa,CAAC,CAAC,EACpG,CAAC;CACH;CAEA,OAAO;EACL,SAAS;EACT,OAAO,aAAa;EACpB,OAAO;EACP,MAAM;EACN,OAAO,CACL,KAAK,SAAS,SAAS,SAAS,QAAQ;GACtC,UAAU;GACV,QAAQ,CACN,KAAK,SAAS,cAAc,UAAU,QAAQ;IAAE,UAAU;IAAM,cAAc;GAAW,CAAC,GAC1F,KAAK,UAAU,aAAa,SAAS,QAAQ;IAAE,UAAU;IAAM,QAAQ;GAAS,CAAC,CACnF;EACF,CAAC,CACH;EACA,OAAO,CAAC;EACR,cAAc,EACZ,OAAO,CACL;GACE,IAAI;GACJ,OAAO;GACP,QAAQ,CACN;IACE,IAAI;IACJ,OAAO;IACP,MAAM,aAAa,WAAW,MAAM;IACpC,GAAI,aAAa,WAAW,OAAO,WAC/B,EAAE,SAAS,CAAC;KAAE,IAAI;KAAgB,OAAO;IAAe,CAAC,EAAE,IAC3D;GACN,CACF;EACF,CACF,EACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Forms-CfcI3tPU.js","names":[],"sources":["../../../../protocol/src/Forms.ts"],"sourcesContent":["import { Schema } from 'effect'\nimport { DocumentId } from './internal/documents/scalars'\n\nexport const FORM_SUBMISSION_MAX_BYTES = 128 * 1024\n\n/** Budget for the JSON-escaped revision, leaving space for the envelope and answers. */\nexport const FORM_REVISION_MAX_BYTES = 60000\n\nexport type FormFieldType = 'text' | 'email' | 'textarea' | 'number' | 'checkbox' | 'select'\n\nexport const FormFieldType: Schema.Codec<FormFieldType> = Schema.Literals([\n 'text',\n 'email',\n 'textarea',\n 'number',\n 'checkbox',\n 'select',\n])\n\nexport type FormRule = 'required' | 'minLength' | 'maxLength' | 'min' | 'max'\n\nexport const FormRule: Schema.Codec<FormRule> = Schema.Literals(['required', 'minLength', 'maxLength', 'min', 'max'])\n\nexport interface FormCapabilities {\n readonly label: string\n readonly fieldTypes: ReadonlyArray<FormFieldType>\n readonly rules: ReadonlyArray<FormRule>\n}\n\nexport const FormCapabilities: Schema.Codec<FormCapabilities> = Schema.Struct({\n label: Schema.NonEmptyString,\n fieldTypes: Schema.Array(FormFieldType).check(Schema.isMinLength(1)),\n rules: Schema.Array(FormRule),\n})\n\nexport interface FormOption {\n readonly id: string\n readonly label: string\n}\n\nexport const FormOption: Schema.Codec<FormOption> = Schema.Struct({\n id: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n})\n\nexport interface FormField {\n readonly id: string\n readonly label: string\n readonly type: FormFieldType\n readonly help?: string\n readonly required?: boolean\n readonly minLength?: number\n readonly maxLength?: number\n readonly min?: number\n readonly max?: number\n readonly options?: ReadonlyArray<FormOption>\n}\n\nexport const FormField: Schema.Codec<FormField> = Schema.Struct({\n id: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n type: FormFieldType,\n help: Schema.optionalKey(Schema.String),\n required: Schema.optionalKey(Schema.Boolean),\n minLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n maxLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n min: Schema.optionalKey(Schema.Finite),\n max: Schema.optionalKey(Schema.Finite),\n options: Schema.optionalKey(Schema.Array(FormOption)),\n})\n\nexport interface FormStep {\n readonly id: string\n readonly title: string\n readonly fields: ReadonlyArray<FormField>\n}\n\nexport const FormStep: Schema.Codec<FormStep> = Schema.Struct({\n id: Schema.NonEmptyString,\n title: Schema.NonEmptyString,\n fields: Schema.Array(FormField).check(Schema.isMinLength(1), Schema.isMaxLength(100)),\n})\n\nexport const FormSteps: Schema.Codec<ReadonlyArray<FormStep>> = Schema.Array(FormStep).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(20),\n)\n\nexport interface FormReference {\n readonly documentId: DocumentId\n readonly nodePath: ReadonlyArray<number>\n readonly revision: string\n}\n\nconst referenceFields = {\n documentId: DocumentId,\n nodePath: Schema.Array(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n ),\n revision: Schema.String.check(Schema.isMaxLength(FORM_REVISION_MAX_BYTES)),\n}\n\nexport const FormReference: Schema.Codec<\n FormReference,\n { readonly documentId: string; readonly nodePath: ReadonlyArray<number>; readonly revision: string }\n> = Schema.Struct(referenceFields)\n\nexport interface FormDefinition extends FormReference {\n readonly name: string\n readonly steps: ReadonlyArray<FormStep>\n readonly preview: boolean\n}\n\nexport type FormValues = Readonly<Record<string, string | number | boolean | null>>\n\nexport const FormValues: Schema.Codec<FormValues> = Schema.Record(\n Schema.String,\n Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.Null]),\n)\n\nexport interface FormSubmission extends FormReference {\n readonly values: FormValues\n}\n\nexport const FormSubmission: Schema.Codec<\n FormSubmission,\n {\n readonly documentId: string\n readonly nodePath: ReadonlyArray<number>\n readonly revision: string\n readonly values: FormValues\n }\n> = Schema.Struct({ ...referenceFields, values: FormValues })\n\nexport interface FormResult {\n readonly status: 'accepted' | 'invalid' | 'stale' | 'unavailable' | 'failed'\n readonly errors: Readonly<Record<string, string>>\n}\n\nexport const FormResult: Schema.Codec<FormResult> = Schema.Struct({\n status: Schema.Literals(['accepted', 'invalid', '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