@proveanything/smartlinks 1.10.0 → 1.10.2

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.
@@ -1,4 +1,4 @@
1
- import type { AppCase, CreateCaseInput, UpdateCaseInput, AppendHistoryInput, CaseSummaryRequest, CaseSummaryResponse, CaseListQueryParams, AppThread, CreateThreadInput, UpdateThreadInput, ReplyInput, ThreadListQueryParams, AppRecord, CreateRecordInput, CreateRecordResponse, UpdateRecordInput, UpsertRecordInput, UpsertRecordResponse, MatchRecordsInput, MatchResult, BulkUpsertItem, BulkUpsertResult, BulkDeleteResult, BulkDeleteInput, RecordListQueryParams, PaginatedResponse, AggregateRequest, AggregateResponse, RelatedResponse } from '../types/appObjects';
1
+ import type { AppCase, CreateCaseInput, UpdateCaseInput, AppendHistoryInput, CaseSummaryRequest, CaseSummaryResponse, CaseListQueryParams, AppThread, CreateThreadInput, UpdateThreadInput, ReplyInput, ThreadListQueryParams, AppRecord, CreateRecordInput, CreateRecordResponse, UpdateRecordInput, UpsertRecordInput, UpsertRecordResponse, MatchRecordsInput, MatchResult, BulkUpsertItem, BulkUpsertResult, BulkDeleteResult, BulkDeleteInput, RecordListQueryParams, ResolveAllParams, ResolveAllResult, PreviewRuleParams, PreviewRuleResult, PaginatedResponse, AggregateRequest, AggregateResponse, RelatedResponse } from '../types/appObjects';
2
2
  export declare namespace app {
3
3
  namespace cases {
4
4
  /**
@@ -239,5 +239,20 @@ export declare namespace app {
239
239
  * ```
240
240
  */
241
241
  function bulkDelete(collectionId: string, appId: string, input: BulkDeleteInput): Promise<BulkDeleteResult>;
242
+ /**
243
+ * Resolve every applicable record for a product context in one call.
244
+ * Returns records across all tiers (proof, batch, variant, product, rule, facet, collection)
245
+ * deduplicated and sorted by specificity descending.
246
+ * POST /records/resolve-all
247
+ *
248
+ * @param admin - false for public (visibility-filtered), true for admin (all records)
249
+ */
250
+ function resolveAll(collectionId: string, appId: string, input: ResolveAllParams, admin?: boolean): Promise<ResolveAllResult>;
251
+ /**
252
+ * Preview which products in the collection match a given facetRule.
253
+ * Admin only. Use for live "matches N products" feedback while authoring a rule.
254
+ * POST /records/preview-rule
255
+ */
256
+ function previewRule(collectionId: string, appId: string, input: PreviewRuleParams): Promise<PreviewRuleResult>;
242
257
  }
243
258
  }
@@ -378,6 +378,29 @@ export var app;
378
378
  return post(path, input);
379
379
  }
380
380
  records_1.bulkDelete = bulkDelete;
381
+ /**
382
+ * Resolve every applicable record for a product context in one call.
383
+ * Returns records across all tiers (proof, batch, variant, product, rule, facet, collection)
384
+ * deduplicated and sorted by specificity descending.
385
+ * POST /records/resolve-all
386
+ *
387
+ * @param admin - false for public (visibility-filtered), true for admin (all records)
388
+ */
389
+ async function resolveAll(collectionId, appId, input, admin = false) {
390
+ const path = `${basePath(collectionId, appId, admin)}/resolve-all`;
391
+ return post(path, input);
392
+ }
393
+ records_1.resolveAll = resolveAll;
394
+ /**
395
+ * Preview which products in the collection match a given facetRule.
396
+ * Admin only. Use for live "matches N products" feedback while authoring a rule.
397
+ * POST /records/preview-rule
398
+ */
399
+ async function previewRule(collectionId, appId, input) {
400
+ const path = `${basePath(collectionId, appId, true)}/preview-rule`;
401
+ return post(path, input);
402
+ }
403
+ records_1.previewRule = previewRule;
381
404
  })(records = app.records || (app.records = {}));
382
405
  })(app || (app = {})); // end namespace app
383
406
  // ==================== HELPERS ====================
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.10.0 | Generated: 2026-04-25T13:26:09.113Z
3
+ Version: 1.10.2 | Generated: 2026-04-27T09:32:45.351Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -1880,24 +1880,24 @@ interface ReplyInput {
1880
1880
  }
1881
1881
  ```
1882
1882
 
1883
- **ScopeFacetClause** (interface)
1883
+ **FacetRuleClause** (interface)
1884
1884
  ```typescript
1885
- interface ScopeFacetClause {
1886
- key: string
1887
- valueKeys: string[]
1885
+ interface FacetRuleClause {
1886
+ * Facet key this clause tests, e.g. "brand", "type", "bread-type".
1887
+ * Must reference a defined facet on the collection.
1888
+ facetKey: string
1889
+ * One or more facet value keys that satisfy the clause (OR semantics).
1890
+ * At least one value required. Server deduplicates and sorts.
1891
+ anyOf: string[]
1888
1892
  }
1889
1893
  ```
1890
1894
 
1891
- **RecordScope** (interface)
1895
+ **FacetRule** (interface)
1892
1896
  ```typescript
1893
- interface RecordScope {
1894
- productId?: string
1895
- variantId?: string
1896
- proofId?: string
1897
- batchId?: string
1898
- * Arbitrary facet clauses.
1899
- * Clauses are ANDed together; valueKeys within a clause are ORed.
1900
- facets?: ScopeFacetClause[]
1897
+ interface FacetRule {
1898
+ * All clauses must be satisfied (AND semantics).
1899
+ * Must be non-empty; no duplicate facetKey entries.
1900
+ all: FacetRuleClause[]
1901
1901
  }
1902
1902
  ```
1903
1903
 
@@ -1908,8 +1908,10 @@ interface RecordTarget {
1908
1908
  variantId?: string
1909
1909
  proofId?: string
1910
1910
  batchId?: string
1911
- * Facet values the caller possesses, keyed by facet key.
1912
- * A scope clause is satisfied if ANY of the clause's valueKeys appears here.
1911
+ * Facet assignments for the product (e.g. `{ brand: ['samsung'], type: ['tv'] }`).
1912
+ * Used exclusively to match FacetRule records via GIN-indexed containment check.
1913
+ * Does NOT filter legacy scope.facets arrays (that system is removed in SDK 1.12).
1914
+ * Omit to exclude rule records from results.
1913
1915
  facets?: Record<string, string[]>
1914
1916
  }
1915
1917
  ```
@@ -1919,14 +1921,18 @@ interface RecordTarget {
1919
1921
  interface BulkUpsertItem {
1920
1922
  ref: string
1921
1923
  recordType?: string
1922
- customId?: string
1923
- sourceSystem?: string
1924
+ productId?: string | null
1925
+ variantId?: string | null
1926
+ batchId?: string | null
1927
+ proofId?: string | null
1928
+ customId?: string | null
1929
+ sourceSystem?: string | null
1924
1930
  startsAt?: string | null
1925
1931
  expiresAt?: string | null
1926
1932
  status?: string | null
1927
- scope?: RecordScope
1928
1933
  data?: Record<string, unknown> | null
1929
1934
  metadata?: Record<string, unknown> | null
1935
+ facetRule?: FacetRule | null
1930
1936
  }
1931
1937
  ```
1932
1938
 
@@ -1953,10 +1959,9 @@ interface BulkDeleteResult {
1953
1959
  **MatchResult** (interface)
1954
1960
  ```typescript
1955
1961
  interface MatchResult {
1956
- records: MatchedRecord[]
1957
- * Only present when strategy is 'best'.
1958
- * The single highest-specificity record per recordType.
1959
- best?: Record<string, MatchedRecord>
1962
+ data: MatchEntry[]
1963
+ total: number
1964
+ strategy: 'all' | 'best'
1960
1965
  }
1961
1966
  ```
1962
1967
 
@@ -1965,14 +1970,18 @@ interface MatchResult {
1965
1970
  interface UpsertRecordInput {
1966
1971
  ref: string
1967
1972
  recordType?: string
1968
- customId?: string
1969
- sourceSystem?: string
1973
+ productId?: string | null
1974
+ variantId?: string | null
1975
+ batchId?: string | null
1976
+ proofId?: string | null
1977
+ customId?: string | null
1978
+ sourceSystem?: string | null
1970
1979
  startsAt?: string | null
1971
1980
  expiresAt?: string | null
1972
1981
  status?: string | null
1973
- scope?: RecordScope
1974
1982
  data?: Record<string, unknown> | null
1975
1983
  metadata?: Record<string, unknown> | null
1984
+ facetRule?: FacetRule | null
1976
1985
  }
1977
1986
  ```
1978
1987
 
@@ -2001,10 +2010,15 @@ interface AppRecord {
2001
2010
  visibility: Visibility
2002
2011
  recordType: string | null
2003
2012
  ref: string | null
2013
+ scopeType: string | null
2014
+ scopeId: string | null
2004
2015
  customId: string | null
2016
+ customIdNormalized: string | null
2005
2017
  sourceSystem: string | null
2006
2018
  status: string | null
2007
2019
  productId: string | null
2020
+ variantId: string | null
2021
+ batchId: string | null
2008
2022
  proofId: string | null
2009
2023
  contactId: string | null
2010
2024
  authorId: string | null
@@ -2016,12 +2030,13 @@ interface AppRecord {
2016
2030
  startsAt: string | null
2017
2031
  expiresAt: string | null
2018
2032
  deletedAt: string | null // admin only
2019
- * Structured scope definition. Empty object means universal.
2020
- * Platform-canonicalized on write (keys sorted, valueKeys deduplicated).
2021
- scope: RecordScope
2022
- * Numeric specificity score computed from scope.
2023
- * Higher = more specific. 0 = universal scope.
2033
+ * Numeric specificity score. Server-computed from anchor IDs and facetRule.
2034
+ * Higher = more specific. 0 = universal (no anchors, no rule).
2024
2035
  specificity: number
2036
+ * Facet rule for rule records (ref starts with "rule:").
2037
+ * null on all other record types. Mutually exclusive with anchor IDs.
2038
+ facetRule: FacetRule | null
2039
+ singletonKey: string | null
2025
2040
  data: Record<string, unknown>
2026
2041
  owner: Record<string, unknown>
2027
2042
  admin: Record<string, unknown> // admin only
@@ -2032,26 +2047,33 @@ interface AppRecord {
2032
2047
  **CreateRecordInput** (interface)
2033
2048
  ```typescript
2034
2049
  interface CreateRecordInput {
2035
- recordType: string
2036
- visibility?: Visibility // default 'owner'
2037
- ref?: string // derived from scope if omitted and scope provided
2038
- status?: string // default 'active'
2039
- productId?: string
2040
- proofId?: string
2050
+ recordType?: string
2051
+ visibility?: Visibility
2052
+ ref?: string
2053
+ status?: string
2054
+ productId?: string | null
2055
+ variantId?: string | null
2056
+ batchId?: string | null
2057
+ proofId?: string | null
2041
2058
  contactId?: string
2042
2059
  authorId?: string
2043
2060
  authorType?: string
2044
2061
  parentType?: string
2045
2062
  parentId?: string
2046
- startsAt?: string // ISO 8601
2047
- expiresAt?: string
2048
- scope?: RecordScope
2049
- customId?: string
2050
- sourceSystem?: string
2063
+ startsAt?: string | null
2064
+ expiresAt?: string | null
2065
+ scopeType?: string | null
2066
+ scopeId?: string | null
2067
+ customId?: string | null
2068
+ sourceSystem?: string | null
2069
+ * Opt-in singleton cardinality. When set, the server upserts rather than
2070
+ * inserting a duplicate. Values: 'collection' | 'product' | 'variant' | 'batch' | 'proof'
2071
+ singletonPer?: string
2051
2072
  data?: Record<string, unknown>
2052
2073
  owner?: Record<string, unknown>
2053
- admin?: Record<string, unknown> // admin only
2074
+ admin?: Record<string, unknown>
2054
2075
  metadata?: Record<string, unknown>
2076
+ facetRule?: FacetRule | null
2055
2077
  }
2056
2078
  ```
2057
2079
 
@@ -2065,12 +2087,90 @@ interface UpdateRecordInput {
2065
2087
  visibility?: Visibility
2066
2088
  ref?: string
2067
2089
  recordType?: string
2068
- startsAt?: string
2069
- expiresAt?: string
2070
- scope?: RecordScope
2071
- customId?: string
2072
- sourceSystem?: string
2090
+ productId?: string | null
2091
+ variantId?: string | null
2092
+ batchId?: string | null
2093
+ proofId?: string | null
2094
+ startsAt?: string | null
2095
+ expiresAt?: string | null
2096
+ scopeType?: string | null
2097
+ scopeId?: string | null
2098
+ customId?: string | null
2099
+ sourceSystem?: string | null
2073
2100
  metadata?: Record<string, unknown>
2101
+ facetRule?: FacetRule | null
2102
+ }
2103
+ ```
2104
+
2105
+ **ResolveAllParams** (interface)
2106
+ ```typescript
2107
+ interface ResolveAllParams {
2108
+ context: {
2109
+ productId?: string
2110
+ variantId?: string
2111
+ batchId?: string
2112
+ proofId?: string
2113
+ * Facet assignments for the product — used for both legacy facet-ref matching
2114
+ * and facetRule evaluation.
2115
+ * e.g. { "brand": "samsung", "type": ["tv", "laptop"] }
2116
+ facets?: Record<string, string | string[]>
2117
+ }
2118
+ recordType?: string
2119
+ tiers?: Array<'proof' | 'batch' | 'variant' | 'product' | 'rule' | 'facet' | 'collection'>
2120
+ limit?: number
2121
+ at?: string
2122
+ includeScheduled?: boolean
2123
+ includeExpired?: boolean
2124
+ }
2125
+ ```
2126
+
2127
+ **ResolveAllResult** (interface)
2128
+ ```typescript
2129
+ interface ResolveAllResult {
2130
+ records: ResolveAllEntry[]
2131
+ total: number
2132
+ context: ResolveAllContext
2133
+ truncated: boolean
2134
+ }
2135
+ ```
2136
+
2137
+ **ResolveAllEntry** (interface)
2138
+ ```typescript
2139
+ interface ResolveAllEntry {
2140
+ record: AppRecord
2141
+ matchedAt: MatchedAt
2142
+ specificity: number
2143
+ matchedRule?: FacetRule
2144
+ matchedClauseCount?: number
2145
+ }
2146
+ ```
2147
+
2148
+ **ResolveAllContext** (interface)
2149
+ ```typescript
2150
+ interface ResolveAllContext {
2151
+ productId?: string
2152
+ variantId?: string
2153
+ batchId?: string
2154
+ proofId?: string
2155
+ facets?: Record<string, string[]>
2156
+ }
2157
+ ```
2158
+
2159
+ **PreviewRuleParams** (interface)
2160
+ ```typescript
2161
+ interface PreviewRuleParams {
2162
+ facetRule: FacetRule
2163
+ recordType?: string
2164
+ limit?: number
2165
+ }
2166
+ ```
2167
+
2168
+ **PreviewRuleResult** (interface)
2169
+ ```typescript
2170
+ interface PreviewRuleResult {
2171
+ matchingProducts: Array<{ productId: string; name?: string; facets: Record<string, string[]> }>
2172
+ total: number
2173
+ rule: FacetRule
2074
2174
  }
2075
2175
  ```
2076
2176
 
@@ -2140,7 +2240,7 @@ interface PublicCreateBranch {
2140
2240
 
2141
2241
  **BulkDeleteInput** = ``
2142
2242
 
2143
- **MatchedAtLevel** = ``
2243
+ **MatchedAt** = ``
2144
2244
 
2145
2245
  ### asset
2146
2246
 
@@ -7306,6 +7406,17 @@ Upsert up to 500 records in a single transaction. Each row is individually error
7306
7406
  input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
7307
7407
  Soft-delete records in bulk. Supports two modes: - **refs mode**: explicit list of refs (max 1000) - **scope mode**: delete by scope anchor (productId / variantId / etc.) POST /records/bulk-delete (admin only) ```ts // Refs mode await app.records.bulkDelete(collectionId, appId, { refs: ['product:prod_abc', 'product:prod_xyz'], recordType: 'nutrition', }); // Scope mode await app.records.bulkDelete(collectionId, appId, { scope: { productId: 'prod_abc' }, }); ```
7308
7408
 
7409
+ **resolveAll**(collectionId: string,
7410
+ appId: string,
7411
+ input: ResolveAllParams,
7412
+ admin: boolean = false) → `Promise<ResolveAllResult>`
7413
+ Resolve every applicable record for a product context in one call. Returns records across all tiers (proof, batch, variant, product, rule, facet, collection) deduplicated and sorted by specificity descending. POST /records/resolve-all
7414
+
7415
+ **previewRule**(collectionId: string,
7416
+ appId: string,
7417
+ input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
7418
+ Preview which products in the collection match a given facetRule. Admin only. Use for live "matches N products" feedback while authoring a rule. POST /records/preview-rule
7419
+
7309
7420
  ### app.threads
7310
7421
 
7311
7422
  Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.