@superblocksteam/shared 0.9584.10 → 0.9585.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/dist/types/application/index.d.ts +22 -1
- package/dist/types/application/index.d.ts.map +1 -1
- package/dist/types/application/index.js +28 -1
- package/dist/types/application/index.js.map +1 -1
- package/dist/types/audit/ocsf.d.ts.map +1 -1
- package/dist/types/audit/ocsf.js +2 -1
- package/dist/types/audit/ocsf.js.map +1 -1
- package/dist/types/user/analytics.d.ts.map +1 -1
- package/dist/types/user/analytics.js +1 -2
- package/dist/types/user/analytics.js.map +1 -1
- package/dist/types/user/index.d.ts +19 -0
- package/dist/types/user/index.d.ts.map +1 -1
- package/dist/types/user/index.js +8 -1
- package/dist/types/user/index.js.map +1 -1
- package/dist/utils/attachment-delivery.d.ts +11 -0
- package/dist/utils/attachment-delivery.d.ts.map +1 -0
- package/dist/utils/attachment-delivery.js +78 -0
- package/dist/utils/attachment-delivery.js.map +1 -0
- package/dist/utils/attachment-upload.d.ts +6 -1
- package/dist/utils/attachment-upload.d.ts.map +1 -1
- package/dist/utils/attachment-upload.js +3 -2
- package/dist/utils/attachment-upload.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist-esm/types/application/index.d.ts +22 -1
- package/dist-esm/types/application/index.d.ts.map +1 -1
- package/dist-esm/types/application/index.js +25 -0
- package/dist-esm/types/application/index.js.map +1 -1
- package/dist-esm/types/audit/ocsf.d.ts.map +1 -1
- package/dist-esm/types/audit/ocsf.js +2 -1
- package/dist-esm/types/audit/ocsf.js.map +1 -1
- package/dist-esm/types/user/analytics.d.ts.map +1 -1
- package/dist-esm/types/user/analytics.js +1 -2
- package/dist-esm/types/user/analytics.js.map +1 -1
- package/dist-esm/types/user/index.d.ts +19 -0
- package/dist-esm/types/user/index.d.ts.map +1 -1
- package/dist-esm/types/user/index.js +7 -0
- package/dist-esm/types/user/index.js.map +1 -1
- package/dist-esm/utils/attachment-delivery.d.ts +11 -0
- package/dist-esm/utils/attachment-delivery.d.ts.map +1 -0
- package/dist-esm/utils/attachment-delivery.js +73 -0
- package/dist-esm/utils/attachment-delivery.js.map +1 -0
- package/dist-esm/utils/attachment-upload.d.ts +6 -1
- package/dist-esm/utils/attachment-upload.d.ts.map +1 -1
- package/dist-esm/utils/attachment-upload.js +3 -2
- package/dist-esm/utils/attachment-upload.js.map +1 -1
- package/dist-esm/utils/index.d.ts +1 -0
- package/dist-esm/utils/index.d.ts.map +1 -1
- package/dist-esm/utils/index.js +1 -0
- package/dist-esm/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/types/application/index.ts +49 -1
- package/src/types/audit/ocsf.ts +2 -1
- package/src/types/user/analytics.ts +1 -2
- package/src/types/user/index.ts +22 -0
- package/src/utils/attachment-delivery.ts +96 -0
- package/src/utils/attachment-upload.ts +10 -2
- package/src/utils/index.ts +1 -0
package/src/types/user/index.ts
CHANGED
|
@@ -82,6 +82,28 @@ export enum UserType {
|
|
|
82
82
|
|
|
83
83
|
export type UserAuthSource = 'Superblocks' | 'Auth0' | 'Anonymous';
|
|
84
84
|
|
|
85
|
+
export enum JoinRequestStatus {
|
|
86
|
+
APPROVED = 'APPROVED',
|
|
87
|
+
CANCELLED = 'CANCELLED',
|
|
88
|
+
DENIED = 'DENIED',
|
|
89
|
+
PENDING = 'PENDING'
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface JoinRequestDto {
|
|
93
|
+
id: string;
|
|
94
|
+
requesterEmail: string;
|
|
95
|
+
requesterName: string;
|
|
96
|
+
targetOrganizationId: string;
|
|
97
|
+
targetOrganizationName: string;
|
|
98
|
+
status: JoinRequestStatus;
|
|
99
|
+
created: Date;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface MatchingDomainOrgDto {
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
export enum RequestSource {
|
|
86
108
|
SUPERBLOCKS = 'superblocks',
|
|
87
109
|
EMBED = 'embed'
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { getTextAttachmentType } from './attachment-upload.js';
|
|
2
|
+
|
|
3
|
+
export type AttachmentDeliveryMode = 'inline_native' | 'reference_only';
|
|
4
|
+
export type AttachmentArchiveType = 'gz' | 'tgz' | 'zip';
|
|
5
|
+
|
|
6
|
+
const ARCHIVE_MIME_TYPES_BY_TYPE: Record<AttachmentArchiveType, Set<string>> = {
|
|
7
|
+
gz: new Set(['application/gzip', 'application/x-gzip']),
|
|
8
|
+
tgz: new Set([
|
|
9
|
+
'application/tar+gzip',
|
|
10
|
+
'application/x-compressed-tar',
|
|
11
|
+
'application/x-gtar',
|
|
12
|
+
'application/x-tar+gzip',
|
|
13
|
+
'application/x-tgz'
|
|
14
|
+
]),
|
|
15
|
+
zip: new Set(['application/x-zip', 'application/x-zip-compressed', 'application/zip'])
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type AttachmentTypeInput = {
|
|
19
|
+
fileName?: string;
|
|
20
|
+
mimeType?: string | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function normalizeMimeType(mimeType?: string | null): string {
|
|
24
|
+
return mimeType?.trim().toLowerCase() ?? '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeFileName(fileName?: string): string {
|
|
28
|
+
return fileName?.trim().toLowerCase() ?? '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function hasAnyFileName(input: AttachmentTypeInput): boolean {
|
|
32
|
+
return normalizeFileName(input.fileName).length > 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function detectAttachmentArchiveType(input: AttachmentTypeInput): AttachmentArchiveType | null {
|
|
36
|
+
const fileName = normalizeFileName(input.fileName);
|
|
37
|
+
if (fileName.endsWith('.tar.gz') || fileName.endsWith('.tgz')) {
|
|
38
|
+
return 'tgz';
|
|
39
|
+
}
|
|
40
|
+
if (fileName.endsWith('.zip')) {
|
|
41
|
+
return 'zip';
|
|
42
|
+
}
|
|
43
|
+
if (fileName.endsWith('.gzip') || fileName.endsWith('.gz')) {
|
|
44
|
+
return 'gz';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mimeType = normalizeMimeType(input.mimeType);
|
|
48
|
+
if (!mimeType) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (ARCHIVE_MIME_TYPES_BY_TYPE.zip.has(mimeType)) {
|
|
53
|
+
return 'zip';
|
|
54
|
+
}
|
|
55
|
+
if (ARCHIVE_MIME_TYPES_BY_TYPE.tgz.has(mimeType)) {
|
|
56
|
+
return 'tgz';
|
|
57
|
+
}
|
|
58
|
+
if (ARCHIVE_MIME_TYPES_BY_TYPE.gz.has(mimeType)) {
|
|
59
|
+
return 'gz';
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function classifyAttachmentDelivery(input: AttachmentTypeInput): AttachmentDeliveryMode {
|
|
65
|
+
if (detectAttachmentArchiveType(input)) {
|
|
66
|
+
return 'reference_only';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const mimeType = normalizeMimeType(input.mimeType);
|
|
70
|
+
if (mimeType.startsWith('image/') || mimeType === 'application/pdf') {
|
|
71
|
+
return 'inline_native';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
getTextAttachmentType({
|
|
76
|
+
fileName: input.fileName,
|
|
77
|
+
mimeType
|
|
78
|
+
}) !== null
|
|
79
|
+
) {
|
|
80
|
+
return 'inline_native';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return 'reference_only';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isSupportedAttachmentUploadType(input: AttachmentTypeInput): boolean {
|
|
87
|
+
if (detectAttachmentArchiveType(input)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!hasAnyFileName(input) && !normalizeMimeType(input.mimeType)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return classifyAttachmentDelivery(input) === 'inline_native';
|
|
96
|
+
}
|
|
@@ -106,6 +106,12 @@ type UploadPdfAttachmentLike = {
|
|
|
106
106
|
fileName: string;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
type UploadArchiveAttachmentLike = {
|
|
110
|
+
type: 'archive';
|
|
111
|
+
data: string;
|
|
112
|
+
fileName: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
109
115
|
type UploadTextAttachmentLike = {
|
|
110
116
|
type: 'csv' | 'css' | 'json' | 'txt' | 'yaml';
|
|
111
117
|
content: string;
|
|
@@ -121,6 +127,7 @@ export type AttachmentUploadSourceLike =
|
|
|
121
127
|
| Blob
|
|
122
128
|
| File
|
|
123
129
|
| UploadAttachmentDataLike
|
|
130
|
+
| UploadArchiveAttachmentLike
|
|
124
131
|
| UploadImageAttachmentLike
|
|
125
132
|
| UploadPdfAttachmentLike
|
|
126
133
|
| UploadTextAttachmentLike
|
|
@@ -449,9 +456,10 @@ export function toAttachmentUploadDescriptor(
|
|
|
449
456
|
};
|
|
450
457
|
}
|
|
451
458
|
|
|
452
|
-
if (source.type === 'pdf') {
|
|
459
|
+
if (source.type === 'pdf' || source.type === 'archive') {
|
|
453
460
|
const parsedDataUrl = parseDataUrl(source.data);
|
|
454
|
-
const
|
|
461
|
+
const defaultMimeType = source.type === 'pdf' ? 'application/pdf' : 'application/octet-stream';
|
|
462
|
+
const mimeType = parsedDataUrl?.mimeType ?? normalizeNonEmptyString(options?.fallbackMimeType) ?? defaultMimeType;
|
|
455
463
|
|
|
456
464
|
return {
|
|
457
465
|
blob: new Blob([decodeBase64(parsedDataUrl?.base64Data ?? source.data)], {
|