@infinitetoken/lumber-kit 0.5.0 → 0.5.2
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/README.md +11 -0
- package/dist/index.d.mts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +52 -18
- package/dist/index.mjs +46 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,17 @@ import { LogLevel, LogRecord, LogEncrypted, LogPayload, LogsQuery } from '@infin
|
|
|
101
101
|
| `KeyPin` | interface | An account key a user accepted for someone, with its MAC |
|
|
102
102
|
| `HolderKeyCheck`, `ClaimantKeyCheck`, `KeyCheckResult` | interfaces | A key check as the holder and the person being confirmed read it |
|
|
103
103
|
|
|
104
|
+
### Colors
|
|
105
|
+
|
|
106
|
+
| Export | Kind | Purpose |
|
|
107
|
+
|--------|------|---------|
|
|
108
|
+
| `logLevelColors` | object | Each `LogLevel`'s color, as the apps and the CLI draw it |
|
|
109
|
+
| `DEFAULT_ACCENT` | constant | The accent until someone picks their own (their account's `color`): amber `#FBBF24` |
|
|
110
|
+
| `APP_COLORS` | array | The twelve colors `nameColor` picks from |
|
|
111
|
+
| `nameColor` | function | A stable color for a name, ignoring case and surrounding spaces, the same on every device |
|
|
112
|
+
| `resolveAppColor` | function | An app's own color, or its name's |
|
|
113
|
+
| `personColor` | function | Someone else's color, from their user id |
|
|
114
|
+
|
|
104
115
|
### API keys
|
|
105
116
|
|
|
106
117
|
| Export | Kind | Purpose |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/** Each log level's color: its label in the apps' log list, a level's heat on the heatmap, the CLI's level column. */
|
|
2
|
+
declare const logLevelColors: Record<number, string>;
|
|
3
|
+
/** The accent until someone picks their own (their account's `color`): amber, the wordmark's and the icon's. */
|
|
4
|
+
declare const DEFAULT_ACCENT = "#FBBF24";
|
|
5
|
+
/**
|
|
6
|
+
* Colors for an app without one of its own, and for other people, picked by `nameColor`: Tailwind's 500s, roughly
|
|
7
|
+
* evenly spaced around the wheel, vivid and mid-light enough to read on dark and light surfaces.
|
|
8
|
+
*/
|
|
9
|
+
declare const APP_COLORS: readonly ["#EF4444", "#F97316", "#F59E0B", "#84CC16", "#22C55E", "#14B8A6", "#06B6D4", "#3B82F6", "#6366F1", "#8B5CF6", "#D946EF", "#EC4899"];
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Machine-readable reasons the API refuses a request, sent as `code` beside `message` where one status means more than
|
|
3
13
|
* one thing. Messages are for people and may change; clients decide by the code.
|
|
@@ -574,6 +584,8 @@ interface PushToken {
|
|
|
574
584
|
interface NotificationPreference {
|
|
575
585
|
enabled?: boolean;
|
|
576
586
|
minimumLevel?: number;
|
|
587
|
+
/** Whether new notes on this app push, over the account's `notes`; missing follows the account's. */
|
|
588
|
+
notes?: boolean;
|
|
577
589
|
lastReadAt?: string;
|
|
578
590
|
}
|
|
579
591
|
interface NotificationPreferences {
|
|
@@ -608,6 +620,15 @@ interface UserRecord {
|
|
|
608
620
|
declare const isValidAppearance: (value: unknown) => value is Appearance;
|
|
609
621
|
/** Accepts 3- and 6-digit hex color strings (#rgb, #rrggbb). */
|
|
610
622
|
declare const isValidColor: (value: string) => boolean;
|
|
623
|
+
/**
|
|
624
|
+
* One of APP_COLORS for a name, ignoring case and surrounding spaces. Nothing is stored: every device works out the
|
|
625
|
+
* same color.
|
|
626
|
+
*/
|
|
627
|
+
declare const nameColor: (name: string) => string;
|
|
628
|
+
/** An app's color: the one its owner picked, or its name's. */
|
|
629
|
+
declare const resolveAppColor: (name: string, color?: string | null) => string;
|
|
630
|
+
/** Someone else's color, from their user id, since their own accent lives on their account. */
|
|
631
|
+
declare const personColor: (userId: string) => string;
|
|
611
632
|
declare const isValidLogLevel: (value: unknown) => value is LogLevel;
|
|
612
633
|
declare const isValidSubscriptionLevel: (value: unknown) => value is SubscriptionLevel;
|
|
613
634
|
declare const isValidDeviceLinkStatus: (value: unknown) => value is DeviceLinkStatus;
|
|
@@ -636,4 +657,4 @@ declare const apiErrorCodeOf: (body: unknown) => ApiErrorCode | null;
|
|
|
636
657
|
/** A push notification's data as PushData, or null for data no Lumber push sends. */
|
|
637
658
|
declare const parsePushData: (data: unknown) => PushData | null;
|
|
638
659
|
|
|
639
|
-
export { type ApiErrorBody, type ApiErrorCode, type ApiKeyRecord, type ApiResponse, type AppCreatedRecord, type AppEncryptedKey, type AppKeyUpsertBody, type AppPermission, type AppPersonRecord, type AppRecord, type AppTeamAccess, type Appearance, type AppsQuery, type ClaimantKeyCheck, type ClientToServerEvents, DEFAULT_PUSH_THRESHOLD, type DeviceLinkCreatedRecord, type DeviceLinkRecord, type DeviceLinkStatus, type FlagRecord, type FlagsQuery, type GuestRecord, type HolderKeyCheck, type InvitationRecord, type KeyCheckResult, type KeyHolder, type KeyPin, type LogContext, type LogEncrypted, LogLevel, type LogLevelName, type LogPayload, type LogRecord, type LogTimeseriesQuery, type LogsQuery, type NoteEncrypted, type NoteRecord, type NotesQuery, type NotificationPreference, type NotificationPreferences, PUSH_OFF, type PendingAppKey, type PushData, type PushThreshold, type PushToken, type PushType, type ResponseMetadata, type ServerToClientEvents, type SocketAppPayload, SubscriptionLevel, type SubscriptionLevelName, type SubscriptionLimits, type SubscriptionPlan, type SubscriptionPlanRecord, type TeamMemberRecord, type TeamRecord, type TeamsQuery, type TimeseriesBucket, type TimeseriesResponse, type UserRecord, apiErrorCodeOf, apiErrorCodes, isApiErrorCode, isValidAppearance, isValidColor, isValidDeviceLinkStatus, isValidImageUrl, isValidLogLevel, isValidSubscriptionLevel, isValidTeamMemberRole, joinApiKey, logLevelNameToLevel, logLevelToName, logLevels, normalizePushThreshold, parsePushData, splitApiKey, subscriptionLevelToName, subscriptionLevels, subscriptionLimits, subscriptionPlans };
|
|
660
|
+
export { APP_COLORS, type ApiErrorBody, type ApiErrorCode, type ApiKeyRecord, type ApiResponse, type AppCreatedRecord, type AppEncryptedKey, type AppKeyUpsertBody, type AppPermission, type AppPersonRecord, type AppRecord, type AppTeamAccess, type Appearance, type AppsQuery, type ClaimantKeyCheck, type ClientToServerEvents, DEFAULT_ACCENT, DEFAULT_PUSH_THRESHOLD, type DeviceLinkCreatedRecord, type DeviceLinkRecord, type DeviceLinkStatus, type FlagRecord, type FlagsQuery, type GuestRecord, type HolderKeyCheck, type InvitationRecord, type KeyCheckResult, type KeyHolder, type KeyPin, type LogContext, type LogEncrypted, LogLevel, type LogLevelName, type LogPayload, type LogRecord, type LogTimeseriesQuery, type LogsQuery, type NoteEncrypted, type NoteRecord, type NotesQuery, type NotificationPreference, type NotificationPreferences, PUSH_OFF, type PendingAppKey, type PushData, type PushThreshold, type PushToken, type PushType, type ResponseMetadata, type ServerToClientEvents, type SocketAppPayload, SubscriptionLevel, type SubscriptionLevelName, type SubscriptionLimits, type SubscriptionPlan, type SubscriptionPlanRecord, type TeamMemberRecord, type TeamRecord, type TeamsQuery, type TimeseriesBucket, type TimeseriesResponse, type UserRecord, apiErrorCodeOf, apiErrorCodes, isApiErrorCode, isValidAppearance, isValidColor, isValidDeviceLinkStatus, isValidImageUrl, isValidLogLevel, isValidSubscriptionLevel, isValidTeamMemberRole, joinApiKey, logLevelColors, logLevelNameToLevel, logLevelToName, logLevels, nameColor, normalizePushThreshold, parsePushData, personColor, resolveAppColor, splitApiKey, subscriptionLevelToName, subscriptionLevels, subscriptionLimits, subscriptionPlans };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/** Each log level's color: its label in the apps' log list, a level's heat on the heatmap, the CLI's level column. */
|
|
2
|
+
declare const logLevelColors: Record<number, string>;
|
|
3
|
+
/** The accent until someone picks their own (their account's `color`): amber, the wordmark's and the icon's. */
|
|
4
|
+
declare const DEFAULT_ACCENT = "#FBBF24";
|
|
5
|
+
/**
|
|
6
|
+
* Colors for an app without one of its own, and for other people, picked by `nameColor`: Tailwind's 500s, roughly
|
|
7
|
+
* evenly spaced around the wheel, vivid and mid-light enough to read on dark and light surfaces.
|
|
8
|
+
*/
|
|
9
|
+
declare const APP_COLORS: readonly ["#EF4444", "#F97316", "#F59E0B", "#84CC16", "#22C55E", "#14B8A6", "#06B6D4", "#3B82F6", "#6366F1", "#8B5CF6", "#D946EF", "#EC4899"];
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Machine-readable reasons the API refuses a request, sent as `code` beside `message` where one status means more than
|
|
3
13
|
* one thing. Messages are for people and may change; clients decide by the code.
|
|
@@ -574,6 +584,8 @@ interface PushToken {
|
|
|
574
584
|
interface NotificationPreference {
|
|
575
585
|
enabled?: boolean;
|
|
576
586
|
minimumLevel?: number;
|
|
587
|
+
/** Whether new notes on this app push, over the account's `notes`; missing follows the account's. */
|
|
588
|
+
notes?: boolean;
|
|
577
589
|
lastReadAt?: string;
|
|
578
590
|
}
|
|
579
591
|
interface NotificationPreferences {
|
|
@@ -608,6 +620,15 @@ interface UserRecord {
|
|
|
608
620
|
declare const isValidAppearance: (value: unknown) => value is Appearance;
|
|
609
621
|
/** Accepts 3- and 6-digit hex color strings (#rgb, #rrggbb). */
|
|
610
622
|
declare const isValidColor: (value: string) => boolean;
|
|
623
|
+
/**
|
|
624
|
+
* One of APP_COLORS for a name, ignoring case and surrounding spaces. Nothing is stored: every device works out the
|
|
625
|
+
* same color.
|
|
626
|
+
*/
|
|
627
|
+
declare const nameColor: (name: string) => string;
|
|
628
|
+
/** An app's color: the one its owner picked, or its name's. */
|
|
629
|
+
declare const resolveAppColor: (name: string, color?: string | null) => string;
|
|
630
|
+
/** Someone else's color, from their user id, since their own accent lives on their account. */
|
|
631
|
+
declare const personColor: (userId: string) => string;
|
|
611
632
|
declare const isValidLogLevel: (value: unknown) => value is LogLevel;
|
|
612
633
|
declare const isValidSubscriptionLevel: (value: unknown) => value is SubscriptionLevel;
|
|
613
634
|
declare const isValidDeviceLinkStatus: (value: unknown) => value is DeviceLinkStatus;
|
|
@@ -636,4 +657,4 @@ declare const apiErrorCodeOf: (body: unknown) => ApiErrorCode | null;
|
|
|
636
657
|
/** A push notification's data as PushData, or null for data no Lumber push sends. */
|
|
637
658
|
declare const parsePushData: (data: unknown) => PushData | null;
|
|
638
659
|
|
|
639
|
-
export { type ApiErrorBody, type ApiErrorCode, type ApiKeyRecord, type ApiResponse, type AppCreatedRecord, type AppEncryptedKey, type AppKeyUpsertBody, type AppPermission, type AppPersonRecord, type AppRecord, type AppTeamAccess, type Appearance, type AppsQuery, type ClaimantKeyCheck, type ClientToServerEvents, DEFAULT_PUSH_THRESHOLD, type DeviceLinkCreatedRecord, type DeviceLinkRecord, type DeviceLinkStatus, type FlagRecord, type FlagsQuery, type GuestRecord, type HolderKeyCheck, type InvitationRecord, type KeyCheckResult, type KeyHolder, type KeyPin, type LogContext, type LogEncrypted, LogLevel, type LogLevelName, type LogPayload, type LogRecord, type LogTimeseriesQuery, type LogsQuery, type NoteEncrypted, type NoteRecord, type NotesQuery, type NotificationPreference, type NotificationPreferences, PUSH_OFF, type PendingAppKey, type PushData, type PushThreshold, type PushToken, type PushType, type ResponseMetadata, type ServerToClientEvents, type SocketAppPayload, SubscriptionLevel, type SubscriptionLevelName, type SubscriptionLimits, type SubscriptionPlan, type SubscriptionPlanRecord, type TeamMemberRecord, type TeamRecord, type TeamsQuery, type TimeseriesBucket, type TimeseriesResponse, type UserRecord, apiErrorCodeOf, apiErrorCodes, isApiErrorCode, isValidAppearance, isValidColor, isValidDeviceLinkStatus, isValidImageUrl, isValidLogLevel, isValidSubscriptionLevel, isValidTeamMemberRole, joinApiKey, logLevelNameToLevel, logLevelToName, logLevels, normalizePushThreshold, parsePushData, splitApiKey, subscriptionLevelToName, subscriptionLevels, subscriptionLimits, subscriptionPlans };
|
|
660
|
+
export { APP_COLORS, type ApiErrorBody, type ApiErrorCode, type ApiKeyRecord, type ApiResponse, type AppCreatedRecord, type AppEncryptedKey, type AppKeyUpsertBody, type AppPermission, type AppPersonRecord, type AppRecord, type AppTeamAccess, type Appearance, type AppsQuery, type ClaimantKeyCheck, type ClientToServerEvents, DEFAULT_ACCENT, DEFAULT_PUSH_THRESHOLD, type DeviceLinkCreatedRecord, type DeviceLinkRecord, type DeviceLinkStatus, type FlagRecord, type FlagsQuery, type GuestRecord, type HolderKeyCheck, type InvitationRecord, type KeyCheckResult, type KeyHolder, type KeyPin, type LogContext, type LogEncrypted, LogLevel, type LogLevelName, type LogPayload, type LogRecord, type LogTimeseriesQuery, type LogsQuery, type NoteEncrypted, type NoteRecord, type NotesQuery, type NotificationPreference, type NotificationPreferences, PUSH_OFF, type PendingAppKey, type PushData, type PushThreshold, type PushToken, type PushType, type ResponseMetadata, type ServerToClientEvents, type SocketAppPayload, SubscriptionLevel, type SubscriptionLevelName, type SubscriptionLimits, type SubscriptionPlan, type SubscriptionPlanRecord, type TeamMemberRecord, type TeamRecord, type TeamsQuery, type TimeseriesBucket, type TimeseriesResponse, type UserRecord, apiErrorCodeOf, apiErrorCodes, isApiErrorCode, isValidAppearance, isValidColor, isValidDeviceLinkStatus, isValidImageUrl, isValidLogLevel, isValidSubscriptionLevel, isValidTeamMemberRole, joinApiKey, logLevelColors, logLevelNameToLevel, logLevelToName, logLevels, nameColor, normalizePushThreshold, parsePushData, personColor, resolveAppColor, splitApiKey, subscriptionLevelToName, subscriptionLevels, subscriptionLimits, subscriptionPlans };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
APP_COLORS: () => APP_COLORS,
|
|
24
|
+
DEFAULT_ACCENT: () => DEFAULT_ACCENT,
|
|
23
25
|
DEFAULT_PUSH_THRESHOLD: () => DEFAULT_PUSH_THRESHOLD,
|
|
24
26
|
LogLevel: () => LogLevel,
|
|
25
27
|
PUSH_OFF: () => PUSH_OFF,
|
|
@@ -35,11 +37,15 @@ __export(index_exports, {
|
|
|
35
37
|
isValidSubscriptionLevel: () => isValidSubscriptionLevel,
|
|
36
38
|
isValidTeamMemberRole: () => isValidTeamMemberRole,
|
|
37
39
|
joinApiKey: () => joinApiKey,
|
|
40
|
+
logLevelColors: () => logLevelColors,
|
|
38
41
|
logLevelNameToLevel: () => logLevelNameToLevel,
|
|
39
42
|
logLevelToName: () => logLevelToName,
|
|
40
43
|
logLevels: () => logLevels,
|
|
44
|
+
nameColor: () => nameColor,
|
|
41
45
|
normalizePushThreshold: () => normalizePushThreshold,
|
|
42
46
|
parsePushData: () => parsePushData,
|
|
47
|
+
personColor: () => personColor,
|
|
48
|
+
resolveAppColor: () => resolveAppColor,
|
|
43
49
|
splitApiKey: () => splitApiKey,
|
|
44
50
|
subscriptionLevelToName: () => subscriptionLevelToName,
|
|
45
51
|
subscriptionLevels: () => subscriptionLevels,
|
|
@@ -48,24 +54,6 @@ __export(index_exports, {
|
|
|
48
54
|
});
|
|
49
55
|
module.exports = __toCommonJS(index_exports);
|
|
50
56
|
|
|
51
|
-
// src/constants/errors.ts
|
|
52
|
-
var apiErrorCodes = [
|
|
53
|
-
/** 403: the team's plan has no room for another app. */
|
|
54
|
-
"APP_LIMIT",
|
|
55
|
-
/** 403: the team's plan has no room for another member (members and live invitations). */
|
|
56
|
-
"SEAT_LIMIT",
|
|
57
|
-
/** 403: the app's team's plan has no room for another guest on it (guests and live invitations). */
|
|
58
|
-
"GUEST_LIMIT",
|
|
59
|
-
/** 409: the person invited is already on the team. */
|
|
60
|
-
"ALREADY_MEMBER",
|
|
61
|
-
/** 409: the person invited can already read the app. */
|
|
62
|
-
"ALREADY_READS",
|
|
63
|
-
/** 409: the address invited already has an open invitation. */
|
|
64
|
-
"ALREADY_INVITED",
|
|
65
|
-
/** 409: the address invited already has an account, so invite the person instead. */
|
|
66
|
-
"HAS_ACCOUNT"
|
|
67
|
-
];
|
|
68
|
-
|
|
69
57
|
// src/constants/logLevel.ts
|
|
70
58
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
71
59
|
LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
|
|
@@ -91,6 +79,35 @@ var logLevelNameToLevel = {
|
|
|
91
79
|
};
|
|
92
80
|
var logLevels = [0 /* Debug */, 1 /* Info */, 2 /* Warn */, 3 /* Error */, 4 /* Fatal */];
|
|
93
81
|
|
|
82
|
+
// src/constants/colors.ts
|
|
83
|
+
var logLevelColors = {
|
|
84
|
+
[0 /* Debug */]: "#737373",
|
|
85
|
+
[1 /* Info */]: "#60A5FA",
|
|
86
|
+
[2 /* Warn */]: "#FBBF24",
|
|
87
|
+
[3 /* Error */]: "#F87171",
|
|
88
|
+
[4 /* Fatal */]: "#E879F9"
|
|
89
|
+
};
|
|
90
|
+
var DEFAULT_ACCENT = "#FBBF24";
|
|
91
|
+
var APP_COLORS = ["#EF4444", "#F97316", "#F59E0B", "#84CC16", "#22C55E", "#14B8A6", "#06B6D4", "#3B82F6", "#6366F1", "#8B5CF6", "#D946EF", "#EC4899"];
|
|
92
|
+
|
|
93
|
+
// src/constants/errors.ts
|
|
94
|
+
var apiErrorCodes = [
|
|
95
|
+
/** 403: the team's plan has no room for another app. */
|
|
96
|
+
"APP_LIMIT",
|
|
97
|
+
/** 403: the team's plan has no room for another member (members and live invitations). */
|
|
98
|
+
"SEAT_LIMIT",
|
|
99
|
+
/** 403: the app's team's plan has no room for another guest on it (guests and live invitations). */
|
|
100
|
+
"GUEST_LIMIT",
|
|
101
|
+
/** 409: the person invited is already on the team. */
|
|
102
|
+
"ALREADY_MEMBER",
|
|
103
|
+
/** 409: the person invited can already read the app. */
|
|
104
|
+
"ALREADY_READS",
|
|
105
|
+
/** 409: the address invited already has an open invitation. */
|
|
106
|
+
"ALREADY_INVITED",
|
|
107
|
+
/** 409: the address invited already has an account, so invite the person instead. */
|
|
108
|
+
"HAS_ACCOUNT"
|
|
109
|
+
];
|
|
110
|
+
|
|
94
111
|
// src/constants/notifications.ts
|
|
95
112
|
var PUSH_OFF = 5;
|
|
96
113
|
var DEFAULT_PUSH_THRESHOLD = 2 /* Warn */;
|
|
@@ -127,6 +144,17 @@ var subscriptionPlans = {
|
|
|
127
144
|
var appearanceValues = ["system", "dark", "light"];
|
|
128
145
|
var isValidAppearance = (value) => appearanceValues.includes(value);
|
|
129
146
|
var isValidColor = (value) => /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);
|
|
147
|
+
var hashName = (name) => {
|
|
148
|
+
let hash = 2166136261;
|
|
149
|
+
for (const char of name.trim().toLowerCase()) {
|
|
150
|
+
hash ^= char.codePointAt(0) ?? 0;
|
|
151
|
+
hash = Math.imul(hash, 16777619);
|
|
152
|
+
}
|
|
153
|
+
return hash >>> 0;
|
|
154
|
+
};
|
|
155
|
+
var nameColor = (name) => APP_COLORS[hashName(name) % APP_COLORS.length];
|
|
156
|
+
var resolveAppColor = (name, color) => color && isValidColor(color) ? color : nameColor(name);
|
|
157
|
+
var personColor = (userId) => nameColor(userId);
|
|
130
158
|
var isValidLogLevel = (value) => logLevels.includes(value);
|
|
131
159
|
var isValidSubscriptionLevel = (value) => subscriptionLevels.includes(value);
|
|
132
160
|
var deviceLinkStatuses = ["pending", "approved", "denied"];
|
|
@@ -184,6 +212,8 @@ var parsePushData = (data) => {
|
|
|
184
212
|
};
|
|
185
213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
214
|
0 && (module.exports = {
|
|
215
|
+
APP_COLORS,
|
|
216
|
+
DEFAULT_ACCENT,
|
|
187
217
|
DEFAULT_PUSH_THRESHOLD,
|
|
188
218
|
LogLevel,
|
|
189
219
|
PUSH_OFF,
|
|
@@ -199,11 +229,15 @@ var parsePushData = (data) => {
|
|
|
199
229
|
isValidSubscriptionLevel,
|
|
200
230
|
isValidTeamMemberRole,
|
|
201
231
|
joinApiKey,
|
|
232
|
+
logLevelColors,
|
|
202
233
|
logLevelNameToLevel,
|
|
203
234
|
logLevelToName,
|
|
204
235
|
logLevels,
|
|
236
|
+
nameColor,
|
|
205
237
|
normalizePushThreshold,
|
|
206
238
|
parsePushData,
|
|
239
|
+
personColor,
|
|
240
|
+
resolveAppColor,
|
|
207
241
|
splitApiKey,
|
|
208
242
|
subscriptionLevelToName,
|
|
209
243
|
subscriptionLevels,
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
// src/constants/errors.ts
|
|
2
|
-
var apiErrorCodes = [
|
|
3
|
-
/** 403: the team's plan has no room for another app. */
|
|
4
|
-
"APP_LIMIT",
|
|
5
|
-
/** 403: the team's plan has no room for another member (members and live invitations). */
|
|
6
|
-
"SEAT_LIMIT",
|
|
7
|
-
/** 403: the app's team's plan has no room for another guest on it (guests and live invitations). */
|
|
8
|
-
"GUEST_LIMIT",
|
|
9
|
-
/** 409: the person invited is already on the team. */
|
|
10
|
-
"ALREADY_MEMBER",
|
|
11
|
-
/** 409: the person invited can already read the app. */
|
|
12
|
-
"ALREADY_READS",
|
|
13
|
-
/** 409: the address invited already has an open invitation. */
|
|
14
|
-
"ALREADY_INVITED",
|
|
15
|
-
/** 409: the address invited already has an account, so invite the person instead. */
|
|
16
|
-
"HAS_ACCOUNT"
|
|
17
|
-
];
|
|
18
|
-
|
|
19
1
|
// src/constants/logLevel.ts
|
|
20
2
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
21
3
|
LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
|
|
@@ -41,6 +23,35 @@ var logLevelNameToLevel = {
|
|
|
41
23
|
};
|
|
42
24
|
var logLevels = [0 /* Debug */, 1 /* Info */, 2 /* Warn */, 3 /* Error */, 4 /* Fatal */];
|
|
43
25
|
|
|
26
|
+
// src/constants/colors.ts
|
|
27
|
+
var logLevelColors = {
|
|
28
|
+
[0 /* Debug */]: "#737373",
|
|
29
|
+
[1 /* Info */]: "#60A5FA",
|
|
30
|
+
[2 /* Warn */]: "#FBBF24",
|
|
31
|
+
[3 /* Error */]: "#F87171",
|
|
32
|
+
[4 /* Fatal */]: "#E879F9"
|
|
33
|
+
};
|
|
34
|
+
var DEFAULT_ACCENT = "#FBBF24";
|
|
35
|
+
var APP_COLORS = ["#EF4444", "#F97316", "#F59E0B", "#84CC16", "#22C55E", "#14B8A6", "#06B6D4", "#3B82F6", "#6366F1", "#8B5CF6", "#D946EF", "#EC4899"];
|
|
36
|
+
|
|
37
|
+
// src/constants/errors.ts
|
|
38
|
+
var apiErrorCodes = [
|
|
39
|
+
/** 403: the team's plan has no room for another app. */
|
|
40
|
+
"APP_LIMIT",
|
|
41
|
+
/** 403: the team's plan has no room for another member (members and live invitations). */
|
|
42
|
+
"SEAT_LIMIT",
|
|
43
|
+
/** 403: the app's team's plan has no room for another guest on it (guests and live invitations). */
|
|
44
|
+
"GUEST_LIMIT",
|
|
45
|
+
/** 409: the person invited is already on the team. */
|
|
46
|
+
"ALREADY_MEMBER",
|
|
47
|
+
/** 409: the person invited can already read the app. */
|
|
48
|
+
"ALREADY_READS",
|
|
49
|
+
/** 409: the address invited already has an open invitation. */
|
|
50
|
+
"ALREADY_INVITED",
|
|
51
|
+
/** 409: the address invited already has an account, so invite the person instead. */
|
|
52
|
+
"HAS_ACCOUNT"
|
|
53
|
+
];
|
|
54
|
+
|
|
44
55
|
// src/constants/notifications.ts
|
|
45
56
|
var PUSH_OFF = 5;
|
|
46
57
|
var DEFAULT_PUSH_THRESHOLD = 2 /* Warn */;
|
|
@@ -77,6 +88,17 @@ var subscriptionPlans = {
|
|
|
77
88
|
var appearanceValues = ["system", "dark", "light"];
|
|
78
89
|
var isValidAppearance = (value) => appearanceValues.includes(value);
|
|
79
90
|
var isValidColor = (value) => /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);
|
|
91
|
+
var hashName = (name) => {
|
|
92
|
+
let hash = 2166136261;
|
|
93
|
+
for (const char of name.trim().toLowerCase()) {
|
|
94
|
+
hash ^= char.codePointAt(0) ?? 0;
|
|
95
|
+
hash = Math.imul(hash, 16777619);
|
|
96
|
+
}
|
|
97
|
+
return hash >>> 0;
|
|
98
|
+
};
|
|
99
|
+
var nameColor = (name) => APP_COLORS[hashName(name) % APP_COLORS.length];
|
|
100
|
+
var resolveAppColor = (name, color) => color && isValidColor(color) ? color : nameColor(name);
|
|
101
|
+
var personColor = (userId) => nameColor(userId);
|
|
80
102
|
var isValidLogLevel = (value) => logLevels.includes(value);
|
|
81
103
|
var isValidSubscriptionLevel = (value) => subscriptionLevels.includes(value);
|
|
82
104
|
var deviceLinkStatuses = ["pending", "approved", "denied"];
|
|
@@ -133,6 +155,8 @@ var parsePushData = (data) => {
|
|
|
133
155
|
}
|
|
134
156
|
};
|
|
135
157
|
export {
|
|
158
|
+
APP_COLORS,
|
|
159
|
+
DEFAULT_ACCENT,
|
|
136
160
|
DEFAULT_PUSH_THRESHOLD,
|
|
137
161
|
LogLevel,
|
|
138
162
|
PUSH_OFF,
|
|
@@ -148,11 +172,15 @@ export {
|
|
|
148
172
|
isValidSubscriptionLevel,
|
|
149
173
|
isValidTeamMemberRole,
|
|
150
174
|
joinApiKey,
|
|
175
|
+
logLevelColors,
|
|
151
176
|
logLevelNameToLevel,
|
|
152
177
|
logLevelToName,
|
|
153
178
|
logLevels,
|
|
179
|
+
nameColor,
|
|
154
180
|
normalizePushThreshold,
|
|
155
181
|
parsePushData,
|
|
182
|
+
personColor,
|
|
183
|
+
resolveAppColor,
|
|
156
184
|
splitApiKey,
|
|
157
185
|
subscriptionLevelToName,
|
|
158
186
|
subscriptionLevels,
|