@flowgram.ai/runtime-nodejs 0.2.16 → 0.2.18

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.
package/.eslintrc.cjs CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  const { defineConfig } = require('@flowgram.ai/eslint-config');
2
7
 
3
8
  module.exports = defineConfig({
@@ -10,12 +10,12 @@
10
10
  {"kind":"O","text":"\u001b[34mCJS\u001b[39m Build start\n"}
11
11
  {"kind":"O","text":"\u001b[34mESM\u001b[39m Build start\n"}
12
12
  {"kind":"O","text":"\u001b[32mCJS\u001b[39m \u001b[1mdist/index.js \u001b[22m\u001b[32m6.67 KB\u001b[39m\n"}
13
- {"kind":"O","text":"\u001b[32mCJS\u001b[39m \u001b[1mdist/index.js.map \u001b[22m\u001b[32m10.28 KB\u001b[39m\n"}
14
- {"kind":"O","text":"\u001b[32mCJS\u001b[39m ⚡️ Build success in 107ms\n"}
13
+ {"kind":"O","text":"\u001b[32mCJS\u001b[39m \u001b[1mdist/index.js.map \u001b[22m\u001b[32m11.10 KB\u001b[39m\n"}
14
+ {"kind":"O","text":"\u001b[32mCJS\u001b[39m ⚡️ Build success in 75ms\n"}
15
15
  {"kind":"O","text":"\u001b[32mESM\u001b[39m \u001b[1mdist/esm/index.js \u001b[22m\u001b[32m5.09 KB\u001b[39m\n"}
16
- {"kind":"O","text":"\u001b[32mESM\u001b[39m \u001b[1mdist/esm/index.js.map \u001b[22m\u001b[32m10.12 KB\u001b[39m\n"}
17
- {"kind":"O","text":"\u001b[32mESM\u001b[39m ⚡️ Build success in 108ms\n"}
16
+ {"kind":"O","text":"\u001b[32mESM\u001b[39m \u001b[1mdist/esm/index.js.map \u001b[22m\u001b[32m10.94 KB\u001b[39m\n"}
17
+ {"kind":"O","text":"\u001b[32mESM\u001b[39m ⚡️ Build success in 76ms\n"}
18
18
  {"kind":"O","text":"\u001b[34mDTS\u001b[39m Build start\n"}
19
- {"kind":"O","text":"\u001b[32mDTS\u001b[39m ⚡️ Build success in 5570ms\n"}
19
+ {"kind":"O","text":"\u001b[32mDTS\u001b[39m ⚡️ Build success in 5859ms\n"}
20
20
  {"kind":"O","text":"\u001b[32mDTS\u001b[39m \u001b[1mdist/index.d.ts \u001b[22m\u001b[32m13.00 B\u001b[39m\n"}
21
21
  {"kind":"O","text":"\u001b[32mDTS\u001b[39m \u001b[1mdist/index.d.mts \u001b[22m\u001b[32m13.00 B\u001b[39m\n"}
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "files": {
3
3
  "packages/runtime/nodejs/.eslintignore": "cf64a52f02394efe72596e139e57b1578da2a3ef",
4
- "packages/runtime/nodejs/.eslintrc.cjs": "9c2f4ba5790ef33d9f8ca81d42c5a476cb4616bf",
4
+ "packages/runtime/nodejs/.eslintrc.cjs": "c180e7cab4f101d243eceb563e48596c93d52dc0",
5
5
  "packages/runtime/nodejs/.gitignore": "5ef6a520780202a1d6addd833d800ccb1ecac0bb",
6
6
  "packages/runtime/nodejs/.rush/temp/shrinkwrap-deps.json": "47f74b0dbbf0c43302dfab567a638e7addfeb0b7",
7
7
  "packages/runtime/nodejs/README.md": "d7615d898b67036fde30bfa0de1f0dc10621361a",
8
8
  "packages/runtime/nodejs/package.json": "3e5571ae5603fec0ffebea08a8c0b50cf9cbf8f9",
9
- "packages/runtime/nodejs/src/api/create-api.ts": "1c2abefcacd57572ec7310af699042246ab0159b",
10
- "packages/runtime/nodejs/src/api/index.ts": "ec640ef604fc6c9780546a4a24a9508f863b7693",
11
- "packages/runtime/nodejs/src/api/trpc.ts": "3a62ba7c3680004f629a60d316e0e27a8628ff9b",
12
- "packages/runtime/nodejs/src/api/type.ts": "0f9aa56d1ee895306021f1173b550fe2b51b30f4",
13
- "packages/runtime/nodejs/src/config/index.ts": "9e50faa200e70281c577f859df7b39aa63dc75ac",
14
- "packages/runtime/nodejs/src/index.ts": "ce6975456b83cfa732166d61488b7d89acc7fe7e",
15
- "packages/runtime/nodejs/src/server/context.ts": "209780635e28b725e7311ed27a1892c2a505bec9",
16
- "packages/runtime/nodejs/src/server/docs.ts": "3748b1b757e3a7f203f440dd86899a31859fdf17",
17
- "packages/runtime/nodejs/src/server/index.ts": "3eba1b971c392b90f827d57a2f27bf68d38cbb14",
18
- "packages/runtime/nodejs/src/server/type.ts": "c40f8cb85a9fad2fc6642b9d6c8a6d0d255f2b7e",
9
+ "packages/runtime/nodejs/src/api/create-api.ts": "473b7a5aa0aec44ef72572e74d4440f958608f82",
10
+ "packages/runtime/nodejs/src/api/index.ts": "ffae37adf855bd02fb447b05f8b92f00ac3ca32f",
11
+ "packages/runtime/nodejs/src/api/trpc.ts": "a21b0b400704420c1fa9093d35ac4f3185be6f84",
12
+ "packages/runtime/nodejs/src/api/type.ts": "cd943a7b96b70397ecd013158b5d4747d6955ce3",
13
+ "packages/runtime/nodejs/src/config/index.ts": "71d651c9f4dfce2c1b39d752b63f70cd1b97113e",
14
+ "packages/runtime/nodejs/src/index.ts": "56657d1a705458e750376c979d8b28312542fa95",
15
+ "packages/runtime/nodejs/src/server/context.ts": "d058e5890d3447a7f64b2a3d5c389986543869df",
16
+ "packages/runtime/nodejs/src/server/docs.ts": "5a15f84f6a9f6db377d1879665ea9e24ed81bbb6",
17
+ "packages/runtime/nodejs/src/server/index.ts": "0e6721b88f77f9374136473aeb8fa147eea853d7",
18
+ "packages/runtime/nodejs/src/server/type.ts": "142449bcfb70e3d9ebeedee38909e96a1ebbeabf",
19
19
  "packages/runtime/nodejs/tsconfig.json": "26bd95eae3ae3f584a1ef9c1be2e99b776e0eb4a",
20
- "packages/runtime/nodejs/vitest.config.ts": "1e8c36111a5b4d1bdb49cb59c438d8596aa58512"
20
+ "packages/runtime/nodejs/vitest.config.ts": "67ff26553f389cf7d5135e06fdad942ca1bf5a60"
21
21
  },
22
22
  "arguments": "npm run build:fast -- --dts-resolve "
23
23
  }
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@flowgram.ai/runtime-nodejs",
3
3
  "entries": [
4
4
  {
5
- "version": "0.2.16",
6
- "tag": "@flowgram.ai/runtime-nodejs_v0.2.16",
7
- "date": "Fri, 27 Jun 2025 10:16:56 GMT",
5
+ "version": "0.2.18",
6
+ "tag": "@flowgram.ai/runtime-nodejs_v0.2.18",
7
+ "date": "Thu, 03 Jul 2025 02:45:25 GMT",
8
8
  "comments": {}
9
9
  }
10
10
  ]
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Change Log - @flowgram.ai/runtime-nodejs
2
2
 
3
- This log was last generated on Fri, 27 Jun 2025 10:16:56 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 03 Jul 2025 02:45:25 GMT and should not be manually modified.
4
4
 
5
- ## 0.2.16
6
- Fri, 27 Jun 2025 10:16:56 GMT
5
+ ## 0.2.18
6
+ Thu, 03 Jul 2025 02:45:25 GMT
7
7
 
8
8
  _Initial release_
9
9
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/index.ts","../../src/config/index.ts","../../src/api/index.ts","../../src/api/trpc.ts","../../src/api/create-api.ts","../../src/server/docs.ts","../../src/server/context.ts","../../src/index.ts"],"sourcesContent":["import { fastifyTRPCOpenApiPlugin } from 'trpc-openapi';\nimport fastify from 'fastify';\nimport { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';\nimport { ServerInfoDefine, type ServerInfoOutput } from '@flowgram.ai/runtime-interface';\nimport ws from '@fastify/websocket';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport fastifySwagger from '@fastify/swagger';\nimport cors from '@fastify/cors';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\nimport { serverDocument } from './docs';\nimport { createContext } from './context';\n\nexport async function createServer() {\n const server = fastify({ logger: ServerConfig.dev });\n\n await server.register(cors);\n await server.register(ws);\n await server.register(fastifyTRPCPlugin, {\n prefix: '/trpc',\n useWss: false,\n trpcOptions: { router: appRouter, createContext },\n });\n await server.register(fastifyTRPCOpenApiPlugin, {\n basePath: ServerConfig.basePath,\n router: appRouter,\n createContext,\n } as any);\n\n await server.register(fastifySwagger, {\n mode: 'static',\n specification: { document: serverDocument },\n uiConfig: { displayOperationId: true },\n exposeRoute: true,\n } as any);\n\n await server.register(fastifySwaggerUI, {\n routePrefix: ServerConfig.docsPath,\n uiConfig: {\n docExpansion: 'full',\n deepLinking: false,\n },\n uiHooks: {\n onRequest: function (request, reply, next) {\n next();\n },\n preHandler: function (request, reply, next) {\n next();\n },\n },\n staticCSP: true,\n transformStaticCSP: (header) => header,\n transformSpecification: (swaggerObject, request, reply) => swaggerObject,\n transformSpecificationClone: true,\n });\n\n server.get(ServerInfoDefine.path, async (): Promise<ServerInfoOutput> => {\n const serverTime = new Date();\n const output: ServerInfoOutput = {\n name: ServerConfig.name,\n title: ServerConfig.title,\n description: ServerConfig.description,\n runtime: ServerConfig.runtime,\n version: ServerConfig.version,\n time: serverTime.toISOString(),\n };\n return output;\n });\n\n const stop = async () => {\n await server.close();\n };\n const start = async () => {\n try {\n const address = await server.listen({ port: ServerConfig.port });\n await server.ready();\n server.swagger();\n console.log(\n `> Listen Port: ${ServerConfig.port}\\n> Server Address: ${address}\\n> API Docs: http://localhost:4000/docs`\n );\n } catch (err) {\n server.log.error(err);\n process.exit(1);\n }\n };\n\n return { server, start, stop };\n}\n","import type { ServerParams } from '@server/type';\n\nexport const ServerConfig: ServerParams = {\n name: 'flowgram-runtime',\n title: 'FlowGram Runtime',\n description: 'FlowGram Runtime Demo',\n runtime: 'nodejs',\n version: '0.0.1',\n dev: false,\n port: 4000,\n basePath: '/api',\n docsPath: '/docs',\n};\n","import { FlowGramAPINames } from '@flowgram.ai/runtime-interface';\n\nimport { APIRouter } from './type';\nimport { router } from './trpc';\nimport { createAPI } from './create-api';\n\nconst APIS = FlowGramAPINames.map((apiName) => createAPI(apiName));\n\nexport const routers = APIS.reduce((acc, api) => {\n acc[api.define.path] = api.procedure;\n return acc;\n}, {} as APIRouter);\n\nexport const appRouter = router(routers);\n\nexport type AppRouter = typeof appRouter;\n","import { OpenApiMeta } from 'trpc-openapi';\nimport { initTRPC } from '@trpc/server';\n\nimport type { Context } from '../server/context';\n\nconst t = initTRPC\n .context<Context>()\n .meta<OpenApiMeta>()\n .create({\n errorFormatter({ shape }) {\n return shape;\n },\n });\n\nexport const router = t.router;\nexport const publicProcedure = t.procedure;\n","import z from 'zod';\nimport { WorkflowRuntimeAPIs } from '@flowgram.ai/runtime-js';\nimport { FlowGramAPIMethod, FlowGramAPIName, FlowGramAPIs } from '@flowgram.ai/runtime-interface';\n\nimport { APIHandler } from './type';\nimport { publicProcedure } from './trpc';\n\nexport const createAPI = (apiName: FlowGramAPIName): APIHandler => {\n const define = FlowGramAPIs[apiName];\n const caller = WorkflowRuntimeAPIs[apiName];\n if (define.method === FlowGramAPIMethod.GET) {\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .query(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n\n return {\n define,\n procedure: procedure as any,\n };\n }\n\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .mutation(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n return {\n define,\n procedure: procedure as any,\n };\n};\n","import { generateOpenApiDocument } from 'trpc-openapi';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\n\n// Generate OpenAPI schema document\nexport const serverDocument = generateOpenApiDocument(appRouter, {\n title: ServerConfig.title,\n description: ServerConfig.description,\n version: ServerConfig.version,\n baseUrl: `http://localhost:${ServerConfig.port}${ServerConfig.basePath}`,\n docsUrl: 'https://flowgram.ai',\n tags: ['Task'],\n});\n","import type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';\n\nexport function createContext(ctx: CreateFastifyContextOptions) {\n const { req, res } = ctx;\n return { req, res };\n}\n\nexport type Context = Awaited<ReturnType<typeof createContext>>;\n","import { createServer } from '@server/index';\n\nasync function main() {\n const server = await createServer();\n server.start();\n}\n\nmain();\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,OAAO,aAAa;AACpB,SAAS,yBAAyB;AAClC,SAAS,wBAA+C;AACxD,OAAO,QAAQ;AACf,OAAO,sBAAsB;AAC7B,OAAO,oBAAoB;AAC3B,OAAO,UAAU;;;ACLV,IAAM,eAA6B;AAAA,EACxC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACZ;;;ACZA,SAAS,wBAAwB;;;ACCjC,SAAS,gBAAgB;AAIzB,IAAM,IAAI,SACP,QAAiB,EACjB,KAAkB,EAClB,OAAO;AAAA,EACN,eAAe,EAAE,MAAM,GAAG;AACxB,WAAO;AAAA,EACT;AACF,CAAC;AAEI,IAAM,SAAS,EAAE;AACjB,IAAM,kBAAkB,EAAE;;;ACfjC,OAAO,OAAO;AACd,SAAS,2BAA2B;AACpC,SAAS,mBAAoC,oBAAoB;AAK1D,IAAM,YAAY,CAAC,YAAyC;AACjE,QAAM,SAAS,aAAa,OAAO;AACnC,QAAM,SAAS,oBAAoB,OAAO;AAC1C,MAAI,OAAO,WAAW,kBAAkB,KAAK;AAC3C,UAAMA,aAAY,gBACf,KAAK;AAAA,MACJ,SAAS;AAAA,QACP,QAAQ,OAAO;AAAA,QACf,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,MAAM,CAAC,OAAO,MAA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AC5B,UAAM,SAA2B;AAAA,MAC/B,MAAM,aAAa;AAAA,MACnB,OAAO,aAAa;AAAA,MACpB,aAAa,aAAa;AAAA,MAC1B,SAAS,aAAa;AAAA,MACtB,SAAS,aAAa;AAAA,MACtB,MAAM,WAAW,YAAY;AAAA,IAC/B;AACA,WAAO;AAAA,EACT,CAAC;AAED,QAAM,OAAO,YAAY;AACvB,UAAM,OAAO,MAAM;AAAA,EACrB;AACA,QAAM,QAAQ,YAAY;AACxB,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,OAAO,EAAE,MAAM,aAAa,KAAK,CAAC;AAC/D,YAAM,OAAO,MAAM;AACnB,aAAO,QAAQ;AACf,cAAQ;AAAA,QACN,kBAAkB,aAAa,IAAI;AAAA,oBAAuB,OAAO;AAAA;AAAA,MACnE;AAAA,IACF,SAAS,KAAK;AACZ,aAAO,IAAI,MAAM,GAAG;AACpB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,OAAO,KAAK;AAC/B;;;AOtFA,eAAe,OAAO;AACpB,QAAM,SAAS,MAAM,aAAa;AAClC,SAAO,MAAM;AACf;AAEA,KAAK;","names":["procedure"]}
1
+ {"version":3,"sources":["../../src/server/index.ts","../../src/config/index.ts","../../src/api/index.ts","../../src/api/trpc.ts","../../src/api/create-api.ts","../../src/server/docs.ts","../../src/server/context.ts","../../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { fastifyTRPCOpenApiPlugin } from 'trpc-openapi';\nimport fastify from 'fastify';\nimport { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';\nimport { ServerInfoDefine, type ServerInfoOutput } from '@flowgram.ai/runtime-interface';\nimport ws from '@fastify/websocket';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport fastifySwagger from '@fastify/swagger';\nimport cors from '@fastify/cors';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\nimport { serverDocument } from './docs';\nimport { createContext } from './context';\n\nexport async function createServer() {\n const server = fastify({ logger: ServerConfig.dev });\n\n await server.register(cors);\n await server.register(ws);\n await server.register(fastifyTRPCPlugin, {\n prefix: '/trpc',\n useWss: false,\n trpcOptions: { router: appRouter, createContext },\n });\n await server.register(fastifyTRPCOpenApiPlugin, {\n basePath: ServerConfig.basePath,\n router: appRouter,\n createContext,\n } as any);\n\n await server.register(fastifySwagger, {\n mode: 'static',\n specification: { document: serverDocument },\n uiConfig: { displayOperationId: true },\n exposeRoute: true,\n } as any);\n\n await server.register(fastifySwaggerUI, {\n routePrefix: ServerConfig.docsPath,\n uiConfig: {\n docExpansion: 'full',\n deepLinking: false,\n },\n uiHooks: {\n onRequest: function (request, reply, next) {\n next();\n },\n preHandler: function (request, reply, next) {\n next();\n },\n },\n staticCSP: true,\n transformStaticCSP: (header) => header,\n transformSpecification: (swaggerObject, request, reply) => swaggerObject,\n transformSpecificationClone: true,\n });\n\n server.get(ServerInfoDefine.path, async (): Promise<ServerInfoOutput> => {\n const serverTime = new Date();\n const output: ServerInfoOutput = {\n name: ServerConfig.name,\n title: ServerConfig.title,\n description: ServerConfig.description,\n runtime: ServerConfig.runtime,\n version: ServerConfig.version,\n time: serverTime.toISOString(),\n };\n return output;\n });\n\n const stop = async () => {\n await server.close();\n };\n const start = async () => {\n try {\n const address = await server.listen({ port: ServerConfig.port });\n await server.ready();\n server.swagger();\n console.log(\n `> Listen Port: ${ServerConfig.port}\\n> Server Address: ${address}\\n> API Docs: http://localhost:4000/docs`\n );\n } catch (err) {\n server.log.error(err);\n process.exit(1);\n }\n };\n\n return { server, start, stop };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { ServerParams } from '@server/type';\n\nexport const ServerConfig: ServerParams = {\n name: 'flowgram-runtime',\n title: 'FlowGram Runtime',\n description: 'FlowGram Runtime Demo',\n runtime: 'nodejs',\n version: '0.0.1',\n dev: false,\n port: 4000,\n basePath: '/api',\n docsPath: '/docs',\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowGramAPINames } from '@flowgram.ai/runtime-interface';\n\nimport { APIRouter } from './type';\nimport { router } from './trpc';\nimport { createAPI } from './create-api';\n\nconst APIS = FlowGramAPINames.map((apiName) => createAPI(apiName));\n\nexport const routers = APIS.reduce((acc, api) => {\n acc[api.define.path] = api.procedure;\n return acc;\n}, {} as APIRouter);\n\nexport const appRouter = router(routers);\n\nexport type AppRouter = typeof appRouter;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { OpenApiMeta } from 'trpc-openapi';\nimport { initTRPC } from '@trpc/server';\n\nimport type { Context } from '../server/context';\n\nconst t = initTRPC\n .context<Context>()\n .meta<OpenApiMeta>()\n .create({\n errorFormatter({ shape }) {\n return shape;\n },\n });\n\nexport const router = t.router;\nexport const publicProcedure = t.procedure;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport z from 'zod';\nimport { WorkflowRuntimeAPIs } from '@flowgram.ai/runtime-js';\nimport { FlowGramAPIMethod, FlowGramAPIName, FlowGramAPIs } from '@flowgram.ai/runtime-interface';\n\nimport { APIHandler } from './type';\nimport { publicProcedure } from './trpc';\n\nexport const createAPI = (apiName: FlowGramAPIName): APIHandler => {\n const define = FlowGramAPIs[apiName];\n const caller = WorkflowRuntimeAPIs[apiName];\n if (define.method === FlowGramAPIMethod.GET) {\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .query(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n\n return {\n define,\n procedure: procedure as any,\n };\n }\n\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .mutation(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n return {\n define,\n procedure: procedure as any,\n };\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { generateOpenApiDocument } from 'trpc-openapi';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\n\n// Generate OpenAPI schema document\nexport const serverDocument = generateOpenApiDocument(appRouter, {\n title: ServerConfig.title,\n description: ServerConfig.description,\n version: ServerConfig.version,\n baseUrl: `http://localhost:${ServerConfig.port}${ServerConfig.basePath}`,\n docsUrl: 'https://flowgram.ai',\n tags: ['Task'],\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';\n\nexport function createContext(ctx: CreateFastifyContextOptions) {\n const { req, res } = ctx;\n return { req, res };\n}\n\nexport type Context = Awaited<ReturnType<typeof createContext>>;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { createServer } from '@server/index';\n\nasync function main() {\n const server = await createServer();\n server.start();\n}\n\nmain();\n"],"mappings":";AAKA,SAAS,gCAAgC;AACzC,OAAO,aAAa;AACpB,SAAS,yBAAyB;AAClC,SAAS,wBAA+C;AACxD,OAAO,QAAQ;AACf,OAAO,sBAAsB;AAC7B,OAAO,oBAAoB;AAC3B,OAAO,UAAU;;;ACLV,IAAM,eAA6B;AAAA,EACxC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AA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AA,IAChB;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,OAAO,KAAK;AAC/B;;;AOtFA,eAAe,OAAO;AACpB,QAAM,SAAS,MAAM,aAAa;AAClC,SAAO,MAAM;AACf;AAEA,KAAK;","names":["procedure"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/index.ts","../src/config/index.ts","../src/api/index.ts","../src/api/trpc.ts","../src/api/create-api.ts","../src/server/docs.ts","../src/server/context.ts","../src/index.ts"],"sourcesContent":["import { fastifyTRPCOpenApiPlugin } from 'trpc-openapi';\nimport fastify from 'fastify';\nimport { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';\nimport { ServerInfoDefine, type ServerInfoOutput } from '@flowgram.ai/runtime-interface';\nimport ws from '@fastify/websocket';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport fastifySwagger from '@fastify/swagger';\nimport cors from '@fastify/cors';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\nimport { serverDocument } from './docs';\nimport { createContext } from './context';\n\nexport async function createServer() {\n const server = fastify({ logger: ServerConfig.dev });\n\n await server.register(cors);\n await server.register(ws);\n await server.register(fastifyTRPCPlugin, {\n prefix: '/trpc',\n useWss: false,\n trpcOptions: { router: appRouter, createContext },\n });\n await server.register(fastifyTRPCOpenApiPlugin, {\n basePath: ServerConfig.basePath,\n router: appRouter,\n createContext,\n } as any);\n\n await server.register(fastifySwagger, {\n mode: 'static',\n specification: { document: serverDocument },\n uiConfig: { displayOperationId: true },\n exposeRoute: true,\n } as any);\n\n await server.register(fastifySwaggerUI, {\n routePrefix: ServerConfig.docsPath,\n uiConfig: {\n docExpansion: 'full',\n deepLinking: false,\n },\n uiHooks: {\n onRequest: function (request, reply, next) {\n next();\n },\n preHandler: function (request, reply, next) {\n next();\n },\n },\n staticCSP: true,\n transformStaticCSP: (header) => header,\n transformSpecification: (swaggerObject, request, reply) => swaggerObject,\n transformSpecificationClone: true,\n });\n\n server.get(ServerInfoDefine.path, async (): Promise<ServerInfoOutput> => {\n const serverTime = new Date();\n const output: ServerInfoOutput = {\n name: ServerConfig.name,\n title: ServerConfig.title,\n description: ServerConfig.description,\n runtime: ServerConfig.runtime,\n version: ServerConfig.version,\n time: serverTime.toISOString(),\n };\n return output;\n });\n\n const stop = async () => {\n await server.close();\n };\n const start = async () => {\n try {\n const address = await server.listen({ port: ServerConfig.port });\n await server.ready();\n server.swagger();\n console.log(\n `> Listen Port: ${ServerConfig.port}\\n> Server Address: ${address}\\n> API Docs: http://localhost:4000/docs`\n );\n } catch (err) {\n server.log.error(err);\n process.exit(1);\n }\n };\n\n return { server, start, stop };\n}\n","import type { ServerParams } from '@server/type';\n\nexport const ServerConfig: ServerParams = {\n name: 'flowgram-runtime',\n title: 'FlowGram Runtime',\n description: 'FlowGram Runtime Demo',\n runtime: 'nodejs',\n version: '0.0.1',\n dev: false,\n port: 4000,\n basePath: '/api',\n docsPath: '/docs',\n};\n","import { FlowGramAPINames } from '@flowgram.ai/runtime-interface';\n\nimport { APIRouter } from './type';\nimport { router } from './trpc';\nimport { createAPI } from './create-api';\n\nconst APIS = FlowGramAPINames.map((apiName) => createAPI(apiName));\n\nexport const routers = APIS.reduce((acc, api) => {\n acc[api.define.path] = api.procedure;\n return acc;\n}, {} as APIRouter);\n\nexport const appRouter = router(routers);\n\nexport type AppRouter = typeof appRouter;\n","import { OpenApiMeta } from 'trpc-openapi';\nimport { initTRPC } from '@trpc/server';\n\nimport type { Context } from '../server/context';\n\nconst t = initTRPC\n .context<Context>()\n .meta<OpenApiMeta>()\n .create({\n errorFormatter({ shape }) {\n return shape;\n },\n });\n\nexport const router = t.router;\nexport const publicProcedure = t.procedure;\n","import z from 'zod';\nimport { WorkflowRuntimeAPIs } from '@flowgram.ai/runtime-js';\nimport { FlowGramAPIMethod, FlowGramAPIName, FlowGramAPIs } from '@flowgram.ai/runtime-interface';\n\nimport { APIHandler } from './type';\nimport { publicProcedure } from './trpc';\n\nexport const createAPI = (apiName: FlowGramAPIName): APIHandler => {\n const define = FlowGramAPIs[apiName];\n const caller = WorkflowRuntimeAPIs[apiName];\n if (define.method === FlowGramAPIMethod.GET) {\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .query(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n\n return {\n define,\n procedure: procedure as any,\n };\n }\n\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .mutation(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n return {\n define,\n procedure: procedure as any,\n };\n};\n","import { generateOpenApiDocument } from 'trpc-openapi';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\n\n// Generate OpenAPI schema document\nexport const serverDocument = generateOpenApiDocument(appRouter, {\n title: ServerConfig.title,\n description: ServerConfig.description,\n version: ServerConfig.version,\n baseUrl: `http://localhost:${ServerConfig.port}${ServerConfig.basePath}`,\n docsUrl: 'https://flowgram.ai',\n tags: ['Task'],\n});\n","import type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';\n\nexport function createContext(ctx: CreateFastifyContextOptions) {\n const { req, res } = ctx;\n return { req, res };\n}\n\nexport type Context = Awaited<ReturnType<typeof createContext>>;\n","import { createServer } from '@server/index';\n\nasync function main() {\n const server = await createServer();\n server.start();\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,uBAAyC;AACzC,qBAAoB;AACpB,IAAAC,kBAAkC;AAClC,IAAAC,4BAAwD;AACxD,uBAAe;AACf,wBAA6B;AAC7B,qBAA2B;AAC3B,kBAAiB;;;AC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AkB,aAAa,IAAI;AAAA,oBAAuB,OAAO;AAAA;AAAA,MACnE;AAAA,IACF,SAAS,KAAK;AACZ,aAAO,IAAI,MAAM,GAAG;AACpB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,OAAO,KAAK;AAC/B;;;AOtFA,eAAe,OAAO;AACpB,QAAM,SAAS,MAAM,aAAa;AAClC,SAAO,MAAM;AACf;AAEA,KAAK;","names":["import_trpc_openapi","import_fastify","import_runtime_interface","import_runtime_interface","procedure","z","fastify","cors","ws","fastifySwagger","fastifySwaggerUI"]}
1
+ {"version":3,"sources":["../src/server/index.ts","../src/config/index.ts","../src/api/index.ts","../src/api/trpc.ts","../src/api/create-api.ts","../src/server/docs.ts","../src/server/context.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { fastifyTRPCOpenApiPlugin } from 'trpc-openapi';\nimport fastify from 'fastify';\nimport { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';\nimport { ServerInfoDefine, type ServerInfoOutput } from '@flowgram.ai/runtime-interface';\nimport ws from '@fastify/websocket';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport fastifySwagger from '@fastify/swagger';\nimport cors from '@fastify/cors';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\nimport { serverDocument } from './docs';\nimport { createContext } from './context';\n\nexport async function createServer() {\n const server = fastify({ logger: ServerConfig.dev });\n\n await server.register(cors);\n await server.register(ws);\n await server.register(fastifyTRPCPlugin, {\n prefix: '/trpc',\n useWss: false,\n trpcOptions: { router: appRouter, createContext },\n });\n await server.register(fastifyTRPCOpenApiPlugin, {\n basePath: ServerConfig.basePath,\n router: appRouter,\n createContext,\n } as any);\n\n await server.register(fastifySwagger, {\n mode: 'static',\n specification: { document: serverDocument },\n uiConfig: { displayOperationId: true },\n exposeRoute: true,\n } as any);\n\n await server.register(fastifySwaggerUI, {\n routePrefix: ServerConfig.docsPath,\n uiConfig: {\n docExpansion: 'full',\n deepLinking: false,\n },\n uiHooks: {\n onRequest: function (request, reply, next) {\n next();\n },\n preHandler: function (request, reply, next) {\n next();\n },\n },\n staticCSP: true,\n transformStaticCSP: (header) => header,\n transformSpecification: (swaggerObject, request, reply) => swaggerObject,\n transformSpecificationClone: true,\n });\n\n server.get(ServerInfoDefine.path, async (): Promise<ServerInfoOutput> => {\n const serverTime = new Date();\n const output: ServerInfoOutput = {\n name: ServerConfig.name,\n title: ServerConfig.title,\n description: ServerConfig.description,\n runtime: ServerConfig.runtime,\n version: ServerConfig.version,\n time: serverTime.toISOString(),\n };\n return output;\n });\n\n const stop = async () => {\n await server.close();\n };\n const start = async () => {\n try {\n const address = await server.listen({ port: ServerConfig.port });\n await server.ready();\n server.swagger();\n console.log(\n `> Listen Port: ${ServerConfig.port}\\n> Server Address: ${address}\\n> API Docs: http://localhost:4000/docs`\n );\n } catch (err) {\n server.log.error(err);\n process.exit(1);\n }\n };\n\n return { server, start, stop };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { ServerParams } from '@server/type';\n\nexport const ServerConfig: ServerParams = {\n name: 'flowgram-runtime',\n title: 'FlowGram Runtime',\n description: 'FlowGram Runtime Demo',\n runtime: 'nodejs',\n version: '0.0.1',\n dev: false,\n port: 4000,\n basePath: '/api',\n docsPath: '/docs',\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowGramAPINames } from '@flowgram.ai/runtime-interface';\n\nimport { APIRouter } from './type';\nimport { router } from './trpc';\nimport { createAPI } from './create-api';\n\nconst APIS = FlowGramAPINames.map((apiName) => createAPI(apiName));\n\nexport const routers = APIS.reduce((acc, api) => {\n acc[api.define.path] = api.procedure;\n return acc;\n}, {} as APIRouter);\n\nexport const appRouter = router(routers);\n\nexport type AppRouter = typeof appRouter;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { OpenApiMeta } from 'trpc-openapi';\nimport { initTRPC } from '@trpc/server';\n\nimport type { Context } from '../server/context';\n\nconst t = initTRPC\n .context<Context>()\n .meta<OpenApiMeta>()\n .create({\n errorFormatter({ shape }) {\n return shape;\n },\n });\n\nexport const router = t.router;\nexport const publicProcedure = t.procedure;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport z from 'zod';\nimport { WorkflowRuntimeAPIs } from '@flowgram.ai/runtime-js';\nimport { FlowGramAPIMethod, FlowGramAPIName, FlowGramAPIs } from '@flowgram.ai/runtime-interface';\n\nimport { APIHandler } from './type';\nimport { publicProcedure } from './trpc';\n\nexport const createAPI = (apiName: FlowGramAPIName): APIHandler => {\n const define = FlowGramAPIs[apiName];\n const caller = WorkflowRuntimeAPIs[apiName];\n if (define.method === FlowGramAPIMethod.GET) {\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .query(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n\n return {\n define,\n procedure: procedure as any,\n };\n }\n\n const procedure = publicProcedure\n .meta({\n openapi: {\n method: define.method,\n path: define.path,\n summary: define.name,\n tags: [define.module],\n },\n })\n .input(define.schema.input)\n .output(z.union([define.schema.output, z.undefined()]))\n .mutation(async (opts) => {\n const input = opts.input;\n try {\n const output = await caller(input);\n return output;\n } catch {\n return undefined;\n }\n });\n return {\n define,\n procedure: procedure as any,\n };\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { generateOpenApiDocument } from 'trpc-openapi';\n\nimport { ServerConfig } from '@config/index';\nimport { appRouter } from '@api/index';\n\n// Generate OpenAPI schema document\nexport const serverDocument = generateOpenApiDocument(appRouter, {\n title: ServerConfig.title,\n description: ServerConfig.description,\n version: ServerConfig.version,\n baseUrl: `http://localhost:${ServerConfig.port}${ServerConfig.basePath}`,\n docsUrl: 'https://flowgram.ai',\n tags: ['Task'],\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';\n\nexport function createContext(ctx: CreateFastifyContextOptions) {\n const { req, res } = ctx;\n return { req, res };\n}\n\nexport type Context = Awaited<ReturnType<typeof createContext>>;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { createServer } from '@server/index';\n\nasync function main() {\n const server = await createServer();\n server.start();\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAAA,uBAAyC;AACzC,qBAAoB;AACpB,IAAAC,kBAAkC;AAClC,IAAAC,4BAAwD;AACxD,uBAAe;AACf,wBAA6B;AAC7B,qBAA2B;AAC3B,kBAAiB;;;ACLV,IAAM,eAA6B;AAAA,EACxC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACZ;;;ACZA,IAAAC,4BAAiC;;;ACCjC,oBAAyB;AAIzB,IAAM,IAAI,uBACP,QAAiB,EACjB,KAAkB,EAClB,OAAO;AAAA,EACN,eAAe,EAAE,MAAM,GAAG;AACxB,WAAO;AAAA,EACT;AACF,CAAC;AAEI,IAAM,SAAS,EAAE;AACjB,IAAM,kBAAkB,EAAE;;;ACfjC,iBAAc;AACd,wBAAoC;AACpC,+BAAiE;AAK1D,IAAM,YAAY,CAAC,YAAyC;A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OAAO,MAAM;AACzC,aAAK;AAAA,MACP;AAAA,MACA,YAAY,SAAU,SAAS,OAAO,MAAM;AAC1C,aAAK;AAAA,MACP;AAAA,IACF;AAAA,IACA,WAAW;AAAA,IACX,oBAAoB,CAAC,WAAW;AAAA,IAChC,wBAAwB,CAAC,eAAe,SAAS,UAAU;AAAA,IAC3D,6BAA6B;AAAA,EAC/B,CAAC;AAED,SAAO,IAAI,2CAAiB,MAAM,YAAuC;AACvE,UAAM,aAAa,oBAAI,KAAK;AAC5B,UAAM,SAA2B;AAAA,MAC/B,MAAM,aAAa;AAAA,MACnB,OAAO,aAAa;AAAA,MACpB,aAAa,aAAa;AAAA,MAC1B,SAAS,aAAa;AAAA,MACtB,SAAS,aAAa;AAAA,MACtB,MAAM,WAAW,YAAY;AAAA,IAC/B;AACA,WAAO;AAAA,EACT,CAAC;AAED,QAAM,OAAO,YAAY;AACvB,UAAM,OAAO,MAAM;AAAA,EACrB;AACA,QAAM,QAAQ,YAAY;AACxB,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,OAAO,EAAE,MAAM,aAAa,KAAK,CAAC;AAC/D,YAAM,OAAO,MAAM;AACnB,aAAO,QAAQ;AACf,cAAQ;AAAA,QACN,kBAAkB,aAAa,IAAI;AAAA,oBAAuB,OAAO;AAAA;AAAA,MACnE;AAAA,IACF,SAAS,KAAK;AACZ,aAAO,IAAI,MAAM,GAAG;AACpB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,OAAO,KAAK;AAC/B;;;AOtFA,eAAe,OAAO;AACpB,QAAM,SAAS,MAAM,aAAa;AAClC,SAAO,MAAM;AACf;AAEA,KAAK;","names":["import_trpc_openapi","import_fastify","import_runtime_interface","import_runtime_interface","procedure","z","fastify","cors","ws","fastifySwagger","fastifySwaggerUI"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/runtime-nodejs",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -18,8 +18,8 @@
18
18
  "lodash-es": "^4.17.21",
19
19
  "ws": "^8.0.0",
20
20
  "zod": "^3.24.4",
21
- "@flowgram.ai/runtime-js": "0.2.16",
22
- "@flowgram.ai/runtime-interface": "0.2.16"
21
+ "@flowgram.ai/runtime-js": "0.2.18",
22
+ "@flowgram.ai/runtime-interface": "0.2.18"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/cors": "^2.8.13",
@@ -40,8 +40,8 @@
40
40
  "@vitest/coverage-v8": "^0.32.0",
41
41
  "vitest": "^0.34.6",
42
42
  "wait-port": "^1.0.1",
43
- "@flowgram.ai/ts-config": "0.2.16",
44
- "@flowgram.ai/eslint-config": "0.2.16"
43
+ "@flowgram.ai/eslint-config": "0.2.18",
44
+ "@flowgram.ai/ts-config": "0.2.18"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public",
@@ -10,12 +10,12 @@ CLI Target: esnext
10
10
  CJS Build start
11
11
  ESM Build start
12
12
  CJS dist/index.js 6.67 KB
13
- CJS dist/index.js.map 10.28 KB
14
- CJS ⚡️ Build success in 107ms
13
+ CJS dist/index.js.map 11.10 KB
14
+ CJS ⚡️ Build success in 75ms
15
15
  ESM dist/esm/index.js 5.09 KB
16
- ESM dist/esm/index.js.map 10.12 KB
17
- ESM ⚡️ Build success in 108ms
16
+ ESM dist/esm/index.js.map 10.94 KB
17
+ ESM ⚡️ Build success in 76ms
18
18
  DTS Build start
19
- DTS ⚡️ Build success in 5570ms
19
+ DTS ⚡️ Build success in 5859ms
20
20
  DTS dist/index.d.ts 13.00 B
21
21
  DTS dist/index.d.mts 13.00 B
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import z from 'zod';
2
7
  import { WorkflowRuntimeAPIs } from '@flowgram.ai/runtime-js';
3
8
  import { FlowGramAPIMethod, FlowGramAPIName, FlowGramAPIs } from '@flowgram.ai/runtime-interface';
package/src/api/index.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { FlowGramAPINames } from '@flowgram.ai/runtime-interface';
2
7
 
3
8
  import { APIRouter } from './type';
package/src/api/trpc.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { OpenApiMeta } from 'trpc-openapi';
2
7
  import { initTRPC } from '@trpc/server';
3
8
 
package/src/api/type.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { BuildProcedure } from '@trpc/server';
2
7
  import { FlowGramAPIDefine } from '@flowgram.ai/runtime-interface';
3
8
 
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import type { ServerParams } from '@server/type';
2
7
 
3
8
  export const ServerConfig: ServerParams = {
package/src/index.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { createServer } from '@server/index';
2
7
 
3
8
  async function main() {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import type { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';
2
7
 
3
8
  export function createContext(ctx: CreateFastifyContextOptions) {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { generateOpenApiDocument } from 'trpc-openapi';
2
7
 
3
8
  import { ServerConfig } from '@config/index';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { fastifyTRPCOpenApiPlugin } from 'trpc-openapi';
2
7
  import fastify from 'fastify';
3
8
  import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { ServerInfoOutput } from '@flowgram.ai/runtime-interface';
2
7
 
3
8
  export interface ServerParams extends Omit<ServerInfoOutput, 'time'> {
package/vitest.config.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  import { config } from "dotenv";
2
7
  import path from 'path';
3
8
  import { defineConfig } from 'vitest/config';