@friggframework/core 2.0.0--canary.696.5d9f1be.0 → 2.0.0--canary.699.0d57ee8.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 (92) hide show
  1. package/generated/prisma-mongodb/edge.js +2 -2
  2. package/generated/prisma-mongodb/index.js +2 -2
  3. package/generated/prisma-mongodb/package.json +1 -1
  4. package/generated/prisma-mongodb/schema.prisma +2 -2
  5. package/generated/prisma-mongodb/wasm.js +2 -2
  6. package/generated/prisma-postgresql/edge.js +2 -2
  7. package/generated/prisma-postgresql/index.js +2 -2
  8. package/generated/prisma-postgresql/package.json +1 -1
  9. package/generated/prisma-postgresql/schema.prisma +2 -2
  10. package/generated/prisma-postgresql/wasm.js +2 -2
  11. package/handlers/app-handler-helpers.js +5 -2
  12. package/handlers/integration-event-dispatcher.js +1 -1
  13. package/integrations/{data-defined → definitions}/README.md +42 -12
  14. package/integrations/definitions/capabilities/AUDIT.md +452 -0
  15. package/integrations/{data-defined → definitions}/capabilities/asana.capabilities.json +21 -13
  16. package/integrations/{data-defined → definitions}/capabilities/fathom.capabilities.json +15 -6
  17. package/integrations/{data-defined → definitions}/capabilities/hubspot.capabilities.json +77 -27
  18. package/integrations/{data-defined → definitions}/capabilities/linear.capabilities.json +29 -10
  19. package/integrations/{data-defined → definitions}/capabilities/phone.capabilities.json +23 -7
  20. package/integrations/{data-defined → definitions}/capabilities/pipedrive.capabilities.json +25 -11
  21. package/integrations/{data-defined → definitions}/capabilities/salesforce.capabilities.json +64 -18
  22. package/integrations/{data-defined → definitions}/capabilities/slack.capabilities.json +11 -5
  23. package/integrations/{data-defined → definitions}/capabilities/stripe.capabilities.json +27 -10
  24. package/integrations/{data-defined → definitions}/config-form.js +1 -1
  25. package/integrations/{data-defined → definitions}/examples/asana-slack.definition.json +4 -5
  26. package/integrations/{data-defined → definitions}/examples/hubspot-slack.definition.json +4 -4
  27. package/integrations/{data-defined → definitions}/examples/klaviyo-hubspot.definition.json +1 -4
  28. package/integrations/{data-defined → definitions}/examples/phone-hubspot.definition.json +1 -5
  29. package/integrations/{data-defined → definitions}/examples/pipedrive-hubspot.definition.json +1 -1
  30. package/integrations/{data-defined → definitions}/examples/records/phone-hubspot.integration.json +1 -1
  31. package/integrations/{data-defined → definitions}/expressions.js +3 -1
  32. package/integrations/{data-defined → definitions}/index.js +8 -2
  33. package/integrations/{data-defined/data-defined-integration.js → definitions/integration-runtime.js} +24 -23
  34. package/integrations/{data-defined → definitions}/manifests.js +18 -0
  35. package/integrations/definitions/renderers/common.js +67 -0
  36. package/integrations/definitions/renderers/html.js +129 -0
  37. package/integrations/definitions/renderers/hubspot.js +59 -0
  38. package/integrations/definitions/renderers/preview.js +154 -0
  39. package/integrations/definitions/renderers/slack.js +146 -0
  40. package/integrations/{data-defined → definitions}/router.js +11 -11
  41. package/integrations/{data-defined → definitions}/runtime.js +18 -3
  42. package/integrations/{data-defined → definitions}/schema/capability-manifest.v0.1.schema.json +40 -0
  43. package/integrations/{data-defined → definitions}/schema/installation.v0.1.schema.json +1 -1
  44. package/integrations/{data-defined → definitions}/schema/records.md +1 -1
  45. package/integrations/definitions/scripts/check-manifests.js +220 -0
  46. package/integrations/{data-defined → definitions}/scripts/validate.js +1 -1
  47. package/integrations/{data-defined → definitions}/tests/helpers-fake-crm.js +11 -6
  48. package/integrations/{data-defined → definitions}/use-cases/definition-use-cases.js +1 -1
  49. package/integrations/{data-defined → definitions}/validate.js +6 -0
  50. package/integrations/{data-defined → definitions}/versioning.js +1 -1
  51. package/integrations/integration-base.js +31 -1
  52. package/integrations/integration-router.js +1 -1
  53. package/package.json +6 -6
  54. package/prisma-mongodb/schema.prisma +2 -2
  55. package/prisma-postgresql/schema.prisma +2 -2
  56. /package/integrations/{data-defined → definitions}/canonical.js +0 -0
  57. /package/integrations/{data-defined → definitions}/capabilities/acmeerp.capabilities.json +0 -0
  58. /package/integrations/{data-defined → definitions}/capabilities/calendly.capabilities.json +0 -0
  59. /package/integrations/{data-defined → definitions}/capabilities/docusign.capabilities.json +0 -0
  60. /package/integrations/{data-defined → definitions}/capabilities/github.capabilities.json +0 -0
  61. /package/integrations/{data-defined → definitions}/capabilities/jira.capabilities.json +0 -0
  62. /package/integrations/{data-defined → definitions}/capabilities/klaviyo.capabilities.json +0 -0
  63. /package/integrations/{data-defined → definitions}/capabilities/netsuite.capabilities.json +0 -0
  64. /package/integrations/{data-defined → definitions}/capabilities/notion.capabilities.json +0 -0
  65. /package/integrations/{data-defined → definitions}/capabilities/quickbooks.capabilities.json +0 -0
  66. /package/integrations/{data-defined → definitions}/capabilities/shopify.capabilities.json +0 -0
  67. /package/integrations/{data-defined → definitions}/capabilities/webflow.capabilities.json +0 -0
  68. /package/integrations/{data-defined → definitions}/capabilities/zendesk.capabilities.json +0 -0
  69. /package/integrations/{data-defined → definitions}/compile.js +0 -0
  70. /package/integrations/{data-defined → definitions}/examples/acme-erp-quickbooks.definition.json +0 -0
  71. /package/integrations/{data-defined → definitions}/examples/calendly-salesforce.definition.json +0 -0
  72. /package/integrations/{data-defined → definitions}/examples/docusign-salesforce.definition.json +0 -0
  73. /package/integrations/{data-defined → definitions}/examples/fathom-hubspot-notion.definition.json +0 -0
  74. /package/integrations/{data-defined → definitions}/examples/github-linear.definition.json +0 -0
  75. /package/integrations/{data-defined → definitions}/examples/pipedrive-phone.definition.json +0 -0
  76. /package/integrations/{data-defined → definitions}/examples/records/phone-hubspot.definition-version.json +0 -0
  77. /package/integrations/{data-defined → definitions}/examples/records/phone-hubspot.mappings.json +0 -0
  78. /package/integrations/{data-defined → definitions}/examples/records/phone-hubspot.workflow-run.json +0 -0
  79. /package/integrations/{data-defined → definitions}/examples/shopify-klaviyo.definition.json +0 -0
  80. /package/integrations/{data-defined → definitions}/examples/shopify-netsuite.definition.json +0 -0
  81. /package/integrations/{data-defined → definitions}/examples/stripe-quickbooks.definition.json +0 -0
  82. /package/integrations/{data-defined → definitions}/examples/webflow-hubspot-slack.definition.json +0 -0
  83. /package/integrations/{data-defined → definitions}/examples/zendesk-jira.definition.json +0 -0
  84. /package/integrations/{data-defined → definitions}/interpreter.js +0 -0
  85. /package/integrations/{data-defined → definitions}/repositories/definition-version-repository.js +0 -0
  86. /package/integrations/{data-defined → definitions}/repositories/workflow-run-repository.js +0 -0
  87. /package/integrations/{data-defined → definitions}/schema/integration-definition.v0.1.schema.json +0 -0
  88. /package/integrations/{data-defined → definitions}/schema-check.js +0 -0
  89. /package/integrations/{data-defined → definitions}/steps.js +0 -0
  90. /package/integrations/{data-defined → definitions}/sync-engine.js +0 -0
  91. /package/integrations/{data-defined → definitions}/transforms.js +0 -0
  92. /package/integrations/{data-defined → definitions}/webhooks.js +0 -0
@@ -428,8 +428,8 @@ const config = {
428
428
  }
429
429
  }
430
430
  },
431
- "inlineSchema": "// Frigg Framework - Prisma Schema (PostgreSQL)\n// PostgreSQL database schema for enterprise integration platform\n// Converted from MongoDB schema for relational database support\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../generated/prisma-postgresql\"\n binaryTargets = [\"native\", \"rhel-openssl-3.0.x\"] // native for local dev, rhel for Lambda deployment\n // Library engine (default since Prisma 3.x): Rust query engine loads as a\n // Node-API addon inside the same process. The binary engine forks a child\n // query-engine subprocess and communicates over a local HTTP/IPC pipe with\n // NO client-side timeout — a zombied child wedges the Node process until\n // Lambda's 900s cap. Switching to library eliminates that entire class of\n // silent hangs. See friggframework/frigg#580 for the investigation.\n engineType = \"library\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\n// ============================================================================\n// USER MODELS\n// ============================================================================\n\n/// User model with discriminator pattern support\n/// Replaces Mongoose discriminators (IndividualUser, OrganizationUser)\nmodel User {\n id Int @id @default(autoincrement())\n type UserType\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // IndividualUser fields (nullable for organizations)\n email String?\n username String?\n hashword String? // Bcrypt hashed password (handled in application layer)\n appUserId String?\n organizationId Int?\n\n // Self-referential relation for organization membership\n organization User? @relation(\"OrgMembers\", fields: [organizationId], references: [id], onDelete: NoAction, onUpdate: NoAction)\n members User[] @relation(\"OrgMembers\")\n\n // OrganizationUser fields (nullable for individuals)\n appOrgId String?\n name String?\n\n // Relations\n tokens Token[]\n credentials Credential[]\n entities Entity[]\n integrations Integration[]\n processes Process[]\n\n @@unique([username, appUserId])\n @@index([type])\n @@index([appUserId])\n @@index([organizationId])\n}\n\nenum UserType {\n INDIVIDUAL\n ORGANIZATION\n}\n\n// ============================================================================\n// AUTHENTICATION MODELS\n// ============================================================================\n\n/// Authentication tokens with expiration\n/// Bcrypt hashed tokens stored (handled in application layer)\nmodel Token {\n id Int @id @default(autoincrement())\n token String // Bcrypt hashed\n created DateTime @default(now())\n expires DateTime?\n userId Int\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n @@index([userId])\n @@index([expires])\n}\n\n// ============================================================================\n// CREDENTIAL & ENTITY MODELS\n// ============================================================================\n\n/// OAuth credentials and API tokens\n/// All sensitive data encrypted with KMS at rest\nmodel Credential {\n id Int @id @default(autoincrement())\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n authIsValid Boolean?\n externalId String?\n\n // Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)\n // Contains: access_token, refresh_token, domain, expires_in, token_type, etc.\n data Json @default(\"{}\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations\n entities Entity[]\n\n @@index([userId])\n @@index([externalId])\n}\n\n/// External service entities (API connections)\nmodel Entity {\n id Int @id @default(autoincrement())\n credentialId Int?\n credential Credential? @relation(fields: [credentialId], references: [id], onDelete: SetNull)\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n name String?\n moduleName String?\n externalId String?\n\n data Json @default(\"{}\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations - many-to-many with implicit join tables\n integrations Integration[]\n syncs Sync[]\n\n dataIdentifiers DataIdentifier[]\n associationObjects AssociationObject[]\n\n @@index([userId])\n @@index([externalId])\n @@index([moduleName])\n @@index([credentialId])\n}\n\n// ============================================================================\n// INTEGRATION MODELS\n// ============================================================================\n\n/// Main integration configuration and state\nmodel Integration {\n id Int @id @default(autoincrement())\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n status IntegrationStatus @default(IN_CREATION)\n\n // Configuration and version\n config Json? // Integration configuration object\n version String?\n\n // Entity references (many-to-many via implicit join table)\n entities Entity[]\n\n // Message arrays (stored as JSON)\n errors Json @default(\"[]\")\n warnings Json @default(\"[]\")\n info Json @default(\"[]\")\n logs Json @default(\"[]\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations\n associations Association[]\n syncs Sync[]\n mappings IntegrationMapping[]\n processes Process[]\n workflowRuns WorkflowRun[]\n\n @@index([userId])\n @@index([status])\n}\n\nenum IntegrationStatus {\n ENABLED\n NEEDS_CONFIG\n PROCESSING\n DISABLED\n ERROR\n IN_CREATION\n IN_DELETION\n}\n\n/// Integration-specific data mappings\n/// All mapping data encrypted with KMS\nmodel IntegrationMapping {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n sourceId String?\n\n // Encrypted mapping data (handled via Prisma middleware)\n mapping Json?\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([integrationId, sourceId])\n @@index([integrationId])\n @@index([sourceId])\n}\n\n// ============================================================================\n// SYNC MODELS\n// ============================================================================\n\n/// Bidirectional data synchronization tracking\nmodel Sync {\n id Int @id @default(autoincrement())\n integrationId Int?\n integration Integration? @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n\n // Entity references (many-to-many via implicit join table)\n entities Entity[]\n\n hash String\n name String\n\n // Data identifiers (extracted to separate model)\n dataIdentifiers DataIdentifier[]\n\n @@index([integrationId])\n @@index([hash])\n @@index([name])\n}\n\n/// Data identifier for sync operations\n/// Replaces nested array structure in Mongoose\nmodel DataIdentifier {\n id Int @id @default(autoincrement())\n syncId Int?\n sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)\n entityId Int\n entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)\n\n // Identifier data (can be any structure)\n idData Json\n\n hash String\n\n @@index([syncId])\n @@index([entityId])\n @@index([hash])\n}\n\n// ============================================================================\n// ASSOCIATION MODELS\n// ============================================================================\n\n/// Entity associations with cardinality tracking\nmodel Association {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n name String\n type AssociationType\n primaryObject String\n\n // Associated objects (extracted to separate model)\n objects AssociationObject[]\n\n @@index([integrationId])\n @@index([name])\n}\n\n/// Association object entry\n/// Replaces nested array structure in Mongoose\nmodel AssociationObject {\n id Int @id @default(autoincrement())\n associationId Int\n association Association @relation(fields: [associationId], references: [id], onDelete: Cascade)\n entityId Int\n entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)\n objectType String\n objId String\n metadata Json? // Optional metadata\n\n @@index([associationId])\n @@index([entityId])\n}\n\nenum AssociationType {\n ONE_TO_MANY\n ONE_TO_ONE\n MANY_TO_ONE\n}\n\n// ============================================================================\n// PROCESS MODELS\n// ============================================================================\n\n/// Generic Process Model - tracks any long-running operation\n/// Used for: CRM syncs, data migrations, bulk operations, etc.\nmodel Process {\n id Int @id @default(autoincrement())\n\n // Core references\n userId Int\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n\n // Process identification\n name String // e.g., \"zoho-crm-contact-sync\", \"pipedrive-lead-sync\"\n type String // e.g., \"CRM_SYNC\", \"DATA_MIGRATION\", \"BULK_OPERATION\"\n\n // State machine\n state String // Current state (integration-defined states)\n\n // Flexible storage\n context Json @default(\"{}\") // Process-specific data (pagination, metadata, etc.)\n results Json @default(\"{}\") // Process results and metrics\n\n // Hierarchy support - self-referential relation\n parentProcessId Int?\n parentProcess Process? @relation(\"ProcessHierarchy\", fields: [parentProcessId], references: [id], onDelete: SetNull)\n childProcesses Process[] @relation(\"ProcessHierarchy\")\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n @@index([integrationId])\n @@index([type])\n @@index([state])\n @@index([name])\n @@index([parentProcessId])\n}\n\n// ============================================================================\n// UTILITY MODELS\n// ============================================================================\n\n/// Generic state storage\nmodel State {\n id Int @id @default(autoincrement())\n state Json?\n}\n\n/// AWS API Gateway WebSocket connection tracking\nmodel WebsocketConnection {\n id Int @id @default(autoincrement())\n connectionId String?\n\n @@index([connectionId])\n}\n\n// ============================================================================\n// ADMIN PROCESS MODELS\n// ============================================================================\n\n/// Admin process state machine\nenum AdminScriptExecutionState {\n PENDING\n RUNNING\n COMPLETED\n FAILED\n}\n\n/// Admin process tracking (like Process but without user/integration FK)\n/// Used for: admin scripts, db migrations, system maintenance tasks\nmodel AdminScriptExecution {\n id Int @id @default(autoincrement())\n name String // e.g., \"oauth-token-refresh\", \"db-migration-xyz\"\n type String // e.g., \"ADMIN_SCRIPT\", \"DB_MIGRATION\"\n\n // State machine\n state AdminScriptExecutionState @default(PENDING)\n\n // Flexible storage (mirrors Process model pattern)\n context Json @default(\"{}\") // input, trigger, audit info, script version\n results Json @default(\"{}\") // output, logs, metrics, errors\n\n // Hierarchy support - self-referential relation\n parentExecutionId Int?\n parentExecution AdminScriptExecution? @relation(\"AdminScriptExecutionHierarchy\", fields: [parentExecutionId], references: [id], onDelete: SetNull)\n childExecutions AdminScriptExecution[] @relation(\"AdminScriptExecutionHierarchy\")\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([name, createdAt(sort: Desc)])\n @@index([state])\n @@index([type])\n}\n\n/// Script scheduling configuration for hybrid scheduling (SQS + EventBridge)\nmodel ScriptSchedule {\n id Int @id @default(autoincrement())\n scriptName String @unique\n enabled Boolean @default(false)\n cronExpression String?\n timezone String @default(\"UTC\")\n lastTriggeredAt DateTime?\n nextTriggerAt DateTime?\n\n // External Scheduler (e.g., AWS EventBridge Scheduler)\n externalScheduleId String?\n externalScheduleName String?\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([enabled])\n}\n\n/// Durable usage counters, deliberately isolated: no userId and no foreign key\n/// to Integration, so a user-scoped query can never return a usage row and usage\n/// history survives integration deletion.\nmodel UsageCounter {\n id Int @id @default(autoincrement())\n\n integrationId String\n integrationType String\n metric String\n window String // e.g. \"day:2026-07-05\" or \"hour:2026-07-05T14\"\n value BigInt @default(0) // BigInt: a busy day/hour counter can exceed 32-bit\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([integrationId, integrationType, metric, window])\n // Covers totals() (metric + window prefix/range, no integrationType filter).\n @@index([metric, window])\n // Covers series() (metric + integrationType + window range).\n @@index([metric, integrationType, window])\n}\n\n// Data-defined integrations (ADR-063): one immutable row per published definition version.\nenum DefinitionStatus {\n DRAFT\n PUBLISHED\n DEPRECATED\n RETIRED\n}\n\nmodel IntegrationDefinitionVersion {\n id Int @id @default(autoincrement())\n definitionId String\n version String\n schemaVersion String\n status DefinitionStatus @default(DRAFT)\n checksum String\n document Json\n changeLevel String?\n previousVersion String?\n notes String?\n createdBy String?\n // The workspace an integration a user built belongs to (null: the app's own catalogue, offered to everyone).\n workspaceId String?\n publishedAt DateTime?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([definitionId, version])\n @@index([definitionId, status])\n @@index([workspaceId, status])\n}\n\n// One row per data-defined workflow run. trace holds step ids, statuses, timings and error messages, never request or\n// response bodies.\nmodel WorkflowRun {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n definitionId String\n definitionVersion String\n workflowId String\n triggerType String\n eventId String?\n status String\n reason String?\n error String?\n retryable Boolean @default(false)\n trace Json @default(\"[]\")\n /// The runtime's run id (run_...): how routes and resume jobs address a run\n runKey String?\n /// A paused run (status waiting): which step, and what it waits for. Never request or response bodies.\n waitingFor Json?\n resumeAt DateTime?\n startedAt DateTime\n endedAt DateTime?\n createdAt DateTime @default(now())\n\n @@index([integrationId, runKey])\n @@index([integrationId, startedAt])\n @@index([integrationId, workflowId, startedAt])\n @@index([integrationId, status])\n}\n",
432
- "inlineSchemaHash": "7cbcf3d54afbe39160d69f8b640da30304af16dd1eb4ce3267842820b464be7a",
431
+ "inlineSchema": "// Frigg Framework - Prisma Schema (PostgreSQL)\n// PostgreSQL database schema for enterprise integration platform\n// Converted from MongoDB schema for relational database support\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../generated/prisma-postgresql\"\n binaryTargets = [\"native\", \"rhel-openssl-3.0.x\"] // native for local dev, rhel for Lambda deployment\n // Library engine (default since Prisma 3.x): Rust query engine loads as a\n // Node-API addon inside the same process. The binary engine forks a child\n // query-engine subprocess and communicates over a local HTTP/IPC pipe with\n // NO client-side timeout — a zombied child wedges the Node process until\n // Lambda's 900s cap. Switching to library eliminates that entire class of\n // silent hangs. See friggframework/frigg#580 for the investigation.\n engineType = \"library\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\n// ============================================================================\n// USER MODELS\n// ============================================================================\n\n/// User model with discriminator pattern support\n/// Replaces Mongoose discriminators (IndividualUser, OrganizationUser)\nmodel User {\n id Int @id @default(autoincrement())\n type UserType\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // IndividualUser fields (nullable for organizations)\n email String?\n username String?\n hashword String? // Bcrypt hashed password (handled in application layer)\n appUserId String?\n organizationId Int?\n\n // Self-referential relation for organization membership\n organization User? @relation(\"OrgMembers\", fields: [organizationId], references: [id], onDelete: NoAction, onUpdate: NoAction)\n members User[] @relation(\"OrgMembers\")\n\n // OrganizationUser fields (nullable for individuals)\n appOrgId String?\n name String?\n\n // Relations\n tokens Token[]\n credentials Credential[]\n entities Entity[]\n integrations Integration[]\n processes Process[]\n\n @@unique([username, appUserId])\n @@index([type])\n @@index([appUserId])\n @@index([organizationId])\n}\n\nenum UserType {\n INDIVIDUAL\n ORGANIZATION\n}\n\n// ============================================================================\n// AUTHENTICATION MODELS\n// ============================================================================\n\n/// Authentication tokens with expiration\n/// Bcrypt hashed tokens stored (handled in application layer)\nmodel Token {\n id Int @id @default(autoincrement())\n token String // Bcrypt hashed\n created DateTime @default(now())\n expires DateTime?\n userId Int\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n @@index([userId])\n @@index([expires])\n}\n\n// ============================================================================\n// CREDENTIAL & ENTITY MODELS\n// ============================================================================\n\n/// OAuth credentials and API tokens\n/// All sensitive data encrypted with KMS at rest\nmodel Credential {\n id Int @id @default(autoincrement())\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n authIsValid Boolean?\n externalId String?\n\n // Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)\n // Contains: access_token, refresh_token, domain, expires_in, token_type, etc.\n data Json @default(\"{}\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations\n entities Entity[]\n\n @@index([userId])\n @@index([externalId])\n}\n\n/// External service entities (API connections)\nmodel Entity {\n id Int @id @default(autoincrement())\n credentialId Int?\n credential Credential? @relation(fields: [credentialId], references: [id], onDelete: SetNull)\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n name String?\n moduleName String?\n externalId String?\n\n data Json @default(\"{}\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations - many-to-many with implicit join tables\n integrations Integration[]\n syncs Sync[]\n\n dataIdentifiers DataIdentifier[]\n associationObjects AssociationObject[]\n\n @@index([userId])\n @@index([externalId])\n @@index([moduleName])\n @@index([credentialId])\n}\n\n// ============================================================================\n// INTEGRATION MODELS\n// ============================================================================\n\n/// Main integration configuration and state\nmodel Integration {\n id Int @id @default(autoincrement())\n userId Int?\n user User? @relation(fields: [userId], references: [id], onDelete: Cascade)\n status IntegrationStatus @default(IN_CREATION)\n\n // Configuration and version\n config Json? // Integration configuration object\n version String?\n\n // Entity references (many-to-many via implicit join table)\n entities Entity[]\n\n // Message arrays (stored as JSON)\n errors Json @default(\"[]\")\n warnings Json @default(\"[]\")\n info Json @default(\"[]\")\n logs Json @default(\"[]\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n // Relations\n associations Association[]\n syncs Sync[]\n mappings IntegrationMapping[]\n processes Process[]\n workflowRuns WorkflowRun[]\n\n @@index([userId])\n @@index([status])\n}\n\nenum IntegrationStatus {\n ENABLED\n NEEDS_CONFIG\n PROCESSING\n DISABLED\n ERROR\n IN_CREATION\n IN_DELETION\n}\n\n/// Integration-specific data mappings\n/// All mapping data encrypted with KMS\nmodel IntegrationMapping {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n sourceId String?\n\n // Encrypted mapping data (handled via Prisma middleware)\n mapping Json?\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([integrationId, sourceId])\n @@index([integrationId])\n @@index([sourceId])\n}\n\n// ============================================================================\n// SYNC MODELS\n// ============================================================================\n\n/// Bidirectional data synchronization tracking\nmodel Sync {\n id Int @id @default(autoincrement())\n integrationId Int?\n integration Integration? @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n\n // Entity references (many-to-many via implicit join table)\n entities Entity[]\n\n hash String\n name String\n\n // Data identifiers (extracted to separate model)\n dataIdentifiers DataIdentifier[]\n\n @@index([integrationId])\n @@index([hash])\n @@index([name])\n}\n\n/// Data identifier for sync operations\n/// Replaces nested array structure in Mongoose\nmodel DataIdentifier {\n id Int @id @default(autoincrement())\n syncId Int?\n sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)\n entityId Int\n entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)\n\n // Identifier data (can be any structure)\n idData Json\n\n hash String\n\n @@index([syncId])\n @@index([entityId])\n @@index([hash])\n}\n\n// ============================================================================\n// ASSOCIATION MODELS\n// ============================================================================\n\n/// Entity associations with cardinality tracking\nmodel Association {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n name String\n type AssociationType\n primaryObject String\n\n // Associated objects (extracted to separate model)\n objects AssociationObject[]\n\n @@index([integrationId])\n @@index([name])\n}\n\n/// Association object entry\n/// Replaces nested array structure in Mongoose\nmodel AssociationObject {\n id Int @id @default(autoincrement())\n associationId Int\n association Association @relation(fields: [associationId], references: [id], onDelete: Cascade)\n entityId Int\n entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)\n objectType String\n objId String\n metadata Json? // Optional metadata\n\n @@index([associationId])\n @@index([entityId])\n}\n\nenum AssociationType {\n ONE_TO_MANY\n ONE_TO_ONE\n MANY_TO_ONE\n}\n\n// ============================================================================\n// PROCESS MODELS\n// ============================================================================\n\n/// Generic Process Model - tracks any long-running operation\n/// Used for: CRM syncs, data migrations, bulk operations, etc.\nmodel Process {\n id Int @id @default(autoincrement())\n\n // Core references\n userId Int\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n\n // Process identification\n name String // e.g., \"zoho-crm-contact-sync\", \"pipedrive-lead-sync\"\n type String // e.g., \"CRM_SYNC\", \"DATA_MIGRATION\", \"BULK_OPERATION\"\n\n // State machine\n state String // Current state (integration-defined states)\n\n // Flexible storage\n context Json @default(\"{}\") // Process-specific data (pagination, metadata, etc.)\n results Json @default(\"{}\") // Process results and metrics\n\n // Hierarchy support - self-referential relation\n parentProcessId Int?\n parentProcess Process? @relation(\"ProcessHierarchy\", fields: [parentProcessId], references: [id], onDelete: SetNull)\n childProcesses Process[] @relation(\"ProcessHierarchy\")\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n @@index([integrationId])\n @@index([type])\n @@index([state])\n @@index([name])\n @@index([parentProcessId])\n}\n\n// ============================================================================\n// UTILITY MODELS\n// ============================================================================\n\n/// Generic state storage\nmodel State {\n id Int @id @default(autoincrement())\n state Json?\n}\n\n/// AWS API Gateway WebSocket connection tracking\nmodel WebsocketConnection {\n id Int @id @default(autoincrement())\n connectionId String?\n\n @@index([connectionId])\n}\n\n// ============================================================================\n// ADMIN PROCESS MODELS\n// ============================================================================\n\n/// Admin process state machine\nenum AdminScriptExecutionState {\n PENDING\n RUNNING\n COMPLETED\n FAILED\n}\n\n/// Admin process tracking (like Process but without user/integration FK)\n/// Used for: admin scripts, db migrations, system maintenance tasks\nmodel AdminScriptExecution {\n id Int @id @default(autoincrement())\n name String // e.g., \"oauth-token-refresh\", \"db-migration-xyz\"\n type String // e.g., \"ADMIN_SCRIPT\", \"DB_MIGRATION\"\n\n // State machine\n state AdminScriptExecutionState @default(PENDING)\n\n // Flexible storage (mirrors Process model pattern)\n context Json @default(\"{}\") // input, trigger, audit info, script version\n results Json @default(\"{}\") // output, logs, metrics, errors\n\n // Hierarchy support - self-referential relation\n parentExecutionId Int?\n parentExecution AdminScriptExecution? @relation(\"AdminScriptExecutionHierarchy\", fields: [parentExecutionId], references: [id], onDelete: SetNull)\n childExecutions AdminScriptExecution[] @relation(\"AdminScriptExecutionHierarchy\")\n\n // Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([name, createdAt(sort: Desc)])\n @@index([state])\n @@index([type])\n}\n\n/// Script scheduling configuration for hybrid scheduling (SQS + EventBridge)\nmodel ScriptSchedule {\n id Int @id @default(autoincrement())\n scriptName String @unique\n enabled Boolean @default(false)\n cronExpression String?\n timezone String @default(\"UTC\")\n lastTriggeredAt DateTime?\n nextTriggerAt DateTime?\n\n // External Scheduler (e.g., AWS EventBridge Scheduler)\n externalScheduleId String?\n externalScheduleName String?\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([enabled])\n}\n\n/// Durable usage counters, deliberately isolated: no userId and no foreign key\n/// to Integration, so a user-scoped query can never return a usage row and usage\n/// history survives integration deletion.\nmodel UsageCounter {\n id Int @id @default(autoincrement())\n\n integrationId String\n integrationType String\n metric String\n window String // e.g. \"day:2026-07-05\" or \"hour:2026-07-05T14\"\n value BigInt @default(0) // BigInt: a busy day/hour counter can exceed 32-bit\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([integrationId, integrationType, metric, window])\n // Covers totals() (metric + window prefix/range, no integrationType filter).\n @@index([metric, window])\n // Covers series() (metric + integrationType + window range).\n @@index([metric, integrationType, window])\n}\n\n// Integrations published as definitions (ADR-063): one immutable row per published definition version.\nenum DefinitionStatus {\n DRAFT\n PUBLISHED\n DEPRECATED\n RETIRED\n}\n\nmodel IntegrationDefinitionVersion {\n id Int @id @default(autoincrement())\n definitionId String\n version String\n schemaVersion String\n status DefinitionStatus @default(DRAFT)\n checksum String\n document Json\n changeLevel String?\n previousVersion String?\n notes String?\n createdBy String?\n // The workspace an integration a user built belongs to (null: the app's own catalogue, offered to everyone).\n workspaceId String?\n publishedAt DateTime?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([definitionId, version])\n @@index([definitionId, status])\n @@index([workspaceId, status])\n}\n\n// One row per workflow run. trace holds step ids, statuses, timings and error messages, never request or\n// response bodies.\nmodel WorkflowRun {\n id Int @id @default(autoincrement())\n integrationId Int\n integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)\n definitionId String\n definitionVersion String\n workflowId String\n triggerType String\n eventId String?\n status String\n reason String?\n error String?\n retryable Boolean @default(false)\n trace Json @default(\"[]\")\n /// The runtime's run id (run_...): how routes and resume jobs address a run\n runKey String?\n /// A paused run (status waiting): which step, and what it waits for. Never request or response bodies.\n waitingFor Json?\n resumeAt DateTime?\n startedAt DateTime\n endedAt DateTime?\n createdAt DateTime @default(now())\n\n @@index([integrationId, runKey])\n @@index([integrationId, startedAt])\n @@index([integrationId, workflowId, startedAt])\n @@index([integrationId, status])\n}\n",
432
+ "inlineSchemaHash": "5d11039694b44af001971b7239ab8290b642c385239660aee17e709d4fa0b509",
433
433
  "copyEngine": true
434
434
  }
435
435
  config.dirname = '/'
@@ -12,8 +12,11 @@ const log = getLogger('frigg.http');
12
12
  const createApp = (applyMiddleware) => {
13
13
  const app = express();
14
14
 
15
- app.use(bodyParser.json({ limit: '10mb' }));
16
- app.use(bodyParser.urlencoded({ extended: true }));
15
+ // Keep the bytes as received: webhook signatures (HubSpot, Slack, Stripe, Linear…) are computed over the exact
16
+ // raw body, which re-serialising the parsed body does not reproduce. A reference to the buffer, not a copy.
17
+ const keepRaw = (req, res, buf) => { req.rawBody = buf; };
18
+ app.use(bodyParser.json({ limit: '10mb', verify: keepRaw }));
19
+ app.use(bodyParser.urlencoded({ extended: true, verify: keepRaw }));
17
20
  app.use(
18
21
  cors({
19
22
  origin: '*',
@@ -21,7 +21,7 @@ class IntegrationEventDispatcher {
21
21
  async dispatchJob({ event, data, context, delivery }) {
22
22
  return this._dispatch(event, (instance, handler) => {
23
23
  const invoke = () => handler.call(instance, { data, context, delivery });
24
- // An integration that keeps run history records each queued event as a run (data-defined runtime).
24
+ // An integration that keeps run history records each queued event as a run (integration runtime).
25
25
  return typeof instance.runEvent === 'function'
26
26
  ? instance.runEvent(event, invoke)
27
27
  : invoke();
@@ -1,4 +1,4 @@
1
- # Data-defined integrations (v0.1)
1
+ # Integrations published as definitions (v0.1)
2
2
 
3
3
  ADR-063, implemented to the point where a definition can be validated, compiled into Frigg events, executed, rendered
4
4
  and versioned. An integration becomes a **document** (what it connects, what it syncs, which workflows and UI it has)
@@ -17,9 +17,10 @@ installation (Integration.config) ─┘ │
17
17
  |---|---|
18
18
  | `schema/integration-definition.v0.1.schema.json` | The definition format (JSON Schema 2020-12) |
19
19
  | `schema/capability-manifest.v0.1.schema.json` | What an API module declares it can do |
20
- | `schema/installation.v0.1.schema.json` | `Integration.config` for a data-defined installation |
20
+ | `schema/installation.v0.1.schema.json` | `Integration.config` for an installation |
21
21
  | `schema/records.md` | Database records: definition versions, installation, mappings, workflow runs |
22
- | `capabilities/*.capabilities.json` | Mock manifests (HubSpot, Phone, and the apps the examples use) |
22
+ | `capabilities/*.capabilities.json` | Capability manifests. Nine are checked against the real Api classes (`capabilities/AUDIT.md`); the other twelve are still mock-shaped |
23
+ | `scripts/check-manifests.js` | Checks every manifest `method` exists on the real module's Api class, with the arguments it takes |
23
24
  | `examples/*.definition.json` | Example definitions; `examples/records/` has Phone ↔ HubSpot database records |
24
25
  | `expressions.js` | `$.ref`, `{{template \| filter}}` and conditions. No eval. |
25
26
  | `steps.js`, `interpreter.js`, `transforms.js` | The step catalogue and the interpreter |
@@ -29,7 +30,7 @@ installation (Integration.config) ─┘ │
29
30
  | `sync-engine.js` | Syncs: link → identity → search → create/update, master rules, backfill pages, polls |
30
31
  | `runtime.js` | Ports (Api calls, link store), `runWorkflow`, `runQuery`, `renderSurface`, `runLifecycle`, `resolveOptions`, `installContext` |
31
32
  | `versioning.js` | `diff`, `checkBump`, `planUpgrade` |
32
- | `data-defined-integration.js` | `defineIntegrationClass`: the IntegrationBase subclass that runs it all |
33
+ | `integration-runtime.js` | `defineIntegrationClass`: the IntegrationBase subclass that runs it all |
33
34
  | `use-cases/definition-use-cases.js` | Publish, deprecate, catalogue, history, upgrade plan; `createDefinitionCatalog()` (the store the runtime reads) |
34
35
  | `repositories/` | `IntegrationDefinitionVersion` and `WorkflowRun` rows (MongoDB, PostgreSQL, DocumentDB) |
35
36
  | `router.js` | The publish, catalogue, upgrade and run-history routes |
@@ -106,9 +107,9 @@ Definitions live in the `IntegrationDefinitionVersion` table (Prisma models in b
106
107
  `20261018000000_add_data_defined_integrations`), and runs in `WorkflowRun`. Point the class at the store:
107
108
 
108
109
  ```js
109
- const { defineSharedIntegrationClass, createDefinitionCatalog } = require('@friggframework/core/integrations/data-defined');
110
+ const { defineSharedIntegrationClass, createDefinitionCatalog } = require('@friggframework/core/integrations/definitions');
110
111
  // A database store is read asynchronously, so it goes with the shared class (one class, every definition).
111
- const DataDefined = defineSharedIntegrationClass({ definitions: createDefinitionCatalog(), manifests, modules });
112
+ const IntegrationRuntime = defineSharedIntegrationClass({ definitions: createDefinitionCatalog(), manifests, modules });
112
113
  ```
113
114
 
114
115
  | Route | Auth | |
@@ -117,8 +118,8 @@ const DataDefined = defineSharedIntegrationClass({ definitions: createDefinition
117
118
  | `GET /admin/integrations/:id/versions` | admin key | Version history |
118
119
  | `POST /admin/integrations/:id/versions/:v/deprecate` | admin key | Stop new installs of a version |
119
120
  | `GET /api/integrations` | user | What can be installed: code and published integrations in one list of options |
120
- | `GET /api/data-defined/definitions` | user | The published ones, with their counts |
121
- | `POST /api/integrations` with `config: { type: '<id>' }` | user | Install; pins the latest published version and its checksum (`{ type: 'data-defined', definition: { id } }` still works) |
121
+ | `GET /api/integration-definitions` | user | The published ones, with their counts |
122
+ | `POST /api/integrations` with `config: { type: '<id>' }` | user | Install; pins the latest published version and its checksum |
122
123
  | `GET` / `POST /api/integrations/:id/upgrade` `{ to? }` | user | Plan / apply an upgrade (409 with the plan while something is needed) |
123
124
  | `GET /api/integrations/:id/runs` | user | Run history, newest first |
124
125
  | `GET /api/integrations/:id/syncs` | user | Each sync's backfill progress and poll marks |
@@ -144,6 +145,29 @@ different document at the same version is refused. So is a version that is not n
144
145
  semver bump smaller than the changes. Publishing goes through a conditional write, so two concurrent publishes of one
145
146
  version cannot both win. With `memoryDefinitions()` (definitions bundled in the app) the admin routes answer 501.
146
147
 
148
+ ## Previews: in the app
149
+
150
+ An integration shows up inside the apps it connects: a HubSpot card, a Slack message, digest or approval request. A
151
+ preview renders exactly that from the current settings and sample or real records, with the same query, view and step
152
+ code production runs (`renderers/`):
153
+
154
+ | Function | Does |
155
+ |---|---|
156
+ | `previewSurface({ def, installation, surfaceId, record, ports, host? })` | `{ surface, view, html, slack?, hubspot? }`. `slack` is Block Kit (`{ blocks, text, truncated }`), `hubspot` a data description of `@hubspot/ui-extensions` components (names and props checked against 0.17.1; `props` are real component props, a userAction button carries our own node-level `action` for the card to post, an `open_url` button is a real `href`), `html` the same card framed as its host looks. `host` defaults to the surface's own |
157
+ | `previewWorkflow({ def, installation, workflowId, event?, record?, manifests, fixtures? })` | Dry run: `{ status, sends, calls, trace, waiting? }`. Each call is `{ stepId, module, capability, kind, args, output, rendered }`; `rendered` is `{ html, slack? }` for writes (a Slack post renders as the message, anything else as a "would call" card) |
158
+ | `recordingPorts({ def, manifests, fixtures })` | Ports that record and answer instead of calling an API; give them to `previewSurface` for sample data |
159
+ | `viewToSlack`, `viewToHubSpot`, `viewToHtml`, `slackMessageToHtml` | The renderers on their own. `decodeAction(value)` reads a Slack button click back to `{ integrationId?, workflow, surface }` |
160
+
161
+ Dry-run rules: nothing is performed (the base ports' API function throws, and the recorder sits in front of it).
162
+ `fixtures` answers calls, keyed `"<module key>.<capability>"` (a value, or `(args) => value`; `code:<ref>` for code
163
+ steps, which are never run), otherwise the manifest's own record shape with ids filled. A webhook workflow with no
164
+ `event` runs on the manifest's sample payload. A pausing step ends the preview with `waiting`.
165
+
166
+ Everything that is record data is escaped for its target (mrkdwn `& < >` plus fenced `* _ ~`, HTML, text children for
167
+ HubSpot), links are http(s) only, Block Kit limits are met by truncating with a marker (50 blocks, 3000/2000/150
168
+ characters, 25 buttons), and nothing throws on an odd tree. Text a *definition* writes into a Slack message (templates)
169
+ is sent as authored: a preview shows it as sent, including any raw record data a template interpolates.
170
+
147
171
  ## Syncs
148
172
 
149
173
  `sync-engine.js` runs `syncs`: backfill (a button or `onInstall`, one queued page per message, progress at
@@ -207,14 +231,14 @@ they were routed under and finish on it.
207
231
  ## Running the tests
208
232
 
209
233
  ```bash
210
- npx jest --config '{}' --rootDir packages/core/integrations/data-defined tests
234
+ npx jest --config '{}' --rootDir packages/core/integrations/definitions tests
211
235
  ```
212
236
 
213
237
  `tests/persistence.test.js` runs the repositories and the publish rules against real databases. Each leg runs only
214
238
  when its URL is set. Point them at a migrated PostgreSQL database and a MongoDB replica set with the schema pushed:
215
239
 
216
240
  ```bash
217
- DATA_DEFINED_POSTGRES_URL=postgresql://… DATA_DEFINED_MONGO_URL=mongodb://… npx jest … tests
241
+ INTEGRATION_DEFINITIONS_POSTGRES_URL=postgresql://… INTEGRATION_DEFINITIONS_MONGO_URL=mongodb://… npx jest … tests
218
242
  ```
219
243
 
220
244
  ## Validating
@@ -227,14 +251,20 @@ Validation is two layers, and a document is valid only when both pass (`schema-c
227
251
 
228
252
  ```bash
229
253
  npm run validate:definitions --workspace @friggframework/core # bundled manifests + examples
230
- node packages/core/integrations/data-defined/scripts/validate.js my.definition.json --strict
231
- node packages/core/integrations/data-defined/scripts/validate.js --manifests ./capabilities --json defs/
254
+ node packages/core/integrations/definitions/scripts/validate.js my.definition.json --strict
255
+ node packages/core/integrations/definitions/scripts/validate.js --manifests ./capabilities --json defs/
232
256
  ```
233
257
 
234
258
  Exit codes: `0` valid, `1` invalid (or a warning with `--strict`), `2` could not run (unreadable JSON, missing file,
235
259
  unknown option, `ajv` not installed). Manifests are checked first and an invalid manifest fails the run, because a
236
260
  definition is only as trustworthy as the manifests it is checked against.
237
261
 
262
+ A manifest is only as real as its methods. `scripts/check-manifests.js <modules-dir>...` loads each module's Api class
263
+ (no network, nothing instantiated) and checks that every capability's `method` exists and is called the way it takes its
264
+ arguments (`args`: positional inputs, `"$rest"`, or a `{ "value" }` constant; no `args` means one object of all inputs).
265
+ A capability the real Api lacks is marked `"status": "unimplemented"` with a `note`: a definition that uses it validates
266
+ with a warning, not an error. `capabilities/AUDIT.md` has the table.
267
+
238
268
  `ajv` comes from the monorepo root (`@friggframework/schemas` depends on it); core's runtime stays dependency-free and
239
269
  loads it only for validation. `tests/schemas.test.js` runs both layers over every example and manifest and drives the
240
270
  CLI as a child process; it fails, rather than skips, if `ajv` is missing. Core's `npm test`, and so CI's