@proveanything/smartlinks 2.1.17 → 2.1.19
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/adminViews.d.ts +104 -0
- package/dist/adminViews.js +275 -0
- package/dist/api/ai.d.ts +15 -5
- package/dist/api/ai.js +15 -9
- package/dist/api/aiGuide.d.ts +108 -0
- package/dist/api/aiGuide.js +161 -0
- package/dist/api/appObjects.d.ts +21 -0
- package/dist/api/appObjects.js +33 -1
- package/dist/api/authKit.d.ts +37 -1
- package/dist/api/authKit.js +51 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/operations.d.ts +36 -0
- package/dist/api/operations.js +56 -0
- package/dist/api/order.d.ts +12 -1
- package/dist/api/order.js +15 -0
- package/dist/api/userGroups.d.ts +78 -0
- package/dist/api/userGroups.js +124 -0
- package/dist/docs/API_SUMMARY.md +1111 -80
- package/dist/docs/admin-lists-and-pickers.md +140 -0
- package/dist/docs/admin-views.md +147 -0
- package/dist/docs/app-data-storage.md +277 -276
- package/dist/docs/app-manifest.md +2 -0
- package/dist/docs/auth-kit.md +872 -741
- package/dist/docs/comms.md +686 -644
- package/dist/docs/customer-guide.md +70 -0
- package/dist/docs/headless-providers.md +112 -112
- package/dist/docs/operations.md +281 -0
- package/dist/docs/overview.md +3 -0
- package/dist/docs/server-functions.md +87 -1
- package/dist/docs/ui-utils.md +123 -121
- package/dist/docs/user-groups.md +175 -0
- package/dist/docs/utils.md +17 -0
- package/dist/headless.js +38 -2
- package/dist/http.js +8 -0
- package/dist/iframeResponder.d.ts +15 -0
- package/dist/iframeResponder.js +39 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/live.d.ts +80 -0
- package/dist/live.js +315 -0
- package/dist/openapi.yaml +1864 -48
- package/dist/testing/index.d.ts +35 -0
- package/dist/testing/index.js +86 -0
- package/dist/types/appManifest.d.ts +297 -1
- package/dist/types/appOptions.d.ts +32 -0
- package/dist/types/appOptions.js +3 -0
- package/dist/types/authKit.d.ts +193 -4
- package/dist/types/comms.d.ts +41 -2
- package/dist/types/containers.d.ts +8 -0
- package/dist/types/headless.d.ts +49 -1
- package/dist/types/iframeResponder.d.ts +16 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/operations.d.ts +598 -0
- package/dist/types/operations.js +8 -0
- package/dist/types/order.d.ts +35 -6
- package/dist/types/userGroups.d.ts +103 -0
- package/dist/types/userGroups.js +5 -0
- package/dist/utils/conditions.d.ts +7 -0
- package/dist/utils/conditions.js +16 -9
- package/docs/API_SUMMARY.md +1111 -80
- package/docs/admin-lists-and-pickers.md +140 -0
- package/docs/admin-views.md +147 -0
- package/docs/app-data-storage.md +277 -276
- package/docs/app-manifest.md +2 -0
- package/docs/auth-kit.md +872 -741
- package/docs/comms.md +686 -644
- package/docs/customer-guide.md +70 -0
- package/docs/headless-providers.md +112 -112
- package/docs/operations.md +281 -0
- package/docs/overview.md +3 -0
- package/docs/server-functions.md +87 -1
- package/docs/ui-utils.md +123 -121
- package/docs/user-groups.md +175 -0
- package/docs/utils.md +17 -0
- package/openapi.yaml +1864 -48
- package/package.json +1 -1
- package/scripts/doctor.mjs +454 -428
- package/scripts/lib/keyed-app-data.mjs +21 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User groups: named lists of people in a collection ("QC Controllers", "Warehouse", "Approved
|
|
3
|
+
* partners"), used to say who may do what. See docs/user-groups.md.
|
|
4
|
+
*/
|
|
5
|
+
/** A user group. Apps may keep extra fields on it; the ones below are the platform's. */
|
|
6
|
+
export interface UserGroup {
|
|
7
|
+
/** Random id. Never changes. */
|
|
8
|
+
id: string;
|
|
9
|
+
collectionId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The short stable name code uses: `'qc-controller'`. Lowercase letters, digits and hyphens, unique in
|
|
12
|
+
* the collection. Set when the user group is created and kept through a rename. A user group made
|
|
13
|
+
* before keys existed has none until it is next saved.
|
|
14
|
+
*/
|
|
15
|
+
key?: string;
|
|
16
|
+
/** What people see. Free to change. */
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
/** User ids of the people in it. */
|
|
20
|
+
members?: string[];
|
|
21
|
+
createdAt?: string;
|
|
22
|
+
updatedAt?: string;
|
|
23
|
+
deleted?: boolean;
|
|
24
|
+
deletedAt?: string | null;
|
|
25
|
+
[extra: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export interface CreateUserGroupRequest {
|
|
28
|
+
name: string;
|
|
29
|
+
/** Optional. Made from the name when absent ("QC Controllers" → `qc-controllers`). */
|
|
30
|
+
key?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
members?: string[];
|
|
33
|
+
[extra: string]: any;
|
|
34
|
+
}
|
|
35
|
+
/** Any fields to change. `key` can't be changed once set. */
|
|
36
|
+
export interface UpdateUserGroupRequest {
|
|
37
|
+
name?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
members?: string[];
|
|
40
|
+
[extra: string]: any;
|
|
41
|
+
}
|
|
42
|
+
/** One member, as the admin member list shows them. */
|
|
43
|
+
export interface UserGroupMember {
|
|
44
|
+
uid: string;
|
|
45
|
+
name?: string | null;
|
|
46
|
+
email?: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** Who to add: an existing user id, or an email (found in the collection's logins, or added to them). */
|
|
49
|
+
export type AddUserGroupMemberRequest = {
|
|
50
|
+
userId: string;
|
|
51
|
+
} | {
|
|
52
|
+
email: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
};
|
|
55
|
+
/** A user group a person is in, as `userGroups.ofUser` lists it. */
|
|
56
|
+
export interface UserGroupRef {
|
|
57
|
+
id: string;
|
|
58
|
+
key: string | null;
|
|
59
|
+
name: string | null;
|
|
60
|
+
}
|
|
61
|
+
/** What a signed-in person learns about their own membership (`userGroups.mine`). */
|
|
62
|
+
export interface MyUserGroups {
|
|
63
|
+
/** Keys of the user groups they are in. Use these in code. */
|
|
64
|
+
userGroups: string[];
|
|
65
|
+
/** Ids of the same user groups (older saved conditions refer to ids). */
|
|
66
|
+
userGroupIds: string[];
|
|
67
|
+
}
|
|
68
|
+
/** What kind of change a history entry records. */
|
|
69
|
+
export type UserGroupChangeType = 'usergroup.created' | 'usergroup.renamed' | 'usergroup.deleted' | 'usergroup.member-added' | 'usergroup.member-removed';
|
|
70
|
+
/** One recorded change to a user group (`userGroups.history`). Ids only: no names or emails of people. */
|
|
71
|
+
export interface UserGroupChange {
|
|
72
|
+
id: string;
|
|
73
|
+
/** When it happened (ISO 8601). */
|
|
74
|
+
at: string;
|
|
75
|
+
type: UserGroupChangeType;
|
|
76
|
+
/** The user group's id. */
|
|
77
|
+
entityId: string | null;
|
|
78
|
+
data: {
|
|
79
|
+
userGroupId: string;
|
|
80
|
+
key: string | null;
|
|
81
|
+
name: string | null;
|
|
82
|
+
/** `member-added` / `member-removed`: the person. */
|
|
83
|
+
userId?: string;
|
|
84
|
+
/** `renamed`: what it was called before. */
|
|
85
|
+
previousName?: string | null;
|
|
86
|
+
/** `deleted`: who was in it at the time. */
|
|
87
|
+
members?: string[];
|
|
88
|
+
};
|
|
89
|
+
actorType: string | null;
|
|
90
|
+
/** The admin who made the change, when known. */
|
|
91
|
+
actorId: string | null;
|
|
92
|
+
}
|
|
93
|
+
export interface UserGroupHistoryParams {
|
|
94
|
+
/** Only this user group. */
|
|
95
|
+
userGroupId?: string;
|
|
96
|
+
/** Only changes about this person. */
|
|
97
|
+
userId?: string;
|
|
98
|
+
/** ISO dates. Default: the last 30 days. At most 400 days apart. */
|
|
99
|
+
from?: string;
|
|
100
|
+
to?: string;
|
|
101
|
+
/** Default 100, at most 1000. */
|
|
102
|
+
limit?: number;
|
|
103
|
+
}
|
|
@@ -59,6 +59,9 @@ export interface NestedCondition extends BaseCondition {
|
|
|
59
59
|
export interface UserCondition extends BaseCondition {
|
|
60
60
|
type: 'user';
|
|
61
61
|
userType: 'valid' | 'invalid' | 'owner' | 'admin' | 'group';
|
|
62
|
+
/** `group` only: the user must be in at least one of these user groups (ids or keys). */
|
|
63
|
+
groupIds?: string[];
|
|
64
|
+
/** `group` only: a single user group (id or key). Same as `groupIds: [groupId]`. */
|
|
62
65
|
groupId?: string;
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
@@ -232,6 +235,10 @@ export interface UserInfo {
|
|
|
232
235
|
valid: boolean;
|
|
233
236
|
uid?: string;
|
|
234
237
|
location?: UserLocation;
|
|
238
|
+
/**
|
|
239
|
+
* The user groups this person is in: keys and/or ids. Fill it from `userGroups.mine(collectionId)`
|
|
240
|
+
* (`[...userGroups, ...userGroupIds]`) so a `group` condition can be checked.
|
|
241
|
+
*/
|
|
235
242
|
groups?: string[];
|
|
236
243
|
}
|
|
237
244
|
/**
|
package/dist/utils/conditions.js
CHANGED
|
@@ -505,20 +505,27 @@ async function validateUser(condition, params) {
|
|
|
505
505
|
hasRoles: !!((_t = params.collection) === null || _t === void 0 ? void 0 : _t.roles),
|
|
506
506
|
},
|
|
507
507
|
};
|
|
508
|
-
case 'group':
|
|
509
|
-
//
|
|
510
|
-
//
|
|
508
|
+
case 'group': {
|
|
509
|
+
// The user is signed in and in at least one of the named user groups (matched by id or key).
|
|
510
|
+
// A condition that names no user group passes nobody. This only shows or hides: what must be
|
|
511
|
+
// protected is limited on the server (a function's `userGroups`).
|
|
512
|
+
const wanted = [
|
|
513
|
+
...(Array.isArray(condition.groupIds) ? condition.groupIds : []),
|
|
514
|
+
...(condition.groupId ? [condition.groupId] : []),
|
|
515
|
+
].filter((g) => typeof g === 'string' && g);
|
|
516
|
+
const mine = Array.isArray((_u = params.user) === null || _u === void 0 ? void 0 : _u.groups) ? params.user.groups : [];
|
|
511
517
|
return {
|
|
512
|
-
passed: !!(params.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
518
|
+
passed: !!(((_v = params.user) === null || _v === void 0 ? void 0 : _v.valid) && wanted.length && wanted.some((g) => mine.includes(g))),
|
|
519
|
+
detail: wanted.length
|
|
520
|
+
? 'Group check passes when the signed-in user is in at least one of the named user groups.'
|
|
521
|
+
: 'Group condition names no user group, so nobody passes.',
|
|
516
522
|
context: {
|
|
517
|
-
|
|
518
|
-
groups:
|
|
523
|
+
groupIds: wanted,
|
|
524
|
+
groups: mine,
|
|
519
525
|
userValid: (_x = (_w = params.user) === null || _w === void 0 ? void 0 : _w.valid) !== null && _x !== void 0 ? _x : false,
|
|
520
526
|
},
|
|
521
527
|
};
|
|
528
|
+
}
|
|
522
529
|
default:
|
|
523
530
|
return {
|
|
524
531
|
passed: true,
|