@datadog/flagging-core 0.1.0-alpha.1 → 0.1.0-alpha.3
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/index.js +20 -0
- package/package.json +18 -15
- package/dist/index.d.mts +0 -59
- package/dist/index.d.ts +0 -59
- package/dist/index.js +0 -63
- package/dist/index.mjs +0 -35
package/cjs/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./configuration"), exports);
|
|
18
|
+
// Build environment placeholder for testing
|
|
19
|
+
const SDK_VERSION = "dev";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
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.3",
|
|
4
4
|
"description": "Runtime-agnostic flag-evaluation logic for Datadog Flagging",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,25 +9,24 @@
|
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"dist"
|
|
16
17
|
],
|
|
17
|
-
"main": "
|
|
18
|
-
"module": "
|
|
19
|
-
"types": "
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"import": "./dist/index.mjs",
|
|
24
|
-
"require": "./dist/index.js"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
18
|
+
"main": "cjs/index.js",
|
|
19
|
+
"module": "esm/index.js",
|
|
20
|
+
"types": "cjs/index.d.ts",
|
|
27
21
|
"scripts": {
|
|
28
|
-
"build": "tsup src/index.ts --dts --format cjs,esm",
|
|
29
22
|
"prepack": "yarn build",
|
|
30
|
-
"
|
|
23
|
+
"pack": "yarn pack",
|
|
24
|
+
"build": "run-p build:cjs build:esm build:bundle",
|
|
25
|
+
"build:bundle": "rm -rf bundle && SDK_SETUP=cdn node ../../scripts/webpack-runner.js webpack.config.js --mode=production",
|
|
26
|
+
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
|
|
27
|
+
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
|
|
28
|
+
"replace-build-env": "node ../../scripts/build/replace-build-env.js",
|
|
29
|
+
"clean": "rm -rf dist cjs esm",
|
|
31
30
|
"test": "jest --passWithNoTests",
|
|
32
31
|
"typecheck": "tsc --noEmit"
|
|
33
32
|
},
|
|
@@ -35,12 +34,16 @@
|
|
|
35
34
|
"@types/jest": "^29.4.0",
|
|
36
35
|
"@types/node": "^20.0.0",
|
|
37
36
|
"jest": "^30.0.4",
|
|
37
|
+
"npm-run-all": "^4.1.5",
|
|
38
38
|
"ts-jest": "^29.4.0",
|
|
39
|
-
"
|
|
39
|
+
"ts-loader": "^9.5.2",
|
|
40
40
|
"typescript": "^5.5.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@openfeature/core": "^1.8.1",
|
|
44
44
|
"@openfeature/web-sdk": "^1.5.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"webpack": "^5.0.0"
|
|
45
48
|
}
|
|
46
49
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { FlagValueType, JsonValue, ResolutionReason, EvaluationContext } from '@openfeature/web-sdk';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal configuration for DatadogProvider.
|
|
5
|
-
*/
|
|
6
|
-
type Configuration = {
|
|
7
|
-
/** @internal */
|
|
8
|
-
precomputed?: PrecomputedConfiguration;
|
|
9
|
-
};
|
|
10
|
-
/** @internal */
|
|
11
|
-
type PrecomputedConfiguration = {
|
|
12
|
-
response: PrecomputedConfigurationResponse;
|
|
13
|
-
context?: EvaluationContext;
|
|
14
|
-
fetchedAt?: UnixTimestamp;
|
|
15
|
-
};
|
|
16
|
-
/** @internal */
|
|
17
|
-
type FlagTypeToValue<T extends FlagValueType> = {
|
|
18
|
-
['boolean']: boolean;
|
|
19
|
-
['string']: string;
|
|
20
|
-
['number']: number;
|
|
21
|
-
['object']: JsonValue;
|
|
22
|
-
}[T];
|
|
23
|
-
/** @internal
|
|
24
|
-
* Timestamp in milliseconds since Unix Epoch.
|
|
25
|
-
*/
|
|
26
|
-
type UnixTimestamp = number;
|
|
27
|
-
/** @internal */
|
|
28
|
-
type PrecomputedConfigurationResponse = {
|
|
29
|
-
data: {
|
|
30
|
-
attributes: {
|
|
31
|
-
/** When configuration was generated. */
|
|
32
|
-
createdAt: number;
|
|
33
|
-
flags: Record<string, PrecomputedFlag>;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/** @internal */
|
|
38
|
-
type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
39
|
-
allocationKey: string;
|
|
40
|
-
variationKey: string;
|
|
41
|
-
variationType: T;
|
|
42
|
-
variationValue: FlagTypeToValue<T>;
|
|
43
|
-
reason: ResolutionReason;
|
|
44
|
-
doLog: boolean;
|
|
45
|
-
extraLogging: Record<string, unknown>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Create configuration from a string created with `configurationToString`.
|
|
50
|
-
*/
|
|
51
|
-
declare function configurationFromString(s: string): Configuration;
|
|
52
|
-
/**
|
|
53
|
-
* Serialize configuration to string that can be deserialized with
|
|
54
|
-
* `configurationFromString`. The serialized string format is
|
|
55
|
-
* unspecified.
|
|
56
|
-
*/
|
|
57
|
-
declare function configurationToString(configuration: Configuration): string;
|
|
58
|
-
|
|
59
|
-
export { type Configuration, type FlagTypeToValue, type PrecomputedConfiguration, type PrecomputedConfigurationResponse, type PrecomputedFlag, type UnixTimestamp, configurationFromString, configurationToString };
|
package/dist/index.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { FlagValueType, JsonValue, ResolutionReason, EvaluationContext } from '@openfeature/web-sdk';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal configuration for DatadogProvider.
|
|
5
|
-
*/
|
|
6
|
-
type Configuration = {
|
|
7
|
-
/** @internal */
|
|
8
|
-
precomputed?: PrecomputedConfiguration;
|
|
9
|
-
};
|
|
10
|
-
/** @internal */
|
|
11
|
-
type PrecomputedConfiguration = {
|
|
12
|
-
response: PrecomputedConfigurationResponse;
|
|
13
|
-
context?: EvaluationContext;
|
|
14
|
-
fetchedAt?: UnixTimestamp;
|
|
15
|
-
};
|
|
16
|
-
/** @internal */
|
|
17
|
-
type FlagTypeToValue<T extends FlagValueType> = {
|
|
18
|
-
['boolean']: boolean;
|
|
19
|
-
['string']: string;
|
|
20
|
-
['number']: number;
|
|
21
|
-
['object']: JsonValue;
|
|
22
|
-
}[T];
|
|
23
|
-
/** @internal
|
|
24
|
-
* Timestamp in milliseconds since Unix Epoch.
|
|
25
|
-
*/
|
|
26
|
-
type UnixTimestamp = number;
|
|
27
|
-
/** @internal */
|
|
28
|
-
type PrecomputedConfigurationResponse = {
|
|
29
|
-
data: {
|
|
30
|
-
attributes: {
|
|
31
|
-
/** When configuration was generated. */
|
|
32
|
-
createdAt: number;
|
|
33
|
-
flags: Record<string, PrecomputedFlag>;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/** @internal */
|
|
38
|
-
type PrecomputedFlag<T extends FlagValueType = FlagValueType> = {
|
|
39
|
-
allocationKey: string;
|
|
40
|
-
variationKey: string;
|
|
41
|
-
variationType: T;
|
|
42
|
-
variationValue: FlagTypeToValue<T>;
|
|
43
|
-
reason: ResolutionReason;
|
|
44
|
-
doLog: boolean;
|
|
45
|
-
extraLogging: Record<string, unknown>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Create configuration from a string created with `configurationToString`.
|
|
50
|
-
*/
|
|
51
|
-
declare function configurationFromString(s: string): Configuration;
|
|
52
|
-
/**
|
|
53
|
-
* Serialize configuration to string that can be deserialized with
|
|
54
|
-
* `configurationFromString`. The serialized string format is
|
|
55
|
-
* unspecified.
|
|
56
|
-
*/
|
|
57
|
-
declare function configurationToString(configuration: Configuration): string;
|
|
58
|
-
|
|
59
|
-
export { type Configuration, type FlagTypeToValue, type PrecomputedConfiguration, type PrecomputedConfigurationResponse, type PrecomputedFlag, type UnixTimestamp, configurationFromString, configurationToString };
|
package/dist/index.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
configurationFromString: () => configurationFromString,
|
|
24
|
-
configurationToString: () => configurationToString
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
|
-
// src/configuration/wire.ts
|
|
29
|
-
function configurationFromString(s) {
|
|
30
|
-
try {
|
|
31
|
-
const wire = JSON.parse(s);
|
|
32
|
-
if (wire.version !== 1) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
const configuration = {};
|
|
36
|
-
if (wire.precomputed) {
|
|
37
|
-
configuration.precomputed = {
|
|
38
|
-
...wire.precomputed,
|
|
39
|
-
response: JSON.parse(wire.precomputed.response)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return configuration;
|
|
43
|
-
} catch (e) {
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function configurationToString(configuration) {
|
|
48
|
-
const wire = {
|
|
49
|
-
version: 1
|
|
50
|
-
};
|
|
51
|
-
if (configuration.precomputed) {
|
|
52
|
-
wire.precomputed = {
|
|
53
|
-
...configuration.precomputed,
|
|
54
|
-
response: JSON.stringify(configuration.precomputed)
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return JSON.stringify(wire);
|
|
58
|
-
}
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
configurationFromString,
|
|
62
|
-
configurationToString
|
|
63
|
-
});
|
package/dist/index.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// src/configuration/wire.ts
|
|
2
|
-
function configurationFromString(s) {
|
|
3
|
-
try {
|
|
4
|
-
const wire = JSON.parse(s);
|
|
5
|
-
if (wire.version !== 1) {
|
|
6
|
-
return {};
|
|
7
|
-
}
|
|
8
|
-
const configuration = {};
|
|
9
|
-
if (wire.precomputed) {
|
|
10
|
-
configuration.precomputed = {
|
|
11
|
-
...wire.precomputed,
|
|
12
|
-
response: JSON.parse(wire.precomputed.response)
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return configuration;
|
|
16
|
-
} catch (e) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function configurationToString(configuration) {
|
|
21
|
-
const wire = {
|
|
22
|
-
version: 1
|
|
23
|
-
};
|
|
24
|
-
if (configuration.precomputed) {
|
|
25
|
-
wire.precomputed = {
|
|
26
|
-
...configuration.precomputed,
|
|
27
|
-
response: JSON.stringify(configuration.precomputed)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return JSON.stringify(wire);
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
configurationFromString,
|
|
34
|
-
configurationToString
|
|
35
|
-
};
|