Conversation
| }; | ||
| const { configuration } = job; | ||
| // picking credential | ||
| if (typeof configuration === 'string' && configuration.trim()) { |
There was a problem hiding this comment.
Why are we calling configuration.trim() here?
Oh, you're testing if it's not an empty string
Maybe we should rely on the Project class to do this validation for us, and then we can just assume that credentials is falsy or a string? It'll make this code a lot tidier
| typeof configuration === 'object' && | ||
| !Array.isArray(configuration) && | ||
| typeof configuration[CREDENTIALS_KEY] === 'string' && | ||
| (configuration[CREDENTIALS_KEY] as string).trim() |
There was a problem hiding this comment.
Hmm. Having a bit of a hard time with this but the CREDENTIALS_KEY stuff shouldn't be in the project file. It's only used by execute as a hack to update the user's credential.
Unless you've seen a clear use-case where this is needed, I think we can cut it.
| import { CREDENTIALS_KEY } from '../execute/apply-credential-map'; | ||
| import type { Logger } from '../util/logger'; | ||
|
|
||
| export function collectCredentialReferences(project: Project): string[] { |
There was a problem hiding this comment.
Maybe findCredentialIds is a clearer name?
| const absolutePath = path.resolve(workspacePath, credentialsPath); | ||
| let existing: Record<string, unknown> = {}; | ||
|
|
||
| if (fs.existsSync(absolutePath)) { |
There was a problem hiding this comment.
Interesting. Not really happy about all this validation being buried down here. If it's not an exact duplicate of the code in execute/handler.ts, it's going to be super close
Maybe we can create a loadCredentialMap util file which is re-used? Then we just have one technique to load the credential map
Short Description
This PR adds a feature where a
credentials.yamlfile is auto generated during the pull (openfn project pull <project-id>).Fixes #1261
Implementation Details
QA Notes
List any considerations/cases/advice for testing/QA here.
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Release branch checklist
Delete this section if this is not a release PR.
If this IS a release branch:
pnpm changeset versionfrom root to bump versionspnpm installpnpm changeset tagto generate tagsgit push --tagsTags may need updating if commits come in after the tags are first generated.