-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow linking and unlinking lambdas to applications #8
Open
rideam
wants to merge
13
commits into
FusionAuth:main
Choose a base branch
from
ritza-co:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
af6229d
Converting json to yaml to allow newlines in lambdas
41acd70
Lambda functionality now works for multiline function bodies, using y…
f1ff5a8
Add command to create lambda
dd66e33
Allow unlinking access token and id token lambdas from application
611c858
Allow creating lambdas, linking, and unlinking from id and access tok…
ae7e5fd
Merge pull request #2 from RichardJECooke/main
rideam 86f9acf
Update README.md
rideam c3e5f64
Add brackets to if statements. Use blank lamba ids instead of null. U…
89584e3
Remove application name from request to patchApplication because it w…
c99ac2e
Add .summary() to lambda commands
eee381b
add brackets
rideam 517ef18
Removed lambda link and unlink commands from the CLI. https://github.…
880d627
remove lambda link and unlink mention in README
rideam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {Command} from '@commander-js/extra-typings'; | ||
import {FusionAuthClient} from '@fusionauth/typescript-client'; | ||
import {readFile} from 'fs/promises'; | ||
import chalk from 'chalk'; | ||
import {join} from 'path'; | ||
import {errorAndExit} from '../utils.js'; | ||
import {apiKeyOption, hostOption} from "../options.js"; | ||
import {load as loadYaml} from 'js-yaml'; | ||
|
||
const action = async function (lambdaId: string, {input, key: apiKey, host}: { | ||
input: string; | ||
key: string; | ||
host: string | ||
}): Promise<void> { | ||
console.log(`Creating lambda ${lambdaId} on ${host}`); | ||
try { | ||
const filename = join(input, lambdaId + ".yaml"); | ||
const data = await readFile(filename, 'utf-8'); | ||
const lambda = loadYaml(data) as object; | ||
const fusionAuthClient = new FusionAuthClient(apiKey, host); | ||
const clientResponse = await fusionAuthClient.createLambda(lambdaId, { lambda }); | ||
if (!clientResponse.wasSuccessful()) { | ||
errorAndExit(`Error creating lambda: `, clientResponse); | ||
} | ||
console.log(chalk.green(`Lambda created`)); | ||
} | ||
catch (e: unknown) { | ||
errorAndExit(`Error creating lambda: `, e); | ||
} | ||
} | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
export const lambdaCreate = new Command('lambda:create') | ||
.summary('Create a lambda on FusionAuth') | ||
.description(`Create a lambda on FusionAuth. | ||
Example lambda .yaml file: | ||
|
||
body: | | ||
function populate(jwt, user, registration) { | ||
jwt.message = 'Hello World!'; | ||
console.info('Hello World!'); | ||
} | ||
debug: true | ||
engineType: GraalJS | ||
id: f3b3b547-7754-452d-8729-21b50d111505 | ||
insertInstant: 1692177291178 | ||
lastUpdateInstant: 1692211131823 | ||
name: '[ATestLambda]' | ||
type: JWTPopulate | ||
`) | ||
.argument('<lambdaId>', 'The lambda id to create. The lambda is read from the file <id>.yaml in the <input> directory.') | ||
.option('-i, --input <input>', 'The input directory', './lambdas/') | ||
.addOption(apiKeyOption) | ||
.addOption(hostOption) | ||
.action(action); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a short
.summary('Create a lambda on FusionAuth')
for commands with a large description. (lamdba:create
,lambda:link-to-application
,lamdba:unlink-from-application
)