Skip to content

Commit

Permalink
feat: create typescript module (#168)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Lamb <[email protected]>
  • Loading branch information
cwaldren-ld and kinyoklion authored Oct 29, 2024
1 parent 337e0ef commit 7c363ad
Show file tree
Hide file tree
Showing 19 changed files with 4,562 additions and 5 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Test API Module
run: cd api && go test ./...
- name: Test Tool Module
- name: Test Go Tool Module
run: cd tool && go test ./...
- name: Test Go API
run: cd api && go test ./...
- name: Setup node
uses: actions/setup-node@v4
- name: Build JS API
run: cd api/sdkmeta-js && npm install && npm run build
- name: Test JS API
run: cd api/sdkmeta-js && npm test
- name: Sanity test
run: |
cd tool && go run ./cmd/ingest -db test.sqlite3 \
Expand Down
2 changes: 0 additions & 2 deletions CODEOWNERS.md

This file was deleted.

2 changes: 2 additions & 0 deletions api/sdkmeta-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
dist
13 changes: 13 additions & 0 deletions api/sdkmeta-js/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"verbose": true,
"testPathIgnorePatterns": ["./dist", "./src"],
"testMatch": ["**.test.ts"],
"transform": {
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "tsconfig.test.json"
}
]
}
}
39 changes: 39 additions & 0 deletions api/sdkmeta-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@launchdarkly/sdk-meta",
"version": "0.0.1",
"description": "LaunchDarkly SDK Metadata",
"license": "Apache-2.0",
"homepage": "https://github.com/launchdarkly/sdk-meta/tree/main",
"repository": {
"type": "git",
"url": "https://github.com/launchdarkly/sdk-meta.git"
},
"scripts": {
"test": "jest",
"build": "tsup",
"prepare": "npm run build"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
},
"type": "module",
"main": "./dist/SDKMeta.cjs",
"module": "./dist/SDKMeta.js",
"types": "./dist/SDKMeta.d.ts",
"exports": {
".": {
"require": {
"types": "./dist/SDKMeta.d.cts",
"require": "./dist/SDKMeta.cjs"
},
"import": {
"types": "./dist/SDKMeta.d.ts",
"import": "./dist/SDKMeta.js"
}
}
}
}
37 changes: 37 additions & 0 deletions api/sdkmeta-js/src/SDKMeta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sdkLanguages from './data/languages.json'
import sdkRepos from './data/repos.json'
import sdkNames from './data/names.json'
import sdkTypes from './data/types.json'
import sdkPopularity from './data/popularity.json'

export enum Type {
// ClientSide is an SDK that runs in a client scenario.
ClientSide = "client-side",
// ServerSide is an SDK that runs in a server scenario.
ServerSide = "server-side",
// Edge is an SDK that runs in an edge deployment scenario.
Edge = "edge",
// Relay is Relay Proxy.
Relay = "relay",
// Unknown if the SDK's type is not recognized.
Unknown = "unknown"
}

function isType(value: string): value is Type {
return Object.values(Type).includes(value as Type);
}

export type Repo = {
github: string;
}

export const Languages: Record<string, string[]> = sdkLanguages;
export const Names: Record<string, string> = sdkNames;
export const Repos: Record<string, Repo> = sdkRepos;
export const Popularity: Record<string, number> = sdkPopularity;

export const Types: Record<string, Type> = Object.fromEntries(
Object.entries(sdkTypes).map(([key, value]) => [
key,
isType(value) ? value : Type.Unknown
]));
94 changes: 94 additions & 0 deletions api/sdkmeta-js/src/data/feature_info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"allFlags": {
"description": "Return the flag variations for all feature flags for a given context.",
"name": "Getting all flags"
},
"appMetadata": {
"description": "Specify application and application version information.",
"name": "Application metadata"
},
"autoEnvAttrs": {
"description": "Automatically include device and application data in each evaluated context.",
"name": "Automatic environment attributes"
},
"bigSegments": {
"description": "Configure a persistent store to hold segments that are either synced from external tools, or that contain an arbitrarily large number of contexts of any one context kind.",
"name": "Big segments"
},
"bootstrapping": {
"description": "Provide an initial set of flag values that are immediately available during client initialization.",
"name": "Bootstrapping"
},
"contexts": {
"description": "Evaluate flags based on contexts. A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags. SDKs without this feature only support flag evaluation for users.",
"name": "Contexts and context kinds"
},
"experimentation": {
"description": "Connect a flag with one or more metrics to measure end-user behavior for different variations of a flag. Requires minimum SDK versions, but no SDK configuration.",
"name": "Experimentation"
},
"fileDataSource": {
"description": "Use flag values, specified in JSON or YAML files, for all flag evaluations. Useful for testing or prototyping; do not use in production.",
"name": "Reading flags from a file"
},
"flagChanges": {
"description": "Use a listener pattern to subscribe to flag change notifications.",
"name": "Subscribing to flag changes"
},
"hooks": {
"description": "Define callbacks that are executed by the SDK at various points of interest, usually for metrics or tracing.",
"name": "Hooks"
},
"migrations": {
"description": "Configure how to read and write data for an old and new system, determine which stage of a migration the application is in, execute the correct read and write calls for each stage.",
"name": "Migration flags"
},
"multiEnv": {
"description": "Evaluate flags from multiple environments using a single client instance",
"name": "Multiple environments"
},
"offlineMode": {
"description": "Close the SDK's connection to LaunchDarkly. Use cached or fallback values for each flag evaluation.",
"name": "Offline mode"
},
"otel": {
"description": "Add flag evaluation information to OpenTelemetry spans.",
"name": "OpenTelemetry"
},
"privateAttrs": {
"description": "Use context attribute values for targeting, but do not send them to LaunchDarkly.",
"name": "Private attributes"
},
"relayProxyDaemon": {
"description": "Configure the SDK to connect to a persistent store, such as the Relay Proxy's data store.",
"name": "Relay Proxy in daemon mode"
},
"relayProxyProxy": {
"description": "Configure the SDK to connect to alternate service endpoints, such as the Relay Proxy.",
"name": "Relay Proxy in proxy mode"
},
"secureMode": {
"description": "For clent-side SDKs, require a hash, signed with the SDK key for the LaunchDarkly environment, to evaluate flag variations. For server-side or edge SDKs, generate a secure mode hash.",
"name": "Secure mode"
},
"storingData": {
"description": "Configure an external database as a feature store. Persist flag data across application restarts.",
"name": "Storing data"
},
"testDataSource": {
"description": "Mock data of an SDK. Useful for unit tests; cannot be used in production.",
"name": "Test data sources"
},
"track": {
"description": "Record actions taken in your application as events. You can connect to these events to metrics for use in experiments.",
"name": "Sending custom events"
},
"variationDetail": {
"description": "Receive information about how a flag variation was calculated, for example, because it matched a specific targeting rule.",
"name": "Flag evaluation reasons"
},
"webProxy": {
"description": "Configure the SDK to connect to LaunchDarkly through a web proxy.",
"name": "Web proxy configuration"
}
}
9 changes: 9 additions & 0 deletions api/sdkmeta-js/src/data/features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dotnet-server-sdk": {
"hooks": {
"deprecated": null,
"introduced": "8.3",
"removed": null
}
}
}
108 changes: 108 additions & 0 deletions api/sdkmeta-js/src/data/languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"akamai-base": [
"JavaScript",
"TypeScript"
],
"akamai-edgekv": [
"JavaScript",
"TypeScript"
],
"android": [
"Java",
"Kotlin"
],
"apex-server-sdk": [
"Apex"
],
"cloudflare": [
"JavaScript",
"TypeScript"
],
"cpp-client-sdk": [
"C++",
"C"
],
"cpp-server-sdk": [
"C++",
"C"
],
"dotnet-client-sdk": [
"C#"
],
"dotnet-server-sdk": [
"C#"
],
"electron": [
"JavaScript",
"TypeScript"
],
"erlang-server-sdk": [
"Erlang",
"Elixir"
],
"flutter-client-sdk": [
"Dart"
],
"go-server-sdk": [
"Go"
],
"haskell-server-sdk": [
"Haskell"
],
"java-server-sdk": [
"Java"
],
"js-client-sdk": [
"JavaScript",
"TypeScript"
],
"lua-server-sdk": [
"Lua"
],
"node-client-sdk": [
"JavaScript",
"TypeScript"
],
"node-server": [
"JavaScript",
"TypeScript"
],
"php-server-sdk": [
"PHP"
],
"python-server-sdk": [
"Python"
],
"react-client-sdk": [
"JavaScript",
"TypeScript"
],
"react-native": [
"JavaScript",
"TypeScript"
],
"relay-proxy": [
"Go"
],
"roku": [
"BrightScript"
],
"ruby-server-sdk": [
"Ruby"
],
"rust-server-sdk": [
"Rust"
],
"swift-client-sdk": [
"Swift",
"Objective-C"
],
"vercel": [
"JavaScript",
"TypeScript"
],
"vue": [
"JavaScript",
"TypeScript"
]
}
32 changes: 32 additions & 0 deletions api/sdkmeta-js/src/data/names.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"akamai-base": "Akamai SDK",
"akamai-edgekv": "Akamai SDK for EdgeKV",
"android": "Android SDK",
"apex-server-sdk": "Apex Server SDK",
"cloudflare": "Cloudflare SDK",
"cpp-client-sdk": "C++ Client SDK",
"cpp-server-sdk": "C++ Server SDK",
"dotnet-client-sdk": ".NET Client SDK",
"dotnet-server-sdk": ".NET Server SDK",
"electron": "Electron SDK",
"erlang-server-sdk": "Erlang Server SDK",
"flutter-client-sdk": "Flutter Client SDK",
"go-server-sdk": "Go Server SDK",
"haskell-server-sdk": "Haskell Server SDK",
"java-server-sdk": "Java Server SDK",
"js-client-sdk": "JavaScript Client SDK",
"lua-server-sdk": "Lua Server SDK",
"node-client-sdk": "Node.js Client SDK",
"node-server": "Node.js Server SDK",
"php-server-sdk": "PHP SDK",
"python-server-sdk": "Python Server SDK",
"react-client-sdk": "React Web SDK",
"react-native": "React Native SDK",
"relay-proxy": "Relay Proxy",
"roku": "Roku SDK",
"ruby-server-sdk": "Ruby Server SDK",
"rust-server-sdk": "Rust Server SDK",
"swift-client-sdk": "iOS SDK",
"vercel": "Vercel Edge SDK",
"vue": "Vue SDK"
}
25 changes: 25 additions & 0 deletions api/sdkmeta-js/src/data/popularity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"android": 10,
"cpp-client-sdk": 17,
"cpp-server-sdk": 20,
"dotnet-client-sdk": 14,
"dotnet-server-sdk": 5,
"erlang-server-sdk": 15,
"flutter-client-sdk": 13,
"go-server-sdk": 9,
"haskell-server-sdk": 22,
"java-server-sdk": 4,
"js-client-sdk": 6,
"lua-server-sdk": 21,
"node-client-sdk": 19,
"node-server": 2,
"php-server-sdk": 23,
"python-server-sdk": 3,
"react-client-sdk": 1,
"react-native": 11,
"roku": 18,
"ruby-server-sdk": 12,
"rust-server-sdk": 16,
"swift-client-sdk": 8,
"vue": 7
}
Loading

0 comments on commit 7c363ad

Please sign in to comment.