@uniformdev/context 14.2.1-alpha.34 → 16.0.1-alpha.164
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/LICENSE.txt +2 -2
- package/dist/api/api.d.ts +7 -5
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +2 -1
- package/dist/cli/cli.d.ts +2 -2
- package/dist/cli/cli.js +51 -51
- package/dist/cli/cli.mjs +53 -52
- package/dist/{contextTypes-7f24fc7c.d.ts → contextTypes-572b0d33.d.ts} +1 -1
- package/dist/index.d.ts +58 -24
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{types-6c6360c2.d.ts → types-c12d92cd.d.ts} +153 -87
- package/dist/{v2-manifest.swagger-d0899723.d.ts → v2-manifest.swagger-ff2af13e.d.ts} +9 -0
- package/package.json +10 -5
- package/dist/chunk-2QBWX3VO.mjs +0 -2
- package/dist/chunk-ORM4ZDHU.mjs +0 -1
- package/dist/chunk-PZGIHZYO.mjs +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { c as components, e as external } from './v2-manifest.swagger-
|
1
|
+
import { c as components, e as external } from './v2-manifest.swagger-ff2af13e.js';
|
2
2
|
import * as mitt from 'mitt';
|
3
3
|
|
4
4
|
declare type StorageCommand<TID extends string = string, TData = unknown> = {
|
@@ -100,9 +100,12 @@ declare type VisitorData = {
|
|
100
100
|
controlGroup?: boolean;
|
101
101
|
};
|
102
102
|
declare const emptyVisitorData: () => VisitorData;
|
103
|
+
/**
|
104
|
+
* Expresses a 'patch' to the Uniform Context state
|
105
|
+
*/
|
103
106
|
declare type ContextState = {
|
104
107
|
cookies: Record<string, string>;
|
105
|
-
url
|
108
|
+
url?: URL;
|
106
109
|
quirks: Quirks;
|
107
110
|
enrichments: EnrichmentData[];
|
108
111
|
events: EventData[];
|
@@ -189,25 +192,65 @@ declare abstract class TransitionDataStore {
|
|
189
192
|
getClientTransitionState(): ServerToClientTransitionState | undefined;
|
190
193
|
}
|
191
194
|
|
192
|
-
declare type
|
193
|
-
|
194
|
-
|
195
|
-
|
195
|
+
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
196
|
+
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
197
|
+
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
198
|
+
declare type Signal = SharedTypes['Signal'];
|
199
|
+
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
200
|
+
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
201
|
+
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
202
|
+
declare type StringMatch = SharedTypes['StringMatch'];
|
203
|
+
declare type NumberMatch = SharedTypes['NumberMatch'];
|
204
|
+
declare type TestDefinition = SharedTypes['Test'];
|
205
|
+
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
206
|
+
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
207
|
+
|
208
|
+
/**
|
209
|
+
* The result of evaluating a signal criteria.
|
210
|
+
*/
|
211
|
+
declare type CriteriaEvaluatorResult = {
|
212
|
+
/** Whether the criteria evaluated to true or not */
|
213
|
+
result: boolean;
|
214
|
+
/**
|
215
|
+
* Whether the value of the criteria changed from the previous state
|
216
|
+
* If ALL criteria on a signal have NOT changed, the signal is skipped
|
217
|
+
* and its score is left alone.
|
218
|
+
*/
|
219
|
+
changed: boolean;
|
196
220
|
};
|
197
|
-
declare type
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
221
|
+
declare type CriteriaEvaluatorParameters = {
|
222
|
+
/** The update being made to the Context state */
|
223
|
+
update: ContextStateUpdate;
|
224
|
+
/** Current criteria to evaluate the update against */
|
225
|
+
criteria: SignalCriteria;
|
226
|
+
/**
|
227
|
+
* The storage commands that will be executed by this update.
|
228
|
+
* If the evaluation requires custom commands, push them into this parameter.
|
229
|
+
* NOTE: needing to use this is very rare and should be avoided if possible.
|
230
|
+
*/
|
231
|
+
commands: StorageCommands[];
|
232
|
+
/** The parent signal containing the criteria we are evaluating */
|
233
|
+
signal: SignalData;
|
234
|
+
/** Function to emit log notices to the Context log */
|
235
|
+
onLogMessage?: (message: LogMessage) => void;
|
236
|
+
};
|
237
|
+
declare type SignalData = Signal & {
|
238
|
+
id: string;
|
202
239
|
};
|
203
240
|
/**
|
204
|
-
*
|
205
|
-
*
|
206
|
-
* if it needs to apply score decay. The data store ensures immutability already.
|
207
|
-
*
|
208
|
-
* @returns true if any decay was applied, false otherwise
|
241
|
+
* A type that evaluates a signal criteria type and
|
242
|
+
* decides if it matches the current Context state or not.
|
209
243
|
*/
|
210
|
-
declare type
|
244
|
+
declare type CriteriaEvaluator = ((parameters: CriteriaEvaluatorParameters) => CriteriaEvaluatorResult) & {
|
245
|
+
/** If true the criteria will always execute even if a short-circuit would normally skip it */
|
246
|
+
alwaysExecute?: boolean;
|
247
|
+
};
|
248
|
+
|
249
|
+
declare class GroupCriteriaEvaluator {
|
250
|
+
#private;
|
251
|
+
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
252
|
+
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: SignalData, onLogMessage?: (message: LogMessage) => void): CriteriaEvaluatorResult;
|
253
|
+
}
|
211
254
|
|
212
255
|
/** Defines all error codes and their parameter(s) */
|
213
256
|
declare type LogMessages = {
|
@@ -229,6 +272,8 @@ declare type LogMessages = {
|
|
229
272
|
102: MessageFunc<VisitorData>;
|
230
273
|
/** Storage data was deleted bool: fromAllDevices */
|
231
274
|
103: MessageFunc<boolean>;
|
275
|
+
/** Visitor was assigned or removed from control group */
|
276
|
+
104: MessageFunc<boolean>;
|
232
277
|
/** Storage score was truncated to its cap */
|
233
278
|
110: MessageFunc<{
|
234
279
|
dim: string;
|
@@ -239,13 +284,53 @@ declare type LogMessages = {
|
|
239
284
|
120: MessageFunc;
|
240
285
|
/** Server to client transition score data was loaded */
|
241
286
|
130: MessageFunc<ScoreVector>;
|
242
|
-
/**
|
287
|
+
/** Server to client transition data was discarded */
|
288
|
+
131: MessageFunc;
|
289
|
+
/** Decay function executed */
|
290
|
+
140: MessageFunc<string>;
|
291
|
+
/** Signals evaluation beginning */
|
292
|
+
200: MessageFunc;
|
293
|
+
/** Evaluation of a specific signal beginning */
|
294
|
+
201: MessageFunc<SignalData>;
|
295
|
+
/** Evaluation of a group beginning */
|
296
|
+
202: MessageFunc<SignalCriteriaGroup>;
|
297
|
+
203: MessageFunc<{
|
298
|
+
criteria: SignalCriteria;
|
299
|
+
result: CriteriaEvaluatorResult;
|
300
|
+
explanation: string;
|
301
|
+
}>;
|
302
|
+
/** Result of evaluating a criteria group */
|
303
|
+
204: MessageFunc<CriteriaEvaluatorResult>;
|
304
|
+
/** Personalization placement executing */
|
305
|
+
300: MessageFunc<{
|
306
|
+
name: string;
|
307
|
+
take?: number;
|
308
|
+
}>;
|
309
|
+
/** Personalization placement testing variation */
|
310
|
+
301: MessageFunc<{
|
311
|
+
id: string;
|
312
|
+
op?: string;
|
313
|
+
}>;
|
314
|
+
/** Processed a personalization criteria */
|
315
|
+
302: MessageFunc<{
|
316
|
+
matched: boolean;
|
317
|
+
description: string;
|
318
|
+
}>;
|
319
|
+
/** Final result for a personalized variation */
|
320
|
+
303: MessageFunc<boolean>;
|
321
|
+
/** A/B test placement executing */
|
322
|
+
400: MessageFunc<string>;
|
323
|
+
/** A/B Test definition did not exist */
|
243
324
|
401: MessageFunc<string>;
|
244
325
|
/** Previously shown test variant no longer in variant data */
|
245
326
|
402: MessageFunc<{
|
246
|
-
|
247
|
-
|
327
|
+
missingVariant: string;
|
328
|
+
variants: string[];
|
248
329
|
}>;
|
330
|
+
/** Selected a new A/B test variation */
|
331
|
+
403: MessageFunc<string>;
|
332
|
+
/** Displaying A/B test variation */
|
333
|
+
404: MessageFunc<string>;
|
249
334
|
/** gtag was not present on the page to emit events to */
|
250
335
|
700: MessageFunc;
|
251
336
|
/** Enabled gtag event signal redirection */
|
@@ -253,15 +338,41 @@ declare type LogMessages = {
|
|
253
338
|
};
|
254
339
|
|
255
340
|
declare type Severity = 'debug' | 'info' | 'warn' | 'error';
|
341
|
+
declare type MessageCategory = 'context' | 'storage' | 'testing' | 'personalization' | 'gtag' | 'signals';
|
256
342
|
declare type OutputSeverity = Severity | 'none';
|
257
|
-
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
258
|
-
|
343
|
+
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
344
|
+
/** Category of the message */
|
345
|
+
MessageCategory,
|
346
|
+
/** Log message text */
|
347
|
+
string,
|
348
|
+
/** Log message */
|
349
|
+
...unknown[]
|
350
|
+
];
|
351
|
+
declare type LogMessage = LogMessageSingle | LogMessageGroup;
|
352
|
+
declare type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [
|
259
353
|
severity: Severity,
|
260
354
|
id: TID,
|
261
355
|
...args: Parameters<LogMessages[TID]>
|
262
356
|
];
|
357
|
+
declare type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
|
263
358
|
declare type LogDrain = (message: LogMessage) => void;
|
264
359
|
|
360
|
+
declare type DecayOptions = {
|
361
|
+
now: number;
|
362
|
+
lastUpd: number | undefined;
|
363
|
+
scores: ScoreVector;
|
364
|
+
sessionScores: ScoreVector;
|
365
|
+
onLogMessage?: (message: LogMessage) => void;
|
366
|
+
};
|
367
|
+
/**
|
368
|
+
* Computes decay of visitor scores over time.
|
369
|
+
* NOTE: it is expected that this function mutates the incoming score vectors,
|
370
|
+
* if it needs to apply score decay. The data store ensures immutability already.
|
371
|
+
*
|
372
|
+
* @returns true if any decay was applied, false otherwise
|
373
|
+
*/
|
374
|
+
declare type DecayFunction = (options: DecayOptions) => boolean;
|
375
|
+
|
265
376
|
declare type VisitorDataStoreOptions = {
|
266
377
|
/** Transition storage used to transfer server or edge side execution state to the client. Unused for client side only. */
|
267
378
|
transitionStore?: TransitionDataStore;
|
@@ -285,7 +396,7 @@ declare type VisitorDataStoreOptions = {
|
|
285
396
|
* Because the feed of the URL may be marginally delayed (for example in React it's in an effect so it's a second render),
|
286
397
|
* one render might be done with _no_ scores unless we dropped the server scores in temporarily, resulting in a flash of unpersonalized content.
|
287
398
|
*/
|
288
|
-
|
399
|
+
onServerTransitionReceived?: (state: ServerToClientTransitionState) => void;
|
289
400
|
/** Called when a log message is emitted from the data store */
|
290
401
|
onLogMessage?: (message: LogMessage) => void;
|
291
402
|
};
|
@@ -347,9 +458,10 @@ declare class VisitorDataStore {
|
|
347
458
|
declare class ManifestInstance {
|
348
459
|
#private;
|
349
460
|
readonly data: ManifestV2;
|
350
|
-
constructor({ manifest, evaluator, }: {
|
461
|
+
constructor({ manifest, evaluator, onLogMessage, }: {
|
351
462
|
manifest: ManifestV2;
|
352
463
|
evaluator?: GroupCriteriaEvaluator;
|
464
|
+
onLogMessage?: (message: LogMessage) => void;
|
353
465
|
});
|
354
466
|
rollForControlGroup(): boolean;
|
355
467
|
getTest(name: string): TestDefinition | undefined;
|
@@ -361,32 +473,6 @@ declare class ManifestInstance {
|
|
361
473
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
362
474
|
}
|
363
475
|
|
364
|
-
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
365
|
-
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
366
|
-
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
367
|
-
declare type Signal = SharedTypes['Signal'];
|
368
|
-
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
369
|
-
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
370
|
-
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
371
|
-
declare type StringMatch = SharedTypes['StringMatch'];
|
372
|
-
declare type NumberMatch = SharedTypes['NumberMatch'];
|
373
|
-
declare type TestDefinition = SharedTypes['Test'];
|
374
|
-
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
375
|
-
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
376
|
-
|
377
|
-
/**
|
378
|
-
* A type that evaluates a signal criteria type and
|
379
|
-
* decides if it matches the current Context state or not.
|
380
|
-
* @returns {boolean} - true for a match, false for no match
|
381
|
-
* */
|
382
|
-
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => boolean;
|
383
|
-
|
384
|
-
declare class GroupCriteriaEvaluator {
|
385
|
-
#private;
|
386
|
-
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
387
|
-
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string): boolean;
|
388
|
-
}
|
389
|
-
|
390
476
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
391
477
|
declare type BehaviorTag = {
|
392
478
|
beh?: EnrichmentData[];
|
@@ -426,39 +512,6 @@ declare type TestResult<TVariant> = {
|
|
426
512
|
*/
|
427
513
|
variantAssigned: boolean;
|
428
514
|
};
|
429
|
-
/** Defines the shape of arbitrarily tagged content where the tag can be for a test, behaviour, or personalization */
|
430
|
-
declare type TaggedContent = PersonalizedVariant & TestVariant & BehaviorTag & {
|
431
|
-
/** @deprecated no longer used */
|
432
|
-
intents?: IntentTagVector;
|
433
|
-
};
|
434
|
-
/**
|
435
|
-
* A vector keyed by intent ID which contains magnitude and configuration data for each intent ID that has been tagged
|
436
|
-
* @deprecated no longer used
|
437
|
-
*/
|
438
|
-
declare type IntentTagVector = Record<string, IntentTagAxis>;
|
439
|
-
/**
|
440
|
-
* An individual intent tag magnitude value in an IntentTagVector
|
441
|
-
* @deprecated no longer used
|
442
|
-
*/
|
443
|
-
interface IntentTagAxis {
|
444
|
-
/** If this is true, don't use this intent tag when calculating personalization. If false or unspecified, personalization is allowed. */
|
445
|
-
noPn?: boolean;
|
446
|
-
/** If this is true, don't use this intent tag when calculating behavior. If false or unspecified, behavior is allowed. */
|
447
|
-
noBeh?: boolean;
|
448
|
-
/**
|
449
|
-
* If this is true, ANY strength in the tagged intent will result in selecting this variant to personalize,
|
450
|
-
* regardless of other intents' strengths. If more than one tag is override,
|
451
|
-
* they are sorted normally.
|
452
|
-
*/
|
453
|
-
override?: boolean;
|
454
|
-
/**
|
455
|
-
* Sets the minimum visitor score required to trigger this variation.
|
456
|
-
* If more than one intent tag matches, the one with the highest threshold will win.
|
457
|
-
*/
|
458
|
-
threshold?: number;
|
459
|
-
/** Strength of the intent tag. If unspecified, IntentTagStrength.Normal should be inferred */
|
460
|
-
str?: number | string;
|
461
|
-
}
|
462
515
|
|
463
516
|
declare type PersonalizeOptions<TVariant> = {
|
464
517
|
/** Name of placement (sent to analytics) */
|
@@ -467,8 +520,9 @@ declare type PersonalizeOptions<TVariant> = {
|
|
467
520
|
variations: Iterable<TVariant>;
|
468
521
|
/** Maximum number of variants to place (default: 1) */
|
469
522
|
take?: number;
|
523
|
+
onLogMessage?: (message: LogMessage) => void;
|
470
524
|
};
|
471
|
-
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ context, variations, take, }: PersonalizeOptions<TVariant> & {
|
525
|
+
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
|
472
526
|
context: Context;
|
473
527
|
}): PersonalizedResult<TVariant>;
|
474
528
|
|
@@ -525,8 +579,9 @@ declare type TestOptions<TVariant extends TestVariant> = {
|
|
525
579
|
/** Variations that are being tested. */
|
526
580
|
variations: TVariant[];
|
527
581
|
};
|
528
|
-
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, }: TestOptions<TVariant> & {
|
582
|
+
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
529
583
|
context: Context;
|
584
|
+
onLogMessage?: ((message: LogMessage) => void) | undefined;
|
530
585
|
}) => TestResult<TVariant>;
|
531
586
|
|
532
587
|
/**
|
@@ -595,7 +650,7 @@ declare type ContextEvents = {
|
|
595
650
|
* Note that event handlers attached to this event will not catch events
|
596
651
|
* logged during initialisation of the Context unless they are attached as plugins to the constructor.
|
597
652
|
*/
|
598
|
-
log: LogMessage;
|
653
|
+
log: LogMessage | LogMessageGroup;
|
599
654
|
/** Test variant has been selected */
|
600
655
|
testResult: TestEvent;
|
601
656
|
/** Personalization variants have been selected */
|
@@ -620,8 +675,19 @@ declare class Context implements Context {
|
|
620
675
|
};
|
621
676
|
};
|
622
677
|
readonly storage: VisitorDataStore;
|
678
|
+
/**
|
679
|
+
* Updates the Context with new data of any sort, such as
|
680
|
+
* new URLs, cookies, quirks, and enrichments.
|
681
|
+
*
|
682
|
+
* Only properties that are set in the data parameter will be updated.
|
683
|
+
* Properties that do not result in a changed state,
|
684
|
+
* i.e. pushing the same URL or cookies as before,
|
685
|
+
* will NOT result in a recomputation of signal state.
|
686
|
+
*/
|
623
687
|
update(newData: Partial<ContextState>): Promise<void>;
|
688
|
+
/** use test() instead */
|
624
689
|
getTestVariantId(testName: string): string | null | undefined;
|
690
|
+
/** use test() instead */
|
625
691
|
setTestVariantId(testName: string, variantId: string): void;
|
626
692
|
/**
|
627
693
|
* Writes a message to the Context log sink.
|
@@ -703,4 +769,4 @@ declare global {
|
|
703
769
|
}
|
704
770
|
}
|
705
771
|
|
706
|
-
export {
|
772
|
+
export { ContextEvents as $, AggregateDimension as A, SetTestCommand as B, ContextPlugin as C, DecayFunction as D, EnrichmentCategory as E, SetControlGroupCommand as F, GroupCriteriaEvaluator as G, DecayOptions as H, IdentifyCommand as I, VisitorDataStoreOptions as J, VisitorDataStoreEvents as K, LogDrain as L, ManifestInstance as M, NumberMatch as N, OutputSeverity as O, PersonalizationManifest as P, Quirks as Q, VisitorDataStore as R, StorageCommands as S, TransitionDataStore as T, ServerToClientTransitionState as U, VisitorData as V, SERVER_STATE_ID as W, TransitionDataStoreEvents as X, ContextOptions as Y, PersonalizationEvent as Z, TestEvent as _, TransitionDataStoreOptions as a, Context as a0, LogMessages as a1, Severity as a2, MessageCategory as a3, MessageFunc as a4, LogMessageSingle as a5, LogMessageGroup as a6, testVariations as a7, TestOptions as a8, PersonalizeOptions as a9, personalizeVariations as aa, DimensionMatch as ab, BehaviorTag as ac, PersonalizedVariant as ad, PersonalizedResult as ae, TestVariant as af, TestResult as ag, DevToolsUiVersion as ah, DevToolsState as ai, DevToolsActions as aj, DevToolsEvent as ak, DevToolsEvents as al, DevToolsLogEvent as am, DevToolsDataEvent as an, DevToolsHelloEvent as ao, DevToolsUpdateEvent as ap, DevToolsRawCommandsEvent as aq, DevToolsForgetEvent as ar, CriteriaEvaluator as b, StringMatch as c, ScoreVector as d, VariantMatchCriteria as e, LogMessage as f, ManifestV2 as g, Signal as h, SignalCriteriaGroup as i, SignalCriteria as j, TestDefinition as k, AggregateDimensionInput as l, CriteriaEvaluatorResult as m, CriteriaEvaluatorParameters as n, SignalData as o, Tests as p, EnrichmentData as q, EventData as r, emptyVisitorData as s, ContextState as t, ContextStateUpdate as u, StorageCommand as v, ModifyScoreCommand as w, ModifySessionScoreCommand as x, SetConsentCommand as y, SetQuirkCommand as z };
|
@@ -41,6 +41,15 @@ interface components {
|
|
41
41
|
schemas: {
|
42
42
|
ManifestV2: {
|
43
43
|
project: {
|
44
|
+
/**
|
45
|
+
* Format: uuid
|
46
|
+
* @description is not present unless getting a preview manifest
|
47
|
+
*/
|
48
|
+
id?: string;
|
49
|
+
/** @description is not present unless getting a preview manifest */
|
50
|
+
name?: string;
|
51
|
+
/** @description is not present unless getting a preview manifest */
|
52
|
+
ui_version?: number;
|
44
53
|
pz?: components["schemas"]["PersonalizationManifest"];
|
45
54
|
/** @description A/B test settings */
|
46
55
|
test?: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "
|
3
|
+
"version": "16.0.1-alpha.164+c3b15fc3f",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -49,14 +49,16 @@
|
|
49
49
|
"benchmark:run": "node ./dist/storage.benchmark.js"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
|
-
"@types/
|
53
|
-
"@
|
52
|
+
"@types/js-cookie": "3.0.2",
|
53
|
+
"@types/yargs": "17.0.10",
|
54
|
+
"@uniformdev/cli": "^16.0.1-alpha.164+c3b15fc3f",
|
54
55
|
"benny": "3.7.1",
|
55
|
-
"yargs": "17.
|
56
|
+
"yargs": "17.5.1"
|
56
57
|
},
|
57
58
|
"dependencies": {
|
58
59
|
"dequal": "^2.0.2",
|
59
60
|
"isomorphic-unfetch": "^3.1.0",
|
61
|
+
"js-cookie": "3.0.1",
|
60
62
|
"mitt": "^3.0.0",
|
61
63
|
"p-limit": "^3.1.0",
|
62
64
|
"rfdc": "^1.3.0"
|
@@ -64,5 +66,8 @@
|
|
64
66
|
"files": [
|
65
67
|
"/dist"
|
66
68
|
],
|
67
|
-
"
|
69
|
+
"publishConfig": {
|
70
|
+
"access": "public"
|
71
|
+
},
|
72
|
+
"gitHead": "c3b15fc3f3101dd990d7adfe84cb7e0bad77899d"
|
68
73
|
}
|
package/dist/chunk-2QBWX3VO.mjs
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{d as w,e as r,f as n,i as s}from"./chunk-PZGIHZYO.mjs";s();var N=async b=>await b(),j=class extends Error{constructor(t,e,i,c,o){super(`${t}
|
2
|
-
${c}${o?" "+o:""} (${e} ${i})`);this.errorMessage=t;this.fetchMethod=e;this.fetchUri=i;this.statusCode=c;this.statusText=o;Object.setPrototypeOf(this,j.prototype)}};s();s();var a=class{constructor(t){w(this,"options");var e,i,c,o,p,l;if(!t.apiKey&&!t.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options={...t,fetch:(e=t.fetch)!=null?e:fetch,apiHost:(i=t.apiHost)!=null?i:"https://uniform.app",apiKey:(c=t.apiKey)!=null?c:null,projectId:(o=t.projectId)!=null?o:null,bearerToken:(p=t.bearerToken)!=null?p:null,limitPolicy:(l=t.limitPolicy)!=null?l:N}}async apiClient(t,e){return this.options.limitPolicy(async()=>{var o;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},c=await fetch(t.toString(),{...e,headers:{...e==null?void 0:e.headers,...i}});if(!c.ok){let p="";try{let l=await c.text();try{let x=JSON.parse(l);x.errorMessage?p=Array.isArray(x.errorMessage)?x.errorMessage.join(", "):x.errorMessage:p=l}catch(x){p=l}}catch(l){p="General error"}throw new j(p,(o=e==null?void 0:e.method)!=null?o:"GET",t.toString(),c.status)}return(e==null?void 0:e.expectNoContent)?null:await c.json()})}createUrl(t,e){let i=new URL(`${this.options.apiHost}${t}`);return Object.entries(e!=null?e:{}).forEach(([c,o])=>{var p;typeof o!="undefined"&&o!==null&&i.searchParams.append(c,(p=o==null?void 0:o.toString())!=null?p:"")}),i}};var P,E=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(E,P),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(E,P));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(E,P));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},S=E;P=new WeakMap,n(S,P,"/api/v2/aggregate");s();var y,C,u=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(u,y),{...t,projectId:e});return await this.apiClient(i)}async upsertCategory(t){let e=this.createUrl(r(u,y));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeCategory(t){let e=this.createUrl(r(u,y));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async upsertValue(t){let e=this.createUrl(r(u,C));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeValue(t){let e=this.createUrl(r(u,C));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},G=u;y=new WeakMap,C=new WeakMap,n(G,y,"/api/v1/enrichments"),n(G,C,"/api/v1/enrichment-values");s();var O,R=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(R,O),{...t,projectId:e});return await this.apiClient(i)}},k=R;O=new WeakMap,n(k,O,"/api/v2/manifest");s();var d,U=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(U,d),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(U,d));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(U,d));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},A=U;d=new WeakMap,n(A,d,"/api/v2/quirk");s();var g,T=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(T,g),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(T,g));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(T,g));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},D=T;g=new WeakMap,n(D,g,"/api/v2/signal");s();var f,I=class extends a{constructor(t){super(t)}async get(t){let{projectId:e}=this.options,i=this.createUrl(r(I,f),{...t,projectId:e});return await this.apiClient(i)}async upsert(t){let e=this.createUrl(r(I,f));await this.apiClient(e,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async remove(t){let e=this.createUrl(r(I,f));await this.apiClient(e,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},L=I;f=new WeakMap,n(L,f,"/api/v2/test");export{N as a,j as b,a as c,S as d,G as e,k as f,A as g,D as h,L as i};
|
package/dist/chunk-ORM4ZDHU.mjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{i as R}from"./chunk-PZGIHZYO.mjs";R();var A="_";export{A as a};
|
package/dist/chunk-PZGIHZYO.mjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
var a=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var s=(t,e,o)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var _=t=>i(t,"__esModule",{value:!0});var x=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,o)=>(typeof require!="undefined"?require:e)[o]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var g=(t,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!l.call(t,r)&&(o||r!=="default")&&i(t,r,{get:()=>e[r],enumerable:!(m=p(e,r))||m.enumerable});return t},D=(t,e)=>g(_(i(t!=null?a(f(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var F=(t,e,o)=>(s(t,typeof e!="symbol"?e+"":e,o),o),n=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var L=(t,e,o)=>(n(t,e,"read from private field"),o?o.call(t):e.get(t)),P=(t,e,o)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,o)},R=(t,e,o,m)=>(n(t,e,"write to private field"),m?m.call(t,o):e.set(t,o),o);var T=(t,e,o)=>(n(t,e,"access private method"),o);var h=d(()=>{});export{x as a,u as b,D as c,F as d,L as e,P as f,R as g,T as h,h as i};
|