@syntrologie/adapt-faq 0.0.0-semantically-released
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/FAQWidget.d.ts +31 -0
- package/dist/FAQWidget.d.ts.map +1 -0
- package/dist/FAQWidget.js +332 -0
- package/dist/cdn.d.ts +38 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/cdn.js +36 -0
- package/dist/editor.d.ts +17 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +280 -0
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +43 -0
- package/dist/schema.d.ts +653 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +103 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/package.json +49 -0
package/dist/schema.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - Config Schema
|
|
3
|
+
*
|
|
4
|
+
* Zod schema for validating FAQ accordion configuration.
|
|
5
|
+
* Demonstrates compositional action pattern with per-item showWhen.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Decision Strategy Schema (simplified for this package)
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const ConditionZ = z
|
|
12
|
+
.object({
|
|
13
|
+
type: z.string(),
|
|
14
|
+
})
|
|
15
|
+
.passthrough();
|
|
16
|
+
const RuleZ = z.object({
|
|
17
|
+
conditions: z.array(ConditionZ),
|
|
18
|
+
value: z.unknown(),
|
|
19
|
+
});
|
|
20
|
+
const RuleStrategyZ = z.object({
|
|
21
|
+
type: z.literal('rules'),
|
|
22
|
+
rules: z.array(RuleZ),
|
|
23
|
+
default: z.unknown(),
|
|
24
|
+
});
|
|
25
|
+
const ScoreStrategyZ = z.object({
|
|
26
|
+
type: z.literal('score'),
|
|
27
|
+
field: z.string(),
|
|
28
|
+
threshold: z.number(),
|
|
29
|
+
above: z.unknown(),
|
|
30
|
+
below: z.unknown(),
|
|
31
|
+
});
|
|
32
|
+
const ModelStrategyZ = z.object({
|
|
33
|
+
type: z.literal('model'),
|
|
34
|
+
modelId: z.string(),
|
|
35
|
+
inputs: z.array(z.string()),
|
|
36
|
+
outputMapping: z.record(z.unknown()),
|
|
37
|
+
default: z.unknown(),
|
|
38
|
+
});
|
|
39
|
+
const ExternalStrategyZ = z.object({
|
|
40
|
+
type: z.literal('external'),
|
|
41
|
+
endpoint: z.string(),
|
|
42
|
+
method: z.enum(['GET', 'POST']).optional(),
|
|
43
|
+
default: z.unknown(),
|
|
44
|
+
timeoutMs: z.number().optional(),
|
|
45
|
+
});
|
|
46
|
+
const DecisionStrategyZ = z.discriminatedUnion('type', [
|
|
47
|
+
RuleStrategyZ,
|
|
48
|
+
ScoreStrategyZ,
|
|
49
|
+
ModelStrategyZ,
|
|
50
|
+
ExternalStrategyZ,
|
|
51
|
+
]);
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// FAQ Question Schema
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Schema for a single FAQ question (compositional action).
|
|
57
|
+
*/
|
|
58
|
+
export const FAQQuestionSchema = z.object({
|
|
59
|
+
kind: z.literal('faq:question'),
|
|
60
|
+
config: z.object({
|
|
61
|
+
/** Unique identifier for this question */
|
|
62
|
+
id: z.string().min(1, 'ID is required'),
|
|
63
|
+
/** The question text */
|
|
64
|
+
question: z.string().min(1, 'Question is required'),
|
|
65
|
+
/** The answer text (supports basic markdown) */
|
|
66
|
+
answer: z.string().min(1, 'Answer is required'),
|
|
67
|
+
/** Optional category for grouping */
|
|
68
|
+
category: z.string().optional(),
|
|
69
|
+
}),
|
|
70
|
+
/** Per-item activation strategy (null = always show) */
|
|
71
|
+
showWhen: DecisionStrategyZ.nullable().optional(),
|
|
72
|
+
});
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// FAQ Config Schema
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Full configuration schema for adaptive-faq.
|
|
78
|
+
*/
|
|
79
|
+
export const configSchema = z.object({
|
|
80
|
+
/** Whether only one or multiple questions can be expanded at once */
|
|
81
|
+
expandBehavior: z.enum(['single', 'multiple']).default('single'),
|
|
82
|
+
/** Whether to show a search/filter input */
|
|
83
|
+
searchable: z.boolean().default(false),
|
|
84
|
+
/** Color theme */
|
|
85
|
+
theme: z.enum(['light', 'dark', 'auto']).default('auto'),
|
|
86
|
+
/** FAQ questions (compositional actions) */
|
|
87
|
+
actions: z.array(FAQQuestionSchema).default([]),
|
|
88
|
+
});
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Validation Helpers
|
|
91
|
+
// ============================================================================
|
|
92
|
+
/**
|
|
93
|
+
* Validate a FAQ question action.
|
|
94
|
+
*/
|
|
95
|
+
export function validateFAQQuestion(data) {
|
|
96
|
+
return FAQQuestionSchema.safeParse(data);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Validate the full FAQ config.
|
|
100
|
+
*/
|
|
101
|
+
export function validateFAQConfig(data) {
|
|
102
|
+
return configSchema.safeParse(data);
|
|
103
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive FAQ - Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the FAQ accordion adaptive.
|
|
5
|
+
* Demonstrates compositional action pattern with per-item showWhen.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Simplified DecisionStrategy type for this package.
|
|
9
|
+
* Full definition is in @syntrologie/runtime-sdk.
|
|
10
|
+
*/
|
|
11
|
+
export type DecisionStrategy<T = unknown> = RuleStrategy<T> | ScoreStrategy<T> | ModelStrategy<T> | ExternalStrategy<T>;
|
|
12
|
+
export interface RuleStrategy<T = unknown> {
|
|
13
|
+
type: 'rules';
|
|
14
|
+
rules: Array<{
|
|
15
|
+
conditions: Array<Record<string, unknown>>;
|
|
16
|
+
value: T;
|
|
17
|
+
}>;
|
|
18
|
+
default: T;
|
|
19
|
+
}
|
|
20
|
+
export interface ScoreStrategy<T = unknown> {
|
|
21
|
+
type: 'score';
|
|
22
|
+
field: string;
|
|
23
|
+
threshold: number;
|
|
24
|
+
above: T;
|
|
25
|
+
below: T;
|
|
26
|
+
}
|
|
27
|
+
export interface ModelStrategy<T = unknown> {
|
|
28
|
+
type: 'model';
|
|
29
|
+
modelId: string;
|
|
30
|
+
inputs: string[];
|
|
31
|
+
outputMapping: Record<string, T>;
|
|
32
|
+
default: T;
|
|
33
|
+
}
|
|
34
|
+
export interface ExternalStrategy<T = unknown> {
|
|
35
|
+
type: 'external';
|
|
36
|
+
endpoint: string;
|
|
37
|
+
method?: 'GET' | 'POST';
|
|
38
|
+
default: T;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Single FAQ question configuration.
|
|
43
|
+
* This is a "compositional action" - it's not executed, but rendered by the parent.
|
|
44
|
+
*/
|
|
45
|
+
export interface FAQQuestionAction {
|
|
46
|
+
/** Action kind identifier */
|
|
47
|
+
kind: 'faq:question';
|
|
48
|
+
/** Question configuration */
|
|
49
|
+
config: {
|
|
50
|
+
/** Unique identifier for this question */
|
|
51
|
+
id: string;
|
|
52
|
+
/** The question text */
|
|
53
|
+
question: string;
|
|
54
|
+
/** The answer text (supports basic markdown) */
|
|
55
|
+
answer: string;
|
|
56
|
+
/** Optional category for grouping */
|
|
57
|
+
category?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Optional per-item activation strategy */
|
|
60
|
+
showWhen?: DecisionStrategy<boolean> | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Expand behavior for the accordion.
|
|
64
|
+
*/
|
|
65
|
+
export type ExpandBehavior = 'single' | 'multiple';
|
|
66
|
+
/**
|
|
67
|
+
* Theme for the FAQ widget.
|
|
68
|
+
*/
|
|
69
|
+
export type FAQTheme = 'light' | 'dark' | 'auto';
|
|
70
|
+
/**
|
|
71
|
+
* Full configuration for the adaptive-faq widget.
|
|
72
|
+
*/
|
|
73
|
+
export interface FAQConfig {
|
|
74
|
+
/** Whether only one or multiple questions can be expanded at once */
|
|
75
|
+
expandBehavior: ExpandBehavior;
|
|
76
|
+
/** Whether to show a search/filter input */
|
|
77
|
+
searchable: boolean;
|
|
78
|
+
/** Color theme */
|
|
79
|
+
theme: FAQTheme;
|
|
80
|
+
/** FAQ questions (compositional actions) */
|
|
81
|
+
actions: FAQQuestionAction[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Runtime services passed to the widget.
|
|
85
|
+
*/
|
|
86
|
+
export interface FAQWidgetRuntime {
|
|
87
|
+
/** Synchronously evaluate a decision strategy */
|
|
88
|
+
evaluateSync: <T>(strategy: DecisionStrategy<T>) => {
|
|
89
|
+
value: T;
|
|
90
|
+
isFallback: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Context manager for subscribing to changes */
|
|
93
|
+
context: {
|
|
94
|
+
subscribe: (callback: () => void) => () => void;
|
|
95
|
+
};
|
|
96
|
+
/** Event bus for publishing interactions */
|
|
97
|
+
events: {
|
|
98
|
+
publish: (name: string, props?: Record<string, unknown>) => void;
|
|
99
|
+
};
|
|
100
|
+
/** Scoped state store */
|
|
101
|
+
state?: {
|
|
102
|
+
get: (key: string) => unknown;
|
|
103
|
+
set: (key: string, value: unknown) => void;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Props passed to the FAQWidget component.
|
|
108
|
+
*/
|
|
109
|
+
export interface FAQWidgetProps {
|
|
110
|
+
/** Widget configuration */
|
|
111
|
+
config: FAQConfig;
|
|
112
|
+
/** Runtime services */
|
|
113
|
+
runtime: FAQWidgetRuntime;
|
|
114
|
+
/** Instance ID for telemetry */
|
|
115
|
+
instanceId: string;
|
|
116
|
+
}
|
|
117
|
+
export interface EditorPanelProps {
|
|
118
|
+
config: Record<string, unknown>;
|
|
119
|
+
onChange: (config: Record<string, unknown>) => void;
|
|
120
|
+
editor: {
|
|
121
|
+
setDirty: (dirty: boolean) => void;
|
|
122
|
+
navigateHome: () => Promise<boolean>;
|
|
123
|
+
save: () => Promise<void>;
|
|
124
|
+
publish: (captureScreenshot?: boolean) => Promise<void>;
|
|
125
|
+
};
|
|
126
|
+
platformClient?: unknown;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IACpC,YAAY,CAAC,CAAC,CAAC,GACf,aAAa,CAAC,CAAC,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,GAChB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAExB,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;QACX,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3C,KAAK,EAAE,CAAC,CAAC;KACV,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAA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C;IACF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@syntrologie/adapt-faq",
|
|
3
|
+
"version": "0.0.0-semantically-released",
|
|
4
|
+
"description": "Adaptive FAQ - Collapsible Q&A accordion with per-item conditional visibility",
|
|
5
|
+
"license": "Proprietary",
|
|
6
|
+
"private": false,
|
|
7
|
+
"author": "Syntrologie <eng@syntrologie.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/SyntropyForge/amazing-demos.git",
|
|
11
|
+
"directory": "tech-core/sdks/adaptives/adaptive-faq"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./runtime": {
|
|
19
|
+
"types": "./dist/runtime.d.ts",
|
|
20
|
+
"import": "./dist/runtime.js"
|
|
21
|
+
},
|
|
22
|
+
"./schema": {
|
|
23
|
+
"types": "./dist/schema.d.ts",
|
|
24
|
+
"import": "./dist/schema.js"
|
|
25
|
+
},
|
|
26
|
+
"./editor": {
|
|
27
|
+
"types": "./dist/editor.d.ts",
|
|
28
|
+
"import": "./dist/editor.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"clean": "rm -rf dist"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@syntrologie/runtime-sdk": "^2.0.0",
|
|
40
|
+
"react": ">=18.0.0",
|
|
41
|
+
"react-dom": ">=18.0.0",
|
|
42
|
+
"zod": "^3.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/react": "^18.0.0",
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"zod": "^3.25.0"
|
|
48
|
+
}
|
|
49
|
+
}
|