@openpeepshq/common 0.1.43
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/LICENSE.md +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/adminSections.d.ts +53 -0
- package/dist/lib/adminSections.js +62 -0
- package/dist/lib/attachmentHelpers.d.ts +1 -0
- package/dist/lib/attachmentHelpers.js +13 -0
- package/dist/lib/capabilitiesHelpers.d.ts +118 -0
- package/dist/lib/capabilitiesHelpers.js +238 -0
- package/dist/lib/colors.d.ts +5 -0
- package/dist/lib/colors.js +17 -0
- package/dist/lib/csvHelpers.d.ts +6 -0
- package/dist/lib/csvHelpers.js +17 -0
- package/dist/lib/eventIcs.d.ts +4 -0
- package/dist/lib/eventIcs.js +83 -0
- package/dist/lib/groupHelpers.d.ts +134 -0
- package/dist/lib/groupHelpers.js +216 -0
- package/dist/lib/index.d.ts +17 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/jamHelpers.d.ts +5 -0
- package/dist/lib/jamHelpers.js +37 -0
- package/dist/lib/markdownHelpers.d.ts +1 -0
- package/dist/lib/markdownHelpers.js +24 -0
- package/dist/lib/mediaDimensions.d.ts +19 -0
- package/dist/lib/mediaDimensions.js +19 -0
- package/dist/lib/postHelpers.d.ts +146 -0
- package/dist/lib/postHelpers.js +144 -0
- package/dist/lib/profileHelpers.d.ts +30 -0
- package/dist/lib/profileHelpers.js +75 -0
- package/dist/lib/pushHelpers.d.ts +4 -0
- package/dist/lib/pushHelpers.js +6 -0
- package/dist/lib/scopeHelpers.d.ts +25 -0
- package/dist/lib/scopeHelpers.js +85 -0
- package/dist/lib/text.d.ts +3 -0
- package/dist/lib/text.js +18 -0
- package/dist/lib/tokenHelpers.d.ts +21 -0
- package/dist/lib/tokenHelpers.js +81 -0
- package/dist/lib/utils.d.ts +43 -0
- package/dist/lib/utils.js +200 -0
- package/dist/types/admin-db.d.ts +62 -0
- package/dist/types/admin-db.js +41 -0
- package/dist/types/admin-email.d.ts +39 -0
- package/dist/types/admin-email.js +41 -0
- package/dist/types/admin-jobs.d.ts +15 -0
- package/dist/types/admin-jobs.js +14 -0
- package/dist/types/admin-performance.d.ts +23 -0
- package/dist/types/admin-performance.js +14 -0
- package/dist/types/analytics.d.ts +583 -0
- package/dist/types/analytics.js +213 -0
- package/dist/types/api.d.ts +20076 -0
- package/dist/types/api.js +492 -0
- package/dist/types/apple-app-site-association.d.ts +50 -0
- package/dist/types/apple-app-site-association.js +38 -0
- package/dist/types/auth.d.ts +367 -0
- package/dist/types/auth.js +17 -0
- package/dist/types/capabilities.d.ts +24 -0
- package/dist/types/capabilities.js +144 -0
- package/dist/types/config.d.ts +858 -0
- package/dist/types/config.js +352 -0
- package/dist/types/db.d.ts +8780 -0
- package/dist/types/db.js +65 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +18 -0
- package/dist/types/internal.d.ts +44337 -0
- package/dist/types/internal.js +154 -0
- package/dist/types/models.d.ts +2619 -0
- package/dist/types/models.js +599 -0
- package/dist/types/notifications.d.ts +148 -0
- package/dist/types/notifications.js +40 -0
- package/dist/types/plugins.d.ts +66 -0
- package/dist/types/plugins.js +29 -0
- package/dist/types/stats.d.ts +10216 -0
- package/dist/types/stats.js +109 -0
- package/dist/types/stripe.d.ts +42 -0
- package/dist/types/stripe.js +35 -0
- package/dist/types/utils.d.ts +84 -0
- package/dist/types/utils.js +39 -0
- package/package.json +54 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AudienceSetting, CommunityConfig, GroupData, GroupWithMeta, ProfileSettings, PublicProfile } from '../types';
|
|
2
|
+
export declare const pick: <T, K extends keyof T>(obj: T, ...keys: K[]) => Pick<T, K>;
|
|
3
|
+
export declare const transformKeys: (object: Record<string, unknown>, transform: (name: string) => string) => {
|
|
4
|
+
[k: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const transformValues: <T, V>(object: Record<string | number | symbol, T>, transform: (value: T) => V) => Record<string | number | symbol, V>;
|
|
7
|
+
export declare const decodeBase64ToUint8Array: (value: string) => Uint8Array;
|
|
8
|
+
export declare const decodeBase64UrlToUint8Array: (value: string) => Uint8Array;
|
|
9
|
+
export declare const lowerCaseFirst: (input: string) => string;
|
|
10
|
+
export declare const asyncFilter: <T>(arr: T[], predicate: (e: T) => Promise<boolean>) => Promise<T[]>;
|
|
11
|
+
export declare const passThroughUndefined: <Input, Output>(func: (input: Input) => Output) => (input: Input | undefined) => Output | undefined;
|
|
12
|
+
export declare const countBy: <T, V extends string | number | symbol>(arr: T[], fn: (val: T) => V) => Record<V, number>;
|
|
13
|
+
export declare const groupBy: <T, V extends string | number | symbol>(arr: T[], fn: (val: T) => V) => Record<V, T[]>;
|
|
14
|
+
export declare const dateSorter: <T extends {
|
|
15
|
+
createdAt: string;
|
|
16
|
+
}>() => ((v0: T, v1: T) => number);
|
|
17
|
+
export declare const getUniqueBy: <T, V = string>(arr: T[], predicate: (o: T) => V) => T[];
|
|
18
|
+
export declare const interpolate: (text: string | undefined, params?: Record<string, string>) => any;
|
|
19
|
+
export declare const sleep: (seconds: number) => Promise<void>;
|
|
20
|
+
export declare const deepSet: <T>(obj: T, path: string | (string | number)[], val: unknown) => T;
|
|
21
|
+
export declare const deepGet: (obj: unknown, path: (string | number)[]) => unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a value is valid => not (null, undefined, empty, etc.)
|
|
24
|
+
* Special case: treats 0 as a valid value unlike standard JS truthiness
|
|
25
|
+
*/
|
|
26
|
+
export declare const hasValue: (v: unknown) => boolean;
|
|
27
|
+
export declare const kebabToCamelCase: (str: string) => string;
|
|
28
|
+
export declare const formatTimeStamp: (timestamp: number | null, startDate?: number | null) => string;
|
|
29
|
+
export declare const getTheme: (config: CommunityConfig, profileSettings?: ProfileSettings, systemTheme?: "dark" | "light") => {
|
|
30
|
+
dark: boolean;
|
|
31
|
+
primaryHex: string;
|
|
32
|
+
logoSmall?: string | undefined;
|
|
33
|
+
defaultProfileAvatar?: string | undefined;
|
|
34
|
+
defaultGroupAvatar?: string | undefined;
|
|
35
|
+
backgroundAuth?: string | undefined;
|
|
36
|
+
background?: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
export declare const getSystemTheme: () => "light" | "dark";
|
|
39
|
+
export declare const getProfileAvatar: (profile: PublicProfile | undefined | null, config: CommunityConfig) => string;
|
|
40
|
+
export declare const getGroupAvatar: (group: GroupWithMeta | GroupData | undefined | null, config: CommunityConfig) => string;
|
|
41
|
+
export declare const extractDateFromUUIDv7: (uuidV7: string) => string;
|
|
42
|
+
export declare const formatSize: (bytes: number) => string;
|
|
43
|
+
export declare const hasVisibilityChanged: (previousAudienceSetting: AudienceSetting, newAudienceSetting: AudienceSetting) => boolean;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export const pick = (obj, ...keys) => {
|
|
2
|
+
const ret = {};
|
|
3
|
+
keys.forEach((key) => {
|
|
4
|
+
ret[key] = obj[key];
|
|
5
|
+
});
|
|
6
|
+
return ret;
|
|
7
|
+
};
|
|
8
|
+
export const transformKeys = (object, transform) => Object.fromEntries([...Object.entries(object)].map((entry) => [transform(entry[0]), entry[1]]));
|
|
9
|
+
export const transformValues = (object, transform) => Object.fromEntries([...Object.entries(object)].map((entry) => [entry[0], transform(entry[1])]));
|
|
10
|
+
const toPaddedBase64 = (value) => {
|
|
11
|
+
const normalized = value
|
|
12
|
+
.replace(/-/g, '+')
|
|
13
|
+
.replace(/_/g, '/')
|
|
14
|
+
.replace(/\s+/g, '');
|
|
15
|
+
return normalized.padEnd(normalized.length + ((4 - (normalized.length % 4)) % 4), '=');
|
|
16
|
+
};
|
|
17
|
+
export const decodeBase64ToUint8Array = (value) => Uint8Array.from(Buffer.from(toPaddedBase64(value), 'base64'));
|
|
18
|
+
export const decodeBase64UrlToUint8Array = (value) => decodeBase64ToUint8Array(value);
|
|
19
|
+
export const lowerCaseFirst = (input) => {
|
|
20
|
+
return input.charAt(0).toLowerCase() + input.substring(1);
|
|
21
|
+
};
|
|
22
|
+
export const asyncFilter = async (arr, predicate) => Promise.all(arr.map(predicate)).then((results) => arr.filter((_v, index) => results[index]));
|
|
23
|
+
export const passThroughUndefined = (func) => (input) => input && func(input);
|
|
24
|
+
export const countBy = (arr, fn) => arr.map(fn).reduce((acc, val) => {
|
|
25
|
+
acc[val] = (acc[val] || 0) + 1;
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
export const groupBy = (arr, fn) => arr.reduce((acc, val) => {
|
|
29
|
+
acc[fn(val)] = [...(acc[fn(val)] || []), val];
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
export const dateSorter = () => (v0, v1) => Date.parse(v0.createdAt) - Date.parse(v1.createdAt);
|
|
33
|
+
export const getUniqueBy = (arr, predicate) => {
|
|
34
|
+
const set = new Set();
|
|
35
|
+
return arr.filter((o) => !set.has(predicate(o)) && set.add(predicate(o)));
|
|
36
|
+
};
|
|
37
|
+
export const interpolate = (text, params = {}) => {
|
|
38
|
+
try {
|
|
39
|
+
if (!text)
|
|
40
|
+
return text;
|
|
41
|
+
const names = Object.keys(params);
|
|
42
|
+
const vals = Object.values(params);
|
|
43
|
+
return new Function(...names, `return \`${text}\`;`)(...vals);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new Error(`Failed to interpolate "${text}" with ${JSON.stringify(params)}, error`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export const sleep = async (seconds) => {
|
|
50
|
+
await new Promise((resolve) => {
|
|
51
|
+
setTimeout(resolve, seconds * 1000);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export const deepSet = (obj, path, val) => {
|
|
55
|
+
const keys = Array.isArray(path)
|
|
56
|
+
? path
|
|
57
|
+
: path
|
|
58
|
+
.replace(/(\w)\[/g, '$1.[')
|
|
59
|
+
.split('.')
|
|
60
|
+
.map((k) => k.includes('[') ? parseInt(k.substring(1, k.length - 1)) : k);
|
|
61
|
+
let subObject = obj;
|
|
62
|
+
for (let i = 0; i < keys.length; i++) {
|
|
63
|
+
const currentKey = keys[i];
|
|
64
|
+
const nextKey = keys[i + 1];
|
|
65
|
+
if (typeof nextKey !== 'undefined') {
|
|
66
|
+
// @ts-expect-error deepset is not really typeable
|
|
67
|
+
subObject[currentKey] = subObject[currentKey]
|
|
68
|
+
? // @ts-expect-error deepset is not really typeable
|
|
69
|
+
subObject[currentKey]
|
|
70
|
+
: // @ts-expect-error deepset is not really typeable
|
|
71
|
+
isNaN(nextKey)
|
|
72
|
+
? {}
|
|
73
|
+
: [];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// @ts-expect-error deepset is not really typeable
|
|
77
|
+
subObject[currentKey] = val;
|
|
78
|
+
}
|
|
79
|
+
// @ts-expect-error deepset is not really typeable
|
|
80
|
+
subObject = subObject[currentKey];
|
|
81
|
+
}
|
|
82
|
+
return obj;
|
|
83
|
+
};
|
|
84
|
+
export const deepGet = (obj, path) =>
|
|
85
|
+
// @ts-expect-error deepget is not typeable
|
|
86
|
+
path.reduce((o, i) => o[i], obj);
|
|
87
|
+
/**
|
|
88
|
+
* Checks if a value is valid => not (null, undefined, empty, etc.)
|
|
89
|
+
* Special case: treats 0 as a valid value unlike standard JS truthiness
|
|
90
|
+
*/
|
|
91
|
+
export const hasValue = (v) => v === 0 || !!v;
|
|
92
|
+
export const kebabToCamelCase = (str) => {
|
|
93
|
+
return str.replace(/-([a-z])/g, function (_match, letter) {
|
|
94
|
+
return letter.toUpperCase();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export const formatTimeStamp = (timestamp, startDate) => {
|
|
98
|
+
if (!timestamp) {
|
|
99
|
+
if (startDate) {
|
|
100
|
+
const startDateObj = new Date(startDate * 1000);
|
|
101
|
+
const nextMonth = new Date(startDateObj);
|
|
102
|
+
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
103
|
+
if (nextMonth.getDate() !== startDateObj.getDate()) {
|
|
104
|
+
nextMonth.setDate(0);
|
|
105
|
+
}
|
|
106
|
+
return nextMonth.toLocaleDateString();
|
|
107
|
+
}
|
|
108
|
+
return 'N/A';
|
|
109
|
+
}
|
|
110
|
+
return new Date(timestamp * 1000).toLocaleDateString();
|
|
111
|
+
};
|
|
112
|
+
const getMode = (config, profileSettings, systemTheme) => {
|
|
113
|
+
if (profileSettings) {
|
|
114
|
+
if (profileSettings.theme === "system") {
|
|
115
|
+
return systemTheme;
|
|
116
|
+
}
|
|
117
|
+
else if ((profileSettings === null || profileSettings === void 0 ? void 0 : profileSettings.theme) === "dark") {
|
|
118
|
+
return "dark";
|
|
119
|
+
}
|
|
120
|
+
else if ((profileSettings === null || profileSettings === void 0 ? void 0 : profileSettings.theme) === "light") {
|
|
121
|
+
return "light";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return config.theme.base === 'OpenpeepsDark' ? 'dark' : 'light';
|
|
125
|
+
};
|
|
126
|
+
export const getTheme = (config, profileSettings, systemTheme = getSystemTheme()) => getMode(config, profileSettings, systemTheme) === 'dark' ?
|
|
127
|
+
{ ...config.theme.dark, dark: true } :
|
|
128
|
+
{ ...config.theme.light, dark: false };
|
|
129
|
+
export const getSystemTheme = () => {
|
|
130
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
131
|
+
const systemIsDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
132
|
+
return systemIsDark ? "dark" : "light";
|
|
133
|
+
}
|
|
134
|
+
return 'light';
|
|
135
|
+
};
|
|
136
|
+
export const getProfileAvatar = (profile, config) => {
|
|
137
|
+
return (profile === null || profile === void 0 ? void 0 : profile.avatar)
|
|
138
|
+
? profile.avatar
|
|
139
|
+
: getTheme(config).defaultProfileAvatar;
|
|
140
|
+
};
|
|
141
|
+
export const getGroupAvatar = (group, config) => {
|
|
142
|
+
return (group === null || group === void 0 ? void 0 : group.avatar)
|
|
143
|
+
? group.avatar
|
|
144
|
+
: getTheme(config).defaultGroupAvatar;
|
|
145
|
+
};
|
|
146
|
+
export const extractDateFromUUIDv7 = (uuidV7) => {
|
|
147
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
148
|
+
if (!UUID_REGEX.test(uuidV7)) {
|
|
149
|
+
throw new Error('Invalid UUID format');
|
|
150
|
+
}
|
|
151
|
+
const versionChar = uuidV7[14];
|
|
152
|
+
if ((parseInt(versionChar, 16) & 0xf) !== 0x7) {
|
|
153
|
+
throw new Error('Not a UUIDv7 - version bits are not 7');
|
|
154
|
+
}
|
|
155
|
+
const hex = uuidV7.replace(/-/g, '');
|
|
156
|
+
const timestampHex = hex.slice(0, 12);
|
|
157
|
+
const timestampMs = parseInt(timestampHex, 16);
|
|
158
|
+
const date = new Date(timestampMs);
|
|
159
|
+
const pad = (num, size) => {
|
|
160
|
+
let s = String(num);
|
|
161
|
+
while (s.length < size) {
|
|
162
|
+
s = '0' + s;
|
|
163
|
+
}
|
|
164
|
+
return s;
|
|
165
|
+
};
|
|
166
|
+
return (date.getUTCFullYear().toString() +
|
|
167
|
+
pad(date.getUTCMonth() + 1, 2) + // months are zero‑based
|
|
168
|
+
pad(date.getUTCDate(), 2) +
|
|
169
|
+
pad(date.getUTCHours(), 2) +
|
|
170
|
+
pad(date.getUTCMinutes(), 2));
|
|
171
|
+
};
|
|
172
|
+
export const formatSize = (bytes) => {
|
|
173
|
+
if (bytes < 1024)
|
|
174
|
+
return bytes + ' B';
|
|
175
|
+
if (bytes < 1024 * 1024)
|
|
176
|
+
return (bytes / 1024).toFixed(1) + ' kB';
|
|
177
|
+
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
|
178
|
+
};
|
|
179
|
+
export const hasVisibilityChanged = (previousAudienceSetting, newAudienceSetting) => {
|
|
180
|
+
var _a, _b;
|
|
181
|
+
if (previousAudienceSetting.visibility !== newAudienceSetting.visibility) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (previousAudienceSetting.groupId !== newAudienceSetting.groupId) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
const prevAudience = (_a = previousAudienceSetting.audience) !== null && _a !== void 0 ? _a : [];
|
|
188
|
+
const newAudience = (_b = newAudienceSetting.audience) !== null && _b !== void 0 ? _b : [];
|
|
189
|
+
if (prevAudience.length !== newAudience.length) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const prevIds = prevAudience.map((p) => p.id).sort();
|
|
193
|
+
const newIds = newAudience.map((p) => p.id).sort();
|
|
194
|
+
for (let i = 0; i < prevIds.length; i++) {
|
|
195
|
+
if (prevIds[i] !== newIds[i]) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Json } from './utils';
|
|
3
|
+
export declare const explorerColumnSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
dataType: z.ZodString;
|
|
6
|
+
primaryKey: z.ZodBoolean;
|
|
7
|
+
notNull: z.ZodBoolean;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type ExplorerColumn = z.infer<typeof explorerColumnSchema>;
|
|
10
|
+
export declare const explorerTableSchema: z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
dataType: z.ZodString;
|
|
15
|
+
primaryKey: z.ZodBoolean;
|
|
16
|
+
notNull: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ExplorerTable = z.infer<typeof explorerTableSchema>;
|
|
20
|
+
export declare const explorerTablesResponseSchema: z.ZodObject<{
|
|
21
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
dataType: z.ZodString;
|
|
26
|
+
primaryKey: z.ZodBoolean;
|
|
27
|
+
notNull: z.ZodBoolean;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type ExplorerTablesResponse = z.infer<typeof explorerTablesResponseSchema>;
|
|
32
|
+
export declare const explorerRowsResponseSchema: z.ZodObject<{
|
|
33
|
+
columns: z.ZodArray<z.ZodString>;
|
|
34
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodType<Json, unknown, z.core.$ZodTypeInternals<Json, unknown>>>>;
|
|
35
|
+
total: z.ZodNumber;
|
|
36
|
+
limit: z.ZodNumber;
|
|
37
|
+
offset: z.ZodNumber;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type ExplorerRowsResponse = z.infer<typeof explorerRowsResponseSchema>;
|
|
40
|
+
/** JSON-compatible values for request bodies (matches fetch-client Serializable). */
|
|
41
|
+
export type ExplorerJson = Json;
|
|
42
|
+
export declare const explorerUpdateRowInputSchema: z.ZodObject<{
|
|
43
|
+
primaryKey: z.ZodRecord<z.ZodString, z.ZodType<Json, unknown, z.core.$ZodTypeInternals<Json, unknown>>>;
|
|
44
|
+
patch: z.ZodRecord<z.ZodString, z.ZodType<Json, unknown, z.core.$ZodTypeInternals<Json, unknown>>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type ExplorerUpdateRowInput = z.infer<typeof explorerUpdateRowInputSchema>;
|
|
47
|
+
export declare const explorerUpdateRowResponseSchema: z.ZodObject<{
|
|
48
|
+
row: z.ZodRecord<z.ZodString, z.ZodType<Json, unknown, z.core.$ZodTypeInternals<Json, unknown>>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type ExplorerUpdateRowResponse = z.infer<typeof explorerUpdateRowResponseSchema>;
|
|
51
|
+
export declare const explorerSqlInputSchema: z.ZodObject<{
|
|
52
|
+
statement: z.ZodString;
|
|
53
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type ExplorerSqlInput = z.infer<typeof explorerSqlInputSchema>;
|
|
56
|
+
export declare const explorerSqlResponseSchema: z.ZodObject<{
|
|
57
|
+
columns: z.ZodArray<z.ZodString>;
|
|
58
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodType<Json, unknown, z.core.$ZodTypeInternals<Json, unknown>>>>;
|
|
59
|
+
rowCount: z.ZodNumber;
|
|
60
|
+
command: z.ZodString;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type ExplorerSqlResponse = z.infer<typeof explorerSqlResponseSchema>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { jsonSchema } from './utils.js';
|
|
3
|
+
export const explorerColumnSchema = z.object({
|
|
4
|
+
name: z.string(),
|
|
5
|
+
dataType: z.string(),
|
|
6
|
+
primaryKey: z.boolean(),
|
|
7
|
+
notNull: z.boolean(),
|
|
8
|
+
});
|
|
9
|
+
export const explorerTableSchema = z.object({
|
|
10
|
+
name: z.string(),
|
|
11
|
+
columns: z.array(explorerColumnSchema),
|
|
12
|
+
});
|
|
13
|
+
export const explorerTablesResponseSchema = z.object({
|
|
14
|
+
tables: z.array(explorerTableSchema),
|
|
15
|
+
});
|
|
16
|
+
export const explorerRowsResponseSchema = z.object({
|
|
17
|
+
columns: z.array(z.string()),
|
|
18
|
+
// Use jsonSchema (not z.unknown / z.lazy) so OpenAPI generation stays safe.
|
|
19
|
+
rows: z.array(z.record(z.string(), jsonSchema)),
|
|
20
|
+
total: z.number(),
|
|
21
|
+
limit: z.number(),
|
|
22
|
+
offset: z.number(),
|
|
23
|
+
});
|
|
24
|
+
export const explorerUpdateRowInputSchema = z.object({
|
|
25
|
+
primaryKey: z.record(z.string(), jsonSchema),
|
|
26
|
+
patch: z.record(z.string(), jsonSchema),
|
|
27
|
+
});
|
|
28
|
+
export const explorerUpdateRowResponseSchema = z.object({
|
|
29
|
+
row: z.record(z.string(), jsonSchema),
|
|
30
|
+
});
|
|
31
|
+
export const explorerSqlInputSchema = z.object({
|
|
32
|
+
statement: z.string().min(1),
|
|
33
|
+
/** Max rows to return (capped server-side). Omit for the default cap. */
|
|
34
|
+
limit: z.number().int().positive().max(10000).optional(),
|
|
35
|
+
});
|
|
36
|
+
export const explorerSqlResponseSchema = z.object({
|
|
37
|
+
columns: z.array(z.string()),
|
|
38
|
+
rows: z.array(z.record(z.string(), jsonSchema)),
|
|
39
|
+
rowCount: z.number(),
|
|
40
|
+
command: z.string(),
|
|
41
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const adminEmailTestInputSchema: z.ZodObject<{
|
|
3
|
+
to: z.ZodString;
|
|
4
|
+
email: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
defaultFrom: z.ZodOptional<z.ZodString>;
|
|
6
|
+
transportConfig: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
host: z.ZodOptional<z.ZodString>;
|
|
8
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
user: z.ZodOptional<z.ZodString>;
|
|
12
|
+
pass: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type AdminEmailTestInput = z.infer<typeof adminEmailTestInputSchema>;
|
|
18
|
+
export declare const adminEmailQueueTestInputSchema: z.ZodObject<{
|
|
19
|
+
to: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type AdminEmailQueueTestInput = z.infer<typeof adminEmailQueueTestInputSchema>;
|
|
22
|
+
export declare const adminEmailQueueStatsSchema: z.ZodObject<{
|
|
23
|
+
counts: z.ZodObject<{
|
|
24
|
+
waiting: z.ZodNumber;
|
|
25
|
+
active: z.ZodNumber;
|
|
26
|
+
completed: z.ZodNumber;
|
|
27
|
+
failed: z.ZodNumber;
|
|
28
|
+
delayed: z.ZodNumber;
|
|
29
|
+
prioritized: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
recentFailures: z.ZodArray<z.ZodObject<{
|
|
32
|
+
queue: z.ZodString;
|
|
33
|
+
id: z.ZodNullable<z.ZodString>;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
failedReason: z.ZodString;
|
|
36
|
+
finishedOn: z.ZodNullable<z.ZodNumber>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type AdminEmailQueueStats = z.infer<typeof adminEmailQueueStatsSchema>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const transportOverrideSchema = z.object({
|
|
3
|
+
host: z.string().optional(),
|
|
4
|
+
port: z.number().optional(),
|
|
5
|
+
secure: z.boolean().optional(),
|
|
6
|
+
auth: z
|
|
7
|
+
.object({
|
|
8
|
+
user: z.string().optional(),
|
|
9
|
+
pass: z.string().optional(),
|
|
10
|
+
})
|
|
11
|
+
.optional(),
|
|
12
|
+
});
|
|
13
|
+
export const adminEmailTestInputSchema = z.object({
|
|
14
|
+
to: z.string().email(),
|
|
15
|
+
email: z
|
|
16
|
+
.object({
|
|
17
|
+
defaultFrom: z.string().optional(),
|
|
18
|
+
transportConfig: transportOverrideSchema.optional(),
|
|
19
|
+
})
|
|
20
|
+
.optional(),
|
|
21
|
+
});
|
|
22
|
+
export const adminEmailQueueTestInputSchema = z.object({
|
|
23
|
+
to: z.string().email(),
|
|
24
|
+
});
|
|
25
|
+
export const adminEmailQueueStatsSchema = z.object({
|
|
26
|
+
counts: z.object({
|
|
27
|
+
waiting: z.number(),
|
|
28
|
+
active: z.number(),
|
|
29
|
+
completed: z.number(),
|
|
30
|
+
failed: z.number(),
|
|
31
|
+
delayed: z.number(),
|
|
32
|
+
prioritized: z.number(),
|
|
33
|
+
}),
|
|
34
|
+
recentFailures: z.array(z.object({
|
|
35
|
+
queue: z.string(),
|
|
36
|
+
id: z.string().nullable(),
|
|
37
|
+
name: z.string(),
|
|
38
|
+
failedReason: z.string(),
|
|
39
|
+
finishedOn: z.number().nullable(),
|
|
40
|
+
})),
|
|
41
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const adminJobDetailSchema: z.ZodObject<{
|
|
3
|
+
queue: z.ZodString;
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
state: z.ZodString;
|
|
7
|
+
failedReason: z.ZodNullable<z.ZodString>;
|
|
8
|
+
finishedOn: z.ZodNullable<z.ZodNumber>;
|
|
9
|
+
processedOn: z.ZodNullable<z.ZodNumber>;
|
|
10
|
+
timestamp: z.ZodNullable<z.ZodNumber>;
|
|
11
|
+
data: z.ZodNullable<z.ZodUnknown>;
|
|
12
|
+
logs: z.ZodArray<z.ZodString>;
|
|
13
|
+
logCount: z.ZodNumber;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type AdminJobDetail = z.infer<typeof adminJobDetailSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const adminJobDetailSchema = z.object({
|
|
3
|
+
queue: z.string(),
|
|
4
|
+
id: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
state: z.string(),
|
|
7
|
+
failedReason: z.string().nullable(),
|
|
8
|
+
finishedOn: z.number().nullable(),
|
|
9
|
+
processedOn: z.number().nullable(),
|
|
10
|
+
timestamp: z.number().nullable(),
|
|
11
|
+
data: z.unknown().nullable(),
|
|
12
|
+
logs: z.array(z.string()),
|
|
13
|
+
logCount: z.number(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const slowRequestRecordSchema: z.ZodObject<{
|
|
3
|
+
method: z.ZodString;
|
|
4
|
+
path: z.ZodString;
|
|
5
|
+
status: z.ZodNumber;
|
|
6
|
+
durationMs: z.ZodNumber;
|
|
7
|
+
at: z.ZodString;
|
|
8
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type SlowRequestRecord = z.infer<typeof slowRequestRecordSchema>;
|
|
11
|
+
export declare const adminPerformanceStatsSchema: z.ZodObject<{
|
|
12
|
+
slowRequestMs: z.ZodNumber;
|
|
13
|
+
dbTimingEnabled: z.ZodBoolean;
|
|
14
|
+
slowRequests: z.ZodArray<z.ZodObject<{
|
|
15
|
+
method: z.ZodString;
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
status: z.ZodNumber;
|
|
18
|
+
durationMs: z.ZodNumber;
|
|
19
|
+
at: z.ZodString;
|
|
20
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type AdminPerformanceStats = z.infer<typeof adminPerformanceStatsSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const slowRequestRecordSchema = z.object({
|
|
3
|
+
method: z.string(),
|
|
4
|
+
path: z.string(),
|
|
5
|
+
status: z.number(),
|
|
6
|
+
durationMs: z.number(),
|
|
7
|
+
at: z.string(),
|
|
8
|
+
hostname: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const adminPerformanceStatsSchema = z.object({
|
|
11
|
+
slowRequestMs: z.number(),
|
|
12
|
+
dbTimingEnabled: z.boolean(),
|
|
13
|
+
slowRequests: z.array(slowRequestRecordSchema),
|
|
14
|
+
});
|