Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in Cloud Functions environment #11

Open
zallesov opened this issue Sep 1, 2024 · 0 comments
Open

Does not work in Cloud Functions environment #11

zallesov opened this issue Sep 1, 2024 · 0 comments

Comments

@zallesov
Copy link

zallesov commented Sep 1, 2024

First of all - great idea and great library. If it works it works great! but I'm having a hard time making it run inside a cloud function. This is my function for reference

/** @description Given `cities` a list of city names with country codes, 
 * returns a the same list with added latitude, longitude. */
function hidrateCitiesCoordinates(cities: TripPoint[]): (TripPoint & { lat: number, lng: number })[] | void { }
export const hidrateCitiesCoordinatesAI = toAIFunction(hidrateCitiesCoordinates)

I could make it work locally in plain typescript app ran with tsup-node or ts-node

Describe the bug
I attempted to run it in the Google Cloud Functions environment which is "compiled" to javascript.
I get this error

TypeError: Cannot read properties of undefined (reading 'type')
    at toAIFunction (file:///Users/username/Projects/air/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/@typeai/core/dist/index.js:4186:40)

and Indeed in the js files there is no implementation of the function

import { toAIFunction } from "@typeai/core";
function hidrateCitiesCoordinates(cities) {
}
var hidrateCitiesCoordinatesAI = toAIFunction(hidrateCitiesCoordinates);

tsconfig.json

  "compilerOptions": {
    "outDir": "dist",
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "lib": [
      "esnext"
    ],
    "sourceMap": true,
    "types": [
      "node"
    ],
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "src/*"
      ]
    },
    "experimentalDecorators": true
  },
  "reflection": true,
  "include": [
    "src"
  ]
}

I also did the step with deepkit-type-install

Is it even possible to achieve this?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant