@reform-society/agera-core 0.2.0 → 0.3.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.
- package/dist/index.d.ts +14 -1
- package/dist/index.js +27 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -396,6 +396,19 @@ type DeviceInput = {
|
|
|
396
396
|
};
|
|
397
397
|
declare function detectDeviceType(input: DeviceInput): DeviceType;
|
|
398
398
|
//#endregion
|
|
399
|
+
//#region src/visitor.d.ts
|
|
400
|
+
declare const VISITOR_ID_STORAGE_KEY = "agera:vid";
|
|
401
|
+
/**
|
|
402
|
+
* Read the semi-persistent pseudonymous visitor id from storage, generating
|
|
403
|
+
* and persisting a new one when absent. Used only to correlate requests from
|
|
404
|
+
* the same browser in crm-api logs — never stored server-side.
|
|
405
|
+
*
|
|
406
|
+
* Returns null when storage can't be read or written (private mode, quota,
|
|
407
|
+
* blocked storage): an unpersisted id would look like a new visitor on every
|
|
408
|
+
* page load, so callers omit the header instead.
|
|
409
|
+
*/
|
|
410
|
+
declare function getOrCreateVisitorId(storage: StorageAccessor): string | null;
|
|
411
|
+
//#endregion
|
|
399
412
|
//#region src/crm-fetch.d.ts
|
|
400
413
|
type CrmFetchOptions = {
|
|
401
414
|
waitForResponse?: boolean;
|
|
@@ -446,5 +459,5 @@ declare function assembleCrmRequest({
|
|
|
446
459
|
//#region src/polling.d.ts
|
|
447
460
|
declare function matchesFormat(example: unknown, value: unknown): boolean;
|
|
448
461
|
//#endregion
|
|
449
|
-
export { type AssembleCrmRequestParams, type BandQuizResults, CRM_CONTACT_KEYS, type CompositePredicate, type CounterDisplayConfig, type CounterPayload, type CounterResponse, type CounterUpdateConfig, type CrmCommand, type CrmConfig, type CrmContactKey, type CrmDispatch, type CrmFetchOptions, type CrmFetchResult, type CrmFrontendKey, type CrmGateway, type CrmGatewayResult, type CrmGroupedAnswer, type CrmJsonGroups, type CrmOutcome, type CrmV2PatchRequest, type CrmV2Payload, type CrmV2Request, type DeviceInput, type DeviceType, type ErrorMessages, type FetchBasinJWTOptions, type InsertDirective, type JsonValue, type JwtPayload, type MemoryCache, type MemoryCacheOptions, type MemoryCacheSetOptions, type PassQuizResults, type PlacesMessageKey, type PlacesMessages, type Predicate, type PredicateOp, type ProgressInfo, type ProgressModeInfo, type QuestionMetrics, type QuizBandDefinition, type QuizConfig, type QuizOutcomeModel, type QuizPassFailConfig, type QuizQuestionInput, type QuizQuestionModel, type QuizQuestionResult, type QuizQuestionState, type QuizResults, type QuizScoringModel, type QuizSectionConfig, type QuizSectionResults, type ResolveValueSources, type ScoreQuizResults, type SessionState, type ShareConfig, type SimplePredicate, type SplitConfig, type StepState, type StorageAccessor, type SurveyOptions, type Utms, type ValidationRule, type Validators, type WeightedQuizResults, aggregateWeightedScores, answersChanged, assembleCrmRequest, buildContext, buildCounterPayload, buildFcrmUtms, calculateScoreResults, calculateSectionResults, calculateWinner, computeAutoTarget, createMemoryCache, createSessionStore, createStepsStore, crmFetch, decodeJwtPayload, deriveBandResults, derivePassResults, deriveQuestionState, detectDeviceType, errorMessages, evaluateNextMap, evaluatePredicate, evaluateShowIf, executeCrm, extractUtms, fetchBasinJWT, fetchCounter, flattenObject, formatCounterValue, getErrorMessagesForLanguage, getPhoneExample, getPlacesMessagesForLanguage, getPostalExample, groupCrmAnswers, inferCounterName, isCounterResponse, isCrmContactKey, isJwtExpired, isSafeRedirectUrl, matchesFormat, mergeAnswers, parseCounterUpdateAttr, parseInsertDirective, parseInsertDirectives, resolveValue, scoreExactQuestion, scorePartialQuestion, scoreQuiz, scoreQuizQuestions, serializeCrmJsonGroups, updateUrlWithParams, validators };
|
|
462
|
+
export { type AssembleCrmRequestParams, type BandQuizResults, CRM_CONTACT_KEYS, type CompositePredicate, type CounterDisplayConfig, type CounterPayload, type CounterResponse, type CounterUpdateConfig, type CrmCommand, type CrmConfig, type CrmContactKey, type CrmDispatch, type CrmFetchOptions, type CrmFetchResult, type CrmFrontendKey, type CrmGateway, type CrmGatewayResult, type CrmGroupedAnswer, type CrmJsonGroups, type CrmOutcome, type CrmV2PatchRequest, type CrmV2Payload, type CrmV2Request, type DeviceInput, type DeviceType, type ErrorMessages, type FetchBasinJWTOptions, type InsertDirective, type JsonValue, type JwtPayload, type MemoryCache, type MemoryCacheOptions, type MemoryCacheSetOptions, type PassQuizResults, type PlacesMessageKey, type PlacesMessages, type Predicate, type PredicateOp, type ProgressInfo, type ProgressModeInfo, type QuestionMetrics, type QuizBandDefinition, type QuizConfig, type QuizOutcomeModel, type QuizPassFailConfig, type QuizQuestionInput, type QuizQuestionModel, type QuizQuestionResult, type QuizQuestionState, type QuizResults, type QuizScoringModel, type QuizSectionConfig, type QuizSectionResults, type ResolveValueSources, type ScoreQuizResults, type SessionState, type ShareConfig, type SimplePredicate, type SplitConfig, type StepState, type StorageAccessor, type SurveyOptions, type Utms, VISITOR_ID_STORAGE_KEY, type ValidationRule, type Validators, type WeightedQuizResults, aggregateWeightedScores, answersChanged, assembleCrmRequest, buildContext, buildCounterPayload, buildFcrmUtms, calculateScoreResults, calculateSectionResults, calculateWinner, computeAutoTarget, createMemoryCache, createSessionStore, createStepsStore, crmFetch, decodeJwtPayload, deriveBandResults, derivePassResults, deriveQuestionState, detectDeviceType, errorMessages, evaluateNextMap, evaluatePredicate, evaluateShowIf, executeCrm, extractUtms, fetchBasinJWT, fetchCounter, flattenObject, formatCounterValue, getErrorMessagesForLanguage, getOrCreateVisitorId, getPhoneExample, getPlacesMessagesForLanguage, getPostalExample, groupCrmAnswers, inferCounterName, isCounterResponse, isCrmContactKey, isJwtExpired, isSafeRedirectUrl, matchesFormat, mergeAnswers, parseCounterUpdateAttr, parseInsertDirective, parseInsertDirectives, resolveValue, scoreExactQuestion, scorePartialQuestion, scoreQuiz, scoreQuizQuestions, serializeCrmJsonGroups, updateUrlWithParams, validators };
|
|
450
463
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1115,6 +1115,32 @@ function detectDeviceType(input) {
|
|
|
1115
1115
|
return "desktop";
|
|
1116
1116
|
}
|
|
1117
1117
|
//#endregion
|
|
1118
|
+
//#region src/visitor.ts
|
|
1119
|
+
const VISITOR_ID_STORAGE_KEY = "agera:vid";
|
|
1120
|
+
function generateVisitorId() {
|
|
1121
|
+
return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Read the semi-persistent pseudonymous visitor id from storage, generating
|
|
1125
|
+
* and persisting a new one when absent. Used only to correlate requests from
|
|
1126
|
+
* the same browser in crm-api logs — never stored server-side.
|
|
1127
|
+
*
|
|
1128
|
+
* Returns null when storage can't be read or written (private mode, quota,
|
|
1129
|
+
* blocked storage): an unpersisted id would look like a new visitor on every
|
|
1130
|
+
* page load, so callers omit the header instead.
|
|
1131
|
+
*/
|
|
1132
|
+
function getOrCreateVisitorId(storage) {
|
|
1133
|
+
try {
|
|
1134
|
+
const existing = storage.getItem(VISITOR_ID_STORAGE_KEY);
|
|
1135
|
+
if (existing) return existing;
|
|
1136
|
+
const id = generateVisitorId();
|
|
1137
|
+
storage.setItem(VISITOR_ID_STORAGE_KEY, id);
|
|
1138
|
+
return id;
|
|
1139
|
+
} catch {
|
|
1140
|
+
return null;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
//#endregion
|
|
1118
1144
|
//#region src/crm-fetch.ts
|
|
1119
1145
|
const noop = () => {};
|
|
1120
1146
|
async function crmFetch(url, payload, options = {}) {
|
|
@@ -1234,6 +1260,6 @@ function matchesFormat(example, value) {
|
|
|
1234
1260
|
return example === value;
|
|
1235
1261
|
}
|
|
1236
1262
|
//#endregion
|
|
1237
|
-
export { CRM_CONTACT_KEYS, aggregateWeightedScores, answersChanged, assembleCrmRequest, buildContext, buildCounterPayload, buildFcrmUtms, calculateScoreResults, calculateSectionResults, calculateWinner, computeAutoTarget, createMemoryCache, createSessionStore, createStepsStore, crmFetch, decodeJwtPayload, deriveBandResults, derivePassResults, deriveQuestionState, detectDeviceType, errorMessages, evaluateNextMap, evaluatePredicate, evaluateShowIf, executeCrm, extractUtms, fetchBasinJWT, fetchCounter, flattenObject, formatCounterValue, getErrorMessagesForLanguage, getPhoneExample, getPlacesMessagesForLanguage, getPostalExample, groupCrmAnswers, inferCounterName, isCounterResponse, isCrmContactKey, isJwtExpired, isSafeRedirectUrl, matchesFormat, mergeAnswers, parseCounterUpdateAttr, parseInsertDirective, parseInsertDirectives, resolveValue, scoreExactQuestion, scorePartialQuestion, scoreQuiz, scoreQuizQuestions, serializeCrmJsonGroups, updateUrlWithParams, validators };
|
|
1263
|
+
export { CRM_CONTACT_KEYS, VISITOR_ID_STORAGE_KEY, aggregateWeightedScores, answersChanged, assembleCrmRequest, buildContext, buildCounterPayload, buildFcrmUtms, calculateScoreResults, calculateSectionResults, calculateWinner, computeAutoTarget, createMemoryCache, createSessionStore, createStepsStore, crmFetch, decodeJwtPayload, deriveBandResults, derivePassResults, deriveQuestionState, detectDeviceType, errorMessages, evaluateNextMap, evaluatePredicate, evaluateShowIf, executeCrm, extractUtms, fetchBasinJWT, fetchCounter, flattenObject, formatCounterValue, getErrorMessagesForLanguage, getOrCreateVisitorId, getPhoneExample, getPlacesMessagesForLanguage, getPostalExample, groupCrmAnswers, inferCounterName, isCounterResponse, isCrmContactKey, isJwtExpired, isSafeRedirectUrl, matchesFormat, mergeAnswers, parseCounterUpdateAttr, parseInsertDirective, parseInsertDirectives, resolveValue, scoreExactQuestion, scorePartialQuestion, scoreQuiz, scoreQuizQuestions, serializeCrmJsonGroups, updateUrlWithParams, validators };
|
|
1238
1264
|
|
|
1239
1265
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reform-society/agera-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "DOM-free core logic for Agera",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
38
|
-
"tsdown": "^0.21.
|
|
38
|
+
"tsdown": "^0.21.10",
|
|
39
39
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
40
|
-
"vite": "
|
|
41
|
-
"vitest": "^4.1.
|
|
40
|
+
"vite": "7.3.5",
|
|
41
|
+
"vitest": "^4.1.11"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"loglevel": "^1.9.2",
|
|
45
|
-
"nanostores": "^1.
|
|
45
|
+
"nanostores": "^1.5.2"
|
|
46
46
|
}
|
|
47
47
|
}
|