@proveanything/smartlinks 2.1.22 → 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/openapi.yaml CHANGED
@@ -70,6 +70,8 @@ tags:
70
70
  description: Collection (tenant) configuration and resources.
71
71
  - name: comms
72
72
  description: Communications preferences, consent and delivery.
73
+ - name: conditions
74
+ description: conditions API
73
75
  - name: config
74
76
  description: Proof-type and platform configuration.
75
77
  - name: contact
@@ -3324,6 +3326,65 @@ paths:
3324
3326
  description: Unauthorized
3325
3327
  404:
3326
3328
  description: Not found
3329
+ /admin/collection/{collectionId}/contacts/query:
3330
+ get:
3331
+ tags:
3332
+ - contact
3333
+ summary: "What a contacts query can use: its fields and what each can filter, sort, group or total."
3334
+ operationId: contact_queryFields
3335
+ security:
3336
+ - bearerAuth: []
3337
+ parameters:
3338
+ - name: collectionId
3339
+ in: path
3340
+ required: true
3341
+ schema:
3342
+ type: string
3343
+ responses:
3344
+ 200:
3345
+ description: Success
3346
+ content:
3347
+ application/json:
3348
+ schema:
3349
+ $ref: "#/components/schemas/QueryDescription"
3350
+ 400:
3351
+ description: Bad request
3352
+ 401:
3353
+ description: Unauthorized
3354
+ 404:
3355
+ description: Not found
3356
+ post:
3357
+ tags:
3358
+ - contact
3359
+ summary: "The standard query on contacts (admin only): filter, sort, page, count and total in one call."
3360
+ operationId: contact_query
3361
+ security:
3362
+ - bearerAuth: []
3363
+ parameters:
3364
+ - name: collectionId
3365
+ in: path
3366
+ required: true
3367
+ schema:
3368
+ type: string
3369
+ responses:
3370
+ 200:
3371
+ description: Success
3372
+ content:
3373
+ application/json:
3374
+ schema:
3375
+ $ref: "#/components/schemas/QueryResult"
3376
+ 400:
3377
+ description: Bad request
3378
+ 401:
3379
+ description: Unauthorized
3380
+ 404:
3381
+ description: Not found
3382
+ requestBody:
3383
+ required: true
3384
+ content:
3385
+ application/json:
3386
+ schema:
3387
+ $ref: "#/components/schemas/StandardQuery"
3327
3388
  /admin/collection/{collectionId}/contacts/search:
3328
3389
  get:
3329
3390
  tags:
@@ -7970,6 +8031,65 @@ paths:
7970
8031
  application/json:
7971
8032
  schema:
7972
8033
  $ref: "#/components/schemas/ProductCreateRequest"
8034
+ /admin/collection/{collectionId}/products/standard/query:
8035
+ get:
8036
+ tags:
8037
+ - products
8038
+ summary: "What a products standard query can use: its fields and what each can filter, sort, group or total."
8039
+ operationId: products_standardQueryFields
8040
+ security:
8041
+ - bearerAuth: []
8042
+ parameters:
8043
+ - name: collectionId
8044
+ in: path
8045
+ required: true
8046
+ schema:
8047
+ type: string
8048
+ responses:
8049
+ 200:
8050
+ description: Success
8051
+ content:
8052
+ application/json:
8053
+ schema:
8054
+ $ref: "#/components/schemas/QueryDescription"
8055
+ 400:
8056
+ description: Bad request
8057
+ 401:
8058
+ description: Unauthorized
8059
+ 404:
8060
+ description: Not found
8061
+ post:
8062
+ tags:
8063
+ - products
8064
+ summary: "The standard query on products (admin only): the one query shape every resource is moving to, with counts, totals and filtering by facet."
8065
+ operationId: products_standardQuery
8066
+ security:
8067
+ - bearerAuth: []
8068
+ parameters:
8069
+ - name: collectionId
8070
+ in: path
8071
+ required: true
8072
+ schema:
8073
+ type: string
8074
+ responses:
8075
+ 200:
8076
+ description: Success
8077
+ content:
8078
+ application/json:
8079
+ schema:
8080
+ $ref: "#/components/schemas/QueryResult"
8081
+ 400:
8082
+ description: Bad request
8083
+ 401:
8084
+ description: Unauthorized
8085
+ 404:
8086
+ description: Not found
8087
+ requestBody:
8088
+ required: true
8089
+ content:
8090
+ application/json:
8091
+ schema:
8092
+ $ref: "#/components/schemas/StandardQuery"
7973
8093
  /admin/collection/{collectionId}/products/{productId}:
7974
8094
  put:
7975
8095
  tags:
@@ -8340,6 +8460,65 @@ paths:
8340
8460
  description: Unauthorized
8341
8461
  404:
8342
8462
  description: Not found
8463
+ /admin/collection/{collectionId}/proof/query:
8464
+ get:
8465
+ tags:
8466
+ - proof
8467
+ summary: "What a proofs query can use: its fields, what each can filter, sort, group or total, and its links."
8468
+ operationId: proof_queryFields
8469
+ security:
8470
+ - bearerAuth: []
8471
+ parameters:
8472
+ - name: collectionId
8473
+ in: path
8474
+ required: true
8475
+ schema:
8476
+ type: string
8477
+ responses:
8478
+ 200:
8479
+ description: Success
8480
+ content:
8481
+ application/json:
8482
+ schema:
8483
+ $ref: "#/components/schemas/QueryDescription"
8484
+ 400:
8485
+ description: Bad request
8486
+ 401:
8487
+ description: Unauthorized
8488
+ 404:
8489
+ description: Not found
8490
+ post:
8491
+ tags:
8492
+ - proof
8493
+ summary: "The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs in one call, and follow a proof to its `product` and its `owner` (the owner's contact)."
8494
+ operationId: proof_query
8495
+ security:
8496
+ - bearerAuth: []
8497
+ parameters:
8498
+ - name: collectionId
8499
+ in: path
8500
+ required: true
8501
+ schema:
8502
+ type: string
8503
+ responses:
8504
+ 200:
8505
+ description: Success
8506
+ content:
8507
+ application/json:
8508
+ schema:
8509
+ $ref: "#/components/schemas/QueryResult"
8510
+ 400:
8511
+ description: Bad request
8512
+ 401:
8513
+ description: Unauthorized
8514
+ 404:
8515
+ description: Not found
8516
+ requestBody:
8517
+ required: true
8518
+ content:
8519
+ application/json:
8520
+ schema:
8521
+ $ref: "#/components/schemas/StandardQuery"
8343
8522
  /admin/collection/{collectionId}/research/fetch:
8344
8523
  post:
8345
8524
  tags:
@@ -15299,6 +15478,32 @@ paths:
15299
15478
  description: Unauthorized
15300
15479
  404:
15301
15480
  description: Not found
15481
+ /{conditionId}:
15482
+ get:
15483
+ tags:
15484
+ - conditions
15485
+ summary: One saved condition.
15486
+ operationId: conditions_get
15487
+ security: []
15488
+ parameters:
15489
+ - name: conditionId
15490
+ in: path
15491
+ required: true
15492
+ schema:
15493
+ type: string
15494
+ responses:
15495
+ 200:
15496
+ description: Success
15497
+ content:
15498
+ application/json:
15499
+ schema:
15500
+ $ref: "#/components/schemas/SavedCondition"
15501
+ 400:
15502
+ description: Bad request
15503
+ 401:
15504
+ description: Unauthorized
15505
+ 404:
15506
+ description: Not found
15302
15507
  /{groupId}/members:
15303
15508
  post:
15304
15509
  tags:
@@ -16412,6 +16617,83 @@ paths:
16412
16617
  application/json:
16413
16618
  schema:
16414
16619
  $ref: "#/components/schemas/PreviewRuleParams"
16620
+ /{zone}/collection/{collectionId}/app/{appId}/records/query:
16621
+ get:
16622
+ tags:
16623
+ - records
16624
+ summary: "What a records query can use: its fields, what each can filter, sort, group or total, and its links."
16625
+ operationId: records_queryFields
16626
+ security: []
16627
+ parameters:
16628
+ - name: zone
16629
+ in: path
16630
+ required: true
16631
+ schema:
16632
+ type: string
16633
+ - name: collectionId
16634
+ in: path
16635
+ required: true
16636
+ schema:
16637
+ type: string
16638
+ - name: appId
16639
+ in: path
16640
+ required: true
16641
+ schema:
16642
+ type: string
16643
+ responses:
16644
+ 200:
16645
+ description: Success
16646
+ content:
16647
+ application/json:
16648
+ schema:
16649
+ $ref: "#/components/schemas/QueryDescription"
16650
+ 400:
16651
+ description: Bad request
16652
+ 401:
16653
+ description: Unauthorized
16654
+ 404:
16655
+ description: Not found
16656
+ post:
16657
+ tags:
16658
+ - records
16659
+ summary: "The standard query on an app's records (admin only): filter, sort, page, count and total in one call, reaching into a record's own fields by path, and following a record to its `product` and its `contact`."
16660
+ operationId: records_query
16661
+ security: []
16662
+ parameters:
16663
+ - name: zone
16664
+ in: path
16665
+ required: true
16666
+ schema:
16667
+ type: string
16668
+ - name: collectionId
16669
+ in: path
16670
+ required: true
16671
+ schema:
16672
+ type: string
16673
+ - name: appId
16674
+ in: path
16675
+ required: true
16676
+ schema:
16677
+ type: string
16678
+ responses:
16679
+ 200:
16680
+ description: Success
16681
+ content:
16682
+ application/json:
16683
+ schema:
16684
+ $ref: "#/components/schemas/QueryResult"
16685
+ 400:
16686
+ description: Bad request
16687
+ 401:
16688
+ description: Unauthorized
16689
+ 404:
16690
+ description: Not found
16691
+ requestBody:
16692
+ required: true
16693
+ content:
16694
+ application/json:
16695
+ schema:
16696
+ $ref: "#/components/schemas/StandardQuery"
16415
16697
  /{zone}/collection/{collectionId}/app/{appId}/records/resolve-all:
16416
16698
  post:
16417
16699
  tags:
@@ -35542,6 +35824,136 @@ components:
35542
35824
  type: string
35543
35825
  required:
35544
35826
  - code
35827
+ QueryFieldTest:
35828
+ type: object
35829
+ properties:
35830
+ eq:
35831
+ $ref: "#/components/schemas/QueryValue"
35832
+ ne:
35833
+ $ref: "#/components/schemas/QueryValue"
35834
+ gt:
35835
+ $ref: "#/components/schemas/QueryValue"
35836
+ gte:
35837
+ $ref: "#/components/schemas/QueryValue"
35838
+ lt:
35839
+ $ref: "#/components/schemas/QueryValue"
35840
+ lte:
35841
+ $ref: "#/components/schemas/QueryValue"
35842
+ in:
35843
+ type: array
35844
+ items:
35845
+ $ref: "#/components/schemas/QueryValue"
35846
+ nin:
35847
+ type: array
35848
+ items:
35849
+ $ref: "#/components/schemas/QueryValue"
35850
+ contains:
35851
+ type: string
35852
+ startsWith:
35853
+ type: string
35854
+ isNull:
35855
+ type: boolean
35856
+ has:
35857
+ type: string
35858
+ hasAny:
35859
+ type: array
35860
+ items:
35861
+ type: string
35862
+ hasAll:
35863
+ type: array
35864
+ items:
35865
+ type: string
35866
+ QueryWhere:
35867
+ type: object
35868
+ properties:
35869
+ and:
35870
+ type: array
35871
+ items:
35872
+ $ref: "#/components/schemas/QueryWhere"
35873
+ or:
35874
+ type: array
35875
+ items:
35876
+ $ref: "#/components/schemas/QueryWhere"
35877
+ not:
35878
+ $ref: "#/components/schemas/QueryWhere"
35879
+ StandardQuery:
35880
+ type: object
35881
+ properties:
35882
+ where:
35883
+ $ref: "#/components/schemas/QueryWhere"
35884
+ orderBy:
35885
+ type: array
35886
+ items:
35887
+ type: object
35888
+ additionalProperties:
35889
+ type: string
35890
+ enum:
35891
+ - asc
35892
+ - desc
35893
+ limit:
35894
+ type: number
35895
+ cursor:
35896
+ type: string
35897
+ select:
35898
+ type: array
35899
+ items:
35900
+ type: string
35901
+ count:
35902
+ type: boolean
35903
+ groupBy:
35904
+ type: array
35905
+ items:
35906
+ type: string
35907
+ aggregates:
35908
+ type: object
35909
+ additionalProperties:
35910
+ $ref: "#/components/schemas/QueryAggregate"
35911
+ expand:
35912
+ type: object
35913
+ additionalProperties: true
35914
+ QueryDescription:
35915
+ type: object
35916
+ properties:
35917
+ name:
35918
+ type: string
35919
+ fields:
35920
+ type: object
35921
+ additionalProperties:
35922
+ type: object
35923
+ additionalProperties: true
35924
+ count:
35925
+ type: boolean
35926
+ aggregates:
35927
+ type: boolean
35928
+ links:
35929
+ type: object
35930
+ additionalProperties:
35931
+ type: object
35932
+ additionalProperties: true
35933
+ limits:
35934
+ type: object
35935
+ additionalProperties: true
35936
+ shape:
35937
+ type: string
35938
+ required:
35939
+ - name
35940
+ - fields
35941
+ - count
35942
+ - aggregates
35943
+ - links
35944
+ - limits
35945
+ - shape
35946
+ QueryValue:
35947
+ type: object
35948
+ additionalProperties: true
35949
+ QueryKeyedTest:
35950
+ type: object
35951
+ additionalProperties:
35952
+ type: object
35953
+ additionalProperties: true
35954
+ QueryAggregate:
35955
+ type: object
35956
+ additionalProperties: true
35545
35957
  RealtimeTokenRequest:
35546
35958
  type: object
35547
35959
  properties:
@@ -36999,6 +37411,22 @@ components:
36999
37411
  additionalProperties: true
37000
37412
  required:
37001
37413
  - valid
37414
+ SavedCondition:
37415
+ type: object
37416
+ properties:
37417
+ id:
37418
+ type: string
37419
+ title:
37420
+ type: string
37421
+ disabled:
37422
+ type: boolean
37423
+ deleted:
37424
+ type: boolean
37425
+ required:
37426
+ - id
37427
+ - title
37428
+ SaveConditionRequest:
37429
+ $ref: "#/components/schemas/SavedCondition"
37002
37430
  FunctionListEntry:
37003
37431
  type: object
37004
37432
  properties:
@@ -102,12 +102,13 @@ export interface AdminCardPayload {
102
102
  total: number;
103
103
  label?: string;
104
104
  };
105
- /** A short list — at most 5 are shown. */
105
+ /** A short list — at most 5 are shown. `image` (https) is a small picture beside the row, e.g. a product photo. */
106
106
  items?: Array<{
107
107
  title: string;
108
108
  subtitle?: string;
109
109
  meta?: string;
110
110
  path?: string;
111
+ image?: string;
111
112
  }>;
112
113
  /** Things that need doing — collected into the dashboard's To do strip. */
113
114
  todo?: Array<{
@@ -18,6 +18,7 @@ export * from "./segments.js";
18
18
  export * from "./userGroups.js";
19
19
  export * from "./operations.js";
20
20
  export * from "./common.js";
21
+ export * from "./query.js";
21
22
  export * from "./journeys.js";
22
23
  export * from "./journeysAnalytics.js";
23
24
  export * from "./qr.js";
@@ -20,6 +20,7 @@ export * from "./segments.js";
20
20
  export * from "./userGroups.js";
21
21
  export * from "./operations.js";
22
22
  export * from "./common.js";
23
+ export * from "./query.js";
23
24
  export * from "./journeys.js";
24
25
  export * from "./journeysAnalytics.js";
25
26
  export * from "./qr.js";
@@ -0,0 +1,121 @@
1
+ /** A value a field can be compared with. Dates are ISO 8601 strings. */
2
+ export type QueryValue = string | number | boolean;
3
+ /** How one field is tested. Several tests on one field must all hold. */
4
+ export interface QueryFieldTest {
5
+ eq?: QueryValue;
6
+ ne?: QueryValue;
7
+ gt?: QueryValue;
8
+ gte?: QueryValue;
9
+ lt?: QueryValue;
10
+ lte?: QueryValue;
11
+ /** One of these values (1 to 100). */
12
+ in?: QueryValue[];
13
+ /** None of these values (1 to 100). */
14
+ nin?: QueryValue[];
15
+ /** Text containing this, in any case. */
16
+ contains?: string;
17
+ /** Text starting with this, in any case. */
18
+ startsWith?: string;
19
+ /** true: the field is empty. false: it has a value. */
20
+ isNull?: boolean;
21
+ /** A list field (e.g. a contact's tags) holds this value. */
22
+ has?: string;
23
+ /** A list field holds at least one of these. */
24
+ hasAny?: string[];
25
+ /** A list field holds all of these. */
26
+ hasAll?: string[];
27
+ }
28
+ /**
29
+ * A keyed field (e.g. a product's `facets`) is filtered key by key: `{ brand: "Breville" }` or
30
+ * `{ category: { in: ["Toasters", "Kettles"] } }`. Every key must match.
31
+ */
32
+ export type QueryKeyedTest = Record<string, QueryValue | {
33
+ eq?: QueryValue;
34
+ in?: QueryValue[];
35
+ }>;
36
+ /**
37
+ * What to match. Each entry is `field: value` (equal to) or `field: { op: value }`; all entries must
38
+ * hold. `and`, `or` and `not` combine further conditions (nested up to 4 levels).
39
+ *
40
+ * A document field (an app record's `data`) is reached by path, as a field name: `"data.status"`.
41
+ */
42
+ export interface QueryWhere {
43
+ and?: QueryWhere[];
44
+ or?: QueryWhere[];
45
+ not?: QueryWhere;
46
+ [field: string]: QueryValue | QueryFieldTest | QueryKeyedTest | QueryWhere | QueryWhere[] | undefined;
47
+ }
48
+ /** One total. `count` counts rows; the others take a field (or a path into a document). */
49
+ export type QueryAggregate = {
50
+ count: true;
51
+ } | {
52
+ countDistinct: string;
53
+ } | {
54
+ sum: string;
55
+ } | {
56
+ avg: string;
57
+ } | {
58
+ min: string;
59
+ } | {
60
+ max: string;
61
+ };
62
+ /** The standard query body. Everything is optional: an empty query returns the first page. */
63
+ export interface StandardQuery {
64
+ where?: QueryWhere;
65
+ /** e.g. `[{ createdAt: "desc" }]`. Only fields that can be sorted on (never an empty-able one). */
66
+ orderBy?: Array<Record<string, 'asc' | 'desc'>>;
67
+ /** Rows per page (1 to 200, default 50), or groups (1 to 500) with groupBy / aggregates. */
68
+ limit?: number;
69
+ /** `nextCursor` from the previous page, with the same `where` and `orderBy`. */
70
+ cursor?: string | null;
71
+ /** Which fields to return. A path into a document can be selected: `"data.status"`. */
72
+ select?: string[];
73
+ /** Also return how many rows match `where` in all (not just this page). */
74
+ count?: boolean;
75
+ /** Group rows by up to 3 fields (or document paths). Returns groups, not rows. */
76
+ groupBy?: string[];
77
+ /** Named totals, e.g. `{ owners: { countDistinct: "userId" } }`. Returns groups, not rows. */
78
+ aggregates?: Record<string, QueryAggregate>;
79
+ /**
80
+ * Follow a link and return the linked thing inside each row: `["product", "owner"]`, or with the
81
+ * fields wanted `{ owner: ["firstName", "email"] }`. Rows only. Null where there is nothing linked.
82
+ */
83
+ expand?: string[] | Record<string, string[] | true>;
84
+ }
85
+ /** A page of rows. */
86
+ export interface QueryRows<T = Record<string, unknown>> {
87
+ items: T[];
88
+ /** Pass as `cursor` for the next page; null on the last page. */
89
+ nextCursor: string | null;
90
+ /** Present when the query asked for `count: true`. */
91
+ count?: number;
92
+ }
93
+ /** The answer to a query with `groupBy` and/or `aggregates`. */
94
+ export interface QueryGroups<G = Record<string, unknown>> {
95
+ groups: G[];
96
+ /** True when there were more groups than `limit`. */
97
+ more: boolean;
98
+ }
99
+ export type QueryResult<T = Record<string, unknown>, G = Record<string, unknown>> = QueryRows<T> | QueryGroups<G>;
100
+ /** What a resource's query can use (from `GET …/query`). */
101
+ export interface QueryDescription {
102
+ name: string;
103
+ fields: Record<string, {
104
+ type: 'string' | 'number' | 'boolean' | 'date' | 'list' | 'keyed' | 'json';
105
+ about?: string;
106
+ can: string[];
107
+ }>;
108
+ count: boolean;
109
+ aggregates: boolean;
110
+ links: Record<string, {
111
+ to: string;
112
+ by: string;
113
+ about?: string;
114
+ }>;
115
+ limits: {
116
+ limit: number;
117
+ groups: number;
118
+ };
119
+ /** The query shape in a few lines of plain words. */
120
+ shape: string;
121
+ }
@@ -0,0 +1,5 @@
1
+ // src/types/query.ts
2
+ //
3
+ // The STANDARD QUERY: one request body for filtering, sorting, paging, counting and totalling, the same
4
+ // on every resource that takes it (proofs, contacts, products, app records). See docs/standard-query.md.
5
+ export {};
@@ -296,7 +296,7 @@ export interface ConditionParams {
296
296
  itemContext?: ItemContext;
297
297
  /** Statistics/tracking information */
298
298
  stats?: StatsInfo;
299
- /** Function to fetch conditions by ID (optional) */
299
+ /** Load a saved condition by id (optional; by default the collection's saved conditions are read with `conditions.get`) */
300
300
  fetchCondition?: (collectionId: string, conditionId: string) => Promise<ConditionSet | null>;
301
301
  /** Function to get user's current location (optional) */
302
302
  getLocation?: () => Promise<{