@crombolo/render 0.80.1 → 0.81.0
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/package.json +3 -3
- package/src/model.ts +2 -0
- package/src/sign-in.ts +11 -3
- package/src/site.ts +69 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. TSX server rendering and the published-content model for crombolo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@crombolo/common": "0.
|
|
39
|
-
"@crombolo/core": "0.
|
|
38
|
+
"@crombolo/common": "0.81.0",
|
|
39
|
+
"@crombolo/core": "0.81.0",
|
|
40
40
|
"@types/react": "^19.3.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/model.ts
CHANGED
|
@@ -267,6 +267,8 @@ export interface RequestMember {
|
|
|
267
267
|
username: string
|
|
268
268
|
email: string
|
|
269
269
|
roles: string[]
|
|
270
|
+
/** What their member type lets them see of themselves (story 207). */
|
|
271
|
+
properties?: Readonly<Record<string, unknown>>
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
/** The query string, as Next.js hands it to a page: repeated names become arrays. */
|
package/src/sign-in.ts
CHANGED
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
* Links for signing in through a member identity provider (story 031), for a
|
|
3
3
|
* site's login form: `<a href={externalSignInUrl('entra', returnUrl)}>`. The
|
|
4
4
|
* provider is one the site's config lists in `memberIdentityProviders`, by id.
|
|
5
|
+
* `flow` starts another of its flows, such as `signUp` (story 191).
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
/** Where member sign-ins through an identity provider start. */
|
|
8
9
|
export const MEMBER_EXTERNAL_SIGN_IN_PATH = '/umbraco/members/external'
|
|
9
10
|
|
|
10
11
|
/** The URL that signs a member in through a provider, coming back to `returnUrl` (a path on this site). */
|
|
11
|
-
export function externalSignInUrl(
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export function externalSignInUrl(
|
|
13
|
+
providerId: string,
|
|
14
|
+
returnUrl?: string,
|
|
15
|
+
options: { flow?: string } = {},
|
|
16
|
+
): string {
|
|
17
|
+
const query = [
|
|
18
|
+
...(options.flow ? [`flow=${encodeURIComponent(options.flow)}`] : []),
|
|
19
|
+
...(returnUrl ? [`returnUrl=${encodeURIComponent(returnUrl)}`] : []),
|
|
20
|
+
].join('&')
|
|
21
|
+
return `${MEMBER_EXTERNAL_SIGN_IN_PATH}/${encodeURIComponent(providerId)}${query ? `?${query}` : ''}`
|
|
14
22
|
}
|
package/src/site.ts
CHANGED
|
@@ -21,10 +21,20 @@ export interface QueryCaller {
|
|
|
21
21
|
member(): Promise<
|
|
22
22
|
Pick<RequestMember, 'key' | 'name' | 'username' | 'email' | 'roles'> | undefined
|
|
23
23
|
>
|
|
24
|
+
/** The signed-in back-office user, on a staff screen's route (story 431); undefined for a member or a visitor. */
|
|
25
|
+
user(): Promise<QueryUser | undefined>
|
|
24
26
|
/** The language the page renders in, when there is a page. */
|
|
25
27
|
locale: string | null
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
/** A back-office user, as a query sees them: their groups by alias. */
|
|
31
|
+
export interface QueryUser {
|
|
32
|
+
key: string
|
|
33
|
+
name: string
|
|
34
|
+
email: string
|
|
35
|
+
groups: string[]
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* A named query: `db` is the site's own tables and `caller` who is asking; the
|
|
30
40
|
* rest are what `site().queries.<module>.<name>(…)` is called with.
|
|
@@ -58,10 +68,66 @@ export type SiteQueries = Register extends { queries: infer Q }
|
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
|
|
61
|
-
/**
|
|
71
|
+
/** A member as the site's code reads one (story 207): the properties the caller may see. */
|
|
72
|
+
export interface SiteMember {
|
|
73
|
+
key: string
|
|
74
|
+
/** Their member type's alias. */
|
|
75
|
+
type: string
|
|
76
|
+
name: string
|
|
77
|
+
username: string
|
|
78
|
+
email: string
|
|
79
|
+
/** Group names. */
|
|
80
|
+
groups: readonly string[]
|
|
81
|
+
approved: boolean
|
|
82
|
+
properties: Readonly<Record<string, unknown>>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Which members to list; `after` is the last page's `next`. */
|
|
86
|
+
export interface SiteMemberQuery {
|
|
87
|
+
group?: string
|
|
88
|
+
/** A member type's alias. */
|
|
89
|
+
type?: string
|
|
90
|
+
approved?: boolean
|
|
91
|
+
/** Found in their name, username or e-mail. */
|
|
92
|
+
text?: string
|
|
93
|
+
/** Made or saved since. */
|
|
94
|
+
since?: Date
|
|
95
|
+
after?: string
|
|
96
|
+
/** How many at once: 100, and at most 500. */
|
|
97
|
+
take?: number
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** A change to a member: what is given, the rest kept. A property set to null is cleared. */
|
|
101
|
+
export interface SiteMemberChange {
|
|
102
|
+
name?: string
|
|
103
|
+
email?: string
|
|
104
|
+
properties?: Readonly<Record<string, unknown>>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Members, acting as whoever is asking: a member reaches their own record only,
|
|
109
|
+
* and a job or an event handler is the API user `members.actAs` names.
|
|
110
|
+
*/
|
|
62
111
|
export interface SiteMembers {
|
|
63
|
-
|
|
64
|
-
|
|
112
|
+
/** The signed-in member. */
|
|
113
|
+
me(): Promise<Result<SiteMember, 403>>
|
|
114
|
+
get(key: string): Promise<Result<SiteMember, 403 | 404>>
|
|
115
|
+
byEmail(email: string): Promise<Result<SiteMember, 403 | 404>>
|
|
116
|
+
byUsername(username: string): Promise<Result<SiteMember, 403 | 404>>
|
|
117
|
+
list(
|
|
118
|
+
query?: SiteMemberQuery,
|
|
119
|
+
): Promise<Result<{ items: SiteMember[]; next: string | null }, 400 | 403>>
|
|
120
|
+
update(
|
|
121
|
+
key: string,
|
|
122
|
+
change: SiteMemberChange,
|
|
123
|
+
): Promise<Result<{ key: string }, 400 | 403 | 404 | 422>>
|
|
124
|
+
addToGroups(key: string, groups: readonly string[]): Promise<Result<{ key: string }, 403 | 404>>
|
|
125
|
+
removeFromGroups(
|
|
126
|
+
key: string,
|
|
127
|
+
groups: readonly string[],
|
|
128
|
+
): Promise<Result<{ key: string }, 403 | 404>>
|
|
129
|
+
/** For good: members have no recycle bin. Never as the member themselves. */
|
|
130
|
+
delete(key: string): Promise<Result<{ key: string }, 403 | 404>>
|
|
65
131
|
}
|
|
66
132
|
|
|
67
133
|
/** A background job as the site's code reads it (story 187). */
|