deepline 0.1.41 → 0.1.45

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.js CHANGED
@@ -215,8 +215,8 @@ function resolveConfig(options) {
215
215
  }
216
216
 
217
217
  // src/version.ts
218
- var SDK_VERSION = "0.1.41";
219
- var SDK_API_CONTRACT = "2026-05-cloud-play-search";
218
+ var SDK_VERSION = "0.1.45";
219
+ var SDK_API_CONTRACT = "2026-05-promo-redemption-policy";
220
220
 
221
221
  // ../shared_libs/play-runtime/coordinator-headers.ts
222
222
  var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
@@ -763,7 +763,7 @@ var DeeplineClient = class {
763
763
  params.set("search_terms", options.searchTerms.trim());
764
764
  }
765
765
  return this.http.get(
766
- `/api/v2/integrations/list?${params.toString()}`
766
+ `/api/v2/tools/search?${params.toString()}`
767
767
  );
768
768
  }
769
769
  /**
@@ -1736,6 +1736,16 @@ function getAtPath(root, path) {
1736
1736
  }
1737
1737
  return current;
1738
1738
  }
1739
+ function normalizeString(value) {
1740
+ if (typeof value === "string") {
1741
+ const trimmed = value.trim();
1742
+ return trimmed ? trimmed : null;
1743
+ }
1744
+ if (typeof value === "number" && Number.isFinite(value)) {
1745
+ return String(value);
1746
+ }
1747
+ return null;
1748
+ }
1739
1749
  function normalizeRows(value) {
1740
1750
  if (!Array.isArray(value)) return null;
1741
1751
  return value.map((entry) => isRecord2(entry) ? entry : { value: entry });
@@ -1779,14 +1789,49 @@ function findFirstTargetByKey(result, target, depth = 0, path = []) {
1779
1789
  }
1780
1790
  return null;
1781
1791
  }
1792
+ function normalizeEmailStatus(value) {
1793
+ const normalized = normalizeString(value)?.toLowerCase().replace(/[\s-]+/g, "_");
1794
+ if (!normalized) return "unknown";
1795
+ if (["deliverable", "verified", "ok", "true"].includes(normalized))
1796
+ return "valid";
1797
+ if (["undeliverable", "bad", "false", "failed"].includes(normalized))
1798
+ return "invalid";
1799
+ if (["accept_all", "acceptall", "catchall", "valid_catch_all"].includes(
1800
+ normalized
1801
+ )) {
1802
+ return "catch_all";
1803
+ }
1804
+ return normalized;
1805
+ }
1806
+ function normalizePhoneStatus(value) {
1807
+ if (typeof value === "boolean") return value ? "valid" : "invalid";
1808
+ const normalized = normalizeString(value)?.toLowerCase().replace(/[\s-]+/g, "_");
1809
+ if (!normalized) return "unknown";
1810
+ if (["verified", "ok", "true", "active"].includes(normalized)) return "valid";
1811
+ if (["bad", "false", "failed", "inactive", "disconnected"].includes(normalized)) {
1812
+ return "invalid";
1813
+ }
1814
+ return normalized;
1815
+ }
1816
+ function applyExtractorTransforms(value, descriptor) {
1817
+ return (descriptor.transforms ?? []).reduce((current, transform) => {
1818
+ if (transform.endsWith("emailStatus")) return normalizeEmailStatus(current);
1819
+ if (transform.endsWith("phoneStatus")) return normalizePhoneStatus(current);
1820
+ return current;
1821
+ }, value);
1822
+ }
1823
+ function coerceToEnum(value, descriptor) {
1824
+ if (!descriptor.enum?.length) return value;
1825
+ const normalized = normalizeString(value);
1826
+ if (!normalized) return value;
1827
+ return descriptor.enum.includes(normalized) ? normalized : value;
1828
+ }
1782
1829
  function resolveListRows(result, listExtractorPaths) {
1783
1830
  const lists = {};
1784
1831
  for (const rawPath of listExtractorPaths ?? []) {
1785
1832
  const path = normalizeResultPath(rawPath);
1786
1833
  if (!path) continue;
1787
- const candidates = [
1788
- ...candidateResultPaths(rawPath)
1789
- ].filter(
1834
+ const candidates = [...candidateResultPaths(rawPath)].filter(
1790
1835
  (candidate, index, all) => candidate && all.indexOf(candidate) === index
1791
1836
  );
1792
1837
  let resolvedPath = null;
@@ -1810,9 +1855,7 @@ function deriveListKeys(input) {
1810
1855
  for (const [target, paths] of Object.entries(
1811
1856
  input.listIdentityGetters ?? {}
1812
1857
  )) {
1813
- const firstPath = paths.map(
1814
- (rawPath) => normalizeRelativePath(rawPath)
1815
- ).find(Boolean);
1858
+ const firstPath = paths.map((rawPath) => normalizeRelativePath(rawPath)).find(Boolean);
1816
1859
  if (firstPath) {
1817
1860
  keys[target] = firstPath;
1818
1861
  }
@@ -1822,7 +1865,7 @@ function deriveListKeys(input) {
1822
1865
  }
1823
1866
  const listPrefix = input.listPath.replace(/\[\d+\]$/, "");
1824
1867
  for (const [target, paths] of Object.entries(
1825
- input.resultIdentityGetters ?? {}
1868
+ input.targetGetters ?? {}
1826
1869
  )) {
1827
1870
  for (const rawPath of paths) {
1828
1871
  const path = String(rawPath || "").trim().replace(/^\./, "");
@@ -1859,13 +1902,25 @@ function deriveListKeys(input) {
1859
1902
  }
1860
1903
  return keys;
1861
1904
  }
1862
- function buildTargets(result, resultIdentityGetters) {
1905
+ function buildTargets(result, extractors, targetGetters) {
1863
1906
  const targets = {};
1864
- const metadataTargets = new Set(Object.keys(resultIdentityGetters ?? {}));
1907
+ for (const [target, descriptor] of Object.entries(extractors ?? {})) {
1908
+ const fromExtractor = findFirstTargetByPath(result, descriptor.paths);
1909
+ if (!fromExtractor) continue;
1910
+ targets[target] = {
1911
+ path: fromExtractor.path,
1912
+ value: coerceToEnum(
1913
+ applyExtractorTransforms(fromExtractor.value, descriptor),
1914
+ descriptor
1915
+ )
1916
+ };
1917
+ }
1918
+ const metadataTargets = new Set(Object.keys(targetGetters ?? {}));
1865
1919
  for (const target of metadataTargets) {
1920
+ if (targets[target]) continue;
1866
1921
  const fromMetadata = findFirstTargetByPath(
1867
1922
  result,
1868
- resultIdentityGetters?.[target]
1923
+ targetGetters?.[target]
1869
1924
  );
1870
1925
  if (fromMetadata) {
1871
1926
  targets[target] = fromMetadata;
@@ -1883,9 +1938,8 @@ function buildTargets(result, resultIdentityGetters) {
1883
1938
  }
1884
1939
  return targets;
1885
1940
  }
1886
- function buildLists(result, metadata) {
1941
+ function buildLists(resolved, metadata) {
1887
1942
  const lists = {};
1888
- const resolved = resolveListRows(result, metadata.listExtractorPaths);
1889
1943
  for (const [name, list] of Object.entries(resolved)) {
1890
1944
  lists[name] = {
1891
1945
  path: list.path,
@@ -1893,7 +1947,7 @@ function buildLists(result, metadata) {
1893
1947
  keys: deriveListKeys({
1894
1948
  listPath: list.path,
1895
1949
  rows: list.rows,
1896
- resultIdentityGetters: metadata.resultIdentityGetters,
1950
+ targetGetters: metadata.targetGetters,
1897
1951
  listIdentityGetters: metadata.listIdentityGetters
1898
1952
  })
1899
1953
  };
@@ -1920,9 +1974,10 @@ function buildExtractedAccessors(targets) {
1920
1974
  })
1921
1975
  );
1922
1976
  }
1923
- function buildListAccessors(result, lists) {
1977
+ function buildListAccessors(resolved, lists) {
1924
1978
  return Object.fromEntries(
1925
1979
  Object.entries(lists).map(([name, metadata]) => {
1980
+ const rows = resolved[name]?.rows ?? [];
1926
1981
  const accessor = {
1927
1982
  path: metadata.path,
1928
1983
  count: metadata.count,
@@ -1930,7 +1985,7 @@ function buildListAccessors(result, lists) {
1930
1985
  };
1931
1986
  Object.defineProperty(accessor, "get", {
1932
1987
  value() {
1933
- return normalizeRows(getAtPath(result, metadata.path)) ?? [];
1988
+ return rows;
1934
1989
  },
1935
1990
  enumerable: false
1936
1991
  });
@@ -1948,13 +2003,19 @@ function createToolExecuteResult(input) {
1948
2003
  };
1949
2004
  const targets = buildTargets(
1950
2005
  resultRoot,
1951
- input.metadata.resultIdentityGetters
2006
+ input.metadata.extractors,
2007
+ input.metadata.targetGetters
1952
2008
  );
1953
- const lists = buildLists(resultRoot, input.metadata);
2009
+ const resolvedLists = resolveListRows(
2010
+ resultRoot,
2011
+ input.metadata.listExtractorPaths
2012
+ );
2013
+ const lists = buildLists(resolvedLists, input.metadata);
1954
2014
  const metadata = {
1955
2015
  toolId: input.metadata.toolId,
1956
2016
  execution: input.execution,
1957
2017
  targets,
2018
+ ...input.metadata.extractors ? { extractors: input.metadata.extractors } : {},
1958
2019
  lists
1959
2020
  };
1960
2021
  const toolResponse = {
@@ -1962,7 +2023,7 @@ function createToolExecuteResult(input) {
1962
2023
  ...result.meta ? { meta: result.meta } : {}
1963
2024
  };
1964
2025
  const extractedValues = buildExtractedAccessors(targets);
1965
- const extractedLists = buildListAccessors(resultRoot, lists);
2026
+ const extractedLists = buildListAccessors(resolvedLists, lists);
1966
2027
  const wrapper = {
1967
2028
  status: input.status,
1968
2029
  ...input.jobId ? { job_id: input.jobId } : {},
@@ -2250,6 +2311,28 @@ function stringArrayRecord(value) {
2250
2311
  function stringArray(value) {
2251
2312
  return Array.isArray(value) ? value.map(String) : [];
2252
2313
  }
2314
+ function extractorDescriptorRecord(value) {
2315
+ if (!isRecord3(value)) return {};
2316
+ return Object.fromEntries(
2317
+ Object.entries(value).flatMap(([key, descriptor]) => {
2318
+ if (!isRecord3(descriptor)) return [];
2319
+ const paths = stringArray(descriptor.paths).map((path) => path.trim()).filter(Boolean);
2320
+ if (paths.length === 0) return [];
2321
+ const transforms = stringArray(descriptor.transforms).map((transform) => transform.trim()).filter(Boolean);
2322
+ const enumValues = stringArray(descriptor.enum).map((entry) => entry.trim()).filter(Boolean);
2323
+ return [
2324
+ [
2325
+ key,
2326
+ {
2327
+ paths,
2328
+ ...transforms.length > 0 ? { transforms } : {},
2329
+ ...enumValues.length > 0 ? { enum: enumValues } : {}
2330
+ }
2331
+ ]
2332
+ ];
2333
+ })
2334
+ );
2335
+ }
2253
2336
  function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2254
2337
  const raw = response.toolResponse?.raw ?? null;
2255
2338
  const meta = response.toolResponse?.meta;
@@ -2264,8 +2347,9 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2264
2347
  },
2265
2348
  metadata: {
2266
2349
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
2267
- resultIdentityGetters: stringArrayRecord(
2268
- toolMetadata.resultIdentityGetters
2350
+ extractors: extractorDescriptorRecord(toolMetadata.extractors),
2351
+ targetGetters: stringArrayRecord(
2352
+ toolMetadata.targetGetters
2269
2353
  ),
2270
2354
  listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
2271
2355
  listIdentityGetters: stringArrayRecord(toolMetadata.listIdentityGetters)
package/dist/index.mjs CHANGED
@@ -169,8 +169,8 @@ function resolveConfig(options) {
169
169
  }
170
170
 
171
171
  // src/version.ts
172
- var SDK_VERSION = "0.1.41";
173
- var SDK_API_CONTRACT = "2026-05-cloud-play-search";
172
+ var SDK_VERSION = "0.1.45";
173
+ var SDK_API_CONTRACT = "2026-05-promo-redemption-policy";
174
174
 
175
175
  // ../shared_libs/play-runtime/coordinator-headers.ts
176
176
  var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
@@ -717,7 +717,7 @@ var DeeplineClient = class {
717
717
  params.set("search_terms", options.searchTerms.trim());
718
718
  }
719
719
  return this.http.get(
720
- `/api/v2/integrations/list?${params.toString()}`
720
+ `/api/v2/tools/search?${params.toString()}`
721
721
  );
722
722
  }
723
723
  /**
@@ -1690,6 +1690,16 @@ function getAtPath(root, path) {
1690
1690
  }
1691
1691
  return current;
1692
1692
  }
1693
+ function normalizeString(value) {
1694
+ if (typeof value === "string") {
1695
+ const trimmed = value.trim();
1696
+ return trimmed ? trimmed : null;
1697
+ }
1698
+ if (typeof value === "number" && Number.isFinite(value)) {
1699
+ return String(value);
1700
+ }
1701
+ return null;
1702
+ }
1693
1703
  function normalizeRows(value) {
1694
1704
  if (!Array.isArray(value)) return null;
1695
1705
  return value.map((entry) => isRecord2(entry) ? entry : { value: entry });
@@ -1733,14 +1743,49 @@ function findFirstTargetByKey(result, target, depth = 0, path = []) {
1733
1743
  }
1734
1744
  return null;
1735
1745
  }
1746
+ function normalizeEmailStatus(value) {
1747
+ const normalized = normalizeString(value)?.toLowerCase().replace(/[\s-]+/g, "_");
1748
+ if (!normalized) return "unknown";
1749
+ if (["deliverable", "verified", "ok", "true"].includes(normalized))
1750
+ return "valid";
1751
+ if (["undeliverable", "bad", "false", "failed"].includes(normalized))
1752
+ return "invalid";
1753
+ if (["accept_all", "acceptall", "catchall", "valid_catch_all"].includes(
1754
+ normalized
1755
+ )) {
1756
+ return "catch_all";
1757
+ }
1758
+ return normalized;
1759
+ }
1760
+ function normalizePhoneStatus(value) {
1761
+ if (typeof value === "boolean") return value ? "valid" : "invalid";
1762
+ const normalized = normalizeString(value)?.toLowerCase().replace(/[\s-]+/g, "_");
1763
+ if (!normalized) return "unknown";
1764
+ if (["verified", "ok", "true", "active"].includes(normalized)) return "valid";
1765
+ if (["bad", "false", "failed", "inactive", "disconnected"].includes(normalized)) {
1766
+ return "invalid";
1767
+ }
1768
+ return normalized;
1769
+ }
1770
+ function applyExtractorTransforms(value, descriptor) {
1771
+ return (descriptor.transforms ?? []).reduce((current, transform) => {
1772
+ if (transform.endsWith("emailStatus")) return normalizeEmailStatus(current);
1773
+ if (transform.endsWith("phoneStatus")) return normalizePhoneStatus(current);
1774
+ return current;
1775
+ }, value);
1776
+ }
1777
+ function coerceToEnum(value, descriptor) {
1778
+ if (!descriptor.enum?.length) return value;
1779
+ const normalized = normalizeString(value);
1780
+ if (!normalized) return value;
1781
+ return descriptor.enum.includes(normalized) ? normalized : value;
1782
+ }
1736
1783
  function resolveListRows(result, listExtractorPaths) {
1737
1784
  const lists = {};
1738
1785
  for (const rawPath of listExtractorPaths ?? []) {
1739
1786
  const path = normalizeResultPath(rawPath);
1740
1787
  if (!path) continue;
1741
- const candidates = [
1742
- ...candidateResultPaths(rawPath)
1743
- ].filter(
1788
+ const candidates = [...candidateResultPaths(rawPath)].filter(
1744
1789
  (candidate, index, all) => candidate && all.indexOf(candidate) === index
1745
1790
  );
1746
1791
  let resolvedPath = null;
@@ -1764,9 +1809,7 @@ function deriveListKeys(input) {
1764
1809
  for (const [target, paths] of Object.entries(
1765
1810
  input.listIdentityGetters ?? {}
1766
1811
  )) {
1767
- const firstPath = paths.map(
1768
- (rawPath) => normalizeRelativePath(rawPath)
1769
- ).find(Boolean);
1812
+ const firstPath = paths.map((rawPath) => normalizeRelativePath(rawPath)).find(Boolean);
1770
1813
  if (firstPath) {
1771
1814
  keys[target] = firstPath;
1772
1815
  }
@@ -1776,7 +1819,7 @@ function deriveListKeys(input) {
1776
1819
  }
1777
1820
  const listPrefix = input.listPath.replace(/\[\d+\]$/, "");
1778
1821
  for (const [target, paths] of Object.entries(
1779
- input.resultIdentityGetters ?? {}
1822
+ input.targetGetters ?? {}
1780
1823
  )) {
1781
1824
  for (const rawPath of paths) {
1782
1825
  const path = String(rawPath || "").trim().replace(/^\./, "");
@@ -1813,13 +1856,25 @@ function deriveListKeys(input) {
1813
1856
  }
1814
1857
  return keys;
1815
1858
  }
1816
- function buildTargets(result, resultIdentityGetters) {
1859
+ function buildTargets(result, extractors, targetGetters) {
1817
1860
  const targets = {};
1818
- const metadataTargets = new Set(Object.keys(resultIdentityGetters ?? {}));
1861
+ for (const [target, descriptor] of Object.entries(extractors ?? {})) {
1862
+ const fromExtractor = findFirstTargetByPath(result, descriptor.paths);
1863
+ if (!fromExtractor) continue;
1864
+ targets[target] = {
1865
+ path: fromExtractor.path,
1866
+ value: coerceToEnum(
1867
+ applyExtractorTransforms(fromExtractor.value, descriptor),
1868
+ descriptor
1869
+ )
1870
+ };
1871
+ }
1872
+ const metadataTargets = new Set(Object.keys(targetGetters ?? {}));
1819
1873
  for (const target of metadataTargets) {
1874
+ if (targets[target]) continue;
1820
1875
  const fromMetadata = findFirstTargetByPath(
1821
1876
  result,
1822
- resultIdentityGetters?.[target]
1877
+ targetGetters?.[target]
1823
1878
  );
1824
1879
  if (fromMetadata) {
1825
1880
  targets[target] = fromMetadata;
@@ -1837,9 +1892,8 @@ function buildTargets(result, resultIdentityGetters) {
1837
1892
  }
1838
1893
  return targets;
1839
1894
  }
1840
- function buildLists(result, metadata) {
1895
+ function buildLists(resolved, metadata) {
1841
1896
  const lists = {};
1842
- const resolved = resolveListRows(result, metadata.listExtractorPaths);
1843
1897
  for (const [name, list] of Object.entries(resolved)) {
1844
1898
  lists[name] = {
1845
1899
  path: list.path,
@@ -1847,7 +1901,7 @@ function buildLists(result, metadata) {
1847
1901
  keys: deriveListKeys({
1848
1902
  listPath: list.path,
1849
1903
  rows: list.rows,
1850
- resultIdentityGetters: metadata.resultIdentityGetters,
1904
+ targetGetters: metadata.targetGetters,
1851
1905
  listIdentityGetters: metadata.listIdentityGetters
1852
1906
  })
1853
1907
  };
@@ -1874,9 +1928,10 @@ function buildExtractedAccessors(targets) {
1874
1928
  })
1875
1929
  );
1876
1930
  }
1877
- function buildListAccessors(result, lists) {
1931
+ function buildListAccessors(resolved, lists) {
1878
1932
  return Object.fromEntries(
1879
1933
  Object.entries(lists).map(([name, metadata]) => {
1934
+ const rows = resolved[name]?.rows ?? [];
1880
1935
  const accessor = {
1881
1936
  path: metadata.path,
1882
1937
  count: metadata.count,
@@ -1884,7 +1939,7 @@ function buildListAccessors(result, lists) {
1884
1939
  };
1885
1940
  Object.defineProperty(accessor, "get", {
1886
1941
  value() {
1887
- return normalizeRows(getAtPath(result, metadata.path)) ?? [];
1942
+ return rows;
1888
1943
  },
1889
1944
  enumerable: false
1890
1945
  });
@@ -1902,13 +1957,19 @@ function createToolExecuteResult(input) {
1902
1957
  };
1903
1958
  const targets = buildTargets(
1904
1959
  resultRoot,
1905
- input.metadata.resultIdentityGetters
1960
+ input.metadata.extractors,
1961
+ input.metadata.targetGetters
1906
1962
  );
1907
- const lists = buildLists(resultRoot, input.metadata);
1963
+ const resolvedLists = resolveListRows(
1964
+ resultRoot,
1965
+ input.metadata.listExtractorPaths
1966
+ );
1967
+ const lists = buildLists(resolvedLists, input.metadata);
1908
1968
  const metadata = {
1909
1969
  toolId: input.metadata.toolId,
1910
1970
  execution: input.execution,
1911
1971
  targets,
1972
+ ...input.metadata.extractors ? { extractors: input.metadata.extractors } : {},
1912
1973
  lists
1913
1974
  };
1914
1975
  const toolResponse = {
@@ -1916,7 +1977,7 @@ function createToolExecuteResult(input) {
1916
1977
  ...result.meta ? { meta: result.meta } : {}
1917
1978
  };
1918
1979
  const extractedValues = buildExtractedAccessors(targets);
1919
- const extractedLists = buildListAccessors(resultRoot, lists);
1980
+ const extractedLists = buildListAccessors(resolvedLists, lists);
1920
1981
  const wrapper = {
1921
1982
  status: input.status,
1922
1983
  ...input.jobId ? { job_id: input.jobId } : {},
@@ -2204,6 +2265,28 @@ function stringArrayRecord(value) {
2204
2265
  function stringArray(value) {
2205
2266
  return Array.isArray(value) ? value.map(String) : [];
2206
2267
  }
2268
+ function extractorDescriptorRecord(value) {
2269
+ if (!isRecord3(value)) return {};
2270
+ return Object.fromEntries(
2271
+ Object.entries(value).flatMap(([key, descriptor]) => {
2272
+ if (!isRecord3(descriptor)) return [];
2273
+ const paths = stringArray(descriptor.paths).map((path) => path.trim()).filter(Boolean);
2274
+ if (paths.length === 0) return [];
2275
+ const transforms = stringArray(descriptor.transforms).map((transform) => transform.trim()).filter(Boolean);
2276
+ const enumValues = stringArray(descriptor.enum).map((entry) => entry.trim()).filter(Boolean);
2277
+ return [
2278
+ [
2279
+ key,
2280
+ {
2281
+ paths,
2282
+ ...transforms.length > 0 ? { transforms } : {},
2283
+ ...enumValues.length > 0 ? { enum: enumValues } : {}
2284
+ }
2285
+ ]
2286
+ ];
2287
+ })
2288
+ );
2289
+ }
2207
2290
  function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2208
2291
  const raw = response.toolResponse?.raw ?? null;
2209
2292
  const meta = response.toolResponse?.meta;
@@ -2218,8 +2301,9 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response) {
2218
2301
  },
2219
2302
  metadata: {
2220
2303
  toolId: typeof toolMetadata.toolId === "string" ? toolMetadata.toolId : fallbackToolId,
2221
- resultIdentityGetters: stringArrayRecord(
2222
- toolMetadata.resultIdentityGetters
2304
+ extractors: extractorDescriptorRecord(toolMetadata.extractors),
2305
+ targetGetters: stringArrayRecord(
2306
+ toolMetadata.targetGetters
2223
2307
  ),
2224
2308
  listExtractorPaths: stringArray(toolMetadata.listExtractorPaths),
2225
2309
  listIdentityGetters: stringArrayRecord(toolMetadata.listIdentityGetters)