@pebble-software/bonsai 0.3.0 → 0.4.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.
Files changed (32) hide show
  1. package/README.md +30 -14
  2. package/dist/ast.js +1 -1
  3. package/dist/chunks/{builder.meta-B7Y9M7Ab.js → builder.meta-DKq-ggkn.js} +3 -3
  4. package/dist/chunks/{builder.meta-B7Y9M7Ab.js.map → builder.meta-DKq-ggkn.js.map} +1 -1
  5. package/dist/chunks/class-names-CoKRVvWM.js +66 -0
  6. package/dist/chunks/class-names-CoKRVvWM.js.map +1 -0
  7. package/dist/chunks/{create-renderer-kgClEYyp.js → create-renderer-CSFyNcqr.js} +2 -2
  8. package/dist/chunks/{create-renderer-kgClEYyp.js.map → create-renderer-CSFyNcqr.js.map} +1 -1
  9. package/dist/chunks/{index-CD5pykpk.js → index-df-PhUtD.js} +2 -2
  10. package/dist/chunks/{index-CD5pykpk.js.map → index-df-PhUtD.js.map} +1 -1
  11. package/dist/chunks/{render-shared-CrG0OFhJ.js → render-shared-DSYQFhTh.js} +2 -2
  12. package/dist/chunks/{render-shared-CrG0OFhJ.js.map → render-shared-DSYQFhTh.js.map} +1 -1
  13. package/dist/classes.d.ts +28 -10
  14. package/dist/classes.js +21 -12
  15. package/dist/classes.js.map +1 -1
  16. package/dist/classes.json +1 -1
  17. package/dist/components/ui/signature-pad.d.ts +2 -2
  18. package/dist/constants.js +7 -2
  19. package/dist/constants.js.map +1 -1
  20. package/dist/core.js +3 -3
  21. package/dist/css.d.ts +42 -0
  22. package/dist/css.js +7483 -0
  23. package/dist/css.js.map +1 -0
  24. package/dist/index.js +200 -245
  25. package/dist/index.js.map +1 -1
  26. package/dist/lib/ast/class-names.d.ts +18 -3
  27. package/dist/library/constants/src/components.d.ts +1 -0
  28. package/dist/presets/signature.js +2 -2
  29. package/dist/presets/signature.js.map +1 -1
  30. package/dist/schemas.js +1 -1
  31. package/dist/styles/presets.json +2 -1
  32. package/package.json +6 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../library/schemas/src/common.ts","../../../library/schemas/src/api.schema.ts","../../../library/schemas/src/entities/user.schema.ts","../../../library/schemas/src/entities/organization.schema.ts","../../../library/schemas/src/entities/organization-user.schema.ts","../../../library/schemas/src/entities/template.schema.ts","../../../library/schemas/src/entities/form-request.schema.ts","../../../library/schemas/src/entities/api-key.schema.ts","../../../library/schemas/src/entities/webhook.schema.ts","../../../library/schemas/src/entities/jwt.schema.ts","../../../library/schemas/src/entities/file.schema.ts","../../../library/schemas/src/entities/pdf-request.schema.ts","../../../library/schemas/src/index.ts","../src/lib/ui/registry.ts","../src/lib/registry/pebble-registry.ts","../src/lib/ast/class-names.ts","../src/lib/registry/identity.ts","../src/lib/registry/validate.ts","../src/lib/registry/json-schema-to-zod.ts","../src/lib/registry/manifest-schema.ts","../src/lib/registry/manifest.ts","../src/lib/registry/merge-generated.ts","../src/lib/registry/drift.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** MongoDB ObjectId as a 24-character hex string (transport layer — no Mongoose coupling) */\nexport const OID = z.string().length(24).meta({\n description: \"MongoDB ObjectId (24-character hex string)\",\n example: \"67e091ab2c4d3f22001a2b3c\",\n});\n\n/** Valid email address */\nexport const EMAIL = z.string().email().meta({\n description: \"Valid email address\",\n example: \"jack@datahaven.net\",\n});\n\n/** ISO 8601 datetime string with timezone offset */\nexport const TIMESTAMP = z.string().datetime({ offset: true }).meta({\n description: \"ISO 8601 datetime with optional timezone offset\",\n example: \"2077-12-25T23:59:59Z\",\n});\n\n/** A boolean or string-coerced boolean (common in HTML attribute bindings like 'disabled', 'checked') */\nexport const BOOLISH = z.union([z.boolean(), z.string()]).meta({\n description: \"Boolean or string-coerced boolean ('true'/'false')\",\n example: true,\n});\n","import { z } from \"zod\";\n\n// ── Response Envelope ─────────────────────────────────────────────────────────\n// Reusable wrappers for the standard {message, data} / {error} envelope.\n// The docs server calls these with the per-endpoint data shape.\n\n/** Wrap a data schema in the success envelope */\nexport const API_SUCCESS = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z.object({\n message: z.string().meta({ description: \"Human-readable status message\", example: \"Success\" }),\n data: dataSchema.optional().meta({ description: \"Response payload\" }),\n }).meta({ description: \"Successful API response\" });\n\n/** Standard error response envelope */\nexport const API_ERROR = z.object({\n error: z.string().meta({ description: \"Human-readable error description\", example: \"Forbidden — no access to this resource\" }),\n data: z.any().optional().meta({ description: \"Additional error context (if available)\" }),\n}).meta({ description: \"Error API response\" });\n\n/** Convenience union — caller passes a data schema to get {message, data?} | {error} */\nexport function API_RESPONSE<T extends z.ZodTypeAny>(dataSchema: T) {\n return z.union([API_SUCCESS(dataSchema), API_ERROR]);\n}\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── User ─────────────────────────────────────────────────────────────────────\n\nexport const UserSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n email: z.string().email().meta({\n description: \"User's email address (used as the primary identifier)\",\n example: \"jack@datahaven.net\",\n readOnly: true,\n }),\n name: z.string().min(1).max(100).meta({ description: \"Full display name\", example: \"Razor Jack\" }),\n emailVerified: z.boolean().nullable().optional().meta({ description: \"Whether the user's email has been verified\" }),\n image: z.string().optional().meta({ description: \"Avatar image URL\", example: \"https://cdn.datahaven.net/avatars/rj7741.png\" }),\n createdAt: TIMESTAMP.optional().meta({ description: \"When the user account was created\", readOnly: true }),\n updatedAt: TIMESTAMP.optional().meta({ description: \"When the user account was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"An authenticated user account. Users are distinct from organization memberships — a user may belong to multiple organizations.\",\n});\n\n// ── Edit User Request ────────────────────────────────────────────────────────\n\nexport const EditUserRequestSchema = z.object({\n name: z.string().min(1).optional().meta({ description: \"Updated display name\", example: \"Cyber Jack\" }),\n image: z.string().optional().meta({ description: \"Updated avatar URL\", example: \"https://cdn.datahaven.net/avatars/cj7741.png\" }),\n}).strict().meta({ description: \"Update the authenticated user's profile\" });\n","import { z } from \"zod\";\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Organization ──────────────────────────────────────────────────────────────\n\nexport const OrganizationSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n clientId: z.string().min(1).meta({ description: \"Unique client identifier for the organization\", example: \"pb-org-7f3a2b9c\", readOnly: true }),\n name: z.string().min(3).max(50).meta({ description: \"Unique organization slug/identifier\", example: \"neon-shadow\" }),\n displayName: z.string().min(3).max(50).meta({ description: \"Human-readable organization name shown in UI and emails\", example: \"Neon Shadow Corp\" }),\n legalName: z.string().min(3).max(50).meta({ description: \"Legal business name for contracts and compliance\", example: \"Neon Shadow Corporation Ltd.\" }),\n legalAddress: z.string().min(3).max(100).meta({ description: \"Registered business address\", example: \"42 Cyber Avenue, Night City, NC 20777\" }),\n contactEmail: z.string().email().meta({ description: \"Primary contact email for the organization\", example: \"legal@neon-shadow.io\" }),\n icon: z.string().meta({ description: \"Organization icon/logo URL\", example: \"https://cdn.neon-shadow.io/icon.png\" }),\n banner: z.string().nullable().optional().meta({ description: \"Organization banner image URL\", example: \"https://cdn.neon-shadow.io/banner.png\" }),\n createdBy: OID.meta({ description: \"User ObjectId who created the organization\", readOnly: true }),\n customerId: z.string().optional().nullable().meta({ description: \"Stripe customer ID for billing\", example: \"cus_9x8y7z6w5v4u3t2s\", readOnly: true }),\n subscriptionId: z.string().optional().nullable().meta({ description: \"Stripe subscription ID\", example: \"sub_1A2B3C4D5E6F7G8H\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the organization was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the organization was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A tenant organization. Each organization has its own isolated workspace, templates, signature requests, and API keys.\",\n});\n\n// ── Requests ─────────────────────────────────────────────────────────────────\n\nexport const CreateOrganizationRequestSchema = z.object({\n name: z.string().min(3).max(50).meta({ description: \"Unique organization slug/identifier\", example: \"neon-shadow\" }),\n displayName: z.string().min(3).max(50).meta({ description: \"Human-readable name shown in UI\", example: \"Neon Shadow Corp\" }),\n legalName: z.string().min(3).max(50).meta({ description: \"Legal business name\", example: \"Neon Shadow Corporation Ltd.\" }),\n legalAddress: z.string().min(3).max(100).meta({ description: \"Registered business address\", example: \"42 Cyber Avenue, Night City, NC 20777\" }),\n contactEmail: z.string().email().meta({ description: \"Primary contact email\", example: \"legal@neon-shadow.io\" }),\n icon: z.string().meta({ description: \"Organization icon/logo URL\", example: \"https://cdn.neon-shadow.io/icon.png\" }),\n}).strict().meta({ description: \"Create a new organization\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Organization User ─────────────────────────────────────────────────────────\n\nexport const OrganizationUserSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n organization: OID.meta({ description: \"The organization this membership belongs to\", readOnly: true }),\n user: OID.meta({ description: \"The user who is a member of the organization\", readOnly: true }),\n role: z.string().min(1).meta({ description: \"Role identifier (e.g. 'admin', 'member', 'viewer')\", example: \"admin\" }),\n permissions: z.string().min(1).meta({ description: \"Permission set identifier or JSON string\", example: \"{\\\"templates\\\":\\\"rw\\\",\\\"forms\\\":\\\"r\\\"}\" }),\n status: z.enum([\"active\", \"inactive\", \"blocked\"]).meta({ description: \"Membership status\", example: \"active\" }),\n lastLogin: TIMESTAMP.nullable().meta({ description: \"When the user last logged into this organization\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the membership was created\", readOnly: true }),\n updatedAt: TIMESTAMP.optional().meta({ description: \"When the membership was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A user's membership within an organization. This links a User to an Organization and defines their role and permissions.\",\n});\n\n// ── Requests ─────────────────────────────────────────────────────────────────\n\nexport const InviteOrganizationUserRequestSchema = z.object({\n email: z.string().email().meta({ description: \"Email address of the user to invite\", example: \"jack@datahaven.net\" }),\n name: z.string().min(3).meta({ description: \"Display name of the invited user\", example: \"Razor Jack\" }),\n role: z.string().min(2).meta({ description: \"Role to assign (e.g. 'admin', 'member')\", example: \"member\" }),\n image: z.string().optional().meta({ description: \"Avatar URL for the invited user\", example: \"https://cdn.datahaven.net/avatars/rj7741.png\" }),\n permissions: z.string().min(1).meta({ description: \"Permission set to assign\", example: \"{\\\"templates\\\":\\\"r\\\",\\\"forms\\\":\\\"rw\\\"}\" }),\n}).strict().meta({ description: \"Invite a user to join an organization\" });\n\nexport const EditOrganizationUserRequestSchema = z.object({\n _id: OID.meta({ description: \"OrganizationUser membership MongoDB ObjectId\", readOnly: true }),\n role: z.string().min(2).meta({ description: \"Updated role\", example: \"viewer\" }),\n permissions: z.string().min(1).meta({ description: \"Updated permission set\", example: \"{\\\"templates\\\":\\\"r\\\"}\" }),\n}).strict().meta({ description: \"Update an organization user's role or permissions\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── Template ──────────────────────────────────────────────────────────────────\n\n/**\n * The builder's own document for a template (blocks, editor ids). Opaque to the\n * API and SSR, which only ever read `config`; `version` lets the builder migrate\n * older documents.\n */\nexport const TemplateSource = z\n .looseObject({\n version: z.number().int().positive().meta({ description: \"Builder document format version\" }),\n })\n .meta({ description: \"Builder source document the config was compiled from (editor-only)\" });\n\nexport const TemplateSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n organization: OID.meta({ description: \"Organization that owns this template\", readOnly: true }),\n createdBy: OID.meta({ description: \"OrganizationUser ID who created this template\", readOnly: true }),\n name: z.string().min(1).meta({ description: \"Template name (unique within the organization)\", example: \"Neural_NDA_v3\" }),\n description: z.string().default(\"\").meta({ description: \"Human-readable description of the template's purpose\", example: \"Standard non-disclosure agreement with neural implant data clause\" }),\n config: z.any().meta({ description: \"The Bonsai component tree defining the template layout and fields\" }),\n source: TemplateSource.optional(),\n header: z.string().optional().meta({ description: \"A small Bonsai component tree used for page headers in PDF rendering output\" }),\n footer: z.string().optional().meta({ description: \"A small Bonsai component tree used for page footers in PDF rendering output\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the serialized config, used for deduplication\", example: \"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1\" }),\n css: z.string().optional().meta({ description: \"Generated Tailwind CSS for the template layout\" }),\n tags: z.array(z.string()).default([]).meta({ description: \"Tags for organizing and discovering templates\", example: [\"nda\", \"legal\", \"neural-interface\"] }),\n active: z.boolean().default(true).meta({ description: \"Whether the template is active and available for use\" }),\n lastUsed: TIMESTAMP.nullable().optional().meta({ description: \"When the template was last referenced in a signature request\", readOnly: true }),\n usageCount: z.number().default(0).meta({ description: \"Total number of signature requests created from this template\" }),\n version: z.number().default(1).meta({ description: \"Template schema version (increments on significant config changes)\" }),\n createdAt: TIMESTAMP.meta({ description: \"When the template was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the template was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A reusable Bonsai signature template. Templates define the form layout via a component tree and can be referenced by ID when creating signature requests.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/template — Create a new template */\nexport const CreateTemplateRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the template\" }),\n name: z.string().min(1).meta({ description: \"Template name (must be unique within the organization)\", example: \"Neural_NDA_v3\" }),\n description: z.string().optional().meta({ description: \"Optional description of the template's purpose\", example: \"Standard NDA with neural implant clause\" }),\n config: Config.meta({ description: \"The Bonsai component tree that defines the template layout\" }),\n source: TemplateSource.optional(),\n pdf: z.object({\n header: Config.optional().meta({ description: \"PDF header Bonsai component tree\" }),\n footer: Config.optional().meta({ description: \"PDF footer Bonsai component tree\" }),\n }).optional(),\n tags: z.array(z.string()).optional().meta({ description: \"Tags for organizing and filtering templates\", example: [\"nda\", \"legal\"] }),\n}).strict().meta({ description: \"Create a new reusable signature template\" });\n\n/** PUT /v1/template/{id} — Replace a template's content */\nexport const UpdateTemplateRequest = z.object({\n name: z.string().min(1).optional().meta({ description: \"New template name (must be unique within the organization)\" }),\n description: z.string().optional().meta({ description: \"New description\" }),\n config: Config.optional().meta({ description: \"Replacement Bonsai component tree; CSS and content hash are recomputed\" }),\n source: TemplateSource.optional(),\n pdf: z.object({\n header: Config.optional().meta({ description: \"PDF header Bonsai component tree\" }),\n footer: Config.optional().meta({ description: \"PDF footer Bonsai component tree\" }),\n }).optional(),\n tags: z.array(z.string()).optional().meta({ description: \"Replacement tags\" }),\n}).strict()\n .refine((body) => Object.keys(body).length > 0, { message: \"Provide at least one field to update\" })\n .meta({ description: \"Update an existing template\" });\n\nexport const UpdateTemplateResponseData = z.object({\n id: z.string().meta({ description: \"MongoDB ObjectId of the template\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n name: z.string().meta({ description: \"Template name\", example: \"Neural_NDA_v3\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the config after the update\" }),\n version: z.number().meta({ description: \"Template version after the update\" }),\n}).strict().meta({ description: \"Updated template summary\" });\n\nexport const CreateTemplateResponseData = z.object({\n id: z.string().meta({ description: \"MongoDB ObjectId of the created template\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n name: z.string().meta({ description: \"Template name\", example: \"Neural_NDA_v3\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the config, useful for deduplication\" }),\n}).strict().meta({ description: \"Created template summary\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── Form Request ──────────────────────────────────────────────────────────────\n\nexport const FormRequestStatus = z.enum([\n \"pending\", \"captured\", \"completed\", \"error\", \"revoked\",\n]);\nexport type FormRequestStatus = z.infer<typeof FormRequestStatus>;\n\nexport const FormRequestSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public-facing unique request ID (random hex string)\", example: \"fr_a7b8c9d0e1f2\", readOnly: true }),\n token: z.string().meta({ description: \"Verification token used for cookie-based auth in the signer's browser\", readOnly: true }),\n email: z.string().email().meta({ description: \"Recipient email address where the signature link was sent\", example: \"jack@datahaven.net\" }),\n name: z.string().min(1).meta({ description: \"Recipient's display name\", example: \"Razor Jack\" }),\n attachments: z.array(z.string()).optional().meta({ description: \"Array of attachment URLs included with the form\", example: [\"https://files.datahaven.net/nda_v3.pdf\"] }),\n data: z.any().optional().meta({ description: \"Form field data submitted by the signer\" }),\n webhooks: z.array(OID).optional().meta({ description: \"Webhook ObjectIds notified on lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"Capture-time metadata such as IP address, user agent, and timestamps\" }),\n expiry: TIMESTAMP.meta({ description: \"When the signature request link expires\" }),\n due: TIMESTAMP.optional().nullable().meta({ description: \"Soft deadline for completing the signature\" }),\n digest: z.string().meta({ description: \"SHA-256 hash of the serialized payload, used for deduplication\", readOnly: true }),\n template: z.any().meta({ description: \"Snapshot of the Bonsai component tree config at the time of form creation\", readOnly: true }),\n header: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering\", readOnly: true }),\n footer: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering\", readOnly: true }),\n css: z.string().meta({ description: \"Tailwind CSS generated from the template at the time of form creation\", readOnly: true }),\n status: FormRequestStatus.meta({ description: \"Current lifecycle status of the form request\", example: \"pending\" }),\n organization: OID.meta({ description: \"Organization that owns this form request\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the form request was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the form request was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A signature request sent to a recipient. Tracks the full lifecycle from creation through signing, completion, or revocation.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/form — Create a new signature request */\nexport const CreateFormRequest = z.object({\n name: z.string().min(1).meta({ description: \"Recipient's display name (used in the email greeting and form header)\", example: \"Razor Jack\" }),\n email: z.string().email().meta({ description: \"Recipient email address where the signature link will be sent\", example: \"jack@datahaven.net\" }),\n template: z.union([Config, z.string()]).meta({\n description: \"Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the form layout\",\n }),\n expiry: z.coerce.date().optional().meta({ description: \"When the signature request link expires (ISO 8601 date)\", example: \"2077-12-25T23:59:59Z\" }),\n due: z.coerce.date().optional().meta({ description: \"Soft deadline for the signature (ISO 8601 date)\", example: \"2077-12-20T18:00:00Z\" }),\n webhooks: z.array(z.string()).min(1).meta({ description: \"Array of webhook ObjectIds to notify on form lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n attachments: z.array(z.string()).optional().meta({ description: \"Array of attachment URLs to include with the form\", example: [\"https://files.datahaven.net/nda_v3.pdf\"] }),\n metadata: z.any().optional().meta({ description: \"Arbitrary metadata to associate with the form request\", example: { department: \"Legal\", priority: \"high\" } }),\n data: z.any().optional().meta({ description: \"Pre-filled form field data to populate the form on load\", example: { full_name: \"Razor Jack\", badge_id: \"RJ-7741\" } }),\n pdf: z.union([z.boolean(), z.object({\n header: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n })]).optional().meta({ description: \"PDF file config object (header||footer) or `true/false` boolean to trigger PDF file generation after form capture\" }),\n}).strict().meta({ description: \"Create a new signature request targeting a recipient\" });\n\nexport const CreateFormRequestResponseData = z.object({\n formId: z.string().meta({ description: \"MongoDB ObjectId of the newly created form request\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n}).strict().meta({ description: \"Created form request identifier\" });\n\n/** POST /v1/form/{id}/revoke — Revoke a pending form request */\nexport const RevokeFormRequest = z.object({\n reason: z.string().optional().meta({ description: \"Optional explanation for why the form was revoked (logged for audit)\", example: \"Signer compromised — ICE breach detected on endpoint\" }),\n}).strict().meta({ description: \"Payload for revoking a signature request\" });\n\n/** POST /v1/form/{id}/resend — Re-send the signature request email */\nexport const ResendFormRequestEmail = z.object({\n email: z.string().email().optional().meta({ description: \"Override the recipient email address (uses the original if omitted)\", example: \"jack@neon-shadow.io\" }),\n}).strict().meta({ description: \"Payload for re-sending the signature request email\" });\n\n/** POST /v1/capture — Submit form data from the signer's browser */\nexport const SubmitCaptureRequest = z.object({\n data: z.record(z.string(), z.any()).optional().meta({\n description: \"Form field data collected from the signer\",\n example: { signature: \"data:image/png;base64,iVBOR...\", accepted_terms: true },\n }),\n}).strict().meta({ description: \"Submit captured form data from the signer's browser session\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── API Key ───────────────────────────────────────────────────────────────────\n\nexport const ApiKeySchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public key identifier (e.g. pb-xxxx). Used as the 'client' field when authenticating.\", example: \"pb-a7f3b2c9d1e8f4a5b6c7d8e9\", readOnly: true }),\n secret: z.string().meta({ description: \"Encrypted API key secret — only viewable at creation time\", readOnly: true }),\n allowedOrigins: z.array(z.string()).default([]).meta({ description: \"CORS origin allowlist. Requests from origins not in this list are rejected.\", example: [\"https://console.neon-shadow.io\"] }),\n allowedIps: z.array(z.string()).default([]).meta({ description: \"IP CIDR allowlist. Requests from IPs not in this list are rejected.\", example: [\"203.0.113.0/24\"] }),\n active: z.boolean().default(true).meta({ description: \"Whether the key is active and can be used for authentication\" }),\n expiry: TIMESTAMP.meta({ description: \"When the API key expires and can no longer be used\" }),\n lastUsed: TIMESTAMP.meta({ description: \"Timestamp of the most recent request using this key\", readOnly: true }),\n audience: z.enum([\"internal\", \"external\"]).meta({ description: \"Key audience — 'internal' for server-to-server, 'external' for client-side\", example: \"internal\" }),\n organization: OID.meta({ description: \"Organization this key belongs to\", readOnly: true }),\n generatedBy: OID.meta({ description: \"OrganizationUser ID who created this key\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the API key was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the API key was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"An API key scoped to an organization. Each key has configurable IP and origin restrictions for fine-grained access control.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/api-key — Create a new API key */\nexport const CreateApiKeyRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the API key\" }),\n expiry: z.coerce.date().optional().meta({ description: \"Key expiration date (defaults to +1 year from creation)\", example: \"2078-12-19T00:00:00Z\" }),\n audience: z.enum([\"internal\", \"external\"]).meta({ description: \"Key audience — 'internal' for server-to-server, 'external' for client-side usage\", example: \"internal\" }),\n allowedOrigins: z.array(z.string()).optional().meta({ description: \"CORS origin allowlist (e.g. ['https://app.example.com']). Empty array disables origin restriction.\", example: [\"https://console.neon-shadow.io\", \"https://api.datahaven.net\"] }),\n allowedIps: z.array(z.string()).optional().meta({ description: \"IP CIDR allowlist (e.g. ['203.0.113.0/24']). Empty array disables IP restriction.\", example: [\"203.0.113.0/24\", \"10.0.0.0/8\"] }),\n}).strict().meta({ description: \"Payload for creating a new API key\" });\n\nexport const CreateApiKeyResponseData = z.object({\n id: z.string().meta({ description: \"Public API key ID (e.g. pb-xxxx)\", example: \"pb-a7f3b2c9d1e8f4a5b6c7d8e9\", readOnly: true }),\n secret: z.string().meta({ description: \"API key secret — **this is the only time the secret is returned**. Store it securely.\", readOnly: true }),\n}).strict().meta({ description: \"API key credentials — the secret is only shown once\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Webhook ───────────────────────────────────────────────────────────────────\n\nexport const WebhookSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public webhook identifier (e.g. pb-wbhk-xxxx)\", example: \"pb-wbhk-a7b8c9d0\", readOnly: true }),\n url: z.string().url().meta({ description: \"HTTPS endpoint receiving POST event notifications\", example: \"https://hooks.datahaven.net/events\" }),\n secret: z.string().meta({ description: \"HMAC-SHA256 signing secret — used to verify that webhook payloads genuinely came from Bonsai\", readOnly: true }),\n active: z.boolean().default(true).meta({ description: \"Whether the webhook is active and receiving events\" }),\n lastUsed: TIMESTAMP.meta({ description: \"When the webhook last received an event\", readOnly: true }),\n organization: OID.meta({ description: \"Organization that owns this webhook\", readOnly: true }),\n generatedBy: OID.meta({ description: \"OrganizationUser ID who created this webhook\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the webhook was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the webhook was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A webhook destination for form request lifecycle events. When a form is created, signed, or revoked, Bonsai sends a POST request to this URL with a JSON payload signed via HMAC-SHA256.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/webhook — Create a new webhook destination */\nexport const CreateWebhookRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the webhook\" }),\n url: z.string().url().meta({ description: \"HTTPS endpoint that will receive POST event notifications\", example: \"https://hooks.datahaven.net/events\" }),\n}).strict().meta({ description: \"Payload for creating a new webhook destination\" });\n\nexport const CreateWebhookResponseData = z.object({\n id: z.string().meta({ description: \"Webhook MongoDB ObjectId\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n secret: z.string().meta({ description: \"HMAC signing secret — **this is the only time the secret is returned**. Use it to verify webhook payload authenticity.\", readOnly: true }),\n}).strict().meta({ description: \"Webhook credentials — the signing secret is only shown once\" });\n","import { z } from \"zod\";\n\n// ── JWT / Auth ────────────────────────────────────────────────────────────────\n\n/** POST /v1/token — Exchange API key credentials for a JWT */\nexport const GenerateTokenRequest = z.object({\n client: z.string().min(1).meta({ description: \"API key ID (e.g. pb-xxxx)\", example: \"pb-7f3a2b9c1d8e4f5a6b7c8d9e\" }),\n secret: z.string().min(1).meta({ description: \"API key secret\", example: \"sk_liv...1f0e\" }),\n refresh: z.boolean().optional().meta({ description: \"If true, also issues a refresh token (30 day expiry)\", example: true }),\n}).strict().meta({ description: \"Credentials for obtaining a JWT access token\" });\n\nexport const GenerateTokenResponseData = z.object({\n token: z.string().meta({ description: \"JWT access token (1 hour expiry). Include as Bearer token in subsequent requests.\", example: \"eyJhbGciOiJIUzI1NiIs...f456\" }),\n refresh: z.string().optional().meta({ description: \"Refresh token (30 day expiry). Use at POST /v1/token/refresh to get a new JWT without re-entering credentials.\", example: \"rt_live_8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d\" }),\n}).strict().meta({ description: \"Token response containing JWT and optional refresh token\" });\n\n/** POST /v1/token/refresh — Exchange a refresh token for a new JWT */\nexport const RefreshTokenRequest = z.object({\n refreshToken: z.string().min(1).meta({ description: \"Refresh token obtained from a prior POST /v1/token response\", example: \"rt_live_8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d\" }),\n}).strict().meta({ description: \"Request to refresh an expired JWT using a refresh token\" });\n\nexport const RefreshTokenResponseData = z.object({\n token: z.string().meta({ description: \"New JWT access token (1 hour expiry)\", example: \"eyJhbGciOiJIUzI1NiIs...c012\" }),\n}).strict().meta({ description: \"New JWT access token\" });\n","import { z } from \"zod\";\n\n// ── File MIME Types ───────────────────────────────────────────────────────────\n\nexport const FileMimeType = z.enum([\n \"application/pdf\",\n \"image/png\",\n \"image/jpeg\",\n \"image/webp\",\n \"text/plain\",\n \"text/csv\",\n]);\nexport type FileMimeType = z.infer<typeof FileMimeType>;\n\n// ── Signed Download URL ───────────────────────────────────────────────────────\n\n/** GET /v1/file/{id}/url — Get a signed GCS download URL */\nexport const GetFileUrlQuery = z.object({\n ttl: z.coerce.number().int().min(60).max(86400).default(3600)\n .meta({ description: \"Signed URL lifetime in seconds (default 3600, min 60, max 86400 [24h])\", example: 3600 }),\n}).strict().meta({ description: \"Query parameters for generating a signed download URL\" });\n\nexport const GetFileUrlResponseData = z.object({\n downloadUrl: z.string().url().meta({ description: \"Pre-signed GCS download URL\", example: \"https://storage.googleapis.com/bonsai-secure/f1e2d3...X-Goog-Signature=def456\" }),\n filename: z.string().meta({ description: \"Original filename (for Content-Disposition)\", example: \"signed_nda_razorjack.pdf\" }),\n mimeType: FileMimeType.meta({ description: \"MIME type (for Content-Type)\", example: \"application/pdf\" }),\n size: z.number().int().meta({ description: \"File size in bytes\", example: 245760 }),\n}).strict().meta({ description: \"Signed download URL for secure file access\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── PDF Request ──────────────────────────────────────────────────────────────\n\nexport const PDFRequestStatus = z.enum([\n \"pending\", \"generating\", \"completed\", \"error\", \"revoked\",\n]);\nexport type PDFRequestStatus = z.infer<typeof PDFRequestStatus>;\n\nexport const PDFRequestSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public-facing unique request ID (random hex string)\", example: \"fr_a7b8c9d0e1f2\", readOnly: true }),\n token: z.string().meta({ description: \"Verification token used for cookie-based auth in the signer's browser\", readOnly: true }),\n data: z.any().optional().meta({ description: \"Form field data submitted by the signer/requester\" }),\n webhooks: z.array(OID).optional().meta({ description: \"Webhook ObjectIds notified on lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"File metadata such as size, contentType, etc.\" }),\n digest: z.string().meta({ description: \"SHA-256 hash of the serialized payload, used for deduplication\", readOnly: true }),\n template: z.any().meta({ description: \"Snapshot of the Bonsai component tree config at the time of PDF creation\" }),\n header: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n css: z.string().meta({ description: \"Tailwind CSS generated from the template at the time of PDF generation request\", readOnly: true }),\n status: PDFRequestStatus.meta({ description: \"Current lifecycle status of the PDF request\", example: \"pending\" }),\n organization: OID.meta({ description: \"Organization that owns this PDF request\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the PDF request was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the PDF request was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A PDF request used to trigger the generation of a custom PDF file. Tracks the full lifecycle and alerts sends results via webhook.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/pdf — Create a new pdf file generation request */\nexport const CreatePDFRequest = z.object({\n template: z.union([Config, z.string()]).meta({\n description: \"Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the PDF content layout\",\n }),\n webhooks: z.array(z.string()).min(1).meta({ description: \"Array of webhook ObjectIds to notify on form lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"Arbitrary metadata to associate with the PDF request\", example: { department: \"Legal\", priority: \"high\" } }),\n data: z.any().optional().meta({ description: \"Pre-filled template field data to populate the PDF with\", example: { full_name: \"Razor Jack\", badge_id: \"RJ-7741\" } }),\n header: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n}).strict().meta({ description: \"Create a new PDF request to generate a PDF file from a Bonsai template\" });\n\nexport const CreatePDFRequestResponseData = z.object({\n pdfId: z.string().meta({ description: \"MongoDB ObjectId of the newly created PDF request (this is NOT the rendered pdf file - a file ID is returned after async pdf generation via webhook)\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n}).strict().meta({ description: \"Created form request identifier\" });\n","import zod from \"zod\";\nimport { createErrorMap } from \"zod-validation-error\";\n\nzod.config({\n customError: createErrorMap(),\n});\n\n// Common primitives (shared across schema files)\nexport * from \"./common\";\n\n// API response envelope + request/response schemas\nexport * from \"./api.schema\";\n\n// Bonsai UI component tree (the template DSL)\nexport * from \"./bonsai.schema\";\nexport * from \"./builder.meta\";\n\n// Domain entity schemas (for OpenAPI component schemas + docs)\nexport * from \"./entities/user.schema\";\nexport * from \"./entities/organization.schema\";\nexport * from \"./entities/organization-user.schema\";\nexport * from \"./entities/template.schema\";\nexport * from \"./entities/form-request.schema\";\nexport * from \"./entities/api-key.schema\";\nexport * from \"./entities/webhook.schema\";\nexport * from \"./entities/jwt.schema\";\nexport * from \"./entities/file.schema\";\nexport * from \"./entities/pdf-request.schema\";\n","import {\n coreComponents,\n coreControlledInputs,\n type ComponentRegistry,\n type ControlledInput,\n type ControlledInputEntry,\n type ControlledInputRegistry,\n} from \"../../renderer/core-registry\";\nimport { calendarPreset } from \"../../renderer/presets/calendar\";\nimport { signaturePreset } from \"../../renderer/presets/signature\";\n\n/**\n * The full, batteries-included registry: every core component plus the heavy\n * opt-in presets (calendar, signature). Importing this module transitively\n * pulls in react-day-picker and react-signature-canvas — use\n * `renderer/core-registry` if you want to stay lightweight.\n *\n * Typed with `ComponentRegistry`/`ControlledInputRegistry` (both\n * `Record<string, ...>`) rather than `Record<COMPONENT[number], ...>` from\n * `@bonsai/constants` — that package is workspace-only and unpublished, and\n * referencing its types here would bake an escaping import path into this\n * file's emitted declaration, the same class of bug fixed for `Config` in\n * `src/types.ts`. (`COMPONENT[number]`, a numeric index into a union of\n * string-literal enum members, was already widening to plain `string` here —\n * so `ComponentRegistry`/`ControlledInputRegistry` lose nothing.)\n */\nexport const componentMap: ComponentRegistry = {\n ...coreComponents,\n ...calendarPreset.components,\n ...signaturePreset.components,\n};\n\nexport const controlledInputMap: ControlledInputRegistry = {\n ...coreControlledInputs,\n ...calendarPreset.controlledInputs,\n ...signaturePreset.controlledInputs,\n};\n\nexport type { ControlledInput, ControlledInputEntry };\n","import { PEBBLE_COMPONENT_SCHEMAS } from \"@bonsai/schemas\";\nimport { componentMap, controlledInputMap } from \"../ui/registry\";\nimport { coreRegistry, extendRegistry } from \"../../renderer/core-registry\";\nimport { defineBonsaiRegistry, defineComponent } from \"./types\";\n\nconst builtIns = extendRegistry(coreRegistry, {\n components: componentMap,\n controlledInputs: controlledInputMap,\n});\n\n// The full built-in library: `coreRegistry`'s identity, every built-in component\n// (heavy presets included), plus each component's `propsSchema` for `validateTemplate`.\nexport const pebbleRegistry = defineBonsaiRegistry({\n ...builtIns,\n components: Object.fromEntries(\n Object.entries(builtIns.components).map(([type, def]) => [\n type,\n defineComponent({ ...def, propsSchema: PEBBLE_COMPONENT_SCHEMAS[type]?.argsSchema }),\n ]),\n ),\n});\n","import { compileExpression } from \"./index\";\nimport type { ASTNode, KnownNode } from \"./types\";\n\n// Past this many possible results an expression is reported rather than enumerated.\nconst MAX_OUTCOMES = 1024;\n\nconst tokens = (value: string) => value.split(/\\s+/).filter(Boolean);\n\nfunction union(a: string[] | null, b: string[] | null): string[] | null {\n return a && b ? [...new Set([...a, ...b])] : null;\n}\n\nfunction product(a: string[] | null, b: string[] | null): string[] | null {\n if (!a || !b || a.length * b.length > MAX_OUTCOMES) return null;\n return [...new Set(a.flatMap((left) => b.map((right) => left + right)))];\n}\n\n/**\n * Every string an expression can evaluate to, or null when a result can come\n * from data or a computation instead of a literal. Only result positions are\n * constrained: a ternary's test, or the left side of `&&`, may read anything.\n * Each literal reached is pushed onto `written`.\n */\nfunction outcomes(node: ASTNode, written: string[]): string[] | null {\n const n = node as KnownNode;\n switch (n.type) {\n case \"Literal\": {\n // `null` / booleans render no class; a number renders as its digits.\n const value =\n n.value == null || typeof n.value === \"boolean\" ? \"\" : String(n.value);\n written.push(value);\n return [value];\n }\n\n case \"ConditionalExpression\":\n return union(\n outcomes(n.consequent, written),\n outcomes(n.alternate, written),\n );\n\n case \"BinaryExpression\":\n switch (n.operator) {\n // A falsy left side renders no class, so only the right side is a result.\n case \"&&\":\n return union([\"\"], outcomes(n.right, written));\n case \"||\":\n case \"??\":\n return union(outcomes(n.left, written), outcomes(n.right, written));\n case \"+\":\n return product(outcomes(n.left, written), outcomes(n.right, written));\n default:\n return null;\n }\n\n default:\n return null;\n }\n}\n\n/**\n * Why a `className` value can't be styled from the template's source text, or\n * null when it can.\n *\n * Template stylesheets are compiled from the template JSON plus the component\n * class manifest, without rendering. That covers an expression only when every\n * class it can produce is written whole inside one of its string literals:\n * `{{ x ? 'bg-red-500' : 'p-2' }}` and `{{ 'p-4 ' + (x ? 'shadow-md' : '') }}`\n * are fine, `{{ 'bg-' + color }}` and `{{ 'bg-' + (x ? 'red-500' : 'blue-500') }}`\n * are not. Plain strings always pass; an expression that fails to parse is left\n * for the render to report.\n */\nexport function classNameIssue(value: unknown): string | null {\n const ast = compileExpression(value)?.ast;\n if (!ast) return null;\n\n const written: string[] = [];\n const results = outcomes(ast, written);\n if (!results) {\n return \"must evaluate to classes written in string literals (e.g. a ternary between class strings), not to data or a computed value\";\n }\n\n const whole = new Set(written.flatMap(tokens));\n for (const result of results) {\n for (const token of tokens(result)) {\n if (!whole.has(token)) {\n return `builds \"${token}\" by joining strings; write each class whole inside one string literal`;\n }\n }\n }\n return null;\n}\n","import type { BonsaiRegistry } from \"./types\";\n\nexport interface RegistryIdentity {\n id: string;\n version: string;\n manifestHash?: string;\n}\n\nexport type PinResolution =\n | { action: \"render\"; reason: \"no-pin\" }\n | { action: \"render\"; reason: \"match\" }\n | { action: \"render\"; reason: \"version-skew\"; warning: string }\n | { action: \"fail\"; reason: \"id-mismatch\"; error: string };\n\n// Implements the registry-pin migration rule: templates\n// already in storage carry no pin at all, so an absent pin must render (not fail).\n// A patch bump must not brick live forms — only an `id` mismatch is a different\n// component library, and that is the only case that fails closed.\nexport function resolveRegistryPin(\n pin: RegistryIdentity | undefined,\n registry: Pick<BonsaiRegistry, \"id\" | \"version\"> & { manifestHash?: string },\n): PinResolution {\n if (!pin) {\n return { action: \"render\", reason: \"no-pin\" };\n }\n\n if (pin.id !== registry.id) {\n return {\n action: \"fail\",\n reason: \"id-mismatch\",\n error: `Template is pinned to registry \"${pin.id}\", but rendering registry is \"${registry.id}\" — this is a different component library, not a version skew.`,\n };\n }\n\n const versionMatches = pin.version === registry.version;\n // A Case A manifest can be edited at a stable URL without a version bump — that's\n // exactly the drift the pinning rules exist to prevent, so a manifestHash mismatch\n // is treated the same as a version mismatch even when `version` itself matches.\n const manifestHashMatches =\n pin.manifestHash == null || registry.manifestHash == null || pin.manifestHash === registry.manifestHash;\n\n if (versionMatches && manifestHashMatches) {\n return { action: \"render\", reason: \"match\" };\n }\n\n return {\n action: \"render\",\n reason: \"version-skew\",\n warning: versionMatches\n ? `Template is pinned to registry \"${pin.id}\"@\"${pin.version}\" (manifest ${pin.manifestHash}), but the resolved manifest is now ${registry.manifestHash}. Re-pin on next save.`\n : `Template is pinned to registry \"${pin.id}\"@\"${pin.version}\", but rendering registry is \"${pin.id}\"@\"${registry.version}\". Re-pin on next save.`,\n };\n}\n","import { COMPONENT } from \"@bonsai/constants\";\nimport type { Config } from \"../../types\";\nimport { classNameIssue } from \"../ast/class-names\";\nimport { resolveRegistryPin, type RegistryIdentity } from \"./identity\";\nimport type { BonsaiRegistry, ComponentDefinition } from \"./types\";\n\n// `each`/`if` are core engine control-flow nodes, not registry components — the renderer\n// special-cases them before ever consulting the registry (see bonsai.tsx), so validation\n// must too rather than reporting them as unknown components.\nconst STRUCTURAL_TYPES: string[] = [COMPONENT.EACH, COMPONENT.IF];\n\nexport interface RegistryValidationError {\n path: string;\n message: string;\n componentType?: string;\n}\n\nexport interface RegistryValidationResult {\n valid: boolean;\n errors: RegistryValidationError[];\n // Non-fatal notices — currently only a registry version/manifest skew on an\n // otherwise-matching pin (see the migration rules in ./identity.ts).\n warnings: string[];\n}\n\nexport interface ValidateTemplateOptions {\n // Which render target this validation gates. A component whose capabilities omit\n // the matching mode (e.g. no \"pdf\") is rejected for that mode. Defaults to \"web\".\n mode?: \"web\" | \"pdf\";\n // The registry identity a stored template was last validated against. Absent for\n // templates written before pinning existed — that renders unpinned, not fail-closed\n // (see the migration rules this implements in identity.ts).\n pin?: RegistryIdentity;\n}\n\nfunction isRenderTargetCapable(\n def: ComponentDefinition,\n mode: \"web\" | \"pdf\",\n): boolean {\n if (!def.capabilities) return true;\n if (mode === \"pdf\") return def.capabilities.includes(\"pdf\");\n return def.capabilities.includes(\"ssr\");\n}\n\nfunction walk(\n node: Config | undefined,\n path: string,\n registry: BonsaiRegistry,\n mode: \"web\" | \"pdf\",\n errors: RegistryValidationError[],\n): void {\n if (node == null) return;\n if (typeof node === \"string\") return;\n\n const type = node.type;\n if (!type) {\n errors.push({ path, message: \"Node is missing a required `type` field\" });\n return;\n }\n\n if (STRUCTURAL_TYPES.includes(type)) {\n (node.children ?? []).forEach((child, i) =>\n walk(child, `${path}.children[${i}]`, registry, mode, errors),\n );\n return;\n }\n\n const def = registry.components[type];\n if (!def) {\n errors.push({\n path,\n componentType: type,\n message: `Unknown component type \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\"`,\n });\n return;\n }\n\n if (!isRenderTargetCapable(def, mode)) {\n errors.push({\n path,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not support \"${mode}\" rendering`,\n });\n }\n\n if (def.propsSchema) {\n const result = def.propsSchema.safeParse(node.args);\n if (!result.success) {\n for (const issue of result.error.issues) {\n const issuePath = issue.path.length ? `${path}.args.${issue.path.join(\".\")}` : `${path}.args`;\n errors.push({ path: issuePath, componentType: type, message: issue.message });\n }\n }\n }\n\n if (node.args?.onClick !== undefined && def.capabilities && !def.capabilities.includes(\"events\")) {\n errors.push({\n path: `${path}.args.onClick`,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not accept onClick`,\n });\n }\n\n const classNameProblem = classNameIssue(node.args?.className);\n if (classNameProblem) {\n errors.push({\n path: `${path}.args.className`,\n componentType: type,\n message: `className ${classNameProblem}`,\n });\n }\n\n const hasChildren = (node.children?.length ?? 0) > 0;\n if (hasChildren) {\n if (def.capabilities && !def.capabilities.includes(\"children\")) {\n errors.push({\n path,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not accept children`,\n });\n }\n (node.children ?? []).forEach((child, i) =>\n walk(child, `${path}.children[${i}]`, registry, mode, errors),\n );\n }\n}\n\nexport function validateTemplate(\n template: Config,\n registry: BonsaiRegistry,\n options: ValidateTemplateOptions = {},\n): RegistryValidationResult {\n const errors: RegistryValidationError[] = [];\n const warnings: string[] = [];\n\n if (options.pin) {\n const resolution = resolveRegistryPin(options.pin, registry);\n if (resolution.action === \"fail\") {\n errors.push({ path: \"root\", message: resolution.error });\n return { valid: false, errors, warnings };\n }\n if (resolution.reason === \"version-skew\") {\n warnings.push(resolution.warning);\n }\n }\n\n walk(template, \"root\", registry, options.mode ?? \"web\", errors);\n return { valid: errors.length === 0, errors, warnings };\n}\n","import { z } from \"zod\";\n\n/**\n * Compiles the JSON Schema subset a manifest's `propsSchema` is allowed to use into a\n * Zod validator: JSON Schema on the wire, compiled to a Zod validator at load.\n * Deliberately a subset, not a general JSON\n * Schema implementation — enough to express prop narrowing (type, enum, required,\n * string/number bounds), which is the only thing a Case A manifest is allowed to do\n * to a prop schema in the first place.\n */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface JsonSchemaToZodOptions {\n /**\n * Accept a `\"{{expression}}\"` binding anywhere a typed value is declared.\n *\n * A template author writes `checked: \"{{form.agree}}\"` and the binding is resolved at\n * render time, long after validation runs — so a schema saying `{\"type\":\"boolean\"}`\n * rejects a template that would render perfectly. The hand-rolled registry has always\n * worked around this by declaring `z.union([z.string(), z.boolean()])` by hand on every\n * affected prop. This is that convention made available to manifests whose schemas were\n * machine-derived from component sources and so cannot hand-write it.\n *\n * Opt-in rather than automatic: `bonsai.generated.json` doubles as an LLM tool\n * definition, and a prop that reads \"boolean\" there is worth keeping precise.\n *\n * Narrower than the hand-rolled convention on purpose — only binding-*shaped* strings\n * are admitted, not every string. `{\"type\":\"string\",\"minLength\":1}` therefore still\n * rejects `\"\"`, and an `enum` still rejects a value outside it, both of which a blanket\n * `z.string()` union would silently discard.\n */\n allowBindings?: boolean;\n}\n\n// The exact test `parseExpression` and `extractVariables` apply before treating a value as\n// an expression (`lib/ast/index.ts`). Anything failing it is a literal at render time, so\n// admitting it here would accept values the renderer will never substitute.\nconst bindingExpression = z\n .string()\n .refine((value) => value.startsWith(\"{{\") && value.endsWith(\"}}\"), {\n message: 'Expected a value of the declared type, or a \"{{binding}}\" expression',\n });\n\nexport function jsonSchemaToZod(schema: JsonSchema, options: JsonSchemaToZodOptions = {}): z.ZodType<unknown> {\n // Applied to every terminus but `object`: an object schema is a prop *container* — the\n // root `propsSchema` is one — and a node's `args` is never itself a binding string. Its\n // properties each pass back through here and are wrapped individually.\n const bindable = (inner: z.ZodType<unknown>): z.ZodType<unknown> =>\n options.allowBindings ? z.union([bindingExpression, inner]) : inner;\n\n if (\"const\" in schema) {\n return bindable(z.literal(schema.const as string | number | boolean));\n }\n\n if (Array.isArray(schema.enum)) {\n const values = schema.enum as (string | number | boolean)[];\n if (values.length === 0) {\n throw new Error(\"jsonSchemaToZod: enum must have at least one value\");\n }\n const [first, ...rest] = values;\n return bindable(rest.reduce((acc: z.ZodType<unknown>, v) => z.union([acc, z.literal(v)]), z.literal(first)));\n }\n\n const type = schema.type as string | undefined;\n\n switch (type) {\n case \"string\": {\n let s = z.string();\n if (typeof schema.minLength === \"number\") s = s.min(schema.minLength);\n if (typeof schema.maxLength === \"number\") s = s.max(schema.maxLength);\n if (typeof schema.pattern === \"string\") s = s.regex(new RegExp(schema.pattern));\n return bindable(s);\n }\n case \"number\":\n case \"integer\": {\n let n = z.number();\n if (type === \"integer\") n = n.int();\n if (typeof schema.minimum === \"number\") n = n.min(schema.minimum);\n if (typeof schema.maximum === \"number\") n = n.max(schema.maximum);\n return bindable(n);\n }\n case \"boolean\":\n return bindable(z.boolean());\n case \"array\": {\n const items = schema.items ? jsonSchemaToZod(schema.items as JsonSchema, options) : z.unknown();\n return bindable(z.array(items));\n }\n case \"object\": {\n const properties = (schema.properties ?? {}) as Record<string, JsonSchema>;\n const required = new Set((schema.required as string[] | undefined) ?? []);\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const [key, propSchema] of Object.entries(properties)) {\n const propZod = jsonSchemaToZod(propSchema, options);\n shape[key] = required.has(key) ? propZod : propZod.optional();\n }\n let obj = z.object(shape);\n if (schema.additionalProperties === false) obj = obj.strict();\n return obj;\n }\n default:\n return z.unknown();\n }\n}\n","import { z } from \"zod\";\n\n// Structural shape of a RegistryManifest on the wire.\n// Pure JSON: no function can be expressed in this schema — that is the\n// entire reason a Case A manifest is safe to accept from a tenant.\nexport const ManifestControlledSchema = z\n .object({\n valueProp: z.string().min(1),\n changeProp: z.string().min(1),\n extract: z.string().min(1),\n })\n .strict();\n\nexport const ManifestComponentSchema = z\n .object({\n name: z.string().min(1),\n canonicalName: z.string().min(1).optional(),\n // Case A: a key resolved against `base`'s exports, never a module path to import.\n entry: z.string().min(1),\n propsSchema: z.record(z.string(), z.unknown()).optional(),\n capabilities: z\n .array(z.enum([\"children\", \"bindings\", \"events\", \"formField\", \"ssr\", \"pdf\"]))\n .optional(),\n controlled: ManifestControlledSchema.optional(),\n css: z.array(z.string()).optional(),\n })\n .strict();\n\nexport const RegistryManifestSchema = z\n .object({\n $schema: z.string().optional(),\n id: z.string().min(1),\n namespace: z.string().min(1).optional(),\n version: z.string().min(1),\n engine: z\n .object({\n name: z.literal(\"bonsai\"),\n api: z.string().min(1),\n })\n .strict(),\n components: z.array(ManifestComponentSchema).min(1),\n integrity: z\n .object({\n algorithm: z.literal(\"sha256\"),\n manifestHash: z.string().min(1),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport type RegistryManifest = z.infer<typeof RegistryManifestSchema>;\nexport type ManifestComponent = z.infer<typeof ManifestComponentSchema>;\n","import { z } from \"zod\";\nimport { jsonSchemaToZod, type JsonSchema } from \"./json-schema-to-zod\";\nimport { RegistryManifestSchema, type ManifestComponent, type RegistryManifest } from \"./manifest-schema\";\nimport { defineBonsaiRegistry, defineComponent, type BonsaiRegistry } from \"./types\";\n\nexport type { RegistryManifest, ManifestComponent } from \"./manifest-schema\";\nexport { RegistryManifestSchema } from \"./manifest-schema\";\n\nconst SUPPORTED_ENGINE_API = \"1\";\n\n// Named-extractor allowlist: a manifest\n// names an extractor from this fixed list, resolved to a real function by the loader.\n// There is no syntactic position in a manifest where a function can be expressed, so\n// none can be smuggled in — this is the reason a Case A manifest is safe to accept\n// from a tenant at all.\nexport const EXTRACTOR_ALLOWLIST: Record<string, (eventOrValue: unknown) => unknown> = {\n identity: (value) => value,\n targetValue: (event) => (event as { target?: { value?: unknown } })?.target?.value,\n targetChecked: (event) => (event as { target?: { checked?: unknown } })?.target?.checked,\n targetValueAsNumber: (event) =>\n (event as { target?: { valueAsNumber?: unknown } })?.target?.valueAsNumber,\n};\n\nexport class ManifestLoadError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ManifestLoadError\";\n }\n}\n\n// Intersect, never replace (a locked security decision: a manifest can narrow or re-describe props but must not widen a\n// component past what its own first-party schema accepts). Deliberately not\n// `z.intersection` — zod's intersection merge does not reliably propagate a strict()\n// base schema's rejection of unrecognized keys, which would silently defeat the\n// narrowing-only guarantee. This runs both schemas independently and requires both to\n// accept the value, so the stricter of the two always wins.\nexport function composePropsSchema(\n baseSchema: z.ZodType<unknown> | undefined,\n tenantSchema: z.ZodType<unknown> | undefined,\n): z.ZodType<unknown> | undefined {\n if (!baseSchema) return tenantSchema;\n if (!tenantSchema) return baseSchema;\n return z.any().superRefine((value, ctx) => {\n const baseResult = baseSchema.safeParse(value);\n if (!baseResult.success) {\n for (const issue of baseResult.error.issues) {\n ctx.addIssue({ code: \"custom\", message: issue.message, path: issue.path });\n }\n }\n const tenantResult = tenantSchema.safeParse(value);\n if (!tenantResult.success) {\n for (const issue of tenantResult.error.issues) {\n ctx.addIssue({ code: \"custom\", message: issue.message, path: issue.path });\n }\n }\n });\n}\n\nexport async function computeManifestHash(raw: string): Promise<string> {\n const bytes = new TextEncoder().encode(raw);\n const digest = await crypto.subtle.digest(\"SHA-256\", bytes);\n const hex = Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `sha256:${hex}`;\n}\n\nexport interface ResolveManifestOptions {\n base: BonsaiRegistry;\n engineApi?: string;\n maxComponents?: number;\n maxManifestBytes?: number;\n rawManifestSize?: number;\n manifestHash?: string;\n}\n\nfunction resolveExtractor(name: string): (eventOrValue: unknown) => unknown {\n const fn = EXTRACTOR_ALLOWLIST[name];\n if (!fn) {\n throw new ManifestLoadError(\n `Registry manifest: unknown extractor \"${name}\" — must be one of: ${Object.keys(EXTRACTOR_ALLOWLIST).join(\", \")}`,\n );\n }\n return fn;\n}\n\nfunction resolveComponent(\n entry: ManifestComponent,\n base: BonsaiRegistry,\n manifestId: string,\n): [string, ReturnType<typeof defineComponent>] {\n const baseDef = base.components[entry.entry];\n if (!baseDef) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifestId}\": component \"${entry.name}\" resolves entry \"${entry.entry}\", which is not exported by base registry \"${base.id}\"@\"${base.version}\"`,\n );\n }\n\n const tenantPropsSchema = entry.propsSchema\n ? jsonSchemaToZod(entry.propsSchema as JsonSchema)\n : undefined;\n\n const controlled = entry.controlled\n ? {\n valueProp: entry.controlled.valueProp,\n changeProp: entry.controlled.changeProp,\n extract: resolveExtractor(entry.controlled.extract),\n }\n : baseDef.controlled;\n\n const canonicalName = entry.canonicalName ?? entry.name;\n\n return [\n canonicalName,\n defineComponent({\n component: baseDef.component,\n propsSchema: composePropsSchema(baseDef.propsSchema, tenantPropsSchema),\n capabilities: entry.capabilities ?? baseDef.capabilities,\n controlled,\n assets: entry.css ? { css: entry.css } : baseDef.assets,\n }),\n ];\n}\n\n// Case A only: the manifest binds to component implementations already in `base` —\n// `entry` is a key resolved against `base`'s exports, never a module path to import.\n// Resolution happens once (at init/template-create time), never per render.\nexport function resolveManifest(\n manifest: RegistryManifest,\n options: ResolveManifestOptions,\n): BonsaiRegistry {\n const parsed = RegistryManifestSchema.parse(manifest);\n\n const engineApi = options.engineApi ?? SUPPORTED_ENGINE_API;\n if (parsed.engine.api !== engineApi) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" targets engine.api \"${parsed.engine.api}\", but this build supports \"${engineApi}\"`,\n );\n }\n\n const maxComponents = options.maxComponents ?? 500;\n if (parsed.components.length > maxComponents) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" declares ${parsed.components.length} components, exceeding the limit of ${maxComponents}`,\n );\n }\n\n const maxBytes = options.maxManifestBytes ?? 5 * 1024 * 1024;\n if (options.rawManifestSize != null && options.rawManifestSize > maxBytes) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" is ${options.rawManifestSize} bytes, exceeding the limit of ${maxBytes}`,\n );\n }\n\n const components = Object.fromEntries(\n parsed.components.map((entry) => resolveComponent(entry, options.base, parsed.id)),\n );\n\n return defineBonsaiRegistry({\n id: parsed.id,\n version: parsed.version,\n namespace: parsed.namespace,\n manifestHash: options.manifestHash,\n fallback: options.base.fallback,\n components,\n });\n}\n\nexport interface LoadManifestOptions extends ResolveManifestOptions {\n allowedOrigins?: string[];\n // Test/DI seam — defaults to the global fetch.\n fetchImpl?: typeof fetch;\n}\n\nconst manifestCache = new Map<string, BonsaiRegistry>();\n\nexport function clearManifestCache(): void {\n manifestCache.clear();\n}\n\nfunction verifyIntegrity(manifest: RegistryManifest, hash: string): void {\n if (!manifest.integrity) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifest.id}\" has no integrity block — a manifest hash is required before use`,\n );\n }\n if (manifest.integrity.manifestHash !== hash) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifest.id}\" failed its integrity check: expected \"${manifest.integrity.manifestHash}\", computed \"${hash}\"`,\n );\n }\n}\n\n// Resolves once and caches by manifestHash — never fetched or re-resolved per render\n// (the hosted SSR path has a ~13ms warm budget a network hop plus manifest parse does\n// not fit in).\nexport async function loadRegistryManifest(\n source: RegistryManifest | string,\n options: LoadManifestOptions,\n): Promise<BonsaiRegistry> {\n let raw: string;\n\n if (typeof source === \"string\") {\n const url = new URL(source);\n if (options.allowedOrigins && !options.allowedOrigins.includes(url.origin)) {\n throw new ManifestLoadError(\n `Registry manifest origin \"${url.origin}\" is not in the allowed origins list`,\n );\n }\n const doFetch = options.fetchImpl ?? fetch;\n const res = await doFetch(source);\n if (!res.ok) {\n throw new ManifestLoadError(\n `Registry manifest fetch failed: ${source} responded ${res.status}`,\n );\n }\n raw = await res.text();\n } else {\n raw = JSON.stringify(source);\n }\n\n const manifest = RegistryManifestSchema.parse(JSON.parse(raw));\n\n // The hash covers the manifest's content, not its own integrity block — hashing the\n // raw bytes (which already embed `integrity.manifestHash`) would be self-referential\n // and could never match. This is what a build step computes before stamping the hash\n // back into the manifest it just built.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- discarding `integrity` on purpose\n const { integrity: _integrity, ...withoutIntegrity } = manifest;\n const hash = await computeManifestHash(JSON.stringify(withoutIntegrity));\n verifyIntegrity(manifest, hash);\n\n const cached = manifestCache.get(hash);\n if (cached) return cached;\n\n const resolved = resolveManifest(manifest, { ...options, rawManifestSize: raw.length, manifestHash: hash });\n manifestCache.set(hash, resolved);\n return resolved;\n}\n","import type { JsonSchema } from \"./json-schema-to-zod\";\n\n// A type alias, not an interface, on purpose: `JsonSchema` is `Record<string, unknown>`\n// and only aliases get an implicit index signature. As an interface this type cannot be\n// passed to `jsonSchemaToZod` — which is exactly the composition the comment below\n// describes and which every generated registry adapter performs.\nexport type ObjectPropsSchema = {\n type?: \"object\";\n properties: Record<string, JsonSchema>;\n required?: string[];\n};\n\n// `generated ∪ overrides`, per component and per prop, overrides\n// win. NOT `composePropsSchema` (manifest.ts) — that intersects because it composes an\n// *untrusted* tenant schema over a first-party one, a security boundary. Here both\n// sides are first-party and dev-authored; overrides are authoritative, not narrowing.\n// Runs at the JSON Schema level, before `jsonSchemaToZod` — merging Zod types directly\n// would give intersect-flavoured semantics instead.\nexport function mergeGeneratedWithOverrides(\n generated: ObjectPropsSchema | undefined,\n overrides: Partial<ObjectPropsSchema> | undefined,\n): ObjectPropsSchema {\n const properties = { ...(generated?.properties ?? {}), ...(overrides?.properties ?? {}) };\n const required = [...new Set([...(generated?.required ?? []), ...(overrides?.required ?? [])])];\n return { type: \"object\", properties, required };\n}\n","// The two checks that run at build/startup, in the app that\n// consumes the generated artifact — network-free by construction, both sides are\n// values already on disk (the committed artifact and the installed @base-ui/react).\nexport interface RegistrySource {\n url: string;\n registryHash: string;\n}\n\nexport interface DriftCheckInput {\n // `bonsai.generated.json`'s `registries` and `pebble-kit.json`'s `registries`. Compared\n // per URL rather than as one aggregate hash: this file ships in the browser bundle and\n // must not pull in a hash implementation, and a per-URL comparison can name the\n // registry that moved instead of reporting two opaque digests.\n artifactRegistries: RegistrySource[];\n configRegistries: RegistrySource[];\n artifactBaseUiVersion: string;\n installedBaseUiVersion: string;\n}\n\nfunction describeStaleArtifact(artifact: RegistrySource[], config: RegistrySource[]): string | undefined {\n const artifactByUrl = new Map(artifact.map((r) => [r.url, r.registryHash]));\n const configByUrl = new Map(config.map((r) => [r.url, r.registryHash]));\n const reasons: string[] = [];\n\n for (const [url, configHash] of configByUrl) {\n const artifactHash = artifactByUrl.get(url);\n if (artifactHash === undefined) {\n reasons.push(`${url} is configured but missing from the artifact`);\n } else if (artifactHash !== configHash) {\n reasons.push(`${url}: artifact has ${artifactHash}, pebble-kit.json records ${configHash}`);\n }\n }\n for (const url of artifactByUrl.keys()) {\n if (!configByUrl.has(url)) reasons.push(`${url} is in the artifact but no longer configured`);\n }\n\n return reasons.length > 0 ? reasons.join(\"; \") : undefined;\n}\n\nexport interface DriftIssue {\n check: \"stale-artifact\" | \"baseui-drift\";\n level: \"warn\" | \"fail\";\n message: string;\n}\n\nfunction extractMajor(version: string): number | undefined {\n const match = /(\\d+)\\.\\d+\\.\\d+/.exec(version);\n return match ? Number(match[1]) : undefined;\n}\n\nexport function checkArtifactDrift(input: DriftCheckInput): DriftIssue[] {\n const issues: DriftIssue[] = [];\n\n const staleReason = describeStaleArtifact(input.artifactRegistries, input.configRegistries);\n if (staleReason) {\n issues.push({\n check: \"stale-artifact\",\n level: \"fail\",\n message: `bonsai.generated.json is out of date with pebble-kit.json (${staleReason}) — run \"pebble-kit generate\"`,\n });\n }\n\n if (input.artifactBaseUiVersion !== input.installedBaseUiVersion) {\n const artifactMajor = extractMajor(input.artifactBaseUiVersion);\n const installedMajor = extractMajor(input.installedBaseUiVersion);\n const majorMismatch = artifactMajor !== undefined && installedMajor !== undefined && artifactMajor !== installedMajor;\n issues.push({\n check: \"baseui-drift\",\n level: majorMismatch ? \"fail\" : \"warn\",\n message: `generated artifact's baseline was built against @base-ui/react ${input.artifactBaseUiVersion}, but ${input.installedBaseUiVersion} is installed`,\n });\n }\n\n return issues;\n}\n\n// \"Fail loud\" (5.6): a fail-level issue throws; warn-level issues are the caller's to\n// surface however it likes (console.warn, a logger, ...) — this only gates the hard stop.\nexport function assertNoFailingDrift(issues: DriftIssue[]): void {\n const failing = issues.filter((i) => i.level === \"fail\");\n if (failing.length > 0) {\n throw new Error(failing.map((f) => f.message).join(\"; \"));\n }\n}\n","// Default entrypoint: the batteries-included preset. `Bonsai` here resolves\n// every built-in component, including the heavy ones (calendar, signature),\n// which keeps existing consumers working unchanged. Import\n// `@pebble-software/bonsai/core` instead to start from the lightweight\n// registry and opt into heavy components via `.../presets/*`.\n//\n// The theme stylesheet is not imported here: it ships raw as\n// `@pebble-software/bonsai/index.css` for the consumer's Tailwind build.\n\nimport { createBonsaiRenderer } from \"./renderer/create-renderer\";\nimport { pebbleRegistry } from \"./lib/registry/pebble-registry\";\n\n/** Renderer bound to the full built-in registry. */\nexport const { Bonsai } = createBonsaiRenderer({ registry: pebbleRegistry });\n\nexport { createBonsaiRenderer };\nexport { useUpdateData, useBonsaiRenderMode } from \"./components/core/bonsai\";\nexport { componentMap, controlledInputMap } from \"./lib/ui/registry\";\nexport { pebbleRegistry };\nexport { coreRegistry, extendRegistry } from \"./renderer/core-registry\";\nexport { defineComponent, defineBonsaiRegistry } from \"./lib/registry/types\";\nexport type {\n BonsaiRegistry,\n ComponentDefinition,\n ControlledFieldSpec,\n ComponentCapability,\n} from \"./lib/registry/types\";\nexport { validateTemplate } from \"./lib/registry/validate\";\nexport type {\n RegistryValidationError,\n RegistryValidationResult,\n ValidateTemplateOptions,\n} from \"./lib/registry/validate\";\nexport { resolveRegistryPin } from \"./lib/registry/identity\";\nexport type { RegistryIdentity, PinResolution } from \"./lib/registry/identity\";\nexport {\n resolveManifest,\n loadRegistryManifest,\n computeManifestHash,\n composePropsSchema,\n clearManifestCache,\n ManifestLoadError,\n EXTRACTOR_ALLOWLIST,\n RegistryManifestSchema,\n} from \"./lib/registry/manifest\";\nexport type {\n RegistryManifest,\n ManifestComponent,\n ResolveManifestOptions,\n LoadManifestOptions,\n} from \"./lib/registry/manifest\";\nexport { jsonSchemaToZod } from \"./lib/registry/json-schema-to-zod\";\nexport type { JsonSchema } from \"./lib/registry/json-schema-to-zod\";\nexport { mergeGeneratedWithOverrides } from \"./lib/registry/merge-generated\";\nexport type { ObjectPropsSchema } from \"./lib/registry/merge-generated\";\nexport { checkArtifactDrift, assertNoFailingDrift } from \"./lib/registry/drift\";\nexport type { DriftCheckInput, DriftIssue, RegistrySource } from \"./lib/registry/drift\";\n\nexport type { BonsaiProps, RenderMode } from \"./components/core/bonsai\";\nexport type {\n BonsaiRendererOptions,\n BonsaiRendererInstance,\n} from \"./renderer/create-renderer\";\nexport type {\n BonsaiPreset,\n ComponentRegistry,\n ControlledInput,\n ControlledInputEntry,\n ControlledInputRegistry,\n} from \"./renderer/core-registry\";\nexport type { Config, ConfigNode } from \"./types\";\n"],"names":["OID","z","TIMESTAMP","TemplateSource","Config","body","FormRequestStatus","FileMimeType","PDFRequestStatus","zod","createErrorMap","componentMap","coreComponents","calendarPreset","signaturePreset","controlledInputMap","coreControlledInputs","builtIns","extendRegistry","coreRegistry","pebbleRegistry","defineBonsaiRegistry","type","def","defineComponent","PEBBLE_COMPONENT_SCHEMAS","MAX_OUTCOMES","tokens","value","union","a","b","product","left","right","outcomes","node","written","classNameIssue","ast","compileExpression","results","whole","result","token","resolveRegistryPin","pin","registry","versionMatches","manifestHashMatches","STRUCTURAL_TYPES","COMPONENT","isRenderTargetCapable","mode","walk","path","errors","child","i","issue","issuePath","classNameProblem","validateTemplate","template","options","warnings","resolution","bindingExpression","jsonSchemaToZod","schema","bindable","inner","values","first","rest","acc","v","s","n","items","properties","required","shape","key","propSchema","propZod","obj","ManifestControlledSchema","ManifestComponentSchema","RegistryManifestSchema","SUPPORTED_ENGINE_API","EXTRACTOR_ALLOWLIST","event","ManifestLoadError","message","composePropsSchema","baseSchema","tenantSchema","ctx","baseResult","tenantResult","computeManifestHash","raw","bytes","digest","resolveExtractor","name","fn","resolveComponent","entry","base","manifestId","baseDef","tenantPropsSchema","controlled","resolveManifest","manifest","parsed","engineApi","maxComponents","maxBytes","components","manifestCache","clearManifestCache","verifyIntegrity","hash","loadRegistryManifest","source","url","res","_integrity","withoutIntegrity","cached","resolved","mergeGeneratedWithOverrides","generated","overrides","describeStaleArtifact","artifact","config","artifactByUrl","r","configByUrl","reasons","configHash","artifactHash","extractMajor","version","match","checkArtifactDrift","input","issues","staleReason","artifactMajor","installedMajor","majorMismatch","assertNoFailingDrift","failing","f","Bonsai","createBonsaiRenderer"],"mappings":";;;;;;;;;;;AAGO,MAAMA,IAAMC,EAAE,OAAA,EAAS,OAAO,EAAE,EAAE,KAAK;AAAA,EAC5C,aAAa;AAAA,EACb,SAAS;AACX,CAAC;AAGoBA,EAAE,OAAA,EAAS,MAAA,EAAQ,KAAK;AAAA,EAC3C,aAAa;AAAA,EACb,SAAS;AACX,CAAC;AAGM,MAAMC,IAAYD,EAAE,SAAS,SAAS,EAAE,QAAQ,IAAM,EAAE,KAAK;AAAA,EAClE,aAAa;AAAA,EACb,SAAS;AACX,CAAC;AAGsBA,EAAE,MAAM,CAACA,EAAE,QAAA,GAAWA,EAAE,OAAA,CAAQ,CAAC,EAAE,KA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ACpC;AAEO,SAASC,GAAmBC,GAAsC;AACvE,QAAMC,IAAuB,CAAA,GAEvBC,IAAcf,GAAsBa,EAAM,oBAAoBA,EAAM,gBAAgB;AAS1F,MARIE,KACFD,EAAO,KAAK;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS,8DAA8DC,CAAW;AAAA,EAAA,CACnF,GAGCF,EAAM,0BAA0BA,EAAM,wBAAwB;AAChE,UAAMG,IAAgBP,EAAaI,EAAM,qBAAqB,GACxDI,IAAiBR,EAAaI,EAAM,sBAAsB,GAC1DK,IAAgBF,MAAkB,UAAaC,MAAmB,UAAaD,MAAkBC;AACvG,IAAAH,EAAO,KAAK;AAAA,MACV,OAAO;AAAA,MACP,OAAOI,IAAgB,SAAS;AAAA,MAChC,SAAS,kEAAkEL,EAAM,qBAAqB,SAASA,EAAM,sBAAsB;AAAA,IAAA,CAC5I;AAAA,EACH;AAEA,SAAOC;AACT;AAIO,SAASK,GAAqBL,GAA4B;AAC/D,QAAMM,IAAUN,EAAO,OAAO,CAAC7F,MAAMA,EAAE,UAAU,MAAM;AACvD,MAAImG,EAAQ,SAAS;AACnB,UAAM,IAAI,MAAMA,EAAQ,IAAI,CAACC,MAAMA,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE5D;ACtEO,MAAM,EAAE,QAAAC,GAAA,IAAWC,EAAqB,EAAE,UAAU5I,GAAgB;"}
1
+ {"version":3,"file":"index.js","sources":["../../../library/schemas/src/common.ts","../../../library/schemas/src/api.schema.ts","../../../library/schemas/src/entities/user.schema.ts","../../../library/schemas/src/entities/organization.schema.ts","../../../library/schemas/src/entities/organization-user.schema.ts","../../../library/schemas/src/entities/template.schema.ts","../../../library/schemas/src/entities/form-request.schema.ts","../../../library/schemas/src/entities/api-key.schema.ts","../../../library/schemas/src/entities/webhook.schema.ts","../../../library/schemas/src/entities/jwt.schema.ts","../../../library/schemas/src/entities/file.schema.ts","../../../library/schemas/src/entities/pdf-request.schema.ts","../../../library/schemas/src/index.ts","../src/lib/ui/registry.ts","../src/lib/registry/pebble-registry.ts","../src/lib/registry/identity.ts","../src/lib/registry/validate.ts","../src/lib/registry/json-schema-to-zod.ts","../src/lib/registry/manifest-schema.ts","../src/lib/registry/manifest.ts","../src/lib/registry/merge-generated.ts","../src/lib/registry/drift.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** MongoDB ObjectId as a 24-character hex string (transport layer — no Mongoose coupling) */\nexport const OID = z.string().length(24).meta({\n description: \"MongoDB ObjectId (24-character hex string)\",\n example: \"67e091ab2c4d3f22001a2b3c\",\n});\n\n/** Valid email address */\nexport const EMAIL = z.string().email().meta({\n description: \"Valid email address\",\n example: \"jack@datahaven.net\",\n});\n\n/** ISO 8601 datetime string with timezone offset */\nexport const TIMESTAMP = z.string().datetime({ offset: true }).meta({\n description: \"ISO 8601 datetime with optional timezone offset\",\n example: \"2077-12-25T23:59:59Z\",\n});\n\n/** A boolean or string-coerced boolean (common in HTML attribute bindings like 'disabled', 'checked') */\nexport const BOOLISH = z.union([z.boolean(), z.string()]).meta({\n description: \"Boolean or string-coerced boolean ('true'/'false')\",\n example: true,\n});\n","import { z } from \"zod\";\n\n// ── Response Envelope ─────────────────────────────────────────────────────────\n// Reusable wrappers for the standard {message, data} / {error} envelope.\n// The docs server calls these with the per-endpoint data shape.\n\n/** Wrap a data schema in the success envelope */\nexport const API_SUCCESS = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z.object({\n message: z.string().meta({ description: \"Human-readable status message\", example: \"Success\" }),\n data: dataSchema.optional().meta({ description: \"Response payload\" }),\n }).meta({ description: \"Successful API response\" });\n\n/** Standard error response envelope */\nexport const API_ERROR = z.object({\n error: z.string().meta({ description: \"Human-readable error description\", example: \"Forbidden — no access to this resource\" }),\n data: z.any().optional().meta({ description: \"Additional error context (if available)\" }),\n}).meta({ description: \"Error API response\" });\n\n/** Convenience union — caller passes a data schema to get {message, data?} | {error} */\nexport function API_RESPONSE<T extends z.ZodTypeAny>(dataSchema: T) {\n return z.union([API_SUCCESS(dataSchema), API_ERROR]);\n}\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── User ─────────────────────────────────────────────────────────────────────\n\nexport const UserSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n email: z.string().email().meta({\n description: \"User's email address (used as the primary identifier)\",\n example: \"jack@datahaven.net\",\n readOnly: true,\n }),\n name: z.string().min(1).max(100).meta({ description: \"Full display name\", example: \"Razor Jack\" }),\n emailVerified: z.boolean().nullable().optional().meta({ description: \"Whether the user's email has been verified\" }),\n image: z.string().optional().meta({ description: \"Avatar image URL\", example: \"https://cdn.datahaven.net/avatars/rj7741.png\" }),\n createdAt: TIMESTAMP.optional().meta({ description: \"When the user account was created\", readOnly: true }),\n updatedAt: TIMESTAMP.optional().meta({ description: \"When the user account was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"An authenticated user account. Users are distinct from organization memberships — a user may belong to multiple organizations.\",\n});\n\n// ── Edit User Request ────────────────────────────────────────────────────────\n\nexport const EditUserRequestSchema = z.object({\n name: z.string().min(1).optional().meta({ description: \"Updated display name\", example: \"Cyber Jack\" }),\n image: z.string().optional().meta({ description: \"Updated avatar URL\", example: \"https://cdn.datahaven.net/avatars/cj7741.png\" }),\n}).strict().meta({ description: \"Update the authenticated user's profile\" });\n","import { z } from \"zod\";\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Organization ──────────────────────────────────────────────────────────────\n\nexport const OrganizationSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n clientId: z.string().min(1).meta({ description: \"Unique client identifier for the organization\", example: \"pb-org-7f3a2b9c\", readOnly: true }),\n name: z.string().min(3).max(50).meta({ description: \"Unique organization slug/identifier\", example: \"neon-shadow\" }),\n displayName: z.string().min(3).max(50).meta({ description: \"Human-readable organization name shown in UI and emails\", example: \"Neon Shadow Corp\" }),\n legalName: z.string().min(3).max(50).meta({ description: \"Legal business name for contracts and compliance\", example: \"Neon Shadow Corporation Ltd.\" }),\n legalAddress: z.string().min(3).max(100).meta({ description: \"Registered business address\", example: \"42 Cyber Avenue, Night City, NC 20777\" }),\n contactEmail: z.string().email().meta({ description: \"Primary contact email for the organization\", example: \"legal@neon-shadow.io\" }),\n icon: z.string().meta({ description: \"Organization icon/logo URL\", example: \"https://cdn.neon-shadow.io/icon.png\" }),\n banner: z.string().nullable().optional().meta({ description: \"Organization banner image URL\", example: \"https://cdn.neon-shadow.io/banner.png\" }),\n createdBy: OID.meta({ description: \"User ObjectId who created the organization\", readOnly: true }),\n customerId: z.string().optional().nullable().meta({ description: \"Stripe customer ID for billing\", example: \"cus_9x8y7z6w5v4u3t2s\", readOnly: true }),\n subscriptionId: z.string().optional().nullable().meta({ description: \"Stripe subscription ID\", example: \"sub_1A2B3C4D5E6F7G8H\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the organization was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the organization was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A tenant organization. Each organization has its own isolated workspace, templates, signature requests, and API keys.\",\n});\n\n// ── Requests ─────────────────────────────────────────────────────────────────\n\nexport const CreateOrganizationRequestSchema = z.object({\n name: z.string().min(3).max(50).meta({ description: \"Unique organization slug/identifier\", example: \"neon-shadow\" }),\n displayName: z.string().min(3).max(50).meta({ description: \"Human-readable name shown in UI\", example: \"Neon Shadow Corp\" }),\n legalName: z.string().min(3).max(50).meta({ description: \"Legal business name\", example: \"Neon Shadow Corporation Ltd.\" }),\n legalAddress: z.string().min(3).max(100).meta({ description: \"Registered business address\", example: \"42 Cyber Avenue, Night City, NC 20777\" }),\n contactEmail: z.string().email().meta({ description: \"Primary contact email\", example: \"legal@neon-shadow.io\" }),\n icon: z.string().meta({ description: \"Organization icon/logo URL\", example: \"https://cdn.neon-shadow.io/icon.png\" }),\n}).strict().meta({ description: \"Create a new organization\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Organization User ─────────────────────────────────────────────────────────\n\nexport const OrganizationUserSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n organization: OID.meta({ description: \"The organization this membership belongs to\", readOnly: true }),\n user: OID.meta({ description: \"The user who is a member of the organization\", readOnly: true }),\n role: z.string().min(1).meta({ description: \"Role identifier (e.g. 'admin', 'member', 'viewer')\", example: \"admin\" }),\n permissions: z.string().min(1).meta({ description: \"Permission set identifier or JSON string\", example: \"{\\\"templates\\\":\\\"rw\\\",\\\"forms\\\":\\\"r\\\"}\" }),\n status: z.enum([\"active\", \"inactive\", \"blocked\"]).meta({ description: \"Membership status\", example: \"active\" }),\n lastLogin: TIMESTAMP.nullable().meta({ description: \"When the user last logged into this organization\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the membership was created\", readOnly: true }),\n updatedAt: TIMESTAMP.optional().meta({ description: \"When the membership was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A user's membership within an organization. This links a User to an Organization and defines their role and permissions.\",\n});\n\n// ── Requests ─────────────────────────────────────────────────────────────────\n\nexport const InviteOrganizationUserRequestSchema = z.object({\n email: z.string().email().meta({ description: \"Email address of the user to invite\", example: \"jack@datahaven.net\" }),\n name: z.string().min(3).meta({ description: \"Display name of the invited user\", example: \"Razor Jack\" }),\n role: z.string().min(2).meta({ description: \"Role to assign (e.g. 'admin', 'member')\", example: \"member\" }),\n image: z.string().optional().meta({ description: \"Avatar URL for the invited user\", example: \"https://cdn.datahaven.net/avatars/rj7741.png\" }),\n permissions: z.string().min(1).meta({ description: \"Permission set to assign\", example: \"{\\\"templates\\\":\\\"r\\\",\\\"forms\\\":\\\"rw\\\"}\" }),\n}).strict().meta({ description: \"Invite a user to join an organization\" });\n\nexport const EditOrganizationUserRequestSchema = z.object({\n _id: OID.meta({ description: \"OrganizationUser membership MongoDB ObjectId\", readOnly: true }),\n role: z.string().min(2).meta({ description: \"Updated role\", example: \"viewer\" }),\n permissions: z.string().min(1).meta({ description: \"Updated permission set\", example: \"{\\\"templates\\\":\\\"r\\\"}\" }),\n}).strict().meta({ description: \"Update an organization user's role or permissions\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── Template ──────────────────────────────────────────────────────────────────\n\n/**\n * The builder's own document for a template (blocks, editor ids). Opaque to the\n * API and SSR, which only ever read `config`; `version` lets the builder migrate\n * older documents.\n */\nexport const TemplateSource = z\n .looseObject({\n version: z.number().int().positive().meta({ description: \"Builder document format version\" }),\n })\n .meta({ description: \"Builder source document the config was compiled from (editor-only)\" });\n\nexport const TemplateSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n organization: OID.meta({ description: \"Organization that owns this template\", readOnly: true }),\n createdBy: OID.meta({ description: \"OrganizationUser ID who created this template\", readOnly: true }),\n name: z.string().min(1).meta({ description: \"Template name (unique within the organization)\", example: \"Neural_NDA_v3\" }),\n description: z.string().default(\"\").meta({ description: \"Human-readable description of the template's purpose\", example: \"Standard non-disclosure agreement with neural implant data clause\" }),\n config: z.any().meta({ description: \"The Bonsai component tree defining the template layout and fields\" }),\n source: TemplateSource.optional(),\n header: z.string().optional().meta({ description: \"A small Bonsai component tree used for page headers in PDF rendering output\" }),\n footer: z.string().optional().meta({ description: \"A small Bonsai component tree used for page footers in PDF rendering output\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the serialized config, used for deduplication\", example: \"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1\" }),\n css: z.string().optional().meta({ description: \"Generated Tailwind CSS for the template layout\" }),\n tags: z.array(z.string()).default([]).meta({ description: \"Tags for organizing and discovering templates\", example: [\"nda\", \"legal\", \"neural-interface\"] }),\n active: z.boolean().default(true).meta({ description: \"Whether the template is active and available for use\" }),\n lastUsed: TIMESTAMP.nullable().optional().meta({ description: \"When the template was last referenced in a signature request\", readOnly: true }),\n usageCount: z.number().default(0).meta({ description: \"Total number of signature requests created from this template\" }),\n version: z.number().default(1).meta({ description: \"Template schema version (increments on significant config changes)\" }),\n createdAt: TIMESTAMP.meta({ description: \"When the template was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the template was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A reusable Bonsai signature template. Templates define the form layout via a component tree and can be referenced by ID when creating signature requests.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/template — Create a new template */\nexport const CreateTemplateRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the template\" }),\n name: z.string().min(1).meta({ description: \"Template name (must be unique within the organization)\", example: \"Neural_NDA_v3\" }),\n description: z.string().optional().meta({ description: \"Optional description of the template's purpose\", example: \"Standard NDA with neural implant clause\" }),\n config: Config.meta({ description: \"The Bonsai component tree that defines the template layout\" }),\n source: TemplateSource.optional(),\n pdf: z.object({\n header: Config.optional().meta({ description: \"PDF header Bonsai component tree\" }),\n footer: Config.optional().meta({ description: \"PDF footer Bonsai component tree\" }),\n }).optional(),\n tags: z.array(z.string()).optional().meta({ description: \"Tags for organizing and filtering templates\", example: [\"nda\", \"legal\"] }),\n}).strict().meta({ description: \"Create a new reusable signature template\" });\n\n/** PUT /v1/template/{id} — Replace a template's content */\nexport const UpdateTemplateRequest = z.object({\n name: z.string().min(1).optional().meta({ description: \"New template name (must be unique within the organization)\" }),\n description: z.string().optional().meta({ description: \"New description\" }),\n config: Config.optional().meta({ description: \"Replacement Bonsai component tree; CSS and content hash are recomputed\" }),\n source: TemplateSource.optional(),\n pdf: z.object({\n header: Config.optional().meta({ description: \"PDF header Bonsai component tree\" }),\n footer: Config.optional().meta({ description: \"PDF footer Bonsai component tree\" }),\n }).optional(),\n tags: z.array(z.string()).optional().meta({ description: \"Replacement tags\" }),\n}).strict()\n .refine((body) => Object.keys(body).length > 0, { message: \"Provide at least one field to update\" })\n .meta({ description: \"Update an existing template\" });\n\nexport const UpdateTemplateResponseData = z.object({\n id: z.string().meta({ description: \"MongoDB ObjectId of the template\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n name: z.string().meta({ description: \"Template name\", example: \"Neural_NDA_v3\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the config after the update\" }),\n version: z.number().meta({ description: \"Template version after the update\" }),\n}).strict().meta({ description: \"Updated template summary\" });\n\nexport const CreateTemplateResponseData = z.object({\n id: z.string().meta({ description: \"MongoDB ObjectId of the created template\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n name: z.string().meta({ description: \"Template name\", example: \"Neural_NDA_v3\" }),\n contentHash: z.string().optional().meta({ description: \"SHA-256 hash of the config, useful for deduplication\" }),\n}).strict().meta({ description: \"Created template summary\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── Form Request ──────────────────────────────────────────────────────────────\n\nexport const FormRequestStatus = z.enum([\n \"pending\", \"captured\", \"completed\", \"error\", \"revoked\",\n]);\nexport type FormRequestStatus = z.infer<typeof FormRequestStatus>;\n\nexport const FormRequestSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public-facing unique request ID (random hex string)\", example: \"fr_a7b8c9d0e1f2\", readOnly: true }),\n token: z.string().meta({ description: \"Verification token used for cookie-based auth in the signer's browser\", readOnly: true }),\n email: z.string().email().meta({ description: \"Recipient email address where the signature link was sent\", example: \"jack@datahaven.net\" }),\n name: z.string().min(1).meta({ description: \"Recipient's display name\", example: \"Razor Jack\" }),\n attachments: z.array(z.string()).optional().meta({ description: \"Array of attachment URLs included with the form\", example: [\"https://files.datahaven.net/nda_v3.pdf\"] }),\n data: z.any().optional().meta({ description: \"Form field data submitted by the signer\" }),\n webhooks: z.array(OID).optional().meta({ description: \"Webhook ObjectIds notified on lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"Capture-time metadata such as IP address, user agent, and timestamps\" }),\n expiry: TIMESTAMP.meta({ description: \"When the signature request link expires\" }),\n due: TIMESTAMP.optional().nullable().meta({ description: \"Soft deadline for completing the signature\" }),\n digest: z.string().meta({ description: \"SHA-256 hash of the serialized payload, used for deduplication\", readOnly: true }),\n template: z.any().meta({ description: \"Snapshot of the Bonsai component tree config at the time of form creation\", readOnly: true }),\n header: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering\", readOnly: true }),\n footer: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering\", readOnly: true }),\n css: z.string().meta({ description: \"Tailwind CSS generated from the template at the time of form creation\", readOnly: true }),\n status: FormRequestStatus.meta({ description: \"Current lifecycle status of the form request\", example: \"pending\" }),\n organization: OID.meta({ description: \"Organization that owns this form request\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the form request was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the form request was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A signature request sent to a recipient. Tracks the full lifecycle from creation through signing, completion, or revocation.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/form — Create a new signature request */\nexport const CreateFormRequest = z.object({\n name: z.string().min(1).meta({ description: \"Recipient's display name (used in the email greeting and form header)\", example: \"Razor Jack\" }),\n email: z.string().email().meta({ description: \"Recipient email address where the signature link will be sent\", example: \"jack@datahaven.net\" }),\n template: z.union([Config, z.string()]).meta({\n description: \"Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the form layout\",\n }),\n expiry: z.coerce.date().optional().meta({ description: \"When the signature request link expires (ISO 8601 date)\", example: \"2077-12-25T23:59:59Z\" }),\n due: z.coerce.date().optional().meta({ description: \"Soft deadline for the signature (ISO 8601 date)\", example: \"2077-12-20T18:00:00Z\" }),\n webhooks: z.array(z.string()).min(1).meta({ description: \"Array of webhook ObjectIds to notify on form lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n attachments: z.array(z.string()).optional().meta({ description: \"Array of attachment URLs to include with the form\", example: [\"https://files.datahaven.net/nda_v3.pdf\"] }),\n metadata: z.any().optional().meta({ description: \"Arbitrary metadata to associate with the form request\", example: { department: \"Legal\", priority: \"high\" } }),\n data: z.any().optional().meta({ description: \"Pre-filled form field data to populate the form on load\", example: { full_name: \"Razor Jack\", badge_id: \"RJ-7741\" } }),\n pdf: z.union([z.boolean(), z.object({\n header: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n })]).optional().meta({ description: \"PDF file config object (header||footer) or `true/false` boolean to trigger PDF file generation after form capture\" }),\n}).strict().meta({ description: \"Create a new signature request targeting a recipient\" });\n\nexport const CreateFormRequestResponseData = z.object({\n formId: z.string().meta({ description: \"MongoDB ObjectId of the newly created form request\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n}).strict().meta({ description: \"Created form request identifier\" });\n\n/** POST /v1/form/{id}/revoke — Revoke a pending form request */\nexport const RevokeFormRequest = z.object({\n reason: z.string().optional().meta({ description: \"Optional explanation for why the form was revoked (logged for audit)\", example: \"Signer compromised — ICE breach detected on endpoint\" }),\n}).strict().meta({ description: \"Payload for revoking a signature request\" });\n\n/** POST /v1/form/{id}/resend — Re-send the signature request email */\nexport const ResendFormRequestEmail = z.object({\n email: z.string().email().optional().meta({ description: \"Override the recipient email address (uses the original if omitted)\", example: \"jack@neon-shadow.io\" }),\n}).strict().meta({ description: \"Payload for re-sending the signature request email\" });\n\n/** POST /v1/capture — Submit form data from the signer's browser */\nexport const SubmitCaptureRequest = z.object({\n data: z.record(z.string(), z.any()).optional().meta({\n description: \"Form field data collected from the signer\",\n example: { signature: \"data:image/png;base64,iVBOR...\", accepted_terms: true },\n }),\n}).strict().meta({ description: \"Submit captured form data from the signer's browser session\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── API Key ───────────────────────────────────────────────────────────────────\n\nexport const ApiKeySchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public key identifier (e.g. pb-xxxx). Used as the 'client' field when authenticating.\", example: \"pb-a7f3b2c9d1e8f4a5b6c7d8e9\", readOnly: true }),\n secret: z.string().meta({ description: \"Encrypted API key secret — only viewable at creation time\", readOnly: true }),\n allowedOrigins: z.array(z.string()).default([]).meta({ description: \"CORS origin allowlist. Requests from origins not in this list are rejected.\", example: [\"https://console.neon-shadow.io\"] }),\n allowedIps: z.array(z.string()).default([]).meta({ description: \"IP CIDR allowlist. Requests from IPs not in this list are rejected.\", example: [\"203.0.113.0/24\"] }),\n active: z.boolean().default(true).meta({ description: \"Whether the key is active and can be used for authentication\" }),\n expiry: TIMESTAMP.meta({ description: \"When the API key expires and can no longer be used\" }),\n lastUsed: TIMESTAMP.meta({ description: \"Timestamp of the most recent request using this key\", readOnly: true }),\n audience: z.enum([\"internal\", \"external\"]).meta({ description: \"Key audience — 'internal' for server-to-server, 'external' for client-side\", example: \"internal\" }),\n organization: OID.meta({ description: \"Organization this key belongs to\", readOnly: true }),\n generatedBy: OID.meta({ description: \"OrganizationUser ID who created this key\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the API key was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the API key was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"An API key scoped to an organization. Each key has configurable IP and origin restrictions for fine-grained access control.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/api-key — Create a new API key */\nexport const CreateApiKeyRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the API key\" }),\n expiry: z.coerce.date().optional().meta({ description: \"Key expiration date (defaults to +1 year from creation)\", example: \"2078-12-19T00:00:00Z\" }),\n audience: z.enum([\"internal\", \"external\"]).meta({ description: \"Key audience — 'internal' for server-to-server, 'external' for client-side usage\", example: \"internal\" }),\n allowedOrigins: z.array(z.string()).optional().meta({ description: \"CORS origin allowlist (e.g. ['https://app.example.com']). Empty array disables origin restriction.\", example: [\"https://console.neon-shadow.io\", \"https://api.datahaven.net\"] }),\n allowedIps: z.array(z.string()).optional().meta({ description: \"IP CIDR allowlist (e.g. ['203.0.113.0/24']). Empty array disables IP restriction.\", example: [\"203.0.113.0/24\", \"10.0.0.0/8\"] }),\n}).strict().meta({ description: \"Payload for creating a new API key\" });\n\nexport const CreateApiKeyResponseData = z.object({\n id: z.string().meta({ description: \"Public API key ID (e.g. pb-xxxx)\", example: \"pb-a7f3b2c9d1e8f4a5b6c7d8e9\", readOnly: true }),\n secret: z.string().meta({ description: \"API key secret — **this is the only time the secret is returned**. Store it securely.\", readOnly: true }),\n}).strict().meta({ description: \"API key credentials — the secret is only shown once\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\n\n// ── Webhook ───────────────────────────────────────────────────────────────────\n\nexport const WebhookSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public webhook identifier (e.g. pb-wbhk-xxxx)\", example: \"pb-wbhk-a7b8c9d0\", readOnly: true }),\n url: z.string().url().meta({ description: \"HTTPS endpoint receiving POST event notifications\", example: \"https://hooks.datahaven.net/events\" }),\n secret: z.string().meta({ description: \"HMAC-SHA256 signing secret — used to verify that webhook payloads genuinely came from Bonsai\", readOnly: true }),\n active: z.boolean().default(true).meta({ description: \"Whether the webhook is active and receiving events\" }),\n lastUsed: TIMESTAMP.meta({ description: \"When the webhook last received an event\", readOnly: true }),\n organization: OID.meta({ description: \"Organization that owns this webhook\", readOnly: true }),\n generatedBy: OID.meta({ description: \"OrganizationUser ID who created this webhook\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the webhook was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the webhook was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A webhook destination for form request lifecycle events. When a form is created, signed, or revoked, Bonsai sends a POST request to this URL with a JSON payload signed via HMAC-SHA256.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/webhook — Create a new webhook destination */\nexport const CreateWebhookRequest = z.object({\n ou: OID.meta({ description: \"OrganizationUser ID of the user creating the webhook\" }),\n url: z.string().url().meta({ description: \"HTTPS endpoint that will receive POST event notifications\", example: \"https://hooks.datahaven.net/events\" }),\n}).strict().meta({ description: \"Payload for creating a new webhook destination\" });\n\nexport const CreateWebhookResponseData = z.object({\n id: z.string().meta({ description: \"Webhook MongoDB ObjectId\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n secret: z.string().meta({ description: \"HMAC signing secret — **this is the only time the secret is returned**. Use it to verify webhook payload authenticity.\", readOnly: true }),\n}).strict().meta({ description: \"Webhook credentials — the signing secret is only shown once\" });\n","import { z } from \"zod\";\n\n// ── JWT / Auth ────────────────────────────────────────────────────────────────\n\n/** POST /v1/token — Exchange API key credentials for a JWT */\nexport const GenerateTokenRequest = z.object({\n client: z.string().min(1).meta({ description: \"API key ID (e.g. pb-xxxx)\", example: \"pb-7f3a2b9c1d8e4f5a6b7c8d9e\" }),\n secret: z.string().min(1).meta({ description: \"API key secret\", example: \"sk_liv...1f0e\" }),\n refresh: z.boolean().optional().meta({ description: \"If true, also issues a refresh token (30 day expiry)\", example: true }),\n}).strict().meta({ description: \"Credentials for obtaining a JWT access token\" });\n\nexport const GenerateTokenResponseData = z.object({\n token: z.string().meta({ description: \"JWT access token (1 hour expiry). Include as Bearer token in subsequent requests.\", example: \"eyJhbGciOiJIUzI1NiIs...f456\" }),\n refresh: z.string().optional().meta({ description: \"Refresh token (30 day expiry). Use at POST /v1/token/refresh to get a new JWT without re-entering credentials.\", example: \"rt_live_8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d\" }),\n}).strict().meta({ description: \"Token response containing JWT and optional refresh token\" });\n\n/** POST /v1/token/refresh — Exchange a refresh token for a new JWT */\nexport const RefreshTokenRequest = z.object({\n refreshToken: z.string().min(1).meta({ description: \"Refresh token obtained from a prior POST /v1/token response\", example: \"rt_live_8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d\" }),\n}).strict().meta({ description: \"Request to refresh an expired JWT using a refresh token\" });\n\nexport const RefreshTokenResponseData = z.object({\n token: z.string().meta({ description: \"New JWT access token (1 hour expiry)\", example: \"eyJhbGciOiJIUzI1NiIs...c012\" }),\n}).strict().meta({ description: \"New JWT access token\" });\n","import { z } from \"zod\";\n\n// ── File MIME Types ───────────────────────────────────────────────────────────\n\nexport const FileMimeType = z.enum([\n \"application/pdf\",\n \"image/png\",\n \"image/jpeg\",\n \"image/webp\",\n \"text/plain\",\n \"text/csv\",\n]);\nexport type FileMimeType = z.infer<typeof FileMimeType>;\n\n// ── Signed Download URL ───────────────────────────────────────────────────────\n\n/** GET /v1/file/{id}/url — Get a signed GCS download URL */\nexport const GetFileUrlQuery = z.object({\n ttl: z.coerce.number().int().min(60).max(86400).default(3600)\n .meta({ description: \"Signed URL lifetime in seconds (default 3600, min 60, max 86400 [24h])\", example: 3600 }),\n}).strict().meta({ description: \"Query parameters for generating a signed download URL\" });\n\nexport const GetFileUrlResponseData = z.object({\n downloadUrl: z.string().url().meta({ description: \"Pre-signed GCS download URL\", example: \"https://storage.googleapis.com/bonsai-secure/f1e2d3...X-Goog-Signature=def456\" }),\n filename: z.string().meta({ description: \"Original filename (for Content-Disposition)\", example: \"signed_nda_razorjack.pdf\" }),\n mimeType: FileMimeType.meta({ description: \"MIME type (for Content-Type)\", example: \"application/pdf\" }),\n size: z.number().int().meta({ description: \"File size in bytes\", example: 245760 }),\n}).strict().meta({ description: \"Signed download URL for secure file access\" });\n","import { z } from \"zod\";\n\nimport { OID, TIMESTAMP } from \"../common\";\nimport { Config } from \"../bonsai.schema\";\n\n// ── PDF Request ──────────────────────────────────────────────────────────────\n\nexport const PDFRequestStatus = z.enum([\n \"pending\", \"generating\", \"completed\", \"error\", \"revoked\",\n]);\nexport type PDFRequestStatus = z.infer<typeof PDFRequestStatus>;\n\nexport const PDFRequestSchema = z.object({\n _id: OID.meta({ readOnly: true }),\n id: z.string().meta({ description: \"Public-facing unique request ID (random hex string)\", example: \"fr_a7b8c9d0e1f2\", readOnly: true }),\n token: z.string().meta({ description: \"Verification token used for cookie-based auth in the signer's browser\", readOnly: true }),\n data: z.any().optional().meta({ description: \"Form field data submitted by the signer/requester\" }),\n webhooks: z.array(OID).optional().meta({ description: \"Webhook ObjectIds notified on lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"File metadata such as size, contentType, etc.\" }),\n digest: z.string().meta({ description: \"SHA-256 hash of the serialized payload, used for deduplication\", readOnly: true }),\n template: z.any().meta({ description: \"Snapshot of the Bonsai component tree config at the time of PDF creation\" }),\n header: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.any().meta({ description: \"Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n css: z.string().meta({ description: \"Tailwind CSS generated from the template at the time of PDF generation request\", readOnly: true }),\n status: PDFRequestStatus.meta({ description: \"Current lifecycle status of the PDF request\", example: \"pending\" }),\n organization: OID.meta({ description: \"Organization that owns this PDF request\", readOnly: true }),\n createdAt: TIMESTAMP.meta({ description: \"When the PDF request was created\", readOnly: true }),\n updatedAt: TIMESTAMP.meta({ description: \"When the PDF request was last updated\", readOnly: true }),\n}).strict().meta({\n description: \"A PDF request used to trigger the generation of a custom PDF file. Tracks the full lifecycle and alerts sends results via webhook.\",\n});\n\n// ── Requests / Responses ──────────────────────────────────────────────────────\n\n/** POST /v1/pdf — Create a new pdf file generation request */\nexport const CreatePDFRequest = z.object({\n template: z.union([Config, z.string()]).meta({\n description: \"Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the PDF content layout\",\n }),\n webhooks: z.array(z.string()).min(1).meta({ description: \"Array of webhook ObjectIds to notify on form lifecycle events\", example: [\"67e091ab2c4d3f22001a2b3c\"] }),\n metadata: z.any().optional().meta({ description: \"Arbitrary metadata to associate with the PDF request\", example: { department: \"Legal\", priority: \"high\" } }),\n data: z.any().optional().meta({ description: \"Pre-filled template field data to populate the PDF with\", example: { full_name: \"Razor Jack\", badge_id: \"RJ-7741\" } }),\n header: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page header rendering\" }),\n footer: z.union([Config, z.string()]).optional().meta({ description: \"A (small) Bonsai component tree config used for the output PDF page footer rendering\" }),\n}).strict().meta({ description: \"Create a new PDF request to generate a PDF file from a Bonsai template\" });\n\nexport const CreatePDFRequestResponseData = z.object({\n pdfId: z.string().meta({ description: \"MongoDB ObjectId of the newly created PDF request (this is NOT the rendered pdf file - a file ID is returned after async pdf generation via webhook)\", example: \"67e091ab2c4d3f22001a2b3c\", readOnly: true }),\n}).strict().meta({ description: \"Created form request identifier\" });\n","import zod from \"zod\";\nimport { createErrorMap } from \"zod-validation-error\";\n\nzod.config({\n customError: createErrorMap(),\n});\n\n// Common primitives (shared across schema files)\nexport * from \"./common\";\n\n// API response envelope + request/response schemas\nexport * from \"./api.schema\";\n\n// Bonsai UI component tree (the template DSL)\nexport * from \"./bonsai.schema\";\nexport * from \"./builder.meta\";\n\n// Domain entity schemas (for OpenAPI component schemas + docs)\nexport * from \"./entities/user.schema\";\nexport * from \"./entities/organization.schema\";\nexport * from \"./entities/organization-user.schema\";\nexport * from \"./entities/template.schema\";\nexport * from \"./entities/form-request.schema\";\nexport * from \"./entities/api-key.schema\";\nexport * from \"./entities/webhook.schema\";\nexport * from \"./entities/jwt.schema\";\nexport * from \"./entities/file.schema\";\nexport * from \"./entities/pdf-request.schema\";\n","import {\n coreComponents,\n coreControlledInputs,\n type ComponentRegistry,\n type ControlledInput,\n type ControlledInputEntry,\n type ControlledInputRegistry,\n} from \"../../renderer/core-registry\";\nimport { calendarPreset } from \"../../renderer/presets/calendar\";\nimport { signaturePreset } from \"../../renderer/presets/signature\";\n\n/**\n * The full, batteries-included registry: every core component plus the heavy\n * opt-in presets (calendar, signature). Importing this module transitively\n * pulls in react-day-picker and react-signature-canvas — use\n * `renderer/core-registry` if you want to stay lightweight.\n *\n * Typed with `ComponentRegistry`/`ControlledInputRegistry` (both\n * `Record<string, ...>`) rather than `Record<COMPONENT[number], ...>` from\n * `@bonsai/constants` — that package is workspace-only and unpublished, and\n * referencing its types here would bake an escaping import path into this\n * file's emitted declaration, the same class of bug fixed for `Config` in\n * `src/types.ts`. (`COMPONENT[number]`, a numeric index into a union of\n * string-literal enum members, was already widening to plain `string` here —\n * so `ComponentRegistry`/`ControlledInputRegistry` lose nothing.)\n */\nexport const componentMap: ComponentRegistry = {\n ...coreComponents,\n ...calendarPreset.components,\n ...signaturePreset.components,\n};\n\nexport const controlledInputMap: ControlledInputRegistry = {\n ...coreControlledInputs,\n ...calendarPreset.controlledInputs,\n ...signaturePreset.controlledInputs,\n};\n\nexport type { ControlledInput, ControlledInputEntry };\n","import { PEBBLE_COMPONENT_SCHEMAS } from \"@bonsai/schemas\";\nimport { componentMap, controlledInputMap } from \"../ui/registry\";\nimport { coreRegistry, extendRegistry } from \"../../renderer/core-registry\";\nimport { defineBonsaiRegistry, defineComponent } from \"./types\";\n\nconst builtIns = extendRegistry(coreRegistry, {\n components: componentMap,\n controlledInputs: controlledInputMap,\n});\n\n// The full built-in library: `coreRegistry`'s identity, every built-in component\n// (heavy presets included), plus each component's `propsSchema` for `validateTemplate`.\nexport const pebbleRegistry = defineBonsaiRegistry({\n ...builtIns,\n components: Object.fromEntries(\n Object.entries(builtIns.components).map(([type, def]) => [\n type,\n defineComponent({ ...def, propsSchema: PEBBLE_COMPONENT_SCHEMAS[type]?.argsSchema }),\n ]),\n ),\n});\n","import type { BonsaiRegistry } from \"./types\";\n\nexport interface RegistryIdentity {\n id: string;\n version: string;\n manifestHash?: string;\n}\n\nexport type PinResolution =\n | { action: \"render\"; reason: \"no-pin\" }\n | { action: \"render\"; reason: \"match\" }\n | { action: \"render\"; reason: \"version-skew\"; warning: string }\n | { action: \"fail\"; reason: \"id-mismatch\"; error: string };\n\n// Implements the registry-pin migration rule: templates\n// already in storage carry no pin at all, so an absent pin must render (not fail).\n// A patch bump must not brick live forms — only an `id` mismatch is a different\n// component library, and that is the only case that fails closed.\nexport function resolveRegistryPin(\n pin: RegistryIdentity | undefined,\n registry: Pick<BonsaiRegistry, \"id\" | \"version\"> & { manifestHash?: string },\n): PinResolution {\n if (!pin) {\n return { action: \"render\", reason: \"no-pin\" };\n }\n\n if (pin.id !== registry.id) {\n return {\n action: \"fail\",\n reason: \"id-mismatch\",\n error: `Template is pinned to registry \"${pin.id}\", but rendering registry is \"${registry.id}\" — this is a different component library, not a version skew.`,\n };\n }\n\n const versionMatches = pin.version === registry.version;\n // A Case A manifest can be edited at a stable URL without a version bump — that's\n // exactly the drift the pinning rules exist to prevent, so a manifestHash mismatch\n // is treated the same as a version mismatch even when `version` itself matches.\n const manifestHashMatches =\n pin.manifestHash == null || registry.manifestHash == null || pin.manifestHash === registry.manifestHash;\n\n if (versionMatches && manifestHashMatches) {\n return { action: \"render\", reason: \"match\" };\n }\n\n return {\n action: \"render\",\n reason: \"version-skew\",\n warning: versionMatches\n ? `Template is pinned to registry \"${pin.id}\"@\"${pin.version}\" (manifest ${pin.manifestHash}), but the resolved manifest is now ${registry.manifestHash}. Re-pin on next save.`\n : `Template is pinned to registry \"${pin.id}\"@\"${pin.version}\", but rendering registry is \"${pin.id}\"@\"${registry.version}\". Re-pin on next save.`,\n };\n}\n","import { STRUCTURAL_COMPONENTS } from \"@bonsai/constants\";\nimport type { Config } from \"../../types\";\nimport { analyzeClassName, isClassNameProp } from \"../ast/class-names\";\nimport { resolveRegistryPin, type RegistryIdentity } from \"./identity\";\nimport type { BonsaiRegistry, ComponentDefinition } from \"./types\";\n\nexport interface RegistryValidationError {\n path: string;\n message: string;\n componentType?: string;\n}\n\nexport interface RegistryValidationResult {\n valid: boolean;\n errors: RegistryValidationError[];\n // Non-fatal notices — currently only a registry version/manifest skew on an\n // otherwise-matching pin (see the migration rules in ./identity.ts).\n warnings: string[];\n}\n\nexport interface ValidateTemplateOptions {\n // Which render target this validation gates. A component whose capabilities omit\n // the matching mode (e.g. no \"pdf\") is rejected for that mode. Defaults to \"web\".\n mode?: \"web\" | \"pdf\";\n // The registry identity a stored template was last validated against. Absent for\n // templates written before pinning existed — that renders unpinned, not fail-closed\n // (see the migration rules this implements in identity.ts).\n pin?: RegistryIdentity;\n}\n\nfunction isRenderTargetCapable(\n def: ComponentDefinition,\n mode: \"web\" | \"pdf\",\n): boolean {\n if (!def.capabilities) return true;\n if (mode === \"pdf\") return def.capabilities.includes(\"pdf\");\n return def.capabilities.includes(\"ssr\");\n}\n\nfunction walk(\n node: Config | undefined,\n path: string,\n registry: BonsaiRegistry,\n mode: \"web\" | \"pdf\",\n errors: RegistryValidationError[],\n): void {\n if (node == null) return;\n if (typeof node === \"string\") return;\n\n const type = node.type;\n if (!type) {\n errors.push({ path, message: \"Node is missing a required `type` field\" });\n return;\n }\n\n if (STRUCTURAL_COMPONENTS.has(type)) {\n (node.children ?? []).forEach((child, i) =>\n walk(child, `${path}.children[${i}]`, registry, mode, errors),\n );\n return;\n }\n\n const def = registry.components[type];\n if (!def) {\n errors.push({\n path,\n componentType: type,\n message: `Unknown component type \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\"`,\n });\n return;\n }\n\n if (!isRenderTargetCapable(def, mode)) {\n errors.push({\n path,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not support \"${mode}\" rendering`,\n });\n }\n\n if (def.propsSchema) {\n const result = def.propsSchema.safeParse(node.args);\n if (!result.success) {\n for (const issue of result.error.issues) {\n const issuePath = issue.path.length ? `${path}.args.${issue.path.join(\".\")}` : `${path}.args`;\n errors.push({ path: issuePath, componentType: type, message: issue.message });\n }\n }\n }\n\n if (node.args?.onClick !== undefined && def.capabilities && !def.capabilities.includes(\"events\")) {\n errors.push({\n path: `${path}.args.onClick`,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not accept onClick`,\n });\n }\n\n for (const [name, value] of Object.entries(node.args ?? {})) {\n if (!isClassNameProp(name)) continue;\n const { issue } = analyzeClassName(value);\n if (issue) {\n errors.push({\n path: `${path}.args.${name}`,\n componentType: type,\n message: `${name} ${issue}`,\n });\n }\n }\n\n const hasChildren = (node.children?.length ?? 0) > 0;\n if (hasChildren) {\n if (def.capabilities && !def.capabilities.includes(\"children\")) {\n errors.push({\n path,\n componentType: type,\n message: `Component \"${type}\" in registry \"${registry.id}\"@\"${registry.version}\" does not accept children`,\n });\n }\n (node.children ?? []).forEach((child, i) =>\n walk(child, `${path}.children[${i}]`, registry, mode, errors),\n );\n }\n}\n\nexport function validateTemplate(\n template: Config,\n registry: BonsaiRegistry,\n options: ValidateTemplateOptions = {},\n): RegistryValidationResult {\n const errors: RegistryValidationError[] = [];\n const warnings: string[] = [];\n\n if (options.pin) {\n const resolution = resolveRegistryPin(options.pin, registry);\n if (resolution.action === \"fail\") {\n errors.push({ path: \"root\", message: resolution.error });\n return { valid: false, errors, warnings };\n }\n if (resolution.reason === \"version-skew\") {\n warnings.push(resolution.warning);\n }\n }\n\n walk(template, \"root\", registry, options.mode ?? \"web\", errors);\n return { valid: errors.length === 0, errors, warnings };\n}\n","import { z } from \"zod\";\n\n/**\n * Compiles the JSON Schema subset a manifest's `propsSchema` is allowed to use into a\n * Zod validator: JSON Schema on the wire, compiled to a Zod validator at load.\n * Deliberately a subset, not a general JSON\n * Schema implementation — enough to express prop narrowing (type, enum, required,\n * string/number bounds), which is the only thing a Case A manifest is allowed to do\n * to a prop schema in the first place.\n */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface JsonSchemaToZodOptions {\n /**\n * Accept a `\"{{expression}}\"` binding anywhere a typed value is declared.\n *\n * A template author writes `checked: \"{{form.agree}}\"` and the binding is resolved at\n * render time, long after validation runs — so a schema saying `{\"type\":\"boolean\"}`\n * rejects a template that would render perfectly. The hand-rolled registry has always\n * worked around this by declaring `z.union([z.string(), z.boolean()])` by hand on every\n * affected prop. This is that convention made available to manifests whose schemas were\n * machine-derived from component sources and so cannot hand-write it.\n *\n * Opt-in rather than automatic: `bonsai.generated.json` doubles as an LLM tool\n * definition, and a prop that reads \"boolean\" there is worth keeping precise.\n *\n * Narrower than the hand-rolled convention on purpose — only binding-*shaped* strings\n * are admitted, not every string. `{\"type\":\"string\",\"minLength\":1}` therefore still\n * rejects `\"\"`, and an `enum` still rejects a value outside it, both of which a blanket\n * `z.string()` union would silently discard.\n */\n allowBindings?: boolean;\n}\n\n// The exact test `parseExpression` and `extractVariables` apply before treating a value as\n// an expression (`lib/ast/index.ts`). Anything failing it is a literal at render time, so\n// admitting it here would accept values the renderer will never substitute.\nconst bindingExpression = z\n .string()\n .refine((value) => value.startsWith(\"{{\") && value.endsWith(\"}}\"), {\n message: 'Expected a value of the declared type, or a \"{{binding}}\" expression',\n });\n\nexport function jsonSchemaToZod(schema: JsonSchema, options: JsonSchemaToZodOptions = {}): z.ZodType<unknown> {\n // Applied to every terminus but `object`: an object schema is a prop *container* — the\n // root `propsSchema` is one — and a node's `args` is never itself a binding string. Its\n // properties each pass back through here and are wrapped individually.\n const bindable = (inner: z.ZodType<unknown>): z.ZodType<unknown> =>\n options.allowBindings ? z.union([bindingExpression, inner]) : inner;\n\n if (\"const\" in schema) {\n return bindable(z.literal(schema.const as string | number | boolean));\n }\n\n if (Array.isArray(schema.enum)) {\n const values = schema.enum as (string | number | boolean)[];\n if (values.length === 0) {\n throw new Error(\"jsonSchemaToZod: enum must have at least one value\");\n }\n const [first, ...rest] = values;\n return bindable(rest.reduce((acc: z.ZodType<unknown>, v) => z.union([acc, z.literal(v)]), z.literal(first)));\n }\n\n const type = schema.type as string | undefined;\n\n switch (type) {\n case \"string\": {\n let s = z.string();\n if (typeof schema.minLength === \"number\") s = s.min(schema.minLength);\n if (typeof schema.maxLength === \"number\") s = s.max(schema.maxLength);\n if (typeof schema.pattern === \"string\") s = s.regex(new RegExp(schema.pattern));\n return bindable(s);\n }\n case \"number\":\n case \"integer\": {\n let n = z.number();\n if (type === \"integer\") n = n.int();\n if (typeof schema.minimum === \"number\") n = n.min(schema.minimum);\n if (typeof schema.maximum === \"number\") n = n.max(schema.maximum);\n return bindable(n);\n }\n case \"boolean\":\n return bindable(z.boolean());\n case \"array\": {\n const items = schema.items ? jsonSchemaToZod(schema.items as JsonSchema, options) : z.unknown();\n return bindable(z.array(items));\n }\n case \"object\": {\n const properties = (schema.properties ?? {}) as Record<string, JsonSchema>;\n const required = new Set((schema.required as string[] | undefined) ?? []);\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const [key, propSchema] of Object.entries(properties)) {\n const propZod = jsonSchemaToZod(propSchema, options);\n shape[key] = required.has(key) ? propZod : propZod.optional();\n }\n let obj = z.object(shape);\n if (schema.additionalProperties === false) obj = obj.strict();\n return obj;\n }\n default:\n return z.unknown();\n }\n}\n","import { z } from \"zod\";\n\n// Structural shape of a RegistryManifest on the wire.\n// Pure JSON: no function can be expressed in this schema — that is the\n// entire reason a Case A manifest is safe to accept from a tenant.\nexport const ManifestControlledSchema = z\n .object({\n valueProp: z.string().min(1),\n changeProp: z.string().min(1),\n extract: z.string().min(1),\n })\n .strict();\n\nexport const ManifestComponentSchema = z\n .object({\n name: z.string().min(1),\n canonicalName: z.string().min(1).optional(),\n // Case A: a key resolved against `base`'s exports, never a module path to import.\n entry: z.string().min(1),\n propsSchema: z.record(z.string(), z.unknown()).optional(),\n capabilities: z\n .array(z.enum([\"children\", \"bindings\", \"events\", \"formField\", \"ssr\", \"pdf\"]))\n .optional(),\n controlled: ManifestControlledSchema.optional(),\n css: z.array(z.string()).optional(),\n })\n .strict();\n\nexport const RegistryManifestSchema = z\n .object({\n $schema: z.string().optional(),\n id: z.string().min(1),\n namespace: z.string().min(1).optional(),\n version: z.string().min(1),\n engine: z\n .object({\n name: z.literal(\"bonsai\"),\n api: z.string().min(1),\n })\n .strict(),\n components: z.array(ManifestComponentSchema).min(1),\n integrity: z\n .object({\n algorithm: z.literal(\"sha256\"),\n manifestHash: z.string().min(1),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport type RegistryManifest = z.infer<typeof RegistryManifestSchema>;\nexport type ManifestComponent = z.infer<typeof ManifestComponentSchema>;\n","import { z } from \"zod\";\nimport { jsonSchemaToZod, type JsonSchema } from \"./json-schema-to-zod\";\nimport { RegistryManifestSchema, type ManifestComponent, type RegistryManifest } from \"./manifest-schema\";\nimport { defineBonsaiRegistry, defineComponent, type BonsaiRegistry } from \"./types\";\n\nexport type { RegistryManifest, ManifestComponent } from \"./manifest-schema\";\nexport { RegistryManifestSchema } from \"./manifest-schema\";\n\nconst SUPPORTED_ENGINE_API = \"1\";\n\n// Named-extractor allowlist: a manifest\n// names an extractor from this fixed list, resolved to a real function by the loader.\n// There is no syntactic position in a manifest where a function can be expressed, so\n// none can be smuggled in — this is the reason a Case A manifest is safe to accept\n// from a tenant at all.\nexport const EXTRACTOR_ALLOWLIST: Record<string, (eventOrValue: unknown) => unknown> = {\n identity: (value) => value,\n targetValue: (event) => (event as { target?: { value?: unknown } })?.target?.value,\n targetChecked: (event) => (event as { target?: { checked?: unknown } })?.target?.checked,\n targetValueAsNumber: (event) =>\n (event as { target?: { valueAsNumber?: unknown } })?.target?.valueAsNumber,\n};\n\nexport class ManifestLoadError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ManifestLoadError\";\n }\n}\n\n// Intersect, never replace (a locked security decision: a manifest can narrow or re-describe props but must not widen a\n// component past what its own first-party schema accepts). Deliberately not\n// `z.intersection` — zod's intersection merge does not reliably propagate a strict()\n// base schema's rejection of unrecognized keys, which would silently defeat the\n// narrowing-only guarantee. This runs both schemas independently and requires both to\n// accept the value, so the stricter of the two always wins.\nexport function composePropsSchema(\n baseSchema: z.ZodType<unknown> | undefined,\n tenantSchema: z.ZodType<unknown> | undefined,\n): z.ZodType<unknown> | undefined {\n if (!baseSchema) return tenantSchema;\n if (!tenantSchema) return baseSchema;\n return z.any().superRefine((value, ctx) => {\n const baseResult = baseSchema.safeParse(value);\n if (!baseResult.success) {\n for (const issue of baseResult.error.issues) {\n ctx.addIssue({ code: \"custom\", message: issue.message, path: issue.path });\n }\n }\n const tenantResult = tenantSchema.safeParse(value);\n if (!tenantResult.success) {\n for (const issue of tenantResult.error.issues) {\n ctx.addIssue({ code: \"custom\", message: issue.message, path: issue.path });\n }\n }\n });\n}\n\nexport async function computeManifestHash(raw: string): Promise<string> {\n const bytes = new TextEncoder().encode(raw);\n const digest = await crypto.subtle.digest(\"SHA-256\", bytes);\n const hex = Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n return `sha256:${hex}`;\n}\n\nexport interface ResolveManifestOptions {\n base: BonsaiRegistry;\n engineApi?: string;\n maxComponents?: number;\n maxManifestBytes?: number;\n rawManifestSize?: number;\n manifestHash?: string;\n}\n\nfunction resolveExtractor(name: string): (eventOrValue: unknown) => unknown {\n const fn = EXTRACTOR_ALLOWLIST[name];\n if (!fn) {\n throw new ManifestLoadError(\n `Registry manifest: unknown extractor \"${name}\" — must be one of: ${Object.keys(EXTRACTOR_ALLOWLIST).join(\", \")}`,\n );\n }\n return fn;\n}\n\nfunction resolveComponent(\n entry: ManifestComponent,\n base: BonsaiRegistry,\n manifestId: string,\n): [string, ReturnType<typeof defineComponent>] {\n const baseDef = base.components[entry.entry];\n if (!baseDef) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifestId}\": component \"${entry.name}\" resolves entry \"${entry.entry}\", which is not exported by base registry \"${base.id}\"@\"${base.version}\"`,\n );\n }\n\n const tenantPropsSchema = entry.propsSchema\n ? jsonSchemaToZod(entry.propsSchema as JsonSchema)\n : undefined;\n\n const controlled = entry.controlled\n ? {\n valueProp: entry.controlled.valueProp,\n changeProp: entry.controlled.changeProp,\n extract: resolveExtractor(entry.controlled.extract),\n }\n : baseDef.controlled;\n\n const canonicalName = entry.canonicalName ?? entry.name;\n\n return [\n canonicalName,\n defineComponent({\n component: baseDef.component,\n propsSchema: composePropsSchema(baseDef.propsSchema, tenantPropsSchema),\n capabilities: entry.capabilities ?? baseDef.capabilities,\n controlled,\n assets: entry.css ? { css: entry.css } : baseDef.assets,\n }),\n ];\n}\n\n// Case A only: the manifest binds to component implementations already in `base` —\n// `entry` is a key resolved against `base`'s exports, never a module path to import.\n// Resolution happens once (at init/template-create time), never per render.\nexport function resolveManifest(\n manifest: RegistryManifest,\n options: ResolveManifestOptions,\n): BonsaiRegistry {\n const parsed = RegistryManifestSchema.parse(manifest);\n\n const engineApi = options.engineApi ?? SUPPORTED_ENGINE_API;\n if (parsed.engine.api !== engineApi) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" targets engine.api \"${parsed.engine.api}\", but this build supports \"${engineApi}\"`,\n );\n }\n\n const maxComponents = options.maxComponents ?? 500;\n if (parsed.components.length > maxComponents) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" declares ${parsed.components.length} components, exceeding the limit of ${maxComponents}`,\n );\n }\n\n const maxBytes = options.maxManifestBytes ?? 5 * 1024 * 1024;\n if (options.rawManifestSize != null && options.rawManifestSize > maxBytes) {\n throw new ManifestLoadError(\n `Registry manifest \"${parsed.id}\" is ${options.rawManifestSize} bytes, exceeding the limit of ${maxBytes}`,\n );\n }\n\n const components = Object.fromEntries(\n parsed.components.map((entry) => resolveComponent(entry, options.base, parsed.id)),\n );\n\n return defineBonsaiRegistry({\n id: parsed.id,\n version: parsed.version,\n namespace: parsed.namespace,\n manifestHash: options.manifestHash,\n fallback: options.base.fallback,\n components,\n });\n}\n\nexport interface LoadManifestOptions extends ResolveManifestOptions {\n allowedOrigins?: string[];\n // Test/DI seam — defaults to the global fetch.\n fetchImpl?: typeof fetch;\n}\n\nconst manifestCache = new Map<string, BonsaiRegistry>();\n\nexport function clearManifestCache(): void {\n manifestCache.clear();\n}\n\nfunction verifyIntegrity(manifest: RegistryManifest, hash: string): void {\n if (!manifest.integrity) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifest.id}\" has no integrity block — a manifest hash is required before use`,\n );\n }\n if (manifest.integrity.manifestHash !== hash) {\n throw new ManifestLoadError(\n `Registry manifest \"${manifest.id}\" failed its integrity check: expected \"${manifest.integrity.manifestHash}\", computed \"${hash}\"`,\n );\n }\n}\n\n// Resolves once and caches by manifestHash — never fetched or re-resolved per render\n// (the hosted SSR path has a ~13ms warm budget a network hop plus manifest parse does\n// not fit in).\nexport async function loadRegistryManifest(\n source: RegistryManifest | string,\n options: LoadManifestOptions,\n): Promise<BonsaiRegistry> {\n let raw: string;\n\n if (typeof source === \"string\") {\n const url = new URL(source);\n if (options.allowedOrigins && !options.allowedOrigins.includes(url.origin)) {\n throw new ManifestLoadError(\n `Registry manifest origin \"${url.origin}\" is not in the allowed origins list`,\n );\n }\n const doFetch = options.fetchImpl ?? fetch;\n const res = await doFetch(source);\n if (!res.ok) {\n throw new ManifestLoadError(\n `Registry manifest fetch failed: ${source} responded ${res.status}`,\n );\n }\n raw = await res.text();\n } else {\n raw = JSON.stringify(source);\n }\n\n const manifest = RegistryManifestSchema.parse(JSON.parse(raw));\n\n // The hash covers the manifest's content, not its own integrity block — hashing the\n // raw bytes (which already embed `integrity.manifestHash`) would be self-referential\n // and could never match. This is what a build step computes before stamping the hash\n // back into the manifest it just built.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- discarding `integrity` on purpose\n const { integrity: _integrity, ...withoutIntegrity } = manifest;\n const hash = await computeManifestHash(JSON.stringify(withoutIntegrity));\n verifyIntegrity(manifest, hash);\n\n const cached = manifestCache.get(hash);\n if (cached) return cached;\n\n const resolved = resolveManifest(manifest, { ...options, rawManifestSize: raw.length, manifestHash: hash });\n manifestCache.set(hash, resolved);\n return resolved;\n}\n","import type { JsonSchema } from \"./json-schema-to-zod\";\n\n// A type alias, not an interface, on purpose: `JsonSchema` is `Record<string, unknown>`\n// and only aliases get an implicit index signature. As an interface this type cannot be\n// passed to `jsonSchemaToZod` — which is exactly the composition the comment below\n// describes and which every generated registry adapter performs.\nexport type ObjectPropsSchema = {\n type?: \"object\";\n properties: Record<string, JsonSchema>;\n required?: string[];\n};\n\n// `generated ∪ overrides`, per component and per prop, overrides\n// win. NOT `composePropsSchema` (manifest.ts) — that intersects because it composes an\n// *untrusted* tenant schema over a first-party one, a security boundary. Here both\n// sides are first-party and dev-authored; overrides are authoritative, not narrowing.\n// Runs at the JSON Schema level, before `jsonSchemaToZod` — merging Zod types directly\n// would give intersect-flavoured semantics instead.\nexport function mergeGeneratedWithOverrides(\n generated: ObjectPropsSchema | undefined,\n overrides: Partial<ObjectPropsSchema> | undefined,\n): ObjectPropsSchema {\n const properties = { ...(generated?.properties ?? {}), ...(overrides?.properties ?? {}) };\n const required = [...new Set([...(generated?.required ?? []), ...(overrides?.required ?? [])])];\n return { type: \"object\", properties, required };\n}\n","// The two checks that run at build/startup, in the app that\n// consumes the generated artifact — network-free by construction, both sides are\n// values already on disk (the committed artifact and the installed @base-ui/react).\nexport interface RegistrySource {\n url: string;\n registryHash: string;\n}\n\nexport interface DriftCheckInput {\n // `bonsai.generated.json`'s `registries` and `pebble-kit.json`'s `registries`. Compared\n // per URL rather than as one aggregate hash: this file ships in the browser bundle and\n // must not pull in a hash implementation, and a per-URL comparison can name the\n // registry that moved instead of reporting two opaque digests.\n artifactRegistries: RegistrySource[];\n configRegistries: RegistrySource[];\n artifactBaseUiVersion: string;\n installedBaseUiVersion: string;\n}\n\nfunction describeStaleArtifact(artifact: RegistrySource[], config: RegistrySource[]): string | undefined {\n const artifactByUrl = new Map(artifact.map((r) => [r.url, r.registryHash]));\n const configByUrl = new Map(config.map((r) => [r.url, r.registryHash]));\n const reasons: string[] = [];\n\n for (const [url, configHash] of configByUrl) {\n const artifactHash = artifactByUrl.get(url);\n if (artifactHash === undefined) {\n reasons.push(`${url} is configured but missing from the artifact`);\n } else if (artifactHash !== configHash) {\n reasons.push(`${url}: artifact has ${artifactHash}, pebble-kit.json records ${configHash}`);\n }\n }\n for (const url of artifactByUrl.keys()) {\n if (!configByUrl.has(url)) reasons.push(`${url} is in the artifact but no longer configured`);\n }\n\n return reasons.length > 0 ? reasons.join(\"; \") : undefined;\n}\n\nexport interface DriftIssue {\n check: \"stale-artifact\" | \"baseui-drift\";\n level: \"warn\" | \"fail\";\n message: string;\n}\n\nfunction extractMajor(version: string): number | undefined {\n const match = /(\\d+)\\.\\d+\\.\\d+/.exec(version);\n return match ? Number(match[1]) : undefined;\n}\n\nexport function checkArtifactDrift(input: DriftCheckInput): DriftIssue[] {\n const issues: DriftIssue[] = [];\n\n const staleReason = describeStaleArtifact(input.artifactRegistries, input.configRegistries);\n if (staleReason) {\n issues.push({\n check: \"stale-artifact\",\n level: \"fail\",\n message: `bonsai.generated.json is out of date with pebble-kit.json (${staleReason}) — run \"pebble-kit generate\"`,\n });\n }\n\n if (input.artifactBaseUiVersion !== input.installedBaseUiVersion) {\n const artifactMajor = extractMajor(input.artifactBaseUiVersion);\n const installedMajor = extractMajor(input.installedBaseUiVersion);\n const majorMismatch = artifactMajor !== undefined && installedMajor !== undefined && artifactMajor !== installedMajor;\n issues.push({\n check: \"baseui-drift\",\n level: majorMismatch ? \"fail\" : \"warn\",\n message: `generated artifact's baseline was built against @base-ui/react ${input.artifactBaseUiVersion}, but ${input.installedBaseUiVersion} is installed`,\n });\n }\n\n return issues;\n}\n\n// \"Fail loud\" (5.6): a fail-level issue throws; warn-level issues are the caller's to\n// surface however it likes (console.warn, a logger, ...) — this only gates the hard stop.\nexport function assertNoFailingDrift(issues: DriftIssue[]): void {\n const failing = issues.filter((i) => i.level === \"fail\");\n if (failing.length > 0) {\n throw new Error(failing.map((f) => f.message).join(\"; \"));\n }\n}\n","// Default entrypoint: the batteries-included preset. `Bonsai` here resolves\n// every built-in component, including the heavy ones (calendar, signature),\n// which keeps existing consumers working unchanged. Import\n// `@pebble-software/bonsai/core` instead to start from the lightweight\n// registry and opt into heavy components via `.../presets/*`.\n//\n// The theme stylesheet is not imported here: it ships raw as\n// `@pebble-software/bonsai/index.css` for the consumer's Tailwind build.\n\nimport { createBonsaiRenderer } from \"./renderer/create-renderer\";\nimport { pebbleRegistry } from \"./lib/registry/pebble-registry\";\n\n/** Renderer bound to the full built-in registry. */\nexport const { Bonsai } = createBonsaiRenderer({ registry: pebbleRegistry });\n\nexport { createBonsaiRenderer };\nexport { useUpdateData, useBonsaiRenderMode } from \"./components/core/bonsai\";\nexport { componentMap, controlledInputMap } from \"./lib/ui/registry\";\nexport { pebbleRegistry };\nexport { coreRegistry, extendRegistry } from \"./renderer/core-registry\";\nexport { defineComponent, defineBonsaiRegistry } from \"./lib/registry/types\";\nexport type {\n BonsaiRegistry,\n ComponentDefinition,\n ControlledFieldSpec,\n ComponentCapability,\n} from \"./lib/registry/types\";\nexport { validateTemplate } from \"./lib/registry/validate\";\nexport type {\n RegistryValidationError,\n RegistryValidationResult,\n ValidateTemplateOptions,\n} from \"./lib/registry/validate\";\nexport { resolveRegistryPin } from \"./lib/registry/identity\";\nexport type { RegistryIdentity, PinResolution } from \"./lib/registry/identity\";\nexport {\n resolveManifest,\n loadRegistryManifest,\n computeManifestHash,\n composePropsSchema,\n clearManifestCache,\n ManifestLoadError,\n EXTRACTOR_ALLOWLIST,\n RegistryManifestSchema,\n} from \"./lib/registry/manifest\";\nexport type {\n RegistryManifest,\n ManifestComponent,\n ResolveManifestOptions,\n LoadManifestOptions,\n} from \"./lib/registry/manifest\";\nexport { jsonSchemaToZod } from \"./lib/registry/json-schema-to-zod\";\nexport type { JsonSchema } from \"./lib/registry/json-schema-to-zod\";\nexport { mergeGeneratedWithOverrides } from \"./lib/registry/merge-generated\";\nexport type { ObjectPropsSchema } from \"./lib/registry/merge-generated\";\nexport { checkArtifactDrift, assertNoFailingDrift } from \"./lib/registry/drift\";\nexport type { DriftCheckInput, DriftIssue, RegistrySource } from \"./lib/registry/drift\";\n\nexport type { BonsaiProps, RenderMode } from \"./components/core/bonsai\";\nexport type {\n BonsaiRendererOptions,\n BonsaiRendererInstance,\n} from \"./renderer/create-renderer\";\nexport type {\n BonsaiPreset,\n ComponentRegistry,\n ControlledInput,\n ControlledInputEntry,\n ControlledInputRegistry,\n} from \"./renderer/core-registry\";\nexport type { Config, ConfigNode } from \"./types\";\n"],"names":["OID","z","TIMESTAMP","TemplateSource","Config","body","FormRequestStatus","FileMimeType","PDFRequestStatus","zod","createErrorMap","componentMap","coreComponents","calendarPreset","signaturePreset","controlledInputMap","coreControlledInputs","builtIns","extendRegistry","coreRegistry","pebbleRegistry","defineBonsaiRegistry","type","def","defineComponent","PEBBLE_COMPONENT_SCHEMAS","resolveRegistryPin","pin","registry","versionMatches","manifestHashMatches","isRenderTargetCapable","mode","walk","node","path","errors","STRUCTURAL_COMPONENTS","child","i","result","issue","issuePath","name","value","isClassNameProp","analyzeClassName","validateTemplate","template","options","warnings","resolution","bindingExpression","jsonSchemaToZod","schema","bindable","inner","values","first","rest","acc","v","s","n","items","properties","required","shape","key","propSchema","propZod","obj","ManifestControlledSchema","ManifestComponentSchema","RegistryManifestSchema","SUPPORTED_ENGINE_API","EXTRACTOR_ALLOWLIST","event","ManifestLoadError","message","composePropsSchema","baseSchema","tenantSchema","ctx","baseResult","tenantResult","computeManifestHash","raw","bytes","digest","b","resolveExtractor","fn","resolveComponent","entry","base","manifestId","baseDef","tenantPropsSchema","controlled","resolveManifest","manifest","parsed","engineApi","maxComponents","maxBytes","components","manifestCache","clearManifestCache","verifyIntegrity","hash","loadRegistryManifest","source","url","res","_integrity","withoutIntegrity","cached","resolved","mergeGeneratedWithOverrides","generated","overrides","describeStaleArtifact","artifact","config","artifactByUrl","configByUrl","reasons","configHash","artifactHash","extractMajor","version","match","checkArtifactDrift","input","issues","staleReason","artifactMajor","installedMajor","majorMismatch","assertNoFailingDrift","failing","f","Bonsai","createBonsaiRenderer"],"mappings":";;;;;;;;;;;AAGO,MAAMA,IAAMC,EAAE,OA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5C,SAAOC,IAAQ,OAAOA,EAAM,CAAC,CAAC,IAAI;AACpC;AAEO,SAASC,GAAmBC,GAAsC;AACvE,QAAMC,IAAuB,CAAA,GAEvBC,IAAcd,GAAsBY,EAAM,oBAAoBA,EAAM,gBAAgB;AAS1F,MARIE,KACFD,EAAO,KAAK;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS,8DAA8DC,CAAW;AAAA,EAAA,CACnF,GAGCF,EAAM,0BAA0BA,EAAM,wBAAwB;AAChE,UAAMG,IAAgBP,EAAaI,EAAM,qBAAqB,GACxDI,IAAiBR,EAAaI,EAAM,sBAAsB,GAC1DK,IAAgBF,MAAkB,UAAaC,MAAmB,UAAaD,MAAkBC;AACvG,IAAAH,EAAO,KAAK;AAAA,MACV,OAAO;AAAA,MACP,OAAOI,IAAgB,SAAS;AAAA,MAChC,SAAS,kEAAkEL,EAAM,qBAAqB,SAASA,EAAM,sBAAsB;AAAA,IAAA,CAC5I;AAAA,EACH;AAEA,SAAOC;AACT;AAIO,SAASK,GAAqBL,GAA4B;AAC/D,QAAMM,IAAUN,EAAO,OAAO,CAAChG,MAAMA,EAAE,UAAU,MAAM;AACvD,MAAIsG,EAAQ,SAAS;AACnB,UAAM,IAAI,MAAMA,EAAQ,IAAI,CAACC,MAAMA,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE5D;ACtEO,MAAM,EAAE,QAAAC,GAAA,IAAWC,EAAqB,EAAE,UAAU5H,GAAgB;"}
@@ -1,6 +1,21 @@
1
1
  /**
2
- * Why a `className` value can't be styled from the template's source text, or
3
- * null when it can.
2
+ * Whether an arg takes classes: `className` itself, or a name ending in
3
+ * `ClassName` for a part of the component (`containerClassName`). Validation
4
+ * and the class manifest's template scan both find class props by this name
5
+ * alone, so a prop named any other way is neither checked nor styled.
6
+ */
7
+ export declare function isClassNameProp(name: string): boolean;
8
+ export interface ClassNameAnalysis {
9
+ /**
10
+ * Every class written whole in the value: a plain string's classes, or the
11
+ * classes inside an expression's string literals.
12
+ */
13
+ classes: string[];
14
+ /** Why the value can render a class missing from `classes`, or null when it can't. */
15
+ issue: string | null;
16
+ }
17
+ /**
18
+ * What a class prop's value can render, read from its source text alone.
4
19
  *
5
20
  * Template stylesheets are compiled from the template JSON plus the component
6
21
  * class manifest, without rendering. That covers an expression only when every
@@ -10,4 +25,4 @@
10
25
  * are not. Plain strings always pass; an expression that fails to parse is left
11
26
  * for the render to report.
12
27
  */
13
- export declare function classNameIssue(value: unknown): string | null;
28
+ export declare function analyzeClassName(value: unknown): ClassNameAnalysis;
@@ -57,3 +57,4 @@ export declare enum COMPONENT {
57
57
  IF = "if"
58
58
  }
59
59
  export declare const COMPONENT_LIST: Set<COMPONENT>;
60
+ export declare const STRUCTURAL_COMPONENTS: ReadonlySet<string>;