@dereekb/model 13.11.14 → 13.11.16
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/index.cjs.js +169 -148
- package/index.esm.js +169 -148
- package/package.json +2 -2
- package/src/lib/data/website/link.d.ts +2 -2
- package/src/lib/data/website/link.file.d.ts +8 -8
- package/src/lib/data/website/link.website.d.ts +54 -54
- package/src/lib/service/permission/permission.d.ts +10 -10
- package/src/lib/service/permission/role.d.ts +13 -13
- package/src/lib/service/sync/sync.entity.d.ts +6 -4
- package/src/lib/service/sync/sync.entity.synchronizer.basic.d.ts +6 -5
- package/src/lib/service/sync/sync.entity.synchronizer.d.ts +3 -3
- package/src/lib/transform/transform.d.ts +7 -6
- package/src/lib/transform/transform.function.d.ts +6 -4
- package/src/lib/transform/transform.result.d.ts +3 -2
- package/src/lib/type/type.d.ts +3 -3
- package/src/lib/validator/unique.d.ts +2 -2
package/package.json
CHANGED
|
@@ -18,8 +18,8 @@ export declare const WEBSITE_LINK_TYPE_REGEX: RegExp;
|
|
|
18
18
|
/**
|
|
19
19
|
* Checks whether the given string is a valid {@link WebsiteLinkType}.
|
|
20
20
|
*
|
|
21
|
-
* @param input - the
|
|
22
|
-
* @returns
|
|
21
|
+
* @param input - Value to test against the website link type pattern.
|
|
22
|
+
* @returns True if it matches the alphanumeric 1-32 character pattern.
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```typescript
|
|
@@ -100,8 +100,8 @@ export declare const WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = "f";
|
|
|
100
100
|
/**
|
|
101
101
|
* Converts a {@link WebsiteFileLink} to a {@link WebsiteLink} by encoding its fields into the data string.
|
|
102
102
|
*
|
|
103
|
-
* @param input -
|
|
104
|
-
* @returns
|
|
103
|
+
* @param input - The file link to convert.
|
|
104
|
+
* @returns A WebsiteLink with type "f" and pipe-encoded data.
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
107
|
* ```typescript
|
|
@@ -114,8 +114,8 @@ export declare function websiteFileLinkToWebsiteLink(input: WebsiteFileLink): We
|
|
|
114
114
|
/**
|
|
115
115
|
* Converts a {@link WebsiteLink} back to a {@link WebsiteFileLink} by decoding the pipe-separated data string.
|
|
116
116
|
*
|
|
117
|
-
* @param input -
|
|
118
|
-
* @returns
|
|
117
|
+
* @param input - A WebsiteLink whose data field contains an encoded file link.
|
|
118
|
+
* @returns The decoded file link with type, MIME, name, and data fields.
|
|
119
119
|
*
|
|
120
120
|
* @example
|
|
121
121
|
* ```typescript
|
|
@@ -134,8 +134,8 @@ export declare const WEBSITE_FILE_LINK_ENCODE_SEPARATOR = "|";
|
|
|
134
134
|
*
|
|
135
135
|
* Fields are encoded in order: type, MIME, data, name. Empty/undefined fields become empty strings.
|
|
136
136
|
*
|
|
137
|
-
* @param input -
|
|
138
|
-
* @returns
|
|
137
|
+
* @param input - The file link to encode.
|
|
138
|
+
* @returns A pipe-separated encoded string.
|
|
139
139
|
*
|
|
140
140
|
* @example
|
|
141
141
|
* ```typescript
|
|
@@ -154,8 +154,8 @@ export declare function encodeWebsiteFileLinkToWebsiteLinkEncodedData(input: Web
|
|
|
154
154
|
*
|
|
155
155
|
* Empty fields in the encoded string are omitted from the result (falsy values are filtered out).
|
|
156
156
|
*
|
|
157
|
-
* @param input -
|
|
158
|
-
* @returns
|
|
157
|
+
* @param input - The pipe-separated encoded string.
|
|
158
|
+
* @returns The decoded file link.
|
|
159
159
|
*
|
|
160
160
|
* @example
|
|
161
161
|
* ```typescript
|
|
@@ -18,9 +18,9 @@ export declare const WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID: IsolateWebsitePat
|
|
|
18
18
|
*
|
|
19
19
|
* Optionally prepends a prefix (e.g., "@" for TikTok, "$" for Cash App).
|
|
20
20
|
*
|
|
21
|
-
* @param input -
|
|
22
|
-
* @param prefix -
|
|
23
|
-
* @returns
|
|
21
|
+
* @param input - A username or full profile URL.
|
|
22
|
+
* @param prefix - Optional prefix to prepend to the extracted username.
|
|
23
|
+
* @returns The isolated username, optionally prefixed.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
@@ -37,9 +37,9 @@ export declare function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input:
|
|
|
37
37
|
*
|
|
38
38
|
* Used for platforms with non-standard URL patterns (e.g., Snapchat's `/add/{username}`, YouTube's `/c/{username}`).
|
|
39
39
|
*
|
|
40
|
-
* @param input -
|
|
41
|
-
* @param isolateFn -
|
|
42
|
-
* @returns
|
|
40
|
+
* @param input - A username or full profile URL.
|
|
41
|
+
* @param isolateFn - Custom function that extracts the relevant path segment from the URL.
|
|
42
|
+
* @returns The isolated username.
|
|
43
43
|
*/
|
|
44
44
|
export declare function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input: ModelKey | WebsiteUrl, isolateFn: IsolateWebsitePathFunction): string;
|
|
45
45
|
/**
|
|
@@ -47,8 +47,8 @@ export declare function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(i
|
|
|
47
47
|
*
|
|
48
48
|
* If the input has a website domain, it is returned as-is. Otherwise, it is treated as a path and converted to an absolute slash path.
|
|
49
49
|
*
|
|
50
|
-
* @param input -
|
|
51
|
-
* @returns
|
|
50
|
+
* @param input - A username or website URL.
|
|
51
|
+
* @returns A normalized website URL.
|
|
52
52
|
*/
|
|
53
53
|
export declare function usernameOrWebsiteUrlToWebsiteUrl(input: string): WebsiteUrl;
|
|
54
54
|
/**
|
|
@@ -58,8 +58,8 @@ export declare const WEBSITE_URL_WEBSITE_LINK_TYPE = "w";
|
|
|
58
58
|
/**
|
|
59
59
|
* Converts a generic website URL into a {@link WebsiteLink}, stripping the HTTP/HTTPS protocol.
|
|
60
60
|
*
|
|
61
|
-
* @param input -
|
|
62
|
-
* @returns
|
|
61
|
+
* @param input - The full website URL.
|
|
62
|
+
* @returns A WebsiteLink with the protocol removed from the data.
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* ```typescript
|
|
@@ -75,8 +75,8 @@ export declare const EMAIL_URL_WEBSITE_LINK_TYPE = "e";
|
|
|
75
75
|
/**
|
|
76
76
|
* Converts an email address into a {@link WebsiteLink}.
|
|
77
77
|
*
|
|
78
|
-
* @param input -
|
|
79
|
-
* @returns
|
|
78
|
+
* @param input - The email address.
|
|
79
|
+
* @returns A WebsiteLink storing the email as data.
|
|
80
80
|
*/
|
|
81
81
|
export declare function emailAddressToWebsiteLink(input: EmailAddress): WebsiteLink;
|
|
82
82
|
/**
|
|
@@ -86,8 +86,8 @@ export declare const PHONE_URL_WEBSITE_LINK_TYPE = "p";
|
|
|
86
86
|
/**
|
|
87
87
|
* Converts an E.164 phone number into a {@link WebsiteLink}.
|
|
88
88
|
*
|
|
89
|
-
* @param input -
|
|
90
|
-
* @returns
|
|
89
|
+
* @param input - The phone number in E.164 format.
|
|
90
|
+
* @returns A WebsiteLink storing the phone number as data.
|
|
91
91
|
*/
|
|
92
92
|
export declare function phoneNumberToWebsiteLink(input: E164PhoneNumber): WebsiteLink;
|
|
93
93
|
/**
|
|
@@ -115,8 +115,8 @@ export type FacebookWebsiteLinkType = typeof FACEBOOK_WEBSITE_LINK_TYPE;
|
|
|
115
115
|
*
|
|
116
116
|
* Accepts either a raw username or a full Facebook profile URL.
|
|
117
117
|
*
|
|
118
|
-
* @param input -
|
|
119
|
-
* @returns
|
|
118
|
+
* @param input - A Facebook profile ID or full profile URL.
|
|
119
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
120
120
|
*
|
|
121
121
|
* @example
|
|
122
122
|
* ```typescript
|
|
@@ -131,8 +131,8 @@ export declare function facebookProfileUrlToWebsiteLink(input: FacebookProfileId
|
|
|
131
131
|
/**
|
|
132
132
|
* Constructs a full Facebook profile URL from a profile ID.
|
|
133
133
|
*
|
|
134
|
-
* @param profileId -
|
|
135
|
-
* @returns
|
|
134
|
+
* @param profileId - The Facebook profile ID or username.
|
|
135
|
+
* @returns The full profile URL.
|
|
136
136
|
*/
|
|
137
137
|
export declare function facebookProfileUrl<P extends FacebookProfileId>(profileId: P): FacebookProfileUrl<P>;
|
|
138
138
|
/**
|
|
@@ -158,15 +158,15 @@ export type InstagramWebsiteLinkType = typeof INSTAGRAM_WEBSITE_LINK_TYPE;
|
|
|
158
158
|
/**
|
|
159
159
|
* Converts an Instagram profile ID or URL into a {@link WebsiteLink}.
|
|
160
160
|
*
|
|
161
|
-
* @param input -
|
|
162
|
-
* @returns
|
|
161
|
+
* @param input - An Instagram username or full profile URL.
|
|
162
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
163
163
|
*/
|
|
164
164
|
export declare function instagramProfileUrlToWebsiteLink(input: InstagramProfileId | WebsiteUrl): WebsiteLink;
|
|
165
165
|
/**
|
|
166
166
|
* Constructs a full Instagram profile URL from a profile ID.
|
|
167
167
|
*
|
|
168
|
-
* @param profileId -
|
|
169
|
-
* @returns
|
|
168
|
+
* @param profileId - The Instagram username.
|
|
169
|
+
* @returns The full profile URL.
|
|
170
170
|
*/
|
|
171
171
|
export declare function instagramProfileUrl<P extends InstagramProfileId>(profileId: P): InstagramProfileUrl<P>;
|
|
172
172
|
/**
|
|
@@ -192,15 +192,15 @@ export type TwitterWebsiteLinkType = typeof TWITTER_WEBSITE_LINK_TYPE;
|
|
|
192
192
|
/**
|
|
193
193
|
* Converts a Twitter profile ID or URL into a {@link WebsiteLink}.
|
|
194
194
|
*
|
|
195
|
-
* @param input -
|
|
196
|
-
* @returns
|
|
195
|
+
* @param input - A Twitter username or full profile URL.
|
|
196
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
197
197
|
*/
|
|
198
198
|
export declare function twitterProfileUrlToWebsiteLink(input: TwitterProfileId | WebsiteUrl): WebsiteLink;
|
|
199
199
|
/**
|
|
200
200
|
* Constructs a full Twitter profile URL from a profile ID.
|
|
201
201
|
*
|
|
202
|
-
* @param profileId -
|
|
203
|
-
* @returns
|
|
202
|
+
* @param profileId - The Twitter username.
|
|
203
|
+
* @returns The full profile URL.
|
|
204
204
|
*/
|
|
205
205
|
export declare function twitterProfileUrl<P extends TwitterProfileId>(profileId: P): TwitterProfileUrl<P>;
|
|
206
206
|
/**
|
|
@@ -232,15 +232,15 @@ export type TikTokWebsiteLinkType = typeof TIKTOK_WEBSITE_LINK_TYPE;
|
|
|
232
232
|
*
|
|
233
233
|
* Automatically prepends the "@" prefix if not already present.
|
|
234
234
|
*
|
|
235
|
-
* @param input -
|
|
236
|
-
* @returns
|
|
235
|
+
* @param input - A TikTok username (with or without "@") or full profile URL.
|
|
236
|
+
* @returns A WebsiteLink with the "@"-prefixed username as data.
|
|
237
237
|
*/
|
|
238
238
|
export declare function tiktokProfileUrlToWebsiteLink(input: TikTokProfileId | WebsiteUrl): WebsiteLink;
|
|
239
239
|
/**
|
|
240
240
|
* Constructs a full TikTok profile URL from a profile ID.
|
|
241
241
|
*
|
|
242
|
-
* @param profileId -
|
|
243
|
-
* @returns
|
|
242
|
+
* @param profileId - The TikTok username (without "@" prefix)
|
|
243
|
+
* @returns The full profile URL with "@" prefix.
|
|
244
244
|
*/
|
|
245
245
|
export declare function tiktokProfileUrl<P extends TikTokProfileId>(profileId: P): TikTokProfileUrl<P>;
|
|
246
246
|
/**
|
|
@@ -272,15 +272,15 @@ export declare const SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePat
|
|
|
272
272
|
*
|
|
273
273
|
* Handles Snapchat's `/add/{username}` URL pattern.
|
|
274
274
|
*
|
|
275
|
-
* @param input -
|
|
276
|
-
* @returns
|
|
275
|
+
* @param input - A Snapchat username or full profile URL.
|
|
276
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
277
277
|
*/
|
|
278
278
|
export declare function snapchatProfileUrlToWebsiteLink(input: SnapchatProfileId | WebsiteUrl): WebsiteLink;
|
|
279
279
|
/**
|
|
280
280
|
* Constructs a full Snapchat profile URL from a profile ID.
|
|
281
281
|
*
|
|
282
|
-
* @param profileId -
|
|
283
|
-
* @returns
|
|
282
|
+
* @param profileId - The Snapchat username.
|
|
283
|
+
* @returns The full profile URL with `/add/` path.
|
|
284
284
|
*/
|
|
285
285
|
export declare function snapchatProfileUrl<P extends SnapchatProfileId>(profileId: P): SnapchatProfileUrl<P>;
|
|
286
286
|
/**
|
|
@@ -312,15 +312,15 @@ export declare const YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePath
|
|
|
312
312
|
*
|
|
313
313
|
* Handles YouTube's `/c/{channel}` URL pattern.
|
|
314
314
|
*
|
|
315
|
-
* @param input -
|
|
316
|
-
* @returns
|
|
315
|
+
* @param input - A YouTube channel name or full channel URL.
|
|
316
|
+
* @returns A WebsiteLink with the isolated channel name as data.
|
|
317
317
|
*/
|
|
318
318
|
export declare function youtubeProfileUrlToWebsiteLink(input: YouTubeProfileId | WebsiteUrl): WebsiteLink;
|
|
319
319
|
/**
|
|
320
320
|
* Constructs a full YouTube channel URL from a profile ID.
|
|
321
321
|
*
|
|
322
|
-
* @param profileId -
|
|
323
|
-
* @returns
|
|
322
|
+
* @param profileId - The YouTube channel name.
|
|
323
|
+
* @returns The full channel URL with `/c/` path.
|
|
324
324
|
*/
|
|
325
325
|
export declare function youtubeProfileUrl<P extends YouTubeProfileId>(profileId: P): YouTubeProfileUrl<P>;
|
|
326
326
|
/**
|
|
@@ -346,15 +346,15 @@ export type PayPalWebsiteLinkType = typeof PAYPAL_WEBSITE_LINK_TYPE;
|
|
|
346
346
|
/**
|
|
347
347
|
* Converts a PayPal profile ID or URL into a {@link WebsiteLink}.
|
|
348
348
|
*
|
|
349
|
-
* @param input -
|
|
350
|
-
* @returns
|
|
349
|
+
* @param input - A PayPal username or full PayPal.me URL.
|
|
350
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
351
351
|
*/
|
|
352
352
|
export declare function paypalProfileUrlToWebsiteLink(input: PayPalProfileId | WebsiteUrl): WebsiteLink;
|
|
353
353
|
/**
|
|
354
354
|
* Constructs a full PayPal.me profile URL from a profile ID.
|
|
355
355
|
*
|
|
356
|
-
* @param profileId -
|
|
357
|
-
* @returns
|
|
356
|
+
* @param profileId - The PayPal username.
|
|
357
|
+
* @returns The full PayPal.me URL.
|
|
358
358
|
*/
|
|
359
359
|
export declare function paypalProfileUrl<P extends PayPalProfileId>(profileId: P): PayPalProfileUrl<P>;
|
|
360
360
|
/**
|
|
@@ -386,15 +386,15 @@ export type CashappWebsiteLinkType = typeof CASHAPP_WEBSITE_LINK_TYPE;
|
|
|
386
386
|
*
|
|
387
387
|
* Automatically prepends the "$" prefix if not already present.
|
|
388
388
|
*
|
|
389
|
-
* @param input -
|
|
390
|
-
* @returns
|
|
389
|
+
* @param input - A Cash App username (with or without "$") or full profile URL.
|
|
390
|
+
* @returns A WebsiteLink with the "$"-prefixed username as data.
|
|
391
391
|
*/
|
|
392
392
|
export declare function cashappProfileUrlToWebsiteLink(input: CashappProfileId | WebsiteUrl): WebsiteLink;
|
|
393
393
|
/**
|
|
394
394
|
* Constructs a full Cash App profile URL from a profile ID.
|
|
395
395
|
*
|
|
396
|
-
* @param profileId -
|
|
397
|
-
* @returns
|
|
396
|
+
* @param profileId - The Cash App username (without "$" prefix)
|
|
397
|
+
* @returns The full Cash App URL with "$" prefix.
|
|
398
398
|
*/
|
|
399
399
|
export declare function cashappProfileUrl<P extends CashappProfileId>(profileId: P): CashappProfileUrl<P>;
|
|
400
400
|
/**
|
|
@@ -426,15 +426,15 @@ export declare const VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePathFu
|
|
|
426
426
|
*
|
|
427
427
|
* Handles Venmo's `/u/{username}` URL pattern.
|
|
428
428
|
*
|
|
429
|
-
* @param input -
|
|
430
|
-
* @returns
|
|
429
|
+
* @param input - A Venmo username or full profile URL.
|
|
430
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
431
431
|
*/
|
|
432
432
|
export declare function venmoProfileUrlToWebsiteLink(input: VenmoProfileId | WebsiteUrl): WebsiteLink;
|
|
433
433
|
/**
|
|
434
434
|
* Constructs a full Venmo profile URL from a profile ID.
|
|
435
435
|
*
|
|
436
|
-
* @param profileId -
|
|
437
|
-
* @returns
|
|
436
|
+
* @param profileId - The Venmo username.
|
|
437
|
+
* @returns The full profile URL with `/u/` path.
|
|
438
438
|
*/
|
|
439
439
|
export declare function venmoProfileUrl<P extends VenmoProfileId>(profileId: P): VenmoProfileUrl<P>;
|
|
440
440
|
/**
|
|
@@ -466,14 +466,14 @@ export declare const SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePath
|
|
|
466
466
|
*
|
|
467
467
|
* Handles Spotify's `/user/{username}` URL pattern.
|
|
468
468
|
*
|
|
469
|
-
* @param input -
|
|
470
|
-
* @returns
|
|
469
|
+
* @param input - A Spotify username or full profile URL.
|
|
470
|
+
* @returns A WebsiteLink with the isolated username as data.
|
|
471
471
|
*/
|
|
472
472
|
export declare function spotifyProfileUrlToWebsiteLink(input: SpotifyProfileId | WebsiteUrl): WebsiteLink;
|
|
473
473
|
/**
|
|
474
474
|
* Constructs a full Spotify profile URL from a profile ID.
|
|
475
475
|
*
|
|
476
|
-
* @param profileId -
|
|
477
|
-
* @returns
|
|
476
|
+
* @param profileId - The Spotify username.
|
|
477
|
+
* @returns The full profile URL with `/user/` path.
|
|
478
478
|
*/
|
|
479
479
|
export declare function spotifyProfileUrl<P extends SpotifyProfileId>(profileId: P): SpotifyProfileUrl<P>;
|
|
@@ -13,9 +13,9 @@ export interface ContextGrantedModelRoles<O, C = unknown, R extends string = str
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a {@link ContextGrantedModelRoles} with a no-access role map, indicating the context has no permissions.
|
|
15
15
|
*
|
|
16
|
-
* @param context -
|
|
17
|
-
* @param data -
|
|
18
|
-
* @returns
|
|
16
|
+
* @param context - The context that was evaluated.
|
|
17
|
+
* @param data - Optional model data, if it was loaded.
|
|
18
|
+
* @returns A ContextGrantedModelRoles with no access.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```typescript
|
|
@@ -27,9 +27,9 @@ export declare function noAccessContextGrantedModelRoles<O, C = unknown, R exten
|
|
|
27
27
|
/**
|
|
28
28
|
* Creates a {@link ContextGrantedModelRoles} with a full-access role map, granting all permissions.
|
|
29
29
|
*
|
|
30
|
-
* @param context -
|
|
31
|
-
* @param data -
|
|
32
|
-
* @returns
|
|
30
|
+
* @param context - The context that was evaluated.
|
|
31
|
+
* @param data - Optional model data.
|
|
32
|
+
* @returns A ContextGrantedModelRoles with full access.
|
|
33
33
|
*
|
|
34
34
|
* @example
|
|
35
35
|
* ```typescript
|
|
@@ -41,9 +41,9 @@ export declare function fullAccessGrantedModelRoles<O, C = unknown, R extends st
|
|
|
41
41
|
/**
|
|
42
42
|
* Creates a {@link ContextGrantedModelRoles} with the given role map, data, and context.
|
|
43
43
|
*
|
|
44
|
-
* @param context -
|
|
45
|
-
* @param data -
|
|
46
|
-
* @param roles -
|
|
47
|
-
* @returns
|
|
44
|
+
* @param context - The context that was evaluated.
|
|
45
|
+
* @param data - The model data, if loaded.
|
|
46
|
+
* @param roles - The granted role map.
|
|
47
|
+
* @returns A ContextGrantedModelRoles combining all inputs.
|
|
48
48
|
*/
|
|
49
49
|
export declare function contextGrantedModelRoles<O, C = unknown, R extends string = string>(context: C, data: Maybe<O>, roles: GrantedRoleMap<R>): ContextGrantedModelRoles<O, C, R>;
|
|
@@ -26,8 +26,8 @@ export declare const GRANTED_ADMIN_ROLE_KEY = "admin";
|
|
|
26
26
|
/**
|
|
27
27
|
* Checks whether the given role represents an admin-level permission (either "admin" or "owner").
|
|
28
28
|
*
|
|
29
|
-
* @param role -
|
|
30
|
-
* @returns
|
|
29
|
+
* @param role - The role to check.
|
|
30
|
+
* @returns True if the role is an admin or owner role.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
@@ -66,7 +66,7 @@ export type NoAccessRoleMap = {
|
|
|
66
66
|
/**
|
|
67
67
|
* Creates a {@link GrantedRoleMap} that explicitly denies all access.
|
|
68
68
|
*
|
|
69
|
-
* @returns
|
|
69
|
+
* @returns A role map with only the no-access marker set.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
@@ -78,8 +78,8 @@ export declare function noAccessRoleMap<R extends string = string>(): GrantedRol
|
|
|
78
78
|
/**
|
|
79
79
|
* Type guard that checks whether a role map is a no-access map.
|
|
80
80
|
*
|
|
81
|
-
* @param input -
|
|
82
|
-
* @returns
|
|
81
|
+
* @param input - The role map to check.
|
|
82
|
+
* @returns True if the map has the no-access marker.
|
|
83
83
|
*/
|
|
84
84
|
export declare function isNoAccessRoleMap<R extends string = string>(input: GrantedRoleMap<R> | NoAccessRoleMap): input is NoAccessRoleMap;
|
|
85
85
|
export type FullAccessRoleMap = {
|
|
@@ -88,7 +88,7 @@ export type FullAccessRoleMap = {
|
|
|
88
88
|
/**
|
|
89
89
|
* Creates a {@link GrantedRoleMap} that grants full access to all roles.
|
|
90
90
|
*
|
|
91
|
-
* @returns
|
|
91
|
+
* @returns A role map with the full-access marker set.
|
|
92
92
|
*
|
|
93
93
|
* @example
|
|
94
94
|
* ```typescript
|
|
@@ -100,8 +100,8 @@ export declare function fullAccessRoleMap<R extends string = string>(): GrantedR
|
|
|
100
100
|
/**
|
|
101
101
|
* Type guard that checks whether a role map is a full-access map.
|
|
102
102
|
*
|
|
103
|
-
* @param input -
|
|
104
|
-
* @returns
|
|
103
|
+
* @param input - The role map to check.
|
|
104
|
+
* @returns True if the map has the full-access marker.
|
|
105
105
|
*/
|
|
106
106
|
export declare function isFullAccessRoleMap<R extends string = string>(input: GrantedRoleMap<R> | FullAccessRoleMap): input is FullAccessRoleMap;
|
|
107
107
|
export type GrantedRoleMap<R extends GrantedRole = string> = NoAccessRoleMap | FullAccessRoleMap | GrantedRoleKeysMap<R>;
|
|
@@ -153,8 +153,8 @@ export interface GrantedRoleMapReader<R extends GrantedRole = GrantedRole> {
|
|
|
153
153
|
* The reader handles full-access and no-access maps as special cases, and provides methods
|
|
154
154
|
* for checking individual roles or sets of roles.
|
|
155
155
|
*
|
|
156
|
-
* @param map -
|
|
157
|
-
* @returns
|
|
156
|
+
* @param map - The granted role map to read from.
|
|
157
|
+
* @returns A reader instance for querying the map.
|
|
158
158
|
*
|
|
159
159
|
* @example
|
|
160
160
|
* ```typescript
|
|
@@ -182,9 +182,9 @@ export declare class GrantedRoleMapReaderInstance<R extends GrantedRole = string
|
|
|
182
182
|
/**
|
|
183
183
|
* Converts an array of role strings into a {@link GrantedRoleKeysMap} where each role is mapped to the given boolean value.
|
|
184
184
|
*
|
|
185
|
-
* @param roles -
|
|
186
|
-
* @param value -
|
|
187
|
-
* @returns
|
|
185
|
+
* @param roles - Role keys to include in the resulting map.
|
|
186
|
+
* @param value - Truthiness to assign to every role entry (defaults to true).
|
|
187
|
+
* @returns Map keyed by role with the supplied truthiness for each entry.
|
|
188
188
|
*
|
|
189
189
|
* @example
|
|
190
190
|
* ```typescript
|
|
@@ -44,8 +44,8 @@ export type SyncEntityCommonTypeIdPairFactory = (input: SyncEntityCommonTypeIdPa
|
|
|
44
44
|
* If the input is a string, it is treated as a commonId and paired with the given commonType.
|
|
45
45
|
* If the input is already a pair, it is returned as-is.
|
|
46
46
|
*
|
|
47
|
-
* @param commonType -
|
|
48
|
-
* @returns
|
|
47
|
+
* @param commonType - The default common type to use when input is a plain string.
|
|
48
|
+
* @returns A factory function that produces SyncEntityCommonTypeIdPair instances.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```typescript
|
|
@@ -53,6 +53,7 @@ export type SyncEntityCommonTypeIdPairFactory = (input: SyncEntityCommonTypeIdPa
|
|
|
53
53
|
* factory('abc123'); // { commonType: 'user', commonId: 'abc123' }
|
|
54
54
|
* factory({ commonType: 'user', commonId: 'abc123' }); // passed through as-is
|
|
55
55
|
* ```
|
|
56
|
+
*
|
|
56
57
|
* @__NO_SIDE_EFFECTS__
|
|
57
58
|
*/
|
|
58
59
|
export declare function syncEntityCommonTypeIdPairFactory(commonType: SyncEntityCommonType): SyncEntityCommonTypeIdPairFactory;
|
|
@@ -92,8 +93,8 @@ export type SyncEntityFactory = FactoryWithRequiredInput<SyncEntity, SyncEntityC
|
|
|
92
93
|
* The factory attaches the configured source info and optionally transforms the commonId into an entity id
|
|
93
94
|
* using the provided idFactory (defaults to identity).
|
|
94
95
|
*
|
|
95
|
-
* @param config -
|
|
96
|
-
* @returns
|
|
96
|
+
* @param config - Source info and optional id factory.
|
|
97
|
+
* @returns A factory that creates SyncEntity instances.
|
|
97
98
|
*
|
|
98
99
|
* @example
|
|
99
100
|
* ```typescript
|
|
@@ -104,6 +105,7 @@ export type SyncEntityFactory = FactoryWithRequiredInput<SyncEntity, SyncEntityC
|
|
|
104
105
|
* const entity = factory({ commonType: 'user', commonId: 'abc123' });
|
|
105
106
|
* // entity.id === 'abc123', entity.sourceInfo.id === 'api'
|
|
106
107
|
* ```
|
|
108
|
+
*
|
|
107
109
|
* @__NO_SIDE_EFFECTS__
|
|
108
110
|
*/
|
|
109
111
|
export declare function syncEntityFactory(config: SyncEntityFactoryConfig): SyncEntityFactory;
|
|
@@ -123,11 +123,12 @@ export interface BasicSyncEntityCommonTypeSynchronizerConfig {
|
|
|
123
123
|
* 2. Secondary sources are synchronized sequentially; if a secondary reports deletion while primary did not, the sync restarts once.
|
|
124
124
|
* 3. Replica sources are synchronized concurrently (up to 3 in parallel).
|
|
125
125
|
*
|
|
126
|
-
* @param config -
|
|
127
|
-
* @returns
|
|
128
|
-
* @throws {NoPrimarySyncSourceError}
|
|
129
|
-
* @throws {MultiplePrimarySyncSourceError}
|
|
130
|
-
* @throws {SynchronizationFailedError}
|
|
126
|
+
* @param config - Common type, sources, and context loader.
|
|
127
|
+
* @returns A synchronizer for the configured common type.
|
|
128
|
+
* @throws {NoPrimarySyncSourceError} When no primary source is found.
|
|
129
|
+
* @throws {MultiplePrimarySyncSourceError} When more than one primary source is found.
|
|
130
|
+
* @throws {SynchronizationFailedError} When primary or secondary sync returns failed/error.
|
|
131
|
+
*
|
|
131
132
|
* @__NO_SIDE_EFFECTS__
|
|
132
133
|
*/
|
|
133
134
|
export declare function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config: BasicSyncEntityCommonTypeSynchronizerConfig): BasicSyncEntityCommonTypeSynchronizer;
|
|
@@ -56,9 +56,9 @@ export interface SyncEntitySynchronizerConfig {
|
|
|
56
56
|
* Registers common type synchronizers and provides lookup by common type. Throws
|
|
57
57
|
* {@link UnregisteredSyncEntityCommonTypeError} if an unregistered common type is requested.
|
|
58
58
|
*
|
|
59
|
-
* @param config -
|
|
60
|
-
* @returns
|
|
61
|
-
* @throws {UnregisteredSyncEntityCommonTypeError}
|
|
59
|
+
* @param config - Contains the list of common type synchronizers to register.
|
|
60
|
+
* @returns A synchronizer that delegates to the appropriate common type synchronizer.
|
|
61
|
+
* @throws {UnregisteredSyncEntityCommonTypeError} When requesting an unregistered common type.
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
64
64
|
* ```typescript
|
|
@@ -16,8 +16,8 @@ export interface TransformAndValidateObject<T extends object, O, C = unknown> ex
|
|
|
16
16
|
*
|
|
17
17
|
* On validation success, calls the configured handler function. On validation failure, delegates to the error handler.
|
|
18
18
|
*
|
|
19
|
-
* @param config -
|
|
20
|
-
* @returns
|
|
19
|
+
* @param config - Schema, handler function, and validation error handler.
|
|
20
|
+
* @returns Wrapped function that runs validation then either invokes the handler or routes failures to the error handler.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
@@ -47,8 +47,9 @@ export type TransformAndValidateObjectFactory<C = unknown> = <T extends object,
|
|
|
47
47
|
* The factory pre-configures error handling so individual function calls
|
|
48
48
|
* only need to specify the schema and handler.
|
|
49
49
|
*
|
|
50
|
-
* @param defaults -
|
|
51
|
-
* @returns
|
|
50
|
+
* @param defaults - Default error handler.
|
|
51
|
+
* @returns A factory function that creates TransformAndValidateObjectFunction instances.
|
|
52
|
+
*
|
|
52
53
|
* @__NO_SIDE_EFFECTS__
|
|
53
54
|
*/
|
|
54
55
|
export declare function transformAndValidateObjectFactory<C = unknown>(defaults: TransformAndValidateObjectFactoryDefaults<C>): TransformAndValidateObjectFactory<C>;
|
|
@@ -73,8 +74,8 @@ export interface TransformAndValidateObjectResultFunctionConfig<T extends object
|
|
|
73
74
|
* Returns `{ success: true, object, result }` on valid input, or `{ success: false, validationErrors }` on failure.
|
|
74
75
|
* The caller is responsible for handling the error case.
|
|
75
76
|
*
|
|
76
|
-
* @param config -
|
|
77
|
-
* @returns
|
|
77
|
+
* @param config - Schema and handler function.
|
|
78
|
+
* @returns Wrapped function that yields a discriminated result so the caller can branch on success or validation failure.
|
|
78
79
|
*
|
|
79
80
|
* @example
|
|
80
81
|
* ```typescript
|
|
@@ -12,8 +12,9 @@ export type TransformAndValidateFunctionResultFactory<C = unknown> = <T extends
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a factory for transform-and-validate functions that return the result with the parsed object attached as `params`.
|
|
14
14
|
*
|
|
15
|
-
* @param defaults -
|
|
16
|
-
* @returns
|
|
15
|
+
* @param defaults - Shared error handler defaults.
|
|
16
|
+
* @returns A factory that produces functions returning {@link TransformAndValidateFunctionResult}
|
|
17
|
+
*
|
|
17
18
|
* @__NO_SIDE_EFFECTS__
|
|
18
19
|
*/
|
|
19
20
|
export declare function transformAndValidateFunctionResultFactory<C = unknown>(defaults: TransformAndValidateObjectFactoryDefaults<C>): TransformAndValidateFunctionResultFactory<C>;
|
|
@@ -21,8 +22,9 @@ export declare function transformAndValidateFunctionResultFactory<C = unknown>(d
|
|
|
21
22
|
* Wraps an existing {@link TransformAndValidateObjectFactory} to produce functions that attach the parsed object
|
|
22
23
|
* as `params` on the result.
|
|
23
24
|
*
|
|
24
|
-
* @param transformAndValidateObjectFactory -
|
|
25
|
-
* @returns
|
|
25
|
+
* @param transformAndValidateObjectFactory - The base factory to wrap.
|
|
26
|
+
* @returns A factory that produces functions returning results with `params` attached.
|
|
27
|
+
*
|
|
26
28
|
* @__NO_SIDE_EFFECTS__
|
|
27
29
|
*/
|
|
28
30
|
export declare function toTransformAndValidateFunctionResultFactory<C = unknown>(transformAndValidateObjectFactory: TransformAndValidateObjectFactory<C>): TransformAndValidateFunctionResultFactory<C>;
|
|
@@ -10,8 +10,9 @@ export type TransformAndValidateResultFactory<C = unknown> = <T extends object,
|
|
|
10
10
|
*
|
|
11
11
|
* Useful when you only need the processed output and don't need access to the validated input.
|
|
12
12
|
*
|
|
13
|
-
* @param defaults -
|
|
14
|
-
* @returns
|
|
13
|
+
* @param defaults - Shared error handler defaults.
|
|
14
|
+
* @returns A factory that produces functions returning only the handler's result.
|
|
15
|
+
*
|
|
15
16
|
* @__NO_SIDE_EFFECTS__
|
|
16
17
|
*/
|
|
17
18
|
export declare function transformAndValidateResultFactory<C = unknown>(defaults: TransformAndValidateObjectFactoryDefaults<C>): TransformAndValidateResultFactory<C>;
|
package/src/lib/type/type.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const EMPTY_ARKTYPE_TYPE: Type<{}>;
|
|
|
34
34
|
* Returns the shared {@link EMPTY_ARKTYPE_TYPE} cast to the requested type, providing a typed empty-object schema
|
|
35
35
|
* without creating a new ArkType instance each time.
|
|
36
36
|
*
|
|
37
|
-
* @returns
|
|
37
|
+
* @returns The singleton empty type schema typed as `Type<T>`
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```typescript
|
|
@@ -70,5 +70,5 @@ export declare function emptyType<T = {}>(): Type<T>;
|
|
|
70
70
|
* @param definition The ArkType definition string or Type instance to make clearable.
|
|
71
71
|
* @returns An ArkType schema that accepts the defined type, null, or undefined.
|
|
72
72
|
*/
|
|
73
|
-
export declare function clearable<const def extends string>(definition: def): Type<type.infer<def
|
|
74
|
-
export declare function clearable<T>(definition: Type<T>): Type<T
|
|
73
|
+
export declare function clearable<const def extends string>(definition: def): Type<Maybe<type.infer<def>>>;
|
|
74
|
+
export declare function clearable<T>(definition: Type<T>): Type<Maybe<T>>;
|
|
@@ -2,8 +2,8 @@ import { type ReadKeyFunction } from '@dereekb/util';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates an ArkType schema that validates an array has no duplicate keys.
|
|
4
4
|
*
|
|
5
|
-
* @param readKey -
|
|
6
|
-
* @returns
|
|
5
|
+
* @param readKey - Function that extracts the key from each array element.
|
|
6
|
+
* @returns An ArkType schema that narrows `T[]` to ensure uniqueness.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|