@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.
Files changed (105) hide show
  1. package/cjs/cache/abstract-assignment-cache.d.ts +39 -0
  2. package/cjs/cache/abstract-assignment-cache.d.ts.map +1 -0
  3. package/cjs/cache/abstract-assignment-cache.js +59 -0
  4. package/cjs/cache/abstract-assignment-cache.js.map +1 -0
  5. package/cjs/cache/index.d.ts +4 -0
  6. package/cjs/cache/index.d.ts.map +1 -0
  7. package/cjs/cache/index.js +20 -0
  8. package/cjs/cache/index.js.map +1 -0
  9. package/cjs/cache/lru-cache.d.ts +31 -0
  10. package/cjs/cache/lru-cache.d.ts.map +1 -0
  11. package/cjs/cache/lru-cache.js +85 -0
  12. package/cjs/cache/lru-cache.js.map +1 -0
  13. package/cjs/cache/lru-in-memory-assignment-cache.d.ts +16 -0
  14. package/cjs/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
  15. package/cjs/cache/lru-in-memory-assignment-cache.js +22 -0
  16. package/cjs/cache/lru-in-memory-assignment-cache.js.map +1 -0
  17. package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
  18. package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
  19. package/cjs/cache/non-expiring-in-memory-cache-assignment.js +17 -0
  20. package/cjs/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
  21. package/cjs/configuration/configuration.d.ts +14 -8
  22. package/cjs/configuration/configuration.d.ts.map +1 -1
  23. package/cjs/configuration/exposureEvent.d.ts +4 -0
  24. package/cjs/configuration/exposureEvent.d.ts.map +1 -0
  25. package/cjs/configuration/exposureEvent.js +33 -0
  26. package/cjs/configuration/exposureEvent.js.map +1 -0
  27. package/cjs/configuration/exposureEvent.types.d.ts +21 -0
  28. package/cjs/configuration/exposureEvent.types.d.ts.map +1 -0
  29. package/cjs/configuration/exposureEvent.types.js +3 -0
  30. package/cjs/configuration/exposureEvent.types.js.map +1 -0
  31. package/cjs/configuration/index.d.ts +2 -0
  32. package/cjs/configuration/index.d.ts.map +1 -1
  33. package/cjs/configuration/index.js +2 -0
  34. package/cjs/configuration/index.js.map +1 -1
  35. package/cjs/configuration/wire.d.ts +3 -3
  36. package/cjs/configuration/wire.d.ts.map +1 -1
  37. package/cjs/configuration/wire.js.map +1 -1
  38. package/cjs/index.d.ts +2 -0
  39. package/cjs/index.d.ts.map +1 -1
  40. package/cjs/index.js +3 -1
  41. package/cjs/index.js.map +1 -1
  42. package/cjs/obfuscation.d.ts +9 -0
  43. package/cjs/obfuscation.d.ts.map +1 -0
  44. package/cjs/obfuscation.js +23 -0
  45. package/cjs/obfuscation.js.map +1 -0
  46. package/esm/cache/abstract-assignment-cache.d.ts +39 -0
  47. package/esm/cache/abstract-assignment-cache.d.ts.map +1 -0
  48. package/esm/cache/abstract-assignment-cache.js +53 -0
  49. package/esm/cache/abstract-assignment-cache.js.map +1 -0
  50. package/esm/cache/index.d.ts +4 -0
  51. package/esm/cache/index.d.ts.map +1 -0
  52. package/esm/cache/index.js +4 -0
  53. package/esm/cache/index.js.map +1 -0
  54. package/esm/cache/lru-cache.d.ts +31 -0
  55. package/esm/cache/lru-cache.d.ts.map +1 -0
  56. package/esm/cache/lru-cache.js +81 -0
  57. package/esm/cache/lru-cache.js.map +1 -0
  58. package/esm/cache/lru-in-memory-assignment-cache.d.ts +16 -0
  59. package/esm/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
  60. package/esm/cache/lru-in-memory-assignment-cache.js +18 -0
  61. package/esm/cache/lru-in-memory-assignment-cache.js.map +1 -0
  62. package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
  63. package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
  64. package/esm/cache/non-expiring-in-memory-cache-assignment.js +13 -0
  65. package/esm/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
  66. package/esm/configuration/configuration.d.ts +52 -0
  67. package/esm/configuration/configuration.d.ts.map +1 -0
  68. package/esm/configuration/configuration.js +2 -0
  69. package/esm/configuration/configuration.js.map +1 -0
  70. package/esm/configuration/exposureEvent.d.ts +4 -0
  71. package/esm/configuration/exposureEvent.d.ts.map +1 -0
  72. package/esm/configuration/exposureEvent.js +30 -0
  73. package/esm/configuration/exposureEvent.js.map +1 -0
  74. package/esm/configuration/exposureEvent.types.d.ts +21 -0
  75. package/esm/configuration/exposureEvent.types.d.ts.map +1 -0
  76. package/esm/configuration/exposureEvent.types.js +2 -0
  77. package/esm/configuration/exposureEvent.types.js.map +1 -0
  78. package/esm/configuration/index.d.ts +5 -0
  79. package/esm/configuration/index.d.ts.map +1 -0
  80. package/esm/configuration/index.js +5 -0
  81. package/esm/configuration/index.js.map +1 -0
  82. package/esm/configuration/wire.d.ts +12 -0
  83. package/esm/configuration/wire.d.ts.map +1 -0
  84. package/esm/configuration/wire.js +41 -0
  85. package/esm/configuration/wire.js.map +1 -0
  86. package/esm/index.d.ts +4 -0
  87. package/esm/index.d.ts.map +1 -0
  88. package/esm/index.js +6 -0
  89. package/esm/index.js.map +1 -0
  90. package/esm/obfuscation.d.ts +9 -0
  91. package/esm/obfuscation.d.ts.map +1 -0
  92. package/esm/obfuscation.js +16 -0
  93. package/esm/obfuscation.js.map +1 -0
  94. package/package.json +14 -9
  95. package/jest.config.js +0 -15
  96. package/src/configuration/configuration.ts +0 -57
  97. package/src/configuration/index.ts +0 -2
  98. package/src/configuration/wire.ts +0 -58
  99. package/src/global.d.ts +0 -3
  100. package/src/index.ts +0 -4
  101. package/tsconfig.cjs.json +0 -13
  102. package/tsconfig.esm.json +0 -13
  103. package/tsconfig.json +0 -12
  104. package/tsconfig.test.json +0 -8
  105. 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-alpha.8",
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 build:bundle",
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": "^20.0.0",
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
- "webpack": "^5.0.0"
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,2 +0,0 @@
1
- export * from './configuration'
2
- export * from './wire'
@@ -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
@@ -1,3 +0,0 @@
1
- // Build environment placeholders that will be replaced during build
2
- declare const __BUILD_ENV__SDK_VERSION__: string
3
- declare const __BUILD_ENV__SDK_SETUP__: string
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './configuration'
2
-
3
- // Build environment placeholder for testing
4
- const SDK_VERSION = __BUILD_ENV__SDK_VERSION__
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
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.cjs.json",
3
- "compilerOptions": {
4
- "types": ["jest", "node"]
5
- },
6
- "include": ["./src/**/*.spec.ts", "./src/**/*.test.ts"],
7
- "exclude": []
8
- }
package/webpack.config.js DELETED
@@ -1,10 +0,0 @@
1
- const path = require('path')
2
-
3
- const webpackBase = require('../../webpack.base')
4
-
5
- module.exports = (_env, argv) =>
6
- webpackBase({
7
- mode: argv.mode,
8
- entry: path.resolve(__dirname, 'src/index.ts'),
9
- filename: 'datadog-flagging-core.js',
10
- })