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

Handle local type definitions in Monaco #2883

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

josephjclark
Copy link
Contributor

@josephjclark josephjclark commented Jan 30, 2025

Overview

Local adaptor support was added over in #2834, allowing the local monorepo to be used to run jobs through Lightning.

One thing that was (deliberately) excluded was the ability to also load type definitions (for monaco) from the monorepo.

This PR adds support for that, so that you can test your local typings in the editor (very helpful)

Note: This PR does not address the issue of fixing adaptor docs locally.

Implementation

The implementation is pretty simple really.

First of all it assumes that the typings are available over HTTP (see TODO: local serve support)

Then basically all we do is, if local adaptors is enabled, we pull down the typings from localhost. Otherwise, we download them from jsdelivr.

Simple really.

TODO: local serve support

In this current branch of the PR, I am serving adaptor files from the monorepo with an npm package called serve.

So locally I go to adaptors and I run:

 PORT=5000 npx serve  --cors`

Now the contents of the monorepo are statically served to me on localhost:5000.

But I don't want to use npm server for this: I want to uses a phoenix plug to serve them locally from the app.

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

@josephjclark josephjclark self-assigned this Jan 30, 2025
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.72%. Comparing base (8cf9452) to head (c6478d8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2883      +/-   ##
==========================================
+ Coverage   91.69%   91.72%   +0.02%     
==========================================
  Files         349      349              
  Lines       12975    12975              
==========================================
+ Hits        11898    11901       +3     
+ Misses       1077     1074       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

import createCompletionProvider from './magic-completion';
import { initiateSaveAndRun } from '../common';

const LOCAL_ADAPTORS_ROOT = 'http://localhost:5000';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: update this constant when the static fileserver is set up

results.push({
content: `declare module '@openfn/language-common' { ${content} }`,
});
if (!content.match(/<!doctype html>/i)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO check this doctype stuff - this is from npm serve returning folders, I think. When the plug is enabled I'll come back and have another look.

@josephjclark
Copy link
Contributor Author

Hi @theroinaochieng, can Frank take a look at this PR? It's not urgent at all. I know I've missed planning so it can wait until next sprint. I think it's only a small task though.

Frank, we need to set up a plug which will statically serve the contents of the OPENFN_ADAPTORS_REPO folder. Maybe you can mount it at /monorepo or something. We need to update a url in the react code but I can help with that. We ONLY need to do this if LOCAL_ADAPTORS is true.

@josephjclark josephjclark marked this pull request as ready for review March 21, 2025 19:00
@josephjclark
Copy link
Contributor Author

Note to me: do we need to update any docs? What docs do we have to local adaptors?

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

Successfully merging this pull request may close these issues.

1 participant