@pitcher/js-api 1.26.0-beta.12 → 1.26.0-beta.14

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.
Files changed (78) hide show
  1. package/impact-js-api.spec.json +6 -0
  2. package/js-api.esm.js +572 -3
  3. package/js-api.esm.js.map +1 -1
  4. package/js-api.umd.min.js +10 -10
  5. package/js-api.umd.min.js.map +1 -1
  6. package/lib/api/events/events.helpers.d.ts +14 -2
  7. package/lib/apps/agenda-selector/composables/move-item-modal.use.d.ts +4 -0
  8. package/lib/apps/browser/components/Content/ActionsToolbar/ActionsToolbar.vue.d.ts +12 -3
  9. package/lib/apps/browser/stores/api.d.ts +27 -0
  10. package/lib/apps/browser/stores/upload.d.ts +4 -0
  11. package/lib/apps/canvas-builder/components/ui/ContentList/ContentList.vue.d.ts +8 -8
  12. package/lib/apps/canvas-builder/components/ui/DataCharts/types.d.ts +1 -0
  13. package/lib/apps/canvas-builder/components/ui/SectionList/SectionList.vue.d.ts +8 -3
  14. package/lib/apps/canvas-builder/composables/useCanvas.d.ts +83 -0
  15. package/lib/apps/canvas-builder/composables/useCanvasBlocks.d.ts +12 -0
  16. package/lib/apps/canvas-builder/composables/useCanvasHistory.d.ts +12 -0
  17. package/lib/apps/canvas-builder/composables/useCanvasTheme.d.ts +2 -0
  18. package/lib/apps/canvas-builder/composables/useCrmShape.d.ts +1 -1
  19. package/lib/apps/canvas-builder/composables/useCrmShapeWithSectionContext.d.ts +1 -2
  20. package/lib/apps/canvas-builder/composables/usePopupApps.d.ts +2 -0
  21. package/lib/apps/canvas-builder/util/canvas.util.d.ts +1 -0
  22. package/lib/apps/collection-selector/composables/move-slide-modal.use.d.ts +4 -0
  23. package/lib/apps/content-selector/components/Content/AllContent/List/FoldersFilesList.vue.d.ts +12 -3
  24. package/lib/apps/ppt-conversion-selector/composables/move-slide-modal.use.d.ts +2 -0
  25. package/lib/apps/ppt-conversion-selector/stores/app.store.d.ts +2 -0
  26. package/lib/components/CFileAttributes/CFileAttributes.vue.d.ts +1 -0
  27. package/lib/components/CSearchFilters/CSearchFilters.vue.d.ts +4 -1
  28. package/lib/components/CSwitch/CSwitch.vue.d.ts +4 -2
  29. package/lib/components/assignedCanvases/CAssignedCanvasesManagement.vue.d.ts +20 -4
  30. package/lib/components/assignedCanvases/CAssignedCanvasesManagementToolbar.vue.d.ts +4 -1
  31. package/lib/components/canvas-blocks/CBlockManagement.vue.d.ts +16 -4
  32. package/lib/components/canvas-blocks/CBlockManagementToolbar.vue.d.ts +4 -1
  33. package/lib/components/canvas-templates/CTemplateManagement.vue.d.ts +40 -10
  34. package/lib/components/canvas-templates/CTemplateManagementToolbar.vue.d.ts +16 -4
  35. package/lib/components/savedCanvases/CSavedCanvasesManagement.vue.d.ts +16 -4
  36. package/lib/components/savedCanvases/CSavedCanvasesManagementToolbar.vue.d.ts +4 -1
  37. package/lib/components/sections/CSectionManagement.vue.d.ts +16 -4
  38. package/lib/components/sections/CSectionManagementToolbar.vue.d.ts +4 -1
  39. package/lib/components/themes/CThemeManagement.vue.d.ts +16 -4
  40. package/lib/components/themes/CThemeManagementToolbar.vue.d.ts +4 -1
  41. package/lib/composables/useCanvasStandardFilters.d.ts +17 -2
  42. package/lib/composables/useSmartStore.d.ts +25 -0
  43. package/lib/main.lib.d.ts +2 -0
  44. package/lib/sdk/api/HighLevelApi.d.ts +4 -0
  45. package/lib/sdk/api/modules/query.d.ts +80 -1
  46. package/lib/sdk/main.d.ts +12 -0
  47. package/lib/sdk/payload.types.d.ts +69 -0
  48. package/lib/types/instanceSettings.types.d.ts +1 -0
  49. package/lib/types/launchDarkly.types.d.ts +2 -1
  50. package/lib/types/organizationSettings.types.d.ts +5 -0
  51. package/lib/types/sfdc.d.ts +5 -0
  52. package/lib/util/smart-store.util.d.ts +40 -0
  53. package/lib/util/smart-store.util.spec.d.ts +1 -0
  54. package/package.json +1 -1
  55. package/types/openapi/models/FilePermission.d.ts +1 -0
  56. package/types/openapi/models/FilePermissionRequest.d.ts +1 -0
  57. package/types/openapi/models/PaginatedAppList.d.ts +2 -2
  58. package/types/openapi/models/PaginatedAuthTokenList.d.ts +2 -2
  59. package/types/openapi/models/PaginatedCanvasList.d.ts +2 -2
  60. package/types/openapi/models/PaginatedCollaborationList.d.ts +2 -2
  61. package/types/openapi/models/PaginatedContentDistributionGroupList.d.ts +2 -2
  62. package/types/openapi/models/PaginatedContentDistributionGroupMembershipList.d.ts +2 -2
  63. package/types/openapi/models/PaginatedEnvironmentList.d.ts +2 -2
  64. package/types/openapi/models/PaginatedEventList.d.ts +2 -2
  65. package/types/openapi/models/PaginatedFavoriteList.d.ts +2 -2
  66. package/types/openapi/models/PaginatedFileList.d.ts +2 -2
  67. package/types/openapi/models/PaginatedFileRevisionList.d.ts +2 -2
  68. package/types/openapi/models/PaginatedFolderList.d.ts +2 -2
  69. package/types/openapi/models/PaginatedInstanceAssignmentGroupList.d.ts +2 -2
  70. package/types/openapi/models/PaginatedInstanceAssignmentGroupMembershipList.d.ts +2 -2
  71. package/types/openapi/models/PaginatedInstanceList.d.ts +2 -2
  72. package/types/openapi/models/PaginatedInstanceMembershipList.d.ts +2 -2
  73. package/types/openapi/models/PaginatedInvitationList.d.ts +2 -2
  74. package/types/openapi/models/PaginatedMetadataTemplateList.d.ts +2 -2
  75. package/types/openapi/models/PaginatedOfflineSyncFolderList.d.ts +2 -2
  76. package/types/openapi/models/PaginatedRegionList.d.ts +2 -2
  77. package/types/openapi/models/PaginatedRevisionList.d.ts +2 -2
  78. package/types/openapi/models/PaginatedUserList.d.ts +2 -2
@@ -190,6 +190,12 @@
190
190
  "crm_smart_object_metadata": {
191
191
  "description": "Retrieve metadata for a CRM smart object. iOS only."
192
192
  },
193
+ "crm_smart_object_layout": {
194
+ "description": "Retrieve layout information for a CRM smart object. iOS only."
195
+ },
196
+ "crm_layout": {
197
+ "description": "Retrieve layout information for a CRM object. Web only."
198
+ },
193
199
  "crm_smart_delete_objects": {
194
200
  "description": "Delete CRM objects from local CRM data using SmartStore. iOS only."
195
201
  },
package/js-api.esm.js CHANGED
@@ -2531,18 +2531,538 @@ function toast$2(payload) {
2531
2531
  return this.API.request("toast", payload);
2532
2532
  }
2533
2533
 
2534
+ const SQL_KEYWORDS = /* @__PURE__ */ new Set([
2535
+ "SELECT",
2536
+ "FROM",
2537
+ "WHERE",
2538
+ "AND",
2539
+ "OR",
2540
+ "NOT",
2541
+ "IN",
2542
+ "LIKE",
2543
+ "ORDER",
2544
+ "BY",
2545
+ "GROUP",
2546
+ "HAVING",
2547
+ "LIMIT",
2548
+ "OFFSET",
2549
+ "ASC",
2550
+ "DESC",
2551
+ "NULLS",
2552
+ "FIRST",
2553
+ "LAST",
2554
+ "NULL",
2555
+ "TRUE",
2556
+ "FALSE",
2557
+ "COUNT",
2558
+ "SUM",
2559
+ "AVG",
2560
+ "MIN",
2561
+ "MAX",
2562
+ "COUNT_DISTINCT",
2563
+ "CALENDAR_MONTH",
2564
+ "CALENDAR_QUARTER",
2565
+ "CALENDAR_YEAR",
2566
+ "DAY_IN_MONTH",
2567
+ "DAY_IN_WEEK",
2568
+ "DAY_IN_YEAR",
2569
+ "DAY_ONLY",
2570
+ "FISCAL_MONTH",
2571
+ "FISCAL_QUARTER",
2572
+ "FISCAL_YEAR",
2573
+ "HOUR_IN_DAY",
2574
+ "WEEK_IN_MONTH",
2575
+ "WEEK_IN_YEAR",
2576
+ "INCLUDES",
2577
+ "EXCLUDES",
2578
+ "ABOVE",
2579
+ "BELOW",
2580
+ "ABOVE_OR_BELOW",
2581
+ "AT",
2582
+ "TYPEOF",
2583
+ "WHEN",
2584
+ "THEN",
2585
+ "ELSE",
2586
+ "END",
2587
+ "USING",
2588
+ "SCOPE",
2589
+ "DATA",
2590
+ "CATEGORY",
2591
+ "ROLLUP",
2592
+ "CUBE",
2593
+ "FORMAT",
2594
+ "CONVERTCURRENCY",
2595
+ "TOLABEL",
2596
+ "DISTANCE",
2597
+ "GEOLOCATION"
2598
+ ]);
2599
+ const AGGREGATE_FUNCTIONS = ["COUNT", "SUM", "AVG", "MIN", "MAX", "COUNT_DISTINCT"];
2600
+ function isSqlKeyword(word) {
2601
+ return SQL_KEYWORDS.has(word.toUpperCase());
2602
+ }
2603
+ function isLiteralValue(value) {
2604
+ const trimmed = value.trim();
2605
+ if (trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith('"') && trimmed.endsWith('"')) {
2606
+ return true;
2607
+ }
2608
+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
2609
+ return true;
2610
+ }
2611
+ if (/^(true|false)$/i.test(trimmed)) {
2612
+ return true;
2613
+ }
2614
+ if (/^null$/i.test(trimmed)) {
2615
+ return true;
2616
+ }
2617
+ if (/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|[+-]\d{2}:\d{2})?)?$/.test(trimmed)) {
2618
+ return true;
2619
+ }
2620
+ if (/^(TODAY|YESTERDAY|TOMORROW|LAST_WEEK|THIS_WEEK|NEXT_WEEK|LAST_MONTH|THIS_MONTH|NEXT_MONTH|LAST_90_DAYS|NEXT_90_DAYS|LAST_N_DAYS:\d+|NEXT_N_DAYS:\d+|LAST_N_WEEKS:\d+|NEXT_N_WEEKS:\d+|LAST_N_MONTHS:\d+|NEXT_N_MONTHS:\d+|LAST_N_QUARTERS:\d+|NEXT_N_QUARTERS:\d+|LAST_N_YEARS:\d+|NEXT_N_YEARS:\d+|THIS_QUARTER|LAST_QUARTER|NEXT_QUARTER|THIS_YEAR|LAST_YEAR|NEXT_YEAR|THIS_FISCAL_QUARTER|LAST_FISCAL_QUARTER|NEXT_FISCAL_QUARTER|THIS_FISCAL_YEAR|LAST_FISCAL_YEAR|NEXT_FISCAL_YEAR)$/i.test(
2621
+ trimmed
2622
+ )) {
2623
+ return true;
2624
+ }
2625
+ return false;
2626
+ }
2627
+ function isDateTimeLiteral(token) {
2628
+ return /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|[+-]\d{2}:\d{2})?)?$/.test(token);
2629
+ }
2630
+ function convertFieldToSmartStore(field, primaryObject, objectAliases) {
2631
+ const trimmed = field.trim();
2632
+ if (isSqlKeyword(trimmed) || isLiteralValue(trimmed)) {
2633
+ return trimmed;
2634
+ }
2635
+ if (trimmed === "__FIELDS_ALL_PLACEHOLDER__") {
2636
+ return `{${primaryObject}:_soup}`;
2637
+ }
2638
+ if (trimmed === "*") {
2639
+ return "*";
2640
+ }
2641
+ if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
2642
+ return trimmed;
2643
+ }
2644
+ if (trimmed.includes(".")) {
2645
+ const parts = trimmed.split(".");
2646
+ const alias = parts[0];
2647
+ if (objectAliases.has(alias.toLowerCase()) && objectAliases.get(alias.toLowerCase()) === primaryObject) {
2648
+ const fieldPath = parts.slice(1).join(".");
2649
+ return `{${primaryObject}:${fieldPath}}`;
2650
+ }
2651
+ return `{${primaryObject}:${trimmed}}`;
2652
+ }
2653
+ return `{${primaryObject}:${trimmed}}`;
2654
+ }
2655
+ function convertAggregateFunction(expr, primaryObject, objectAliases) {
2656
+ for (const func of AGGREGATE_FUNCTIONS) {
2657
+ const regex = new RegExp(`\\b${func}\\s*\\(([^)]+)\\)`, "gi");
2658
+ expr = expr.replace(regex, (_match, innerField) => {
2659
+ const trimmedInner = innerField.trim();
2660
+ if (trimmedInner === "*") {
2661
+ return `${func}(*)`;
2662
+ }
2663
+ if (trimmedInner.toUpperCase().startsWith("DISTINCT ")) {
2664
+ const fieldPart = trimmedInner.substring(9).trim();
2665
+ const smartField2 = convertFieldToSmartStore(fieldPart, primaryObject, objectAliases);
2666
+ return `${func}(DISTINCT ${smartField2})`;
2667
+ }
2668
+ const smartField = convertFieldToSmartStore(trimmedInner, primaryObject, objectAliases);
2669
+ return `${func}(${smartField})`;
2670
+ });
2671
+ }
2672
+ return expr;
2673
+ }
2674
+ function parseSelectFields(selectClause) {
2675
+ const fields = [];
2676
+ let depth = 0;
2677
+ let currentField = "";
2678
+ for (let i = 0; i < selectClause.length; i++) {
2679
+ const char = selectClause[i];
2680
+ if (char === "(") {
2681
+ depth++;
2682
+ currentField += char;
2683
+ } else if (char === ")") {
2684
+ depth--;
2685
+ currentField += char;
2686
+ } else if (char === "," && depth === 0) {
2687
+ if (currentField.trim()) {
2688
+ fields.push(currentField.trim());
2689
+ }
2690
+ currentField = "";
2691
+ } else {
2692
+ currentField += char;
2693
+ }
2694
+ }
2695
+ if (currentField.trim()) {
2696
+ fields.push(currentField.trim());
2697
+ }
2698
+ return fields;
2699
+ }
2700
+ function convertSelectFields(fields, primaryObject, objectAliases) {
2701
+ return fields.map((field) => {
2702
+ const aliasMatch = field.match(/^(.+?)\s+(?:AS\s+)?([A-Za-z_][A-Za-z0-9_]*)$/i);
2703
+ let expression = field;
2704
+ let alias = "";
2705
+ if (aliasMatch) {
2706
+ expression = aliasMatch[1].trim();
2707
+ alias = aliasMatch[2];
2708
+ }
2709
+ const hasAggregate = AGGREGATE_FUNCTIONS.some((func) => new RegExp(`\\b${func}\\s*\\(`, "i").test(expression));
2710
+ if (hasAggregate) {
2711
+ const converted2 = convertAggregateFunction(expression, primaryObject, objectAliases);
2712
+ return alias ? `${converted2} ${alias}` : converted2;
2713
+ }
2714
+ const converted = convertFieldToSmartStore(expression, primaryObject, objectAliases);
2715
+ return alias ? `${converted} ${alias}` : converted;
2716
+ });
2717
+ }
2718
+ function convertNullComparisons(clause) {
2719
+ let result = clause.replace(/\s*!=\s*null\b/gi, " IS NOT NULL");
2720
+ result = result.replace(/\s*<>\s*null\b/gi, " IS NOT NULL");
2721
+ result = result.replace(/\s*=\s*null\b/gi, " IS NULL");
2722
+ return result;
2723
+ }
2724
+ function convertWhereClause(whereClause, primaryObject, objectAliases) {
2725
+ let result = "";
2726
+ let i = 0;
2727
+ const len = whereClause.length;
2728
+ while (i < len) {
2729
+ const char = whereClause[i];
2730
+ if (/\s/.test(char)) {
2731
+ result += char;
2732
+ i++;
2733
+ continue;
2734
+ }
2735
+ if (char === "'" || char === '"') {
2736
+ const quote = char;
2737
+ result += char;
2738
+ i++;
2739
+ while (i < len && whereClause[i] !== quote) {
2740
+ if (whereClause[i] === "\\" && i + 1 < len) {
2741
+ result += whereClause[i] + whereClause[i + 1];
2742
+ i += 2;
2743
+ } else {
2744
+ result += whereClause[i];
2745
+ i++;
2746
+ }
2747
+ }
2748
+ if (i < len) {
2749
+ result += whereClause[i];
2750
+ i++;
2751
+ }
2752
+ continue;
2753
+ }
2754
+ if (/[()=<>!,]/.test(char)) {
2755
+ result += char;
2756
+ i++;
2757
+ if ((char === "!" || char === "<" || char === ">") && i < len && whereClause[i] === "=") {
2758
+ result += whereClause[i];
2759
+ i++;
2760
+ }
2761
+ continue;
2762
+ }
2763
+ if (/[a-zA-Z_]/.test(char)) {
2764
+ let identifier = "";
2765
+ while (i < len && /[a-zA-Z0-9_.]/.test(whereClause[i])) {
2766
+ identifier += whereClause[i];
2767
+ i++;
2768
+ }
2769
+ if (isSqlKeyword(identifier) || isLiteralValue(identifier)) {
2770
+ result += identifier;
2771
+ } else {
2772
+ result += convertFieldToSmartStore(identifier, primaryObject, objectAliases);
2773
+ }
2774
+ continue;
2775
+ }
2776
+ if (/[0-9-]/.test(char)) {
2777
+ let token = "";
2778
+ if (char === "-") {
2779
+ token += char;
2780
+ i++;
2781
+ }
2782
+ while (i < len && /[0-9.:\-TZ+]/.test(whereClause[i])) {
2783
+ token += whereClause[i];
2784
+ i++;
2785
+ }
2786
+ if (isDateTimeLiteral(token)) {
2787
+ result += `'${token}'`;
2788
+ } else {
2789
+ result += token;
2790
+ }
2791
+ continue;
2792
+ }
2793
+ result += char;
2794
+ i++;
2795
+ }
2796
+ result = convertNullComparisons(result);
2797
+ return result;
2798
+ }
2799
+ function parseOrderByClause(orderByClause) {
2800
+ const result = [];
2801
+ const parts = orderByClause.split(/,(?![^()]*\))/);
2802
+ for (const part of parts) {
2803
+ const trimmed = part.trim();
2804
+ if (!trimmed) continue;
2805
+ const match = trimmed.match(/^(.+?)\s*(ASC|DESC)?\s*(NULLS\s+(?:FIRST|LAST))?$/i);
2806
+ if (match) {
2807
+ const field = match[1].trim();
2808
+ let direction = match[2] ? match[2].toUpperCase() : "";
2809
+ if (match[3]) {
2810
+ direction += (direction ? " " : "") + match[3].toUpperCase();
2811
+ }
2812
+ result.push({ field, direction });
2813
+ } else {
2814
+ result.push({ field: trimmed, direction: "" });
2815
+ }
2816
+ }
2817
+ return result;
2818
+ }
2819
+ function convertOrderByFields(orderByParts, primaryObject, objectAliases) {
2820
+ return orderByParts.map(({ field, direction }) => {
2821
+ const hasAggregate = AGGREGATE_FUNCTIONS.some((func) => new RegExp(`\\b${func}\\s*\\(`, "i").test(field));
2822
+ let convertedField;
2823
+ if (hasAggregate) {
2824
+ convertedField = convertAggregateFunction(field, primaryObject, objectAliases);
2825
+ } else {
2826
+ convertedField = convertFieldToSmartStore(field, primaryObject, objectAliases);
2827
+ }
2828
+ return direction ? `${convertedField} ${direction}` : convertedField;
2829
+ });
2830
+ }
2831
+ function parseGroupByClause(groupByClause) {
2832
+ return groupByClause.split(/,(?![^()]*\))/).map((f) => f.trim()).filter(Boolean);
2833
+ }
2834
+ function convertGroupByFields(fields, primaryObject, objectAliases) {
2835
+ return fields.map((field) => {
2836
+ if (/^(ROLLUP|CUBE)\s*\(/i.test(field)) {
2837
+ return field.replace(/\(([^)]+)\)/g, (_match, inner) => {
2838
+ const innerFields = inner.split(",").map((f) => f.trim());
2839
+ const converted = innerFields.map((f) => convertFieldToSmartStore(f, primaryObject, objectAliases));
2840
+ return `(${converted.join(", ")})`;
2841
+ });
2842
+ }
2843
+ return convertFieldToSmartStore(field, primaryObject, objectAliases);
2844
+ });
2845
+ }
2846
+ function parseFromClause(fromClause) {
2847
+ const joins = [];
2848
+ const primaryMatch = fromClause.match(/^([A-Za-z0-9_]+)(?:\s+(?:AS\s+)?([A-Za-z_][A-Za-z0-9_]*))?/i);
2849
+ if (!primaryMatch) {
2850
+ return { primary: "", joins };
2851
+ }
2852
+ const primary = primaryMatch[1];
2853
+ const alias = primaryMatch[2];
2854
+ const joinRegex = /(LEFT\s+OUTER\s+JOIN|LEFT\s+JOIN|INNER\s+JOIN|JOIN)\s+([A-Za-z0-9_]+)(?:\s+(?:AS\s+)?([A-Za-z_][A-Za-z0-9_]*))?\s+ON\s+([^,]+?)(?=(?:LEFT|INNER|JOIN|$))/gi;
2855
+ let joinMatch;
2856
+ while ((joinMatch = joinRegex.exec(fromClause)) !== null) {
2857
+ joins.push({
2858
+ type: joinMatch[1].toUpperCase().replace(/\s+/g, " "),
2859
+ object: joinMatch[2],
2860
+ alias: joinMatch[3],
2861
+ on: joinMatch[4]?.trim()
2862
+ });
2863
+ }
2864
+ return { primary, alias, joins };
2865
+ }
2866
+ function convertSoqlToSmartQuery(soqlQuery) {
2867
+ if (!soqlQuery || typeof soqlQuery !== "string") {
2868
+ return "";
2869
+ }
2870
+ let normalizedQuery = soqlQuery.replace(/\s+/g, " ").trim();
2871
+ const fromMatch = normalizedQuery.match(
2872
+ /FROM\s+([\s\S]+?)(?=\s+WHERE\s+|\s+ORDER\s+BY\s+|\s+GROUP\s+BY\s+|\s+HAVING\s+|\s+LIMIT\s+|\s+OFFSET\s+|$)/i
2873
+ );
2874
+ if (!fromMatch) {
2875
+ return soqlQuery;
2876
+ }
2877
+ const fromParsed = parseFromClause(fromMatch[1].trim());
2878
+ const primaryObject = fromParsed.primary;
2879
+ if (!primaryObject) {
2880
+ return soqlQuery;
2881
+ }
2882
+ normalizedQuery = normalizedQuery.replace(
2883
+ /\bFIELDS\s*\(\s*(ALL|STANDARD|CUSTOM)\s*\)/gi,
2884
+ "__FIELDS_ALL_PLACEHOLDER__"
2885
+ );
2886
+ const selectMatch = normalizedQuery.match(/SELECT\s+([\s\S]+?)\s+FROM\s+/i);
2887
+ if (!selectMatch) {
2888
+ return soqlQuery;
2889
+ }
2890
+ const whereMatch = normalizedQuery.match(
2891
+ /WHERE\s+([\s\S]+?)(?=\s+ORDER\s+BY\s+|\s+GROUP\s+BY\s+|\s+HAVING\s+|\s+LIMIT\s+|\s+OFFSET\s+|$)/i
2892
+ );
2893
+ const groupByMatch = normalizedQuery.match(
2894
+ /GROUP\s+BY\s+([\s\S]+?)(?=\s+HAVING\s+|\s+ORDER\s+BY\s+|\s+LIMIT\s+|\s+OFFSET\s+|$)/i
2895
+ );
2896
+ const havingMatch = normalizedQuery.match(/HAVING\s+([\s\S]+?)(?=\s+ORDER\s+BY\s+|\s+LIMIT\s+|\s+OFFSET\s+|$)/i);
2897
+ const orderByMatch = normalizedQuery.match(/ORDER\s+BY\s+([\s\S]+?)(?=\s+LIMIT\s+|\s+OFFSET\s+|$)/i);
2898
+ const limitMatch = normalizedQuery.match(/LIMIT\s+(\d+)/i);
2899
+ const offsetMatch = normalizedQuery.match(/OFFSET\s+(\d+)/i);
2900
+ const objectAliases = /* @__PURE__ */ new Map();
2901
+ if (fromParsed.alias) {
2902
+ objectAliases.set(fromParsed.alias.toLowerCase(), primaryObject);
2903
+ }
2904
+ objectAliases.set(primaryObject.toLowerCase(), primaryObject);
2905
+ const parts = [];
2906
+ const selectFields = parseSelectFields(selectMatch[1].trim());
2907
+ const smartSelectFields = convertSelectFields(selectFields, primaryObject, objectAliases);
2908
+ parts.push(`SELECT ${smartSelectFields.join(", ")}`);
2909
+ parts.push(`FROM {${primaryObject}}`);
2910
+ const whereConditions = [];
2911
+ if (whereMatch) {
2912
+ const smartWhere = convertWhereClause(whereMatch[1].trim(), primaryObject, objectAliases);
2913
+ whereConditions.push(smartWhere);
2914
+ }
2915
+ if (whereConditions.length > 0) {
2916
+ parts.push(`WHERE ${whereConditions.join(" AND ")}`);
2917
+ }
2918
+ if (groupByMatch) {
2919
+ const groupByFields = parseGroupByClause(groupByMatch[1].trim());
2920
+ const smartGroupBy = convertGroupByFields(groupByFields, primaryObject, objectAliases);
2921
+ parts.push(`GROUP BY ${smartGroupBy.join(", ")}`);
2922
+ }
2923
+ if (havingMatch) {
2924
+ const smartHaving = convertWhereClause(havingMatch[1].trim(), primaryObject, objectAliases);
2925
+ parts.push(`HAVING ${smartHaving}`);
2926
+ }
2927
+ if (orderByMatch) {
2928
+ const orderByParts = parseOrderByClause(orderByMatch[1].trim());
2929
+ const smartOrderBy = convertOrderByFields(orderByParts, primaryObject, objectAliases);
2930
+ parts.push(`ORDER BY ${smartOrderBy.join(", ")}`);
2931
+ }
2932
+ if (limitMatch) {
2933
+ parts.push(`LIMIT ${limitMatch[1]}`);
2934
+ }
2935
+ if (offsetMatch) {
2936
+ parts.push(`OFFSET ${offsetMatch[1]}`);
2937
+ }
2938
+ return parts.join(" ");
2939
+ }
2940
+
2534
2941
  function query(payload) {
2535
2942
  return highLevelApi.API.request("query", payload);
2536
2943
  }
2537
2944
  function crmQuery(payload) {
2538
2945
  return highLevelApi.API.request("crm_query", payload);
2539
2946
  }
2947
+ function extractFieldsFromSoql(soqlQuery) {
2948
+ const selectMatch = soqlQuery.match(/SELECT\s+([\s\S]+?)\s+FROM\s+/i);
2949
+ if (!selectMatch) return [];
2950
+ const selectClause = selectMatch[1];
2951
+ const fields = [];
2952
+ let depth = 0;
2953
+ let currentField = "";
2954
+ for (let i = 0; i < selectClause.length; i++) {
2955
+ const char = selectClause[i];
2956
+ if (char === "(") {
2957
+ depth++;
2958
+ currentField += char;
2959
+ } else if (char === ")") {
2960
+ depth--;
2961
+ currentField += char;
2962
+ } else if (char === "," && depth === 0) {
2963
+ if (currentField.trim()) {
2964
+ fields.push(currentField.trim());
2965
+ }
2966
+ currentField = "";
2967
+ } else {
2968
+ currentField += char;
2969
+ }
2970
+ }
2971
+ if (currentField.trim()) {
2972
+ fields.push(currentField.trim());
2973
+ }
2974
+ return fields.map((field) => {
2975
+ const aliasMatch = field.match(/^(.+?)\s+(?:AS\s+)?([A-Za-z_][A-Za-z0-9_]*)$/i);
2976
+ const fieldExpr = aliasMatch ? aliasMatch[1].trim() : field.trim();
2977
+ return fieldExpr;
2978
+ });
2979
+ }
2980
+ function extractObjectFromSoql(soqlQuery) {
2981
+ const fromMatch = soqlQuery.match(/FROM\s+([A-Za-z0-9_]+)/i);
2982
+ return fromMatch ? fromMatch[1] : "";
2983
+ }
2984
+ function setNestedProperty(obj, path, value) {
2985
+ const parts = path.split(".");
2986
+ if (parts.length === 1) {
2987
+ obj[path] = value;
2988
+ return;
2989
+ }
2990
+ let current = obj;
2991
+ for (let i = 0; i < parts.length - 1; i++) {
2992
+ const part = parts[i];
2993
+ if (!current[part] || typeof current[part] !== "object") {
2994
+ current[part] = {};
2995
+ }
2996
+ current = current[part];
2997
+ }
2998
+ current[parts[parts.length - 1]] = value;
2999
+ }
3000
+ function isAllFieldsSelector(field) {
3001
+ const trimmed = field.trim();
3002
+ return trimmed === "*" || /^FIELDS\s*\(\s*(ALL|STANDARD|CUSTOM)\s*\)$/i.test(trimmed);
3003
+ }
3004
+ function transformSmartStoreResults(smartStoreResults, fields, objectName) {
3005
+ if (!smartStoreResults || !Array.isArray(smartStoreResults)) {
3006
+ return [];
3007
+ }
3008
+ return smartStoreResults.map((row) => {
3009
+ const record = {};
3010
+ fields.forEach((field, index) => {
3011
+ if (index < row.length) {
3012
+ const value = row[index];
3013
+ if (isAllFieldsSelector(field)) {
3014
+ if (value && typeof value === "object" && !Array.isArray(value)) {
3015
+ Object.assign(record, value);
3016
+ }
3017
+ } else {
3018
+ setNestedProperty(record, field, value);
3019
+ }
3020
+ }
3021
+ });
3022
+ const recordId = record["Id"] || record["id"] || "";
3023
+ record["attributes"] = {
3024
+ type: objectName,
3025
+ url: recordId ? `/services/data/v57.0/sobjects/${objectName}/${recordId}` : ""
3026
+ };
3027
+ return record;
3028
+ });
3029
+ }
3030
+ async function crmQueryAdaptive(payload) {
3031
+ const query2 = payload.query;
3032
+ if (!query2 || typeof query2 !== "string") {
3033
+ return Promise.reject(new Error("Query is required and must be a string"));
3034
+ }
3035
+ let useSmartStore = false;
3036
+ try {
3037
+ const env = await highLevelApi.API.request("get_env");
3038
+ const isIos = env?.mode === "IOS";
3039
+ const isSfdcSyncEnabled = env?.pitcher?.instance?.settings?.enable_sfdc_sync === true;
3040
+ useSmartStore = isIos && isSfdcSyncEnabled;
3041
+ } catch {
3042
+ useSmartStore = false;
3043
+ }
3044
+ console.log(`[crmQueryAdaptive] Called query: `, query2);
3045
+ if (useSmartStore) {
3046
+ const fields = extractFieldsFromSoql(query2);
3047
+ const objectName = extractObjectFromSoql(query2);
3048
+ const smartQuery = convertSoqlToSmartQuery(query2);
3049
+ console.log(`[crmSmartQuery] Called query: `, smartQuery);
3050
+ const smartStoreResults = await crmSmartQuery({ query: smartQuery });
3051
+ const records = transformSmartStoreResults(smartStoreResults, fields, objectName);
3052
+ console.log(`[SmartStore] Results: `, records);
3053
+ return {
3054
+ records,
3055
+ totalSize: records.length
3056
+ };
3057
+ }
3058
+ return crmQuery(payload);
3059
+ }
2540
3060
  function crmSmartQuery(payload) {
2541
3061
  const query2 = payload.query;
2542
3062
  if (!query2 || typeof query2 !== "string") {
2543
3063
  return Promise.reject(new Error("Query is required and must be a string"));
2544
3064
  }
2545
- const smartStorePattern = /\{[^}]+:[^}]+\}/;
3065
+ const smartStorePattern = /\{[^}]+:[^}]+}/;
2546
3066
  if (!smartStorePattern.test(query2.trim())) {
2547
3067
  return Promise.reject(
2548
3068
  new Error(
@@ -2599,7 +3119,14 @@ function crmSmartUpsertObjects(payload) {
2599
3119
  }
2600
3120
  }
2601
3121
  }
2602
- return highLevelApi.API.request("crm_smart_upsert_objects", payload);
3122
+ console.log("[crmSmartUpsertObjects] Request payload:", JSON.stringify(payload, null, 2));
3123
+ return highLevelApi.API.request("crm_smart_upsert_objects", payload).then((result) => {
3124
+ console.log("[crmSmartUpsertObjects] Success:", result);
3125
+ return result;
3126
+ }).catch((error) => {
3127
+ console.error("[crmSmartUpsertObjects] Error:", error);
3128
+ throw error;
3129
+ });
2603
3130
  }
2604
3131
  function crmSmartObjectValidationRules(payload) {
2605
3132
  if (!payload) {
@@ -2611,6 +3138,16 @@ function crmSmartObjectValidationRules(payload) {
2611
3138
  }
2612
3139
  return highLevelApi.API.request("crm_smart_object_validation_rules", payload);
2613
3140
  }
3141
+ function crmSmartObjectLayout(payload) {
3142
+ if (!payload) {
3143
+ return Promise.reject(new Error("Payload is required"));
3144
+ }
3145
+ const objectName = payload.object;
3146
+ if (!objectName || typeof objectName !== "string" || objectName.trim() === "") {
3147
+ return Promise.reject(new Error("Object name is required and must be a non-empty string"));
3148
+ }
3149
+ return highLevelApi.API.request("crm_smart_object_layout", payload);
3150
+ }
2614
3151
  function crmSmartDeleteObjects(payload) {
2615
3152
  if (!payload || !payload.objects || !Array.isArray(payload.objects)) {
2616
3153
  return Promise.reject(new Error("Payload must contain an array of objects"));
@@ -2639,7 +3176,14 @@ function crmSmartDeleteObjects(payload) {
2639
3176
  }
2640
3177
  }
2641
3178
  }
2642
- return highLevelApi.API.request("crm_smart_delete_objects", payload);
3179
+ console.log("[crmSmartDeleteObjects] Request payload:", JSON.stringify(payload, null, 2));
3180
+ return highLevelApi.API.request("crm_smart_delete_objects", payload).then((result) => {
3181
+ console.log("[crmSmartDeleteObjects] Success:", result);
3182
+ return result;
3183
+ }).catch((error) => {
3184
+ console.error("[crmSmartDeleteObjects] Error:", error);
3185
+ throw error;
3186
+ });
2643
3187
  }
2644
3188
  function crmCreate(payload) {
2645
3189
  if (!payload) {
@@ -2684,6 +3228,24 @@ function crmUpsert(payload) {
2684
3228
  }
2685
3229
  return highLevelApi.API.request("crm_upsert", payload);
2686
3230
  }
3231
+ function crmDescribe(payload) {
3232
+ if (!payload) {
3233
+ return Promise.reject(new Error("Payload is required"));
3234
+ }
3235
+ if (!payload.sobject || typeof payload.sobject !== "string" || payload.sobject.trim() === "") {
3236
+ return Promise.reject(new Error("sobject is required and must be a non-empty string"));
3237
+ }
3238
+ return highLevelApi.API.request("crm_describe", payload);
3239
+ }
3240
+ function crmLayout(payload) {
3241
+ if (!payload) {
3242
+ return Promise.reject(new Error("Payload is required"));
3243
+ }
3244
+ if (!payload.sobject || typeof payload.sobject !== "string" || payload.sobject.trim() === "") {
3245
+ return Promise.reject(new Error("sobject is required and must be a non-empty string"));
3246
+ }
3247
+ return highLevelApi.API.request("crm_layout", payload);
3248
+ }
2687
3249
 
2688
3250
  function getFolders(payload) {
2689
3251
  return this.API.request("get_folders", payload);
@@ -2781,8 +3343,12 @@ const modules = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2781
3343
  createFile,
2782
3344
  createFolder,
2783
3345
  crmCreate,
3346
+ crmDescribe,
3347
+ crmLayout,
2784
3348
  crmQuery,
3349
+ crmQueryAdaptive,
2785
3350
  crmSmartDeleteObjects,
3351
+ crmSmartObjectLayout,
2786
3352
  crmSmartObjectMetadata,
2787
3353
  crmSmartObjectValidationRules,
2788
3354
  crmSmartQuery,
@@ -3382,9 +3948,12 @@ const TRUNCATE_LENGTH_TRIGGER = 10;
3382
3948
  const RAW_PAYLOAD_METHODS = [
3383
3949
  "crm_create",
3384
3950
  "crm_upsert",
3951
+ "crm_describe",
3952
+ "crm_layout",
3385
3953
  "crm_smart_query",
3386
3954
  "crm_smart_object_metadata",
3387
3955
  "crm_smart_object_validation_rules",
3956
+ "crm_smart_object_layout",
3388
3957
  "crm_smart_upsert_objects",
3389
3958
  "crm_smart_delete_objects"
3390
3959
  ];