launchdarkly / api-client-typescript Goto Github PK
View Code? Open in Web Editor NEWLaunchDarkly API Client for Typescript Node Server
License: Other
LaunchDarkly API Client for Typescript Node Server
License: Other
Hey,
I know this is auto generated client, but hopefully you would have a solution.
When i use the api-client-typescript package, and try to send a .patchFeatureFlag()
with a payload example:
"environmentKey": "environment-key-123abc",
"instructions": [{
"kind": "addValuesToClause",
"ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
"clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
"values": ["beta_testers"]
}]
}
There are 2 problems:
op
, path
and value
, so there is a TS compile error. "patch": [
{
"environmentKey": "environment-key-123abc",
"instructions": [
{
"kind": "addValuesToClause",
"ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29,
"clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
"values": [
"please-work"
]
}
]
}
]
}
And the response from the REST API is 400 Error
"code": "invalid_patch",
"message": "must have at least one instruction"
}
Please advise, is there a way to use all the different patch operations via the client?
Currently the library always uses the setApiKeyToObject
method to set up authentication. Which effectively means that the library can only be used with an API Key, and not when using username/password or access tokens (through OAuth).
This seems like a bug, as the common code paths already has functionality like setBasicAuthToObject
and setBearerAuthToObject
.
The fix is fairly simple, we just need to replace all calls to setApiKeyToObject
with something more generic like addAuthToObject
:
const addAuthToObject = function (object, keyParamName, configuration) {
if (!configuration) {
return
}
if (configuration.apiKey) {
setApiKeyToObject(object, keyParamName, configuration);
} else if (configuration.username || configuration.password) {
setBasicAuthToObject(object, configuration);
} else if (configuration.accessToken) {
setBearerAuthToObject(object, configuration);
}
};
As the code here seems auto-generated, I'm not sure if I can submit a PR.
The Getting Started
link in the README points to a bookmark that doesn't exist. I tried looking but couldn't find an example that this could/should point to instead, so I cannot make a PR.
Using the REST api over HTTPs, you can make the following request:
const requestInfo = {
hostname: `app.launchdarkly.com`,
path: `/api/v2/flags/${projectKey}/${flagKey}`,
method: 'PATCH',
headers: {
Authorization: LAUNCHDARKLY_ACCESS_TOKEN,
'Content-Type': 'application/json; domain-model=launchdarkly.semanticpatch',
},
};
const requestBody = {
environmentKey,
instructions: [{ kind: 'turnFlagOn' }],
};
do_request(requestInfo, requestBody);
See the patchFeatureFlag
REST API docs
I couldn't find this functionality exposed on the FeatureFlagsApi
object in this API. Is that an accidental omission? Or did I miss it somewhere?
The version of axios in use (0.26.1) has a moderate-severity vulnerability CVE-2023-45857
.
This is fixed in version 1.6.0 and above.
I'm using this library in a Node project but at the time of building it in my server it fails with a Javascript out of memory
message.
It seems to happen as soon as I create an apiInstance
const apiInstance = new FeatureFlagsApi(config);
For now I will have to refactor and deploy code using the fetch api to interact with the LaunchDarkly API directly.
It would be very useful to have api/v2/caller-identity
be exposed through this library.
Hey, thanks for publishing this client. But how is it meant to be consumed? The repo doesn't have a package.json file, which prevents it from being installed as a git dependency and I also couldn't find it on npm.
I thought maybe you intend users to vendor the api.ts
file, but then I realized that it actually has some dependencies. Installing those and crossing fingers that they line up sounds very brittle.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.