@proveanything/smartlinks 2.1.20 → 2.1.23
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/adminCardsView.d.ts +1 -1
- package/dist/adminCardsView.js +70 -55
- package/dist/api/appObjects.d.ts +26 -0
- package/dist/api/appObjects.js +31 -1
- package/dist/api/conditions.d.ts +51 -0
- package/dist/api/conditions.js +57 -0
- package/dist/api/contact.d.ts +83 -1
- package/dist/api/contact.js +104 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/products.d.ts +22 -0
- package/dist/api/products.js +29 -0
- package/dist/api/proof.d.ts +30 -0
- package/dist/api/proof.js +37 -0
- package/dist/api/realtime.d.ts +19 -0
- package/dist/api/realtime.js +26 -1
- package/dist/docs/API_SUMMARY.md +396 -170
- package/dist/docs/admin-cards.md +1 -1
- package/dist/docs/app-manifest.md +19 -0
- package/dist/docs/assistant-apps.md +4 -0
- package/dist/docs/assistant-context.md +119 -0
- package/dist/docs/realtime.md +20 -0
- package/dist/docs/standard-query.md +187 -0
- package/dist/docs/utils.md +22 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +0 -1
- package/dist/openapi.yaml +675 -0
- package/dist/types/adminCards.d.ts +2 -1
- package/dist/types/appManifest.d.ts +64 -1
- package/dist/types/contact.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/query.d.ts +121 -0
- package/dist/types/query.js +5 -0
- package/dist/types/realtime.d.ts +7 -1
- package/dist/utils/conditions.d.ts +1 -1
- package/dist/utils/conditions.js +21 -6
- package/docs/API_SUMMARY.md +396 -170
- package/docs/admin-cards.md +1 -1
- package/docs/app-manifest.md +19 -0
- package/docs/assistant-apps.md +4 -0
- package/docs/assistant-context.md +119 -0
- package/docs/realtime.md +20 -0
- package/docs/standard-query.md +187 -0
- package/docs/utils.md +22 -8
- package/openapi.yaml +675 -0
- package/package.json +1 -1
package/dist/api/products.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
1
2
|
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryRequest, ProductQueryResponse, ProductResponse, ProductUpdateRequest } from "../types/product.js";
|
|
2
3
|
export declare namespace products {
|
|
3
4
|
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
@@ -25,6 +26,27 @@ export declare namespace products {
|
|
|
25
26
|
* ```
|
|
26
27
|
*/
|
|
27
28
|
function query(collectionId: string, body: ProductQueryRequest, admin?: boolean): Promise<ProductQueryResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* The standard query on products (admin only): the one query shape every resource is moving to, with
|
|
31
|
+
* counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged.
|
|
32
|
+
* POST /admin/collection/:collectionId/products/standard/query
|
|
33
|
+
*
|
|
34
|
+
* Fields: id, name, description, sku, gtin, schemaType, status, sortOrder, createdAt, updatedAt,
|
|
35
|
+
* facets. Facets are filtered by key: the facet by its key or name, the value by its key or name.
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* await products.standardQuery(collectionId, {
|
|
39
|
+
* where: { facets: { brand: 'Breville', category: { in: ['Toasters', 'Kettles'] } }, status: 'active' },
|
|
40
|
+
* select: ['id', 'name', 'sku'], count: true,
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function standardQuery(collectionId: string, body?: StandardQuery): Promise<QueryResult>;
|
|
45
|
+
/**
|
|
46
|
+
* What a products standard query can use: its fields and what each can filter, sort, group or total.
|
|
47
|
+
* GET /admin/collection/:collectionId/products/standard/query
|
|
48
|
+
*/
|
|
49
|
+
function standardQueryFields(collectionId: string): Promise<QueryDescription>;
|
|
28
50
|
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
29
51
|
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<unknown>;
|
|
30
52
|
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
package/dist/api/products.js
CHANGED
|
@@ -53,6 +53,35 @@ export var products;
|
|
|
53
53
|
return post(path, body);
|
|
54
54
|
}
|
|
55
55
|
products.query = query;
|
|
56
|
+
/**
|
|
57
|
+
* The standard query on products (admin only): the one query shape every resource is moving to, with
|
|
58
|
+
* counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged.
|
|
59
|
+
* POST /admin/collection/:collectionId/products/standard/query
|
|
60
|
+
*
|
|
61
|
+
* Fields: id, name, description, sku, gtin, schemaType, status, sortOrder, createdAt, updatedAt,
|
|
62
|
+
* facets. Facets are filtered by key: the facet by its key or name, the value by its key or name.
|
|
63
|
+
*
|
|
64
|
+
* ```typescript
|
|
65
|
+
* await products.standardQuery(collectionId, {
|
|
66
|
+
* where: { facets: { brand: 'Breville', category: { in: ['Toasters', 'Kettles'] } }, status: 'active' },
|
|
67
|
+
* select: ['id', 'name', 'sku'], count: true,
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
async function standardQuery(collectionId, body = {}) {
|
|
72
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/standard/query`;
|
|
73
|
+
return post(path, body);
|
|
74
|
+
}
|
|
75
|
+
products.standardQuery = standardQuery;
|
|
76
|
+
/**
|
|
77
|
+
* What a products standard query can use: its fields and what each can filter, sort, group or total.
|
|
78
|
+
* GET /admin/collection/:collectionId/products/standard/query
|
|
79
|
+
*/
|
|
80
|
+
async function standardQueryFields(collectionId) {
|
|
81
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/standard/query`;
|
|
82
|
+
return request(path);
|
|
83
|
+
}
|
|
84
|
+
products.standardQueryFields = standardQueryFields;
|
|
56
85
|
async function clone(collectionId, productId, body = {}) {
|
|
57
86
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/clone`;
|
|
58
87
|
return post(path, body);
|
package/dist/api/proof.d.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { ProofResponse, ProofCreateRequest, ProofUpdateRequest, ProofValuesUpdateRequest, ProofClaimRequest, ProofGrant, CreateGrantOptions, RedeemGrantOptions, RedeemGrantResult, ProofTransfer, TransferProofOptions, TransferProofResult, AcceptTransferOptions, CancelTransferOptions } from "../types/proof.js";
|
|
2
|
+
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
2
3
|
export declare namespace proof {
|
|
4
|
+
/**
|
|
5
|
+
* The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs
|
|
6
|
+
* in one call, and follow a proof to its `product` and its `owner` (the owner's contact).
|
|
7
|
+
* POST /admin/collection/:collectionId/proof/query
|
|
8
|
+
*
|
|
9
|
+
* Fields: id, productId, userId (the owner's login id), batchId, variantId, lotId, status, claimable,
|
|
10
|
+
* createdAt, updatedAt. A proof's own values are not returned by this call.
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // How many people own each product
|
|
14
|
+
* await proof.query(collectionId, {
|
|
15
|
+
* where: { userId: { isNull: false } },
|
|
16
|
+
* groupBy: ['productId'],
|
|
17
|
+
* aggregates: { owners: { countDistinct: 'userId' } },
|
|
18
|
+
* })
|
|
19
|
+
* // The most recent owner of a product, with their name
|
|
20
|
+
* await proof.query(collectionId, {
|
|
21
|
+
* where: { productId: 'toaster', userId: { isNull: false } },
|
|
22
|
+
* orderBy: [{ createdAt: 'desc' }], limit: 1,
|
|
23
|
+
* expand: { owner: ['firstName', 'lastName', 'email'] },
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function query(collectionId: string, body?: StandardQuery): Promise<QueryResult>;
|
|
28
|
+
/**
|
|
29
|
+
* What a proofs query can use: its fields, what each can filter, sort, group or total, and its links.
|
|
30
|
+
* GET /admin/collection/:collectionId/proof/query
|
|
31
|
+
*/
|
|
32
|
+
function queryFields(collectionId: string): Promise<QueryDescription>;
|
|
3
33
|
/**
|
|
4
34
|
* Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
|
|
5
35
|
* Both public and admin endpoints now include productId in the path.
|
package/dist/api/proof.js
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
import { request, post, put, del } from "../http.js";
|
|
3
3
|
export var proof;
|
|
4
4
|
(function (proof) {
|
|
5
|
+
/**
|
|
6
|
+
* The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs
|
|
7
|
+
* in one call, and follow a proof to its `product` and its `owner` (the owner's contact).
|
|
8
|
+
* POST /admin/collection/:collectionId/proof/query
|
|
9
|
+
*
|
|
10
|
+
* Fields: id, productId, userId (the owner's login id), batchId, variantId, lotId, status, claimable,
|
|
11
|
+
* createdAt, updatedAt. A proof's own values are not returned by this call.
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // How many people own each product
|
|
15
|
+
* await proof.query(collectionId, {
|
|
16
|
+
* where: { userId: { isNull: false } },
|
|
17
|
+
* groupBy: ['productId'],
|
|
18
|
+
* aggregates: { owners: { countDistinct: 'userId' } },
|
|
19
|
+
* })
|
|
20
|
+
* // The most recent owner of a product, with their name
|
|
21
|
+
* await proof.query(collectionId, {
|
|
22
|
+
* where: { productId: 'toaster', userId: { isNull: false } },
|
|
23
|
+
* orderBy: [{ createdAt: 'desc' }], limit: 1,
|
|
24
|
+
* expand: { owner: ['firstName', 'lastName', 'email'] },
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
async function query(collectionId, body = {}) {
|
|
29
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/proof/query`;
|
|
30
|
+
return post(path, body);
|
|
31
|
+
}
|
|
32
|
+
proof.query = query;
|
|
33
|
+
/**
|
|
34
|
+
* What a proofs query can use: its fields, what each can filter, sort, group or total, and its links.
|
|
35
|
+
* GET /admin/collection/:collectionId/proof/query
|
|
36
|
+
*/
|
|
37
|
+
async function queryFields(collectionId) {
|
|
38
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/proof/query`;
|
|
39
|
+
return request(path);
|
|
40
|
+
}
|
|
41
|
+
proof.queryFields = queryFields;
|
|
5
42
|
/**
|
|
6
43
|
* Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
|
|
7
44
|
* Both public and admin endpoints now include productId in the path.
|
package/dist/api/realtime.d.ts
CHANGED
|
@@ -30,6 +30,25 @@ export declare function channel(scope: RealtimeScope & {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare function onChange(scope: RealtimeScope, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) => void): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Something this APP works on changed: one of its work orders, a container or stock it moved, or one of
|
|
35
|
+
* its own records.
|
|
36
|
+
* For the people who use the app, admins or not: someone hears these when they are in one of the app's
|
|
37
|
+
* user groups (the ones its server functions are limited to, or `realtime.staff` in its manifest), and
|
|
38
|
+
* so does a collection admin. IDs only — refetch through your own API.
|
|
39
|
+
*
|
|
40
|
+
* Types: 'workOrder' (`id`, `appId`), 'container' (`id`, `kind` = its container type), 'stock' (`id` =
|
|
41
|
+
* the container, `productId`), 'record' (`id`, `recordType`). Filter as with `onChange`; an empty filter
|
|
42
|
+
* hears them all.
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* // A production app's screens refetch when anything on the floor changes.
|
|
46
|
+
* useEffect(() => realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries()), [collectionId, appId])
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function onStaffChange(scope: RealtimeScope & {
|
|
50
|
+
appId: string;
|
|
51
|
+
}, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) => void): () => void;
|
|
33
52
|
/**
|
|
34
53
|
* Messages for the signed-in person only (e.g. "scan" — a tag they just scanned on another device).
|
|
35
54
|
*/
|
package/dist/api/realtime.js
CHANGED
|
@@ -193,7 +193,7 @@ export function channel(scope, name) {
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
function matches(change, filter) {
|
|
196
|
-
for (const k of ["type", "id", "appId", "recordType", "productId", "proofId"]) {
|
|
196
|
+
for (const k of ["type", "id", "appId", "recordType", "productId", "proofId", "kind"]) {
|
|
197
197
|
if (filter[k] !== undefined && change[k] !== filter[k])
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
@@ -230,6 +230,31 @@ export function onChange(scope, filter, onChangeFn) {
|
|
|
230
230
|
offPublic();
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Something this APP works on changed: one of its work orders, a container or stock it moved, or one of
|
|
235
|
+
* its own records.
|
|
236
|
+
* For the people who use the app, admins or not: someone hears these when they are in one of the app's
|
|
237
|
+
* user groups (the ones its server functions are limited to, or `realtime.staff` in its manifest), and
|
|
238
|
+
* so does a collection admin. IDs only — refetch through your own API.
|
|
239
|
+
*
|
|
240
|
+
* Types: 'workOrder' (`id`, `appId`), 'container' (`id`, `kind` = its container type), 'stock' (`id` =
|
|
241
|
+
* the container, `productId`), 'record' (`id`, `recordType`). Filter as with `onChange`; an empty filter
|
|
242
|
+
* hears them all.
|
|
243
|
+
*
|
|
244
|
+
* ```ts
|
|
245
|
+
* // A production app's screens refetch when anything on the floor changes.
|
|
246
|
+
* useEffect(() => realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries()), [collectionId, appId])
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export function onStaffChange(scope, filter, onChangeFn) {
|
|
250
|
+
return streamFor({ collectionId: scope.collectionId, appId: scope.appId }).add("feed:staff", (m) => {
|
|
251
|
+
if (m.event !== "change" || !m.data || typeof m.data !== "object")
|
|
252
|
+
return;
|
|
253
|
+
const change = m.data;
|
|
254
|
+
if (matches(change, filter))
|
|
255
|
+
onChangeFn(change);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
233
258
|
/**
|
|
234
259
|
* Messages for the signed-in person only (e.g. "scan" — a tag they just scanned on another device).
|
|
235
260
|
*/
|