@did-space/core 1.0.9 → 1.0.11
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/cjs/constants/index.d.ts +2 -0
- package/dist/cjs/constants/index.js +2 -0
- package/dist/cjs/model/audit-log.d.ts +389 -1
- package/dist/cjs/model/audit-log.js +36 -2
- package/dist/cjs/model/space.d.ts +7 -1
- package/dist/cjs/protocols/space-config.d.ts +1 -0
- package/dist/cjs/space/global-space.js +5 -3
- package/dist/cjs/space/object-space.d.ts +7 -8
- package/dist/cjs/space/object-space.js +45 -23
- package/dist/cjs/utils/hash.js +17 -7
- package/dist/es/constants/index.d.ts +2 -0
- package/dist/es/constants/index.js +2 -0
- package/dist/es/model/audit-log.d.ts +389 -1
- package/dist/es/model/audit-log.js +35 -1
- package/dist/es/model/space.d.ts +7 -1
- package/dist/es/protocols/space-config.d.ts +1 -0
- package/dist/es/space/global-space.js +5 -3
- package/dist/es/space/object-space.d.ts +7 -8
- package/dist/es/space/object-space.js +46 -24
- package/dist/es/utils/hash.js +17 -7
- package/package.json +8 -6
|
@@ -25,6 +25,8 @@ export declare const SPACE_CONNECT_ERROR_CODE: {
|
|
|
25
25
|
UNIT_LIMIT: number;
|
|
26
26
|
/** 跨域限制 */
|
|
27
27
|
CORS_BLOCKED: number;
|
|
28
|
+
/** Space 版本不兼容 */
|
|
29
|
+
INCOMPATIBLE: number;
|
|
28
30
|
};
|
|
29
31
|
export declare const GLOBAL_SPACE_ROOT = "__GLOBAL__";
|
|
30
32
|
export declare const STORAGE_BUILT_IN_OBJECTS: string[];
|
|
@@ -33,6 +33,8 @@ exports.SPACE_CONNECT_ERROR_CODE = {
|
|
|
33
33
|
UNIT_LIMIT: 1006,
|
|
34
34
|
/** 跨域限制 */
|
|
35
35
|
CORS_BLOCKED: 1007,
|
|
36
|
+
/** Space 版本不兼容 */
|
|
37
|
+
INCOMPATIBLE: 1008,
|
|
36
38
|
};
|
|
37
39
|
exports.GLOBAL_SPACE_ROOT = '__GLOBAL__';
|
|
38
40
|
exports.STORAGE_BUILT_IN_OBJECTS = ['/config.yml', '/apps/', '/.meta/'];
|
|
@@ -11,7 +11,8 @@ export declare enum AuditLogAction {
|
|
|
11
11
|
APP_DISCONNECTED = "app-disconnected",
|
|
12
12
|
APP_RESTORE = "app-restore",
|
|
13
13
|
APP_BACKUP = "app-backup",
|
|
14
|
-
APP_CONNECTED = "app-connected"
|
|
14
|
+
APP_CONNECTED = "app-connected",
|
|
15
|
+
APP_OBJECTS_SYNC = "app-objects-sync"
|
|
15
16
|
}
|
|
16
17
|
export declare const AppConnectedSchema: z.ZodObject<{
|
|
17
18
|
spaceDid: z.ZodString;
|
|
@@ -92,6 +93,50 @@ export declare const AppRestoreSchema: z.ZodObject<{
|
|
|
92
93
|
referrer: string;
|
|
93
94
|
serverDid: string;
|
|
94
95
|
}>;
|
|
96
|
+
export declare const AppObjectsSyncSchema: z.ZodObject<{
|
|
97
|
+
/** 应用名称 */
|
|
98
|
+
appName: z.ZodString;
|
|
99
|
+
/** 应用描述 */
|
|
100
|
+
appDescription: z.ZodString;
|
|
101
|
+
/** 原路径 */
|
|
102
|
+
source: z.ZodString;
|
|
103
|
+
/** 目标路径 */
|
|
104
|
+
target: z.ZodString;
|
|
105
|
+
/** 总对象数 */
|
|
106
|
+
totalCount: z.ZodNumber;
|
|
107
|
+
/** 失败对象数 */
|
|
108
|
+
errorCount: z.ZodNumber;
|
|
109
|
+
/** 成功对象数 */
|
|
110
|
+
successCount: z.ZodNumber;
|
|
111
|
+
/** 总文件大小 */
|
|
112
|
+
size: z.ZodNumber;
|
|
113
|
+
/** 同步耗时(ms) */
|
|
114
|
+
duration: z.ZodNumber;
|
|
115
|
+
/** 元数据 */
|
|
116
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
target: string;
|
|
119
|
+
size: number;
|
|
120
|
+
appName: string;
|
|
121
|
+
appDescription: string;
|
|
122
|
+
source: string;
|
|
123
|
+
totalCount: number;
|
|
124
|
+
errorCount: number;
|
|
125
|
+
successCount: number;
|
|
126
|
+
duration: number;
|
|
127
|
+
metadata?: Record<string, any> | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
target: string;
|
|
130
|
+
size: number;
|
|
131
|
+
appName: string;
|
|
132
|
+
appDescription: string;
|
|
133
|
+
source: string;
|
|
134
|
+
totalCount: number;
|
|
135
|
+
errorCount: number;
|
|
136
|
+
successCount: number;
|
|
137
|
+
duration: number;
|
|
138
|
+
metadata?: Record<string, any> | undefined;
|
|
139
|
+
}>;
|
|
95
140
|
export declare const AuditLogSchema: z.ZodObject<{
|
|
96
141
|
id: z.ZodString;
|
|
97
142
|
actionType: z.ZodNativeEnum<typeof AuditLogAction>;
|
|
@@ -174,6 +219,49 @@ export declare const AuditLogSchema: z.ZodObject<{
|
|
|
174
219
|
appDescription: string;
|
|
175
220
|
referrer: string;
|
|
176
221
|
serverDid: string;
|
|
222
|
+
}>, z.ZodObject<{
|
|
223
|
+
/** 应用名称 */
|
|
224
|
+
appName: z.ZodString;
|
|
225
|
+
/** 应用描述 */
|
|
226
|
+
appDescription: z.ZodString;
|
|
227
|
+
/** 原路径 */
|
|
228
|
+
source: z.ZodString;
|
|
229
|
+
/** 目标路径 */
|
|
230
|
+
target: z.ZodString;
|
|
231
|
+
/** 总对象数 */
|
|
232
|
+
totalCount: z.ZodNumber;
|
|
233
|
+
/** 失败对象数 */
|
|
234
|
+
errorCount: z.ZodNumber;
|
|
235
|
+
/** 成功对象数 */
|
|
236
|
+
successCount: z.ZodNumber;
|
|
237
|
+
/** 总文件大小 */
|
|
238
|
+
size: z.ZodNumber;
|
|
239
|
+
/** 同步耗时(ms) */
|
|
240
|
+
duration: z.ZodNumber;
|
|
241
|
+
/** 元数据 */
|
|
242
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
target: string;
|
|
245
|
+
size: number;
|
|
246
|
+
appName: string;
|
|
247
|
+
appDescription: string;
|
|
248
|
+
source: string;
|
|
249
|
+
totalCount: number;
|
|
250
|
+
errorCount: number;
|
|
251
|
+
successCount: number;
|
|
252
|
+
duration: number;
|
|
253
|
+
metadata?: Record<string, any> | undefined;
|
|
254
|
+
}, {
|
|
255
|
+
target: string;
|
|
256
|
+
size: number;
|
|
257
|
+
appName: string;
|
|
258
|
+
appDescription: string;
|
|
259
|
+
source: string;
|
|
260
|
+
totalCount: number;
|
|
261
|
+
errorCount: number;
|
|
262
|
+
successCount: number;
|
|
263
|
+
duration: number;
|
|
264
|
+
metadata?: Record<string, any> | undefined;
|
|
177
265
|
}>]>;
|
|
178
266
|
status: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof AuditLogStatus>>>;
|
|
179
267
|
reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -213,6 +301,17 @@ export declare const AuditLogSchema: z.ZodObject<{
|
|
|
213
301
|
appDescription: string;
|
|
214
302
|
referrer: string;
|
|
215
303
|
serverDid: string;
|
|
304
|
+
} | {
|
|
305
|
+
target: string;
|
|
306
|
+
size: number;
|
|
307
|
+
appName: string;
|
|
308
|
+
appDescription: string;
|
|
309
|
+
source: string;
|
|
310
|
+
totalCount: number;
|
|
311
|
+
errorCount: number;
|
|
312
|
+
successCount: number;
|
|
313
|
+
duration: number;
|
|
314
|
+
metadata?: Record<string, any> | undefined;
|
|
216
315
|
};
|
|
217
316
|
reason: string;
|
|
218
317
|
env: Record<string, any>;
|
|
@@ -244,6 +343,17 @@ export declare const AuditLogSchema: z.ZodObject<{
|
|
|
244
343
|
appDescription: string;
|
|
245
344
|
referrer: string;
|
|
246
345
|
serverDid: string;
|
|
346
|
+
} | {
|
|
347
|
+
target: string;
|
|
348
|
+
size: number;
|
|
349
|
+
appName: string;
|
|
350
|
+
appDescription: string;
|
|
351
|
+
source: string;
|
|
352
|
+
totalCount: number;
|
|
353
|
+
errorCount: number;
|
|
354
|
+
successCount: number;
|
|
355
|
+
duration: number;
|
|
356
|
+
metadata?: Record<string, any> | undefined;
|
|
247
357
|
};
|
|
248
358
|
status?: AuditLogStatus | undefined;
|
|
249
359
|
createdAt?: string | undefined;
|
|
@@ -335,6 +445,49 @@ export declare const CreationAuditLogSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
335
445
|
appDescription: string;
|
|
336
446
|
referrer: string;
|
|
337
447
|
serverDid: string;
|
|
448
|
+
}>, z.ZodObject<{
|
|
449
|
+
/** 应用名称 */
|
|
450
|
+
appName: z.ZodString;
|
|
451
|
+
/** 应用描述 */
|
|
452
|
+
appDescription: z.ZodString;
|
|
453
|
+
/** 原路径 */
|
|
454
|
+
source: z.ZodString;
|
|
455
|
+
/** 目标路径 */
|
|
456
|
+
target: z.ZodString;
|
|
457
|
+
/** 总对象数 */
|
|
458
|
+
totalCount: z.ZodNumber;
|
|
459
|
+
/** 失败对象数 */
|
|
460
|
+
errorCount: z.ZodNumber;
|
|
461
|
+
/** 成功对象数 */
|
|
462
|
+
successCount: z.ZodNumber;
|
|
463
|
+
/** 总文件大小 */
|
|
464
|
+
size: z.ZodNumber;
|
|
465
|
+
/** 同步耗时(ms) */
|
|
466
|
+
duration: z.ZodNumber;
|
|
467
|
+
/** 元数据 */
|
|
468
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
469
|
+
}, "strip", z.ZodTypeAny, {
|
|
470
|
+
target: string;
|
|
471
|
+
size: number;
|
|
472
|
+
appName: string;
|
|
473
|
+
appDescription: string;
|
|
474
|
+
source: string;
|
|
475
|
+
totalCount: number;
|
|
476
|
+
errorCount: number;
|
|
477
|
+
successCount: number;
|
|
478
|
+
duration: number;
|
|
479
|
+
metadata?: Record<string, any> | undefined;
|
|
480
|
+
}, {
|
|
481
|
+
target: string;
|
|
482
|
+
size: number;
|
|
483
|
+
appName: string;
|
|
484
|
+
appDescription: string;
|
|
485
|
+
source: string;
|
|
486
|
+
totalCount: number;
|
|
487
|
+
errorCount: number;
|
|
488
|
+
successCount: number;
|
|
489
|
+
duration: number;
|
|
490
|
+
metadata?: Record<string, any> | undefined;
|
|
338
491
|
}>]>;
|
|
339
492
|
status: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof AuditLogStatus>>>;
|
|
340
493
|
reason: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -375,6 +528,17 @@ export declare const CreationAuditLogSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
375
528
|
appDescription: string;
|
|
376
529
|
referrer: string;
|
|
377
530
|
serverDid: string;
|
|
531
|
+
} | {
|
|
532
|
+
target: string;
|
|
533
|
+
size: number;
|
|
534
|
+
appName: string;
|
|
535
|
+
appDescription: string;
|
|
536
|
+
source: string;
|
|
537
|
+
totalCount: number;
|
|
538
|
+
errorCount: number;
|
|
539
|
+
successCount: number;
|
|
540
|
+
duration: number;
|
|
541
|
+
metadata?: Record<string, any> | undefined;
|
|
378
542
|
};
|
|
379
543
|
reason: string;
|
|
380
544
|
env: Record<string, any>;
|
|
@@ -406,6 +570,17 @@ export declare const CreationAuditLogSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
406
570
|
appDescription: string;
|
|
407
571
|
referrer: string;
|
|
408
572
|
serverDid: string;
|
|
573
|
+
} | {
|
|
574
|
+
target: string;
|
|
575
|
+
size: number;
|
|
576
|
+
appName: string;
|
|
577
|
+
appDescription: string;
|
|
578
|
+
source: string;
|
|
579
|
+
totalCount: number;
|
|
580
|
+
errorCount: number;
|
|
581
|
+
successCount: number;
|
|
582
|
+
duration: number;
|
|
583
|
+
metadata?: Record<string, any> | undefined;
|
|
409
584
|
};
|
|
410
585
|
status?: AuditLogStatus | undefined;
|
|
411
586
|
createdAt?: string | undefined;
|
|
@@ -416,15 +591,228 @@ export declare const CreationAuditLogSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
416
591
|
reason?: string | undefined;
|
|
417
592
|
env?: Record<string, any> | undefined;
|
|
418
593
|
}>;
|
|
594
|
+
export declare const UpdateAuditLogSchema: z.ZodObject<{
|
|
595
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof AuditLogStatus>>>>;
|
|
596
|
+
createdAt: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
|
|
597
|
+
id: z.ZodString;
|
|
598
|
+
updatedAt: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
|
|
599
|
+
actionType: z.ZodOptional<z.ZodNativeEnum<typeof AuditLogAction>>;
|
|
600
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
601
|
+
entityName: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
|
|
602
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
603
|
+
username: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
|
|
604
|
+
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
605
|
+
spaceDid: z.ZodOptional<z.ZodString>;
|
|
606
|
+
appDid: z.ZodOptional<z.ZodString>;
|
|
607
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
608
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
609
|
+
scopes: z.ZodOptional<z.ZodString>;
|
|
610
|
+
appUrl: z.ZodOptional<z.ZodString>;
|
|
611
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
612
|
+
}, "strip", z.ZodTypeAny, {
|
|
613
|
+
appDid?: string | undefined;
|
|
614
|
+
appName?: string | undefined;
|
|
615
|
+
appDescription?: string | undefined;
|
|
616
|
+
spaceDid?: string | undefined;
|
|
617
|
+
scopes?: string | undefined;
|
|
618
|
+
appUrl?: string | undefined;
|
|
619
|
+
referrer?: string | undefined;
|
|
620
|
+
}, {
|
|
621
|
+
appDid?: string | undefined;
|
|
622
|
+
appName?: string | undefined;
|
|
623
|
+
appDescription?: string | undefined;
|
|
624
|
+
spaceDid?: string | undefined;
|
|
625
|
+
scopes?: string | undefined;
|
|
626
|
+
appUrl?: string | undefined;
|
|
627
|
+
referrer?: string | undefined;
|
|
628
|
+
}>, z.ZodObject<{
|
|
629
|
+
spaceDid: z.ZodOptional<z.ZodString>;
|
|
630
|
+
appDid: z.ZodOptional<z.ZodString>;
|
|
631
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
632
|
+
}, "strip", z.ZodTypeAny, {
|
|
633
|
+
appDid?: string | undefined;
|
|
634
|
+
appName?: string | undefined;
|
|
635
|
+
spaceDid?: string | undefined;
|
|
636
|
+
}, {
|
|
637
|
+
appDid?: string | undefined;
|
|
638
|
+
appName?: string | undefined;
|
|
639
|
+
spaceDid?: string | undefined;
|
|
640
|
+
}>, z.ZodObject<{
|
|
641
|
+
serverDid: z.ZodOptional<z.ZodString>;
|
|
642
|
+
signerDid: z.ZodOptional<z.ZodString>;
|
|
643
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
644
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
645
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
646
|
+
}, "strip", z.ZodTypeAny, {
|
|
647
|
+
appName?: string | undefined;
|
|
648
|
+
appDescription?: string | undefined;
|
|
649
|
+
referrer?: string | undefined;
|
|
650
|
+
serverDid?: string | undefined;
|
|
651
|
+
signerDid?: string | undefined;
|
|
652
|
+
}, {
|
|
653
|
+
appName?: string | undefined;
|
|
654
|
+
appDescription?: string | undefined;
|
|
655
|
+
referrer?: string | undefined;
|
|
656
|
+
serverDid?: string | undefined;
|
|
657
|
+
signerDid?: string | undefined;
|
|
658
|
+
}>, z.ZodObject<{
|
|
659
|
+
serverDid: z.ZodOptional<z.ZodString>;
|
|
660
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
661
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
662
|
+
referrer: z.ZodOptional<z.ZodString>;
|
|
663
|
+
}, "strip", z.ZodTypeAny, {
|
|
664
|
+
appName?: string | undefined;
|
|
665
|
+
appDescription?: string | undefined;
|
|
666
|
+
referrer?: string | undefined;
|
|
667
|
+
serverDid?: string | undefined;
|
|
668
|
+
}, {
|
|
669
|
+
appName?: string | undefined;
|
|
670
|
+
appDescription?: string | undefined;
|
|
671
|
+
referrer?: string | undefined;
|
|
672
|
+
serverDid?: string | undefined;
|
|
673
|
+
}>, z.ZodObject<{
|
|
674
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
675
|
+
appDescription: z.ZodOptional<z.ZodString>;
|
|
676
|
+
source: z.ZodOptional<z.ZodString>;
|
|
677
|
+
target: z.ZodOptional<z.ZodString>;
|
|
678
|
+
totalCount: z.ZodOptional<z.ZodNumber>;
|
|
679
|
+
errorCount: z.ZodOptional<z.ZodNumber>;
|
|
680
|
+
successCount: z.ZodOptional<z.ZodNumber>;
|
|
681
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
682
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
683
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
684
|
+
}, "strip", z.ZodTypeAny, {
|
|
685
|
+
target?: string | undefined;
|
|
686
|
+
size?: number | undefined;
|
|
687
|
+
metadata?: Record<string, any> | undefined;
|
|
688
|
+
appName?: string | undefined;
|
|
689
|
+
appDescription?: string | undefined;
|
|
690
|
+
source?: string | undefined;
|
|
691
|
+
totalCount?: number | undefined;
|
|
692
|
+
errorCount?: number | undefined;
|
|
693
|
+
successCount?: number | undefined;
|
|
694
|
+
duration?: number | undefined;
|
|
695
|
+
}, {
|
|
696
|
+
target?: string | undefined;
|
|
697
|
+
size?: number | undefined;
|
|
698
|
+
metadata?: Record<string, any> | undefined;
|
|
699
|
+
appName?: string | undefined;
|
|
700
|
+
appDescription?: string | undefined;
|
|
701
|
+
source?: string | undefined;
|
|
702
|
+
totalCount?: number | undefined;
|
|
703
|
+
errorCount?: number | undefined;
|
|
704
|
+
successCount?: number | undefined;
|
|
705
|
+
duration?: number | undefined;
|
|
706
|
+
}>]>>;
|
|
707
|
+
reason: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
|
|
708
|
+
env: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>>;
|
|
709
|
+
}, "strip", z.ZodTypeAny, {
|
|
710
|
+
id: string;
|
|
711
|
+
status?: AuditLogStatus | undefined;
|
|
712
|
+
createdAt?: string | undefined;
|
|
713
|
+
updatedAt?: string | undefined;
|
|
714
|
+
actionType?: AuditLogAction | undefined;
|
|
715
|
+
entityId?: string | undefined;
|
|
716
|
+
entityName?: string | undefined;
|
|
717
|
+
userId?: string | undefined;
|
|
718
|
+
username?: string | undefined;
|
|
719
|
+
data?: {
|
|
720
|
+
appDid?: string | undefined;
|
|
721
|
+
appName?: string | undefined;
|
|
722
|
+
appDescription?: string | undefined;
|
|
723
|
+
spaceDid?: string | undefined;
|
|
724
|
+
scopes?: string | undefined;
|
|
725
|
+
appUrl?: string | undefined;
|
|
726
|
+
referrer?: string | undefined;
|
|
727
|
+
} | {
|
|
728
|
+
appDid?: string | undefined;
|
|
729
|
+
appName?: string | undefined;
|
|
730
|
+
spaceDid?: string | undefined;
|
|
731
|
+
} | {
|
|
732
|
+
appName?: string | undefined;
|
|
733
|
+
appDescription?: string | undefined;
|
|
734
|
+
referrer?: string | undefined;
|
|
735
|
+
serverDid?: string | undefined;
|
|
736
|
+
signerDid?: string | undefined;
|
|
737
|
+
} | {
|
|
738
|
+
appName?: string | undefined;
|
|
739
|
+
appDescription?: string | undefined;
|
|
740
|
+
referrer?: string | undefined;
|
|
741
|
+
serverDid?: string | undefined;
|
|
742
|
+
} | {
|
|
743
|
+
target?: string | undefined;
|
|
744
|
+
size?: number | undefined;
|
|
745
|
+
metadata?: Record<string, any> | undefined;
|
|
746
|
+
appName?: string | undefined;
|
|
747
|
+
appDescription?: string | undefined;
|
|
748
|
+
source?: string | undefined;
|
|
749
|
+
totalCount?: number | undefined;
|
|
750
|
+
errorCount?: number | undefined;
|
|
751
|
+
successCount?: number | undefined;
|
|
752
|
+
duration?: number | undefined;
|
|
753
|
+
} | undefined;
|
|
754
|
+
reason?: string | undefined;
|
|
755
|
+
env?: Record<string, any> | undefined;
|
|
756
|
+
}, {
|
|
757
|
+
id: string;
|
|
758
|
+
status?: AuditLogStatus | undefined;
|
|
759
|
+
createdAt?: string | undefined;
|
|
760
|
+
updatedAt?: string | undefined;
|
|
761
|
+
actionType?: AuditLogAction | undefined;
|
|
762
|
+
entityId?: string | undefined;
|
|
763
|
+
entityName?: string | undefined;
|
|
764
|
+
userId?: string | undefined;
|
|
765
|
+
username?: string | undefined;
|
|
766
|
+
data?: {
|
|
767
|
+
appDid?: string | undefined;
|
|
768
|
+
appName?: string | undefined;
|
|
769
|
+
appDescription?: string | undefined;
|
|
770
|
+
spaceDid?: string | undefined;
|
|
771
|
+
scopes?: string | undefined;
|
|
772
|
+
appUrl?: string | undefined;
|
|
773
|
+
referrer?: string | undefined;
|
|
774
|
+
} | {
|
|
775
|
+
appDid?: string | undefined;
|
|
776
|
+
appName?: string | undefined;
|
|
777
|
+
spaceDid?: string | undefined;
|
|
778
|
+
} | {
|
|
779
|
+
appName?: string | undefined;
|
|
780
|
+
appDescription?: string | undefined;
|
|
781
|
+
referrer?: string | undefined;
|
|
782
|
+
serverDid?: string | undefined;
|
|
783
|
+
signerDid?: string | undefined;
|
|
784
|
+
} | {
|
|
785
|
+
appName?: string | undefined;
|
|
786
|
+
appDescription?: string | undefined;
|
|
787
|
+
referrer?: string | undefined;
|
|
788
|
+
serverDid?: string | undefined;
|
|
789
|
+
} | {
|
|
790
|
+
target?: string | undefined;
|
|
791
|
+
size?: number | undefined;
|
|
792
|
+
metadata?: Record<string, any> | undefined;
|
|
793
|
+
appName?: string | undefined;
|
|
794
|
+
appDescription?: string | undefined;
|
|
795
|
+
source?: string | undefined;
|
|
796
|
+
totalCount?: number | undefined;
|
|
797
|
+
errorCount?: number | undefined;
|
|
798
|
+
successCount?: number | undefined;
|
|
799
|
+
duration?: number | undefined;
|
|
800
|
+
} | undefined;
|
|
801
|
+
reason?: string | undefined;
|
|
802
|
+
env?: Record<string, any> | undefined;
|
|
803
|
+
}>;
|
|
804
|
+
export type UpdateAuditLog = z.infer<typeof UpdateAuditLogSchema>;
|
|
419
805
|
export type AppConnected = z.infer<typeof AppConnectedSchema>;
|
|
420
806
|
export type AppDisconnected = z.infer<typeof AppDisconnectedSchema>;
|
|
421
807
|
export type AppBackup = z.infer<typeof AppBackupSchema>;
|
|
422
808
|
export type AppRestore = z.infer<typeof AppRestoreSchema>;
|
|
809
|
+
export type AppObjectsSync = z.infer<typeof AppObjectsSyncSchema>;
|
|
423
810
|
export type AuditLogDataTypeMapping = {
|
|
424
811
|
[AuditLogAction.APP_CONNECTED]: AppConnected;
|
|
425
812
|
[AuditLogAction.APP_DISCONNECTED]: AppDisconnected;
|
|
426
813
|
[AuditLogAction.APP_BACKUP]: AppBackup;
|
|
427
814
|
[AuditLogAction.APP_RESTORE]: AppRestore;
|
|
815
|
+
[AuditLogAction.APP_OBJECTS_SYNC]: AppObjectsSync;
|
|
428
816
|
};
|
|
429
817
|
export interface AuditLogModel<T extends keyof AuditLogDataTypeMapping = AuditLogAction> {
|
|
430
818
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreationAuditLogSchema = exports.AuditLogSchema = exports.AppRestoreSchema = exports.AppBackupSchema = exports.AppDisconnectedSchema = exports.AppConnectedSchema = exports.AuditLogAction = exports.AuditLogStatus = void 0;
|
|
3
|
+
exports.UpdateAuditLogSchema = exports.CreationAuditLogSchema = exports.AuditLogSchema = exports.AppObjectsSyncSchema = exports.AppRestoreSchema = exports.AppBackupSchema = exports.AppDisconnectedSchema = exports.AppConnectedSchema = exports.AuditLogAction = exports.AuditLogStatus = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
var AuditLogStatus;
|
|
6
6
|
(function (AuditLogStatus) {
|
|
@@ -15,6 +15,7 @@ var AuditLogAction;
|
|
|
15
15
|
AuditLogAction["APP_RESTORE"] = "app-restore";
|
|
16
16
|
AuditLogAction["APP_BACKUP"] = "app-backup";
|
|
17
17
|
AuditLogAction["APP_CONNECTED"] = "app-connected";
|
|
18
|
+
AuditLogAction["APP_OBJECTS_SYNC"] = "app-objects-sync";
|
|
18
19
|
})(AuditLogAction = exports.AuditLogAction || (exports.AuditLogAction = {}));
|
|
19
20
|
exports.AppConnectedSchema = zod_1.z.object({
|
|
20
21
|
spaceDid: zod_1.z.string().min(1),
|
|
@@ -49,6 +50,28 @@ exports.AppRestoreSchema = zod_1.z.object({
|
|
|
49
50
|
appDescription: zod_1.z.string(),
|
|
50
51
|
referrer: zod_1.z.string(),
|
|
51
52
|
});
|
|
53
|
+
exports.AppObjectsSyncSchema = zod_1.z.object({
|
|
54
|
+
/** 应用名称 */
|
|
55
|
+
appName: zod_1.z.string().min(1),
|
|
56
|
+
/** 应用描述 */
|
|
57
|
+
appDescription: zod_1.z.string(),
|
|
58
|
+
/** 原路径 */
|
|
59
|
+
source: zod_1.z.string().min(1),
|
|
60
|
+
/** 目标路径 */
|
|
61
|
+
target: zod_1.z.string().min(1),
|
|
62
|
+
/** 总对象数 */
|
|
63
|
+
totalCount: zod_1.z.number(),
|
|
64
|
+
/** 失败对象数 */
|
|
65
|
+
errorCount: zod_1.z.number(),
|
|
66
|
+
/** 成功对象数 */
|
|
67
|
+
successCount: zod_1.z.number(),
|
|
68
|
+
/** 总文件大小 */
|
|
69
|
+
size: zod_1.z.number(),
|
|
70
|
+
/** 同步耗时(ms) */
|
|
71
|
+
duration: zod_1.z.number(),
|
|
72
|
+
/** 元数据 */
|
|
73
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
74
|
+
});
|
|
52
75
|
exports.AuditLogSchema = zod_1.z.object({
|
|
53
76
|
id: zod_1.z.string(),
|
|
54
77
|
actionType: zod_1.z.nativeEnum(AuditLogAction),
|
|
@@ -56,7 +79,7 @@ exports.AuditLogSchema = zod_1.z.object({
|
|
|
56
79
|
entityName: zod_1.z.string().optional().default(''),
|
|
57
80
|
userId: zod_1.z.string().min(1),
|
|
58
81
|
username: zod_1.z.string().optional().default(''),
|
|
59
|
-
data: zod_1.z.union([exports.AppConnectedSchema, exports.AppDisconnectedSchema, exports.AppBackupSchema, exports.AppRestoreSchema]),
|
|
82
|
+
data: zod_1.z.union([exports.AppConnectedSchema, exports.AppDisconnectedSchema, exports.AppBackupSchema, exports.AppRestoreSchema, exports.AppObjectsSyncSchema]),
|
|
60
83
|
status: zod_1.z.nativeEnum(AuditLogStatus).optional().default(AuditLogStatus.SUCCEEDED),
|
|
61
84
|
reason: zod_1.z.string().optional().default(''),
|
|
62
85
|
env: zod_1.z.record(zod_1.z.any()).optional().default({}),
|
|
@@ -70,3 +93,14 @@ exports.AuditLogSchema = zod_1.z.object({
|
|
|
70
93
|
.default(() => new Date().toISOString()),
|
|
71
94
|
});
|
|
72
95
|
exports.CreationAuditLogSchema = exports.AuditLogSchema.extend({ id: exports.AuditLogSchema.shape.id.optional() });
|
|
96
|
+
exports.UpdateAuditLogSchema = exports.AuditLogSchema.extend({
|
|
97
|
+
data: zod_1.z.union([
|
|
98
|
+
exports.AppConnectedSchema.partial(),
|
|
99
|
+
exports.AppDisconnectedSchema.partial(),
|
|
100
|
+
exports.AppBackupSchema.partial(),
|
|
101
|
+
exports.AppRestoreSchema.partial(),
|
|
102
|
+
exports.AppObjectsSyncSchema.partial(),
|
|
103
|
+
]),
|
|
104
|
+
})
|
|
105
|
+
.partial()
|
|
106
|
+
.required({ id: true });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Model } from 'sequelize';
|
|
1
|
+
import type { CreationOptional, Model } from 'sequelize';
|
|
2
2
|
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import type { Permissions } from '../configuration';
|
|
3
4
|
export declare class SpaceRepositoryClass extends Model<SpaceRepositoryClass, SpaceRepositoryClass> {
|
|
4
5
|
id: string;
|
|
5
6
|
drive: string;
|
|
@@ -17,5 +18,10 @@ export declare class SpaceRepositoryClass extends Model<SpaceRepositoryClass, Sp
|
|
|
17
18
|
updateAt: Date | string;
|
|
18
19
|
expireAt: Date;
|
|
19
20
|
ownerDid: string;
|
|
21
|
+
props: CreationOptional<{
|
|
22
|
+
usedUnit?: number;
|
|
23
|
+
usedUnitUpdatedAt?: string;
|
|
24
|
+
permissions?: Permissions;
|
|
25
|
+
}>;
|
|
20
26
|
}
|
|
21
27
|
export type SpaceRepository = typeof SpaceRepositoryClass;
|
|
@@ -111,11 +111,13 @@ class GlobalSpace {
|
|
|
111
111
|
objectId: hash,
|
|
112
112
|
};
|
|
113
113
|
debug('delete.$where', JSON.stringify(where));
|
|
114
|
-
const
|
|
114
|
+
const treeRef = yield this.treeRepository.findOne({
|
|
115
115
|
where,
|
|
116
|
+
raw: true,
|
|
117
|
+
attributes: ['id'],
|
|
116
118
|
});
|
|
117
|
-
debug('delete.$
|
|
118
|
-
if (
|
|
119
|
+
debug('delete.$treeRef', treeRef);
|
|
120
|
+
if (treeRef) {
|
|
119
121
|
yield this.objectCollectionRepository.destroy({ where: { id: hash } });
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
@@ -29,6 +29,7 @@ export declare class ObjectSpace extends EventEmitter implements SpaceProtocol {
|
|
|
29
29
|
readonly globalSpace: GlobalSpace;
|
|
30
30
|
readonly driver: DriverProtocol;
|
|
31
31
|
static readonly READONLY_OBJECT_KEYS: string[];
|
|
32
|
+
readonly configPath = "/config.yml";
|
|
32
33
|
constructor(options: ObjectSpaceOptions);
|
|
33
34
|
createSpace(spaceConfig: SpaceConfig): Promise<void>;
|
|
34
35
|
isSpaceCreated(): Promise<boolean>;
|
|
@@ -90,18 +91,16 @@ export declare class ObjectSpace extends EventEmitter implements SpaceProtocol {
|
|
|
90
91
|
getStatusAsOwner(key: string): Promise<KeyStatus>;
|
|
91
92
|
createConfig(spaceConfig: SpaceConfig): Promise<void>;
|
|
92
93
|
destroyConfig(): Promise<void>;
|
|
93
|
-
set<T = any>(key: string, value: T
|
|
94
|
-
|
|
94
|
+
set<T = any>(key: string, value: T, { isFromStorage }?: {
|
|
95
|
+
isFromStorage: false | true;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
get<T = any>(key: string, defaultValue?: T, { isFromStorage }?: {
|
|
98
|
+
isFromStorage: false | true;
|
|
99
|
+
}): Promise<T>;
|
|
95
100
|
private getPermission;
|
|
96
101
|
/**
|
|
97
102
|
*
|
|
98
103
|
* @see https://blog.csdn.net/a1173537204/article/details/89765932
|
|
99
|
-
* @private
|
|
100
|
-
* @param {PermissionOptions} { fromAppDid, toAppDid }
|
|
101
|
-
* @param {number} permission
|
|
102
|
-
* @param {boolean} status
|
|
103
|
-
* @return {*} {Promise<void>}
|
|
104
|
-
* @memberof S3SpaceConfig
|
|
105
104
|
*/
|
|
106
105
|
private setPermission;
|
|
107
106
|
/**
|