@proveanything/smartlinks 2.1.16 → 2.1.18

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 (60) hide show
  1. package/dist/adminViews.d.ts +85 -0
  2. package/dist/adminViews.js +259 -0
  3. package/dist/api/errors.d.ts +10 -0
  4. package/dist/api/errors.js +17 -0
  5. package/dist/api/index.d.ts +3 -0
  6. package/dist/api/index.js +3 -0
  7. package/dist/api/operations.d.ts +36 -0
  8. package/dist/api/operations.js +56 -0
  9. package/dist/api/order.d.ts +12 -1
  10. package/dist/api/order.js +15 -0
  11. package/dist/api/partner.d.ts +7 -1
  12. package/dist/api/partner.js +9 -0
  13. package/dist/api/userGroups.d.ts +78 -0
  14. package/dist/api/userGroups.js +124 -0
  15. package/dist/docs/API_SUMMARY.md +699 -46
  16. package/dist/docs/admin-views.md +125 -0
  17. package/dist/docs/app-manifest.md +2 -0
  18. package/dist/docs/app-objects.md +23 -0
  19. package/dist/docs/operations.md +281 -0
  20. package/dist/docs/overview.md +3 -0
  21. package/dist/docs/server-functions.md +106 -0
  22. package/dist/docs/tag-ranges.md +8 -0
  23. package/dist/docs/user-groups.md +168 -0
  24. package/dist/docs/utils.md +17 -0
  25. package/dist/http.js +4 -0
  26. package/dist/iframeResponder.d.ts +15 -0
  27. package/dist/iframeResponder.js +39 -1
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +2 -0
  30. package/dist/openapi.yaml +1426 -276
  31. package/dist/testing/index.d.ts +29 -0
  32. package/dist/testing/index.js +178 -1
  33. package/dist/types/appManifest.d.ts +170 -0
  34. package/dist/types/appObjects.d.ts +22 -1
  35. package/dist/types/claimSet.d.ts +2 -0
  36. package/dist/types/clientLog.d.ts +46 -0
  37. package/dist/types/clientLog.js +1 -0
  38. package/dist/types/containers.d.ts +8 -0
  39. package/dist/types/iframeResponder.d.ts +16 -1
  40. package/dist/types/index.d.ts +3 -0
  41. package/dist/types/index.js +3 -0
  42. package/dist/types/operations.d.ts +598 -0
  43. package/dist/types/operations.js +8 -0
  44. package/dist/types/order.d.ts +35 -6
  45. package/dist/types/userGroups.d.ts +103 -0
  46. package/dist/types/userGroups.js +5 -0
  47. package/dist/utils/conditions.d.ts +7 -0
  48. package/dist/utils/conditions.js +16 -9
  49. package/docs/API_SUMMARY.md +699 -46
  50. package/docs/admin-views.md +125 -0
  51. package/docs/app-manifest.md +2 -0
  52. package/docs/app-objects.md +23 -0
  53. package/docs/operations.md +281 -0
  54. package/docs/overview.md +3 -0
  55. package/docs/server-functions.md +106 -0
  56. package/docs/tag-ranges.md +8 -0
  57. package/docs/user-groups.md +168 -0
  58. package/docs/utils.md +17 -0
  59. package/openapi.yaml +1426 -276
  60. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ import { request, post, put, del } from "../http.js";
2
+ /**
3
+ * User groups: named lists of people in a collection, used to say who may do what.
4
+ *
5
+ * - An admin manages them here (`list`, `create`, `addMember`, …).
6
+ * - A signed-in person asks which ones they are in with `mine()`, so a screen can show or hide things.
7
+ * - A server function is limited to user groups in its manifest declaration (`userGroups: ['manager']`)
8
+ * and reads the caller's with `ctx.caller.userGroups`. That is where things are actually protected.
9
+ *
10
+ * See docs/user-groups.md.
11
+ */
12
+ export var userGroups;
13
+ (function (userGroups) {
14
+ const base = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/userGroup`;
15
+ /**
16
+ * The signed-in person's own user groups in this collection. Not signed in → both lists empty.
17
+ * Nobody can ask about anyone else with this.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const { userGroups: mine } = await userGroups.mine('coll_123')
22
+ * const canRelease = mine.includes('qc-controller')
23
+ * ```
24
+ */
25
+ async function mine(collectionId) {
26
+ return request(`/public/collection/${encodeURIComponent(collectionId)}/userGroups/mine`);
27
+ }
28
+ userGroups.mine = mine;
29
+ /** Every user group in the collection (admin). */
30
+ async function list(collectionId) {
31
+ return request(base(collectionId));
32
+ }
33
+ userGroups.list = list;
34
+ /** One user group (admin). */
35
+ async function get(collectionId, userGroupId) {
36
+ return request(`${base(collectionId)}/${encodeURIComponent(userGroupId)}`);
37
+ }
38
+ userGroups.get = get;
39
+ /**
40
+ * Create a user group (admin). Its key is made from the name unless you give one.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const qc = await userGroups.create('coll_123', { name: 'QC Controllers' })
45
+ * qc.key // 'qc-controllers'
46
+ * ```
47
+ * @throws `KEY_INVALID` / `KEY_TAKEN` for a bad or already-used key
48
+ */
49
+ async function create(collectionId, data) {
50
+ return post(base(collectionId), data);
51
+ }
52
+ userGroups.create = create;
53
+ /**
54
+ * Change a user group (admin): its name, description, or anything else you keep on it. The key stays.
55
+ * To change who is in it, prefer `addMember` / `removeMember`: saving a whole `members` list here can
56
+ * overwrite a change someone else made at the same moment.
57
+ *
58
+ * @throws `KEY_FIXED` if you try to change a key that is already set
59
+ */
60
+ async function update(collectionId, userGroupId, data) {
61
+ return put(`${base(collectionId)}/${encodeURIComponent(userGroupId)}`, data);
62
+ }
63
+ userGroups.update = update;
64
+ /** Delete a user group (admin). Its members lose whatever it allowed. */
65
+ async function remove(collectionId, userGroupId) {
66
+ return del(`${base(collectionId)}/${encodeURIComponent(userGroupId)}`);
67
+ }
68
+ userGroups.remove = remove;
69
+ /** The people in a user group, with name and email (admin). */
70
+ async function members(collectionId, userGroupId) {
71
+ return request(`${base(collectionId)}/${encodeURIComponent(userGroupId)}/users`);
72
+ }
73
+ userGroups.members = members;
74
+ /**
75
+ * Add one person (admin), by user id or by email. By email, the person is found in the collection's
76
+ * logins or added to them (no welcome email is sent). Adding someone who is already in changes nothing.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * await userGroups.addMember('coll_123', qc.id, { email: 'sam@example.com', name: 'Sam' })
81
+ * ```
82
+ */
83
+ async function addMember(collectionId, userGroupId, who) {
84
+ return post(`${base(collectionId)}/${encodeURIComponent(userGroupId)}/members`, who);
85
+ }
86
+ userGroups.addMember = addMember;
87
+ /** Remove one person (admin). */
88
+ async function removeMember(collectionId, userGroupId, userId) {
89
+ return del(`${base(collectionId)}/${encodeURIComponent(userGroupId)}/members/${encodeURIComponent(userId)}`);
90
+ }
91
+ userGroups.removeMember = removeMember;
92
+ /**
93
+ * What changed, newest first (admin): user groups created, renamed and deleted, and every person added
94
+ * or removed, each with the admin who did it (`actorId`) and when (`at`). Give `userGroupId` for one
95
+ * user group, `userId` for everything about one person, or neither for the whole collection.
96
+ * Covers the last 30 days unless you give `from` / `to` (at most 400 days). Takes about a second.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const who = await userGroups.history('coll_123', { userId: 'uid_1' })
101
+ * // [{ at, type: 'usergroup.member-added', actorId: 'uid_admin', data: { key: 'qc-controllers', userId: 'uid_1', … } }]
102
+ * ```
103
+ */
104
+ async function history(collectionId, params = {}) {
105
+ const q = new URLSearchParams();
106
+ if (params.userId)
107
+ q.append('userId', params.userId);
108
+ if (params.from)
109
+ q.append('from', params.from);
110
+ if (params.to)
111
+ q.append('to', params.to);
112
+ if (params.limit)
113
+ q.append('limit', String(params.limit));
114
+ const qs = q.toString();
115
+ const path = params.userGroupId ? `${base(collectionId)}/${encodeURIComponent(params.userGroupId)}/history` : `${base(collectionId)}/history`;
116
+ return request(`${path}${qs ? `?${qs}` : ''}`);
117
+ }
118
+ userGroups.history = history;
119
+ /** The user groups one person is in (admin). */
120
+ async function ofUser(collectionId, userId) {
121
+ return request(`${base(collectionId)}/of/${encodeURIComponent(userId)}`);
122
+ }
123
+ userGroups.ofUser = ofUser;
124
+ })(userGroups || (userGroups = {}));