Add connector protocols with authentication, sync, webhooks, and templates#377
Add connector protocols with authentication, sync, webhooks, and templates#377
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…lates Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot AI Prompt Title: Refactor Connector Protocols to new integration directory Body:Refactor the changes in this PR to move all Connector-related definitions out of the system directory and into a new top-level directory named integration. The current placement in system is overcrowding that namespace. Requirements:
• Create a new directory: packages/spec/src/integration.
• Move packages/spec/src/system/connector.zod.ts (and any related files like authentication, sync configuration, rate limiting schemas) to packages/spec/src/integration/. • Rename/Structure them appropriately (e.g., packages/spec/src/integration/connector.zod.ts).
• Move all specific connector templates (SaaS, Database, File Storage, Message Queue) into the new packages/spec/src/integration directory. • You may organize them into a subdirectory if appropriate, e.g., packages/spec/src/integration/templates/.
• Update packages/spec/src/index.ts to export the definitions from the new integration directory instead of system. • Ensure there are no lingering imports referencing the old system paths for these files.
• Remove the connector-related files from packages/spec/src/system to ensure the directory remains focused on system-level configurations only. Goal: Establish integration as the dedicated namespace for all external system connection protocols. |
…ectory Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Title: Refactor Connector Protocols to new integration directory Body:Refactor the changes in this PR to move all Connector-related definitions out of the system directory and int... Completed the refactoring. All connector protocols have been moved to the new Changes made:
Verification:
The Commit: 95a23eb |
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
| import { | ||
| // Authentication Schemas | ||
| ApiKeyAuthSchema, | ||
| OAuth2AuthSchema, | ||
| JwtAuthSchema, | ||
| SamlAuthSchema, | ||
| BasicAuthSchema, | ||
| BearerTokenAuthSchema, | ||
| NoAuthSchema, | ||
| AuthenticationSchema, | ||
|
|
||
| // Field Mapping | ||
| FieldMappingSchema, | ||
| FieldTransformSchema, | ||
|
|
||
| // Data Sync | ||
| DataSyncConfigSchema, | ||
| SyncStrategySchema, | ||
| ConflictResolutionSchema, | ||
|
|
||
| // Webhook | ||
| WebhookConfigSchema, | ||
| WebhookEventSchema, | ||
|
|
||
| // Rate Limiting & Retry | ||
| RateLimitConfigSchema, | ||
| RetryConfigSchema, | ||
|
|
||
| // Base Connector | ||
| ConnectorSchema, | ||
| ConnectorTypeSchema, | ||
| ConnectorStatusSchema, | ||
|
|
||
| // Types | ||
| type Connector, | ||
| type ApiKeyAuth, | ||
| type OAuth2Auth, | ||
| type FieldMapping, | ||
| type DataSyncConfig, | ||
| type WebhookConfig, | ||
| } from './connector.zod'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
In general, to fix "unused import" issues, you remove the specific imported symbols that are never referenced in the file, leaving the rest of the import statement intact. This improves readability and avoids misleading future maintainers into thinking those items are tested or needed here.
For this file, the best fix is to edit the import block on lines 2–42 of packages/spec/src/integration/connector.test.ts and delete only the unused names: NoAuthSchema, FieldTransformSchema, SyncStrategySchema, ConflictResolutionSchema, WebhookEventSchema, BasicAuthSchema, and BearerTokenAuthSchema. We will keep all imports that are evidently used or could reasonably be used in the shown tests: ApiKeyAuthSchema, OAuth2AuthSchema, JwtAuthSchema, SamlAuthSchema, FieldMappingSchema, DataSyncConfigSchema, RateLimitConfigSchema, RetryConfigSchema, ConnectorSchema, ConnectorTypeSchema, ConnectorStatusSchema, and the imported types Connector, ApiKeyAuth, OAuth2Auth, FieldMapping, DataSyncConfig, WebhookConfig.
No new methods, definitions, or imports are required; we’re only trimming the existing import list.
| @@ -5,23 +5,16 @@ | ||
| OAuth2AuthSchema, | ||
| JwtAuthSchema, | ||
| SamlAuthSchema, | ||
| BasicAuthSchema, | ||
| BearerTokenAuthSchema, | ||
| NoAuthSchema, | ||
| AuthenticationSchema, | ||
|
|
||
| // Field Mapping | ||
| FieldMappingSchema, | ||
| FieldTransformSchema, | ||
|
|
||
| // Data Sync | ||
| DataSyncConfigSchema, | ||
| SyncStrategySchema, | ||
| ConflictResolutionSchema, | ||
|
|
||
| // Webhook | ||
| WebhookConfigSchema, | ||
| WebhookEventSchema, | ||
|
|
||
| // Rate Limiting & Retry | ||
| RateLimitConfigSchema, |
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive connector protocols for external system integration to ObjectStack. It introduces a new integration namespace containing authentication methods, data synchronization, field mapping, webhooks, and specialized connector templates for SaaS, databases, file storage, and message queues.
Changes:
- Creates new
integrationnamespace with core connector protocol (connector.zod.ts) - Adds 4 specialized connector templates (SaaS, Database, File Storage, Message Queue)
- Implements comprehensive authentication schemas (OAuth2, JWT, SAML, API Key, Basic, Bearer, None)
- Provides data sync configuration with conflict resolution and field mapping
- Includes webhook configuration with HMAC verification and retry logic
- Generates 60+ JSON schemas for IDE autocomplete
- Adds comprehensive test coverage (
connector.test.tswith 624 lines) - Updates documentation and exports
Reviewed changes
Copilot reviewed 68 out of 68 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/spec/src/integration/connector.zod.ts |
Core connector protocol with authentication, sync, webhooks, rate limiting |
packages/spec/src/integration/connector/saas.zod.ts |
SaaS connector template (Salesforce, HubSpot, etc.) |
packages/spec/src/integration/connector/database.zod.ts |
Database connector template with CDC support |
packages/spec/src/integration/connector/file-storage.zod.ts |
File storage connector (S3, Azure Blob, Google Drive) |
packages/spec/src/integration/connector/message-queue.zod.ts |
Message queue connector (Kafka, RabbitMQ, SQS) |
packages/spec/src/integration/connector.test.ts |
Comprehensive test suite covering all schemas |
packages/spec/src/integration/index.ts |
Integration namespace exports |
packages/spec/src/index.ts |
Adds Integration namespace to main exports |
packages/spec/src/system/index.ts |
Documents connector protocol moved to integration |
content/docs/references/integration/* |
Documentation for connector schemas |
packages/spec/json-schema/integration/* |
Auto-generated JSON schemas (60+ files) |
| export const ConflictResolutionSchema = z.enum([ | ||
| 'source_wins', // External system data takes precedence | ||
| 'target_wins', // ObjectStack data takes precedence | ||
| 'latest_wins', // Most recently modified wins | ||
| 'manual', // Flag for manual resolution | ||
| ]).describe('Conflict resolution strategy'); |
There was a problem hiding this comment.
Duplicate schema definition: ConflictResolutionSchema is already defined in packages/spec/src/automation/sync.zod.ts (lines 82-88). The automation version includes a 'merge' option that this integration version lacks. This duplication will lead to maintainability issues and inconsistencies. Consider consolidating these into a shared schema or importing from automation if they serve the same purpose.
| | **certificate** | `string` | ✅ | SAML IdP certificate (X.509) | | ||
| | **privateKey** | `string` | optional | SAML service provider private key | | ||
| | **callbackUrl** | `string` | optional | SAML assertion consumer service URL | | ||
| | **signatureAlgorithm** | `Enum<'sha1' \| 'sha256' \| 'sha512'>` | optional | SAML signature algorithm | |
There was a problem hiding this comment.
The SAML signatureAlgorithm property permits the weak sha1 option, which is considered cryptographically broken for signatures and can enable forging SAML assertions in realistic attack scenarios. An attacker who can influence or exploit SHA‑1 collisions could bypass SSO/authentication guarantees if SAML messages are signed with SHA‑1. Restrict this field to modern algorithms like sha256/sha512 (with a secure default) and deprecate or remove sha1 support to avoid relying on a broken primitive.
| | **signatureAlgorithm** | `Enum<'sha1' \| 'sha256' \| 'sha512'>` | optional | SAML signature algorithm | | |
| | **signatureAlgorithm** | `Enum<'sha256' \| 'sha512'>` | optional | SAML signature algorithm | |
Implements external system integration protocols with comprehensive authentication, data synchronization, and connector templates for SaaS, databases, file storage, and message queues.
Core Protocol (
integration/connector.zod.ts)Authentication - Discriminated union supporting:
Data Sync - Bidirectional with conflict resolution:
full,incremental,upsert,append_onlysource_wins,target_wins,latest_wins,manualField Mapping - Source → target with transformations:
Webhooks - Event-driven with HMAC verification:
record.created,record.updated,sync.completed, etc.Rate Limiting - Multiple strategies:
token_bucket,sliding_window,fixed_window,leaky_bucketConnector Templates
SaaS (
integration/connector/saas.zod.ts):Database (
integration/connector/database.zod.ts):File Storage (
integration/connector/file-storage.zod.ts):Message Queue (
integration/connector/message-queue.zod.ts):Schema Generation
60+ JSON schemas auto-generated for IDE autocomplete and validation. All schemas follow
camelCasefor config keys,snake_casefor machine names per ObjectStack conventions.Directory Structure
All connector protocols are organized in the dedicated
integrationnamespace:packages/spec/src/integration/@objectstack/spec/integrationorIntegrationnamespacesystemdirectory focused on core system-level configurationsThe
integrationnamespace is established as the dedicated location for all external system connection protocols, separate from automation workflows and system configuration.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.