@superblocksteam/shared 0.9584.9 → 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.
Files changed (60) hide show
  1. package/dist/types/application/index.d.ts +22 -1
  2. package/dist/types/application/index.d.ts.map +1 -1
  3. package/dist/types/application/index.js +28 -1
  4. package/dist/types/application/index.js.map +1 -1
  5. package/dist/types/audit/ocsf.d.ts.map +1 -1
  6. package/dist/types/audit/ocsf.js +2 -1
  7. package/dist/types/audit/ocsf.js.map +1 -1
  8. package/dist/types/user/analytics.d.ts.map +1 -1
  9. package/dist/types/user/analytics.js +1 -2
  10. package/dist/types/user/analytics.js.map +1 -1
  11. package/dist/types/user/index.d.ts +19 -0
  12. package/dist/types/user/index.d.ts.map +1 -1
  13. package/dist/types/user/index.js +8 -1
  14. package/dist/types/user/index.js.map +1 -1
  15. package/dist/utils/attachment-delivery.d.ts +11 -0
  16. package/dist/utils/attachment-delivery.d.ts.map +1 -0
  17. package/dist/utils/attachment-delivery.js +78 -0
  18. package/dist/utils/attachment-delivery.js.map +1 -0
  19. package/dist/utils/attachment-upload.d.ts +6 -1
  20. package/dist/utils/attachment-upload.d.ts.map +1 -1
  21. package/dist/utils/attachment-upload.js +3 -2
  22. package/dist/utils/attachment-upload.js.map +1 -1
  23. package/dist/utils/index.d.ts +1 -0
  24. package/dist/utils/index.d.ts.map +1 -1
  25. package/dist/utils/index.js +1 -0
  26. package/dist/utils/index.js.map +1 -1
  27. package/dist-esm/types/application/index.d.ts +22 -1
  28. package/dist-esm/types/application/index.d.ts.map +1 -1
  29. package/dist-esm/types/application/index.js +25 -0
  30. package/dist-esm/types/application/index.js.map +1 -1
  31. package/dist-esm/types/audit/ocsf.d.ts.map +1 -1
  32. package/dist-esm/types/audit/ocsf.js +2 -1
  33. package/dist-esm/types/audit/ocsf.js.map +1 -1
  34. package/dist-esm/types/user/analytics.d.ts.map +1 -1
  35. package/dist-esm/types/user/analytics.js +1 -2
  36. package/dist-esm/types/user/analytics.js.map +1 -1
  37. package/dist-esm/types/user/index.d.ts +19 -0
  38. package/dist-esm/types/user/index.d.ts.map +1 -1
  39. package/dist-esm/types/user/index.js +7 -0
  40. package/dist-esm/types/user/index.js.map +1 -1
  41. package/dist-esm/utils/attachment-delivery.d.ts +11 -0
  42. package/dist-esm/utils/attachment-delivery.d.ts.map +1 -0
  43. package/dist-esm/utils/attachment-delivery.js +73 -0
  44. package/dist-esm/utils/attachment-delivery.js.map +1 -0
  45. package/dist-esm/utils/attachment-upload.d.ts +6 -1
  46. package/dist-esm/utils/attachment-upload.d.ts.map +1 -1
  47. package/dist-esm/utils/attachment-upload.js +3 -2
  48. package/dist-esm/utils/attachment-upload.js.map +1 -1
  49. package/dist-esm/utils/index.d.ts +1 -0
  50. package/dist-esm/utils/index.d.ts.map +1 -1
  51. package/dist-esm/utils/index.js +1 -0
  52. package/dist-esm/utils/index.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/types/application/index.ts +49 -1
  55. package/src/types/audit/ocsf.ts +2 -1
  56. package/src/types/user/analytics.ts +1 -2
  57. package/src/types/user/index.ts +22 -0
  58. package/src/utils/attachment-delivery.ts +96 -0
  59. package/src/utils/attachment-upload.ts +10 -2
  60. package/src/utils/index.ts +1 -0
@@ -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 mimeType = parsedDataUrl?.mimeType ?? normalizeNonEmptyString(options?.fallbackMimeType) ?? 'application/pdf';
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)], {
@@ -1,5 +1,6 @@
1
1
  export * from './configuration.js';
2
2
  export * from './attachment-upload.js';
3
+ export * from './attachment-delivery.js';
3
4
  export * from './env.js';
4
5
  export * from './environment.js';
5
6
  export * from './git-url.js';