@mfdj/tsc-as-build-tool 2.8.0 → 2.9.0

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 (65) hide show
  1. package/dist-cjs/Client.d.ts +9 -0
  2. package/dist-cjs/Client.d.ts.map +1 -0
  3. package/dist-cjs/Client.js +20 -0
  4. package/dist-cjs/Client.js.map +1 -0
  5. package/dist-cjs/EntryPoint.d.ts +12 -0
  6. package/dist-cjs/EntryPoint.d.ts.map +1 -0
  7. package/dist-cjs/EntryPoint.js +76 -0
  8. package/dist-cjs/EntryPoint.js.map +1 -0
  9. package/dist-cjs/ExperimentationRoot.d.ts +11 -0
  10. package/dist-cjs/ExperimentationRoot.d.ts.map +1 -0
  11. package/dist-cjs/ExperimentationRoot.js +27 -0
  12. package/dist-cjs/ExperimentationRoot.js.map +1 -0
  13. package/dist-cjs/http/ScopedServiceClient.d.ts +23 -0
  14. package/dist-cjs/http/ScopedServiceClient.d.ts.map +1 -0
  15. package/dist-cjs/http/ScopedServiceClient.js +64 -0
  16. package/dist-cjs/http/ScopedServiceClient.js.map +1 -0
  17. package/dist-cjs/http/createEndpoint.d.ts +9 -0
  18. package/dist-cjs/http/createEndpoint.d.ts.map +1 -0
  19. package/dist-cjs/http/createEndpoint.js +15 -0
  20. package/dist-cjs/http/createEndpoint.js.map +1 -0
  21. package/dist-cjs/http/globalFetch.d.ts +2 -0
  22. package/dist-cjs/http/globalFetch.d.ts.map +1 -0
  23. package/dist-cjs/http/globalFetch.js +15 -0
  24. package/dist-cjs/http/globalFetch.js.map +1 -0
  25. package/dist-cjs/http/response-parsers.d.ts +3 -0
  26. package/dist-cjs/http/response-parsers.d.ts.map +1 -0
  27. package/dist-cjs/http/response-parsers.js +27 -0
  28. package/dist-cjs/http/response-parsers.js.map +1 -0
  29. package/dist-cjs/http/serialize.d.ts +4 -0
  30. package/dist-cjs/http/serialize.d.ts.map +1 -0
  31. package/dist-cjs/http/serialize.js +28 -0
  32. package/dist-cjs/http/serialize.js.map +1 -0
  33. package/dist-cjs/http/serviceFetch.d.ts +4 -0
  34. package/dist-cjs/http/serviceFetch.d.ts.map +1 -0
  35. package/dist-cjs/http/serviceFetch.js +25 -0
  36. package/dist-cjs/http/serviceFetch.js.map +1 -0
  37. package/dist-cjs/index.d.ts +8 -0
  38. package/dist-cjs/index.d.ts.map +1 -0
  39. package/dist-cjs/index.js +34 -0
  40. package/dist-cjs/index.js.map +1 -0
  41. package/dist-cjs/logging.d.ts +11 -0
  42. package/dist-cjs/logging.d.ts.map +1 -0
  43. package/dist-cjs/logging.js +136 -0
  44. package/dist-cjs/logging.js.map +1 -0
  45. package/dist-cjs/misc/arbitrary.d.ts +2 -0
  46. package/dist-cjs/misc/arbitrary.d.ts.map +1 -0
  47. package/dist-cjs/misc/arbitrary.js +5 -0
  48. package/dist-cjs/misc/arbitrary.js.map +1 -0
  49. package/dist-cjs/misc/throwAnError.d.ts +2 -0
  50. package/dist-cjs/misc/throwAnError.d.ts.map +1 -0
  51. package/dist-cjs/misc/throwAnError.js +7 -0
  52. package/dist-cjs/misc/throwAnError.js.map +1 -0
  53. package/dist-cjs/misc/toLowercase.d.ts +2 -0
  54. package/dist-cjs/misc/toLowercase.d.ts.map +1 -0
  55. package/dist-cjs/misc/toLowercase.js +28 -0
  56. package/dist-cjs/misc/toLowercase.js.map +1 -0
  57. package/dist-cjs/persistent-storage/DefaultStore.d.ts +9 -0
  58. package/dist-cjs/persistent-storage/DefaultStore.d.ts.map +1 -0
  59. package/dist-cjs/persistent-storage/DefaultStore.js +27 -0
  60. package/dist-cjs/persistent-storage/DefaultStore.js.map +1 -0
  61. package/dist-cjs/types.d.ts +73 -0
  62. package/dist-cjs/types.d.ts.map +1 -0
  63. package/dist-cjs/types.js +6 -0
  64. package/dist-cjs/types.js.map +1 -0
  65. package/package.json +2 -5
@@ -0,0 +1,9 @@
1
+ import { ScopedServiceClient, type ClientOptions } from "./http/ScopedServiceClient.ts";
2
+ export declare class Client {
3
+ readonly accountClient: ScopedServiceClient<"account">;
4
+ readonly userClient: ScopedServiceClient<"user">;
5
+ constructor(options?: ClientOptions);
6
+ get account(): ScopedServiceClient<"account">;
7
+ get user(): ScopedServiceClient<"user">;
8
+ }
9
+ //# sourceMappingURL=Client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAExF,qBAAa,MAAM;IACjB,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACvD,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;gBAErC,OAAO,CAAC,EAAE,aAAa;IAKnC,IAAI,OAAO,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAE5C;IAED,IAAI,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAEtC;CACF"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ const ScopedServiceClient_ts_1 = require("./http/ScopedServiceClient.js");
5
+ class Client {
6
+ accountClient;
7
+ userClient;
8
+ constructor(options) {
9
+ this.accountClient = new ScopedServiceClient_ts_1.ScopedServiceClient("account", options);
10
+ this.userClient = new ScopedServiceClient_ts_1.ScopedServiceClient("user", options);
11
+ }
12
+ get account() {
13
+ return this.accountClient;
14
+ }
15
+ get user() {
16
+ return this.userClient;
17
+ }
18
+ }
19
+ exports.Client = Client;
20
+ //# sourceMappingURL=Client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":";;;AAAA,0EAAwF;AAExF,MAAa,MAAM;IACR,aAAa,CAAiC;IAC9C,UAAU,CAA8B;IAEjD,YAAY,OAAuB;QACjC,IAAI,CAAC,aAAa,GAAG,IAAI,4CAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,GAAG,IAAI,4CAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAhBD,wBAgBC"}
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from "react";
2
+ import type { EntryPointConfig, ExperimentConfig, ExperimentScope } from "./types.ts";
3
+ export type EntryPointProps = Omit<EntryPointConfig, "name"> & {
4
+ children?: ReactNode;
5
+ experimentName?: ExperimentConfig["name"];
6
+ experiments?: EntryPointConfig | EntryPointConfig[];
7
+ name: ExperimentConfig["entryPointName"];
8
+ scope?: ExperimentScope;
9
+ };
10
+ export declare function EntryPoint({ children, ...props }: EntryPointProps): ReactNode;
11
+ export declare function entryPointParser(props: Omit<EntryPointProps, "children">): ExperimentConfig[];
12
+ //# sourceMappingURL=EntryPoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntryPoint.d.ts","sourceRoot":"","sources":["../src/EntryPoint.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG;IAC7D,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IACpD,IAAI,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAIF,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,GAAG,SAAS,CAmB7E;AAOD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,gBAAgB,EAAE,CAqE7F"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntryPoint = EntryPoint;
4
+ exports.entryPointParser = entryPointParser;
5
+ const react_1 = require("react");
6
+ const logging_ts_1 = require("./logging.js");
7
+ const Client_ts_1 = require("./Client.js");
8
+ const serviceClient = new Client_ts_1.Client(); // TODO: fetch from container/store
9
+ function EntryPoint({ children, ...props }) {
10
+ const configs = entryPointParser(props);
11
+ const fingerprint = JSON.stringify(configs);
12
+ (0, logging_ts_1.debug)("EntryPoint configs", ...configs);
13
+ (0, react_1.useEffect)(() => {
14
+ (0, logging_ts_1.info)("EntryPoint configs useEffect", fingerprint);
15
+ configs.forEach((config) => {
16
+ config.readyToRequest &&
17
+ serviceClient[config.scope].createParticipation(config.name, config.customFilters, config.filterGroups);
18
+ });
19
+ }, [fingerprint]);
20
+ return children;
21
+ }
22
+ // units
23
+ const mixedConfigWarning = "EntryPoint was passed both a standalone experiment and a list of experiments. The standalone will be appended to the list. When there are multiple experiments it's recommended to consolidate them all into the experiments list for clarity.";
24
+ function entryPointParser(props) {
25
+ (0, logging_ts_1.debug)("EntryPointProps", props);
26
+ const { experiments, name: entryPointName, ...standalone } = props;
27
+ // DX: allow non-list values for experiments
28
+ const list = experiments
29
+ ? Array.isArray(experiments)
30
+ ? experiments
31
+ : [experiments]
32
+ : null;
33
+ if (standalone && list) {
34
+ (0, logging_ts_1.warn)(mixedConfigWarning, { standalone, list });
35
+ }
36
+ let configs = [];
37
+ // list and standalone are *nearly* identical but pay attention to the minor differences and separate parsing logic
38
+ // EntrypointConfig[]
39
+ if (list) {
40
+ (0, logging_ts_1.debug)("entryPointParser - list", list);
41
+ list.forEach((entryPointConfig) => {
42
+ const { filterGroups: fg, readyToRequest = true, // experiments default to ready-to-request
43
+ scope = "account", // account is the default scope
44
+ ...passThru } = entryPointConfig;
45
+ configs.push({
46
+ ...passThru,
47
+ entryPointName,
48
+ filterGroups: fg ? (Array.isArray(fg) ? fg : [fg]) : null, // DX: allow non-list values of filterGroups
49
+ readyToRequest,
50
+ scope,
51
+ });
52
+ });
53
+ }
54
+ // subset of EntryPointProps
55
+ if (standalone) {
56
+ (0, logging_ts_1.debug)("entryPointParser - standalone", standalone);
57
+ const { experimentName: name, filterGroups: fg, readyToRequest = true, // experiments default to ready-to-request
58
+ scope = "account", // account is the default scope
59
+ ...passThru } = standalone;
60
+ if (name) {
61
+ configs.push({
62
+ ...passThru,
63
+ entryPointName,
64
+ filterGroups: fg ? (Array.isArray(fg) ? fg : [fg]) : null, // DX: allow non-list values of filterGroups
65
+ name,
66
+ readyToRequest,
67
+ scope,
68
+ });
69
+ }
70
+ else {
71
+ (0, logging_ts_1.debug)("entryPointParser - ignoring standalone since it's missing an experimentName");
72
+ }
73
+ }
74
+ return configs;
75
+ }
76
+ //# sourceMappingURL=EntryPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntryPoint.js","sourceRoot":"","sources":["../src/EntryPoint.tsx"],"names":[],"mappings":";;AAiBA,gCAmBC;AAOD,4CAqEC;AAhHD,iCAAkC;AAClC,6CAAiD;AACjD,2CAAqC;AAarC,MAAM,aAAa,GAAG,IAAI,kBAAM,EAAE,CAAC,CAAC,mCAAmC;AAEvE,SAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAmB;IAChE,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAA,kBAAK,EAAC,oB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
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ interface ExperimentationRootProps {
3
+ children?: ReactNode;
4
+ applicationName?: string;
5
+ disableHydration?: boolean;
6
+ hasIgnoreRenderBlocking?: boolean;
7
+ hasVerboseLogs?: boolean;
8
+ }
9
+ export declare function ExperimentationRoot({ children, ...props }: ExperimentationRootProps): ReactNode;
10
+ export {};
11
+ //# sourceMappingURL=ExperimentationRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExperimentationRoot.d.ts","sourceRoot":"","sources":["../src/ExperimentationRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,wBAAwB;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,wBAAwB,GAAG,SAAS,CAmBtC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExperimentationRoot = ExperimentationRoot;
4
+ const react_1 = require("react");
5
+ const logging_ts_1 = require("./logging.js");
6
+ function ExperimentationRoot({ children, ...props }) {
7
+ const { disableHydration = false, hasVerboseLogs = false, applicationName, } = props;
8
+ const hasVerboseLogsRef = (0, react_1.useRef)(hasVerboseLogs);
9
+ (0, react_1.useEffect)(() => {
10
+ const init = { hasVerboseLogs: hasVerboseLogsRef.current, applicationName };
11
+ if (disableHydration) {
12
+ initialize(init);
13
+ }
14
+ else {
15
+ void hydrate(init);
16
+ }
17
+ }, [initialize, hydrate, disableHydration, applicationName]);
18
+ return children;
19
+ }
20
+ // stubs
21
+ function initialize(a) {
22
+ (0, logging_ts_1.debug)(`TODO: initialize - ${a}`);
23
+ }
24
+ function hydrate(a) {
25
+ (0, logging_ts_1.debug)(`TODO: hydrate - ${a}`);
26
+ }
27
+ //# sourceMappingURL=ExperimentationRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExperimentationRoot.js","sourceRoot":"","sources":["../src/ExperimentationRoot.tsx"],"names":[],"mappings":";;AAaA,kDAsBC;AAnCD,iCAA0C;AAC1C,6CAAqC;AAYrC,SAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,GAAG,KAAK,EACiB;IACzB,MAAM,EACJ,gBAAgB,GAAG,KAAK,EACxB,cAAc,GAAG,KAAK,EACtB,eAAe,GAChB,GAAG,KAAK,CAAC;IAEV,MAAM,iBAAiB,GAAG,IAAA,cAAM,EAAC,cAAc,CAAC,CAAC;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,EAAE,cAAc,EAAE,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;QAC5E,IAAI,gBAAgB,EAAE,CAAC;YACrB,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC;IAE7D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,QAAQ;AACR,SAAS,UAAU,CAAC,CAAM;IACxB,IAAA,kBAAK,EAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,OAAO,CAAC,CAAM;IACrB,IAAA,kBAAK,EAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { AccountFilterGroup, CustomFilters, ExperimentName, ExperimentScope, Participation, ParticipationResponseBody, PersistentStore, UserFilterGroup } from "../types.ts";
2
+ export type ClientOptions = {
3
+ host?: string;
4
+ persistentStore?: PersistentStore;
5
+ };
6
+ export declare class ScopedServiceClient<ES extends ExperimentScope> {
7
+ readonly scope: ES;
8
+ readonly host: string;
9
+ constructor(scope: ES, { host }?: ClientOptions);
10
+ /**
11
+ *
12
+ */
13
+ createEvent(experiment: ExperimentName, event: string): Promise<Response | null>;
14
+ /**
15
+ *
16
+ */
17
+ createParticipation(experiment: ExperimentName, cfs?: CustomFilters | null, fgs?: AccountFilterGroup[] | UserFilterGroup[] | null): Promise<Participation>;
18
+ /**
19
+ *
20
+ */
21
+ getParticipations(): Promise<Response | ParticipationResponseBody[] | null>;
22
+ }
23
+ //# sourceMappingURL=ScopedServiceClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopedServiceClient.d.ts","sourceRoot":"","sources":["../../src/http/ScopedServiceClient.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,eAAe,EACf,aAAa,EACb,yBAAyB,EACzB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF,qBAAa,mBAAmB,CAAC,EAAE,SAAS,eAAe;IACzD,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAE,aAAkB;IAMnD;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAoBtF;;OAEG;IACG,mBAAmB,CACvB,UAAU,EAAE,cAAc,EAC1B,GAAG,GAAE,aAAa,GAAG,IAAW,EAChC,GAAG,GAAE,kBAAkB,EAAE,GAAG,eAAe,EAAE,GAAG,IAAW,GAC1D,OAAO,CAAC,aAAa,CAAC;IAgBzB;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,QAAQ,GAAG,yBAAyB,EAAE,GAAG,IAAI,CAAC;CAOlF"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScopedServiceClient = void 0;
4
+ const logging_ts_1 = require("../logging.js");
5
+ const createEndpoint_ts_1 = require("./createEndpoint.js");
6
+ const response_parsers_ts_1 = require("./response-parsers.js");
7
+ const serviceFetch_ts_1 = require("./serviceFetch.js");
8
+ const serialize_ts_1 = require("./serialize.js");
9
+ class ScopedServiceClient {
10
+ scope;
11
+ host;
12
+ constructor(scope, { host } = {}) {
13
+ this.scope = scope;
14
+ this.host = host || "";
15
+ (0, logging_ts_1.debug)("ScopedServiceClient constructor", this);
16
+ }
17
+ /**
18
+ *
19
+ */
20
+ async createEvent(experiment, event) {
21
+ const scope = this.scope;
22
+ const host = this.host;
23
+ const endpoint = (0, createEndpoint_ts_1.createEndpoint)(scope, "event", { experiment, host });
24
+ (0, logging_ts_1.info)(`creating ${event} event for ${experiment} ${scope}-experiment`);
25
+ try {
26
+ return (0, serviceFetch_ts_1.serviceFetch)(endpoint, {
27
+ body: JSON.stringify({ event_name: event }),
28
+ method: "POST",
29
+ skipJson: true,
30
+ });
31
+ }
32
+ catch (e) {
33
+ // swallow error
34
+ (0, logging_ts_1.error)("Failure to transmit event", e);
35
+ return Promise.resolve(null);
36
+ }
37
+ }
38
+ /**
39
+ *
40
+ */
41
+ async createParticipation(experiment, cfs = null, fgs = null) {
42
+ const scope = this.scope;
43
+ const host = this.host;
44
+ const endpoint = (0, createEndpoint_ts_1.createEndpoint)(scope, "participation", { experiment, host });
45
+ const body = (0, serialize_ts_1.serializeParticipationRequest)(cfs, fgs);
46
+ const result = await (0, serviceFetch_ts_1.serviceFetch)(endpoint, {
47
+ body: JSON.stringify(body),
48
+ method: "POST",
49
+ });
50
+ (0, logging_ts_1.debug)(`createParticipation ${scope} - serviceFetch result`, result);
51
+ return (0, response_parsers_ts_1.parseParticipation)(experiment, result);
52
+ }
53
+ /**
54
+ *
55
+ */
56
+ async getParticipations() {
57
+ const scope = this.scope;
58
+ const host = this.host;
59
+ const endpoint = (0, createEndpoint_ts_1.createEndpoint)(scope, "participations", { host });
60
+ return (0, serviceFetch_ts_1.serviceFetch)(endpoint);
61
+ }
62
+ }
63
+ exports.ScopedServiceClient = ScopedServiceClient;
64
+ //# sourceMappingURL=ScopedServiceClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopedServiceClient.js","sourceRoot":"","sources":["../../src/http/ScopedServiceClient.ts"],"names":[],"mappings":";;;AAAA,8CAA+D;AAE/D,2DAAqD;AACrD,+DAA2D;AAC3D,uDAAiD;AAYjD,iDAA+D;AAO/D,MAAa,mBAAmB;IACrB,KAAK,CAAK;IACV,IAAI,CAAS;IAEtB,YAAY,KAAS,EAAE,EAAE,IAAI,KAAoB,EAAE;QACjD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAA,kBAAK,EAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,UAA0B,EAAE,KAAa;QACzD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAA,kCAAc,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtE,IAAA,iBAAI,EAAC,YAAY,KAAK,cAAc,UAAU,IAAI,KAAK,aAAa,CAAC,CAAC;QAEtE,IAAI,CAAC;YACH,OAAO,IAAA,8BAAY,EA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AAgB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAEnE,OAAO,IAAA,8BAAY,EAA8B,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF;AAlED,kDAkEC"}
@@ -0,0 +1,9 @@
1
+ import type { ExperimentScope } from "../types.ts";
2
+ type EndpointOptions = {
3
+ experiment: string;
4
+ host?: string | undefined;
5
+ };
6
+ export declare function createEndpoint(type: ExperimentScope, resource: "participations", options?: Omit<EndpointOptions, "experiment">): string;
7
+ export declare function createEndpoint(type: ExperimentScope, resource: "event" | "participation", options: EndpointOptions): string;
8
+ export {};
9
+ //# sourceMappingURL=createEndpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEndpoint.d.ts","sourceRoot":"","sources":["../../src/http/createEndpoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAGF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,GAC5C,MAAM,CAAC;AAGV,wBAAgB,cAAc,CAC5B,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,OAAO,GAAG,eAAe,EACnC,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEndpoint = createEndpoint;
4
+ const logging_ts_1 = require("../logging.js");
5
+ function createEndpoint(type, resource, options) {
6
+ const { host, experiment } = options || {};
7
+ const url = host ? new URL(host) : null;
8
+ const finalHost = url === null ? "" : `${url.protocol}//${url.host}`;
9
+ (0, logging_ts_1.debug)("createEndpoint", { host, finalHost, type, resource, experiment });
10
+ if (experiment) {
11
+ return `${finalHost}/api/services/experiments/${type}/experiments/${experiment}/${resource}`;
12
+ }
13
+ return `${finalHost}/api/services/experiments/${type}/experiments/${resource}`;
14
+ }
15
+ //# sourceMappingURL=createEndpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEndpoint.js","sourceRoot":"","sources":["../../src/http/createEndpoint.ts"],"names":[],"mappings":";;AAwBA,wCAgBC;AAxCD,8CAAsC;AAwBtC,SAAgB,cAAc,CAC5B,IAAqB,EACrB,QAAsB,EACtB,OAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,MAAM,SAAS,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;IAErE,IAAA,kBAAK,EAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAEzE,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,GAAG,SAAS,6BAA6B,IAAI,gBAAgB,UAAU,IAAI,QAAQ,EAAE,CAAC;IAC/F,CAAC;IAED,OAAO,GAAG,SAAS,6BAA6B,IAAI,gBAAgB,QAAQ,EAAE,CAAC;AACjF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function globalFetch(...args: Parameters<typeof globalThis.fetch>): ReturnType<typeof globalThis.fetch>;
2
+ //# sourceMappingURL=globalFetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalFetch.d.ts","sourceRoot":"","sources":["../../src/http/globalFetch.ts"],"names":[],"mappings":"AAGA,wBAAsB,WAAW,CAC/B,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,GAC3C,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAQrC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.globalFetch = globalFetch;
4
+ /*
5
+ Tiny wrapper around fetch that throws not-OK responses and makes cleaner mocks
6
+ */
7
+ async function globalFetch(...args) {
8
+ return globalThis.fetch(...args).then((response) => {
9
+ if (!response.ok) {
10
+ throw new Error(response.statusText);
11
+ }
12
+ return response;
13
+ });
14
+ }
15
+ //# sourceMappingURL=globalFetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalFetch.js","sourceRoot":"","sources":["../../src/http/globalFetch.ts"],"names":[],"mappings":";;AAGA,kCAUC;AAbD;;EAEE;AACK,KAAK,UAAU,WAAW,CAC/B,GAAG,IAAyC;IAE5C,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,QAAkB,EAAE,EAAE;QAC3D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ExperimentName, Participation, ParticipationResponseBody } from "../types.ts";
2
+ export declare function parseParticipation(experimentName: ExperimentName, result: ParticipationResponseBody | Response | null): Participation;
3
+ //# sourceMappingURL=response-parsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-parsers.d.ts","sourceRoot":"","sources":["../../src/http/response-parsers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE5F,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,yBAAyB,GAAG,QAAQ,GAAG,IAAI,GAClD,aAAa,CA0Bf"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseParticipation = parseParticipation;
4
+ const logging_ts_1 = require("../logging.js");
5
+ function parseParticipation(experimentName, result) {
6
+ if (!result || result instanceof Response || result.inactive) {
7
+ (0, logging_ts_1.debug)("result parsed as inactive", result);
8
+ return {
9
+ active: false,
10
+ experimentName,
11
+ };
12
+ }
13
+ if (!result.variation) {
14
+ (0, logging_ts_1.warn)("result parsed as inactive because variation is unexpectedly missing", result);
15
+ return {
16
+ active: false,
17
+ experimentName,
18
+ };
19
+ }
20
+ (0, logging_ts_1.debug)("result parsed as active", result);
21
+ return {
22
+ active: true,
23
+ experimentName,
24
+ variation: result.variation,
25
+ };
26
+ }
27
+ //# sourceMappingURL=response-parsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-parsers.js","sourceRoot":"","sources":["../../src/http/response-parsers.ts"],"names":[],"mappings":";;AAGA,gDA6BC;AAhCD,8CAA4C;AAG5C,SAAgB,kBAAkB,CAChC,cAA8B,EAC9B,MAAmD;IAEnD,IAAI,CAAC,MAAM,IAAI,MAAM,YAAY,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC7D,IAAA,kBAAK,EAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;QAE3C,OAAO;YACL,MAAM,EAAE,KAAK;YACb,cAAc;SACf,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,IAAA,iBAAI,EAAC,qEAAqE,EAAE,MAAM,CAAC,CAAC;QAEpF,OAAO;YACL,MAAM,EAAE,KAAK;YACb,cAAc;SACf,CAAC;IACJ,CAAC;IAED,IAAA,kBAAK,EAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;IAEzC,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,cAAc;QACd,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AccountFilterGroup, CustomFilters, CustomFiltersRequest, ParticipationRequestBody, UserFilterGroup } from "../types.ts";
2
+ export declare function serializeCustomFilters(customFilters: CustomFilters): CustomFiltersRequest;
3
+ export declare function serializeParticipationRequest(customFilters: CustomFilters | null, filterGroups: AccountFilterGroup[] | UserFilterGroup[] | null): ParticipationRequestBody;
4
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/http/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,aAAa,GAAG,oBAAoB,CAazF;AAED,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,aAAa,GAAG,IAAI,EACnC,YAAY,EAAE,kBAAkB,EAAE,GAAG,eAAe,EAAE,GAAG,IAAI,GAC5D,wBAAwB,CAY1B"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeCustomFilters = serializeCustomFilters;
4
+ exports.serializeParticipationRequest = serializeParticipationRequest;
5
+ function serializeCustomFilters(customFilters) {
6
+ return Object.keys(customFilters)
7
+ .map((name) => {
8
+ const value = customFilters[name];
9
+ return typeof value !== "undefined"
10
+ ? {
11
+ name,
12
+ value,
13
+ }
14
+ : null;
15
+ })
16
+ .filter((item) => item !== null);
17
+ }
18
+ function serializeParticipationRequest(customFilters, filterGroups) {
19
+ const request = {};
20
+ if (customFilters) {
21
+ request.custom_filters = serializeCustomFilters(customFilters);
22
+ }
23
+ if (filterGroups) {
24
+ request.filter_groups = filterGroups;
25
+ }
26
+ return request;
27
+ }
28
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/http/serialize.ts"],"names":[],"mappings":";;AAQA,wDAaC;AAED,sEAeC;AA9BD,SAAgB,sBAAsB,CAAC,aAA4B;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;SAC9B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,OAAO,KAAK,KAAK,WAAW;YACjC,CAAC,CAAC;gBACE,IAAI;gBACJ,KAAK;aACN;YACH,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,6BAA6B,CAC3C,aAAmC,EACnC,YAA6D;IAE7D,MAAM,OAAO,GAA6B,EAAE,CAAC;IAE7C,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,CAAC,cAAc,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,aAAa,GAAG,YAAY,CAAC;IACvC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function serviceFetch<T>(endpoint: string, options?: RequestInit & {
2
+ skipJson?: boolean;
3
+ }): Promise<T | Response | null>;
4
+ //# sourceMappingURL=serviceFetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceFetch.d.ts","sourceRoot":"","sources":["../../src/http/serviceFetch.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACA,OAAO,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,CAsB9B"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serviceFetch = serviceFetch;
4
+ const logging_ts_1 = require("../logging.js");
5
+ const globalFetch_ts_1 = require("./globalFetch.js");
6
+ async function serviceFetch(endpoint, options) {
7
+ const { skipJson = false, ...fetchOptions } = options ?? {};
8
+ try {
9
+ (0, logging_ts_1.info)(`serviceFetch: ${endpoint}`, fetchOptions);
10
+ const response = await (0, globalFetch_ts_1.globalFetch)(endpoint, {
11
+ headers: {
12
+ "Content-Type": "application/json",
13
+ },
14
+ method: "GET",
15
+ ...(fetchOptions || {}),
16
+ });
17
+ (0, logging_ts_1.info)(`serviceFetch: response`, response);
18
+ return skipJson ? response : response.json();
19
+ }
20
+ catch (error) {
21
+ (0, logging_ts_1.error)("serviceFetch catch", error);
22
+ return null;
23
+ }
24
+ }
25
+ //# sourceMappingURL=serviceFetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceFetch.js","sourceRoot":"","sources":["../../src/http/serviceFetch.ts"],"names":[],"mappings":";;AAGA,oCA2BC;AA9BD,8CAAwD;AACxD,qDAA+C;AAExC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,OAEC;IAED,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,IAAA,iBAAI,EAAC,iBAAiB,QAAQ,EAAE,EAAE,YAAY,CAAC,CAAC;QAEhD,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAW,EAAC,QAAQ,EAAE;YAC3C,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,KAAK;YACb,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;SACxB,CAAC,CAAC;QAEH,IAAA,iBAAI,EAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;QAEzC,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,kBAAQ,EAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function usesCodeThatThrowsAnError({ rethrow }?: {
2
+ rethrow: boolean;
3
+ }): void | Error;
4
+ export declare class CaseChanger {
5
+ static ToLower(input: string): string;
6
+ static toLowercase(input: string): string;
7
+ }
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,yBAAyB,CACvC,EAAE,OAAO,EAAE,GAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAuB,GACrD,IAAI,GAAG,KAAK,CAkBd;AAED,qBAAa,WAAW;IAEtB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIrC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAG1C"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CaseChanger = void 0;
4
+ exports.usesCodeThatThrowsAnError = usesCodeThatThrowsAnError;
5
+ const throwAnError_ts_1 = require("./misc/throwAnError.js");
6
+ const toLowercase_ts_1 = require("./misc/toLowercase.js");
7
+ function usesCodeThatThrowsAnError({ rethrow } = { rethrow: false }) {
8
+ try {
9
+ (0, throwAnError_ts_1.throwAnError)();
10
+ }
11
+ catch (e) {
12
+ const cause = e;
13
+ // including `{ cause }` as 2nd argument requires `"target": "es2022"`
14
+ const nextError = new Error("throwAnError did what it said on the tin", {
15
+ cause,
16
+ });
17
+ if (rethrow) {
18
+ throw nextError;
19
+ }
20
+ return nextError;
21
+ }
22
+ return;
23
+ }
24
+ class CaseChanger {
25
+ // @deprecated in favor of toLowercase
26
+ static ToLower(input) {
27
+ return (0, toLowercase_ts_1.toLowercase)(input);
28
+ }
29
+ static toLowercase(input) {
30
+ return (0, toLowercase_ts_1.toLowercase)(input);
31
+ }
32
+ }
33
+ exports.CaseChanger = CaseChanger;
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAGA,8DAoBC;AAvBD,4DAAsD;AACtD,0DAAoD;AAEpD,SAAgB,yBAAyB,CACvC,EAAE,OAAO,KAA2B,EAAE,OAAO,EAAE,KAAK,EAAE;IAEtD,IAAI,CAAC;QACH,IAAA,8BAAY,GAAE,CAAC;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,KAAK,GAAY,CAAC,CAAC;QACzB,sEAAsE;QACtE,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,0CAA0C,EAAE;YACtE,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;AACT,CAAC;AAED,MAAa,WAAW;IACtB,sCAAsC;IACtC,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAA,4BAAW,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAa;QAC9B,OAAO,IAAA,4BAAW,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF;AATD,kCASC"}
@@ -0,0 +1,11 @@
1
+ declare const channels: readonly ["debug", "error", "info", "warn"];
2
+ type LoggingChannel = (typeof channels)[number];
3
+ export declare function debug(...args: unknown[]): void;
4
+ export declare function error(...args: unknown[]): void;
5
+ export declare function info(...args: unknown[]): void;
6
+ export declare function warn(...args: unknown[]): void;
7
+ export declare function enableLogging(channels?: "all" | "default" | LoggingChannel[]): void;
8
+ export declare function disableLogging(): void;
9
+ export declare function logger(channel: LoggingChannel, ...args: unknown[]): void;
10
+ export {};
11
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,QAAQ,6CAA8C,CAAC;AAC7D,KAAK,cAAc,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE9C;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE9C;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE7C;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE7C;AAED,wBAAgB,aAAa,CAAC,QAAQ,GAAE,KAAK,GAAG,SAAS,GAAG,cAAc,EAAc,GAAG,IAAI,CAG9F;AAED,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CA0CxE"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debug = debug;
4
+ exports.error = error;
5
+ exports.info = info;
6
+ exports.warn = warn;
7
+ exports.enableLogging = enableLogging;
8
+ exports.disableLogging = disableLogging;
9
+ exports.logger = logger;
10
+ // configuration (module scoped)
11
+ let outputAllowed;
12
+ let include_debug = false;
13
+ let include_info = false;
14
+ let include_error = false;
15
+ let include_warn = false;
16
+ let stanza_debug = "[esc]";
17
+ let stanza_info = "[esc]";
18
+ let stanza_error = "[esc]";
19
+ let stanza_warn = "[esc]";
20
+ const channels = ["debug", "error", "info", "warn"];
21
+ function debug(...args) {
22
+ logger("debug", ...args);
23
+ }
24
+ function error(...args) {
25
+ logger("error", ...args);
26
+ }
27
+ function info(...args) {
28
+ logger("info", ...args);
29
+ }
30
+ function warn(...args) {
31
+ logger("warn", ...args);
32
+ }
33
+ function enableLogging(channels = "default") {
34
+ configureLogging(channels);
35
+ outputAllowed = true;
36
+ }
37
+ function disableLogging() {
38
+ outputAllowed = false;
39
+ }
40
+ function logger(channel, ...args) {
41
+ // If not already configured lazily configure the logger using process.env (once per module)
42
+ if (typeof outputAllowed === "undefined") {
43
+ const process = globalThis.process;
44
+ const nodeEnv = process?.env["NODE_ENV"] || "";
45
+ const disabled = Boolean(process?.env["ESC_LOGGING_DISABLE"]);
46
+ const logging = process?.env["ESC_LOGGING"] || ""; // "all", ""
47
+ // Enable if ESC_LOGGING is truthy, or if NODE_ENV looks like "dev" and ESC_LOGGING_DISABLE is not truthy
48
+ outputAllowed = Boolean(logging) || Boolean(nodeEnv.match(/dev/i) && disabled === false);
49
+ if (logging === "all" || logging === "default") {
50
+ configureLogging(logging);
51
+ }
52
+ else if (["1", "true"].includes(logging) || (outputAllowed && logging === "")) {
53
+ configureLogging("default");
54
+ }
55
+ else if (logging) {
56
+ // user configured channels
57
+ configureLogging(logging.split(",").filter(isChannel));
58
+ }
59
+ }
60
+ if (outputAllowed) {
61
+ switch (channel) {
62
+ // std-out
63
+ case "debug":
64
+ include_debug && console.debug(stanza_debug, ...args);
65
+ break;
66
+ case "info":
67
+ include_info && console.info(stanza_info, ...args);
68
+ break;
69
+ // std-err
70
+ case "error":
71
+ include_error && console.error(stanza_error, ...args);
72
+ break;
73
+ case "warn":
74
+ include_warn && console.warn(stanza_warn, ...args);
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ // private
80
+ function isChannel(value) {
81
+ // `as readonly string[]` is a type widening trick from https://8hob.io/posts/elegant-safe-solution-for-typing-array-includes/
82
+ const included = channels.includes(value);
83
+ if (!included)
84
+ console.warn(stanza_warn, `Ignoring unknown logger channel: ${value}`);
85
+ return included;
86
+ }
87
+ function configureLogging(channels = "default") {
88
+ // reset
89
+ include_debug = false;
90
+ include_info = false;
91
+ include_error = false;
92
+ include_warn = false;
93
+ const probablyNode = typeof globalThis.process?.versions?.node === "string";
94
+ if (probablyNode) {
95
+ stanza_debug = "[esc-debug]";
96
+ stanza_info = "[esc-info]";
97
+ stanza_error = "[esc-error]";
98
+ stanza_warn = "[esc-warn]";
99
+ }
100
+ // "all" | "default"
101
+ if (typeof channels === "string") {
102
+ if (channels === "all") {
103
+ include_debug = include_info = include_error = include_warn = true;
104
+ }
105
+ if (channels === "default") {
106
+ include_debug = false;
107
+ include_info = true;
108
+ include_error = true;
109
+ include_warn = true;
110
+ }
111
+ return;
112
+ }
113
+ // LoggingChannel[]
114
+ if (Array.isArray(channels)) {
115
+ // user configured channels
116
+ channels.forEach((channel) => {
117
+ switch (channel) {
118
+ case "debug":
119
+ include_debug = true;
120
+ break;
121
+ case "error":
122
+ include_error = true;
123
+ break;
124
+ case "info":
125
+ include_info = true;
126
+ break;
127
+ case "warn":
128
+ include_warn = true;
129
+ break;
130
+ default:
131
+ console.warn(stanza_warn, `Ignoring unknown logger channel: ${channel}`);
132
+ }
133
+ });
134
+ }
135
+ }
136
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;AAgBA,sBAEC;AAED,sBAEC;AAED,oBAEC;AAED,oBAEC;AAED,sCAGC;AAED,wCAEC;AAED,wBA0CC;AAnFD,gCAAgC;AAChC,IAAI,aAAkC,CAAC;AAEvC,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,IAAI,aAAa,GAAG,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EAAE;YACjD,QAAQ,OAAO,EAAE,CAAC;gBAChB,KAAK,OAAO;oBACV,aAAa,GAAG,IAAI,CAAC;oBACrB,MAAM;gBACR,KAAK,OAAO;oBACV,aAAa,GAAG,IAAI,CAAC;oBACrB,MAAM;gBACR,KAAK,MAAM;oBACT,YAAY,GAAG,IAAI,CAAC;oBACpB,MAAM;gBACR,KAAK,MAAM;oBACT,YAAY,GAAG,IAAI,CAAC;oBACpB,MAAM;gBACR;oBACE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,oCAAoC,OAAO,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const something = "some new value";
2
+ //# sourceMappingURL=arbitrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbitrary.d.ts","sourceRoot":"","sources":["../../src/misc/arbitrary.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.something = void 0;
4
+ exports.something = 'some new value';
5
+ //# sourceMappingURL=arbitrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbitrary.js","sourceRoot":"","sources":["../../src/misc/arbitrary.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function throwAnError(): void;
2
+ //# sourceMappingURL=throwAnError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throwAnError.d.ts","sourceRoot":"","sources":["../../src/misc/throwAnError.ts"],"names":[],"mappings":"AACA,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwAnError = throwAnError;
4
+ function throwAnError() {
5
+ throw new Error("custom-error");
6
+ }
7
+ //# sourceMappingURL=throwAnError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throwAnError.js","sourceRoot":"","sources":["../../src/misc/throwAnError.ts"],"names":[],"mappings":";;AACA,oCAEC;AAFD,SAAgB,YAAY;IAC1B,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function toLowercase(input: string): string;
2
+ //# sourceMappingURL=toLowercase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toLowercase.d.ts","sourceRoot":"","sources":["../../src/misc/toLowercase.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBjD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toLowercase = toLowercase;
4
+ /*
5
+ Crude version that handles basic latin alphabet.
6
+ */
7
+ function toLowercase(input) {
8
+ let output = "";
9
+ for (let i = 0; i < input.length; i++) {
10
+ let charCode = input.charCodeAt(i);
11
+ // let char = input.charAt(i);
12
+ if (charCode >= 65 && charCode <= 90) {
13
+ let newChar = String.fromCharCode(charCode + 32);
14
+ // console.log(
15
+ // `uppercase: ${i} ${char} ${charCode} newCharCode ${
16
+ // charCode + 32
17
+ // } newChar: ${newChar}`
18
+ // );
19
+ output += newChar;
20
+ }
21
+ else {
22
+ // console.log(`already lowercase: ${i} ${char} ${charCode}`);
23
+ output += input[i];
24
+ }
25
+ }
26
+ return output;
27
+ }
28
+ //# sourceMappingURL=toLowercase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toLowercase.js","sourceRoot":"","sources":["../../src/misc/toLowercase.ts"],"names":[],"mappings":";;AAGA,kCAyBC;AA5BD;;EAEE;AACF,SAAgB,WAAW,CAAC,KAAa;IACvC,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACnC,8BAA8B;QAE9B,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;YACrC,IAAI,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;YAEjD,eAAe;YACf,wDAAwD;YACxD,oBAAoB;YACpB,2BAA2B;YAC3B,KAAK;YAEL,MAAM,IAAI,OAAO,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAE9D,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { PersistentStore, StorageKey } from "../types.ts";
2
+ export declare class DefaultStore implements PersistentStore {
3
+ delete(key: StorageKey): void;
4
+ deserialize(data: string | null): any;
5
+ get(key: string): any;
6
+ serialize(data: any): string;
7
+ set(key: StorageKey, data: any): void;
8
+ }
9
+ //# sourceMappingURL=DefaultStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultStore.d.ts","sourceRoot":"","sources":["../../src/persistent-storage/DefaultStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE/D,qBAAa,YAAa,YAAW,eAAe;IAClD,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAI7B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG;IAQrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAMrB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM;IAI5B,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;CAKtC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultStore = void 0;
4
+ class DefaultStore {
5
+ delete(key) {
6
+ globalThis.localStorage.removeItem(key);
7
+ }
8
+ deserialize(data) {
9
+ if (!data) {
10
+ return '';
11
+ }
12
+ return JSON.parse(data);
13
+ }
14
+ get(key) {
15
+ const raw = globalThis.localStorage.getItem(key);
16
+ return this.deserialize(raw);
17
+ }
18
+ serialize(data) {
19
+ return JSON.stringify(data);
20
+ }
21
+ set(key, data) {
22
+ const serialized = this.serialize(data);
23
+ globalThis.localStorage.setItem(key, serialized);
24
+ }
25
+ }
26
+ exports.DefaultStore = DefaultStore;
27
+ //# sourceMappingURL=DefaultStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultStore.js","sourceRoot":"","sources":["../../src/persistent-storage/DefaultStore.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IACvB,MAAM,CAAC,GAAe;QACpB,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,IAAmB;QAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEjD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,IAAS;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,GAAG,CAAC,GAAe,EAAE,IAAS;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAExC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;CACF;AA5BD,oCA4BC"}
@@ -0,0 +1,73 @@
1
+ export declare const CREATED_KEY = "ls:created";
2
+ export type ExperimentScope = "account" | "user";
3
+ export type AccountFilterGroup = "account" | "guide";
4
+ export type UserFilterGroup = "account";
5
+ export type ExperimentName = string;
6
+ export type ExperimentConfig = {
7
+ readonly customFilters?: CustomFilters | null;
8
+ readonly entryPointName: string;
9
+ readonly filterGroups?: AccountFilterGroup[] | UserFilterGroup[] | null;
10
+ readonly name: ExperimentName;
11
+ readonly readyToRequest?: boolean;
12
+ readonly scope: ExperimentScope;
13
+ };
14
+ export type EntryPointConfig = Pick<ExperimentConfig, "customFilters" | "name" | "readyToRequest"> & {
15
+ readonly filterGroups?: AccountFilterGroup | AccountFilterGroup[] | UserFilterGroup | UserFilterGroup[];
16
+ readonly scope?: ExperimentConfig["scope"];
17
+ };
18
+ export interface Participation {
19
+ active: boolean;
20
+ experimentName: ExperimentName;
21
+ variation?: string | number | boolean;
22
+ }
23
+ export interface Participations {
24
+ [experimentName: ExperimentName]: Participation;
25
+ }
26
+ export interface ParticipationResponseBody {
27
+ inactive?: Participation["active"];
28
+ variation?: Participation["variation"];
29
+ }
30
+ export interface ParticipationRequestBody {
31
+ custom_filters?: CustomFiltersRequest;
32
+ filter_groups?: AccountFilterGroup[] | UserFilterGroup[];
33
+ }
34
+ export type CustomFilterName = string;
35
+ export type CustomFilterValue = string | number | boolean;
36
+ type KnownCustomFilters = {
37
+ experiment_readiness: string | null;
38
+ ineligible: boolean;
39
+ requested_via: string;
40
+ };
41
+ export type CustomFilters = Partial<KnownCustomFilters> & Record<CustomFilterName, CustomFilterValue>;
42
+ export type CustomFiltersRequest = Array<{
43
+ name: CustomFilterName;
44
+ value: CustomFilterValue;
45
+ }>;
46
+ export interface ParticipationInStore {
47
+ experimentName?: Participation["experimentName"];
48
+ variation: Participation["variation"];
49
+ [CREATED_KEY]: number;
50
+ }
51
+ export type StoreData = {
52
+ [K in ExperimentScope]: Record<string, {
53
+ variation: unknown;
54
+ [CREATED_KEY]: number;
55
+ }>;
56
+ };
57
+ export type StoragePossibilities = string | StoreData;
58
+ export type LikeLocalStorage = Omit<Storage, "getItem" | "setItem"> & {
59
+ getItem: (key: string) => StoragePossibilities;
60
+ setItem: (key: string, value: StoragePossibilities) => void;
61
+ };
62
+ export type RenderBlocking = {
63
+ enable: boolean;
64
+ maxWaitSeconds: number;
65
+ };
66
+ export type StorageKey = string;
67
+ export interface PersistentStore {
68
+ delete: (key: StorageKey) => void;
69
+ get: (key: string) => any;
70
+ set: (key: StorageKey, data: any) => void;
71
+ }
72
+ export {};
73
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,kBAAkB,EAAE,GAAG,eAAe,EAAE,GAAG,IAAI,CAAC;IACxE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBA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,CAAC,CAAC;AAEH,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,SAAS,GAAG;KACrB,CAAC,IAAI,eAAe,GAAG,MAAM,CAC5B,MAAM,EACN;QACE,SAAS,EAAE,OAAO,CAAC;QACnB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;KACvB,CACF;CACF,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IACpE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,oBAAoB,CAAC;IAC/C,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IAElC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IAE1B,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC3C"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CREATED_KEY = void 0;
4
+ // import { CREATED_KEY } from "./experiments-store";
5
+ exports.CREATED_KEY = "ls:created";
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACxC,QAAA,WAAW,GAAG,YAAY,CAAC"}
package/package.json CHANGED
@@ -13,10 +13,7 @@
13
13
  "typescript": "^5.9.3"
14
14
  },
15
15
  "exports": {
16
- ".": {
17
- "require": "./dist/index.js",
18
- "default": "./dist/index.js"
19
- },
16
+ ".": "./dist/index.js",
20
17
  "./*.js": "./dist/*.js"
21
18
  },
22
19
  "files": [
@@ -40,6 +37,6 @@
40
37
  "test:watch": "./script/test-watch.sh",
41
38
  "typecheck": "tsc --build --noEmit"
42
39
  },
43
- "version": "2.8.0",
40
+ "version": "2.9.0",
44
41
  "type": "module"
45
42
  }