@picked/client 0.0.1-dev.1787019239195 → 0.0.1-dev.1787543060859
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/dist/.tsbuildinfo +1 -1
- package/dist/api-CahTmEWe.cjs +1 -0
- package/dist/api-DwTNwuWK.js +33 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/telemetry/index.js +1 -0
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/feature-flag-allocation.md +43 -1
- package/dist/docs/how-to/install-the-sdk.md +2 -2
- package/dist/docs/how-to/read-a-feature-flag.md +22 -10
- package/dist/docs/how-to/read-a-referenced-entry.md +4 -6
- package/dist/docs/how-to/render-a-step-form.md +3 -4
- package/dist/docs/how-to/switch-workspaces.md +1 -2
- package/dist/docs/reference/dashboard/features.mdx +45 -5
- package/dist/docs/reference/delivery-api/workspace-schema.md +12 -1
- package/dist/docs/reference/pickedql/dimensions.md +6 -0
- package/dist/docs/reference/pickedql/virtual-functions.md +16 -5
- package/dist/docs/reference/sdk/content.md +6 -9
- package/dist/docs/reference/sdk/features.md +24 -6
- package/dist/docs/reference/sdk/steps.md +3 -4
- package/dist/docs/reference/sdk/type-generation.md +18 -4
- package/dist/docs/reference/tools/cli.md +3 -5
- package/dist/docs/reference/tools/vite-plugin.md +1 -5
- package/dist/docs/tutorials/first-experience.mdx +4 -5
- package/dist/emit-D-tLiWL1.cjs +1 -0
- package/dist/emit-Ds2EG7CB.js +14 -0
- package/dist/esm/index.js +275 -490
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/telemetry/index.js +101 -0
- package/dist/esm/server/index.js +1 -1
- package/dist/plugin-BcFzHPC7.cjs +1 -0
- package/dist/{plugin-Bb2fJVFr.js → plugin-L5y4NdFX.js} +83 -47
- package/dist/{provider-DZEDUlIk.cjs → provider-BLDm3i8g.cjs} +1 -1
- package/dist/{provider-B8vTLrFT.js → provider-Dx6VjvZg.js} +1 -1
- package/dist/request-observer-BXDfOU0V.cjs +1 -0
- package/dist/request-observer-DtG0cRfz.js +19 -0
- package/dist/types/data-source/api.d.ts.map +1 -1
- package/dist/types/data-source/provider.d.ts +11 -1
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/data-source/request-observer.d.ts +46 -0
- package/dist/types/data-source/request-observer.d.ts.map +1 -0
- package/dist/types/entities/feature/feature.d.ts +53 -5
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +4 -0
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/types/picked.d.ts +13 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/hash.d.ts +53 -1
- package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +3 -4
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/telemetry/emit.d.ts +18 -0
- package/dist/types/plugins/telemetry/emit.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/index.d.ts +4 -0
- package/dist/types/plugins/telemetry/index.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/plugin-summary.d.ts +10 -0
- package/dist/types/plugins/telemetry/plugin-summary.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/plugin.d.ts +36 -0
- package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -0
- package/dist/types/schema-registry.d.ts +16 -0
- package/dist/types/schema-registry.d.ts.map +1 -1
- package/dist/types/utils/user-timing.d.ts +18 -0
- package/dist/types/utils/user-timing.d.ts.map +1 -0
- package/dist/version-BqU6f22c.cjs +1 -0
- package/dist/version-DAFO6eas.js +256 -0
- package/package.json +16 -4
- package/dist/api-TWnRLh3X.cjs +0 -1
- package/dist/api-uttjU_Tg.js +0 -22
- package/dist/plugin-hFQIiHOB.cjs +0 -1
- package/dist/version-CfTz7TK0.cjs +0 -1
- package/dist/version-DjCWhJD5.js +0 -4
package/dist/types/picked.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @file Picked client — the main entry point for the Picked SDK. */
|
|
2
2
|
import { type Effect, type EventCallable, type Store, type StoreWritable } from 'effector';
|
|
3
|
+
import type { ExperienceContentResponse, ProjectConfig } from '@picked/delivery-api-client';
|
|
3
4
|
import { type Experience, type LaunchExperienceOptions } from './entities/experience/experience';
|
|
4
5
|
import { type Plugin, type PluginConfigIndex } from './entities/plugin/plugin';
|
|
5
6
|
import { type CreateClientOptions } from './client';
|
|
@@ -16,7 +17,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
17
|
import type { Field } from './entities/field/field';
|
|
17
18
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
19
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader
|
|
20
|
+
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
20
21
|
import type { Action } from './entities/action/action';
|
|
21
22
|
import { type Condition } from './entities/condition/condition';
|
|
22
23
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -74,6 +75,16 @@ export declare class Picked {
|
|
|
74
75
|
*/
|
|
75
76
|
previewEmbedderOrigins: string[] | null;
|
|
76
77
|
private readonly plugins;
|
|
78
|
+
/**
|
|
79
|
+
* Names of the plugins registered on this client, in registration order.
|
|
80
|
+
*
|
|
81
|
+
* Covers every plugin, including one whose `setup` returns no config. Complete once
|
|
82
|
+
* the constructor has run, which is where the configured plugins register.
|
|
83
|
+
*
|
|
84
|
+
* @returns {string[]} The registered plugin names.
|
|
85
|
+
* @example client.pluginNames // ['dynamic-experiences', 'single-page-app']
|
|
86
|
+
*/
|
|
87
|
+
get pluginNames(): string[];
|
|
77
88
|
private readonly dataProviders;
|
|
78
89
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
79
90
|
readonly events: EventHistoryStore;
|
|
@@ -172,7 +183,7 @@ export declare class Picked {
|
|
|
172
183
|
getByName: (name: string) => Store<import(".").FeatureIndexItem | undefined>;
|
|
173
184
|
listStore: Store<import(".").FeatureBucket[]>;
|
|
174
185
|
getEvokableFeature: (featureName: string) => Store<() => Promise<import(".").FeatureBucketValue>>;
|
|
175
|
-
getFeatureResult: (featureName:
|
|
186
|
+
getFeatureResult: <K extends string>(featureName: K) => Store<import(".").FeatureResult<import("./schema-registry").FeatureValueFor<K>> | undefined>;
|
|
176
187
|
};
|
|
177
188
|
readonly conditions: {
|
|
178
189
|
register: (condition: Condition) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAA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IACD;;;;;;;;;OASG;IAEH,qBAAqB,kBACJ,MAAM,YACX,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IAED;;;;;;;;OAQG;IAEH,kBAAkB,iBAAwB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;IAED;;;;;;;;OAQG;IAEH,mBAAmB,kBAAyB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAED,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,eAAgB,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
|
|
@@ -24,9 +24,14 @@ export declare function fnv1a32(input: string): number;
|
|
|
24
24
|
* publishing a new version re-runs `decide` against the current weight and an
|
|
25
25
|
* unchanged weight keeps the same audience.
|
|
26
26
|
*
|
|
27
|
+
* This is the boolean path's input. A multi-variant feature does not roll once
|
|
28
|
+
* and look the result up; {@link allocateVariant} scores each arm on its own
|
|
29
|
+
* seed. One roll per feature is still what keeps features independent of one
|
|
30
|
+
* another, per ADR-0018.
|
|
31
|
+
*
|
|
27
32
|
* @param {string} sessionId - Current session id, stable across page loads.
|
|
28
33
|
* @param {string} featureId - Feature the roll is for.
|
|
29
|
-
* @returns {number} A value in the range 0
|
|
34
|
+
* @returns {number} A value in the range 0 to 99.
|
|
30
35
|
* @example
|
|
31
36
|
* ```typescript
|
|
32
37
|
* const diceRoll = featureDiceRoll('sess_1', 'winter-sale')
|
|
@@ -50,4 +55,51 @@ export declare function featureDiceRoll(sessionId: string, featureId: string): n
|
|
|
50
55
|
* ```
|
|
51
56
|
*/
|
|
52
57
|
export declare function isAllocated(diceRoll: number, weight: number): boolean;
|
|
58
|
+
/** The fields {@link allocateVariant} needs from an arm. */
|
|
59
|
+
export interface AllocatableVariant {
|
|
60
|
+
key: string;
|
|
61
|
+
weight: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Picks the arm a session lands in, scoring each arm independently.
|
|
65
|
+
*
|
|
66
|
+
* Each arm is hashed on its own key and scored against its own weight, and the
|
|
67
|
+
* highest score wins. An arm's score therefore depends on nothing but the
|
|
68
|
+
* session, the feature and that arm's own weight, which is what gives the two
|
|
69
|
+
* properties an author is entitled to assume:
|
|
70
|
+
*
|
|
71
|
+
* - Editing one arm's weight moves sessions only into or out of that arm. Two
|
|
72
|
+
* arms the author did not touch never trade sessions with each other.
|
|
73
|
+
* - Widening an arm only admits sessions and never evicts one already inside,
|
|
74
|
+
* the same ratchet {@link isAllocated} gives the boolean path. Narrowing is
|
|
75
|
+
* its mirror.
|
|
76
|
+
*
|
|
77
|
+
* Neither holds for cumulative ranges, where an arm's interval depends on every
|
|
78
|
+
* arm ordered before it, so a boundary shift upstream drags unrelated arms
|
|
79
|
+
* across it.
|
|
80
|
+
*
|
|
81
|
+
* Scores are compared, never summed, so the result is invariant under scaling
|
|
82
|
+
* every weight by the same factor: `1:1:2` and `10:10:20` allocate identically.
|
|
83
|
+
* Ties break on the key so that the arms' arrival order cannot matter — nothing
|
|
84
|
+
* in the delivery pipeline promises one.
|
|
85
|
+
*
|
|
86
|
+
* The chosen arm is returned whole rather than by key, so a caller reading its
|
|
87
|
+
* value needs no second lookup — and cannot resolve a duplicate key to a
|
|
88
|
+
* different arm than the one scored.
|
|
89
|
+
*
|
|
90
|
+
* @template T
|
|
91
|
+
* @param {string} sessionId - Current session id, stable across page loads.
|
|
92
|
+
* @param {string} featureKey - Feature being allocated.
|
|
93
|
+
* @param {readonly T[]} variants - The feature's arms, in any order.
|
|
94
|
+
* @returns {T | null} The chosen arm, or null when the set decides nobody.
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // 'hero-b' takes three sessions in four; 'false' takes the fourth.
|
|
98
|
+
* allocateVariant('sess_1', 'hero', [
|
|
99
|
+
* { key: 'hero-b', weight: 3 },
|
|
100
|
+
* { key: 'false', weight: 1 },
|
|
101
|
+
* ])
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function allocateVariant<T extends AllocatableVariant>(sessionId: string, featureKey: string, variants: readonly T[]): T | null;
|
|
53
105
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/hash.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7C;AA8BD
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/hash.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7C;AA8BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAUrE;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AA4CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,kBAAkB,EAC1D,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB,CAAC,GAAG,IAAI,CAmBV"}
|
|
@@ -3,4 +3,5 @@ export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from '
|
|
|
3
3
|
export { createClientHeaders, fetchSchema } from '@picked/delivery-api-client';
|
|
4
4
|
export { registerPickedBundle } from '../../data-source/registry';
|
|
5
5
|
export type * from './types';
|
|
6
|
+
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigNode, } from '@picked/delivery-api-client';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGzF,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAI9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,mBAAmB,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGzF,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAI9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,mBAAmB,SAAS,CAAA;AAI5B,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,6BAA6B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ProjectConfig } from '@picked/delivery-api-client';
|
|
1
2
|
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
3
|
import type { Picked } from '../../picked';
|
|
3
|
-
import type { ProjectConfig } from './types';
|
|
4
4
|
export { fetchProject, fetchExperienceContent } from '../../data-source/api';
|
|
5
5
|
/**
|
|
6
6
|
* Synchronously registers a complete project config with the client: features, conditions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAK1C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AA+J5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AA2QD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA4DjD"}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* @file Plugin-specific types for the dynamic-experiences plugin.
|
|
3
3
|
*
|
|
4
4
|
* The wire-format shapes the Delivery API returns live in `@picked/delivery-api-client`,
|
|
5
|
-
* which stays runtime-agnostic. This file
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* which stays runtime-agnostic. This file holds the types that only mean something inside
|
|
6
|
+
* the client: the content loader and the virtual data module
|
|
7
|
+
* `@picked/vite-plugin-picked` generates.
|
|
8
8
|
*/
|
|
9
9
|
import type { ExperienceContentResponse, ProjectConfig } from '@picked/delivery-api-client';
|
|
10
|
-
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigNode, } from '@picked/delivery-api-client';
|
|
11
10
|
/**
|
|
12
11
|
* Function that resolves an experience's content blobs. Set on the Picked client by
|
|
13
12
|
* `dynamicExperiencesPlugin` (selecting from virtual module, getContent override, or API)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3F
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,6FAA6F;IAC7F,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;IACrB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iEAAiE;IACjE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE,sBAAsB,CAAA;CACzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The lazily-imported half of the telemetry plugin.
|
|
3
|
+
*
|
|
4
|
+
* This module holds the only import of the OTLP emitter, so bundlers give it
|
|
5
|
+
* its own chunk and the plugin can load it after first paint.
|
|
6
|
+
*/
|
|
7
|
+
import { type SpanAttributes, type TelemetrySpan } from '@picked/telemetry';
|
|
8
|
+
/**
|
|
9
|
+
* Sends a batch of spans and resolves once the attempt has finished.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} endpoint - OTLP HTTP trace endpoint.
|
|
12
|
+
* @param {SpanAttributes} resource - Resource attributes describing this SDK instance.
|
|
13
|
+
* @param {TelemetrySpan[]} spans - Spans to send.
|
|
14
|
+
* @returns {Promise<void>} Resolves when the batch has been attempted.
|
|
15
|
+
* @example await flushSpans(endpoint, { 'service.name': 'picked-sdk' }, spans)
|
|
16
|
+
*/
|
|
17
|
+
export declare function flushSpans(endpoint: string, resource: SpanAttributes, spans: TelemetrySpan[]): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../src/plugins/telemetry/emit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA0B,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEnG;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,aAAa,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/telemetry/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACjE,mBAAmB,UAAU,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @file Summarises a client's registered plugin names for telemetry. */
|
|
2
|
+
/**
|
|
3
|
+
* Sorts and caps a client's registered plugin names for reporting.
|
|
4
|
+
*
|
|
5
|
+
* @param {string[]} registered - Every plugin name registered on the client.
|
|
6
|
+
* @returns {string[]} The names, sorted, capped at the reporting limit.
|
|
7
|
+
* @example summarisePlugins(['window', 'analytics']) // ['analytics', 'window']
|
|
8
|
+
*/
|
|
9
|
+
export declare function summarisePlugins(registered: string[]): string[];
|
|
10
|
+
//# sourceMappingURL=plugin-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-summary.d.ts","sourceRoot":"","sources":["../../../../src/plugins/telemetry/plugin-summary.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAKzE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE/D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
|
+
/** Plugin name under which this plugin registers. */
|
|
3
|
+
export declare const TELEMETRY_PLUGIN_NAME = "telemetry";
|
|
4
|
+
/**
|
|
5
|
+
* Spans held before a flush is forced.
|
|
6
|
+
*
|
|
7
|
+
* A session buffers between flushes, so this is what bounds the buffer on a
|
|
8
|
+
* long-lived page that keeps making delivery requests.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_BUFFERED_SPANS = 50;
|
|
11
|
+
/** Options for {@link telemetryPlugin}. */
|
|
12
|
+
export interface TelemetryPluginOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Fraction of sessions to trace, between 0 and 1.
|
|
15
|
+
*
|
|
16
|
+
* Decided once per client, before the first request, since it also decides
|
|
17
|
+
* whether `traceparent` is sent.
|
|
18
|
+
*
|
|
19
|
+
* @default 1
|
|
20
|
+
*/
|
|
21
|
+
sampleRate?: number;
|
|
22
|
+
/** OTLP HTTP trace endpoint. Defaults to Picked's collector. */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates the browser telemetry plugin.
|
|
27
|
+
*
|
|
28
|
+
* @param {TelemetryPluginOptions} [options] - Sampling and endpoint overrides.
|
|
29
|
+
* @returns {Plugin} A plugin to register with the Picked client.
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const client = createClient({ plugins: [telemetryPlugin({ sampleRate: 0.05 })] })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function telemetryPlugin(options?: TelemetryPluginOptions): Plugin;
|
|
36
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/telemetry/plugin.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAM1D,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,cAAc,CAAA;AAQhD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAsED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAiExE"}
|
|
@@ -24,6 +24,9 @@ type StepFieldKeysMap = PickedSchemaRegistry extends {
|
|
|
24
24
|
type FieldValuesMap = PickedSchemaRegistry extends {
|
|
25
25
|
fieldValues: infer F extends Record<string, unknown>;
|
|
26
26
|
} ? F : never;
|
|
27
|
+
type FeatureValuesMap = PickedSchemaRegistry extends {
|
|
28
|
+
featureValues: infer F extends Record<string, boolean | string>;
|
|
29
|
+
} ? F : never;
|
|
27
30
|
/**
|
|
28
31
|
* Widens a key union so it still accepts a key the workspace does not declare.
|
|
29
32
|
*
|
|
@@ -46,6 +49,19 @@ type AnyString = string & Record<never, never>;
|
|
|
46
49
|
export type KnownFeatureKeys = PickedSchemaRegistry extends {
|
|
47
50
|
featureKeys: infer K extends string;
|
|
48
51
|
} ? K : string;
|
|
52
|
+
/**
|
|
53
|
+
* Value a feature key can resolve to.
|
|
54
|
+
*
|
|
55
|
+
* A text feature declares its arms in the schema, so its key narrows to that union. Every
|
|
56
|
+
* other key — a boolean feature, a feature registered in application code, a
|
|
57
|
+
* `?picked-feature=` override — reads as the general `boolean | string`, which is the
|
|
58
|
+
* documented contract for a key the workspace does not declare.
|
|
59
|
+
*
|
|
60
|
+
* @param {PropertyKey} K - Feature key from the workspace schema.
|
|
61
|
+
* @example
|
|
62
|
+
* type Hero = FeatureValueFor<'hero'>
|
|
63
|
+
*/
|
|
64
|
+
export type FeatureValueFor<K extends PropertyKey> = FeatureValuesMap extends never ? boolean | string : K extends keyof FeatureValuesMap ? FeatureValuesMap[K] : boolean | string;
|
|
49
65
|
/**
|
|
50
66
|
* Feature keys — the workspace union when augmented, plus any locally-defined key.
|
|
51
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-registry.d.ts","sourceRoot":"","sources":["../../src/schema-registry.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAA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,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAClC,WAAW,CAAC,MAAM,CAAC,SAAS,SAAS,CAAC,MAAM,QAAQ,CAAC,EAAE,GACnD,iBAAiB,CAAC,QAAQ,CAAC,GAC3B,WAAW,CAAC,MAAM,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAChD,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAClC,OAAO,GACP,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAClC,OAAO,CAAA;AAEf,YAAY,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records the start-chain begin mark.
|
|
3
|
+
*
|
|
4
|
+
* @returns {void}
|
|
5
|
+
* @example markStartBegin()
|
|
6
|
+
*/
|
|
7
|
+
export declare function markStartBegin(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Records the start-chain measure, spanning from the begin mark to now.
|
|
10
|
+
*
|
|
11
|
+
* Uses the two-argument `measure(name, startMark)` form, whose end defaults to
|
|
12
|
+
* now and which is available wherever User Timing Level 2 is.
|
|
13
|
+
*
|
|
14
|
+
* @returns {void}
|
|
15
|
+
* @example measureStart()
|
|
16
|
+
*/
|
|
17
|
+
export declare function measureStart(): void;
|
|
18
|
+
//# sourceMappingURL=user-timing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-timing.d.ts","sourceRoot":"","sources":["../../../src/utils/user-timing.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAQrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAQnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./logger-CSTvAyyB.cjs"),t=require("./storage-DUw9UJ2h.cjs");let n=require("effector"),r=require("@withease/factories");var i=(0,n.createDomain)(`feature`);function a(e){return e?.enabled===!1}function o(e){return e===`true`||e!==`false`&&e}function s(e){let t=e.indexOf(`:`);if(t<=0)return null;let n=e.substring(0,t),r=e.substring(t+1);return r.length===0?null:{id:n,bucket:o(r)}}var c=(0,r.createFactory)(({client:r})=>{let s=i.store({}),c=i.store([]),l=(0,n.createApi)(s,{register(e,t){return{...e,[t.id]:t.feature}}}),u=(0,n.createEvent)();(0,n.sample)({clock:u,source:s,filter:(e,{id:t})=>e[t]!==void 0,fn:(e,{id:t})=>`Feature '${t}' already registered. Registering again will override the previous registration.`}).watch(t=>e.t(`warn`,t)),(0,n.sample)({clock:u,fn:({id:e,feature:t})=>Object.freeze({id:e,feature:{id:e,feature:{...t,id:e}}}),target:l.register});let d=(0,n.createEffect)(async({id:e,key:n,storage:r=`local`,enabled:i})=>{if(i===!1)return null;let a=t.t(`feature:${e}:${n}`,`global`),s=(r===`session`?t.r:t.n).get(a).text();return s?{id:e,key:n,bucket:o(s),storage:r}:null}),f=(0,n.createEffect)(e=>{if(!e)return null;let n=t.t(`feature:${e.id}:${e.key}`,`global`);(e.storage===`session`?t.r:t.n).set(n,e.bucket)}),p=new Map,m=(0,n.attach)({source:{allFeaturesStore:s,resolvedFeaturesStore:c},effect:async({allFeaturesStore:e,resolvedFeaturesStore:t},{id:n,decide:r,key:i})=>{let o=t.find(e=>e.id===n&&e.key===i);if(o)return o;let s=e[n];if(!s)throw Error(`Feature with id '${n}' not found`);if(a(s.feature))return{id:s.id,bucket:!1,key:i,storage:s.feature.storage};let c=p.get(`${n}:${i}`);if(c!==void 0){let e=await c;return{id:s.id,bucket:e,key:i,storage:s.feature.storage}}let l=r();p.set(`${n}:${i}`,l);let u=await l;return{id:s.id,bucket:u,key:i,storage:s.feature.storage}}});(0,n.sample)({clock:l.register,fn:e=>{let{id:t,feature:n}=e;return{id:t,key:n.feature.key,storage:n.feature.storage,enabled:n.feature.enabled}},target:d}),(0,n.sample)({source:s,clock:m.doneData,filter:(e,t)=>!a(e[t.id]?.feature),fn:(e,t)=>{let{id:n,bucket:r,storage:i}=t,a=e[n]?.feature.key;return a?{key:a,id:n,bucket:r,storage:i}:null},target:f});let h=(0,n.combine)({allFeaturesStore:s,resolvedFeaturesStore:c}).map(({allFeaturesStore:e,resolvedFeaturesStore:t})=>Object.values(e).map(e=>{let n=t.find(t=>t.id===e.id&&t.key===e.feature.key);return n?{id:e.id,name:e.feature.name,key:e.feature.key,enabled:e.feature.enabled,weight:e.feature.weight,valueType:e.feature.valueType,variants:e.feature.variants,getBucket:()=>({id:e.id,bucket:n.bucket}),isResolved:!0}:{id:e.id,name:e.feature.name,key:e.feature.key,enabled:e.feature.enabled,weight:e.feature.weight,valueType:e.feature.valueType,variants:e.feature.variants,getBucket:async()=>await m(e.feature),isResolved:!1}}));(0,n.sample)({clock:m.doneData,source:{resolvedFeatures:c,allFeatures:s},filter:({resolvedFeatures:e,allFeatures:t},{id:n,key:r})=>!a(t[n]?.feature)&&!e.some(e=>e.id===n&&e.key===r),fn:(e,t)=>t,target:r.eventBus.prepend(e=>({type:`feature_decide`,feature:e}))}),(0,n.sample)({clock:[d.doneData,m.doneData],source:{resolvedFeatures:c,allFeatures:s},fn:({resolvedFeatures:e,allFeatures:t},n)=>!n||a(t[n.id]?.feature)||e.some(e=>e.id===n.id&&e.key===n.key)?e:[...e,n],target:c});function g(e){return h.map(t=>t.find(t=>t.id===e))}let _=new Map,v=new Map,y=new Map;function b(e){let t=_.get(e);if(t)return t;let n=g(e);return _.set(e,n),n}function x(e){return s.map(t=>t[e],{skipVoid:!1})}function S(e){let t=(0,n.createStore)(async()=>void 0,{skipVoid:!1}),r=b(e),i=(0,n.attach)({source:r,effect:async e=>{if(e)return async()=>(await e.getBucket()).bucket}});return(0,n.sample)({clock:r,target:i}),(0,n.sample)({clock:i.doneData,filter:e=>e!==void 0,target:t}),i(),t}function C(e){let t=v.get(e);if(t)return t;let n=S(e);return v.set(e,n),n}function w(e){let t=C(e),r=(0,n.createStore)(void 0,{skipVoid:!1}),i=(0,n.attach)({source:t,mapParams:(e,t)=>t,effect:(0,n.createEffect)(async e=>await e())});return(0,n.sample)({clock:i.doneData,fn:t=>{if(t!==void 0)return{id:e,bucket:t}},target:r}),(0,n.sample)({clock:t,target:i}),i(),r}function T(e){let t=y.get(e);if(t)return t;let n=w(e);return y.set(e,n),n}return{register:u,getById:b,getByName:x,listStore:h,getEvokableFeature:C,getFeatureResult:T}});function l(e){return(0,r.invoke)(c,e)}var u=(e,t,n)=>{n.register({id:e,feature:t})},d=()=>`0.0.1-dev.1787543060859`;Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { t as e } from "./logger-DMN6TxJJ.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "./storage-1MW3-_As.js";
|
|
3
|
+
import { attach as i, combine as a, createApi as o, createDomain as s, createEffect as c, createEvent as l, createStore as u, sample as d } from "effector";
|
|
4
|
+
import { createFactory as f, invoke as p } from "@withease/factories";
|
|
5
|
+
//#region src/entities/feature/feature.ts
|
|
6
|
+
var m = s("feature");
|
|
7
|
+
function h(e) {
|
|
8
|
+
return e?.enabled === !1;
|
|
9
|
+
}
|
|
10
|
+
function g(e) {
|
|
11
|
+
return e === "true" || e !== "false" && e;
|
|
12
|
+
}
|
|
13
|
+
function _(e) {
|
|
14
|
+
let t = e.indexOf(":");
|
|
15
|
+
if (t <= 0) return null;
|
|
16
|
+
let n = e.substring(0, t), r = e.substring(t + 1);
|
|
17
|
+
return r.length === 0 ? null : {
|
|
18
|
+
id: n,
|
|
19
|
+
bucket: g(r)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var v = f(({ client: s }) => {
|
|
23
|
+
let f = m.store({}), p = m.store([]), _ = o(f, { register(e, t) {
|
|
24
|
+
return {
|
|
25
|
+
...e,
|
|
26
|
+
[t.id]: t.feature
|
|
27
|
+
};
|
|
28
|
+
} }), v = l();
|
|
29
|
+
d({
|
|
30
|
+
clock: v,
|
|
31
|
+
source: f,
|
|
32
|
+
filter: (e, { id: t }) => e[t] !== void 0,
|
|
33
|
+
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
34
|
+
}).watch((t) => /* @__PURE__ */ e("warn", t)), d({
|
|
35
|
+
clock: v,
|
|
36
|
+
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
37
|
+
id: e,
|
|
38
|
+
feature: {
|
|
39
|
+
id: e,
|
|
40
|
+
feature: {
|
|
41
|
+
...t,
|
|
42
|
+
id: e
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
target: _.register
|
|
47
|
+
});
|
|
48
|
+
let y = c(async ({ id: e, key: i, storage: a = "local", enabled: o }) => {
|
|
49
|
+
if (o === !1) return null;
|
|
50
|
+
let s = r(`feature:${e}:${i}`, "global"), c = (a === "session" ? n : t).get(s).text();
|
|
51
|
+
return c ? {
|
|
52
|
+
id: e,
|
|
53
|
+
key: i,
|
|
54
|
+
bucket: g(c),
|
|
55
|
+
storage: a
|
|
56
|
+
} : null;
|
|
57
|
+
}), b = c((e) => {
|
|
58
|
+
if (!e) return null;
|
|
59
|
+
let i = r(`feature:${e.id}:${e.key}`, "global");
|
|
60
|
+
(e.storage === "session" ? n : t).set(i, e.bucket);
|
|
61
|
+
}), x = /* @__PURE__ */ new Map(), S = i({
|
|
62
|
+
source: {
|
|
63
|
+
allFeaturesStore: f,
|
|
64
|
+
resolvedFeaturesStore: p
|
|
65
|
+
},
|
|
66
|
+
effect: async ({ allFeaturesStore: e, resolvedFeaturesStore: t }, { id: n, decide: r, key: i }) => {
|
|
67
|
+
let a = t.find((e) => e.id === n && e.key === i);
|
|
68
|
+
if (a) return a;
|
|
69
|
+
let o = e[n];
|
|
70
|
+
if (!o) throw Error(`Feature with id '${n}' not found`);
|
|
71
|
+
if (h(o.feature)) return {
|
|
72
|
+
id: o.id,
|
|
73
|
+
bucket: !1,
|
|
74
|
+
key: i,
|
|
75
|
+
storage: o.feature.storage
|
|
76
|
+
};
|
|
77
|
+
let s = x.get(`${n}:${i}`);
|
|
78
|
+
if (s !== void 0) {
|
|
79
|
+
let e = await s;
|
|
80
|
+
return {
|
|
81
|
+
id: o.id,
|
|
82
|
+
bucket: e,
|
|
83
|
+
key: i,
|
|
84
|
+
storage: o.feature.storage
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
let c = r();
|
|
88
|
+
x.set(`${n}:${i}`, c);
|
|
89
|
+
let l = await c;
|
|
90
|
+
return {
|
|
91
|
+
id: o.id,
|
|
92
|
+
bucket: l,
|
|
93
|
+
key: i,
|
|
94
|
+
storage: o.feature.storage
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
d({
|
|
99
|
+
clock: _.register,
|
|
100
|
+
fn: (e) => {
|
|
101
|
+
let { id: t, feature: n } = e;
|
|
102
|
+
return {
|
|
103
|
+
id: t,
|
|
104
|
+
key: n.feature.key,
|
|
105
|
+
storage: n.feature.storage,
|
|
106
|
+
enabled: n.feature.enabled
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
target: y
|
|
110
|
+
}), d({
|
|
111
|
+
source: f,
|
|
112
|
+
clock: S.doneData,
|
|
113
|
+
filter: (e, t) => !h(e[t.id]?.feature),
|
|
114
|
+
fn: (e, t) => {
|
|
115
|
+
let { id: n, bucket: r, storage: i } = t, a = e[n]?.feature.key;
|
|
116
|
+
return a ? {
|
|
117
|
+
key: a,
|
|
118
|
+
id: n,
|
|
119
|
+
bucket: r,
|
|
120
|
+
storage: i
|
|
121
|
+
} : null;
|
|
122
|
+
},
|
|
123
|
+
target: b
|
|
124
|
+
});
|
|
125
|
+
let C = a({
|
|
126
|
+
allFeaturesStore: f,
|
|
127
|
+
resolvedFeaturesStore: p
|
|
128
|
+
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
129
|
+
let n = t.find((t) => t.id === e.id && t.key === e.feature.key);
|
|
130
|
+
return n ? {
|
|
131
|
+
id: e.id,
|
|
132
|
+
name: e.feature.name,
|
|
133
|
+
key: e.feature.key,
|
|
134
|
+
enabled: e.feature.enabled,
|
|
135
|
+
weight: e.feature.weight,
|
|
136
|
+
valueType: e.feature.valueType,
|
|
137
|
+
variants: e.feature.variants,
|
|
138
|
+
getBucket: () => ({
|
|
139
|
+
id: e.id,
|
|
140
|
+
bucket: n.bucket
|
|
141
|
+
}),
|
|
142
|
+
isResolved: !0
|
|
143
|
+
} : {
|
|
144
|
+
id: e.id,
|
|
145
|
+
name: e.feature.name,
|
|
146
|
+
key: e.feature.key,
|
|
147
|
+
enabled: e.feature.enabled,
|
|
148
|
+
weight: e.feature.weight,
|
|
149
|
+
valueType: e.feature.valueType,
|
|
150
|
+
variants: e.feature.variants,
|
|
151
|
+
getBucket: async () => await S(e.feature),
|
|
152
|
+
isResolved: !1
|
|
153
|
+
};
|
|
154
|
+
}));
|
|
155
|
+
d({
|
|
156
|
+
clock: S.doneData,
|
|
157
|
+
source: {
|
|
158
|
+
resolvedFeatures: p,
|
|
159
|
+
allFeatures: f
|
|
160
|
+
},
|
|
161
|
+
filter: ({ resolvedFeatures: e, allFeatures: t }, { id: n, key: r }) => !h(t[n]?.feature) && !e.some((e) => e.id === n && e.key === r),
|
|
162
|
+
fn: (e, t) => t,
|
|
163
|
+
target: s.eventBus.prepend((e) => ({
|
|
164
|
+
type: "feature_decide",
|
|
165
|
+
feature: e
|
|
166
|
+
}))
|
|
167
|
+
}), d({
|
|
168
|
+
clock: [y.doneData, S.doneData],
|
|
169
|
+
source: {
|
|
170
|
+
resolvedFeatures: p,
|
|
171
|
+
allFeatures: f
|
|
172
|
+
},
|
|
173
|
+
fn: ({ resolvedFeatures: e, allFeatures: t }, n) => !n || h(t[n.id]?.feature) || e.some((e) => e.id === n.id && e.key === n.key) ? e : [...e, n],
|
|
174
|
+
target: p
|
|
175
|
+
});
|
|
176
|
+
function w(e) {
|
|
177
|
+
return C.map((t) => t.find((t) => t.id === e));
|
|
178
|
+
}
|
|
179
|
+
let T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
|
|
180
|
+
function O(e) {
|
|
181
|
+
let t = T.get(e);
|
|
182
|
+
if (t) return t;
|
|
183
|
+
let n = w(e);
|
|
184
|
+
return T.set(e, n), n;
|
|
185
|
+
}
|
|
186
|
+
function k(e) {
|
|
187
|
+
return f.map((t) => t[e], { skipVoid: !1 });
|
|
188
|
+
}
|
|
189
|
+
function A(e) {
|
|
190
|
+
let t = u(async () => void 0, { skipVoid: !1 }), n = O(e), r = i({
|
|
191
|
+
source: n,
|
|
192
|
+
effect: async (e) => {
|
|
193
|
+
if (e) return async () => (await e.getBucket()).bucket;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return d({
|
|
197
|
+
clock: n,
|
|
198
|
+
target: r
|
|
199
|
+
}), d({
|
|
200
|
+
clock: r.doneData,
|
|
201
|
+
filter: (e) => e !== void 0,
|
|
202
|
+
target: t
|
|
203
|
+
}), r(), t;
|
|
204
|
+
}
|
|
205
|
+
function j(e) {
|
|
206
|
+
let t = E.get(e);
|
|
207
|
+
if (t) return t;
|
|
208
|
+
let n = A(e);
|
|
209
|
+
return E.set(e, n), n;
|
|
210
|
+
}
|
|
211
|
+
function M(e) {
|
|
212
|
+
let t = j(e), n = u(void 0, { skipVoid: !1 }), r = i({
|
|
213
|
+
source: t,
|
|
214
|
+
mapParams: (e, t) => t,
|
|
215
|
+
effect: c(async (e) => await e())
|
|
216
|
+
});
|
|
217
|
+
return d({
|
|
218
|
+
clock: r.doneData,
|
|
219
|
+
fn: (t) => {
|
|
220
|
+
if (t !== void 0) return {
|
|
221
|
+
id: e,
|
|
222
|
+
bucket: t
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
target: n
|
|
226
|
+
}), d({
|
|
227
|
+
clock: t,
|
|
228
|
+
target: r
|
|
229
|
+
}), r(), n;
|
|
230
|
+
}
|
|
231
|
+
function N(e) {
|
|
232
|
+
let t = D.get(e);
|
|
233
|
+
if (t) return t;
|
|
234
|
+
let n = M(e);
|
|
235
|
+
return D.set(e, n), n;
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
register: v,
|
|
239
|
+
getById: O,
|
|
240
|
+
getByName: k,
|
|
241
|
+
listStore: C,
|
|
242
|
+
getEvokableFeature: j,
|
|
243
|
+
getFeatureResult: N
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
function y(e) {
|
|
247
|
+
return p(v, e);
|
|
248
|
+
}
|
|
249
|
+
var b = (e, t, n) => {
|
|
250
|
+
n.register({
|
|
251
|
+
id: e,
|
|
252
|
+
feature: t
|
|
253
|
+
});
|
|
254
|
+
}, x = () => "0.0.1-dev.1787543060859";
|
|
255
|
+
//#endregion
|
|
256
|
+
export { b as i, y as n, _ as r, x as t };
|