{"id":19623635,"url":"https://github.com/flowcore-io/library-sdk-transformer-core-ts","last_synced_at":"2026-03-05T23:15:13.636Z","repository":{"id":258317371,"uuid":"807640007","full_name":"flowcore-io/library-sdk-transformer-core-ts","owner":"flowcore-io","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-03T12:42:46.000Z","size":518,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-23T03:39:20.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flowcore-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-29T13:42:33.000Z","updated_at":"2025-06-03T12:42:17.000Z","dependencies_parsed_at":"2025-01-27T19:27:58.533Z","dependency_job_id":"098b9732-53f6-4892-adb6-d2bf6ee68ae5","html_url":"https://github.com/flowcore-io/library-sdk-transformer-core-ts","commit_stats":null,"previous_names":["flowcore-io/library-sdk-transformer-core-ts"],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/flowcore-io/library-sdk-transformer-core-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowcore-io%2Flibrary-sdk-transformer-core-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowcore-io%2Flibrary-sdk-transformer-core-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowcore-io%2Flibrary-sdk-transformer-core-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowcore-io%2Flibrary-sdk-transformer-core-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flowcore-io","download_url":"https://codeload.github.com/flowcore-io/library-sdk-transformer-core-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flowcore-io%2Flibrary-sdk-transformer-core-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021331,"owners_count":26087018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:34:58.914Z","updated_at":"2025-10-14T21:07:32.890Z","avatar_url":"https://github.com/flowcore-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sdk-transformer-core\n\nA core library that facilitates writing transformers and business logic services that utilise the flowcore paradigm\n\n## Installation\n\ninstall with npm:\n\n```bash\nnpm install @flowcore/refine-data-provider\n```\n\nor yarn:\n\n```bash\nyarn add @flowcore/refine-data-provider\n```\n\n## Usage\n\n## Development\n\n```bash\nyarn install\n```\n\nor with npm:\n\n```bash\nnpm install\n```\n\n### Transformer builder\n#### Usage exampe\n```ts\nnew TransformerBuilder(\"flow-type.0\")\n    .withSecret(\"SUPER_SECRET_STRING\")\n    // Execute after succsessfully handling and responding to an event\n    .withSuccessHandler(async (event: FlowcoreEvent) =\u003e {\n        // Handle success\n    })\n    .onEventType(\n        \"event-type.0\",\n        EventTypePayloadSchema,\n        async (event: FlowcoreEvent, payload: Static\u003ctypeof EventTypePayloadSchema\u003e) =\u003e {\n            // Handle event\n        }\n    )\n    // ... (add more onEventType)\n    // Get a generic handler method\n    .getHandler()\n    // Returns\n    // (event: unknown, secret?: string) =\u003e Promise\u003c{status: \"ok\" | \"error\", statusCode: number, message?: string, errors?: Record\u003cstring, string\u003e}\u003e\n\n// You can extend the builder to build for specific routers\n\n// Elysia example\nexport class ElysiaTransformerBuilder extends TransformerBuilder {\n  public getRouter() {\n    return new Elysia().post(\n      `/${this.flowType}`,\n      async ({ body, headers, set }) =\u003e {\n        const response = await this.handleEvent(body, headers[\"x-secret\"])\n        set.status = response.statusCode\n        return response\n      },\n      {\n        body: FlowcoreEventSchema,\n        headers: TransformerHeadersSchema,\n        response: TransformerResponseSchema,\n      },\n    )\n  }\n}\n\n```\n### Webhook builder\n#### Usage example\n```ts\nconst webhookFactory = new WebhookBuilder({\n  // Base URL of webhook ingestion (default: \"https://webhook.api.flowcore.io\")\n  baseUrl: \"https://webhook.api.flowcore.io\",\n  // Required: flowcore tenant name\n  tenant: \"tenant\",\n  // Required: data core name or uuid\n  dataCore: \"data-core\",\n  // Required: flowcore api key\n  apiKey: \"00000000-0000-0000-0000-000000000000\",\n})\n    // Will attempt X times to send webhook if it fails with a retryable status code\n    // Retryable status codes are: 408, 429, 500, 502, 503, 504\n    .withRetry({\n        // Maximum number of attempts (default: 1)\n        maxAttempts: 1,\n        // Delay between attempts (default: 250)\n        attemptDelayMs: 250,\n        // Can also be a backoff method\n        // attemptDelayMs: (attempt: number) =\u003e number\n    })\n    // Will do a predicate check after event is sent\n    .withPredicate({\n        // Predicate method: (eventId: string) =\u003e Promise\u003cboolean\u003e | boolean\n        predicate: (eventId: string) =\u003e checkEventId(eventId)\n        // Predicate options\n        options: {\n            // Maximum number of predicate attempts\n            maxAttempts: 8,\n            // Delay betweeen predicate attempts\n            attemptDelayMs: 250,\n            // Can also be a backoff method\n            // attemptDelayMs: (attempt: number) =\u003e number\n        }\n    })\n    // Build webhook method\n    .buildWebhook\u003cEventPayload extends Record\u003cstring, unknown\u003e, MetaData extends Record\u003cstring, unknown\u003e\u003e(\"flow-type.0\", \"event-type.0\")\n    // Returns\n    //{\n    //    send: (payload: EventPayload, metadata?: MetaData, options?: WebhookSendOptions) =\u003e Promise\u003cstring\u003e,\n    //    sendBatch: (payload: EventPayload[], metadata?: MetaData, options?: WebhookSendBatchOptions) =\u003e Promise\u003cstring\u003e,\n    //}\n    .buildFileWebhook\u003cMetaData extends Record\u003cstring, unknown\u003e\u003e(\"flow-type.0\", \"event-type.0\")\n    // Returns\n    //{\n    //    send: (payload: FilePayload, metadata?: MetaData, options?: WebhookSendOptions) =\u003e Promise\u003cstring\u003e,\n    //}\n    // Can also be used as a factory\n    .factory()\n    // Returns a method that returns a new instance of WebhookBuilder with current options\n    // () =\u003e WebhookBuilder\n```\n### Returns and Exception handling\n`webhook.send` returns a single eventId (`string`)\n`webhook.sendBatch` and `fileWebhook.send` return an array of eventIds (`string[]`)\n\nWhen send methods fail you can get these exceptions\n`WebhookSendError {message: string, response?: unknown, exception?: Error}`\n- `response` is the return from the webhook endpoint (send failed on webhook endpoint)\n- `exception` is the locally thrown exception (send failed locally with an exception)\n\n`WebhookPredicateError` {message: string, eventIds: string[], exception?: Error}`\n- `eventIds` the event ids returned from the webhook endpoint\n- `exception` is the locally thrown exception (predicate failed with exception)\n\n`Error`\n- Whoopsy... uncaught exception\n### Metadata factory\n```ts\nconst webhookWithMetadata = metadataWebhook({\n  userId: \"123\",\n})\n\n// Will inject metadata into the sent event\nconst eventId: string = await webhookWithMetadata(webhook.send, {foo: \"bar\"})\n// Will inject metadata into the sent events\nconst eventIds: string[] = await webhookWithMetadata(webhook.sendBatch, {foo: \"bar\"})\n// Will inject metadata into the sent event\nconst eventIds: string[] = await webhookWithMetadata(fileWebhook.send, {foo: \"bar\"})\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowcore-io%2Flibrary-sdk-transformer-core-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflowcore-io%2Flibrary-sdk-transformer-core-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowcore-io%2Flibrary-sdk-transformer-core-ts/lists"}