Skip to content

Commit

Permalink
Merge branch 'main' into yus/sc-214758/send-events-to-environment-end…
Browse files Browse the repository at this point in the history
…point-for-edge
  • Loading branch information
yusinto committed Sep 21, 2023
2 parents ad7d012 + 7693170 commit 303e3ae
Show file tree
Hide file tree
Showing 35 changed files with 291 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/jest*.ts', '**/*.test.ts'],
devDependencies: ['**/jest*.ts', '**/*.test.ts', '**/rollup.config.ts'],
},
],
},
Expand Down
20 changes: 10 additions & 10 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"packages/shared/common": "1.1.0",
"packages/shared/sdk-server": "1.2.2",
"packages/sdk/server-node": "8.2.3",
"packages/sdk/cloudflare": "2.1.3",
"packages/shared/sdk-server-edge": "1.0.12",
"packages/sdk/vercel": "1.1.3",
"packages/sdk/akamai-base": "1.0.6",
"packages/sdk/akamai-edgekv": "1.0.6",
"packages/shared/akamai-edgeworker-sdk": "0.3.3",
"packages/store/node-server-sdk-dynamodb": "5.0.10",
"packages/store/node-server-sdk-redis": "3.0.10"
"packages/shared/sdk-server": "1.2.3",
"packages/sdk/server-node": "8.2.4",
"packages/sdk/cloudflare": "2.2.0",
"packages/shared/sdk-server-edge": "1.0.13",
"packages/sdk/vercel": "1.1.4",
"packages/sdk/akamai-base": "1.0.7",
"packages/sdk/akamai-edgekv": "1.0.7",
"packages/shared/akamai-edgeworker-sdk": "0.3.4",
"packages/store/node-server-sdk-dynamodb": "5.0.11",
"packages/store/node-server-sdk-redis": "3.0.11"
}
13 changes: 13 additions & 0 deletions packages/sdk/akamai-base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to the LaunchDarkly SDK for Akamai Workers will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).

## [1.0.7](https://github.com/launchdarkly/js-core/compare/akamai-server-base-sdk-v1.0.6...akamai-server-base-sdk-v1.0.7) (2023-09-06)

### Bug Fixes

* Use clientSideAvailability instead of clientSide for filtering client side flags. ([#270](https://github.com/launchdarkly/js-core/issues/270)) ([2702342](https://github.com/launchdarkly/js-core/commit/27023429d36986466cda46aa4d95eb01c10cd455))

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^0.3.3 to ^0.3.4
* @launchdarkly/js-server-sdk-common bumped from ^1.2.2 to ^1.2.3

### Dependencies

* The following workspace dependencies were updated
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/akamai-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchdarkly/akamai-server-base-sdk",
"version": "1.0.6",
"version": "1.0.7",
"description": "Akamai LaunchDarkly EdgeWorker SDK",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/akamai-base",
"repository": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"typescript": "5.1.6"
},
"dependencies": {
"@launchdarkly/akamai-edgeworker-sdk-common": "^0.3.3",
"@launchdarkly/js-server-sdk-common": "^1.2.2"
"@launchdarkly/akamai-edgeworker-sdk-common": "^0.3.4",
"@launchdarkly/js-server-sdk-common": "^1.2.3"
}
}
13 changes: 13 additions & 0 deletions packages/sdk/akamai-edgekv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to the LaunchDarkly SDK for Akamai Workers will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).

## [1.0.7](https://github.com/launchdarkly/js-core/compare/akamai-server-edgekv-sdk-v1.0.6...akamai-server-edgekv-sdk-v1.0.7) (2023-08-14)

### Bug Fixes

* Use clientSideAvailability instead of clientSide for filtering client side flags. ([#270](https://github.com/launchdarkly/js-core/issues/270)) ([2702342](https://github.com/launchdarkly/js-core/commit/27023429d36986466cda46aa4d95eb01c10cd455))

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^0.3.3 to ^0.3.4
* @launchdarkly/js-server-sdk-common bumped from ^1.2.2 to ^1.2.3

### Dependencies

* The following workspace dependencies were updated
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/akamai-edgekv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchdarkly/akamai-server-edgekv-sdk",
"version": "1.0.6",
"version": "1.0.7",
"description": "Akamai LaunchDarkly EdgeWorker SDK for EdgeKV feature store",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/akamai-edgekv",
"repository": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"typescript": "5.1.6"
},
"dependencies": {
"@launchdarkly/akamai-edgeworker-sdk-common": "^0.3.3",
"@launchdarkly/js-server-sdk-common": "^1.2.2"
"@launchdarkly/akamai-edgeworker-sdk-common": "^0.3.4",
"@launchdarkly/js-server-sdk-common": "^1.2.3"
}
}
20 changes: 20 additions & 0 deletions packages/sdk/cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

All notable changes to the LaunchDarkly SDK for Cloudflare Workers will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).

## [2.2.0](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v2.1.4...cloudflare-server-sdk-v2.2.0) (2023-09-21)


### Features

* rollup cloudflare sdk ([#279](https://github.com/launchdarkly/js-core/issues/279)) ([7af4f6e](https://github.com/launchdarkly/js-core/commit/7af4f6e2d029b87396087d96904cdfa7d39a8cb3))

## [2.1.4](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v2.1.3...cloudflare-server-sdk-v2.1.4) (2023-09-06)

### Bug Fixes

* Use clientSideAvailability instead of clientSide for filtering client side flags. ([#270](https://github.com/launchdarkly/js-core/issues/270)) ([2702342](https://github.com/launchdarkly/js-core/commit/27023429d36986466cda46aa4d95eb01c10cd455))

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @launchdarkly/js-server-sdk-common-edge bumped from 1.0.12 to 1.0.13

### Dependencies

* The following workspace dependencies were updated
Expand All @@ -14,6 +33,7 @@ All notable changes to the LaunchDarkly SDK for Cloudflare Workers will be docum
* dependencies
* @launchdarkly/js-server-sdk-common-edge bumped from 1.0.11 to 1.0.12


## [2.1.1](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v2.1.0...cloudflare-server-sdk-v2.1.1) (2023-08-14)

Updated common dependency includes performance improvements.
Expand Down
11 changes: 5 additions & 6 deletions packages/sdk/cloudflare/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"module": "./dist/index.mjs",
"packageManager": "[email protected]",
"dependencies": {
"@launchdarkly/cloudflare-server-sdk": "^2.0.2"
"@launchdarkly/cloudflare-server-sdk": "^2.1.4"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230321.0",
Expand All @@ -17,14 +17,13 @@
"prettier": "^2.6.2",
"ts-jest": "^28.0.3",
"typescript": "5.1.6",
"wrangler": "2.13.0"
"wrangler": "2.20.1"
},
"scripts": {
"build": "yarn && yarn link-dev && node build.js",
"build": "node build.js",
"start": "wrangler dev",
"deploy": "wrangler publish",
"test": "yarn build && node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js",
"clean": "rm -rf dist && rm -rf node_modules && rm -rf .yarn/cache && yarn build",
"link-dev": "cd ../../../../ && yarn link-dev"
"test": "yarn build && jest",
"clean": "rm -rf dist && rm -rf node_modules && rm -rf .yarn/cache && yarn build"
}
}
25 changes: 16 additions & 9 deletions packages/sdk/cloudflare/example/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import app from './index';
import testData from './testData.json';

test('variation true', async () => {
// arrange
const env = getMiniflareBindings();
const { LD_KV } = env;
await LD_KV.put('LD-Env-test-sdk-key', JSON.stringify(testData));
describe('test', () => {
let env: Bindings;

// act
const res = await app.fetch(new Request('http://localhost'), env);
beforeEach(async () => {
env = getMiniflareBindings();
const { LD_KV } = env;
await LD_KV.put('LD-Env-test-sdk-key', JSON.stringify(testData));
});

// assert
expect(await res.text()).toContain('testFlag1: true');
test('variation true', async () => {
const res = await app.fetch(new Request('http://localhost/?email=truemail'), env);
expect(await res.text()).toContain('testFlag1: true');
});

test('variation false', async () => {
const res = await app.fetch(new Request('http://localhost/?email=falsemail'), env);
expect(await res.text()).toContain('testFlag1: false');
});
});
6 changes: 5 additions & 1 deletion packages/sdk/cloudflare/example/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const handler: ExportedHandler<Bindings> = {
): Promise<Response> {
const clientSideID = 'client-side-id';
const flagKey = 'testFlag1';
const context = { kind: 'org', key: 'org-key-cf', email: '[email protected]' };
const { searchParams } = new URL(request.url);

// falsemail will return false, other emails return true
const email = searchParams.get('email') ?? '[email protected]';
const context = { kind: 'user', key: 'test-user-key-1', email };

// start using ld
const client = initLD(clientSideID, env.LD_KV, { sendEvents: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/cloudflare/example/src/testData.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"contextKind": "user",
"attribute": "/email",
"op": "contains",
"values": ["gmail"],
"values": ["falsemail"],
"negate": false
}
],
Expand Down
37 changes: 27 additions & 10 deletions packages/sdk/cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchdarkly/cloudflare-server-sdk",
"version": "2.1.3",
"version": "2.2.0",
"description": "Cloudflare LaunchDarkly SDK",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare",
"repository": {
Expand All @@ -17,34 +17,43 @@
],
"type": "module",
"exports": {
"require": "./dist/cjs/src/index.js",
"import": "./dist/esm/src/index.js"
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"main": "./dist/cjs/src/index.js",
"types": "./dist/cjs/src/index.d.ts",
"main": "./dist/cjs/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "../../../scripts/build-package.sh",
"clean": "rimraf dist",
"rb": "rollup -c --configPlugin typescript",
"rbw": "yarn rb --watch",
"build": "yarn clean && yarn rb",
"tsw": "yarn tsc --watch",
"start": "rimraf dist && yarn tsw",
"lint": "eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand",
"coverage": "yarn test --coverage",
"check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
"check": "yarn prettier && yarn lint && yarn build && yarn test"
},
"dependencies": {
"@cloudflare/workers-types": "^4.20230321.0",
"@launchdarkly/js-server-sdk-common-edge": "1.0.12",
"crypto-js": "^4.1.1"
},
"devDependencies": {
"@launchdarkly/js-server-sdk-common-edge": "1.0.13",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.3",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.0",
"@types/rollup-plugin-generate-package-json": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
Expand All @@ -57,9 +66,17 @@
"launchdarkly-js-test-helpers": "^2.2.0",
"miniflare": "^2.13.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.0",
"rimraf": "^5.0.1",
"rollup": "^3.29.2",
"rollup-plugin-dts": "^6.0.2",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-generate-package-json": "^3.2.0",
"ts-jest": "^29.1.0",
"typedoc": "0.25.0",
"typescript": "5.1.6"
}
},
"bundledDependencies": [
"@launchdarkly/js-server-sdk-common-edge"
]
}
53 changes: 53 additions & 0 deletions packages/sdk/cloudflare/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import filesize from 'rollup-plugin-filesize';

const inputPath = 'src/index.ts';
const cjsPath = 'dist/cjs/index.js';
const esmPath = 'dist/esm/index.js';
const typingsPath = 'dist/index.d.ts';

const plugins = [resolve(), commonjs(), esbuild(), json(), terser(), filesize()];

// the second array item is a function to include all js-core packages in the bundle so they
// are not imported or required as separate npm packages
const external = [/node_modules/, (id: string) => !id.includes('js-core')];

export default [
{
input: inputPath,
output: [
{
file: cjsPath,
format: 'cjs',
sourcemap: true,
},
],
plugins,
external,
},
{
input: inputPath,
output: [
{
file: esmPath,
format: 'esm',
sourcemap: true,
},
],
plugins,
external,
},
{
input: inputPath,
plugins: [dts(), json()],
output: {
file: typingsPath,
format: 'esm',
},
},
];
2 changes: 1 addition & 1 deletion packages/sdk/cloudflare/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('init', () => {
});

test('rule match', async () => {
const contextWithEmail = { ...context, email: 'test@gmail.com' };
const contextWithEmail = { ...context, email: 'test@falsemail.com' };
const value = await ldClient.variation(flagKey1, contextWithEmail, false);
const detail = await ldClient.variationDetail(flagKey1, contextWithEmail, false);

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/cloudflare/src/testData.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"contextKind": "user",
"attribute": "/email",
"op": "contains",
"values": ["gmail"],
"values": ["falsemail"],
"negate": false
}
],
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// Uses "." so it can load package.json.
"rootDir": ".",
"outDir": "dist",
"target": "es2017",
"target": "ES2017",
"lib": ["es6"],
"module": "commonjs",
"module": "ES6",
"strict": true,
"noImplicitOverride": true,
"allowSyntheticDefaultImports": true,
Expand Down
Loading

0 comments on commit 303e3ae

Please sign in to comment.