@datadog/flagging-core 0.1.0-alpha.8 → 0.1.0-preview.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/cache/abstract-assignment-cache.d.ts +39 -0
- package/cjs/cache/abstract-assignment-cache.d.ts.map +1 -0
- package/cjs/cache/abstract-assignment-cache.js +59 -0
- package/cjs/cache/abstract-assignment-cache.js.map +1 -0
- package/cjs/cache/index.d.ts +4 -0
- package/cjs/cache/index.d.ts.map +1 -0
- package/cjs/cache/index.js +20 -0
- package/cjs/cache/index.js.map +1 -0
- package/cjs/cache/lru-cache.d.ts +31 -0
- package/cjs/cache/lru-cache.d.ts.map +1 -0
- package/cjs/cache/lru-cache.js +85 -0
- package/cjs/cache/lru-cache.js.map +1 -0
- package/cjs/cache/lru-in-memory-assignment-cache.d.ts +16 -0
- package/cjs/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
- package/cjs/cache/lru-in-memory-assignment-cache.js +22 -0
- package/cjs/cache/lru-in-memory-assignment-cache.js.map +1 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.js +17 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
- package/cjs/configuration/configuration.d.ts +14 -8
- package/cjs/configuration/configuration.d.ts.map +1 -1
- package/cjs/configuration/exposureEvent.d.ts +4 -0
- package/cjs/configuration/exposureEvent.d.ts.map +1 -0
- package/cjs/configuration/exposureEvent.js +33 -0
- package/cjs/configuration/exposureEvent.js.map +1 -0
- package/cjs/configuration/exposureEvent.types.d.ts +21 -0
- package/cjs/configuration/exposureEvent.types.d.ts.map +1 -0
- package/cjs/configuration/exposureEvent.types.js +3 -0
- package/cjs/configuration/exposureEvent.types.js.map +1 -0
- package/cjs/configuration/index.d.ts +2 -0
- package/cjs/configuration/index.d.ts.map +1 -1
- package/cjs/configuration/index.js +2 -0
- package/cjs/configuration/index.js.map +1 -1
- package/cjs/configuration/wire.d.ts +3 -3
- package/cjs/configuration/wire.d.ts.map +1 -1
- package/cjs/configuration/wire.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +3 -1
- package/cjs/index.js.map +1 -1
- package/cjs/obfuscation.d.ts +9 -0
- package/cjs/obfuscation.d.ts.map +1 -0
- package/cjs/obfuscation.js +23 -0
- package/cjs/obfuscation.js.map +1 -0
- package/esm/cache/abstract-assignment-cache.d.ts +39 -0
- package/esm/cache/abstract-assignment-cache.d.ts.map +1 -0
- package/esm/cache/abstract-assignment-cache.js +53 -0
- package/esm/cache/abstract-assignment-cache.js.map +1 -0
- package/esm/cache/index.d.ts +4 -0
- package/esm/cache/index.d.ts.map +1 -0
- package/esm/cache/index.js +4 -0
- package/esm/cache/index.js.map +1 -0
- package/esm/cache/lru-cache.d.ts +31 -0
- package/esm/cache/lru-cache.d.ts.map +1 -0
- package/esm/cache/lru-cache.js +81 -0
- package/esm/cache/lru-cache.js.map +1 -0
- package/esm/cache/lru-in-memory-assignment-cache.d.ts +16 -0
- package/esm/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
- package/esm/cache/lru-in-memory-assignment-cache.js +18 -0
- package/esm/cache/lru-in-memory-assignment-cache.js.map +1 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.js +13 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
- package/esm/configuration/configuration.d.ts +52 -0
- package/esm/configuration/configuration.d.ts.map +1 -0
- package/esm/configuration/configuration.js +2 -0
- package/esm/configuration/configuration.js.map +1 -0
- package/esm/configuration/exposureEvent.d.ts +4 -0
- package/esm/configuration/exposureEvent.d.ts.map +1 -0
- package/esm/configuration/exposureEvent.js +30 -0
- package/esm/configuration/exposureEvent.js.map +1 -0
- package/esm/configuration/exposureEvent.types.d.ts +21 -0
- package/esm/configuration/exposureEvent.types.d.ts.map +1 -0
- package/esm/configuration/exposureEvent.types.js +2 -0
- package/esm/configuration/exposureEvent.types.js.map +1 -0
- package/esm/configuration/index.d.ts +5 -0
- package/esm/configuration/index.d.ts.map +1 -0
- package/esm/configuration/index.js +5 -0
- package/esm/configuration/index.js.map +1 -0
- package/esm/configuration/wire.d.ts +12 -0
- package/esm/configuration/wire.d.ts.map +1 -0
- package/esm/configuration/wire.js +41 -0
- package/esm/configuration/wire.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +6 -0
- package/esm/index.js.map +1 -0
- package/esm/obfuscation.d.ts +9 -0
- package/esm/obfuscation.d.ts.map +1 -0
- package/esm/obfuscation.js +16 -0
- package/esm/obfuscation.js.map +1 -0
- package/package.json +14 -9
- package/jest.config.js +0 -15
- package/src/configuration/configuration.ts +0 -57
- package/src/configuration/index.ts +0 -2
- package/src/configuration/wire.ts +0 -58
- package/src/global.d.ts +0 -3
- package/src/index.ts +0 -4
- package/tsconfig.cjs.json +0 -13
- package/tsconfig.esm.json +0 -13
- package/tsconfig.json +0 -12
- package/tsconfig.test.json +0 -8
- package/webpack.config.js +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/flagging-core",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-preview.10",
|
|
4
4
|
"description": "Runtime-agnostic flag-evaluation logic for Datadog Flagging",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"url": "https://github.com/DataDog/openfeature-js-client.git",
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"cjs/",
|
|
13
|
+
"esm/",
|
|
14
|
+
"*.d.ts"
|
|
15
|
+
],
|
|
11
16
|
"publishConfig": {
|
|
12
17
|
"access": "public",
|
|
13
18
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -18,8 +23,7 @@
|
|
|
18
23
|
"scripts": {
|
|
19
24
|
"prepack": "yarn build",
|
|
20
25
|
"pack": "yarn pack",
|
|
21
|
-
"build": "run-p build:cjs build:esm
|
|
22
|
-
"build:bundle": "rm -rf bundle && SDK_SETUP=cdn node ../../scripts/webpack-runner.js webpack.config.js --mode=production",
|
|
26
|
+
"build": "run-p build:cjs build:esm",
|
|
23
27
|
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
|
|
24
28
|
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
|
|
25
29
|
"replace-build-env": "node ../../scripts/build/replace-build-env.js",
|
|
@@ -28,19 +32,20 @@
|
|
|
28
32
|
"typecheck": "tsc --noEmit"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
35
|
+
"@openfeature/core": "^1.8.1",
|
|
31
36
|
"@types/jest": "^29.4.0",
|
|
32
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^18.0.0",
|
|
38
|
+
"@types/spark-md5": "^3.0.5",
|
|
33
39
|
"jest": "^30.0.4",
|
|
34
40
|
"npm-run-all": "^4.1.5",
|
|
35
41
|
"ts-jest": "^29.4.0",
|
|
36
42
|
"ts-loader": "^9.5.2",
|
|
37
43
|
"typescript": "^5.5.0"
|
|
38
44
|
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@openfeature/core": "^1.8.1",
|
|
41
|
-
"@openfeature/web-sdk": "^1.5.0"
|
|
42
|
-
},
|
|
43
45
|
"peerDependencies": {
|
|
44
|
-
"
|
|
46
|
+
"@openfeature/core": "^1.8.1"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"spark-md5": "^3.0.2"
|
|
45
50
|
}
|
|
46
51
|
}
|
package/jest.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
transform: {
|
|
5
|
-
'^.+\\.ts$': [
|
|
6
|
-
'ts-jest',
|
|
7
|
-
{
|
|
8
|
-
tsconfig: 'tsconfig.test.json',
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
testMatch: ['**/*.spec.ts', '**/*.test.ts'],
|
|
13
|
-
moduleFileExtensions: ['ts', 'js', 'json'],
|
|
14
|
-
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'],
|
|
15
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
EvaluationContext,
|
|
3
|
-
FlagValueType,
|
|
4
|
-
JsonValue,
|
|
5
|
-
ResolutionReason,
|
|
6
|
-
} from '@openfeature/web-sdk'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal configuration for DatadogProvider.
|
|
10
|
-
*/
|
|
11
|
-
export type Configuration = {
|
|
12
|
-
/** @internal */
|
|
13
|
-
precomputed?: PrecomputedConfiguration
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export type PrecomputedConfiguration = {
|
|
18
|
-
response: PrecomputedConfigurationResponse
|
|
19
|
-
context?: EvaluationContext
|
|
20
|
-
fetchedAt?: UnixTimestamp
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Fancy way to map FlagValueType to expected FlagValue.
|
|
24
|
-
/** @internal */
|
|
25
|
-
export type FlagTypeToValue<T extends FlagValueType> = {
|
|
26
|
-
['boolean']: boolean
|
|
27
|
-
['string']: string
|
|
28
|
-
['number']: number
|
|
29
|
-
['object']: JsonValue
|
|
30
|
-
}[T]
|
|
31
|
-
|
|
32
|
-
/** @internal
|
|
33
|
-
* Timestamp in milliseconds since Unix Epoch.
|
|
34
|
-
*/
|
|
35
|
-
export type UnixTimestamp = number
|
|
36
|
-
|
|
37
|
-
/** @internal */
|
|
38
|
-
export type PrecomputedConfigurationResponse = {
|
|
39
|
-
data: {
|
|
40
|
-
attributes: {
|
|
41
|
-
/** When configuration was generated. */
|
|
42
|
-
createdAt: number
|
|
43
|
-
flags: Record<string, PrecomputedFlag>
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** @internal */
|
|
49
|
-
export type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
50
|
-
allocationKey: string
|
|
51
|
-
variationKey: string
|
|
52
|
-
variationType: T
|
|
53
|
-
variationValue: FlagTypeToValue<T>
|
|
54
|
-
reason: ResolutionReason
|
|
55
|
-
doLog: boolean
|
|
56
|
-
extraLogging: Record<string, unknown>
|
|
57
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { EvaluationContext } from '@openfeature/web-sdk'
|
|
2
|
-
|
|
3
|
-
import type { Configuration, UnixTimestamp } from './configuration'
|
|
4
|
-
|
|
5
|
-
type ConfigurationWire = {
|
|
6
|
-
version: 1
|
|
7
|
-
precomputed?: {
|
|
8
|
-
context?: EvaluationContext
|
|
9
|
-
response: string
|
|
10
|
-
fetchedAt?: UnixTimestamp
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Create configuration from a string created with `configurationToString`.
|
|
16
|
-
*/
|
|
17
|
-
export function configurationFromString(s: string): Configuration {
|
|
18
|
-
try {
|
|
19
|
-
const wire: ConfigurationWire = JSON.parse(s)
|
|
20
|
-
|
|
21
|
-
if (wire.version !== 1) {
|
|
22
|
-
// Unknown version
|
|
23
|
-
return {}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const configuration: Configuration = {}
|
|
27
|
-
if (wire.precomputed) {
|
|
28
|
-
configuration.precomputed = {
|
|
29
|
-
...wire.precomputed,
|
|
30
|
-
response: JSON.parse(wire.precomputed.response),
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return configuration
|
|
35
|
-
} catch {
|
|
36
|
-
return {}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Serialize configuration to string that can be deserialized with
|
|
42
|
-
* `configurationFromString`. The serialized string format is
|
|
43
|
-
* unspecified.
|
|
44
|
-
*/
|
|
45
|
-
export function configurationToString(configuration: Configuration): string {
|
|
46
|
-
const wire: ConfigurationWire = {
|
|
47
|
-
version: 1,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (configuration.precomputed) {
|
|
51
|
-
wire.precomputed = {
|
|
52
|
-
...configuration.precomputed,
|
|
53
|
-
response: JSON.stringify(configuration.precomputed),
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return JSON.stringify(wire)
|
|
58
|
-
}
|
package/src/global.d.ts
DELETED
package/src/index.ts
DELETED
package/tsconfig.cjs.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"target": "es2018",
|
|
6
|
-
"outDir": "cjs",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"sourceMap": true
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*"],
|
|
12
|
-
"exclude": ["**/*.test.ts", "**/*.spec.ts", "test/**/*"]
|
|
13
|
-
}
|
package/tsconfig.esm.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "es2020",
|
|
5
|
-
"target": "es2018",
|
|
6
|
-
"outDir": "esm",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"sourceMap": true
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*"],
|
|
12
|
-
"exclude": ["**/*.test.ts", "**/*.spec.ts", "test/**/*"]
|
|
13
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"rootDir": "./src/",
|
|
7
|
-
"outDir": "./dist/",
|
|
8
|
-
"types": ["jest", "node"]
|
|
9
|
-
},
|
|
10
|
-
"include": ["./src/**/*.ts", "./src/**/*.d.ts"],
|
|
11
|
-
"exclude": ["./src/**/*.spec.ts", "./src/**/*.specHelper.ts"]
|
|
12
|
-
}
|
package/tsconfig.test.json
DELETED
package/webpack.config.js
DELETED