@azlib/cms 0.5.0 → 0.7.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/index.cjs +4800 -1429
- package/dist/index.d.cts +814 -19
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +814 -19
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6295 -2983
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DatabaseClient, PersistenceConfig } from "@azlib/persistence";
|
|
1
2
|
//#region src/core/hooks.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* @azlib/cms - WordPress-style Action and Filter Hook System
|
|
@@ -251,12 +252,33 @@ declare class TaxonomyManager {
|
|
|
251
252
|
removeTerms(contentId: string, termIds: string[]): Promise<void>;
|
|
252
253
|
}
|
|
253
254
|
//#endregion
|
|
255
|
+
//#region src/media/drivers/driver-contract.d.ts
|
|
256
|
+
/**
|
|
257
|
+
* @azlib/cms - Media Storage Driver Contract
|
|
258
|
+
*/
|
|
259
|
+
interface MediaStorageDriver {
|
|
260
|
+
write(input: {
|
|
261
|
+
filename: string;
|
|
262
|
+
buffer: Uint8Array;
|
|
263
|
+
mimeType: string;
|
|
264
|
+
}): Promise<{
|
|
265
|
+
url: string;
|
|
266
|
+
path?: string;
|
|
267
|
+
sizeBytes: number;
|
|
268
|
+
}>;
|
|
269
|
+
read(pathOrUrl: string): Promise<Uint8Array | null>;
|
|
270
|
+
delete(pathOrUrl: string): Promise<boolean>;
|
|
271
|
+
getUrl(path: string): string;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
254
274
|
//#region src/media/media-manager.d.ts
|
|
255
275
|
interface MediaUploadInput {
|
|
256
276
|
filename: string;
|
|
257
277
|
mimeType: string;
|
|
258
|
-
sizeBytes
|
|
278
|
+
sizeBytes?: number;
|
|
279
|
+
buffer?: Uint8Array;
|
|
259
280
|
url?: string;
|
|
281
|
+
path?: string;
|
|
260
282
|
width?: number;
|
|
261
283
|
height?: number;
|
|
262
284
|
altText?: string;
|
|
@@ -267,8 +289,9 @@ declare class MediaManager {
|
|
|
267
289
|
private storage;
|
|
268
290
|
private hooks?;
|
|
269
291
|
private publicBaseUrl;
|
|
292
|
+
private driver?;
|
|
270
293
|
private allowedMimePrefixes;
|
|
271
|
-
constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined, publicBaseUrl?: string);
|
|
294
|
+
constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined, publicBaseUrl?: string, driver?: MediaStorageDriver | undefined);
|
|
272
295
|
/**
|
|
273
296
|
* Upload / register a new media item.
|
|
274
297
|
*/
|
|
@@ -328,6 +351,101 @@ declare class RBACManager {
|
|
|
328
351
|
}): boolean;
|
|
329
352
|
}
|
|
330
353
|
//#endregion
|
|
354
|
+
//#region src/auth/auth-service.d.ts
|
|
355
|
+
interface StoredUserRecord extends CMSUser {
|
|
356
|
+
passwordHash: string;
|
|
357
|
+
createdAt: string;
|
|
358
|
+
updatedAt: string;
|
|
359
|
+
}
|
|
360
|
+
declare class AuthService {
|
|
361
|
+
private config;
|
|
362
|
+
private rbac;
|
|
363
|
+
private users;
|
|
364
|
+
private defaultSecret;
|
|
365
|
+
constructor(config: CMSAuthConfig | undefined, rbac: RBACManager);
|
|
366
|
+
get enabled(): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Register a new user account.
|
|
369
|
+
*/
|
|
370
|
+
register(input: {
|
|
371
|
+
username: string;
|
|
372
|
+
email: string;
|
|
373
|
+
password: string;
|
|
374
|
+
displayName?: string;
|
|
375
|
+
role?: UserRole;
|
|
376
|
+
}): Promise<CMSUser>;
|
|
377
|
+
/**
|
|
378
|
+
* Authenticate with email/username and password.
|
|
379
|
+
*/
|
|
380
|
+
login(identifier: string, password: string): Promise<{
|
|
381
|
+
user: CMSUser;
|
|
382
|
+
token: string;
|
|
383
|
+
}>;
|
|
384
|
+
/**
|
|
385
|
+
* Extract and authenticate user from Request (Bearer JWT, ApiKey, or X-API-Key).
|
|
386
|
+
*/
|
|
387
|
+
authenticateRequest(request: Request): Promise<CMSUser | null>;
|
|
388
|
+
/**
|
|
389
|
+
* Find a user by ID.
|
|
390
|
+
*/
|
|
391
|
+
getUserById(id: string): CMSUser | null;
|
|
392
|
+
private sanitizeUser;
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/core/webhooks.d.ts
|
|
396
|
+
declare function computeHmacSignature(payload: string, secret: string): Promise<string>;
|
|
397
|
+
declare class WebhookManager {
|
|
398
|
+
private hooks?;
|
|
399
|
+
private webhooks;
|
|
400
|
+
private fetchFn;
|
|
401
|
+
constructor(initialWebhooks?: readonly CMSWebhookConfig[], hooks?: HooksManager | undefined, fetchFn?: typeof globalThis.fetch);
|
|
402
|
+
/**
|
|
403
|
+
* Register a new webhook endpoint.
|
|
404
|
+
*/
|
|
405
|
+
registerWebhook(webhook: CMSWebhookConfig): string;
|
|
406
|
+
/**
|
|
407
|
+
* Get all registered webhooks.
|
|
408
|
+
*/
|
|
409
|
+
getWebhooks(): CMSWebhookConfig[];
|
|
410
|
+
/**
|
|
411
|
+
* Delete a webhook by ID.
|
|
412
|
+
*/
|
|
413
|
+
deleteWebhook(id: string): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Dispatch an event to all matching webhooks asynchronously.
|
|
416
|
+
*/
|
|
417
|
+
dispatch(event: CMSWebhookEvent, data: Record<string, unknown>): Promise<{
|
|
418
|
+
url: string;
|
|
419
|
+
success: boolean;
|
|
420
|
+
status?: number;
|
|
421
|
+
}[]>;
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region src/core/preview.d.ts
|
|
425
|
+
/**
|
|
426
|
+
* @azlib/cms - Draft Preview Mode Engine
|
|
427
|
+
*/
|
|
428
|
+
interface PreviewTokenPayload extends Record<string, unknown> {
|
|
429
|
+
contentId: string;
|
|
430
|
+
collection: string;
|
|
431
|
+
scope: "preview";
|
|
432
|
+
}
|
|
433
|
+
declare class PreviewManager {
|
|
434
|
+
private secret;
|
|
435
|
+
constructor(secret?: string);
|
|
436
|
+
/**
|
|
437
|
+
* Mint a signed draft preview token.
|
|
438
|
+
*/
|
|
439
|
+
createPreviewToken(contentId: string, collection: string, expiresInSeconds?: number): Promise<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Verify and unpack a draft preview token.
|
|
442
|
+
*/
|
|
443
|
+
verifyPreviewToken(token: string): Promise<{
|
|
444
|
+
contentId: string;
|
|
445
|
+
collection: string;
|
|
446
|
+
} | null>;
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
331
449
|
//#region src/core/engine.d.ts
|
|
332
450
|
interface CreateContentInput {
|
|
333
451
|
title?: string;
|
|
@@ -350,8 +468,16 @@ interface UpdateContentInput {
|
|
|
350
468
|
interface CollectionService<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
351
469
|
readonly config: CollectionConfig;
|
|
352
470
|
create(input: CreateContentInput, authorId?: string | null): Promise<ContentItem<TData>>;
|
|
353
|
-
findById(id: string
|
|
354
|
-
|
|
471
|
+
findById(id: string, options?: {
|
|
472
|
+
populate?: string[];
|
|
473
|
+
select?: string[];
|
|
474
|
+
locale?: string;
|
|
475
|
+
}): Promise<ContentItem<TData> | null>;
|
|
476
|
+
findBySlug(slug: string, options?: {
|
|
477
|
+
populate?: string[];
|
|
478
|
+
select?: string[];
|
|
479
|
+
locale?: string;
|
|
480
|
+
}): Promise<ContentItem<TData> | null>;
|
|
355
481
|
find(options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<TData>>>;
|
|
356
482
|
update(id: string, input: UpdateContentInput, authorId?: string | null, revisionNote?: string): Promise<ContentItem<TData> | null>;
|
|
357
483
|
delete(id: string): Promise<boolean>;
|
|
@@ -370,6 +496,9 @@ declare class CMSEngine {
|
|
|
370
496
|
readonly taxonomies: TaxonomyManager;
|
|
371
497
|
readonly media: MediaManager;
|
|
372
498
|
readonly rbac: RBACManager;
|
|
499
|
+
readonly auth: AuthService;
|
|
500
|
+
readonly webhooks: WebhookManager;
|
|
501
|
+
readonly preview: PreviewManager;
|
|
373
502
|
readonly revisions: RevisionManager;
|
|
374
503
|
readonly lifecycle: ContentLifecycle;
|
|
375
504
|
private collections;
|
|
@@ -520,11 +649,17 @@ declare function definePlugin<TOptions = void>(factory: (options: TOptions) => C
|
|
|
520
649
|
//#endregion
|
|
521
650
|
//#region src/core/types.d.ts
|
|
522
651
|
type ContentStatus = "draft" | "pending_review" | "scheduled" | "published" | "private" | "trash";
|
|
523
|
-
type FieldType = "text" | "slug" | "richText" | "number" | "boolean" | "select" | "image" | "taxonomy" | "relationship" | "date" | "json" | "repeater";
|
|
652
|
+
type FieldType = "text" | "slug" | "richText" | "number" | "boolean" | "select" | "image" | "taxonomy" | "relationship" | "date" | "json" | "repeater" | "blocks" | "email" | "url" | "array";
|
|
524
653
|
interface SelectOption {
|
|
525
654
|
readonly label: string;
|
|
526
655
|
readonly value: string | number;
|
|
527
656
|
}
|
|
657
|
+
interface BlockDefinition {
|
|
658
|
+
readonly slug: string;
|
|
659
|
+
readonly label: string;
|
|
660
|
+
readonly description?: string;
|
|
661
|
+
readonly fields: readonly FieldDefinition[];
|
|
662
|
+
}
|
|
528
663
|
interface FieldDefinition<TValue = any> {
|
|
529
664
|
readonly name: string;
|
|
530
665
|
readonly type: FieldType;
|
|
@@ -538,6 +673,10 @@ interface FieldDefinition<TValue = any> {
|
|
|
538
673
|
readonly targetCollection?: string;
|
|
539
674
|
readonly fromField?: string;
|
|
540
675
|
readonly fields?: readonly FieldDefinition[];
|
|
676
|
+
readonly blocks?: readonly BlockDefinition[];
|
|
677
|
+
readonly readRoles?: readonly string[];
|
|
678
|
+
readonly writeRoles?: readonly string[];
|
|
679
|
+
readonly localized?: boolean;
|
|
541
680
|
readonly min?: number;
|
|
542
681
|
readonly max?: number;
|
|
543
682
|
readonly pattern?: string;
|
|
@@ -559,6 +698,21 @@ interface CollectionConfig {
|
|
|
559
698
|
readonly direction: "asc" | "desc";
|
|
560
699
|
};
|
|
561
700
|
}
|
|
701
|
+
interface QueryOperatorExpression {
|
|
702
|
+
$eq?: unknown;
|
|
703
|
+
$ne?: unknown;
|
|
704
|
+
$gt?: unknown;
|
|
705
|
+
$gte?: unknown;
|
|
706
|
+
$lt?: unknown;
|
|
707
|
+
$lte?: unknown;
|
|
708
|
+
$in?: unknown[];
|
|
709
|
+
$nin?: unknown[];
|
|
710
|
+
$contains?: string;
|
|
711
|
+
$startsWith?: string;
|
|
712
|
+
$endsWith?: string;
|
|
713
|
+
$between?: [unknown, unknown];
|
|
714
|
+
$exists?: boolean;
|
|
715
|
+
}
|
|
562
716
|
interface ContentItem<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
563
717
|
id: string;
|
|
564
718
|
collection: string;
|
|
@@ -572,8 +726,10 @@ interface ContentItem<TData extends Record<string, unknown> = Record<string, unk
|
|
|
572
726
|
createdAt: string;
|
|
573
727
|
updatedAt: string;
|
|
574
728
|
version: number;
|
|
729
|
+
locale?: string;
|
|
575
730
|
data: TData;
|
|
576
731
|
terms?: Record<string, string[]>;
|
|
732
|
+
populated?: Record<string, unknown>;
|
|
577
733
|
}
|
|
578
734
|
interface ContentQueryOptions {
|
|
579
735
|
status?: ContentStatus | ContentStatus[];
|
|
@@ -581,13 +737,17 @@ interface ContentQueryOptions {
|
|
|
581
737
|
parentId?: string | null;
|
|
582
738
|
termIds?: string[];
|
|
583
739
|
search?: string;
|
|
584
|
-
where?: Record<string, unknown>;
|
|
740
|
+
where?: Record<string, unknown | QueryOperatorExpression>;
|
|
585
741
|
orderBy?: string;
|
|
586
742
|
orderDirection?: "asc" | "desc";
|
|
587
743
|
limit?: number;
|
|
588
744
|
offset?: number;
|
|
589
745
|
includeRevisions?: boolean;
|
|
590
746
|
includeTerms?: boolean;
|
|
747
|
+
populate?: string[];
|
|
748
|
+
select?: string[];
|
|
749
|
+
locale?: string;
|
|
750
|
+
fallbackLocale?: string;
|
|
591
751
|
}
|
|
592
752
|
interface PaginatedResult<T> {
|
|
593
753
|
items: T[];
|
|
@@ -683,6 +843,44 @@ interface SiteConfig {
|
|
|
683
843
|
locale?: string;
|
|
684
844
|
timezone?: string;
|
|
685
845
|
}
|
|
846
|
+
interface CMSApiKeyConfig {
|
|
847
|
+
key: string;
|
|
848
|
+
role: UserRole;
|
|
849
|
+
name?: string;
|
|
850
|
+
capabilities?: string[];
|
|
851
|
+
}
|
|
852
|
+
interface CMSAuthConfig {
|
|
853
|
+
enabled?: boolean;
|
|
854
|
+
jwtSecret?: string;
|
|
855
|
+
tokenExpiresIn?: string | number;
|
|
856
|
+
apiKeys?: CMSApiKeyConfig[];
|
|
857
|
+
publicCollections?: string[];
|
|
858
|
+
publicMutations?: boolean;
|
|
859
|
+
}
|
|
860
|
+
type CMSWebhookEvent = "content.created" | "content.updated" | "content.deleted" | "content.published" | "media.uploaded" | "media.deleted" | (string & {});
|
|
861
|
+
interface CMSWebhookConfig {
|
|
862
|
+
id?: string;
|
|
863
|
+
name: string;
|
|
864
|
+
url: string;
|
|
865
|
+
secret?: string;
|
|
866
|
+
events: CMSWebhookEvent[];
|
|
867
|
+
enabled?: boolean;
|
|
868
|
+
headers?: Record<string, string>;
|
|
869
|
+
}
|
|
870
|
+
interface MediaStorageDriver$1 {
|
|
871
|
+
write(input: {
|
|
872
|
+
filename: string;
|
|
873
|
+
buffer: Uint8Array;
|
|
874
|
+
mimeType: string;
|
|
875
|
+
}): Promise<{
|
|
876
|
+
url: string;
|
|
877
|
+
path?: string;
|
|
878
|
+
sizeBytes: number;
|
|
879
|
+
}>;
|
|
880
|
+
read(pathOrUrl: string): Promise<Uint8Array | null>;
|
|
881
|
+
delete(pathOrUrl: string): Promise<boolean>;
|
|
882
|
+
getUrl(path: string): string;
|
|
883
|
+
}
|
|
686
884
|
interface CMSConfig {
|
|
687
885
|
site?: SiteConfig;
|
|
688
886
|
collections: readonly CollectionConfig[];
|
|
@@ -692,6 +890,19 @@ interface CMSConfig {
|
|
|
692
890
|
route?: string;
|
|
693
891
|
enableRegistration?: boolean;
|
|
694
892
|
};
|
|
893
|
+
auth?: CMSAuthConfig;
|
|
894
|
+
webhooks?: readonly CMSWebhookConfig[];
|
|
895
|
+
media?: {
|
|
896
|
+
storageDriver?: MediaStorageDriver$1;
|
|
897
|
+
uploadDir?: string;
|
|
898
|
+
publicBaseUrl?: string;
|
|
899
|
+
maxSizeBytes?: number;
|
|
900
|
+
};
|
|
901
|
+
i18n?: {
|
|
902
|
+
defaultLocale: string;
|
|
903
|
+
locales: readonly string[];
|
|
904
|
+
fallback?: boolean;
|
|
905
|
+
};
|
|
695
906
|
}
|
|
696
907
|
//#endregion
|
|
697
908
|
//#region src/core/config.d.ts
|
|
@@ -709,7 +920,12 @@ declare function defineConfig(config: CMSConfig): CMSConfig;
|
|
|
709
920
|
declare function normalizeConfig(config: Partial<CMSConfig>): CMSConfig;
|
|
710
921
|
//#endregion
|
|
711
922
|
//#region src/content/schema.d.ts
|
|
712
|
-
interface
|
|
923
|
+
interface BaseFieldOptions {
|
|
924
|
+
readRoles?: readonly (UserRole | string)[];
|
|
925
|
+
writeRoles?: readonly (UserRole | string)[];
|
|
926
|
+
localized?: boolean;
|
|
927
|
+
}
|
|
928
|
+
interface TextFieldOptions extends BaseFieldOptions {
|
|
713
929
|
name: string;
|
|
714
930
|
label?: string;
|
|
715
931
|
description?: string;
|
|
@@ -721,21 +937,21 @@ interface TextFieldOptions {
|
|
|
721
937
|
pattern?: string;
|
|
722
938
|
validate?: (value: string, data: Record<string, unknown>) => string | null | boolean;
|
|
723
939
|
}
|
|
724
|
-
interface SlugFieldOptions {
|
|
940
|
+
interface SlugFieldOptions extends BaseFieldOptions {
|
|
725
941
|
name?: string;
|
|
726
942
|
label?: string;
|
|
727
943
|
from?: string;
|
|
728
944
|
required?: boolean;
|
|
729
945
|
unique?: boolean;
|
|
730
946
|
}
|
|
731
|
-
interface RichTextFieldOptions {
|
|
947
|
+
interface RichTextFieldOptions extends BaseFieldOptions {
|
|
732
948
|
name: string;
|
|
733
949
|
label?: string;
|
|
734
950
|
description?: string;
|
|
735
951
|
required?: boolean;
|
|
736
952
|
defaultValue?: string;
|
|
737
953
|
}
|
|
738
|
-
interface NumberFieldOptions {
|
|
954
|
+
interface NumberFieldOptions extends BaseFieldOptions {
|
|
739
955
|
name: string;
|
|
740
956
|
label?: string;
|
|
741
957
|
description?: string;
|
|
@@ -744,13 +960,13 @@ interface NumberFieldOptions {
|
|
|
744
960
|
min?: number;
|
|
745
961
|
max?: number;
|
|
746
962
|
}
|
|
747
|
-
interface BooleanFieldOptions {
|
|
963
|
+
interface BooleanFieldOptions extends BaseFieldOptions {
|
|
748
964
|
name: string;
|
|
749
965
|
label?: string;
|
|
750
966
|
description?: string;
|
|
751
967
|
defaultValue?: boolean;
|
|
752
968
|
}
|
|
753
|
-
interface SelectFieldOptions {
|
|
969
|
+
interface SelectFieldOptions extends BaseFieldOptions {
|
|
754
970
|
name: string;
|
|
755
971
|
label?: string;
|
|
756
972
|
description?: string;
|
|
@@ -758,40 +974,40 @@ interface SelectFieldOptions {
|
|
|
758
974
|
options: readonly (string | SelectOption)[];
|
|
759
975
|
defaultValue?: string | number;
|
|
760
976
|
}
|
|
761
|
-
interface ImageFieldOptions {
|
|
977
|
+
interface ImageFieldOptions extends BaseFieldOptions {
|
|
762
978
|
name: string;
|
|
763
979
|
label?: string;
|
|
764
980
|
description?: string;
|
|
765
981
|
required?: boolean;
|
|
766
982
|
}
|
|
767
|
-
interface TaxonomyFieldOptions {
|
|
983
|
+
interface TaxonomyFieldOptions extends BaseFieldOptions {
|
|
768
984
|
name: string;
|
|
769
985
|
taxonomy: string;
|
|
770
986
|
label?: string;
|
|
771
987
|
required?: boolean;
|
|
772
988
|
}
|
|
773
|
-
interface RelationshipFieldOptions {
|
|
989
|
+
interface RelationshipFieldOptions extends BaseFieldOptions {
|
|
774
990
|
name: string;
|
|
775
991
|
targetCollection: string;
|
|
776
992
|
label?: string;
|
|
777
993
|
description?: string;
|
|
778
994
|
required?: boolean;
|
|
779
995
|
}
|
|
780
|
-
interface DateFieldOptions {
|
|
996
|
+
interface DateFieldOptions extends BaseFieldOptions {
|
|
781
997
|
name: string;
|
|
782
998
|
label?: string;
|
|
783
999
|
description?: string;
|
|
784
1000
|
required?: boolean;
|
|
785
1001
|
defaultValue?: string;
|
|
786
1002
|
}
|
|
787
|
-
interface JsonFieldOptions {
|
|
1003
|
+
interface JsonFieldOptions extends BaseFieldOptions {
|
|
788
1004
|
name: string;
|
|
789
1005
|
label?: string;
|
|
790
1006
|
description?: string;
|
|
791
1007
|
required?: boolean;
|
|
792
1008
|
defaultValue?: unknown;
|
|
793
1009
|
}
|
|
794
|
-
interface RepeaterFieldOptions {
|
|
1010
|
+
interface RepeaterFieldOptions extends BaseFieldOptions {
|
|
795
1011
|
name: string;
|
|
796
1012
|
label?: string;
|
|
797
1013
|
description?: string;
|
|
@@ -799,6 +1015,37 @@ interface RepeaterFieldOptions {
|
|
|
799
1015
|
min?: number;
|
|
800
1016
|
max?: number;
|
|
801
1017
|
}
|
|
1018
|
+
interface BlocksFieldOptions extends BaseFieldOptions {
|
|
1019
|
+
name: string;
|
|
1020
|
+
label?: string;
|
|
1021
|
+
description?: string;
|
|
1022
|
+
required?: boolean;
|
|
1023
|
+
blocks: readonly BlockDefinition[];
|
|
1024
|
+
min?: number;
|
|
1025
|
+
max?: number;
|
|
1026
|
+
}
|
|
1027
|
+
interface EmailFieldOptions extends BaseFieldOptions {
|
|
1028
|
+
name: string;
|
|
1029
|
+
label?: string;
|
|
1030
|
+
description?: string;
|
|
1031
|
+
required?: boolean;
|
|
1032
|
+
defaultValue?: string;
|
|
1033
|
+
unique?: boolean;
|
|
1034
|
+
}
|
|
1035
|
+
interface UrlFieldOptions extends BaseFieldOptions {
|
|
1036
|
+
name: string;
|
|
1037
|
+
label?: string;
|
|
1038
|
+
description?: string;
|
|
1039
|
+
required?: boolean;
|
|
1040
|
+
defaultValue?: string;
|
|
1041
|
+
}
|
|
1042
|
+
interface ArrayFieldOptions extends BaseFieldOptions {
|
|
1043
|
+
name: string;
|
|
1044
|
+
label?: string;
|
|
1045
|
+
description?: string;
|
|
1046
|
+
required?: boolean;
|
|
1047
|
+
defaultValue?: unknown[];
|
|
1048
|
+
}
|
|
802
1049
|
declare const fields: {
|
|
803
1050
|
text(options: TextFieldOptions): FieldDefinition<string>;
|
|
804
1051
|
slug(options?: SlugFieldOptions): FieldDefinition<string>;
|
|
@@ -812,6 +1059,13 @@ declare const fields: {
|
|
|
812
1059
|
date(options: DateFieldOptions): FieldDefinition<string>;
|
|
813
1060
|
json(options: JsonFieldOptions): FieldDefinition<unknown>;
|
|
814
1061
|
repeater(options: RepeaterFieldOptions): FieldDefinition<Record<string, unknown>[]>;
|
|
1062
|
+
blocks(options: BlocksFieldOptions): FieldDefinition<{
|
|
1063
|
+
blockType: string;
|
|
1064
|
+
[key: string]: unknown;
|
|
1065
|
+
}[]>;
|
|
1066
|
+
email(options: EmailFieldOptions): FieldDefinition<string>;
|
|
1067
|
+
url(options: UrlFieldOptions): FieldDefinition<string>;
|
|
1068
|
+
array(options: ArrayFieldOptions): FieldDefinition<unknown[]>;
|
|
815
1069
|
};
|
|
816
1070
|
interface CollectionOptions {
|
|
817
1071
|
slug: string;
|
|
@@ -841,6 +1095,16 @@ declare function validateAndNormalizeData(fieldsList: readonly FieldDefinition[]
|
|
|
841
1095
|
errors: Record<string, string>;
|
|
842
1096
|
};
|
|
843
1097
|
//#endregion
|
|
1098
|
+
//#region src/content/i18n.d.ts
|
|
1099
|
+
/**
|
|
1100
|
+
* Resolve localized fields on a content record for a target locale.
|
|
1101
|
+
*/
|
|
1102
|
+
declare function resolveLocalizedData(data: Record<string, unknown>, fieldsList: readonly FieldDefinition[], targetLocale: string, fallbackLocale?: string): Record<string, unknown>;
|
|
1103
|
+
/**
|
|
1104
|
+
* Merge an incoming update for a specific locale into existing localized dictionaries.
|
|
1105
|
+
*/
|
|
1106
|
+
declare function mergeLocalizedInput(incomingData: Record<string, unknown>, existingData: Record<string, unknown> | undefined, fieldsList: readonly FieldDefinition[], locale: string): Record<string, unknown>;
|
|
1107
|
+
//#endregion
|
|
844
1108
|
//#region src/content/slug.d.ts
|
|
845
1109
|
/**
|
|
846
1110
|
* @azlib/cms - Slug generation and normalization utility
|
|
@@ -854,6 +1118,38 @@ declare function slugify(input: string): string;
|
|
|
854
1118
|
*/
|
|
855
1119
|
declare function resolveUniqueSlug(baseSlug: string, isSlugTaken: (slug: string) => Promise<boolean> | boolean, currentId?: string): Promise<string>;
|
|
856
1120
|
//#endregion
|
|
1121
|
+
//#region src/media/drivers/disk-driver.d.ts
|
|
1122
|
+
interface DiskMediaStorageDriverOptions {
|
|
1123
|
+
uploadDir: string;
|
|
1124
|
+
publicBaseUrl?: string;
|
|
1125
|
+
}
|
|
1126
|
+
declare class DiskMediaStorageDriver implements MediaStorageDriver {
|
|
1127
|
+
private uploadDir;
|
|
1128
|
+
private publicBaseUrl;
|
|
1129
|
+
constructor(options: DiskMediaStorageDriverOptions);
|
|
1130
|
+
write(input: {
|
|
1131
|
+
filename: string;
|
|
1132
|
+
buffer: Uint8Array;
|
|
1133
|
+
mimeType: string;
|
|
1134
|
+
}): Promise<{
|
|
1135
|
+
url: string;
|
|
1136
|
+
path: string;
|
|
1137
|
+
sizeBytes: number;
|
|
1138
|
+
}>;
|
|
1139
|
+
read(pathOrUrl: string): Promise<Uint8Array | null>;
|
|
1140
|
+
delete(pathOrUrl: string): Promise<boolean>;
|
|
1141
|
+
getUrl(filePathOrName: string): string;
|
|
1142
|
+
}
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region src/auth/jwt.d.ts
|
|
1145
|
+
/**
|
|
1146
|
+
* @azlib/cms - Universal Web Crypto JWT & Password Hashing
|
|
1147
|
+
*/
|
|
1148
|
+
declare function signJwt(payload: Record<string, unknown>, secret: string, expiresInSeconds?: number): Promise<string>;
|
|
1149
|
+
declare function verifyJwt<T extends Record<string, unknown> = Record<string, unknown>>(token: string, secret: string): Promise<T | null>;
|
|
1150
|
+
declare function hashPassword(password: string): Promise<string>;
|
|
1151
|
+
declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
1152
|
+
//#endregion
|
|
857
1153
|
//#region src/storage/memory-adapter.d.ts
|
|
858
1154
|
declare class MemoryStorageAdapter implements CMSStorageAdapter {
|
|
859
1155
|
private content;
|
|
@@ -868,6 +1164,8 @@ declare class MemoryStorageAdapter implements CMSStorageAdapter {
|
|
|
868
1164
|
getContent<T extends Record<string, unknown>>(collection: string, id: string): Promise<ContentItem<T> | null>;
|
|
869
1165
|
getContentBySlug<T extends Record<string, unknown>>(collection: string, slug: string): Promise<ContentItem<T> | null>;
|
|
870
1166
|
findContent<T extends Record<string, unknown>>(collection: string, options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<T>>>;
|
|
1167
|
+
private populateItem;
|
|
1168
|
+
private projectItem;
|
|
871
1169
|
updateContent<T extends Record<string, unknown>>(collection: string, id: string, updates: Partial<Omit<ContentItem<T>, "id" | "collection" | "createdAt">>): Promise<ContentItem<T> | null>;
|
|
872
1170
|
deleteContent(collection: string, id: string): Promise<boolean>;
|
|
873
1171
|
countContent(collection: string, options?: ContentQueryOptions): Promise<number>;
|
|
@@ -904,6 +1202,63 @@ declare class MemoryStorageAdapter implements CMSStorageAdapter {
|
|
|
904
1202
|
getOptions(namespace?: string): Promise<OptionItem[]>;
|
|
905
1203
|
}
|
|
906
1204
|
//#endregion
|
|
1205
|
+
//#region src/storage/persistence-adapter.d.ts
|
|
1206
|
+
interface PersistenceStorageAdapterOptions {
|
|
1207
|
+
client: DatabaseClient;
|
|
1208
|
+
config: PersistenceConfig;
|
|
1209
|
+
autoMigrate?: boolean;
|
|
1210
|
+
}
|
|
1211
|
+
declare class PersistenceStorageAdapter implements CMSStorageAdapter {
|
|
1212
|
+
private client;
|
|
1213
|
+
private config;
|
|
1214
|
+
private autoMigrate;
|
|
1215
|
+
constructor(options: PersistenceStorageAdapterOptions);
|
|
1216
|
+
init(): Promise<void>;
|
|
1217
|
+
close(): Promise<void>;
|
|
1218
|
+
createContent<T extends Record<string, unknown>>(item: Omit<ContentItem<T>, "id" | "createdAt" | "updatedAt" | "version">): Promise<ContentItem<T>>;
|
|
1219
|
+
getContent<T extends Record<string, unknown>>(collection: string, id: string): Promise<ContentItem<T> | null>;
|
|
1220
|
+
getContentBySlug<T extends Record<string, unknown>>(collection: string, slug: string): Promise<ContentItem<T> | null>;
|
|
1221
|
+
findContent<T extends Record<string, unknown>>(collection: string, options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<T>>>;
|
|
1222
|
+
updateContent<T extends Record<string, unknown>>(collection: string, id: string, updates: Partial<Omit<ContentItem<T>, "id" | "collection" | "createdAt">>): Promise<ContentItem<T> | null>;
|
|
1223
|
+
deleteContent(collection: string, id: string): Promise<boolean>;
|
|
1224
|
+
countContent(collection: string, options?: ContentQueryOptions): Promise<number>;
|
|
1225
|
+
createRevision(contentId: string, collection: string, version: number, snapshot: ContentItem, authorId?: string | null, note?: string): Promise<RevisionRecord>;
|
|
1226
|
+
getRevisions(contentId: string): Promise<RevisionRecord[]>;
|
|
1227
|
+
getRevision(revisionId: string): Promise<RevisionRecord | null>;
|
|
1228
|
+
deleteRevisionsByContentId(contentId: string): Promise<number>;
|
|
1229
|
+
createTerm(term: Omit<TermItem, "id" | "count" | "createdAt" | "updatedAt">): Promise<TermItem>;
|
|
1230
|
+
getTermById(id: string): Promise<TermItem | null>;
|
|
1231
|
+
getTermBySlug(taxonomy: string, slug: string): Promise<TermItem | null>;
|
|
1232
|
+
getTerms(taxonomy: string, options?: {
|
|
1233
|
+
parentId?: string | null;
|
|
1234
|
+
}): Promise<TermItem[]>;
|
|
1235
|
+
updateTerm(id: string, updates: Partial<Omit<TermItem, "id" | "taxonomy" | "createdAt">>): Promise<TermItem | null>;
|
|
1236
|
+
deleteTerm(id: string): Promise<boolean>;
|
|
1237
|
+
assignTermsToContent(contentId: string, termIds: string[]): Promise<void>;
|
|
1238
|
+
getContentTerms(contentId: string, taxonomy?: string): Promise<TermItem[]>;
|
|
1239
|
+
removeTermsFromContent(contentId: string, termIds: string[]): Promise<void>;
|
|
1240
|
+
createMedia(item: Omit<MediaItem, "id" | "createdAt" | "updatedAt">): Promise<MediaItem>;
|
|
1241
|
+
getMedia(id: string): Promise<MediaItem | null>;
|
|
1242
|
+
findMedia(options?: {
|
|
1243
|
+
search?: string;
|
|
1244
|
+
mimeType?: string;
|
|
1245
|
+
authorId?: string;
|
|
1246
|
+
limit?: number;
|
|
1247
|
+
offset?: number;
|
|
1248
|
+
}): Promise<PaginatedResult<MediaItem>>;
|
|
1249
|
+
updateMedia(id: string, updates: Partial<Omit<MediaItem, "id" | "createdAt">>): Promise<MediaItem | null>;
|
|
1250
|
+
deleteMedia(id: string): Promise<boolean>;
|
|
1251
|
+
getOption<T = unknown>(key: string): Promise<OptionItem<T> | null>;
|
|
1252
|
+
setOption<T = unknown>(item: OptionItem<T>): Promise<void>;
|
|
1253
|
+
deleteOption(key: string): Promise<boolean>;
|
|
1254
|
+
getOptions(namespace?: string): Promise<OptionItem[]>;
|
|
1255
|
+
private deserializeContent;
|
|
1256
|
+
private deserializeTerm;
|
|
1257
|
+
private deserializeMedia;
|
|
1258
|
+
private populateItem;
|
|
1259
|
+
private matchesCondition;
|
|
1260
|
+
}
|
|
1261
|
+
//#endregion
|
|
907
1262
|
//#region src/api/router.d.ts
|
|
908
1263
|
declare class CMSRouter {
|
|
909
1264
|
private engine;
|
|
@@ -918,10 +1273,12 @@ declare class CMSRouter {
|
|
|
918
1273
|
*/
|
|
919
1274
|
handle(request: Request): Promise<Response>;
|
|
920
1275
|
private handleCustomRoute;
|
|
1276
|
+
private handleAuth;
|
|
921
1277
|
private handleContent;
|
|
922
1278
|
private handleTaxonomies;
|
|
923
1279
|
private handleMedia;
|
|
924
1280
|
private handleOptions;
|
|
1281
|
+
private filterRestrictedFields;
|
|
925
1282
|
}
|
|
926
1283
|
declare function createCMSRouter(engine: CMSEngine): CMSRouter;
|
|
927
1284
|
//#endregion
|
|
@@ -1895,5 +2252,443 @@ declare const hrmsPlugin: (options?: void | HRMSPluginOptions | undefined) => CM
|
|
|
1895
2252
|
*/
|
|
1896
2253
|
declare function getHRMSService(engine: CMSEngine, options?: HRMSPluginOptions): HRMSService;
|
|
1897
2254
|
//#endregion
|
|
1898
|
-
|
|
2255
|
+
//#region src/plugins/transfer/types.d.ts
|
|
2256
|
+
type SourceFormat = "json" | "excel" | "csv";
|
|
2257
|
+
type InferredFieldType = "string" | "number" | "boolean" | "date" | "object" | "array" | "unknown";
|
|
2258
|
+
interface SourceFieldSchema {
|
|
2259
|
+
name: string;
|
|
2260
|
+
inferredType: InferredFieldType;
|
|
2261
|
+
sampleValues: unknown[];
|
|
2262
|
+
nullCount: number;
|
|
2263
|
+
totalCount: number;
|
|
2264
|
+
}
|
|
2265
|
+
interface CollectionFieldSummary {
|
|
2266
|
+
name: string;
|
|
2267
|
+
label: string;
|
|
2268
|
+
type: string;
|
|
2269
|
+
required: boolean;
|
|
2270
|
+
unique?: boolean;
|
|
2271
|
+
description?: string;
|
|
2272
|
+
defaultValue?: unknown;
|
|
2273
|
+
targetCollection?: string;
|
|
2274
|
+
options?: readonly (string | {
|
|
2275
|
+
label: string;
|
|
2276
|
+
value: string | number;
|
|
2277
|
+
})[];
|
|
2278
|
+
}
|
|
2279
|
+
interface CollectionSchemaSummary {
|
|
2280
|
+
slug: string;
|
|
2281
|
+
label: string;
|
|
2282
|
+
singularLabel: string;
|
|
2283
|
+
description?: string;
|
|
2284
|
+
fields: CollectionFieldSummary[];
|
|
2285
|
+
taxonomies: readonly string[];
|
|
2286
|
+
}
|
|
2287
|
+
interface SuggestedMappingRule {
|
|
2288
|
+
sourceField: string;
|
|
2289
|
+
targetField: string;
|
|
2290
|
+
confidence: number;
|
|
2291
|
+
}
|
|
2292
|
+
interface SourceInspectionResult {
|
|
2293
|
+
format: SourceFormat;
|
|
2294
|
+
sheets?: string[];
|
|
2295
|
+
selectedSheet?: string;
|
|
2296
|
+
totalRows: number;
|
|
2297
|
+
sourceFields: SourceFieldSchema[];
|
|
2298
|
+
targetSchema?: CollectionSchemaSummary;
|
|
2299
|
+
suggestedMapping?: SuggestedMappingRule[];
|
|
2300
|
+
previewRows: Record<string, unknown>[];
|
|
2301
|
+
}
|
|
2302
|
+
type FieldTransformPreset = "trim" | "lowercase" | "uppercase" | "number" | "boolean" | "date" | "json" | "slug" | "split_comma" | "identity";
|
|
2303
|
+
type FieldTransformFn = (value: unknown, record: Record<string, unknown>) => unknown;
|
|
2304
|
+
interface FieldMappingRule {
|
|
2305
|
+
/** Column / property name in source data */
|
|
2306
|
+
sourceField: string;
|
|
2307
|
+
/** Field name in target CMS collection */
|
|
2308
|
+
targetField: string;
|
|
2309
|
+
/** Transformation preset or custom transform callback */
|
|
2310
|
+
transform?: FieldTransformPreset | FieldTransformFn;
|
|
2311
|
+
/** Default fallback value if source value is null, undefined, or empty string */
|
|
2312
|
+
defaultValue?: unknown;
|
|
2313
|
+
/** If true, this field must be present and valid */
|
|
2314
|
+
required?: boolean;
|
|
2315
|
+
}
|
|
2316
|
+
interface MappingOptions {
|
|
2317
|
+
/** Strip/ignore source fields that are not explicitly mapped (default: true) */
|
|
2318
|
+
ignoreUnmappedFields?: boolean;
|
|
2319
|
+
/** Default content item status: 'draft' | 'published' | 'archived' */
|
|
2320
|
+
defaultStatus?: "draft" | "published" | "archived";
|
|
2321
|
+
/** Mapped field that supplies status value */
|
|
2322
|
+
statusField?: string;
|
|
2323
|
+
/** Auto generate unique slug from title if no slug is mapped (default: true) */
|
|
2324
|
+
autoGenerateSlug?: boolean;
|
|
2325
|
+
/** Worksheet name for multi-sheet Excel files */
|
|
2326
|
+
sheetName?: string;
|
|
2327
|
+
/** Date format parsing hint */
|
|
2328
|
+
dateFormat?: string;
|
|
2329
|
+
/** Action when duplicate unique field is encountered */
|
|
2330
|
+
onDuplicate?: "error" | "update" | "skip";
|
|
2331
|
+
/** Key field to identify existing record when updating (defaults to id, slug, or unique field) */
|
|
2332
|
+
uniqueIdentifierField?: string;
|
|
2333
|
+
/** Abort entire import on first error (default: false) */
|
|
2334
|
+
abortOnError?: boolean;
|
|
2335
|
+
}
|
|
2336
|
+
interface DataMappingDefinition {
|
|
2337
|
+
id?: string;
|
|
2338
|
+
name?: string;
|
|
2339
|
+
collectionSlug: string;
|
|
2340
|
+
fields: FieldMappingRule[];
|
|
2341
|
+
options?: MappingOptions;
|
|
2342
|
+
}
|
|
2343
|
+
type TransferErrorCode = "REQUIRED_FIELD_MISSING" | "INVALID_DATA_TYPE" | "INVALID_SELECT_OPTION" | "CONSTRAINT_UNIQUE_VIOLATION" | "CONSTRAINT_FOREIGN_KEY_VIOLATION" | "VALIDATION_RULE_FAILED" | "TRANSFORM_ERROR" | "PARSE_ERROR";
|
|
2344
|
+
interface TransferErrorDetail {
|
|
2345
|
+
rowNumber: number;
|
|
2346
|
+
field?: string;
|
|
2347
|
+
value?: unknown;
|
|
2348
|
+
code: TransferErrorCode;
|
|
2349
|
+
reason: string;
|
|
2350
|
+
}
|
|
2351
|
+
interface ValidationPreviewRow {
|
|
2352
|
+
rowNumber: number;
|
|
2353
|
+
raw: Record<string, unknown>;
|
|
2354
|
+
mapped: Record<string, unknown>;
|
|
2355
|
+
valid: boolean;
|
|
2356
|
+
errors?: TransferErrorDetail[];
|
|
2357
|
+
}
|
|
2358
|
+
interface ValidationResult {
|
|
2359
|
+
valid: boolean;
|
|
2360
|
+
totalRows: number;
|
|
2361
|
+
validCount: number;
|
|
2362
|
+
errorCount: number;
|
|
2363
|
+
errors: TransferErrorDetail[];
|
|
2364
|
+
previewRows: ValidationPreviewRow[];
|
|
2365
|
+
}
|
|
2366
|
+
interface TransferImportOptions {
|
|
2367
|
+
onDuplicate?: "error" | "update" | "skip";
|
|
2368
|
+
uniqueIdentifierField?: string;
|
|
2369
|
+
abortOnError?: boolean;
|
|
2370
|
+
authorId?: string | null;
|
|
2371
|
+
revisionNote?: string;
|
|
2372
|
+
dryRun?: boolean;
|
|
2373
|
+
}
|
|
2374
|
+
interface TransferImportResult {
|
|
2375
|
+
success: boolean;
|
|
2376
|
+
collectionSlug: string;
|
|
2377
|
+
totalRows: number;
|
|
2378
|
+
importedCount: number;
|
|
2379
|
+
updatedCount: number;
|
|
2380
|
+
skippedCount: number;
|
|
2381
|
+
failedCount: number;
|
|
2382
|
+
createdIds: string[];
|
|
2383
|
+
updatedIds: string[];
|
|
2384
|
+
errors: TransferErrorDetail[];
|
|
2385
|
+
}
|
|
2386
|
+
interface TransferExportOptions {
|
|
2387
|
+
collectionSlug?: string;
|
|
2388
|
+
format?: SourceFormat;
|
|
2389
|
+
mapping?: DataMappingDefinition;
|
|
2390
|
+
fields?: string[];
|
|
2391
|
+
query?: ContentQueryOptions;
|
|
2392
|
+
fileName?: string;
|
|
2393
|
+
sheetName?: string;
|
|
2394
|
+
includeId?: boolean;
|
|
2395
|
+
includeTimestamps?: boolean;
|
|
2396
|
+
}
|
|
2397
|
+
interface TransferExportResult {
|
|
2398
|
+
format: SourceFormat;
|
|
2399
|
+
data: Uint8Array | string;
|
|
2400
|
+
mimeType: string;
|
|
2401
|
+
fileName: string;
|
|
2402
|
+
totalRecords: number;
|
|
2403
|
+
}
|
|
2404
|
+
interface TransferPluginOptions {
|
|
2405
|
+
apiPrefix?: string;
|
|
2406
|
+
maxBatchSize?: number;
|
|
2407
|
+
enableRoutes?: boolean;
|
|
2408
|
+
}
|
|
2409
|
+
//#endregion
|
|
2410
|
+
//#region src/plugins/transfer/parsers/json.d.ts
|
|
2411
|
+
/**
|
|
2412
|
+
* @azlib/cms - Universal JSON Data Parser
|
|
2413
|
+
*/
|
|
2414
|
+
declare function parseJsonSource(input: string | Uint8Array | Buffer | unknown): Record<string, unknown>[];
|
|
2415
|
+
//#endregion
|
|
2416
|
+
//#region src/plugins/transfer/parsers/csv.d.ts
|
|
2417
|
+
/**
|
|
2418
|
+
* @azlib/cms - Universal RFC 4180 CSV Data Parser
|
|
2419
|
+
*/
|
|
2420
|
+
declare function parseCsvSource(input: string | Uint8Array | Buffer): Record<string, unknown>[];
|
|
2421
|
+
//#endregion
|
|
2422
|
+
//#region src/plugins/transfer/parsers/excel.d.ts
|
|
2423
|
+
/**
|
|
2424
|
+
* @azlib/cms - Universal Excel (.xlsx) Data Parser using ExcelJS
|
|
2425
|
+
*/
|
|
2426
|
+
interface ParseExcelResult {
|
|
2427
|
+
sheets: string[];
|
|
2428
|
+
selectedSheet: string;
|
|
2429
|
+
records: Record<string, unknown>[];
|
|
2430
|
+
}
|
|
2431
|
+
declare function parseExcelSource(input: Buffer | Uint8Array | ArrayBuffer, options?: {
|
|
2432
|
+
sheetName?: string;
|
|
2433
|
+
}): Promise<ParseExcelResult>;
|
|
2434
|
+
//#endregion
|
|
2435
|
+
//#region src/plugins/transfer/parsers/index.d.ts
|
|
2436
|
+
interface ParseSourceOptions {
|
|
2437
|
+
format?: SourceFormat;
|
|
2438
|
+
fileName?: string;
|
|
2439
|
+
sheetName?: string;
|
|
2440
|
+
}
|
|
2441
|
+
interface ParsedSourceResult {
|
|
2442
|
+
format: SourceFormat;
|
|
2443
|
+
sheets?: string[];
|
|
2444
|
+
selectedSheet?: string;
|
|
2445
|
+
records: Record<string, unknown>[];
|
|
2446
|
+
}
|
|
2447
|
+
/**
|
|
2448
|
+
* Detect the format of an input payload if not explicitly provided.
|
|
2449
|
+
*/
|
|
2450
|
+
declare function detectFormat(input: unknown, fileName?: string): SourceFormat;
|
|
2451
|
+
/**
|
|
2452
|
+
* Universal source parser that handles JSON, CSV, and Excel (.xlsx).
|
|
2453
|
+
*/
|
|
2454
|
+
declare function parseSource(input: unknown, options?: ParseSourceOptions): Promise<ParsedSourceResult>;
|
|
2455
|
+
//#endregion
|
|
2456
|
+
//#region src/plugins/transfer/service.d.ts
|
|
2457
|
+
declare class TransferService {
|
|
2458
|
+
readonly engine: CMSEngine;
|
|
2459
|
+
readonly options: TransferPluginOptions;
|
|
2460
|
+
private presets;
|
|
2461
|
+
constructor(engine: CMSEngine, options?: TransferPluginOptions);
|
|
2462
|
+
/**
|
|
2463
|
+
* List all registered collections across all active plugins in the engine.
|
|
2464
|
+
*/
|
|
2465
|
+
listCollections(): CollectionSchemaSummary[];
|
|
2466
|
+
/**
|
|
2467
|
+
* Get the collection schema summary for a specific collection slug.
|
|
2468
|
+
*/
|
|
2469
|
+
getCollectionSchema(collectionSlug: string): CollectionSchemaSummary;
|
|
2470
|
+
/**
|
|
2471
|
+
* Register a reusable data mapping preset.
|
|
2472
|
+
*/
|
|
2473
|
+
registerPreset(preset: DataMappingDefinition): void;
|
|
2474
|
+
/**
|
|
2475
|
+
* Get a registered preset by ID.
|
|
2476
|
+
*/
|
|
2477
|
+
getPreset(id: string): DataMappingDefinition | undefined;
|
|
2478
|
+
/**
|
|
2479
|
+
* Get all registered presets, optionally filtered by target collection.
|
|
2480
|
+
*/
|
|
2481
|
+
getPresets(collectionSlug?: string): DataMappingDefinition[];
|
|
2482
|
+
/**
|
|
2483
|
+
* Generate a 1:1 default mapping template for any collection.
|
|
2484
|
+
*/
|
|
2485
|
+
getMappingTemplate(collectionSlug: string): DataMappingDefinition;
|
|
2486
|
+
/**
|
|
2487
|
+
* Inspect any source payload or file (JSON, Excel, CSV) to extract headers,
|
|
2488
|
+
* infer data types, and generate auto-mapping suggestions against a target collection.
|
|
2489
|
+
*/
|
|
2490
|
+
inspectSource(input: unknown, options?: ParseSourceOptions & {
|
|
2491
|
+
collectionSlug?: string;
|
|
2492
|
+
previewLimit?: number;
|
|
2493
|
+
}): Promise<SourceInspectionResult>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Dry-run validation of a source batch against a target collection's schema
|
|
2496
|
+
* and live database constraints without committing any changes.
|
|
2497
|
+
*/
|
|
2498
|
+
validateImport(collectionSlug: string, input: unknown, mapping?: DataMappingDefinition, options?: ParseSourceOptions & {
|
|
2499
|
+
onDuplicate?: "error" | "update" | "skip";
|
|
2500
|
+
previewLimit?: number;
|
|
2501
|
+
}): Promise<ValidationResult>;
|
|
2502
|
+
/**
|
|
2503
|
+
* Execute an import batch from raw data or an external file (JSON, Excel, CSV)
|
|
2504
|
+
* into a target CMS collection.
|
|
2505
|
+
*/
|
|
2506
|
+
importData(collectionSlug: string, input: unknown, mapping?: DataMappingDefinition, options?: TransferImportOptions & ParseSourceOptions): Promise<TransferImportResult>;
|
|
2507
|
+
/**
|
|
2508
|
+
* Export CMS collection records to JSON, Excel (.xlsx), or CSV.
|
|
2509
|
+
*/
|
|
2510
|
+
exportData(collectionSlug: string, options?: TransferExportOptions): Promise<TransferExportResult>;
|
|
2511
|
+
private getCollectionConfigOrThrow;
|
|
2512
|
+
private detectUniqueField;
|
|
2513
|
+
}
|
|
2514
|
+
//#endregion
|
|
2515
|
+
//#region src/plugins/transfer/client.d.ts
|
|
2516
|
+
declare class TransferClient {
|
|
2517
|
+
private client;
|
|
2518
|
+
private options;
|
|
2519
|
+
private service?;
|
|
2520
|
+
private prefix;
|
|
2521
|
+
constructor(client: CMSClient, options?: TransferPluginOptions);
|
|
2522
|
+
/**
|
|
2523
|
+
* List all registered collections across all active plugins.
|
|
2524
|
+
*/
|
|
2525
|
+
listCollections(): Promise<CollectionSchemaSummary[]>;
|
|
2526
|
+
/**
|
|
2527
|
+
* Get the collection schema and default mapping template.
|
|
2528
|
+
*/
|
|
2529
|
+
getSchema(collectionSlug: string): Promise<{
|
|
2530
|
+
schema: CollectionSchemaSummary;
|
|
2531
|
+
template: DataMappingDefinition;
|
|
2532
|
+
}>;
|
|
2533
|
+
/**
|
|
2534
|
+
* Inspect a source file or payload.
|
|
2535
|
+
*/
|
|
2536
|
+
inspect(data: unknown, options?: {
|
|
2537
|
+
collectionSlug?: string;
|
|
2538
|
+
format?: SourceFormat;
|
|
2539
|
+
fileName?: string;
|
|
2540
|
+
sheetName?: string;
|
|
2541
|
+
}): Promise<SourceInspectionResult>;
|
|
2542
|
+
/**
|
|
2543
|
+
* Dry-run validation of a source batch against a target collection and database constraints.
|
|
2544
|
+
*/
|
|
2545
|
+
preview(collectionSlug: string, data: unknown, mapping?: DataMappingDefinition, options?: {
|
|
2546
|
+
format?: SourceFormat;
|
|
2547
|
+
fileName?: string;
|
|
2548
|
+
sheetName?: string;
|
|
2549
|
+
onDuplicate?: "error" | "update" | "skip";
|
|
2550
|
+
}): Promise<ValidationResult>;
|
|
2551
|
+
/**
|
|
2552
|
+
* Execute an import batch into a target collection.
|
|
2553
|
+
*/
|
|
2554
|
+
import(collectionSlug: string, data: unknown, mapping?: DataMappingDefinition, options?: TransferImportOptions & {
|
|
2555
|
+
format?: SourceFormat;
|
|
2556
|
+
fileName?: string;
|
|
2557
|
+
sheetName?: string;
|
|
2558
|
+
}): Promise<TransferImportResult>;
|
|
2559
|
+
/**
|
|
2560
|
+
* Export collection records to JSON, Excel, or CSV.
|
|
2561
|
+
*/
|
|
2562
|
+
export(collectionSlug: string, options?: TransferExportOptions): Promise<TransferExportResult>;
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* Access or instantiate the TransferClient associated with a CMSClient instance.
|
|
2566
|
+
*/
|
|
2567
|
+
declare function getTransferClient(client: CMSClient, options?: TransferPluginOptions): TransferClient;
|
|
2568
|
+
//#endregion
|
|
2569
|
+
//#region src/plugins/transfer/mapping.d.ts
|
|
2570
|
+
/**
|
|
2571
|
+
* Apply a mapping definition to transform an external raw record into a CMS content payload.
|
|
2572
|
+
*/
|
|
2573
|
+
declare function mapSourceRecord(rawRecord: Record<string, unknown>, mapping: DataMappingDefinition): {
|
|
2574
|
+
data: Record<string, unknown>;
|
|
2575
|
+
title?: string;
|
|
2576
|
+
slug?: string;
|
|
2577
|
+
status?: string;
|
|
2578
|
+
};
|
|
2579
|
+
/**
|
|
2580
|
+
* Applies transform preset or custom function to a field value.
|
|
2581
|
+
*/
|
|
2582
|
+
declare function applyFieldTransform(rule: FieldMappingRule, value: unknown, rawRecord: Record<string, unknown>): unknown;
|
|
2583
|
+
/**
|
|
2584
|
+
* Reverse mapping for export: transforms a CMS ContentItem into an external export record.
|
|
2585
|
+
*/
|
|
2586
|
+
declare function mapCmsItemForExport(item: ContentItem<Record<string, unknown>>, mapping?: DataMappingDefinition, options?: {
|
|
2587
|
+
includeId?: boolean;
|
|
2588
|
+
includeTimestamps?: boolean;
|
|
2589
|
+
}): Record<string, unknown>;
|
|
2590
|
+
//#endregion
|
|
2591
|
+
//#region src/plugins/transfer/inspect.d.ts
|
|
2592
|
+
interface InspectOptions extends ParseSourceOptions {
|
|
2593
|
+
collectionConfig?: CollectionConfig;
|
|
2594
|
+
previewLimit?: number;
|
|
2595
|
+
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Inspect an uploaded source file or payload to discover its schema,
|
|
2598
|
+
* infer column types, and generate auto-mapping suggestions against a target collection.
|
|
2599
|
+
*/
|
|
2600
|
+
declare function inspectSource(input: unknown, options?: InspectOptions): Promise<SourceInspectionResult>;
|
|
2601
|
+
/**
|
|
2602
|
+
* Summarize a CMS CollectionConfig into consumer-friendly schema details.
|
|
2603
|
+
*/
|
|
2604
|
+
declare function summarizeCollection(config: CollectionConfig): CollectionSchemaSummary;
|
|
2605
|
+
/**
|
|
2606
|
+
* Generates intelligent auto-mapping suggestions matching source headers to CMS fields.
|
|
2607
|
+
*/
|
|
2608
|
+
declare function generateSuggestedMapping(sourceHeaders: string[], targetSchema: CollectionSchemaSummary): SuggestedMappingRule[];
|
|
2609
|
+
//#endregion
|
|
2610
|
+
//#region src/plugins/transfer/validator.d.ts
|
|
2611
|
+
interface ValidateTransferOptions {
|
|
2612
|
+
storage?: CMSStorageAdapter;
|
|
2613
|
+
onDuplicate?: "error" | "update" | "skip";
|
|
2614
|
+
previewLimit?: number;
|
|
2615
|
+
}
|
|
2616
|
+
/**
|
|
2617
|
+
* Validates a batch of source records against a target CMS collection configuration
|
|
2618
|
+
* and live database constraints.
|
|
2619
|
+
*/
|
|
2620
|
+
declare function validateTransferBatch(rawRecords: Record<string, unknown>[], mapping: DataMappingDefinition, collectionConfig: CollectionConfig, options?: ValidateTransferOptions): Promise<ValidationResult>;
|
|
2621
|
+
//#endregion
|
|
2622
|
+
//#region src/plugins/transfer/serializers/json.d.ts
|
|
2623
|
+
/**
|
|
2624
|
+
* @azlib/cms - Universal JSON Serializer
|
|
2625
|
+
*/
|
|
2626
|
+
interface SerializeJsonOptions {
|
|
2627
|
+
pretty?: boolean;
|
|
2628
|
+
}
|
|
2629
|
+
declare function serializeJson(records: Record<string, unknown>[], options?: SerializeJsonOptions): string;
|
|
2630
|
+
//#endregion
|
|
2631
|
+
//#region src/plugins/transfer/serializers/csv.d.ts
|
|
2632
|
+
/**
|
|
2633
|
+
* @azlib/cms - Universal RFC 4180 CSV Serializer
|
|
2634
|
+
*/
|
|
2635
|
+
interface SerializeCsvOptions {
|
|
2636
|
+
columns?: {
|
|
2637
|
+
key: string;
|
|
2638
|
+
header: string;
|
|
2639
|
+
}[];
|
|
2640
|
+
}
|
|
2641
|
+
declare function serializeCsv(records: Record<string, unknown>[], options?: SerializeCsvOptions): string;
|
|
2642
|
+
//#endregion
|
|
2643
|
+
//#region src/plugins/transfer/serializers/excel.d.ts
|
|
2644
|
+
/**
|
|
2645
|
+
* @azlib/cms - Universal Excel (.xlsx) Serializer using ExcelJS
|
|
2646
|
+
*/
|
|
2647
|
+
interface SerializeExcelOptions {
|
|
2648
|
+
sheetName?: string;
|
|
2649
|
+
columns?: {
|
|
2650
|
+
key: string;
|
|
2651
|
+
header: string;
|
|
2652
|
+
width?: number;
|
|
2653
|
+
}[];
|
|
2654
|
+
}
|
|
2655
|
+
declare function serializeExcel(records: Record<string, unknown>[], options?: SerializeExcelOptions): Promise<Uint8Array>;
|
|
2656
|
+
//#endregion
|
|
2657
|
+
//#region src/plugins/transfer/serializers/index.d.ts
|
|
2658
|
+
interface SerializeSourceOptions {
|
|
2659
|
+
format?: SourceFormat;
|
|
2660
|
+
fileName?: string;
|
|
2661
|
+
sheetName?: string;
|
|
2662
|
+
columns?: {
|
|
2663
|
+
key: string;
|
|
2664
|
+
header: string;
|
|
2665
|
+
width?: number;
|
|
2666
|
+
}[];
|
|
2667
|
+
}
|
|
2668
|
+
declare function serializeSource(records: Record<string, unknown>[], options?: SerializeSourceOptions): Promise<TransferExportResult>;
|
|
2669
|
+
//#endregion
|
|
2670
|
+
//#region src/plugins/transfer/presets/hrms.d.ts
|
|
2671
|
+
/**
|
|
2672
|
+
* Preconfigured mapping definition for importing and exporting HRMS Employers.
|
|
2673
|
+
*/
|
|
2674
|
+
declare const HRMS_EMPLOYER_TRANSFER_PRESET: DataMappingDefinition;
|
|
2675
|
+
/**
|
|
2676
|
+
* Preconfigured mapping definition for importing and exporting HRMS Employees.
|
|
2677
|
+
*/
|
|
2678
|
+
declare const HRMS_EMPLOYEE_TRANSFER_PRESET: DataMappingDefinition;
|
|
2679
|
+
//#endregion
|
|
2680
|
+
//#region src/plugins/transfer/index.d.ts
|
|
2681
|
+
/**
|
|
2682
|
+
* Built-in Universal Data Transfer plugin factory for @azlib/cms.
|
|
2683
|
+
* Equips the CMS engine with dynamic, schema-driven import and export capabilities
|
|
2684
|
+
* across all collections, featuring file schema discovery, definition mapping,
|
|
2685
|
+
* multi-level data validation, database constraint verification, and multi-format support.
|
|
2686
|
+
*/
|
|
2687
|
+
declare const transferPlugin: (options?: void | TransferPluginOptions | undefined) => CMSPlugin;
|
|
2688
|
+
/**
|
|
2689
|
+
* Retrieve the active TransferService instance associated with a CMSEngine.
|
|
2690
|
+
*/
|
|
2691
|
+
declare function getTransferService(engine: CMSEngine, options?: TransferPluginOptions): TransferService;
|
|
2692
|
+
//#endregion
|
|
2693
|
+
export { type ActionCallback, ApproveLeaveInput, type ArrayFieldOptions, AttendanceData, AttendanceItem, AttendanceStatus, AuthService, BlockDefinition, type BlocksFieldOptions, type BooleanFieldOptions, CMSApiKeyConfig, CMSAuthConfig, CMSCapability, CMSClient, type CMSClientOptions, CMSConfig, CMSEngine, type CMSPlugin, type CMSPluginContext, CMSRouter, type CMSStorageAdapter, CMSUser, CMSWebhookConfig, CMSWebhookEvent, CartCalculationInput, CartCalculationResult, CartItemInput, CheckInInput, CheckOutInput, type ClientCollectionApi, CollectionConfig, CollectionFieldSummary, type CollectionOptions, CollectionSchemaSummary, type CollectionService, ContentItem, ContentLifecycle, ContentQueryOptions, ContentStatus, type CreateContentInput, CreateDiscountInput, CreateEmployeeInput, CreateEmployerInput, CreateLeaveRequestInput, CreateLeaveTypeInput, CreateOrderInput, CreateProductInput, type CustomRouteHandler, DEFAULT_COLLECTIONS, DEFAULT_ROLE_CAPABILITIES, DataMappingDefinition, type DateFieldOptions, DiscountData, DiscountItem, DiscountStatus, DiscountType, DiscountValidationResult, DiskMediaStorageDriver, type DiskMediaStorageDriverOptions, EcommerceClient, EcommercePluginOptions, EcommerceProductQuery, EcommerceService, type EmailFieldOptions, EmployeeData, EmployeeDocument, EmployeeEmergencyContact, EmployeeItem, EmployeeLeaveBalanceReport, EmployeeStatus, EmployerData, EmployerItem, EmployerStatus, EmployerWorkSchedule, EmploymentType, FieldDefinition, FieldMappingRule, FieldTransformFn, FieldTransformPreset, FieldType, type FilterCallback, HRMSAttendanceQuery, HRMSClient, HRMSEmployeeQuery, HRMSLeaveQuery, HRMSPluginOptions, HRMSService, HRMS_EMPLOYEE_TRANSFER_PRESET, HRMS_EMPLOYER_TRANSFER_PRESET, type HookEntry, HooksManager, type ImageFieldOptions, InferredFieldType, InspectOptions, type JsonFieldOptions, LeaveBalanceItem, LeaveRequestData, LeaveRequestItem, LeaveRequestStatus, LeaveTypeData, LeaveTypeItem, MappingOptions, MediaItem, MediaManager, MediaStorageDriver, type MediaUploadInput, MemoryStorageAdapter, type NumberFieldOptions, OptionItem, OptionsManager, OrderAddress, OrderData, OrderItem, OrderLineItem, OrderStatus, PaginatedResult, ParseExcelResult, ParseSourceOptions, ParsedSourceResult, PersistenceStorageAdapter, type PersistenceStorageAdapterOptions, PreviewManager, type PreviewTokenPayload, ProductData, ProductImage, ProductItem, ProductStatus, ProductVariant, QueryOperatorExpression, RBACManager, RecordAttendanceManualInput, RejectLeaveInput, type RelationshipFieldOptions, type RepeaterFieldOptions, RevisionDiff, RevisionDiffField, RevisionManager, RevisionRecord, type RichTextFieldOptions, type RouteContext, type SelectFieldOptions, SelectOption, SerializeCsvOptions, SerializeExcelOptions, SerializeJsonOptions, SerializeSourceOptions, SiteConfig, type SlugFieldOptions, SourceFieldSchema, SourceFormat, SourceInspectionResult, type StoredUserRecord, SuggestedMappingRule, type SyncFilterCallback, TaxonomyConfig, type TaxonomyFieldOptions, TaxonomyManager, TermItem, TermTreeItem, type TextFieldOptions, TransferClient, TransferErrorCode, TransferErrorDetail, TransferExportOptions, TransferExportResult, TransferImportOptions, TransferImportResult, TransferPluginOptions, TransferService, type UpdateContentInput, UpdateEmployeeInput, UpdateEmployerInput, UpdateProductInput, type UrlFieldOptions, UserRole, VALID_STATUS_TRANSITIONS, ValidateTransferOptions, ValidationPreviewRow, ValidationResult, WebhookManager, applyFieldTransform, collection, computeHmacSignature, createAttendanceCollection, createCMSEngine, createCMSRouter, createCmsClient, createDiscountCollection, createEcommerceTaxonomies, createEmployeeCollection, createEmployerCollection, createHRMSTaxonomies, createLeaveRequestCollection, createLeaveTypeCollection, createOrderCollection, createProductCollection, defaultHooks, defineConfig, definePlugin, detectFormat, ecommercePlugin, fields, generateSuggestedMapping, getEcommerceClient, getEcommerceService, getHRMSClient, getHRMSService, getTransferClient, getTransferService, hashPassword, hrmsPlugin, inspectSource, mapCmsItemForExport, mapSourceRecord, mergeLocalizedInput, normalizeConfig, parseCsvSource, parseExcelSource, parseJsonSource, parseSource, resolveLocalizedData, resolveUniqueSlug, serializeCsv, serializeExcel, serializeJson, serializeSource, signJwt, slugify, summarizeCollection, transferPlugin, validateAndNormalizeData, validateTransferBatch, verifyJwt, verifyPassword };
|
|
1899
2694
|
//# sourceMappingURL=index.d.mts.map
|