@datadog/flagging-core 0.1.0-alpha.8 → 0.1.0-preview.2

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.
@@ -1,8 +1,8 @@
1
1
  import type { EvaluationContext, FlagValueType, JsonValue, ResolutionReason } from '@openfeature/web-sdk';
2
2
  /**
3
- * Internal configuration for DatadogProvider.
3
+ * Internal flags configuration for DatadogProvider.
4
4
  */
5
- export type Configuration = {
5
+ export type FlagsConfiguration = {
6
6
  /** @internal */
7
7
  precomputed?: PrecomputedConfiguration;
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,gBAAgB,EACjB,MAAM,sBAAsB,CAAA;AAE7B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,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,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AEG;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"}
@@ -1,12 +1,12 @@
1
- import type { Configuration } from './configuration';
1
+ import type { FlagsConfiguration } from './configuration';
2
2
  /**
3
3
  * Create configuration from a string created with `configurationToString`.
4
4
  */
5
- export declare function configurationFromString(s: string): Configuration;
5
+ export declare function configurationFromString(s: string): FlagsConfiguration;
6
6
  /**
7
7
  * Serialize configuration to string that can be deserialized with
8
8
  * `configurationFromString`. The serialized string format is
9
9
  * unspecified.
10
10
  */
11
- export declare function configurationToString(configuration: Configuration): string;
11
+ export declare function configurationToString(configuration: FlagsConfiguration): string;
12
12
  //# sourceMappingURL=wire.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,iBAAiB,CAAA;AAWnE;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAqBhE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAa1E"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/configuration/wire.ts"],"names":[],"mappings":";;AAgBA,0DAqBC;AAOD,sDAaC;AA5CD;;GAEG;AACH,SAAgB,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,GAAkB,EAAE,CAAA;QACvC,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,SAAgB,qBAAqB,CAAC,aAA4B;IAChE,MAAM,IAAI,GAAsB;QAC9B,OAAO,EAAE,CAAC;KACX,CAAA;IAED,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;QAC9B,IAAI,CAAC,WA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AAA;AAC7B,CAAC"}
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './configuration';
2
+ export * from './wire';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ export * from './configuration';
2
+ export * from './wire';
3
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export * from './configuration';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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
@@ -0,0 +1,4 @@
1
+ export * from './configuration';
2
+ // Build environment placeholder for testing
3
+ const SDK_VERSION = "dev";
4
+ //# sourceMappingURL=index.js.map
@@ -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.8",
3
+ "version": "0.1.0-preview.2",
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,6 +32,8 @@
28
32
  "typecheck": "tsc --noEmit"
29
33
  },
30
34
  "devDependencies": {
35
+ "@openfeature/core": "^1.8.1",
36
+ "@openfeature/web-sdk": "^1.5.0",
31
37
  "@types/jest": "^29.4.0",
32
38
  "@types/node": "^20.0.0",
33
39
  "jest": "^30.0.4",
@@ -36,11 +42,8 @@
36
42
  "ts-loader": "^9.5.2",
37
43
  "typescript": "^5.5.0"
38
44
  },
39
- "dependencies": {
45
+ "peerDependencies": {
40
46
  "@openfeature/core": "^1.8.1",
41
47
  "@openfeature/web-sdk": "^1.5.0"
42
- },
43
- "peerDependencies": {
44
- "webpack": "^5.0.0"
45
48
  }
46
49
  }
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
- })