@proveanything/smartlinks 3.0.0-alpha.0 → 3.0.0-alpha.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.
Files changed (149) hide show
  1. package/README.md +7 -7
  2. package/dist/api/analytics.d.ts +5 -4
  3. package/dist/api/analytics.js +5 -4
  4. package/dist/api/appConfiguration.d.ts +23 -18
  5. package/dist/api/appConfiguration.js +24 -18
  6. package/dist/api/appObjects.d.ts +54 -10
  7. package/dist/api/appObjects.js +75 -40
  8. package/dist/api/asset.d.ts +28 -22
  9. package/dist/api/asset.js +45 -56
  10. package/dist/api/attestation.d.ts +11 -3
  11. package/dist/api/attestation.js +12 -3
  12. package/dist/api/attestations.d.ts +12 -8
  13. package/dist/api/attestations.js +18 -21
  14. package/dist/api/authKit.d.ts +15 -10
  15. package/dist/api/authKit.js +17 -11
  16. package/dist/api/batch.d.ts +36 -25
  17. package/dist/api/batch.js +46 -39
  18. package/dist/api/bookings.d.ts +18 -9
  19. package/dist/api/bookings.js +23 -13
  20. package/dist/api/broadcasts.js +3 -17
  21. package/dist/api/claimSet.d.ts +26 -12
  22. package/dist/api/claimSet.js +32 -24
  23. package/dist/api/collection.d.ts +15 -10
  24. package/dist/api/collection.js +17 -11
  25. package/dist/api/comms.d.ts +12 -6
  26. package/dist/api/comms.js +12 -6
  27. package/dist/api/conditions.d.ts +7 -6
  28. package/dist/api/conditions.js +8 -6
  29. package/dist/api/contact.d.ts +6 -2
  30. package/dist/api/contact.js +25 -60
  31. package/dist/api/containers.d.ts +14 -10
  32. package/dist/api/containers.js +19 -14
  33. package/dist/api/crate.js +7 -9
  34. package/dist/api/dpp.d.ts +20 -13
  35. package/dist/api/dpp.js +23 -15
  36. package/dist/api/facets.d.ts +38 -13
  37. package/dist/api/facets.js +40 -15
  38. package/dist/api/files.d.ts +5 -2
  39. package/dist/api/files.js +7 -4
  40. package/dist/api/form.d.ts +8 -5
  41. package/dist/api/form.js +9 -5
  42. package/dist/api/index.d.ts +0 -1
  43. package/dist/api/index.js +0 -1
  44. package/dist/api/integrations.d.ts +29 -17
  45. package/dist/api/integrations.js +32 -25
  46. package/dist/api/interactions.d.ts +11 -6
  47. package/dist/api/interactions.js +14 -23
  48. package/dist/api/jobs.d.ts +16 -6
  49. package/dist/api/jobs.js +30 -20
  50. package/dist/api/journeys.js +2 -14
  51. package/dist/api/journeysAnalytics.d.ts +8 -5
  52. package/dist/api/journeysAnalytics.js +8 -5
  53. package/dist/api/knowledge.d.ts +20 -14
  54. package/dist/api/knowledge.js +22 -15
  55. package/dist/api/location.d.ts +6 -3
  56. package/dist/api/location.js +8 -22
  57. package/dist/api/lots.d.ts +9 -5
  58. package/dist/api/lots.js +22 -26
  59. package/dist/api/loyalty.d.ts +25 -16
  60. package/dist/api/loyalty.js +33 -32
  61. package/dist/api/nfc.d.ts +3 -1
  62. package/dist/api/nfc.js +3 -1
  63. package/dist/api/order.d.ts +45 -39
  64. package/dist/api/order.js +48 -65
  65. package/dist/api/partner.d.ts +17 -14
  66. package/dist/api/partner.js +21 -22
  67. package/dist/api/products.d.ts +35 -12
  68. package/dist/api/products.js +36 -13
  69. package/dist/api/proof.d.ts +41 -19
  70. package/dist/api/proof.js +44 -23
  71. package/dist/api/segments.js +3 -15
  72. package/dist/api/serviceAccounts.d.ts +8 -5
  73. package/dist/api/serviceAccounts.js +9 -6
  74. package/dist/api/shop.d.ts +7 -5
  75. package/dist/api/shop.js +13 -19
  76. package/dist/api/subscriptions.d.ts +12 -10
  77. package/dist/api/subscriptions.js +17 -25
  78. package/dist/api/tags.d.ts +23 -20
  79. package/dist/api/tags.js +40 -52
  80. package/dist/api/template.d.ts +16 -11
  81. package/dist/api/template.js +19 -13
  82. package/dist/api/translations.js +2 -12
  83. package/dist/api/userGroups.d.ts +26 -16
  84. package/dist/api/userGroups.js +43 -30
  85. package/dist/api/variant.d.ts +10 -7
  86. package/dist/api/variant.js +11 -7
  87. package/dist/api/wallet.d.ts +14 -11
  88. package/dist/api/wallet.js +15 -12
  89. package/dist/docs/API_SUMMARY.md +289 -483
  90. package/dist/docs/ai.md +15 -15
  91. package/dist/docs/analytics.md +1 -1
  92. package/dist/docs/app-objects.md +4 -4
  93. package/dist/docs/attestations.md +8 -8
  94. package/dist/docs/contact-search.md +2 -3
  95. package/dist/docs/i18n.md +46 -292
  96. package/dist/docs/knowledge.md +3 -3
  97. package/dist/docs/lists.md +58 -15
  98. package/dist/docs/upgrading-to-3.md +238 -136
  99. package/dist/i18n.d.ts +14 -2
  100. package/dist/i18n.js +23 -6
  101. package/dist/list.d.ts +12 -0
  102. package/dist/list.js +59 -0
  103. package/dist/openapi.yaml +301 -662
  104. package/dist/types/analytics.d.ts +7 -3
  105. package/dist/types/appObjects.d.ts +27 -12
  106. package/dist/types/appOptions.d.ts +2 -2
  107. package/dist/types/asset.d.ts +5 -6
  108. package/dist/types/attestations.d.ts +7 -9
  109. package/dist/types/batch.d.ts +5 -5
  110. package/dist/types/bookings.d.ts +10 -5
  111. package/dist/types/comms.d.ts +9 -5
  112. package/dist/types/contact.d.ts +7 -4
  113. package/dist/types/containers.d.ts +2 -1
  114. package/dist/types/facets.d.ts +14 -2
  115. package/dist/types/files.d.ts +3 -2
  116. package/dist/types/integrations.d.ts +2 -1
  117. package/dist/types/interaction.d.ts +15 -7
  118. package/dist/types/jobs.d.ts +1 -1
  119. package/dist/types/journeysAnalytics.d.ts +3 -2
  120. package/dist/types/knowledge.d.ts +6 -3
  121. package/dist/types/knowledge.js +0 -1
  122. package/dist/types/list.d.ts +30 -2
  123. package/dist/types/location.d.ts +7 -2
  124. package/dist/types/location.js +0 -1
  125. package/dist/types/lots.d.ts +5 -2
  126. package/dist/types/lots.js +0 -6
  127. package/dist/types/order.d.ts +22 -20
  128. package/dist/types/product.d.ts +28 -11
  129. package/dist/types/proof.d.ts +7 -8
  130. package/dist/types/tags.d.ts +5 -3
  131. package/dist/types/userGroups.d.ts +3 -3
  132. package/dist/types/userGroups.js +0 -4
  133. package/dist/version.d.ts +1 -1
  134. package/dist/version.js +1 -1
  135. package/docs/API_SUMMARY.md +289 -483
  136. package/docs/ai.md +15 -15
  137. package/docs/analytics.md +1 -1
  138. package/docs/app-objects.md +4 -4
  139. package/docs/attestations.md +8 -8
  140. package/docs/contact-search.md +2 -3
  141. package/docs/i18n.md +46 -292
  142. package/docs/knowledge.md +3 -3
  143. package/docs/lists.md +58 -15
  144. package/docs/upgrading-to-3.md +238 -136
  145. package/openapi.yaml +301 -662
  146. package/package.json +91 -91
  147. package/scripts/lib/upgrade.mjs +216 -60
  148. package/scripts/upgrade.mjs +33 -10
  149. package/upgrade/3.json +2731 -2213
@@ -1,20 +1,30 @@
1
- import type { ListJobsQuery, Job } from "../types/jobs.js";
1
+ import type { ListJobsQuery, Job, EnqueueAsyncJobRequest, EnqueueAsyncJobResponse } from "../types/jobs.js";
2
2
  import type { ListResult } from "../types/list.js";
3
3
  export declare namespace jobs {
4
4
  /**
5
- * List visible jobs for a collection
5
+ * List visible jobs for a collection, newest first.
6
6
  * GET /admin/collection/:collectionId/jobs
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
- * let page = await jobs.listJobs('coll_123', { state: 'errored', limit: 50 })
11
- * while (page.nextCursor) page = await jobs.listJobs('coll_123', { state: 'errored', limit: 50, cursor: page.nextCursor })
10
+ * let page = await jobs.list('coll_123', { state: 'errored', limit: 50 })
11
+ * while (page.nextCursor) page = await jobs.list('coll_123', { state: 'errored', limit: 50, cursor: page.nextCursor })
12
12
  * ```
13
13
  */
14
- function listJobs(collectionId: string, query?: ListJobsQuery): Promise<ListResult<Job>>;
14
+ function list(collectionId: string, query?: ListJobsQuery): Promise<ListResult<Job>>;
15
15
  /**
16
16
  * Get a single job
17
17
  * GET /admin/collection/:collectionId/jobs/:jobId
18
18
  */
19
- function getJob(collectionId: string, jobId: number): Promise<Job>;
19
+ function get(collectionId: string, jobId: number): Promise<Job>;
20
+ /**
21
+ * Start a background job for a collection.
22
+ * POST /admin/collection/:collectionId/async/jobs (202)
23
+ */
24
+ function enqueue(collectionId: string, params: EnqueueAsyncJobRequest): Promise<EnqueueAsyncJobResponse>;
25
+ /**
26
+ * How a job you started is getting on (may answer 404 once it has finished and been cleared away).
27
+ * GET /admin/collection/:collectionId/async/jobs/:jobId
28
+ */
29
+ function status(collectionId: string, jobId: number): Promise<Job>;
20
30
  }
package/dist/api/jobs.js CHANGED
@@ -1,41 +1,51 @@
1
1
  // src/api/jobs.ts
2
- import { request } from "../http.js";
2
+ // Background jobs: start one, follow it, and list a collection's jobs. One namespace (SDK 2 had two,
3
+ // `jobs` and `async`).
4
+ import { request, post } from "../http.js";
5
+ import { listQuery } from "../list.js";
3
6
  function enc(v) { return encodeURIComponent(v); }
4
- function encodeQuery(params = {}) {
5
- const search = new URLSearchParams();
6
- for (const [key, value] of Object.entries(params)) {
7
- if (value === undefined || value === null || value === '')
8
- continue;
9
- search.set(key, String(value));
10
- }
11
- const qs = search.toString();
12
- return qs ? `?${qs}` : '';
13
- }
14
7
  export var jobs;
15
8
  (function (jobs) {
16
9
  /**
17
- * List visible jobs for a collection
10
+ * List visible jobs for a collection, newest first.
18
11
  * GET /admin/collection/:collectionId/jobs
19
12
  *
20
13
  * @example
21
14
  * ```typescript
22
- * let page = await jobs.listJobs('coll_123', { state: 'errored', limit: 50 })
23
- * while (page.nextCursor) page = await jobs.listJobs('coll_123', { state: 'errored', limit: 50, cursor: page.nextCursor })
15
+ * let page = await jobs.list('coll_123', { state: 'errored', limit: 50 })
16
+ * while (page.nextCursor) page = await jobs.list('coll_123', { state: 'errored', limit: 50, cursor: page.nextCursor })
24
17
  * ```
25
18
  */
26
- async function listJobs(collectionId, query = {}) {
27
- const qs = encodeQuery(query);
28
- const path = `/admin/collection/${enc(collectionId)}/jobs${qs}`;
19
+ async function list(collectionId, query = {}) {
20
+ const path = `/admin/collection/${enc(collectionId)}/jobs${listQuery(query)}`;
29
21
  return request(path);
30
22
  }
31
- jobs.listJobs = listJobs;
23
+ jobs.list = list;
32
24
  /**
33
25
  * Get a single job
34
26
  * GET /admin/collection/:collectionId/jobs/:jobId
35
27
  */
36
- async function getJob(collectionId, jobId) {
28
+ async function get(collectionId, jobId) {
37
29
  const path = `/admin/collection/${enc(collectionId)}/jobs/${jobId}`;
38
30
  return request(path);
39
31
  }
40
- jobs.getJob = getJob;
32
+ jobs.get = get;
33
+ /**
34
+ * Start a background job for a collection.
35
+ * POST /admin/collection/:collectionId/async/jobs (202)
36
+ */
37
+ async function enqueue(collectionId, params) {
38
+ const path = `/admin/collection/${enc(collectionId)}/async/jobs`;
39
+ return post(path, params);
40
+ }
41
+ jobs.enqueue = enqueue;
42
+ /**
43
+ * How a job you started is getting on (may answer 404 once it has finished and been cleared away).
44
+ * GET /admin/collection/:collectionId/async/jobs/:jobId
45
+ */
46
+ async function status(collectionId, jobId) {
47
+ const path = `/admin/collection/${enc(collectionId)}/async/jobs/${jobId}`;
48
+ return request(path);
49
+ }
50
+ jobs.status = status;
41
51
  })(jobs || (jobs = {}));
@@ -1,18 +1,6 @@
1
1
  // src/api/journeys.ts
2
2
  import { request, post, patch, del } from "../http.js";
3
- function encodeQuery(params) {
4
- const search = new URLSearchParams();
5
- for (const [key, value] of Object.entries(params)) {
6
- if (value === undefined || value === null || value === "")
7
- continue;
8
- if (typeof value === "boolean")
9
- search.set(key, value ? "true" : "false");
10
- else
11
- search.set(key, String(value));
12
- }
13
- const qs = search.toString();
14
- return qs ? `?${qs}` : "";
15
- }
3
+ import { listQuery } from "../list.js";
16
4
  export var journeys;
17
5
  (function (journeys) {
18
6
  // Create
@@ -32,7 +20,7 @@ export var journeys;
32
20
  * ```
33
21
  */
34
22
  async function list(collectionId, query = {}) {
35
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${encodeQuery(query)}`;
23
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${listQuery(query)}`;
36
24
  return request(path);
37
25
  }
38
26
  journeys.list = list;
@@ -9,15 +9,18 @@ export declare namespace journeysAnalytics {
9
9
  function stats(collectionId: string, journeyId: string, body?: JourneyStatsRequest): Promise<JourneyStatsResponse>;
10
10
  /**
11
11
  * POST /admin/collection/:collectionId/journeys.analytics/:journeyId/steps/:stepId/recipients
12
- * Returns recipient IDs for a given journey step, as a list of ids. One list, no pages: `limit` in
13
- * the body says how many.
12
+ * Returns recipient IDs for a given journey step, a page at a time (`limit` and `cursor` in the
13
+ * body). The time window is `from` / `to`.
14
14
  * For completed/pending, `interactionId` is required; outcome defaults to 'success'.
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * const { items: contactIds } = await journeysAnalytics.recipients('coll_123', journeyId, stepId, {
19
- * status: 'completed', interactionId, idField: 'contactId', limit: 1000,
20
- * })
18
+ * const query = { status: 'completed' as const, interactionId, idField: 'contactId' as const, limit: 1000 }
19
+ * let page = await journeysAnalytics.recipients('coll_123', journeyId, stepId, query)
20
+ * page.items // contact ids
21
+ * while (page.nextCursor) {
22
+ * page = await journeysAnalytics.recipients('coll_123', journeyId, stepId, { ...query, cursor: page.nextCursor })
23
+ * }
21
24
  * ```
22
25
  */
23
26
  function recipients(collectionId: string, journeyId: string, stepId: string, body?: JourneyStepRecipientsRequest): Promise<ListResult<string>>;
@@ -14,15 +14,18 @@ export var journeysAnalytics;
14
14
  journeysAnalytics.stats = stats;
15
15
  /**
16
16
  * POST /admin/collection/:collectionId/journeys.analytics/:journeyId/steps/:stepId/recipients
17
- * Returns recipient IDs for a given journey step, as a list of ids. One list, no pages: `limit` in
18
- * the body says how many.
17
+ * Returns recipient IDs for a given journey step, a page at a time (`limit` and `cursor` in the
18
+ * body). The time window is `from` / `to`.
19
19
  * For completed/pending, `interactionId` is required; outcome defaults to 'success'.
20
20
  *
21
21
  * @example
22
22
  * ```typescript
23
- * const { items: contactIds } = await journeysAnalytics.recipients('coll_123', journeyId, stepId, {
24
- * status: 'completed', interactionId, idField: 'contactId', limit: 1000,
25
- * })
23
+ * const query = { status: 'completed' as const, interactionId, idField: 'contactId' as const, limit: 1000 }
24
+ * let page = await journeysAnalytics.recipients('coll_123', journeyId, stepId, query)
25
+ * page.items // contact ids
26
+ * while (page.nextCursor) {
27
+ * page = await journeysAnalytics.recipients('coll_123', journeyId, stepId, { ...query, cursor: page.nextCursor })
28
+ * }
26
29
  * ```
27
30
  */
28
31
  async function recipients(collectionId, journeyId, stepId, body = {}) {
@@ -1,5 +1,5 @@
1
1
  import type { KnowledgeSet, SaveKnowledgeSetRequest, UpdateKnowledgeSetRequest, KnowledgeSource, AddKnowledgeSourceRequest, UpdateKnowledgeSourceRequest, KnowledgeDocument, KnowledgeSearchRequest, KnowledgeSearchResponse, KnowledgeSearchResult } from "../types/knowledge.js";
2
- import type { ListResult } from "../types/list.js";
2
+ import type { ListResult, ListOptions } from "../types/list.js";
3
3
  /**
4
4
  * Knowledge search: make a collection's content searchable by meaning and keywords, for people and for AI.
5
5
  *
@@ -20,19 +20,21 @@ import type { ListResult } from "../types/list.js";
20
20
  * await knowledge.upsertDocuments('coll_123', src.id, [
21
21
  * { ref: 'kettle', title: 'Kettle manual', body: '## Descaling\n\nDescale monthly…', meta: { productId: 'p1' } },
22
22
  * ])
23
- * const { items } = await knowledge.publicSearch('coll_123', { query: 'how do I descale', filters: { productId: 'p1' } })
23
+ * const { items } = await knowledge.publicSearch('coll_123', { q: 'how do I descale', filters: { productId: 'p1' } })
24
24
  * ```
25
25
  */
26
26
  export declare namespace knowledge {
27
27
  /**
28
- * Every set, with its source and passage counts (admin). One list, no pages.
28
+ * The collection's sets, with their source and passage counts (admin). A page at a time (`limit` and
29
+ * `cursor`; 50 unless you say otherwise).
29
30
  *
30
31
  * @example
31
32
  * ```typescript
32
- * const { items } = await knowledge.listSets('coll_123')
33
+ * let page = await knowledge.listSets('coll_123')
34
+ * while (page.nextCursor) page = await knowledge.listSets('coll_123', { cursor: page.nextCursor })
33
35
  * ```
34
36
  */
35
- function listSets(collectionId: string): Promise<ListResult<KnowledgeSet>>;
37
+ function listSets(collectionId: string, options?: ListOptions): Promise<ListResult<KnowledgeSet>>;
36
38
  /** Create a set, or update the one with this key (admin). */
37
39
  function saveSet(collectionId: string, body: SaveKnowledgeSetRequest): Promise<KnowledgeSet>;
38
40
  /** One set, by id or key (admin). */
@@ -43,14 +45,16 @@ export declare namespace knowledge {
43
45
  deleted: boolean;
44
46
  }>;
45
47
  /**
46
- * A set's sources, with their status (admin). One list, no pages.
48
+ * A set's sources, with their status (admin). A page at a time (`limit` and `cursor`; 50 unless you
49
+ * say otherwise).
47
50
  *
48
51
  * @example
49
52
  * ```typescript
50
- * const { items } = await knowledge.listSources('coll_123', 'manuals')
53
+ * let page = await knowledge.listSources('coll_123', 'manuals')
54
+ * while (page.nextCursor) page = await knowledge.listSources('coll_123', 'manuals', { cursor: page.nextCursor })
51
55
  * ```
52
56
  */
53
- function listSources(collectionId: string, set: string): Promise<ListResult<KnowledgeSource>>;
57
+ function listSources(collectionId: string, set: string, options?: ListOptions): Promise<ListResult<KnowledgeSource>>;
54
58
  /** Add a source; feeds and pages are read in the background (admin). */
55
59
  function addSource(collectionId: string, set: string, body: AddKnowledgeSourceRequest): Promise<KnowledgeSource>;
56
60
  function updateSource(collectionId: string, sourceId: string, body: UpdateKnowledgeSourceRequest): Promise<KnowledgeSource>;
@@ -73,23 +77,25 @@ export declare namespace knowledge {
73
77
  removed: number;
74
78
  }>;
75
79
  /**
76
- * Search every set, staff ones included (admin). The matches come back as `items`, best first, with the
77
- * `query` and the search `mode` beside them. There are no pages: `k` says how many matches to return.
80
+ * Search every set, staff ones included (admin). `q` is what to look for. The matches come back as
81
+ * `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many matches
82
+ * to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`.
78
83
  *
79
84
  * @example
80
85
  * ```typescript
81
- * const { items, mode } = await knowledge.search('coll_123', { query: 'how do I descale', k: 5 })
86
+ * const { items, mode } = await knowledge.search('coll_123', { q: 'how do I descale', limit: 5 })
82
87
  * ```
83
88
  */
84
89
  function search(collectionId: string, body: KnowledgeSearchRequest): Promise<ListResult<KnowledgeSearchResult> & Pick<KnowledgeSearchResponse, 'query' | 'mode'>>;
85
90
  /**
86
91
  * Search from a website, Portal or Hub: public sets, plus customer sets for a signed-in person. The
87
- * answer has the same shape as the admin `search`: the matches come back as `items`, best first, with the
88
- * `query` and the search `mode` beside them. There are no pages: `k` says how many matches to return.
92
+ * options and the answer are the same as the admin `search`: `q` is what to look for, and the matches come
93
+ * back as `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many
94
+ * matches to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`.
89
95
  *
90
96
  * @example
91
97
  * ```typescript
92
- * const { items } = await knowledge.publicSearch('coll_123', { query: 'how do I descale', k: 5 })
98
+ * const { items } = await knowledge.publicSearch('coll_123', { q: 'how do I descale', limit: 5 })
93
99
  * for (const r of items) console.log(r.title, r.heading, r.url, r.snippet)
94
100
  * ```
95
101
  */
@@ -1,4 +1,5 @@
1
1
  import { request, post, patch, del } from "../http.js";
2
+ import { listQuery } from "../list.js";
2
3
  /**
3
4
  * Knowledge search: make a collection's content searchable by meaning and keywords, for people and for AI.
4
5
  *
@@ -19,7 +20,7 @@ import { request, post, patch, del } from "../http.js";
19
20
  * await knowledge.upsertDocuments('coll_123', src.id, [
20
21
  * { ref: 'kettle', title: 'Kettle manual', body: '## Descaling\n\nDescale monthly…', meta: { productId: 'p1' } },
21
22
  * ])
22
- * const { items } = await knowledge.publicSearch('coll_123', { query: 'how do I descale', filters: { productId: 'p1' } })
23
+ * const { items } = await knowledge.publicSearch('coll_123', { q: 'how do I descale', filters: { productId: 'p1' } })
23
24
  * ```
24
25
  */
25
26
  export var knowledge;
@@ -28,15 +29,17 @@ export var knowledge;
28
29
  const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/knowledge`;
29
30
  const enc = encodeURIComponent;
30
31
  /**
31
- * Every set, with its source and passage counts (admin). One list, no pages.
32
+ * The collection's sets, with their source and passage counts (admin). A page at a time (`limit` and
33
+ * `cursor`; 50 unless you say otherwise).
32
34
  *
33
35
  * @example
34
36
  * ```typescript
35
- * const { items } = await knowledge.listSets('coll_123')
37
+ * let page = await knowledge.listSets('coll_123')
38
+ * while (page.nextCursor) page = await knowledge.listSets('coll_123', { cursor: page.nextCursor })
36
39
  * ```
37
40
  */
38
- async function listSets(collectionId) {
39
- return request(`${adm(collectionId)}/sets`);
41
+ async function listSets(collectionId, options = {}) {
42
+ return request(`${adm(collectionId)}/sets${listQuery(options)}`);
40
43
  }
41
44
  knowledge.listSets = listSets;
42
45
  /** Create a set, or update the one with this key (admin). */
@@ -59,15 +62,17 @@ export var knowledge;
59
62
  }
60
63
  knowledge.deleteSet = deleteSet;
61
64
  /**
62
- * A set's sources, with their status (admin). One list, no pages.
65
+ * A set's sources, with their status (admin). A page at a time (`limit` and `cursor`; 50 unless you
66
+ * say otherwise).
63
67
  *
64
68
  * @example
65
69
  * ```typescript
66
- * const { items } = await knowledge.listSources('coll_123', 'manuals')
70
+ * let page = await knowledge.listSources('coll_123', 'manuals')
71
+ * while (page.nextCursor) page = await knowledge.listSources('coll_123', 'manuals', { cursor: page.nextCursor })
67
72
  * ```
68
73
  */
69
- async function listSources(collectionId, set) {
70
- return request(`${adm(collectionId)}/sets/${enc(set)}/sources`);
74
+ async function listSources(collectionId, set, options = {}) {
75
+ return request(`${adm(collectionId)}/sets/${enc(set)}/sources${listQuery(options)}`);
71
76
  }
72
77
  knowledge.listSources = listSources;
73
78
  /** Add a source; feeds and pages are read in the background (admin). */
@@ -99,12 +104,13 @@ export var knowledge;
99
104
  }
100
105
  knowledge.removeDocuments = removeDocuments;
101
106
  /**
102
- * Search every set, staff ones included (admin). The matches come back as `items`, best first, with the
103
- * `query` and the search `mode` beside them. There are no pages: `k` says how many matches to return.
107
+ * Search every set, staff ones included (admin). `q` is what to look for. The matches come back as
108
+ * `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many matches
109
+ * to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`.
104
110
  *
105
111
  * @example
106
112
  * ```typescript
107
- * const { items, mode } = await knowledge.search('coll_123', { query: 'how do I descale', k: 5 })
113
+ * const { items, mode } = await knowledge.search('coll_123', { q: 'how do I descale', limit: 5 })
108
114
  * ```
109
115
  */
110
116
  async function search(collectionId, body) {
@@ -113,12 +119,13 @@ export var knowledge;
113
119
  knowledge.search = search;
114
120
  /**
115
121
  * Search from a website, Portal or Hub: public sets, plus customer sets for a signed-in person. The
116
- * answer has the same shape as the admin `search`: the matches come back as `items`, best first, with the
117
- * `query` and the search `mode` beside them. There are no pages: `k` says how many matches to return.
122
+ * options and the answer are the same as the admin `search`: `q` is what to look for, and the matches come
123
+ * back as `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many
124
+ * matches to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`.
118
125
  *
119
126
  * @example
120
127
  * ```typescript
121
- * const { items } = await knowledge.publicSearch('coll_123', { query: 'how do I descale', k: 5 })
128
+ * const { items } = await knowledge.publicSearch('coll_123', { q: 'how do I descale', limit: 5 })
122
129
  * for (const r of items) console.log(r.title, r.heading, r.url, r.snippet)
123
130
  * ```
124
131
  */
@@ -12,13 +12,16 @@ export declare namespace location {
12
12
  */
13
13
  function create(collectionId: string, params: LocationPayload): Promise<Location>;
14
14
  /**
15
- * Admin: Search locations to pick during setup (combines collection + global). One list, no pages:
16
- * `limit` says how many (default 20, at most 100).
15
+ * Admin: Search locations to pick during setup (combines collection + global). `q` is the search
16
+ * text. `limit` says how many (default 20, at most 100) and `cursor` is the previous page's
17
+ * `nextCursor`. `orderBy` sorts by one field: `name` (the default), `countryCode` or `countryName`.
17
18
  * GET /admin/collection/:collectionId/location/search
18
19
  *
19
20
  * @example
20
21
  * ```typescript
21
- * const { items } = await location.search('coll_123', { q: 'distillery', countryCode: 'GB', limit: 10 })
22
+ * const { items, nextCursor } = await location.search('coll_123', {
23
+ * q: 'distillery', countryCode: 'GB', limit: 10, orderBy: [{ countryName: 'asc' }],
24
+ * })
22
25
  * ```
23
26
  */
24
27
  function search(collectionId: string, query?: LocationSearchQuery): Promise<ListResult<Location>>;
@@ -1,23 +1,6 @@
1
1
  // src/api/location.ts
2
2
  import { request, post } from "../http.js";
3
- function buildQueryString(q = {}) {
4
- var _a, _b;
5
- const params = new URLSearchParams();
6
- if (q.q)
7
- params.set('q', q.q);
8
- if (q.category)
9
- params.set('category', q.category);
10
- if (q.countryCode)
11
- params.set('countryCode', q.countryCode);
12
- if (q.countryName)
13
- params.set('countryName', q.countryName);
14
- const limit = Math.min(Math.max((_a = q.limit) !== null && _a !== void 0 ? _a : 20, 1), 100);
15
- params.set('limit', String(limit));
16
- const sort = ((_b = q.sort) !== null && _b !== void 0 ? _b : 'name');
17
- params.set('sort', sort);
18
- const s = params.toString();
19
- return s ? `?${s}` : '';
20
- }
3
+ import { listQuery } from "../list.js";
21
4
  export var location;
22
5
  (function (location) {
23
6
  /**
@@ -39,17 +22,20 @@ export var location;
39
22
  }
40
23
  location.create = create;
41
24
  /**
42
- * Admin: Search locations to pick during setup (combines collection + global). One list, no pages:
43
- * `limit` says how many (default 20, at most 100).
25
+ * Admin: Search locations to pick during setup (combines collection + global). `q` is the search
26
+ * text. `limit` says how many (default 20, at most 100) and `cursor` is the previous page's
27
+ * `nextCursor`. `orderBy` sorts by one field: `name` (the default), `countryCode` or `countryName`.
44
28
  * GET /admin/collection/:collectionId/location/search
45
29
  *
46
30
  * @example
47
31
  * ```typescript
48
- * const { items } = await location.search('coll_123', { q: 'distillery', countryCode: 'GB', limit: 10 })
32
+ * const { items, nextCursor } = await location.search('coll_123', {
33
+ * q: 'distillery', countryCode: 'GB', limit: 10, orderBy: [{ countryName: 'asc' }],
34
+ * })
49
35
  * ```
50
36
  */
51
37
  async function search(collectionId, query = {}) {
52
- const qs = buildQueryString(query);
38
+ const qs = listQuery(query);
53
39
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/location/search${qs}`;
54
40
  return request(path);
55
41
  }
@@ -10,12 +10,15 @@ export declare namespace lots {
10
10
  /** Create a lot (resolves its selector into members). */
11
11
  function create(collectionId: string, lot: LotCreateInput): Promise<Lot>;
12
12
  /**
13
- * List lots (summary rows; `payload`/`productIds` omitted). Filter by status, search, or containing
14
- * productId. One list, no pages.
13
+ * List lots (summary rows; `payload`/`productIds` omitted), a page at a time. Filter by `status`, search
14
+ * text (`q`), or containing `productId`; page with `limit` (default 50) and `cursor`.
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * const { items } = await lots.list('coll_123', { status: 'open' })
18
+ * let page = await lots.list('coll_123', { status: 'open', q: 'spring', limit: 50 })
19
+ * while (page.nextCursor) {
20
+ * page = await lots.list('coll_123', { status: 'open', q: 'spring', limit: 50, cursor: page.nextCursor })
21
+ * }
19
22
  * ```
20
23
  */
21
24
  function list(collectionId: string, params?: ListLotsParams): Promise<ListResult<Lot>>;
@@ -55,11 +58,12 @@ export declare namespace lots {
55
58
  */
56
59
  function listProducts(collectionId: string, lotId: string, opts?: ListOptions): Promise<ListResult<LotProductSummary>>;
57
60
  /**
58
- * List lots from a public context (summary rows). One list, no pages.
61
+ * List lots from a public context (summary rows), a page at a time. Filter by `status`, search text
62
+ * (`q`), or containing `productId`; page with `limit` (default 50) and `cursor`.
59
63
  *
60
64
  * @example
61
65
  * ```typescript
62
- * const { items } = await lots.publicList('coll_123', { productId: 'prod_789' })
66
+ * const { items, nextCursor } = await lots.publicList('coll_123', { productId: 'prod_789', limit: 50 })
63
67
  * ```
64
68
  */
65
69
  function publicList(collectionId: string, params?: Omit<ListLotsParams, 'includeDeleted'>): Promise<ListResult<Lot>>;
package/dist/api/lots.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/api/lots.ts
2
2
  import { request, post, put, del } from "../http.js";
3
+ import { listQuery } from "../list.js";
3
4
  /**
4
5
  * Lots — collection-scoped production groupings that span one or more products.
5
6
  * Writes and admin reads hit `/admin/collection/:cid/lots`; the `public*` reads hit
@@ -14,27 +15,18 @@ export var lots;
14
15
  function publicBase(collectionId) {
15
16
  return `/public/collection/${encodeURIComponent(collectionId)}/lots`;
16
17
  }
17
- function listQuery(params = {}) {
18
- const qs = new URLSearchParams();
19
- if (params.status)
20
- qs.append('status', params.status);
21
- if (params.search)
22
- qs.append('search', params.search);
23
- if (params.productId)
24
- qs.append('productId', params.productId);
25
- if (params.includeDeleted)
26
- qs.append('includeDeleted', 'true');
27
- const s = qs.toString();
28
- return s ? `?${s}` : '';
18
+ function lotsQuery(params = {}) {
19
+ return listQuery({
20
+ status: params.status,
21
+ q: params.q,
22
+ productId: params.productId,
23
+ includeDeleted: params.includeDeleted ? 'true' : undefined,
24
+ limit: params.limit,
25
+ cursor: params.cursor,
26
+ });
29
27
  }
30
28
  function pageQuery(opts = {}) {
31
- const qs = new URLSearchParams();
32
- if (opts.limit)
33
- qs.append('limit', String(opts.limit));
34
- if (opts.cursor)
35
- qs.append('cursor', opts.cursor);
36
- const s = qs.toString();
37
- return s ? `?${s}` : '';
29
+ return listQuery({ limit: opts.limit || undefined, cursor: opts.cursor });
38
30
  }
39
31
  // ── Admin (writes + admin reads) ──
40
32
  /** Create a lot (resolves its selector into members). */
@@ -43,16 +35,19 @@ export var lots;
43
35
  }
44
36
  lots.create = create;
45
37
  /**
46
- * List lots (summary rows; `payload`/`productIds` omitted). Filter by status, search, or containing
47
- * productId. One list, no pages.
38
+ * List lots (summary rows; `payload`/`productIds` omitted), a page at a time. Filter by `status`, search
39
+ * text (`q`), or containing `productId`; page with `limit` (default 50) and `cursor`.
48
40
  *
49
41
  * @example
50
42
  * ```typescript
51
- * const { items } = await lots.list('coll_123', { status: 'open' })
43
+ * let page = await lots.list('coll_123', { status: 'open', q: 'spring', limit: 50 })
44
+ * while (page.nextCursor) {
45
+ * page = await lots.list('coll_123', { status: 'open', q: 'spring', limit: 50, cursor: page.nextCursor })
46
+ * }
52
47
  * ```
53
48
  */
54
49
  async function list(collectionId, params = {}) {
55
- return request(`${adminBase(collectionId)}${listQuery(params)}`);
50
+ return request(`${adminBase(collectionId)}${lotsQuery(params)}`);
56
51
  }
57
52
  lots.list = list;
58
53
  /** Get the full lot record. Pass `{ includeDeleted: true }` to fetch a soft-deleted one. */
@@ -110,15 +105,16 @@ export var lots;
110
105
  lots.listProducts = listProducts;
111
106
  // ── Public (cross-app reads) ──
112
107
  /**
113
- * List lots from a public context (summary rows). One list, no pages.
108
+ * List lots from a public context (summary rows), a page at a time. Filter by `status`, search text
109
+ * (`q`), or containing `productId`; page with `limit` (default 50) and `cursor`.
114
110
  *
115
111
  * @example
116
112
  * ```typescript
117
- * const { items } = await lots.publicList('coll_123', { productId: 'prod_789' })
113
+ * const { items, nextCursor } = await lots.publicList('coll_123', { productId: 'prod_789', limit: 50 })
118
114
  * ```
119
115
  */
120
116
  async function publicList(collectionId, params = {}) {
121
- return request(`${publicBase(collectionId)}${listQuery(params)}`);
117
+ return request(`${publicBase(collectionId)}${lotsQuery(params)}`);
122
118
  }
123
119
  lots.publicList = publicList;
124
120
  async function publicGet(collectionId, lotId) {