nextjs-cms 0.8.10 → 0.9.1
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/api/index.d.ts +92 -9
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/lib/serverActions.d.ts +64 -9
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +463 -90
- package/dist/api/root.d.ts +184 -18
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/routers/accountSettings.d.ts +2 -2
- package/dist/api/routers/accountSettings.js +10 -10
- package/dist/api/routers/admins.js +11 -11
- package/dist/api/routers/auth.d.ts +1 -1
- package/dist/api/routers/config.d.ts +13 -0
- package/dist/api/routers/config.d.ts.map +1 -1
- package/dist/api/routers/config.js +4 -0
- package/dist/api/routers/cpanel.js +7 -7
- package/dist/api/routers/fields.d.ts +1 -0
- package/dist/api/routers/fields.d.ts.map +1 -1
- package/dist/api/routers/fields.js +39 -6
- package/dist/api/routers/gallery.js +1 -1
- package/dist/api/routers/hasItemsSection.d.ts +41 -2
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/routers/hasItemsSection.js +43 -2
- package/dist/api/routers/logs.js +1 -1
- package/dist/api/routers/navigation.d.ts +3 -3
- package/dist/api/routers/simpleSection.d.ts +31 -1
- package/dist/api/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/routers/simpleSection.js +44 -2
- package/dist/api/trpc.js +2 -2
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/lib/actions.d.ts +3 -3
- package/dist/auth/lib/actions.d.ts.map +1 -1
- package/dist/auth/lib/actions.js +14 -14
- package/dist/auth/react.d.ts +2 -2
- package/dist/auth/react.d.ts.map +1 -1
- package/dist/auth/react.js +7 -7
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +145 -9
- package/dist/cli/utils/schema-generator.d.ts +20 -0
- package/dist/cli/utils/schema-generator.d.ts.map +1 -1
- package/dist/cli/utils/schema-generator.js +40 -0
- package/dist/core/config/config-loader.d.ts +49 -5
- package/dist/core/config/config-loader.d.ts.map +1 -1
- package/dist/core/config/config-loader.js +100 -21
- package/dist/core/config/index.d.ts +2 -2
- package/dist/core/config/index.d.ts.map +1 -1
- package/dist/core/config/index.js +1 -1
- package/dist/core/factories/FieldFactory.d.ts +5 -3
- package/dist/core/factories/FieldFactory.d.ts.map +1 -1
- package/dist/core/factories/FieldFactory.js +74 -16
- package/dist/core/factories/section-factory-with-esbuild.d.ts.map +1 -1
- package/dist/core/factories/section-factory-with-esbuild.js +6 -0
- package/dist/core/factories/section-factory-with-jiti.d.ts.map +1 -1
- package/dist/core/factories/section-factory-with-jiti.js +6 -0
- package/dist/core/fields/checkbox.d.ts +4 -1
- package/dist/core/fields/checkbox.d.ts.map +1 -1
- package/dist/core/fields/color.d.ts +4 -1
- package/dist/core/fields/color.d.ts.map +1 -1
- package/dist/core/fields/color.js +2 -2
- package/dist/core/fields/date.d.ts +4 -1
- package/dist/core/fields/date.d.ts.map +1 -1
- package/dist/core/fields/date.js +2 -2
- package/dist/core/fields/document.d.ts +4 -1
- package/dist/core/fields/document.d.ts.map +1 -1
- package/dist/core/fields/document.js +27 -18
- package/dist/core/fields/field-group.d.ts +3 -3
- package/dist/core/fields/field-group.d.ts.map +1 -1
- package/dist/core/fields/field.d.ts +11 -8
- package/dist/core/fields/field.d.ts.map +1 -1
- package/dist/core/fields/field.js +15 -11
- package/dist/core/fields/map.d.ts +4 -1
- package/dist/core/fields/map.d.ts.map +1 -1
- package/dist/core/fields/map.js +2 -2
- package/dist/core/fields/number.d.ts +26 -1
- package/dist/core/fields/number.d.ts.map +1 -1
- package/dist/core/fields/number.js +16 -7
- package/dist/core/fields/password.d.ts +4 -1
- package/dist/core/fields/password.d.ts.map +1 -1
- package/dist/core/fields/password.js +3 -3
- package/dist/core/fields/photo.d.ts +4 -1
- package/dist/core/fields/photo.d.ts.map +1 -1
- package/dist/core/fields/photo.js +17 -17
- package/dist/core/fields/richText.d.ts +17 -3
- package/dist/core/fields/richText.d.ts.map +1 -1
- package/dist/core/fields/richText.js +20 -8
- package/dist/core/fields/select.d.ts +11 -4
- package/dist/core/fields/select.d.ts.map +1 -1
- package/dist/core/fields/select.js +27 -34
- package/dist/core/fields/selectMultiple.d.ts +8 -4
- package/dist/core/fields/selectMultiple.d.ts.map +1 -1
- package/dist/core/fields/selectMultiple.js +32 -24
- package/dist/core/fields/slug.d.ts +16 -1
- package/dist/core/fields/slug.d.ts.map +1 -1
- package/dist/core/fields/slug.js +3 -3
- package/dist/core/fields/tags.d.ts +6 -3
- package/dist/core/fields/tags.d.ts.map +1 -1
- package/dist/core/fields/tags.js +26 -19
- package/dist/core/fields/text.d.ts +24 -1
- package/dist/core/fields/text.d.ts.map +1 -1
- package/dist/core/fields/text.js +12 -3
- package/dist/core/fields/textArea.d.ts +24 -1
- package/dist/core/fields/textArea.d.ts.map +1 -1
- package/dist/core/fields/textArea.js +9 -0
- package/dist/core/fields/video.d.ts +4 -1
- package/dist/core/fields/video.d.ts.map +1 -1
- package/dist/core/fields/video.js +14 -12
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/localization/index.d.ts +3 -0
- package/dist/core/localization/index.d.ts.map +1 -0
- package/dist/core/localization/index.js +1 -0
- package/dist/core/localization/resolve-locale.d.ts +29 -0
- package/dist/core/localization/resolve-locale.d.ts.map +1 -0
- package/dist/core/localization/resolve-locale.js +43 -0
- package/dist/core/sections/category.d.ts +22 -10
- package/dist/core/sections/category.d.ts.map +1 -1
- package/dist/core/sections/category.js +3 -3
- package/dist/core/sections/hasItems.d.ts +46 -10
- package/dist/core/sections/hasItems.d.ts.map +1 -1
- package/dist/core/sections/section.d.ts +38 -11
- package/dist/core/sections/section.d.ts.map +1 -1
- package/dist/core/sections/section.js +22 -0
- package/dist/core/sections/simple.d.ts +8 -8
- package/dist/core/sections/simple.d.ts.map +1 -1
- package/dist/core/submit/ItemEditSubmit.d.ts +24 -16
- package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -1
- package/dist/core/submit/ItemEditSubmit.js +62 -38
- package/dist/core/submit/LocaleSubmit.d.ts +97 -0
- package/dist/core/submit/LocaleSubmit.d.ts.map +1 -0
- package/dist/core/submit/LocaleSubmit.js +435 -0
- package/dist/core/submit/NewItemSubmit.d.ts +0 -8
- package/dist/core/submit/NewItemSubmit.d.ts.map +1 -1
- package/dist/core/submit/NewItemSubmit.js +6 -12
- package/dist/core/submit/index.d.ts +1 -0
- package/dist/core/submit/index.d.ts.map +1 -1
- package/dist/core/submit/index.js +1 -0
- package/dist/core/submit/submit.d.ts +35 -12
- package/dist/core/submit/submit.d.ts.map +1 -1
- package/dist/core/submit/submit.js +88 -69
- package/dist/db/schema.d.ts +17 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +1 -0
- package/dist/logging/log.d.ts +1 -1
- package/dist/logging/log.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/loader.d.ts +3 -3
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/translations/base/en.d.ts +24 -2
- package/dist/translations/base/en.d.ts.map +1 -1
- package/dist/translations/base/en.js +24 -2
- package/dist/translations/client.d.ts +292 -28
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/client.js +2 -2
- package/dist/translations/dict-store.d.ts +2 -2
- package/dist/translations/dict-store.d.ts.map +1 -1
- package/dist/translations/dict-store.js +9 -9
- package/dist/translations/index.d.ts +5 -5
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +6 -6
- package/dist/translations/language-cookie.d.ts +24 -0
- package/dist/translations/language-cookie.d.ts.map +1 -0
- package/dist/translations/language-cookie.js +44 -0
- package/dist/translations/language-utils.d.ts +42 -0
- package/dist/translations/language-utils.d.ts.map +1 -0
- package/dist/translations/language-utils.js +52 -0
- package/dist/translations/localization.d.ts +1 -39
- package/dist/translations/localization.d.ts.map +1 -1
- package/dist/translations/localization.js +0 -48
- package/dist/translations/server.d.ts +293 -29
- package/dist/translations/server.d.ts.map +1 -1
- package/dist/translations/server.js +5 -5
- package/dist/validators/select-multiple.d.ts +2 -2
- package/dist/validators/select-multiple.d.ts.map +1 -1
- package/dist/validators/select-multiple.js +1 -1
- package/package.json +7 -3
|
@@ -61,8 +61,9 @@ export declare class TagsField extends Field<'tags', Config> {
|
|
|
61
61
|
hasAutoCompletion: boolean;
|
|
62
62
|
type: "tags";
|
|
63
63
|
name: string;
|
|
64
|
-
label: import("../../index.js").
|
|
64
|
+
label: import("../../index.js").MultilingualString;
|
|
65
65
|
required: boolean;
|
|
66
|
+
localized?: boolean;
|
|
66
67
|
conditionalFields: import("../types/index.js").ConditionalField[];
|
|
67
68
|
readonly: boolean;
|
|
68
69
|
defaultValue: any;
|
|
@@ -76,11 +77,11 @@ export declare class TagsField extends Field<'tags', Config> {
|
|
|
76
77
|
/**
|
|
77
78
|
* Save tags to the destination table after the main item is saved
|
|
78
79
|
*/
|
|
79
|
-
postSubmit(itemId: string): Promise<void>;
|
|
80
|
+
postSubmit(itemId: string, locale?: string): Promise<void>;
|
|
80
81
|
/**
|
|
81
82
|
* Rollback the tags from the destination table if something goes wrong
|
|
82
83
|
*/
|
|
83
|
-
postSubmitRollback(): Promise<void>;
|
|
84
|
+
postSubmitRollback(locale?: string): Promise<void>;
|
|
84
85
|
/**
|
|
85
86
|
* Check the destination db config is set
|
|
86
87
|
* @private
|
|
@@ -112,6 +113,7 @@ declare const baseOptionsSchema: z.ZodObject<{
|
|
|
112
113
|
order: z.ZodOptional<z.ZodNumber>;
|
|
113
114
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
114
115
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
116
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
115
117
|
}, z.core.$strict>;
|
|
116
118
|
type BaseOptions = z.infer<typeof baseOptionsSchema>;
|
|
117
119
|
type DestinationDb = z.infer<typeof destinationDbSchema>;
|
|
@@ -161,6 +163,7 @@ declare const tagsFieldConfigSchema: z.ZodObject<{
|
|
|
161
163
|
order: z.ZodOptional<z.ZodNumber>;
|
|
162
164
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
163
165
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
166
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
164
167
|
}, z.core.$strict>;
|
|
165
168
|
/**
|
|
166
169
|
* Tags field configuration type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/core/fields/tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKhD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,QAAA,MAAM,mBAAmB;;;;kBAIvB,CAAA;AAEF,QAAA,MAAM,YAAY;IACd;;;OAGG;;;;;;IAEH;;;;OAIG;;;IAGH;;;;;OAKG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,SAAU,SAAQ,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;IAChD,gBAAyB,CAA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,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AACD,KAAK,6BAA6B,GAAG,WAAW,GAAG;IAC/C,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,cAAc,CAAC,EAAE,KAAK,CAAA;CACzB,CAAA;AACD,KAAK,gBAAgB,GAAG,0BAA0B,GAAG,6BAA6B,CAAA;AAOlF,QAAA,MAAM,qBAAqB;;;IAxRvB;;;OAGG;;;;;;IAEH;;;;OAIG;;;IAGH;;;;;OAKG;;;;;;;;;;kBA2QL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,eAAe,CAkBlE"}
|
package/dist/core/fields/tags.js
CHANGED
|
@@ -91,15 +91,20 @@ export class TagsField extends Field {
|
|
|
91
91
|
/**
|
|
92
92
|
* Save tags to the destination table after the main item is saved
|
|
93
93
|
*/
|
|
94
|
-
async postSubmit(itemId) {
|
|
94
|
+
async postSubmit(itemId, locale) {
|
|
95
95
|
if (!this.destinationDb)
|
|
96
96
|
return;
|
|
97
97
|
this._itemIdentifier = itemId;
|
|
98
|
+
const useLocale = this.localized && locale !== undefined;
|
|
98
99
|
try {
|
|
99
100
|
/**
|
|
100
|
-
* Delete the existing values
|
|
101
|
+
* Delete the existing values, scoped by locale for localized fields
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
+
const deleteQuery = sql `DELETE FROM \`${sql.raw(this.destinationDb.table)}\` WHERE \`${sql.raw(this.destinationDb.itemIdentifier)}\` = ${this._itemIdentifier}`;
|
|
104
|
+
if (useLocale) {
|
|
105
|
+
deleteQuery.append(sql ` AND \`locale\` = ${locale}`);
|
|
106
|
+
}
|
|
107
|
+
await db.execute(deleteQuery);
|
|
103
108
|
/**
|
|
104
109
|
* Check if we actually have values to save
|
|
105
110
|
*/
|
|
@@ -110,27 +115,25 @@ export class TagsField extends Field {
|
|
|
110
115
|
* Prepare the sql statement
|
|
111
116
|
*/
|
|
112
117
|
const sqlChunks = [];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
if (useLocale) {
|
|
119
|
+
sqlChunks.push(sql `INSERT INTO \`${sql.raw(this.destinationDb.table)}\` (\`${sql.raw(this.destinationDb.selectIdentifier)}\`, \`${sql.raw(this.destinationDb.itemIdentifier)}\`, \`locale\`) VALUES `);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
sqlChunks.push(sql `INSERT INTO \`${sql.raw(this.destinationDb.table)}\` (\`${sql.raw(this.destinationDb.selectIdentifier)}\`, \`${sql.raw(this.destinationDb.itemIdentifier)}\`) VALUES `);
|
|
123
|
+
}
|
|
117
124
|
const count = this._tags.length;
|
|
118
125
|
this._tags.forEach((tag, index) => {
|
|
119
|
-
|
|
126
|
+
if (useLocale) {
|
|
127
|
+
sqlChunks.push(sql `(${tag}, ${this._itemIdentifier}, ${locale})`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
sqlChunks.push(sql `(${tag}, ${this._itemIdentifier})`);
|
|
131
|
+
}
|
|
120
132
|
if (index < count - 1) {
|
|
121
|
-
/**
|
|
122
|
-
* Add a comma to separate the values in the sql statement
|
|
123
|
-
*/
|
|
124
133
|
sqlChunks.push(sql `, `);
|
|
125
134
|
}
|
|
126
135
|
});
|
|
127
|
-
/**
|
|
128
|
-
* Join the sql chunks
|
|
129
|
-
*/
|
|
130
136
|
const finalSql = sql.join(sqlChunks);
|
|
131
|
-
/**
|
|
132
|
-
* Execute the sql statement
|
|
133
|
-
*/
|
|
134
137
|
await db.execute(finalSql);
|
|
135
138
|
}
|
|
136
139
|
catch (error) {
|
|
@@ -141,14 +144,18 @@ export class TagsField extends Field {
|
|
|
141
144
|
/**
|
|
142
145
|
* Rollback the tags from the destination table if something goes wrong
|
|
143
146
|
*/
|
|
144
|
-
async postSubmitRollback() {
|
|
147
|
+
async postSubmitRollback(locale) {
|
|
145
148
|
if (!this.destinationDb)
|
|
146
149
|
return;
|
|
147
150
|
if (!this._itemIdentifier) {
|
|
148
151
|
throw new Error(`${this.label}: Item identifier is not set. Make sure to set the item identifier by calling postSubmit() before calling postSubmitRollback()`);
|
|
149
152
|
}
|
|
150
153
|
try {
|
|
151
|
-
|
|
154
|
+
const query = sql `DELETE FROM \`${sql.raw(this.destinationDb.table)}\` WHERE \`${sql.raw(this.destinationDb.itemIdentifier)}\` = ${this._itemIdentifier}`;
|
|
155
|
+
if (this.localized && locale !== undefined) {
|
|
156
|
+
query.append(sql ` AND \`locale\` = ${locale}`);
|
|
157
|
+
}
|
|
158
|
+
await db.execute(query);
|
|
152
159
|
}
|
|
153
160
|
catch (error) {
|
|
154
161
|
throw new Error(`${this.label}: Error deleting tags from the destination table`);
|
|
@@ -19,6 +19,12 @@ declare const configSchema: z.ZodObject<{
|
|
|
19
19
|
* @default false
|
|
20
20
|
*/
|
|
21
21
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Explicitly set the text direction for this field.
|
|
24
|
+
* When set, overrides the locale-based RTL setting.
|
|
25
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
26
|
+
*/
|
|
27
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
22
28
|
}, z.core.$strict>;
|
|
23
29
|
type Config = z.infer<typeof configSchema>;
|
|
24
30
|
export declare class TextField extends Field<'text', Config> {
|
|
@@ -29,6 +35,7 @@ export declare class TextField extends Field<'text', Config> {
|
|
|
29
35
|
private readonly _defaultValue;
|
|
30
36
|
value: string | undefined;
|
|
31
37
|
readonly sanitize: boolean;
|
|
38
|
+
readonly rtl: boolean | undefined;
|
|
32
39
|
constructor(config: BaseFieldConfig<Config>);
|
|
33
40
|
/**
|
|
34
41
|
* Sanitize the value
|
|
@@ -39,10 +46,12 @@ export declare class TextField extends Field<'text', Config> {
|
|
|
39
46
|
minLength: number | undefined;
|
|
40
47
|
placeholder: string | undefined;
|
|
41
48
|
sanitize: boolean;
|
|
49
|
+
rtl: boolean | undefined;
|
|
42
50
|
type: "text";
|
|
43
51
|
name: string;
|
|
44
|
-
label: import("../../index.js").
|
|
52
|
+
label: import("../../index.js").MultilingualString;
|
|
45
53
|
required: boolean;
|
|
54
|
+
localized?: boolean;
|
|
46
55
|
conditionalFields: import("../types/index.js").ConditionalField[];
|
|
47
56
|
readonly: boolean;
|
|
48
57
|
defaultValue: any;
|
|
@@ -77,12 +86,19 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
77
86
|
* @default false
|
|
78
87
|
*/
|
|
79
88
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Explicitly set the text direction for this field.
|
|
91
|
+
* When set, overrides the locale-based RTL setting.
|
|
92
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
93
|
+
*/
|
|
94
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
80
95
|
name: z.ZodString;
|
|
81
96
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
82
97
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
83
98
|
order: z.ZodOptional<z.ZodNumber>;
|
|
84
99
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
85
100
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
101
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
86
102
|
}, z.core.$strict>;
|
|
87
103
|
declare const textFieldConfigSchema: z.ZodObject<{
|
|
88
104
|
type: z.ZodLiteral<"text">;
|
|
@@ -103,12 +119,19 @@ declare const textFieldConfigSchema: z.ZodObject<{
|
|
|
103
119
|
* @default false
|
|
104
120
|
*/
|
|
105
121
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Explicitly set the text direction for this field.
|
|
124
|
+
* When set, overrides the locale-based RTL setting.
|
|
125
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
126
|
+
*/
|
|
127
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
106
128
|
name: z.ZodString;
|
|
107
129
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
108
130
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
109
131
|
order: z.ZodOptional<z.ZodNumber>;
|
|
110
132
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
111
133
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
134
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
112
135
|
}, z.core.$strict>;
|
|
113
136
|
/**
|
|
114
137
|
* Text field configuration type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/core/fields/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,QAAA,MAAM,YAAY;;;;IAId;;;;OAIG;;IAEH;;;;;OAKG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,SAAU,SAAQ,KAAK,CAAC,MA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,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAA;gBAErB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;IAW3C;;OAEG;IACH,OAAO,CAAC,aAAa;IAgBL,eAAe;;;;;;;;;;;;;;;;IAW/B;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,aAAa;IAWJ,kBAAkB,IAAI,OAAO;IAOtC;;OAEG;IACG,oBAAoB;CAyB7B;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE5E,QAAA,MAAM,aAAa;;;;IAnIf;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;OAIG;;;;;;;;;kBAqHL,CAAA;AAEF,QAAA,MAAM,qBAAqB;;;;;;IAxIvB;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;OAIG;;;;;;;;;kBA2HL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,eAAe,CAmB/E"}
|
package/dist/core/fields/text.js
CHANGED
|
@@ -20,6 +20,12 @@ const configSchema = z.strictObject({
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
sanitize: z.boolean().optional().describe('Sanitize the value before saving'),
|
|
23
|
+
/**
|
|
24
|
+
* Explicitly set the text direction for this field.
|
|
25
|
+
* When set, overrides the locale-based RTL setting.
|
|
26
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
27
|
+
*/
|
|
28
|
+
rtl: z.boolean().optional().describe('Override text direction: true for RTL, false for LTR'),
|
|
23
29
|
});
|
|
24
30
|
export class TextField extends Field {
|
|
25
31
|
static [entityKind] = 'TextField';
|
|
@@ -29,6 +35,7 @@ export class TextField extends Field {
|
|
|
29
35
|
_defaultValue;
|
|
30
36
|
value;
|
|
31
37
|
sanitize;
|
|
38
|
+
rtl;
|
|
32
39
|
constructor(config) {
|
|
33
40
|
super(config, 'text');
|
|
34
41
|
this.maxLength = config.maxLength;
|
|
@@ -37,6 +44,7 @@ export class TextField extends Field {
|
|
|
37
44
|
this.value = config.defaultValue;
|
|
38
45
|
this._defaultValue = config.defaultValue;
|
|
39
46
|
this.sanitize = config.sanitize ?? false;
|
|
47
|
+
this.rtl = config.rtl;
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* Sanitize the value
|
|
@@ -62,6 +70,7 @@ export class TextField extends Field {
|
|
|
62
70
|
minLength: this.minLength,
|
|
63
71
|
placeholder: this.placeholder,
|
|
64
72
|
sanitize: this.sanitize,
|
|
73
|
+
rtl: this.rtl,
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
@@ -76,7 +85,7 @@ export class TextField extends Field {
|
|
|
76
85
|
*/
|
|
77
86
|
if (this.required) {
|
|
78
87
|
if (!this.value || this.value.trim().length === 0) {
|
|
79
|
-
throw new Error(getString('fieldIsRequired', this.
|
|
88
|
+
throw new Error(getString('fieldIsRequired', this.language, { field: this.getLocalizedLabel() }));
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
91
|
}
|
|
@@ -100,7 +109,7 @@ export class TextField extends Field {
|
|
|
100
109
|
*/
|
|
101
110
|
if (this.minLength) {
|
|
102
111
|
if (this.minLength > this.value.length) {
|
|
103
|
-
throw new Error(getString('minLength', this.
|
|
112
|
+
throw new Error(getString('minLength', this.language, { min: this.minLength }));
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
@@ -108,7 +117,7 @@ export class TextField extends Field {
|
|
|
108
117
|
*/
|
|
109
118
|
if (this.maxLength) {
|
|
110
119
|
if (this.maxLength < this.value.length) {
|
|
111
|
-
throw new Error(getString('maxLength', this.
|
|
120
|
+
throw new Error(getString('maxLength', this.language, { max: this.maxLength }));
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
}
|
|
@@ -13,6 +13,12 @@ declare const configSchema: z.ZodObject<{
|
|
|
13
13
|
* @default false
|
|
14
14
|
*/
|
|
15
15
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Explicitly set the text direction for this field.
|
|
18
|
+
* When set, overrides the locale-based RTL setting across all locales.
|
|
19
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
20
|
+
*/
|
|
21
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
16
22
|
}, z.core.$strict>;
|
|
17
23
|
type Config = z.infer<typeof configSchema>;
|
|
18
24
|
export declare class TextAreaField extends Field<'textarea', Config> {
|
|
@@ -21,16 +27,19 @@ export declare class TextAreaField extends Field<'textarea', Config> {
|
|
|
21
27
|
readonly minLength: number | undefined;
|
|
22
28
|
readonly placeholder: string | undefined;
|
|
23
29
|
readonly sanitize: boolean;
|
|
30
|
+
readonly rtl: boolean | undefined;
|
|
24
31
|
constructor(config: BaseFieldConfig<Config>);
|
|
25
32
|
exportForClient(): {
|
|
26
33
|
maxLength: number | undefined;
|
|
27
34
|
minLength: number | undefined;
|
|
28
35
|
placeholder: string | undefined;
|
|
29
36
|
sanitize: boolean;
|
|
37
|
+
rtl: boolean | undefined;
|
|
30
38
|
type: "textarea";
|
|
31
39
|
name: string;
|
|
32
|
-
label: import("../../index.js").
|
|
40
|
+
label: import("../../index.js").MultilingualString;
|
|
33
41
|
required: boolean;
|
|
42
|
+
localized?: boolean;
|
|
34
43
|
conditionalFields: import("../types/index.js").ConditionalField[];
|
|
35
44
|
readonly: boolean;
|
|
36
45
|
defaultValue: any;
|
|
@@ -62,6 +71,12 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
62
71
|
* @default false
|
|
63
72
|
*/
|
|
64
73
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Explicitly set the text direction for this field.
|
|
76
|
+
* When set, overrides the locale-based RTL setting across all locales.
|
|
77
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
78
|
+
*/
|
|
79
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
65
80
|
name: z.ZodString;
|
|
66
81
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
67
82
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -69,6 +84,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
69
84
|
order: z.ZodOptional<z.ZodNumber>;
|
|
70
85
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
71
86
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
87
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
72
88
|
}, z.core.$strict>;
|
|
73
89
|
declare const textAreaFieldConfigSchema: z.ZodObject<{
|
|
74
90
|
type: z.ZodLiteral<"textarea">;
|
|
@@ -83,6 +99,12 @@ declare const textAreaFieldConfigSchema: z.ZodObject<{
|
|
|
83
99
|
* @default false
|
|
84
100
|
*/
|
|
85
101
|
sanitize: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Explicitly set the text direction for this field.
|
|
104
|
+
* When set, overrides the locale-based RTL setting across all locales.
|
|
105
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
106
|
+
*/
|
|
107
|
+
rtl: z.ZodOptional<z.ZodBoolean>;
|
|
86
108
|
name: z.ZodString;
|
|
87
109
|
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
88
110
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -90,6 +112,7 @@ declare const textAreaFieldConfigSchema: z.ZodObject<{
|
|
|
90
112
|
order: z.ZodOptional<z.ZodNumber>;
|
|
91
113
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
92
114
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
115
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
93
116
|
}, z.core.$strict>;
|
|
94
117
|
/**
|
|
95
118
|
* TextArea field configuration type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textArea.d.ts","sourceRoot":"","sources":["../../../src/core/fields/textArea.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,QAAA,MAAM,YAAY;;;;IAId;;;;;OAKG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,aAAc,SAAQ,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC;IACxD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAkB;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"textArea.d.ts","sourceRoot":"","sources":["../../../src/core/fields/textArea.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GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,mBAAmB,CAmBvF"}
|
|
@@ -13,6 +13,12 @@ const configSchema = z.strictObject({
|
|
|
13
13
|
* @default false
|
|
14
14
|
*/
|
|
15
15
|
sanitize: z.boolean().optional().describe('Sanitize the value before saving'),
|
|
16
|
+
/**
|
|
17
|
+
* Explicitly set the text direction for this field.
|
|
18
|
+
* When set, overrides the locale-based RTL setting across all locales.
|
|
19
|
+
* Useful for fields that always have a fixed direction regardless of the content locale.
|
|
20
|
+
*/
|
|
21
|
+
rtl: z.boolean().optional().describe('Override text direction: true for RTL, false for LTR'),
|
|
16
22
|
});
|
|
17
23
|
export class TextAreaField extends Field {
|
|
18
24
|
static [entityKind] = 'TextAreaField';
|
|
@@ -20,12 +26,14 @@ export class TextAreaField extends Field {
|
|
|
20
26
|
minLength;
|
|
21
27
|
placeholder;
|
|
22
28
|
sanitize;
|
|
29
|
+
rtl;
|
|
23
30
|
constructor(config) {
|
|
24
31
|
super(config, 'textarea');
|
|
25
32
|
this.maxLength = config.maxLength;
|
|
26
33
|
this.minLength = config.minLength;
|
|
27
34
|
this.placeholder = config.placeholder;
|
|
28
35
|
this.sanitize = config.sanitize ?? false;
|
|
36
|
+
this.rtl = config.rtl;
|
|
29
37
|
}
|
|
30
38
|
exportForClient() {
|
|
31
39
|
return {
|
|
@@ -34,6 +42,7 @@ export class TextAreaField extends Field {
|
|
|
34
42
|
minLength: this.minLength,
|
|
35
43
|
placeholder: this.placeholder,
|
|
36
44
|
sanitize: this.sanitize,
|
|
45
|
+
rtl: this.rtl,
|
|
37
46
|
};
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
@@ -50,8 +50,9 @@ export declare class VideoField extends FileField<'video', Config> {
|
|
|
50
50
|
mimeType: string[];
|
|
51
51
|
type: "video";
|
|
52
52
|
name: string;
|
|
53
|
-
label: import("../../index.js").
|
|
53
|
+
label: import("../../index.js").MultilingualString;
|
|
54
54
|
required: boolean;
|
|
55
|
+
localized?: boolean;
|
|
55
56
|
conditionalFields: import("../types/index.js").ConditionalField[];
|
|
56
57
|
readonly: boolean;
|
|
57
58
|
defaultValue: any;
|
|
@@ -110,6 +111,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
110
111
|
order: z.ZodOptional<z.ZodNumber>;
|
|
111
112
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
112
113
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
114
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
113
115
|
}, z.core.$strict>;
|
|
114
116
|
declare const videoFieldConfigSchema: z.ZodObject<{
|
|
115
117
|
type: z.ZodLiteral<"video">;
|
|
@@ -140,6 +142,7 @@ declare const videoFieldConfigSchema: z.ZodObject<{
|
|
|
140
142
|
order: z.ZodOptional<z.ZodNumber>;
|
|
141
143
|
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
142
144
|
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
145
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
143
146
|
}, z.core.$strict>;
|
|
144
147
|
/**
|
|
145
148
|
* Video field configuration type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/core/fields/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;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M;IAIX,WAAW,CAAC,KAAK,EAAE,MAAM;IAIvB,QAAQ,CAAC,KAAK,EAAE,GAAG;IAQnB,OAAO,CAAC,IAAI,EAAE,IAAI;IAK3B,aAAa;IAYb;;OAEG;IACG,oBAAoB;CAoD7B;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE9E,QAAA,MAAM,aAAa;IAxPf;;OAEG;;;;;;;;IAQH;;;OAGG;;;;;;;;;;;;;;kBA8OL,CAAA;AAEF,QAAA,MAAM,sBAAsB;;;IA7PxB;;OAEG;;;;;;;;IAQH;;;OAGG;;;;;;;;;;;;;;kBAoPL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,gBAAgB,CAmBjF"}
|
|
@@ -76,13 +76,13 @@ export class VideoField extends FileField {
|
|
|
76
76
|
}
|
|
77
77
|
async readChunkFromFile({ arrayBuffer, length, startPosition = 0, }) {
|
|
78
78
|
if (!arrayBuffer) {
|
|
79
|
-
throw new Error(getString('errorReadingFile', this.
|
|
79
|
+
throw new Error(getString('errorReadingFile', this.language));
|
|
80
80
|
}
|
|
81
81
|
const buffer = new Uint8Array(arrayBuffer);
|
|
82
82
|
const start = Math.max(0, startPosition);
|
|
83
83
|
const end = Math.min(start + length, buffer.length);
|
|
84
84
|
if (start >= end) {
|
|
85
|
-
throw new Error(getString('errorReadingFile', this.
|
|
85
|
+
throw new Error(getString('errorReadingFile', this.language));
|
|
86
86
|
}
|
|
87
87
|
return buffer.subarray(start, end);
|
|
88
88
|
}
|
|
@@ -91,10 +91,10 @@ export class VideoField extends FileField {
|
|
|
91
91
|
*/
|
|
92
92
|
async writeToFile() {
|
|
93
93
|
if (!this._folder) {
|
|
94
|
-
throw new Error(getString('videoFolderNotSet', this.
|
|
94
|
+
throw new Error(getString('videoFolderNotSet', this.language, { field: this.getLocalizedLabel() }));
|
|
95
95
|
}
|
|
96
96
|
if (!this._buffer) {
|
|
97
|
-
throw new Error(getString('videoBufferNotSet', this.
|
|
97
|
+
throw new Error(getString('videoBufferNotSet', this.language, { field: this.getLocalizedLabel() }));
|
|
98
98
|
}
|
|
99
99
|
try {
|
|
100
100
|
/**
|
|
@@ -111,16 +111,18 @@ export class VideoField extends FileField {
|
|
|
111
111
|
await fs.promises.writeFile(path.join(uploadsFolder, '.videos', this._folder, this.value), this._buffer);
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
|
-
throw new Error(getString('videoWriteError', this.
|
|
114
|
+
throw new Error(getString('videoWriteError', this.language, { field: this.getLocalizedLabel() }) + ` ${error.message}`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
async postSubmit(folder) {
|
|
118
|
+
if (!this._file)
|
|
119
|
+
return;
|
|
118
120
|
this._folder = folder;
|
|
119
121
|
await this.writeToFile();
|
|
120
122
|
}
|
|
121
123
|
async postSubmitRollback() {
|
|
122
124
|
if (!this._folder) {
|
|
123
|
-
throw new Error(getString('videoFolderNotSet', this.
|
|
125
|
+
throw new Error(getString('videoFolderNotSet', this.language, { field: this.getLocalizedLabel() }));
|
|
124
126
|
}
|
|
125
127
|
try {
|
|
126
128
|
const uploadsFolder = (await getCMSConfig()).media.upload.path;
|
|
@@ -128,7 +130,7 @@ export class VideoField extends FileField {
|
|
|
128
130
|
await fs.promises.unlink(pathToFile);
|
|
129
131
|
}
|
|
130
132
|
catch (error) {
|
|
131
|
-
throw new Error(getString('fileDeleteError', this.
|
|
133
|
+
throw new Error(getString('fileDeleteError', this.language, { field: this.getLocalizedLabel() }));
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
async cleanupReplacedFile(previousValue, sectionName) {
|
|
@@ -166,7 +168,7 @@ export class VideoField extends FileField {
|
|
|
166
168
|
* Note: Those values are coming from the browser (not safe)
|
|
167
169
|
*/
|
|
168
170
|
if ((this.required && !this._file) || !this._file?.type || !this._file?.name || !this._file?.size) {
|
|
169
|
-
throw new Error(getString('fieldIsRequired', this.
|
|
171
|
+
throw new Error(getString('fieldIsRequired', this.language, { field: this.getLocalizedLabel() }));
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
/**
|
|
@@ -181,14 +183,14 @@ export class VideoField extends FileField {
|
|
|
181
183
|
const arrayBuffer = await this._file.arrayBuffer();
|
|
182
184
|
this._buffer = Buffer.from(arrayBuffer);
|
|
183
185
|
if (!this._buffer.length) {
|
|
184
|
-
throw new Error(getString('fieldIsRequired', this.
|
|
186
|
+
throw new Error(getString('fieldIsRequired', this.language, { field: this.getLocalizedLabel() }));
|
|
185
187
|
}
|
|
186
188
|
/**
|
|
187
189
|
* Check extension
|
|
188
190
|
*/
|
|
189
191
|
const ext = this._file.name.split('.').pop();
|
|
190
192
|
if (!ext || !this.extensions.includes(ext)) {
|
|
191
|
-
throw new Error(getString('invalidFileTypeOrExtension', this.
|
|
193
|
+
throw new Error(getString('invalidFileTypeOrExtension', this.language, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
|
|
192
194
|
}
|
|
193
195
|
/**
|
|
194
196
|
* Read the first 4100 bytes of the file
|
|
@@ -203,14 +205,14 @@ export class VideoField extends FileField {
|
|
|
203
205
|
* If the file type is invalid, return an error
|
|
204
206
|
*/
|
|
205
207
|
if (!fileType) {
|
|
206
|
-
throw new Error(getString('invalidDocumentFileType', this.
|
|
208
|
+
throw new Error(getString('invalidDocumentFileType', this.language, { field: this.getLocalizedLabel() }));
|
|
207
209
|
}
|
|
208
210
|
/**
|
|
209
211
|
* Don't just trust the file extension
|
|
210
212
|
* Check the `fileType.ext` against the allowed extensions
|
|
211
213
|
*/
|
|
212
214
|
if (!fileType.ext || !this.extensions.includes(fileType.ext)) {
|
|
213
|
-
throw new Error(getString('invalidFileTypeOrExtension', this.
|
|
215
|
+
throw new Error(getString('invalidFileTypeOrExtension', this.language, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
|
|
214
216
|
}
|
|
215
217
|
/**
|
|
216
218
|
* Generate a random name for the file
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
package/dist/core/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/localization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveLocale } from './resolve-locale.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComputedCMSConfig } from '../config/index.js';
|
|
2
|
+
type LocalizationConfig = Readonly<ComputedCMSConfig['localization']>;
|
|
3
|
+
type EnabledLocalizationConfig = NonNullable<LocalizationConfig>;
|
|
4
|
+
type LocaleConfig = EnabledLocalizationConfig['locales'][number];
|
|
5
|
+
export type ResolveLocaleInput = {
|
|
6
|
+
localization: LocalizationConfig;
|
|
7
|
+
locale?: string | null;
|
|
8
|
+
};
|
|
9
|
+
export type ResolveLocaleResult = {
|
|
10
|
+
localizationEnabled: true;
|
|
11
|
+
availableLocales: LocaleConfig[];
|
|
12
|
+
resolvedLocale: LocaleConfig | undefined;
|
|
13
|
+
defaultLocale: LocaleConfig;
|
|
14
|
+
isDefault: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
localizationEnabled: false;
|
|
17
|
+
availableLocales: [];
|
|
18
|
+
resolvedLocale: undefined;
|
|
19
|
+
defaultLocale: undefined;
|
|
20
|
+
isDefault: false;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Resolves a caller-provided locale into the effective content locale code.
|
|
24
|
+
*
|
|
25
|
+
* The DB storage convention is intentionally out of scope here.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveLocale({ localization, locale }: ResolveLocaleInput): ResolveLocaleResult;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=resolve-locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-locale.d.ts","sourceRoot":"","sources":["../../../src/core/localization/resolve-locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,KAAK,kBAAkB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAA;AACrE,KAAK,yBAAyB,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAA;AAChE,KAAK,YAAY,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEhE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,YAAY,EAAE,kBAAkB,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,mBAAmB,GACzB;IACI,mBAAmB,EAAE,IAAI,CAAA;IACzB,gBAAgB,EAAE,YAAY,EAAE,CAAA;IAChC,cAAc,EAAE,YAAY,GAAG,SAAS,CAAA;IACxC,aAAa,EAAE,YAAY,CAAA;IAC3B,SAAS,EAAE,OAAO,CAAA;CACrB,GACD;IACI,mBAAmB,EAAE,KAAK,CAAA;IAC1B,gBAAgB,EAAE,EAAE,CAAA;IACpB,cAAc,EAAE,SAAS,CAAA;IACzB,aAAa,EAAE,SAAS,CAAA;IACxB,SAAS,EAAE,KAAK,CAAA;CACnB,CAAA;AAEP;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,mBAAmB,CAmC/F"}
|