@almadar/patterns 1.0.15 → 1.1.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/LICENSE +72 -0
- package/dist/index.d.ts +91 -1
- package/dist/index.js +156 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Almadar FZE
|
|
6
|
+
Licensed Work: KFlow Builder / Almadar
|
|
7
|
+
The Licensed Work is (c) 2025-2026 Almadar FZE.
|
|
8
|
+
Additional Use Grant: You may make production use of the Licensed Work for
|
|
9
|
+
non-commercial purposes and for internal evaluation.
|
|
10
|
+
Production use for commercial purposes requires a
|
|
11
|
+
commercial license from the Licensor.
|
|
12
|
+
Change Date: 2030-02-01
|
|
13
|
+
Change License: Apache License, Version 2.0
|
|
14
|
+
|
|
15
|
+
Terms
|
|
16
|
+
|
|
17
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
18
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
19
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
20
|
+
production use.
|
|
21
|
+
|
|
22
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
23
|
+
available distribution of a specific version of the Licensed Work under this
|
|
24
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
25
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
26
|
+
above terminate.
|
|
27
|
+
|
|
28
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
29
|
+
currently in effect as described in this License, you must purchase a
|
|
30
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
31
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
32
|
+
|
|
33
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
34
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
35
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
36
|
+
for each version of the Licensed Work released by Licensor.
|
|
37
|
+
|
|
38
|
+
You must conspicuously display this License on each original or modified copy
|
|
39
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
40
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
41
|
+
License apply to your use of that work.
|
|
42
|
+
|
|
43
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
44
|
+
terminate your rights under this License for the current and all other
|
|
45
|
+
versions of the Licensed Work.
|
|
46
|
+
|
|
47
|
+
This License does not grant you any right in any trademark or logo of
|
|
48
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
49
|
+
Licensor as expressly required by this License).
|
|
50
|
+
|
|
51
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
52
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
55
|
+
TITLE.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
60
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
61
|
+
|
|
62
|
+
ADDITIONAL TERMS:
|
|
63
|
+
|
|
64
|
+
Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
|
|
65
|
+
|
|
66
|
+
TRADEMARKS:
|
|
67
|
+
|
|
68
|
+
"Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
|
|
69
|
+
Almadar FZE. You may not use these trademarks without prior written
|
|
70
|
+
permission from Almadar FZE.
|
|
71
|
+
|
|
72
|
+
For licensing inquiries: licensing@almadar.io
|
package/dist/index.d.ts
CHANGED
|
@@ -14213,6 +14213,96 @@ declare function getAllPatternTypes(): PatternType[];
|
|
|
14213
14213
|
*/
|
|
14214
14214
|
declare function getPatternMetadata(patternType: string): any;
|
|
14215
14215
|
|
|
14216
|
+
/**
|
|
14217
|
+
* Pattern Recommender
|
|
14218
|
+
*
|
|
14219
|
+
* Maps transition context (entity fields, domain category, UI state) to
|
|
14220
|
+
* ranked pattern suggestions using the registry's `suggestedFor` metadata,
|
|
14221
|
+
* category matching, and entity field type heuristics.
|
|
14222
|
+
*
|
|
14223
|
+
* Used by the design-transition tool to include top-N recommendations
|
|
14224
|
+
* in the LLM prompt context.
|
|
14225
|
+
*
|
|
14226
|
+
* @packageDocumentation
|
|
14227
|
+
*/
|
|
14228
|
+
|
|
14229
|
+
/**
|
|
14230
|
+
* Context for pattern recommendation.
|
|
14231
|
+
*/
|
|
14232
|
+
interface RecommendationContext {
|
|
14233
|
+
/** Current state name (e.g., "Browsing", "Creating") */
|
|
14234
|
+
state?: string;
|
|
14235
|
+
/** Triggering event (e.g., "INIT", "CREATE", "VIEW") */
|
|
14236
|
+
event?: string;
|
|
14237
|
+
/** Target UI slot */
|
|
14238
|
+
slot?: 'main' | 'modal' | 'drawer' | 'sidebar' | 'overlay';
|
|
14239
|
+
/** Domain category */
|
|
14240
|
+
domainCategory?: string;
|
|
14241
|
+
/** Entity field types present */
|
|
14242
|
+
entityFieldTypes?: string[];
|
|
14243
|
+
/** Entity has enum fields */
|
|
14244
|
+
hasEnumFields?: boolean;
|
|
14245
|
+
/** Entity has date/timestamp fields */
|
|
14246
|
+
hasDateFields?: boolean;
|
|
14247
|
+
/** Entity has numeric fields */
|
|
14248
|
+
hasNumericFields?: boolean;
|
|
14249
|
+
/** Entity has relation fields */
|
|
14250
|
+
hasRelationFields?: boolean;
|
|
14251
|
+
/** Entity has image/url fields */
|
|
14252
|
+
hasMediaFields?: boolean;
|
|
14253
|
+
}
|
|
14254
|
+
/**
|
|
14255
|
+
* A pattern recommendation with score and reasoning.
|
|
14256
|
+
*/
|
|
14257
|
+
interface PatternRecommendation {
|
|
14258
|
+
/** Pattern type name */
|
|
14259
|
+
pattern: PatternType;
|
|
14260
|
+
/** Relevance score (0-100) */
|
|
14261
|
+
score: number;
|
|
14262
|
+
/** Why this pattern was recommended */
|
|
14263
|
+
reason: string;
|
|
14264
|
+
/** Pattern category */
|
|
14265
|
+
category: string;
|
|
14266
|
+
/** Pattern description */
|
|
14267
|
+
description: string;
|
|
14268
|
+
/** Key props to use */
|
|
14269
|
+
keyProps: string[];
|
|
14270
|
+
}
|
|
14271
|
+
/**
|
|
14272
|
+
* Recommend patterns for a given context.
|
|
14273
|
+
*
|
|
14274
|
+
* Scoring algorithm:
|
|
14275
|
+
* 1. suggestedFor match with domain keywords (+30)
|
|
14276
|
+
* 2. suggestedFor match with event keywords (+25)
|
|
14277
|
+
* 3. Category affinity with slot (+20)
|
|
14278
|
+
* 4. Category affinity with state (+15)
|
|
14279
|
+
* 5. Entity field type bonus (+10 per matching heuristic)
|
|
14280
|
+
* 6. Entity-aware bonus for display patterns (+5)
|
|
14281
|
+
*
|
|
14282
|
+
* @returns Ranked pattern recommendations, highest score first
|
|
14283
|
+
*/
|
|
14284
|
+
declare function recommendPatterns(context: RecommendationContext, maxResults?: number): PatternRecommendation[];
|
|
14285
|
+
/**
|
|
14286
|
+
* Build recommendation context from entity field information.
|
|
14287
|
+
* Analyzes field types to set the boolean flags used by the recommender.
|
|
14288
|
+
*/
|
|
14289
|
+
declare function buildRecommendationContext(options: {
|
|
14290
|
+
state?: string;
|
|
14291
|
+
event?: string;
|
|
14292
|
+
slot?: 'main' | 'modal' | 'drawer' | 'sidebar' | 'overlay';
|
|
14293
|
+
domainCategory?: string;
|
|
14294
|
+
entityFields?: Array<{
|
|
14295
|
+
name: string;
|
|
14296
|
+
type: string;
|
|
14297
|
+
values?: string[];
|
|
14298
|
+
}>;
|
|
14299
|
+
}): RecommendationContext;
|
|
14300
|
+
/**
|
|
14301
|
+
* Format recommendations as a concise prompt section.
|
|
14302
|
+
* Used to inject into the design-transition tool's user prompt.
|
|
14303
|
+
*/
|
|
14304
|
+
declare function formatRecommendationsForPrompt(recommendations: PatternRecommendation[]): string;
|
|
14305
|
+
|
|
14216
14306
|
declare const registry: {
|
|
14217
14307
|
version: string;
|
|
14218
14308
|
exportedAt: string;
|
|
@@ -28148,4 +28238,4 @@ declare function getComponentForPattern(patternType: string): any;
|
|
|
28148
28238
|
*/
|
|
28149
28239
|
declare function isEntityAwarePattern(patternType: string): boolean;
|
|
28150
28240
|
|
|
28151
|
-
export { type AnyPatternConfig, COMPONENT_MAPPING, EVENT_CONTRACTS, INTEGRATORS_REGISTRY, PATTERN_REGISTRY, PATTERN_TYPES, type PatternConfig, type PatternProps, type PatternPropsMap, type PatternType, componentMapping, eventContracts, generatePatternDescription, getAllPatternTypes, getComponentForPattern, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, integratorsRegistry, isEntityAwarePattern, isValidPatternType, patternsRegistry, registry };
|
|
28241
|
+
export { type AnyPatternConfig, COMPONENT_MAPPING, EVENT_CONTRACTS, INTEGRATORS_REGISTRY, PATTERN_REGISTRY, PATTERN_TYPES, type PatternConfig, type PatternProps, type PatternPropsMap, type PatternRecommendation, type PatternType, type RecommendationContext, buildRecommendationContext, componentMapping, eventContracts, formatRecommendationsForPrompt, generatePatternDescription, getAllPatternTypes, getComponentForPattern, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, integratorsRegistry, isEntityAwarePattern, isValidPatternType, patternsRegistry, recommendPatterns, registry };
|
package/dist/index.js
CHANGED
|
@@ -11484,6 +11484,161 @@ function getPatternMetadata(patternType) {
|
|
|
11484
11484
|
return patterns[patternType] || null;
|
|
11485
11485
|
}
|
|
11486
11486
|
|
|
11487
|
+
// src/helpers/pattern-recommender.ts
|
|
11488
|
+
var DOMAIN_KEYWORDS = {
|
|
11489
|
+
business: ["admin panels", "data-dense views", "list pages", "data entry", "comparisons"],
|
|
11490
|
+
dashboard: ["dashboards", "analytics", "overview pages", "overview screens", "data visualization", "reporting", "KPI indicators"],
|
|
11491
|
+
"e-commerce": ["visual items", "images", "previews", "data entry", "list pages"],
|
|
11492
|
+
content: ["visual items", "images", "previews", "media", "pages with multiple views"],
|
|
11493
|
+
social: ["activity logs", "visual items", "previews"],
|
|
11494
|
+
workflow: ["process tracking", "workflow steps", "multi-step forms", "wizards"],
|
|
11495
|
+
form: ["data entry", "create forms", "edit forms", "multi-step forms"],
|
|
11496
|
+
game: ["game", "real-time", "interactive"]
|
|
11497
|
+
};
|
|
11498
|
+
var EVENT_KEYWORDS = {
|
|
11499
|
+
INIT: ["list pages", "overview pages", "dashboards", "admin panels"],
|
|
11500
|
+
CREATE: ["create forms", "data entry", "multi-step forms"],
|
|
11501
|
+
EDIT: ["edit forms", "data entry"],
|
|
11502
|
+
VIEW: ["detail pages", "entity management", "pages with multiple views"],
|
|
11503
|
+
DELETE: ["destructive actions", "confirmations"],
|
|
11504
|
+
FILTER: ["filterable data", "search functionality", "quick filters"]
|
|
11505
|
+
};
|
|
11506
|
+
var SLOT_CATEGORY_AFFINITY = {
|
|
11507
|
+
main: ["display", "dashboard", "filter", "header", "layout", "visualization", "navigation", "template"],
|
|
11508
|
+
modal: ["form", "container", "state"],
|
|
11509
|
+
drawer: ["display", "form", "navigation"],
|
|
11510
|
+
sidebar: ["navigation", "filter"],
|
|
11511
|
+
overlay: ["container", "state"]
|
|
11512
|
+
};
|
|
11513
|
+
var STATE_CATEGORY_AFFINITY = {
|
|
11514
|
+
Browsing: ["display", "filter", "header", "dashboard", "visualization"],
|
|
11515
|
+
Creating: ["form", "navigation"],
|
|
11516
|
+
Editing: ["form", "navigation"],
|
|
11517
|
+
Viewing: ["display", "navigation"],
|
|
11518
|
+
Deleting: ["container", "state"]
|
|
11519
|
+
};
|
|
11520
|
+
function recommendPatterns(context, maxResults = 10) {
|
|
11521
|
+
const patterns = patterns_registry_default.patterns || {};
|
|
11522
|
+
const scores = /* @__PURE__ */ new Map();
|
|
11523
|
+
const domainKeywords = context.domainCategory ? DOMAIN_KEYWORDS[context.domainCategory] || [] : [];
|
|
11524
|
+
const eventKeywords = context.event ? EVENT_KEYWORDS[context.event] || [] : [];
|
|
11525
|
+
const slotCategories = context.slot ? SLOT_CATEGORY_AFFINITY[context.slot] || [] : [];
|
|
11526
|
+
const stateCategories = context.state ? STATE_CATEGORY_AFFINITY[context.state] || [] : [];
|
|
11527
|
+
for (const [patternName, patternDef] of Object.entries(patterns)) {
|
|
11528
|
+
const suggestedFor = patternDef.suggestedFor || [];
|
|
11529
|
+
const category = patternDef.category || "";
|
|
11530
|
+
let score = 0;
|
|
11531
|
+
const reasons = [];
|
|
11532
|
+
if (category === "game" && context.domainCategory !== "game") continue;
|
|
11533
|
+
if (category === "debug") continue;
|
|
11534
|
+
if (category === "template") continue;
|
|
11535
|
+
for (const keyword of domainKeywords) {
|
|
11536
|
+
if (suggestedFor.some((sf) => sf.toLowerCase().includes(keyword.toLowerCase()))) {
|
|
11537
|
+
score += 30;
|
|
11538
|
+
reasons.push(`domain:${keyword}`);
|
|
11539
|
+
break;
|
|
11540
|
+
}
|
|
11541
|
+
}
|
|
11542
|
+
for (const keyword of eventKeywords) {
|
|
11543
|
+
if (suggestedFor.some((sf) => sf.toLowerCase().includes(keyword.toLowerCase()))) {
|
|
11544
|
+
score += 25;
|
|
11545
|
+
reasons.push(`event:${keyword}`);
|
|
11546
|
+
break;
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
if (slotCategories.includes(category)) {
|
|
11550
|
+
score += 20;
|
|
11551
|
+
reasons.push(`slot:${context.slot}`);
|
|
11552
|
+
}
|
|
11553
|
+
if (stateCategories.includes(category)) {
|
|
11554
|
+
score += 15;
|
|
11555
|
+
reasons.push(`state:${context.state}`);
|
|
11556
|
+
}
|
|
11557
|
+
if (context.hasEnumFields && ["filter-group", "tabs", "badge"].includes(patternName)) {
|
|
11558
|
+
score += 10;
|
|
11559
|
+
reasons.push("enum-fields");
|
|
11560
|
+
}
|
|
11561
|
+
if (context.hasDateFields && ["timeline", "chart"].includes(patternName)) {
|
|
11562
|
+
score += 10;
|
|
11563
|
+
reasons.push("date-fields");
|
|
11564
|
+
}
|
|
11565
|
+
if (context.hasNumericFields && ["stats", "chart", "meter", "progress-bar"].includes(patternName)) {
|
|
11566
|
+
score += 10;
|
|
11567
|
+
reasons.push("numeric-fields");
|
|
11568
|
+
}
|
|
11569
|
+
if (context.hasRelationFields && ["tabs", "master-detail"].includes(patternName)) {
|
|
11570
|
+
score += 10;
|
|
11571
|
+
reasons.push("relation-fields");
|
|
11572
|
+
}
|
|
11573
|
+
if (context.hasMediaFields && ["entity-cards", "media-gallery"].includes(patternName)) {
|
|
11574
|
+
score += 10;
|
|
11575
|
+
reasons.push("media-fields");
|
|
11576
|
+
}
|
|
11577
|
+
if (category === "display" || category === "dashboard") {
|
|
11578
|
+
const propsSchema = patternDef.propsSchema || {};
|
|
11579
|
+
if ("entity" in propsSchema) {
|
|
11580
|
+
score += 5;
|
|
11581
|
+
reasons.push("entity-aware");
|
|
11582
|
+
}
|
|
11583
|
+
}
|
|
11584
|
+
if (score > 0) {
|
|
11585
|
+
scores.set(patternName, { score, reasons });
|
|
11586
|
+
}
|
|
11587
|
+
}
|
|
11588
|
+
const ranked = [...scores.entries()].sort((a, b) => b[1].score - a[1].score).slice(0, maxResults);
|
|
11589
|
+
return ranked.map(([patternName, { score, reasons }]) => {
|
|
11590
|
+
const patternDef = patterns[patternName];
|
|
11591
|
+
const propsSchema = patternDef.propsSchema || {};
|
|
11592
|
+
const keyProps = Object.keys(propsSchema).filter((k) => propsSchema[k]?.required === true).slice(0, 5);
|
|
11593
|
+
if (keyProps.length === 0) {
|
|
11594
|
+
const meaningful = Object.keys(propsSchema).filter(
|
|
11595
|
+
(k) => !["className", "isLoading", "error", "entity"].includes(k)
|
|
11596
|
+
);
|
|
11597
|
+
keyProps.push(...meaningful.slice(0, 4));
|
|
11598
|
+
}
|
|
11599
|
+
return {
|
|
11600
|
+
pattern: patternName,
|
|
11601
|
+
score,
|
|
11602
|
+
reason: reasons.join(", "),
|
|
11603
|
+
category: patternDef.category || "unknown",
|
|
11604
|
+
description: patternDef.description || patternName,
|
|
11605
|
+
keyProps
|
|
11606
|
+
};
|
|
11607
|
+
});
|
|
11608
|
+
}
|
|
11609
|
+
function buildRecommendationContext(options) {
|
|
11610
|
+
const fields = options.entityFields || [];
|
|
11611
|
+
const fieldTypes = fields.map((f) => f.type);
|
|
11612
|
+
return {
|
|
11613
|
+
state: options.state,
|
|
11614
|
+
event: options.event,
|
|
11615
|
+
slot: options.slot,
|
|
11616
|
+
domainCategory: options.domainCategory,
|
|
11617
|
+
entityFieldTypes: fieldTypes,
|
|
11618
|
+
hasEnumFields: fields.some((f) => f.type === "enum" || f.values && f.values.length > 0),
|
|
11619
|
+
hasDateFields: fields.some((f) => ["date", "datetime", "timestamp"].includes(f.type)),
|
|
11620
|
+
hasNumericFields: fields.some((f) => ["number", "integer", "float", "decimal", "currency"].includes(f.type)),
|
|
11621
|
+
hasRelationFields: fields.some((f) => f.type === "relation"),
|
|
11622
|
+
hasMediaFields: fields.some((f) => ["image", "url", "media", "file"].includes(f.type))
|
|
11623
|
+
};
|
|
11624
|
+
}
|
|
11625
|
+
function formatRecommendationsForPrompt(recommendations) {
|
|
11626
|
+
if (recommendations.length === 0) return "";
|
|
11627
|
+
const lines = [
|
|
11628
|
+
"## Recommended Patterns",
|
|
11629
|
+
"",
|
|
11630
|
+
"| Pattern | Category | Key Props | Why |",
|
|
11631
|
+
"|---------|----------|-----------|-----|"
|
|
11632
|
+
];
|
|
11633
|
+
for (const rec of recommendations) {
|
|
11634
|
+
const props = rec.keyProps.length > 0 ? rec.keyProps.join(", ") : "\u2014";
|
|
11635
|
+
lines.push(`| ${rec.pattern} | ${rec.category} | ${props} | ${rec.reason} |`);
|
|
11636
|
+
}
|
|
11637
|
+
lines.push("");
|
|
11638
|
+
lines.push("Use these patterns where appropriate. Combine multiple for rich INIT transitions.");
|
|
11639
|
+
return lines.join("\n");
|
|
11640
|
+
}
|
|
11641
|
+
|
|
11487
11642
|
// src/index.ts
|
|
11488
11643
|
var registry = patterns_registry_default;
|
|
11489
11644
|
var PATTERN_REGISTRY = patterns_registry_default;
|
|
@@ -11507,6 +11662,6 @@ function isEntityAwarePattern(patternType) {
|
|
|
11507
11662
|
return hasEntityProp && hasDataProp;
|
|
11508
11663
|
}
|
|
11509
11664
|
|
|
11510
|
-
export { COMPONENT_MAPPING, EVENT_CONTRACTS, INTEGRATORS_REGISTRY, PATTERN_REGISTRY, PATTERN_TYPES, component_mapping_default as componentMapping, event_contracts_default as eventContracts, generatePatternDescription, getAllPatternTypes, getComponentForPattern, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, integrators_registry_default as integratorsRegistry, isEntityAwarePattern, isValidPatternType, patterns_registry_default as patternsRegistry, registry };
|
|
11665
|
+
export { COMPONENT_MAPPING, EVENT_CONTRACTS, INTEGRATORS_REGISTRY, PATTERN_REGISTRY, PATTERN_TYPES, buildRecommendationContext, component_mapping_default as componentMapping, event_contracts_default as eventContracts, formatRecommendationsForPrompt, generatePatternDescription, getAllPatternTypes, getComponentForPattern, getPatternActionsRef, getPatternDefinition, getPatternMetadata, getPatternPropsCompact, getPatternsGroupedByCategory, integrators_registry_default as integratorsRegistry, isEntityAwarePattern, isValidPatternType, patterns_registry_default as patternsRegistry, recommendPatterns, registry };
|
|
11511
11666
|
//# sourceMappingURL=index.js.map
|
|
11512
11667
|
//# sourceMappingURL=index.js.map
|