@proveanything/smartlinks 1.6.7 → 1.7.1

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 (41) hide show
  1. package/dist/api/attestation.d.ts +22 -0
  2. package/dist/api/attestation.js +22 -0
  3. package/dist/api/attestations.d.ts +292 -0
  4. package/dist/api/attestations.js +405 -0
  5. package/dist/api/containers.d.ts +236 -0
  6. package/dist/api/containers.js +316 -0
  7. package/dist/api/index.d.ts +2 -0
  8. package/dist/api/index.js +2 -0
  9. package/dist/api/tags.d.ts +20 -1
  10. package/dist/api/tags.js +30 -0
  11. package/dist/docs/API_SUMMARY.md +711 -9
  12. package/dist/docs/app-manifest.md +430 -0
  13. package/dist/docs/attestations.md +498 -0
  14. package/dist/docs/container-tracking.md +437 -0
  15. package/dist/docs/deep-link-discovery.md +6 -6
  16. package/dist/docs/executor.md +554 -0
  17. package/dist/docs/interactions.md +291 -0
  18. package/dist/docs/manifests.md +200 -0
  19. package/dist/docs/mpa.md +135 -0
  20. package/dist/docs/overview.md +372 -0
  21. package/dist/index.d.ts +3 -0
  22. package/dist/openapi.yaml +3110 -1323
  23. package/dist/types/appManifest.d.ts +159 -2
  24. package/dist/types/attestation.d.ts +12 -0
  25. package/dist/types/attestations.d.ts +237 -0
  26. package/dist/types/attestations.js +11 -0
  27. package/dist/types/containers.d.ts +186 -0
  28. package/dist/types/containers.js +10 -0
  29. package/dist/types/tags.d.ts +47 -3
  30. package/docs/API_SUMMARY.md +711 -9
  31. package/docs/app-manifest.md +430 -0
  32. package/docs/attestations.md +498 -0
  33. package/docs/container-tracking.md +437 -0
  34. package/docs/deep-link-discovery.md +6 -6
  35. package/docs/executor.md +554 -0
  36. package/docs/interactions.md +291 -0
  37. package/docs/manifests.md +200 -0
  38. package/docs/mpa.md +135 -0
  39. package/docs/overview.md +372 -0
  40. package/openapi.yaml +3110 -1323
  41. package/package.json +1 -1
@@ -1,23 +1,45 @@
1
1
  import type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRequest } from "../types/attestation";
2
+ /**
3
+ * @deprecated Legacy Firestore-backed attestation API.
4
+ *
5
+ * These endpoints store attestation data against a specific proof in Firestore
6
+ * (`/product/:productId/proof/:proofId/attestations`). They remain active for
7
+ * backward-compatibility but **should not be used in new integrations**.
8
+ *
9
+ * Use the new `attestations` namespace instead, which provides:
10
+ * - Polymorphic subjects (container, proof, product, tag, …)
11
+ * - Three data-visibility zones (public / owner / admin)
12
+ * - Cryptographic hash-chain integrity
13
+ * - Time-series summary and tree-rollup queries
14
+ *
15
+ * @see {@link attestations} for the replacement API
16
+ */
2
17
  export declare namespace attestation {
3
18
  /**
4
19
  * List all attestations for a proof.
20
+ * @deprecated Use `attestations.list()` with `subjectType='proof'` instead.
5
21
  */
6
22
  function list(collectionId: string, productId: string, proofId: string): Promise<AttestationResponse[]>;
7
23
  /**
8
24
  * Get a single attestation by ID.
25
+ * @deprecated Use `attestations.list()` with `subjectType='proof'` and filter by ID instead.
9
26
  */
10
27
  function get(collectionId: string, productId: string, proofId: string, attestationId: string): Promise<AttestationResponse>;
11
28
  /**
12
29
  * Create a new attestation for a proof.
30
+ * @deprecated Use `attestations.create()` with `subjectType='proof'` instead.
13
31
  */
14
32
  function create(collectionId: string, productId: string, proofId: string, data: AttestationCreateRequest): Promise<AttestationResponse>;
15
33
  /**
16
34
  * Update an attestation.
35
+ * @deprecated The new attestation system is append-only. Append a corrective record
36
+ * via `attestations.create()` with a note in `metadata` instead.
17
37
  */
18
38
  function update(collectionId: string, productId: string, proofId: string, attestationId: string, data: AttestationUpdateRequest): Promise<AttestationResponse>;
19
39
  /**
20
40
  * Delete an attestation.
41
+ * @deprecated The new attestation system is append-only; deletions are not supported.
42
+ * Use `attestations.create()` to append a corrective/superseding record instead.
21
43
  */
22
44
  function remove(collectionId: string, productId: string, proofId: string, attestationId: string): Promise<void>;
23
45
  }
@@ -1,8 +1,24 @@
1
1
  import { request, post, put, del } from "../http";
2
+ /**
3
+ * @deprecated Legacy Firestore-backed attestation API.
4
+ *
5
+ * These endpoints store attestation data against a specific proof in Firestore
6
+ * (`/product/:productId/proof/:proofId/attestations`). They remain active for
7
+ * backward-compatibility but **should not be used in new integrations**.
8
+ *
9
+ * Use the new `attestations` namespace instead, which provides:
10
+ * - Polymorphic subjects (container, proof, product, tag, …)
11
+ * - Three data-visibility zones (public / owner / admin)
12
+ * - Cryptographic hash-chain integrity
13
+ * - Time-series summary and tree-rollup queries
14
+ *
15
+ * @see {@link attestations} for the replacement API
16
+ */
2
17
  export var attestation;
3
18
  (function (attestation) {
4
19
  /**
5
20
  * List all attestations for a proof.
21
+ * @deprecated Use `attestations.list()` with `subjectType='proof'` instead.
6
22
  */
7
23
  async function list(collectionId, productId, proofId) {
8
24
  const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation`;
@@ -11,6 +27,7 @@ export var attestation;
11
27
  attestation.list = list;
12
28
  /**
13
29
  * Get a single attestation by ID.
30
+ * @deprecated Use `attestations.list()` with `subjectType='proof'` and filter by ID instead.
14
31
  */
15
32
  async function get(collectionId, productId, proofId, attestationId) {
16
33
  const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`;
@@ -19,6 +36,7 @@ export var attestation;
19
36
  attestation.get = get;
20
37
  /**
21
38
  * Create a new attestation for a proof.
39
+ * @deprecated Use `attestations.create()` with `subjectType='proof'` instead.
22
40
  */
23
41
  async function create(collectionId, productId, proofId, data) {
24
42
  const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation`;
@@ -27,6 +45,8 @@ export var attestation;
27
45
  attestation.create = create;
28
46
  /**
29
47
  * Update an attestation.
48
+ * @deprecated The new attestation system is append-only. Append a corrective record
49
+ * via `attestations.create()` with a note in `metadata` instead.
30
50
  */
31
51
  async function update(collectionId, productId, proofId, attestationId, data) {
32
52
  const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`;
@@ -35,6 +55,8 @@ export var attestation;
35
55
  attestation.update = update;
36
56
  /**
37
57
  * Delete an attestation.
58
+ * @deprecated The new attestation system is append-only; deletions are not supported.
59
+ * Use `attestations.create()` to append a corrective/superseding record instead.
38
60
  */
39
61
  async function remove(collectionId, productId, proofId, attestationId) {
40
62
  const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`;
@@ -0,0 +1,292 @@
1
+ import type { Attestation, CreateAttestationInput, ListAttestationsParams, ListAttestationsResponse, AttestationSummaryParams, AttestationSummaryResponse, PublicAttestationSummaryResponse, AttestationLatestParams, AttestationLatestResponse, PublicAttestationLatestResponse, AttestationVerifyParams, ChainVerifyResult, AttestationTreeSummaryParams, AttestationTreeSummaryResponse, PublicAttestationTreeSummaryResponse, AttestationTreeLatestParams, AttestationTreeLatestResponse, PublicAttestationTreeLatestResponse, PublicListAttestationsResponse } from "../types/attestations";
2
+ /**
3
+ * Postgres-backed Attestations API (v2).
4
+ *
5
+ * Attestations are an **append-only, tamper-evident fact log** that can be
6
+ * attached to any subject type in the system (`container`, `proof`, `product`,
7
+ * `tag`, etc.). Each record carries a SHA-256 `contentHash` that chains to
8
+ * the previous record for the same `(subjectType, subjectId, attestationType)`
9
+ * tuple, enabling cryptographic integrity verification.
10
+ *
11
+ * ### Admin vs Public
12
+ * - **Admin** endpoints (`/admin/collection/:id/attestations`) require a valid
13
+ * admin session or bearer token. All three data zones are returned.
14
+ * - **Public** endpoints (`/public/collection/:id/attestations`) are read-only.
15
+ * Owner elevation is available via `Authorization: Bearer <Firebase ID token>`.
16
+ *
17
+ * @see docs/attestations.md
18
+ */
19
+ export declare namespace attestations {
20
+ /**
21
+ * Create a single attestation (admin).
22
+ *
23
+ * @param collectionId - Collection context
24
+ * @param data - Attestation payload; `subjectType`, `subjectId`, and
25
+ * `attestationType` are required
26
+ * @returns The newly created `Attestation` record
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const a = await attestations.create('coll_123', {
31
+ * subjectType: 'container',
32
+ * subjectId: 'uuid-of-cask',
33
+ * attestationType: 'temperature',
34
+ * recordedAt: '2025-04-15T14:30:00Z',
35
+ * value: { celsius: 12.4 },
36
+ * ownerData: { sensorId: 'TEMP-7' },
37
+ * unit: '°C',
38
+ * visibility: 'public',
39
+ * })
40
+ * ```
41
+ */
42
+ function create(collectionId: string, data: CreateAttestationInput): Promise<Attestation>;
43
+ /**
44
+ * Batch-create attestations (admin).
45
+ *
46
+ * Sends an array of `CreateAttestationInput` objects in a single request.
47
+ * The server processes them atomically and returns the created records.
48
+ *
49
+ * @param collectionId - Collection context
50
+ * @param items - Array of attestation payloads (1–1000 items recommended)
51
+ * @returns Array of created `Attestation` records, in the same order
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const records = await attestations.createBatch('coll_123', [
56
+ * { subjectType: 'container', subjectId: 'uuid1', attestationType: 'temperature', value: { celsius: 12.4 } },
57
+ * { subjectType: 'container', subjectId: 'uuid1', attestationType: 'humidity', value: { rh: 68 } },
58
+ * ])
59
+ * ```
60
+ */
61
+ function createBatch(collectionId: string, items: CreateAttestationInput[]): Promise<Attestation[]>;
62
+ /**
63
+ * List attestations for a subject (admin).
64
+ *
65
+ * Returns all three data zones. Supports filtering by type and date range.
66
+ *
67
+ * @param collectionId - Collection context
68
+ * @param params - Query parameters; `subjectType` and `subjectId` are required
69
+ * @returns `{ attestations: Attestation[] }`
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const { attestations: records } = await attestations.list('coll_123', {
74
+ * subjectType: 'container',
75
+ * subjectId: 'uuid-of-cask',
76
+ * attestationType: 'temperature',
77
+ * recordedAfter: '2025-01-01T00:00:00Z',
78
+ * limit: 50,
79
+ * })
80
+ * ```
81
+ */
82
+ function list(collectionId: string, params: ListAttestationsParams): Promise<ListAttestationsResponse>;
83
+ /**
84
+ * Time-series summary of attestations (admin).
85
+ *
86
+ * Aggregates attestation counts (and optionally a numeric `value` field) into
87
+ * time buckets. Useful for charting trends.
88
+ *
89
+ * @param collectionId - Collection context
90
+ * @param params - Query parameters; `subjectType`, `subjectId`, and
91
+ * `attestationType` are required
92
+ * @returns `{ summary: AttestationSummaryBucket[] }`
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const { summary } = await attestations.summary('coll_123', {
97
+ * subjectType: 'container',
98
+ * subjectId: 'uuid-of-cask',
99
+ * attestationType: 'temperature',
100
+ * valueField: 'celsius',
101
+ * groupBy: 'day',
102
+ * recordedAfter: '2025-01-01T00:00:00Z',
103
+ * })
104
+ * ```
105
+ */
106
+ function summary(collectionId: string, params: AttestationSummaryParams): Promise<AttestationSummaryResponse>;
107
+ /**
108
+ * Latest snapshot — one record per `attestationType` (admin).
109
+ *
110
+ * Returns the most-recent attestation for each type recorded against this
111
+ * subject. Ideal for dashboards that show the current state of a container.
112
+ *
113
+ * @param collectionId - Collection context
114
+ * @param params - Query parameters; `subjectType` and `subjectId` are required
115
+ * @returns `{ latest: LatestAttestation[] }`
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const { latest } = await attestations.latest('coll_123', {
120
+ * subjectType: 'container',
121
+ * subjectId: 'uuid-of-fridge',
122
+ * })
123
+ * // latest[0].attestationType === 'temperature'
124
+ * // latest[0].latest.value === { celsius: 4.1 }
125
+ * ```
126
+ */
127
+ function latest(collectionId: string, params: AttestationLatestParams): Promise<AttestationLatestResponse>;
128
+ /**
129
+ * Verify the hash chain for a `(subjectType, subjectId, attestationType)` tuple (admin).
130
+ *
131
+ * Re-computes each `contentHash` and confirms it matches the stored value
132
+ * and correctly references the previous record's hash. A `valid: false`
133
+ * result with `failedAt` indicates the first broken link.
134
+ *
135
+ * @param collectionId - Collection context
136
+ * @param params - Query parameters; all three fields are required
137
+ * @returns `ChainVerifyResult`
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * const result = await attestations.verify('coll_123', {
142
+ * subjectType: 'container',
143
+ * subjectId: 'uuid-of-cask',
144
+ * attestationType: 'temperature',
145
+ * })
146
+ * if (!result.valid) {
147
+ * console.warn('Chain broken at', result.failedAt)
148
+ * }
149
+ * ```
150
+ */
151
+ function verify(collectionId: string, params: AttestationVerifyParams): Promise<ChainVerifyResult>;
152
+ /**
153
+ * Tree time-series summary — aggregates across an entire container subtree (admin).
154
+ *
155
+ * Performs a BFS traversal of the container hierarchy rooted at `subjectId`,
156
+ * collects all descendant container IDs (and optionally their items), then
157
+ * aggregates attestations across all of them.
158
+ *
159
+ * @param collectionId - Collection context
160
+ * @param params - `subjectId` and `attestationType` are required;
161
+ * `subjectType` is implicitly `'container'`
162
+ * @returns `{ summary: AttestationSummaryBucket[], subjectCount: number }`
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const { summary, subjectCount } = await attestations.treeSummary('coll_123', {
167
+ * subjectId: 'root-warehouse-uuid',
168
+ * attestationType: 'temperature',
169
+ * valueField: 'celsius',
170
+ * groupBy: 'hour',
171
+ * includeItems: true,
172
+ * })
173
+ * console.log(`Aggregated over ${subjectCount} subjects`)
174
+ * ```
175
+ */
176
+ function treeSummary(collectionId: string, params: AttestationTreeSummaryParams): Promise<AttestationTreeSummaryResponse>;
177
+ /**
178
+ * Tree latest snapshot — most-recent record per type across a container subtree (admin).
179
+ *
180
+ * Same BFS traversal as `treeSummary`, but returns the most-recent record
181
+ * per `attestationType` aggregated across the entire subtree.
182
+ *
183
+ * @param collectionId - Collection context
184
+ * @param params - `subjectId` is required; `subjectType` is implicitly `'container'`
185
+ * @returns `{ latest: LatestAttestation[], subjectCount: number }`
186
+ */
187
+ function treeLatest(collectionId: string, params: AttestationTreeLatestParams): Promise<AttestationTreeLatestResponse>;
188
+ /**
189
+ * List attestations for a subject (public).
190
+ *
191
+ * Records with `visibility='admin'` are always excluded.
192
+ * Records with `visibility='owner'` are included only when the caller
193
+ * provides a valid Firebase ID token that resolves to the subject owner.
194
+ *
195
+ * The `audience` field in the response indicates the tier that was served.
196
+ *
197
+ * @param collectionId - Collection context
198
+ * @param params - Query parameters; `subjectType` and `subjectId` are required
199
+ * @returns `{ attestations: Attestation[], audience: AttestationAudience }`
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const { attestations: records, audience } = await attestations.publicList('coll_123', {
204
+ * subjectType: 'proof',
205
+ * subjectId: 'proof-uuid',
206
+ * })
207
+ * ```
208
+ */
209
+ function publicList(collectionId: string, params: ListAttestationsParams): Promise<PublicListAttestationsResponse>;
210
+ /**
211
+ * Time-series summary (public).
212
+ *
213
+ * Always served at `audience='public'`. Same parameters as the admin version.
214
+ *
215
+ * @param collectionId - Collection context
216
+ * @param params - Query parameters; `subjectType`, `subjectId`, and
217
+ * `attestationType` are required
218
+ * @returns `{ summary: AttestationSummaryBucket[], audience: 'public' }`
219
+ */
220
+ function publicSummary(collectionId: string, params: AttestationSummaryParams): Promise<PublicAttestationSummaryResponse>;
221
+ /**
222
+ * Latest snapshot per `attestationType` (public).
223
+ *
224
+ * Owner elevation applies — provide a Firebase ID token for owner-tier data.
225
+ *
226
+ * @param collectionId - Collection context
227
+ * @param params - `subjectType` and `subjectId` are required
228
+ * @returns `{ latest: LatestAttestation[], audience: AttestationAudience }`
229
+ */
230
+ function publicLatest(collectionId: string, params: AttestationLatestParams): Promise<PublicAttestationLatestResponse>;
231
+ /**
232
+ * Tree time-series summary (public).
233
+ *
234
+ * Always served at `audience='public'`. Performs the same BFS traversal as
235
+ * the admin version but only includes publicly visible attestations.
236
+ *
237
+ * @param collectionId - Collection context
238
+ * @param params - `subjectId` and `attestationType` are required
239
+ * @returns `{ summary: AttestationSummaryBucket[], audience: 'public', subjectCount: number }`
240
+ */
241
+ function publicTreeSummary(collectionId: string, params: AttestationTreeSummaryParams): Promise<PublicAttestationTreeSummaryResponse>;
242
+ /**
243
+ * Tree latest snapshot (public).
244
+ *
245
+ * @param collectionId - Collection context
246
+ * @param params - `subjectId` is required
247
+ * @returns `{ latest: LatestAttestation[], audience: 'public', subjectCount: number }`
248
+ */
249
+ function publicTreeLatest(collectionId: string, params: AttestationTreeLatestParams): Promise<PublicAttestationTreeLatestResponse>;
250
+ /**
251
+ * List attestations for a specific container (public shortcut).
252
+ *
253
+ * Equivalent to `publicList` with `subjectType='container'` and
254
+ * `subjectId=containerId` pre-filled.
255
+ *
256
+ * @param collectionId - Collection context
257
+ * @param containerId - Container UUID
258
+ * @param params - Optional filters (attestationType, date range, pagination)
259
+ */
260
+ function publicContainerList(collectionId: string, containerId: string, params?: Omit<ListAttestationsParams, 'subjectType' | 'subjectId'>): Promise<PublicListAttestationsResponse>;
261
+ /**
262
+ * Time-series summary for a specific container (public shortcut).
263
+ *
264
+ * @param collectionId - Collection context
265
+ * @param containerId - Container UUID
266
+ * @param params - `attestationType` is required
267
+ */
268
+ function publicContainerSummary(collectionId: string, containerId: string, params: Omit<AttestationSummaryParams, 'subjectType' | 'subjectId'>): Promise<PublicAttestationSummaryResponse>;
269
+ /**
270
+ * Latest snapshot for a specific container (public shortcut).
271
+ *
272
+ * @param collectionId - Collection context
273
+ * @param containerId - Container UUID
274
+ */
275
+ function publicContainerLatest(collectionId: string, containerId: string): Promise<PublicAttestationLatestResponse>;
276
+ /**
277
+ * Tree time-series summary rooted at a specific container (public shortcut).
278
+ *
279
+ * @param collectionId - Collection context
280
+ * @param containerId - Root container UUID
281
+ * @param params - `attestationType` is required
282
+ */
283
+ function publicContainerTreeSummary(collectionId: string, containerId: string, params: Omit<AttestationTreeSummaryParams, 'subjectId'>): Promise<PublicAttestationTreeSummaryResponse>;
284
+ /**
285
+ * Tree latest snapshot rooted at a specific container (public shortcut).
286
+ *
287
+ * @param collectionId - Collection context
288
+ * @param containerId - Root container UUID
289
+ * @param params - Optional `includeItems` flag
290
+ */
291
+ function publicContainerTreeLatest(collectionId: string, containerId: string, params?: Pick<AttestationTreeLatestParams, 'includeItems'>): Promise<PublicAttestationTreeLatestResponse>;
292
+ }