kaabalah 6.2.2 → 6.2.3

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/README.md CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  getTarotArchetype,
84
84
  getTarotCardByNumber,
85
85
  getTarotCardNumber,
86
+ getTarotCorrespondenceProfile,
86
87
  getTarotCardProfile,
87
88
  getTarotRepresentation,
88
89
  listTarotTrees,
@@ -132,6 +133,29 @@ Downstream apps should consume the returned `imageUrl` (or `assetPath`) from the
132
133
 
133
134
  Tarot numbering is tree-scoped. In the current library release the canonical default tree is `kaabalah`, and `getTarotCardProfile()` resolves its `tarotCardNumber` from the direct `tarotArkAnnu ↔ number` correspondence in that tree. Use `getTarotCardNumber()` / `getTarotCardByNumber()` for forward and reverse numbering lookups, and treat raw `ARKANNUS` entries as compatibility data rather than the source of truth.
134
135
 
136
+ For display-facing correspondences, use `getTarotCorrespondenceProfile()` instead of rebuilding card bundles in the app:
137
+
138
+ ```typescript
139
+ const pageOfWands = getTarotCorrespondenceProfile({
140
+ tarotCardName: "Page of Wands"
141
+ });
142
+ // {
143
+ // kind: "court",
144
+ // courtRank: "page",
145
+ // correspondences: {
146
+ // element: { id: "westernElement:Fire", label: "Fire" }
147
+ // }
148
+ // }
149
+
150
+ const magician = getTarotCorrespondenceProfile({
151
+ tarotCardName: "The Magician"
152
+ });
153
+ // includes typed astrology correspondences plus path metadata
154
+ // { pathId, pathNumber, pathSlug, hebrewLetter, fromSphere, toSphere, meaning }
155
+ ```
156
+
157
+ Downstream apps no longer need to parse card-name prefixes like `Page of ...` to determine court rank, or rebuild the same major/court/minor correspondence collapsing logic from raw tree traversals.
158
+
135
159
  Observable kaabalah-default renumbering:
136
160
 
137
161
  - `Ten of Swords` is `55` and `Ace of Swords` is `64`
@@ -985,6 +985,12 @@ function buildDefaultArkannus(cards) {
985
985
  });
986
986
  }
987
987
  var ARKANNUS = buildDefaultArkannus(RAW_ARKANNUS);
988
+ var TAROT_COURT_RANKS = [
989
+ "king",
990
+ "queen",
991
+ "knight",
992
+ "page"
993
+ ];
988
994
  var MAJOR_ARCANA_CARDS = ARKANNUS.filter(
989
995
  (card) => card.type === "major" && majorArcana.includes(card.tarotCardFilename)
990
996
  );
@@ -994,6 +1000,13 @@ function toTarotCardKind(card) {
994
1000
  }
995
1001
  return card.type === "minor" ? "minor" : "court";
996
1002
  }
1003
+ function toTarotCourtRank(card) {
1004
+ if (card.type !== "daat+royalship") {
1005
+ return void 0;
1006
+ }
1007
+ const [rank] = card.tarotCardFilename.split("_");
1008
+ return TAROT_COURT_RANKS.includes(rank) ? rank : void 0;
1009
+ }
997
1010
  function toTarotAssetPathType(card) {
998
1011
  return card.type;
999
1012
  }
@@ -1015,6 +1028,180 @@ function toAstrologyCorrespondence(node) {
1015
1028
  label: parseId(node.id)
1016
1029
  };
1017
1030
  }
1031
+ function getTarotCorrespondenceTree(treeId = DEFAULT_TAROT_TREE_ID) {
1032
+ return getCanonicalTree({
1033
+ system: treeId,
1034
+ parts: ["westernAstrology", "tarot"]
1035
+ });
1036
+ }
1037
+ function getCorrespondenceNodes(tree, sourceId, type, depth = 1, limit) {
1038
+ return tree.getCorrespondences(sourceId, {
1039
+ type,
1040
+ depth,
1041
+ limit
1042
+ }).map(({ node }) => node);
1043
+ }
1044
+ function getFirstCorrespondenceNode(tree, sourceId, type, depth = 1) {
1045
+ return getCorrespondenceNodes(tree, sourceId, type, depth, 1)[0];
1046
+ }
1047
+ function toCorrespondenceNode(node) {
1048
+ if (!node) {
1049
+ return void 0;
1050
+ }
1051
+ return {
1052
+ id: node.id,
1053
+ label: parseId(node.id)
1054
+ };
1055
+ }
1056
+ function toUniqueCorrespondenceNodes(nodes) {
1057
+ const seen = /* @__PURE__ */ new Set();
1058
+ return nodes.flatMap((node) => {
1059
+ const key = String(node.id);
1060
+ if (seen.has(key)) {
1061
+ return [];
1062
+ }
1063
+ seen.add(key);
1064
+ return [toCorrespondenceNode(node)];
1065
+ });
1066
+ }
1067
+ function toTarotCorrespondenceProfileBase(card) {
1068
+ return {
1069
+ tarotArkAnnuId: card.tarotArkAnnuId,
1070
+ tarotCardNumber: card.tarotCardNumber,
1071
+ tarotCardName: card.tarotCardName,
1072
+ tarotCardFilename: card.tarotCardFilename,
1073
+ tarotMeaning: card.tarotMeaning,
1074
+ suit: card.suit
1075
+ };
1076
+ }
1077
+ function resolveTarotCardProfileForTree(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
1078
+ if ("tarotCardNumber" in lookup) {
1079
+ return getTarotCardByNumber(lookup.tarotCardNumber, treeId);
1080
+ }
1081
+ return getTarotCardProfile(lookup);
1082
+ }
1083
+ function buildMajorCorrespondenceProfile(card, tree) {
1084
+ const pathNode = getFirstCorrespondenceNode(
1085
+ tree,
1086
+ card.tarotArkAnnuId,
1087
+ "path" /* PATH */
1088
+ );
1089
+ const hebrewLetterNode = pathNode ? getFirstCorrespondenceNode(
1090
+ tree,
1091
+ pathNode.id,
1092
+ "hebrewLetter" /* HEBREW_LETTER */
1093
+ ) : void 0;
1094
+ const pathNumberNode = pathNode ? getFirstCorrespondenceNode(tree, pathNode.id, "number" /* NUMBER */) : void 0;
1095
+ const pathNumber = pathNumberNode ? Number.parseInt(parseId(pathNumberNode.id), 10) : Number.NaN;
1096
+ const fromSphereNode = pathNode?.data?.from ? tree.getNode(pathNode.data.from) : void 0;
1097
+ const toSphereNode = pathNode?.data?.to ? tree.getNode(pathNode.data.to) : void 0;
1098
+ if (!pathNode || !hebrewLetterNode || !fromSphereNode || !toSphereNode || !Number.isFinite(pathNumber)) {
1099
+ return void 0;
1100
+ }
1101
+ return {
1102
+ ...toTarotCorrespondenceProfileBase(card),
1103
+ kind: "major",
1104
+ correspondences: {
1105
+ astrology: getCorrespondenceNodes(
1106
+ tree,
1107
+ pathNode.id,
1108
+ [
1109
+ "westernElement" /* WESTERN_ELEMENT */,
1110
+ "planet" /* PLANET */,
1111
+ "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
1112
+ ]
1113
+ ).map(
1114
+ (node) => toAstrologyCorrespondence(
1115
+ node
1116
+ )
1117
+ ),
1118
+ path: {
1119
+ pathId: pathNode.id,
1120
+ pathNumber,
1121
+ pathSlug: parseId(hebrewLetterNode.id).toLowerCase(),
1122
+ meaning: pathNode.data?.meaning,
1123
+ hebrewLetter: toCorrespondenceNode(hebrewLetterNode),
1124
+ fromSphere: toCorrespondenceNode(
1125
+ fromSphereNode
1126
+ ),
1127
+ toSphere: toCorrespondenceNode(
1128
+ toSphereNode
1129
+ )
1130
+ }
1131
+ }
1132
+ };
1133
+ }
1134
+ function buildCourtCorrespondenceProfile(card, tree) {
1135
+ const suitNode = getFirstCorrespondenceNode(
1136
+ tree,
1137
+ card.tarotArkAnnuId,
1138
+ "tarotSuit" /* TAROT_SUIT */
1139
+ );
1140
+ if (!card.courtRank) {
1141
+ return void 0;
1142
+ }
1143
+ if (card.courtRank === "page") {
1144
+ const elementNode = suitNode ? getFirstCorrespondenceNode(
1145
+ tree,
1146
+ suitNode.id,
1147
+ "westernElement" /* WESTERN_ELEMENT */
1148
+ ) : void 0;
1149
+ if (!elementNode) {
1150
+ return void 0;
1151
+ }
1152
+ return {
1153
+ ...toTarotCorrespondenceProfileBase(card),
1154
+ kind: "court",
1155
+ courtRank: "page",
1156
+ correspondences: {
1157
+ element: toCorrespondenceNode(elementNode)
1158
+ }
1159
+ };
1160
+ }
1161
+ const signNode = getFirstCorrespondenceNode(
1162
+ tree,
1163
+ card.tarotArkAnnuId,
1164
+ "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
1165
+ );
1166
+ if (!signNode) {
1167
+ return void 0;
1168
+ }
1169
+ return {
1170
+ ...toTarotCorrespondenceProfileBase(card),
1171
+ kind: "court",
1172
+ courtRank: card.courtRank,
1173
+ correspondences: {
1174
+ sign: toCorrespondenceNode(signNode),
1175
+ planets: toUniqueCorrespondenceNodes(
1176
+ getCorrespondenceNodes(
1177
+ tree,
1178
+ signNode.id,
1179
+ "planet" /* PLANET */
1180
+ )
1181
+ )
1182
+ }
1183
+ };
1184
+ }
1185
+ function buildMinorCorrespondenceProfile(card, tree) {
1186
+ const sphereNode = getFirstCorrespondenceNode(
1187
+ tree,
1188
+ card.tarotArkAnnuId,
1189
+ "sphere" /* SPHERE */
1190
+ );
1191
+ if (!sphereNode) {
1192
+ return void 0;
1193
+ }
1194
+ return {
1195
+ ...toTarotCorrespondenceProfileBase(card),
1196
+ kind: "minor",
1197
+ correspondences: {
1198
+ sphere: toCorrespondenceNode(sphereNode),
1199
+ planets: toUniqueCorrespondenceNodes(
1200
+ getCorrespondenceNodes(tree, sphereNode.id, "planet" /* PLANET */)
1201
+ )
1202
+ }
1203
+ };
1204
+ }
1018
1205
  function buildDescriptionsByDeck(tarotArkAnnu) {
1019
1206
  const descriptions = {};
1020
1207
  for (const deck of TAROT_DECK_METADATA) {
@@ -1124,6 +1311,7 @@ function getTarotCardProfileCache() {
1124
1311
  kind: toTarotCardKind(card),
1125
1312
  assetPathType: toTarotAssetPathType(card),
1126
1313
  suit: card.suit,
1314
+ courtRank: toTarotCourtRank(card),
1127
1315
  availableDeckIds,
1128
1316
  descriptionsByDeck
1129
1317
  };
@@ -1262,6 +1450,21 @@ function getTarotArchetype(lookup) {
1262
1450
  }
1263
1451
  return cache.byTarotCardNumber.get(lookup.tarotCardNumber);
1264
1452
  }
1453
+ function getTarotCorrespondenceProfile(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
1454
+ const card = resolveTarotCardProfileForTree(lookup, treeId);
1455
+ if (!card) {
1456
+ return void 0;
1457
+ }
1458
+ const tree = getTarotCorrespondenceTree(treeId);
1459
+ switch (card.kind) {
1460
+ case "major":
1461
+ return buildMajorCorrespondenceProfile(card, tree);
1462
+ case "court":
1463
+ return buildCourtCorrespondenceProfile(card, tree);
1464
+ case "minor":
1465
+ return buildMinorCorrespondenceProfile(card, tree);
1466
+ }
1467
+ }
1265
1468
  function getTarotRepresentations(lookup) {
1266
1469
  const card = getTarotCardProfile(lookup);
1267
1470
  if (!card) {
@@ -2358,6 +2561,6 @@ function drawTarotSpread(options) {
2358
2561
  };
2359
2562
  }
2360
2563
 
2361
- export { ARKANNUS, DEFAULT_TAROT_TREE_ID, TAROT_IMAGE_BASE_URL, TAROT_TREE_IDS, drawTarotSpread, getTarotArchetype, getTarotCardByNumber, getTarotCardNumber, getTarotCardProfile, getTarotRepresentation, getTarotRepresentations, getTarotSpread, listTarotDecks, listTarotSpreads, listTarotTrees, majorArcana, resolveTarotImageUrl, shuffleTarotDeck, validateTarotSpreadSelection };
2362
- //# sourceMappingURL=chunk-VWGXOGEJ.mjs.map
2363
- //# sourceMappingURL=chunk-VWGXOGEJ.mjs.map
2564
+ export { ARKANNUS, DEFAULT_TAROT_TREE_ID, TAROT_IMAGE_BASE_URL, TAROT_TREE_IDS, drawTarotSpread, getTarotArchetype, getTarotCardByNumber, getTarotCardNumber, getTarotCardProfile, getTarotCorrespondenceProfile, getTarotRepresentation, getTarotRepresentations, getTarotSpread, listTarotDecks, listTarotSpreads, listTarotTrees, majorArcana, resolveTarotImageUrl, shuffleTarotDeck, validateTarotSpreadSelection };
2565
+ //# sourceMappingURL=chunk-2RGUI5FG.mjs.map
2566
+ //# sourceMappingURL=chunk-2RGUI5FG.mjs.map