From edf7c231627d7f378675a4392ee693e0f962627f Mon Sep 17 00:00:00 2001 From: Richard Fontein <32132657+rifont@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:21:50 +0100 Subject: [PATCH] refactor(framework): Move API servers into collective folder (#5995) * refactor: Reorganize server-related files and imports * refactor(constants): rename NOVU_FRAMEWORK_API to SERVER * refactor(version): move version constants to separate file * refactor: Reorganize workflow resource imports * refactor(test): refactor action strings to enums * refactor(constants): rename and update cron types path * refactor: Replace strings with ChannelStepEnum keys * fix(api): correct subpath import in echo.server.ts --- apps/api/e2e/echo.server.ts | 2 +- packages/framework/package.json | 36 +++++++++---------- packages/framework/src/client.test.ts | 36 +++++++++---------- packages/framework/src/client.ts | 3 +- .../framework/src/client.validation.test.ts | 2 +- .../cron.constants.ts} | 0 .../src/constants/http-headers.constants.ts | 2 +- packages/framework/src/constants/index.ts | 2 ++ .../src/constants/version.constants.ts | 4 +++ .../src/{ => constants}/version.test.ts | 4 +-- packages/framework/src/handler.ts | 11 +++--- packages/framework/src/index.ts | 4 +-- packages/framework/src/resources/index.ts | 1 + .../src/{ => resources}/workflow.test.ts | 2 +- .../framework/src/{ => resources}/workflow.ts | 18 ++++++---- .../framework/src/schemas/providers/index.ts | 10 +++--- .../framework/src/{ => servers}/express.ts | 6 ++-- packages/framework/src/{ => servers}/h3.ts | 4 +-- packages/framework/src/{ => servers}/next.ts | 8 ++--- packages/framework/src/{ => servers}/nuxt.ts | 4 +-- packages/framework/src/{ => servers}/remix.ts | 6 ++-- .../framework/src/{ => servers}/sveltekit.ts | 6 ++-- packages/framework/src/types/index.ts | 3 +- .../{framework.types.ts => server.types.ts} | 0 packages/framework/src/types/step.types.ts | 4 +-- .../framework/src/types/workflow.types.ts | 3 +- packages/framework/src/version.ts | 4 --- packages/framework/tsup.config.ts | 2 +- 28 files changed, 97 insertions(+), 90 deletions(-) rename packages/framework/src/{types/cron.types.ts => constants/cron.constants.ts} (100%) create mode 100644 packages/framework/src/constants/version.constants.ts rename packages/framework/src/{ => constants}/version.test.ts (65%) create mode 100644 packages/framework/src/resources/index.ts rename packages/framework/src/{ => resources}/workflow.test.ts (99%) rename packages/framework/src/{ => resources}/workflow.ts (96%) rename packages/framework/src/{ => servers}/express.ts (93%) rename packages/framework/src/{ => servers}/h3.ts (92%) rename packages/framework/src/{ => servers}/next.ts (97%) rename packages/framework/src/{ => servers}/nuxt.ts (89%) rename packages/framework/src/{ => servers}/remix.ts (90%) rename packages/framework/src/{ => servers}/sveltekit.ts (92%) rename packages/framework/src/types/{framework.types.ts => server.types.ts} (100%) delete mode 100644 packages/framework/src/version.ts diff --git a/apps/api/e2e/echo.server.ts b/apps/api/e2e/echo.server.ts index 983200348da..de63f1f8414 100644 --- a/apps/api/e2e/echo.server.ts +++ b/apps/api/e2e/echo.server.ts @@ -1,7 +1,7 @@ import * as http from 'http'; import * as express from 'express'; // FIXME: subpath import not working with `workspace:` protocol. Currently we need to drill into the module instead of using the ES export. -import { serve } from '../../../packages/framework/dist/express'; +import { serve } from '../../../packages/framework/dist/servers/express'; import { Client, Workflow } from '@novu/framework'; export type ServerStartOptions = { diff --git a/packages/framework/package.json b/packages/framework/package.json index b126d4d9f55..d2ae95dc893 100644 --- a/packages/framework/package.json +++ b/packages/framework/package.json @@ -56,34 +56,34 @@ "types": "./dist/index.d.ts" }, "./express": { - "require": "./dist/express.js", - "import": "./dist/express.js", - "types": "./dist/express.d.ts" + "require": "./dist/servers/express.js", + "import": "./dist/servers/express.js", + "types": "./dist/servers/express.d.ts" }, "./next": { - "require": "./dist/next.js", - "import": "./dist/next.js", - "types": "./dist/next.d.ts" + "require": "./dist/servers/next.js", + "import": "./dist/servers/next.js", + "types": "./dist/servers/next.d.ts" }, "./nuxt": { - "require": "./dist/nuxt.js", - "import": "./dist/nuxt.js", - "types": "./dist/nuxt.d.ts" + "require": "./dist/servers/nuxt.js", + "import": "./dist/servers/nuxt.js", + "types": "./dist/servers/nuxt.d.ts" }, "./h3": { - "require": "./dist/h3.js", - "import": "./dist/h3.js", - "types": "./dist/h3.d.ts" + "require": "./dist/servers/h3.js", + "import": "./dist/servers/h3.js", + "types": "./dist/servers/h3.d.ts" }, "./sveltekit": { - "require": "./dist/sveltekit.js", - "import": "./dist/sveltekit.js", - "types": "./dist/sveltekit.d.ts" + "require": "./dist/servers/sveltekit.js", + "import": "./dist/servers/sveltekit.js", + "types": "./dist/servers/sveltekit.d.ts" }, "./remix": { - "require": "./dist/remix.js", - "import": "./dist/remix.js", - "types": "./dist/remix.d.ts" + "require": "./dist/servers/remix.js", + "import": "./dist/servers/remix.js", + "types": "./dist/servers/remix.d.ts" } }, "peerDependencies": { diff --git a/packages/framework/src/client.test.ts b/packages/framework/src/client.test.ts index 0280e5e8f1a..9d9764d2c1b 100644 --- a/packages/framework/src/client.test.ts +++ b/packages/framework/src/client.test.ts @@ -7,12 +7,10 @@ import { StepNotFoundError, WorkflowNotFoundError, } from './errors'; -import { workflow } from './workflow'; -import { Event, Step } from './types'; -import { delayOutputSchema } from './schemas'; -import { emailChannelSchemas } from './schemas/steps/channels/email.schema'; -import { FromSchema } from './types/schema.types'; -import { FRAMEWORK_VERSION, SDK_VERSION } from './version'; +import { workflow } from './resources'; +import { Event, Step, FromSchema } from './types'; +import { delayOutputSchema, channelStepSchemas } from './schemas'; +import { FRAMEWORK_VERSION, SDK_VERSION, ChannelStepEnum, PostActionEnum } from './constants'; describe('Novu Client', () => { let client: Client; @@ -341,7 +339,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const emailEvent: Event = { - action: 'preview', + action: PostActionEnum.PREVIEW, data: { name: 'John' }, payload: { name: 'John' }, workflowId: 'test-workflow', @@ -367,7 +365,7 @@ describe('Novu Client', () => { describe('executeWorkflow method', () => { it('should execute workflow successfully when action is execute and payload is provided', async () => { const delayConfiguration: FromSchema = { type: 'regular', unit: 'seconds', amount: 1 }; - const emailConfiguration: FromSchema = { + const emailConfiguration: FromSchema<(typeof channelStepSchemas)[ChannelStepEnum.EMAIL]['output']> = { body: 'Test Body', subject: 'Subject', }; @@ -377,7 +375,7 @@ describe('Novu Client', () => { }); const emailEvent: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, data: {}, payload: {}, workflowId: 'test-workflow', @@ -406,7 +404,7 @@ describe('Novu Client', () => { expect(metadata.duration).toEqual(expect.any(Number)); const delayEvent: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, data: {}, payload: {}, workflowId: 'test-workflow', @@ -489,7 +487,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const emailEvent: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, data: { role: 'product manager', elements: ['cat', 'dog'] }, payload: { role: 'product manager', elements: ['cat', 'dog'] }, workflowId: 'test-workflow', @@ -522,7 +520,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const event: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, workflowId: 'test-workflow', stepId: 'send-email', subscriber: {}, @@ -558,7 +556,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const event: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, workflowId: 'test-workflow', stepId: 'send-email', subscriber: {}, @@ -597,7 +595,7 @@ describe('Novu Client', () => { client.addWorkflows([workflowMock]); const event: Event = { - action: 'preview', + action: PostActionEnum.PREVIEW, workflowId: 'mock-workflow', stepId: 'send-email', subscriber: {}, @@ -623,7 +621,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const event: Event = { - action: 'preview', + action: PostActionEnum.PREVIEW, workflowId: 'test-workflow', stepId: 'send-email', subscriber: {}, @@ -664,7 +662,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const event: Event = { - action: 'preview', + action: PostActionEnum.PREVIEW, workflowId: 'test-workflow', stepId: 'send-email', subscriber: {}, @@ -698,7 +696,7 @@ describe('Novu Client', () => { it('should throw an error when workflow ID is invalid', async () => { // non-existing workflow ID const event: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, workflowId: 'non-existent-workflow', stepId: 'send-email', subscriber: {}, @@ -719,7 +717,7 @@ describe('Novu Client', () => { // no workflow ID const event2 = { - action: 'execute', + action: PostActionEnum.EXECUTE, stepId: 'send-email', subscriber: {}, state: [], @@ -735,7 +733,7 @@ describe('Novu Client', () => { client.addWorkflows([newWorkflow]); const event: Event = { - action: 'execute', + action: PostActionEnum.EXECUTE, workflowId: 'test-workflow', stepId: 'non-existing-step', subscriber: {}, diff --git a/packages/framework/src/client.ts b/packages/framework/src/client.ts index 0c1c97a1d3d..0585e8dda69 100644 --- a/packages/framework/src/client.ts +++ b/packages/framework/src/client.ts @@ -1,8 +1,8 @@ import { JSONSchemaFaker } from 'json-schema-faker'; import { Liquid } from 'liquidjs'; import ora from 'ora'; -import { PostActionEnum } from './constants'; +import { FRAMEWORK_VERSION, PostActionEnum, SDK_VERSION } from './constants'; import { ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, @@ -35,7 +35,6 @@ import type { } from './types'; import { EMOJI, log } from './utils'; import { transformSchema, validateData } from './validators'; -import { FRAMEWORK_VERSION, SDK_VERSION } from './version'; /** * We want to respond with a consistent string value for preview diff --git a/packages/framework/src/client.validation.test.ts b/packages/framework/src/client.validation.test.ts index 53e52a15cf5..1def731cb29 100644 --- a/packages/framework/src/client.validation.test.ts +++ b/packages/framework/src/client.validation.test.ts @@ -1,7 +1,7 @@ import { expect, it, describe, beforeEach } from 'vitest'; import { Client } from './client'; import { z } from 'zod'; -import { workflow } from './workflow'; +import { workflow } from './resources/workflow'; import { ExecutionStateControlsInvalidError } from './errors'; describe('validation', () => { diff --git a/packages/framework/src/types/cron.types.ts b/packages/framework/src/constants/cron.constants.ts similarity index 100% rename from packages/framework/src/types/cron.types.ts rename to packages/framework/src/constants/cron.constants.ts diff --git a/packages/framework/src/constants/http-headers.constants.ts b/packages/framework/src/constants/http-headers.constants.ts index 461473cd27c..c62f2ca0215 100644 --- a/packages/framework/src/constants/http-headers.constants.ts +++ b/packages/framework/src/constants/http-headers.constants.ts @@ -4,7 +4,7 @@ export enum HttpHeaderKeysEnum { NOVU_SIGNATURE_DEPRECATED = 'x-novu-signature', NOVU_ANONYMOUS_DEPRECATED = 'x-novu-anonymous', NOVU_FRAMEWORK_SDK = 'novu-framework-sdk', - NOVU_FRAMEWORK_API = 'novu-framework-api', + NOVU_FRAMEWORK_SERVER = 'novu-framework-server', NOVU_FRAMEWORK_VERSION = 'novu-framework-version', USER_AGENT = 'user-agent', CONTENT_TYPE = 'content-type', diff --git a/packages/framework/src/constants/index.ts b/packages/framework/src/constants/index.ts index 640976489e7..68c24064074 100644 --- a/packages/framework/src/constants/index.ts +++ b/packages/framework/src/constants/index.ts @@ -1,5 +1,6 @@ export * from './action.constants'; export * from './api.constants'; +export * from './cron.constants'; export * from './error.constants'; export * from './http-headers.constants'; export * from './http-methods.constants'; @@ -7,3 +8,4 @@ export * from './http-query.constants'; export * from './http-status.constants'; export * from './resource.constants'; export * from './step.constants'; +export * from './version.constants'; diff --git a/packages/framework/src/constants/version.constants.ts b/packages/framework/src/constants/version.constants.ts new file mode 100644 index 00000000000..0be60af2808 --- /dev/null +++ b/packages/framework/src/constants/version.constants.ts @@ -0,0 +1,4 @@ +import { version } from '../../package.json'; + +export const SDK_VERSION = version; +export const FRAMEWORK_VERSION = '2024-06-26'; diff --git a/packages/framework/src/version.test.ts b/packages/framework/src/constants/version.test.ts similarity index 65% rename from packages/framework/src/version.test.ts rename to packages/framework/src/constants/version.test.ts index 47e6efd1736..b28984f1517 100644 --- a/packages/framework/src/version.test.ts +++ b/packages/framework/src/constants/version.test.ts @@ -1,10 +1,10 @@ import { expect, test, describe } from 'vitest'; -import { SDK_VERSION } from './version'; +import { SDK_VERSION } from './version.constants'; describe('version', () => { test('should export the current version', () => { const importVersion = SDK_VERSION; - const packageJsonVersion = require('../package.json').version; + const packageJsonVersion = require('../../package.json').version; expect(importVersion).toEqual(packageJsonVersion); }); }); diff --git a/packages/framework/src/handler.ts b/packages/framework/src/handler.ts index c3f01f8c809..eae38cd92f7 100644 --- a/packages/framework/src/handler.ts +++ b/packages/framework/src/handler.ts @@ -3,29 +3,30 @@ import { createHmac } from 'node:crypto'; import { Client } from './client'; import { ErrorCodeEnum, + FRAMEWORK_VERSION, GetActionEnum, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, PostActionEnum, + SDK_VERSION, SIGNATURE_TIMESTAMP_TOLERANCE, } from './constants'; import { + BridgeError, + FrameworkError, InvalidActionError, MethodNotAllowedError, - FrameworkError, - BridgeError, + PlatformError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SigningKeyNotFoundError, - PlatformError, } from './errors'; import type { Awaitable, EventTriggerParams, Workflow } from './types'; import { initApiClient } from './utils'; -import { FRAMEWORK_VERSION, SDK_VERSION } from './version'; // eslint-disable-next-line @typescript-eslint/naming-convention export type ServeHandlerOptions = { @@ -97,7 +98,7 @@ export class NovuRequestHandler { [HttpHeaderKeysEnum.ACCESS_CONTROL_MAX_AGE]: '604800', [HttpHeaderKeysEnum.NOVU_FRAMEWORK_VERSION]: FRAMEWORK_VERSION, [HttpHeaderKeysEnum.NOVU_FRAMEWORK_SDK]: SDK_VERSION, - [HttpHeaderKeysEnum.NOVU_FRAMEWORK_API]: this.frameworkName, + [HttpHeaderKeysEnum.NOVU_FRAMEWORK_SERVER]: this.frameworkName, [HttpHeaderKeysEnum.USER_AGENT]: sdkVersion, }; } diff --git a/packages/framework/src/index.ts b/packages/framework/src/index.ts index 788a9e58118..ad5ed866d5e 100644 --- a/packages/framework/src/index.ts +++ b/packages/framework/src/index.ts @@ -1,5 +1,5 @@ export { Client } from './client'; -export * from './types'; export * from './constants'; export { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -export { workflow } from './workflow'; +export * from './resources'; +export * from './types'; diff --git a/packages/framework/src/resources/index.ts b/packages/framework/src/resources/index.ts new file mode 100644 index 00000000000..da6b56629a2 --- /dev/null +++ b/packages/framework/src/resources/index.ts @@ -0,0 +1 @@ +export * from './workflow'; diff --git a/packages/framework/src/workflow.test.ts b/packages/framework/src/resources/workflow.test.ts similarity index 99% rename from packages/framework/src/workflow.test.ts rename to packages/framework/src/resources/workflow.test.ts index fdd5520c7d4..683e6a9eb01 100644 --- a/packages/framework/src/workflow.test.ts +++ b/packages/framework/src/resources/workflow.test.ts @@ -1,5 +1,5 @@ import { it, describe, beforeEach, expect, vi, afterEach } from 'vitest'; -import { MissingSecretKeyError } from './errors'; +import { MissingSecretKeyError } from '../errors'; import { workflow } from './workflow'; describe('workflow function', () => { diff --git a/packages/framework/src/workflow.ts b/packages/framework/src/resources/workflow.ts similarity index 96% rename from packages/framework/src/workflow.ts rename to packages/framework/src/resources/workflow.ts index c4f5f55141f..933b22a61c9 100644 --- a/packages/framework/src/workflow.ts +++ b/packages/framework/src/resources/workflow.ts @@ -1,6 +1,12 @@ -import { ChannelStepEnum } from './constants'; -import { MissingSecretKeyError, StepAlreadyExistsError, WorkflowPayloadInvalidError } from './errors'; -import { channelStepSchemas, delayChannelSchemas, digestChannelSchemas, emptySchema, providerSchemas } from './schemas'; +import { ChannelStepEnum } from '../constants'; +import { MissingSecretKeyError, StepAlreadyExistsError, WorkflowPayloadInvalidError } from '../errors'; +import { + channelStepSchemas, + delayChannelSchemas, + digestChannelSchemas, + emptySchema, + providerSchemas, +} from '../schemas'; import type { ActionStep, Awaitable, @@ -15,9 +21,9 @@ import type { EventTriggerResponse, Workflow, WorkflowOptions, -} from './types'; -import { EMOJI, getBridgeUrl, initApiClient, log } from './utils'; -import { transformSchema, validateData } from './validators'; +} from '../types'; +import { EMOJI, getBridgeUrl, initApiClient, log } from '../utils'; +import { transformSchema, validateData } from '../validators'; /** * Define a new notification workflow. diff --git a/packages/framework/src/schemas/providers/index.ts b/packages/framework/src/schemas/providers/index.ts index feec06b6b82..4b2bcc3de1d 100644 --- a/packages/framework/src/schemas/providers/index.ts +++ b/packages/framework/src/schemas/providers/index.ts @@ -31,9 +31,9 @@ type ProvidersSchemas = | SmsProvidersSchemas; export const providerSchemas = { - chat: chatProviderSchemas, - sms: smsProviderSchemas, - email: emailProviderSchemas, - push: pushProviderSchemas, - in_app: inAppProviderSchemas, + [ChannelStepEnum.CHAT]: chatProviderSchemas, + [ChannelStepEnum.SMS]: smsProviderSchemas, + [ChannelStepEnum.EMAIL]: emailProviderSchemas, + [ChannelStepEnum.PUSH]: pushProviderSchemas, + [ChannelStepEnum.IN_APP]: inAppProviderSchemas, } satisfies Record; diff --git a/packages/framework/src/express.ts b/packages/framework/src/servers/express.ts similarity index 93% rename from packages/framework/src/express.ts rename to packages/framework/src/servers/express.ts index ef08c6a9152..74b8e210f9b 100644 --- a/packages/framework/src/express.ts +++ b/packages/framework/src/servers/express.ts @@ -1,9 +1,9 @@ import { type VercelRequest, type VercelResponse } from '@vercel/node'; import { type Request, type Response } from 'express'; -import { NovuRequestHandler, ServeHandlerOptions } from './handler'; -import { Either } from './types'; -import { type SupportedFrameworkName } from './types'; +import { NovuRequestHandler, ServeHandlerOptions } from '../handler'; +import { Either } from '../types'; +import { type SupportedFrameworkName } from '../types'; export const frameworkName: SupportedFrameworkName = 'express'; diff --git a/packages/framework/src/h3.ts b/packages/framework/src/servers/h3.ts similarity index 92% rename from packages/framework/src/h3.ts rename to packages/framework/src/servers/h3.ts index 2793a635e5b..d8515f9a05d 100644 --- a/packages/framework/src/h3.ts +++ b/packages/framework/src/servers/h3.ts @@ -1,7 +1,7 @@ import { getHeader, getQuery, type H3Event, readBody, send, setHeaders, type EventHandlerRequest } from 'h3'; -import { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -import { type SupportedFrameworkName } from './types'; +import { NovuRequestHandler, type ServeHandlerOptions } from '../handler'; +import { type SupportedFrameworkName } from '../types'; export const frameworkName: SupportedFrameworkName = 'h3'; diff --git a/packages/framework/src/next.ts b/packages/framework/src/servers/next.ts similarity index 97% rename from packages/framework/src/next.ts rename to packages/framework/src/servers/next.ts index dfa35f9ca65..1266c63e12a 100644 --- a/packages/framework/src/next.ts +++ b/packages/framework/src/servers/next.ts @@ -1,10 +1,10 @@ import { type NextApiRequest, type NextApiResponse } from 'next'; import { type NextRequest } from 'next/server'; -import { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -import { type Either } from './types'; -import { type SupportedFrameworkName } from './types'; -import { getResponse } from './utils'; +import { NovuRequestHandler, type ServeHandlerOptions } from '../handler'; +import { type Either } from '../types'; +import { type SupportedFrameworkName } from '../types'; +import { getResponse } from '../utils'; export const frameworkName: SupportedFrameworkName = 'next'; diff --git a/packages/framework/src/nuxt.ts b/packages/framework/src/servers/nuxt.ts similarity index 89% rename from packages/framework/src/nuxt.ts rename to packages/framework/src/servers/nuxt.ts index dbb9a7499e9..e248879c4a9 100644 --- a/packages/framework/src/nuxt.ts +++ b/packages/framework/src/servers/nuxt.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line import/no-extraneous-dependencies import { getHeader, getQuery, H3Event, readBody, send, setHeaders } from 'h3'; -import { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -import { type SupportedFrameworkName } from './types'; +import { NovuRequestHandler, type ServeHandlerOptions } from '../handler'; +import { type SupportedFrameworkName } from '../types'; export const frameworkName: SupportedFrameworkName = 'nuxt'; diff --git a/packages/framework/src/remix.ts b/packages/framework/src/servers/remix.ts similarity index 90% rename from packages/framework/src/remix.ts rename to packages/framework/src/servers/remix.ts index 90e3336d1db..78c66dd0336 100644 --- a/packages/framework/src/remix.ts +++ b/packages/framework/src/servers/remix.ts @@ -1,6 +1,6 @@ -import { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -import { type SupportedFrameworkName } from './types'; -import { getResponse } from './utils'; +import { NovuRequestHandler, type ServeHandlerOptions } from '../handler'; +import { type SupportedFrameworkName } from '../types'; +import { getResponse } from '../utils'; export const frameworkName: SupportedFrameworkName = 'remix'; diff --git a/packages/framework/src/sveltekit.ts b/packages/framework/src/servers/sveltekit.ts similarity index 92% rename from packages/framework/src/sveltekit.ts rename to packages/framework/src/servers/sveltekit.ts index df4bedc19fe..8586f5e9449 100644 --- a/packages/framework/src/sveltekit.ts +++ b/packages/framework/src/servers/sveltekit.ts @@ -1,7 +1,7 @@ import { RequestEvent } from '@sveltejs/kit'; -import { NovuRequestHandler, type ServeHandlerOptions } from './handler'; -import { type SupportedFrameworkName } from './types'; -import { getResponse } from './utils'; +import { NovuRequestHandler, type ServeHandlerOptions } from '../handler'; +import { type SupportedFrameworkName } from '../types'; +import { getResponse } from '../utils'; export const frameworkName: SupportedFrameworkName = 'sveltekit'; diff --git a/packages/framework/src/types/index.ts b/packages/framework/src/types/index.ts index 10d9ae7059f..019f1f1c155 100644 --- a/packages/framework/src/types/index.ts +++ b/packages/framework/src/types/index.ts @@ -1,12 +1,11 @@ export * from './code.types'; export * from './config.types'; -export * from './cron.types'; export * from './discover.types'; export * from './event.types'; export * from './execution.types'; -export * from './framework.types'; export * from './health-check.types'; export * from './schema.types'; +export * from './server.types'; export * from './skip.types'; export * from './step.types'; export * from './subscriber.types'; diff --git a/packages/framework/src/types/framework.types.ts b/packages/framework/src/types/server.types.ts similarity index 100% rename from packages/framework/src/types/framework.types.ts rename to packages/framework/src/types/server.types.ts diff --git a/packages/framework/src/types/step.types.ts b/packages/framework/src/types/step.types.ts index 4a75b194114..2669b9c5893 100644 --- a/packages/framework/src/types/step.types.ts +++ b/packages/framework/src/types/step.types.ts @@ -12,7 +12,7 @@ import { channelStepSchemas } from '../schemas/steps/channels'; import type { Providers } from './provider.types'; import type { FromSchema, Schema } from './schema.types'; import type { Skip } from './skip.types'; -import type { Awaitable } from './util.types'; +import type { Awaitable, Prettify } from './util.types'; // @TODO: remove the credentials, providers, and preferences from the ActionStepOptions (fix the client typings) export type StepOptions = { @@ -212,7 +212,7 @@ export type ChannelStep< /** * The providers for the step. Used to override the behaviour of the providers for the step. */ - providers?: Providers; + providers?: Prettify>; /* * credentials?: (controls: T_Controls) => Promise>; * preferences?: (controls: T_Controls) => Promise>; diff --git a/packages/framework/src/types/workflow.types.ts b/packages/framework/src/types/workflow.types.ts index ffaad5ec442..085435b448f 100644 --- a/packages/framework/src/types/workflow.types.ts +++ b/packages/framework/src/types/workflow.types.ts @@ -1,5 +1,6 @@ import type { Step } from './step.types'; import type { Subscriber } from './subscriber.types'; +import type { Prettify } from './util.types'; /** * The parameters for the workflow function. @@ -10,7 +11,7 @@ export type ExecuteInput = { /** The payload for the event, provided during trigger. */ payload: T_Payload; /** The subscriber for the event, provided during trigger. */ - subscriber: Subscriber; + subscriber: Prettify; /** The environment the workflow is running in. */ environment: Record; /** diff --git a/packages/framework/src/version.ts b/packages/framework/src/version.ts deleted file mode 100644 index abbcc7a4a4f..00000000000 --- a/packages/framework/src/version.ts +++ /dev/null @@ -1,4 +0,0 @@ -import packageJson from '../package.json'; - -export const SDK_VERSION = packageJson.version; -export const FRAMEWORK_VERSION = '2024-06-26'; diff --git a/packages/framework/tsup.config.ts b/packages/framework/tsup.config.ts index 127dd0b2c63..abaad850f51 100644 --- a/packages/framework/tsup.config.ts +++ b/packages/framework/tsup.config.ts @@ -4,7 +4,7 @@ import { type SupportedFrameworkName } from './src'; const frameworks: SupportedFrameworkName[] = ['h3', 'express', 'next', 'nuxt', 'sveltekit', 'remix']; export default defineConfig({ - entry: ['src/index.ts', ...frameworks.map((framework) => `src/${framework}.ts`)], + entry: ['src/index.ts', ...frameworks.map((framework) => `src/servers/${framework}.ts`)], sourcemap: false, clean: true, treeshake: true,