@datadog/flagging-core 0.1.0-alpha.13 → 0.1.0-alpha.15
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/esm/configuration/configuration.d.ts +46 -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/index.d.ts +3 -0
- package/esm/configuration/index.d.ts.map +1 -0
- package/esm/configuration/index.js +3 -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 +2 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -0
- package/package.json +6 -1
- package/jest.config.js +0 -15
- package/src/configuration/configuration.ts +0 -52
- 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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/web-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Internal flags configuration for DatadogProvider.
|
|
4
|
+
*/
|
|
5
|
+
export type FlagsConfiguration = {
|
|
6
|
+
/** @internal */
|
|
7
|
+
precomputed?: PrecomputedConfiguration;
|
|
8
|
+
};
|
|
9
|
+
/** @internal */
|
|
10
|
+
export type PrecomputedConfiguration = {
|
|
11
|
+
response: PrecomputedConfigurationResponse;
|
|
12
|
+
context?: EvaluationContext;
|
|
13
|
+
fetchedAt?: UnixTimestamp;
|
|
14
|
+
};
|
|
15
|
+
/** @internal */
|
|
16
|
+
export type FlagTypeToValue<T extends FlagValueType> = {
|
|
17
|
+
['boolean']: boolean;
|
|
18
|
+
['string']: string;
|
|
19
|
+
['number']: number;
|
|
20
|
+
['object']: JsonValue;
|
|
21
|
+
}[T];
|
|
22
|
+
/** @internal
|
|
23
|
+
* Timestamp in milliseconds since Unix Epoch.
|
|
24
|
+
*/
|
|
25
|
+
export type UnixTimestamp = number;
|
|
26
|
+
/** @internal */
|
|
27
|
+
export type PrecomputedConfigurationResponse = {
|
|
28
|
+
data: {
|
|
29
|
+
attributes: {
|
|
30
|
+
/** When configuration was generated. */
|
|
31
|
+
createdAt: number;
|
|
32
|
+
flags: Record<string, PrecomputedFlag>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/** @internal */
|
|
37
|
+
export type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
38
|
+
allocationKey: string;
|
|
39
|
+
variationKey: string;
|
|
40
|
+
variationType: T;
|
|
41
|
+
variationValue: FlagTypeToValue<T>;
|
|
42
|
+
reason: ResolutionReason;
|
|
43
|
+
doLog: boolean;
|
|
44
|
+
extraLogging: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEzG;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB;IAChB,WAAW,CAAC,EAAE,wBAAwB,CAAA;CACvC,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,gCAAgC,CAAA;IAC1C,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B,CAAA;AAGD,gBAAgB;AAChB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,aAAa,IAAI;IACrD,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IACpB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAClB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAClB,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CACtB,CAAC,CAAC,CAAC,CAAA;AAEJ;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAA;AAElC,gBAAgB;AAChB,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,wCAAwC;YACxC,SAAS,EAAE,MAAM,CAAA;YACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;SACvC,CAAA;KACF,CAAA;CACF,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI;IACrE,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,CAAC,CAAA;IAChB,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IAClC,MAAM,EAAE,gBAAgB,CAAA;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FlagsConfiguration } from './configuration';
|
|
2
|
+
/**
|
|
3
|
+
* Create configuration from a string created with `configurationToString`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function configurationFromString(s: string): FlagsConfiguration;
|
|
6
|
+
/**
|
|
7
|
+
* Serialize configuration to string that can be deserialized with
|
|
8
|
+
* `configurationFromString`. The serialized string format is
|
|
9
|
+
* unspecified.
|
|
10
|
+
*/
|
|
11
|
+
export declare function configurationToString(configuration: FlagsConfiguration): string;
|
|
12
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAA;AAWxE;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAqBrE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,kBAAkB,GAAG,MAAM,CAa/E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create configuration from a string created with `configurationToString`.
|
|
3
|
+
*/
|
|
4
|
+
export function configurationFromString(s) {
|
|
5
|
+
try {
|
|
6
|
+
const wire = JSON.parse(s);
|
|
7
|
+
if (wire.version !== 1) {
|
|
8
|
+
// Unknown version
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
const configuration = {};
|
|
12
|
+
if (wire.precomputed) {
|
|
13
|
+
configuration.precomputed = {
|
|
14
|
+
...wire.precomputed,
|
|
15
|
+
response: JSON.parse(wire.precomputed.response),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return configuration;
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialize configuration to string that can be deserialized with
|
|
26
|
+
* `configurationFromString`. The serialized string format is
|
|
27
|
+
* unspecified.
|
|
28
|
+
*/
|
|
29
|
+
export function configurationToString(configuration) {
|
|
30
|
+
const wire = {
|
|
31
|
+
version: 1,
|
|
32
|
+
};
|
|
33
|
+
if (configuration.precomputed) {
|
|
34
|
+
wire.precomputed = {
|
|
35
|
+
...configuration.precomputed,
|
|
36
|
+
response: JSON.stringify(configuration.precomputed),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return JSON.stringify(wire);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAS;IAC/C,IAAI,CAAC;QACH,MAAM,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAE7C,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,kBAAkB;YAClB,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,aAAa,GAAuB,EAAE,CAAA;QAC5C,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,aAAa,CAAC,WAAW,GAAG;gBAC1B,GAAG,IAAI,CAAC,WAAW;gBACnB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;aAChD,CAAA;QACH,CAAC;QAED,OAAO,aAAa,CAAA;IACtB,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAiC;IACrE,MAAM,IAAI,GAAsB;QAC9B,OAAO,EAAE,CAAC;KACX,CAAA;IAED,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG;YACjB,GAAG,aAAa,CAAC,WAAW;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC;SACpD,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAE/B,4CAA4C;AAC5C,MAAM,WAAW,GAAG,0BAA0B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/flagging-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.15",
|
|
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/"
|
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,52 +0,0 @@
|
|
|
1
|
-
import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/web-sdk'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal flags configuration for DatadogProvider.
|
|
5
|
-
*/
|
|
6
|
-
export type FlagsConfiguration = {
|
|
7
|
-
/** @internal */
|
|
8
|
-
precomputed?: PrecomputedConfiguration
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export type PrecomputedConfiguration = {
|
|
13
|
-
response: PrecomputedConfigurationResponse
|
|
14
|
-
context?: EvaluationContext
|
|
15
|
-
fetchedAt?: UnixTimestamp
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Fancy way to map FlagValueType to expected FlagValue.
|
|
19
|
-
/** @internal */
|
|
20
|
-
export type FlagTypeToValue<T extends FlagValueType> = {
|
|
21
|
-
['boolean']: boolean
|
|
22
|
-
['string']: string
|
|
23
|
-
['number']: number
|
|
24
|
-
['object']: JsonValue
|
|
25
|
-
}[T]
|
|
26
|
-
|
|
27
|
-
/** @internal
|
|
28
|
-
* Timestamp in milliseconds since Unix Epoch.
|
|
29
|
-
*/
|
|
30
|
-
export type UnixTimestamp = number
|
|
31
|
-
|
|
32
|
-
/** @internal */
|
|
33
|
-
export type PrecomputedConfigurationResponse = {
|
|
34
|
-
data: {
|
|
35
|
-
attributes: {
|
|
36
|
-
/** When configuration was generated. */
|
|
37
|
-
createdAt: number
|
|
38
|
-
flags: Record<string, PrecomputedFlag>
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @internal */
|
|
44
|
-
export type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
45
|
-
allocationKey: string
|
|
46
|
-
variationKey: string
|
|
47
|
-
variationType: T
|
|
48
|
-
variationValue: FlagTypeToValue<T>
|
|
49
|
-
reason: ResolutionReason
|
|
50
|
-
doLog: boolean
|
|
51
|
-
extraLogging: Record<string, unknown>
|
|
52
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { EvaluationContext } from '@openfeature/web-sdk'
|
|
2
|
-
|
|
3
|
-
import type { FlagsConfiguration, 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): FlagsConfiguration {
|
|
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: FlagsConfiguration = {}
|
|
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: FlagsConfiguration): 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
|
-
}
|