nextjs-cms 0.9.29 → 0.9.30
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/LICENSE +21 -21
- package/README.md +279 -279
- package/dist/api/actions/pages.d.ts +3 -3
- package/dist/api/index.d.ts +974 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +13 -0
- package/dist/api/lib/serverActions.d.ts +49 -13
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +31 -103
- package/dist/api/root.d.ts +1916 -18
- package/dist/api/root.d.ts.map +1 -1
- package/dist/api/root.js +83 -18
- package/dist/api/routers/config.d.ts.map +1 -1
- package/dist/api/routers/gallery.d.ts +0 -1
- package/dist/api/routers/gallery.d.ts.map +1 -1
- package/dist/api/routers/gallery.js +8 -36
- package/dist/api/routers/hasItemsSection.d.ts +30 -5
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/routers/navigation.d.ts +3 -3
- package/dist/api/routers/simpleSection.d.ts +15 -3
- package/dist/api/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/trpc/root.d.ts +3 -3
- package/dist/api/trpc/root.d.ts.map +1 -1
- package/dist/api/trpc/routers/config.d.ts.map +1 -1
- package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/trpc/routers/navigation.d.ts +3 -3
- package/dist/api/trpc/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/trpc/server.d.ts +9 -9
- package/dist/api/trpc/server.d.ts.map +1 -1
- package/dist/auth/trpc.d.ts +1 -1
- package/dist/auth/trpc.d.ts.map +1 -1
- package/dist/auth/trpc.js +1 -0
- package/dist/cli/lib/db-config.js +10 -10
- package/dist/cli/lib/update-sections.d.ts.map +1 -1
- package/dist/cli/lib/update-sections.js +24 -29
- package/dist/core/db/table-checker/MysqlTable.js +10 -10
- package/dist/core/factories/section-factory-with-esbuild.js +9 -9
- package/dist/core/factories/section-factory-with-jiti.js +9 -9
- package/dist/core/fields/dateRange.d.ts +115 -0
- package/dist/core/fields/dateRange.d.ts.map +1 -0
- package/dist/core/fields/dateRange.js +149 -0
- package/dist/core/sections/category.d.ts +42 -42
- package/dist/core/sections/hasItems.d.ts +42 -42
- package/dist/core/sections/section.d.ts +22 -22
- package/dist/core/sections/simple.d.ts +8 -8
- package/dist/plugins/derive.d.ts +0 -8
- package/dist/plugins/derive.d.ts.map +1 -1
- package/dist/plugins/derive.js +0 -32
- package/dist/plugins/server.d.ts +1 -1
- package/dist/plugins/server.d.ts.map +1 -1
- package/dist/plugins/server.js +1 -1
- package/dist/translations/client.d.ts +4 -4
- package/dist/translations/locale-cookie.d.ts +24 -0
- package/dist/translations/locale-cookie.d.ts.map +1 -0
- package/dist/translations/locale-cookie.js +44 -0
- package/dist/translations/locale-utils.d.ts +8 -0
- package/dist/translations/locale-utils.d.ts.map +1 -0
- package/dist/translations/locale-utils.js +11 -0
- package/dist/translations/localization.d.ts +40 -0
- package/dist/translations/localization.d.ts.map +1 -0
- package/dist/translations/localization.js +48 -0
- package/dist/validators/dateRange.d.ts +11 -0
- package/dist/validators/dateRange.d.ts.map +1 -0
- package/dist/validators/dateRange.js +16 -0
- package/package.json +1 -1
- package/dist/api/client.d.ts +0 -30
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -82
- package/dist/api/server.d.ts +0 -2748
- package/dist/api/server.d.ts.map +0 -1
- package/dist/api/server.js +0 -100
- package/dist/api/utils/async-caller-proxy.d.ts +0 -2
- package/dist/api/utils/async-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/async-caller-proxy.js +0 -36
- package/dist/api/utils/lazy-caller-proxy.d.ts +0 -2
- package/dist/api/utils/lazy-caller-proxy.d.ts.map +0 -1
- package/dist/api/utils/lazy-caller-proxy.js +0 -36
- package/dist/api/utils/router-types.d.ts +0 -7
- package/dist/api/utils/router-types.d.ts.map +0 -1
- package/dist/api/utils/router-types.js +0 -0
- package/dist/plugins/manifest.d.ts +0 -28
- package/dist/plugins/manifest.d.ts.map +0 -1
- package/dist/plugins/manifest.js +0 -83
- package/dist/plugins/registry.d.ts +0 -22
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -25
- package/dist/utils/log.d.ts +0 -18
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js +0 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAUjE,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEvF,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,YAAY;IAC/D,OAAO,CAAC,EAAE,0BAA0B,CAAC,KAAK,CAAC,CAAA;IAC3C,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;CACjE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,KAAK,SAAS,YAAY,GAAG,EAAE,EAAE,IAAI,GAAE,uBAAuB,CAAC,KAAK,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","s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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAA7o+B,CAAC;;;;;+BAAsE,CAAC;;;;;;+BAA2G,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAtFl2B,OAAO,CAAC,SAAS,CAAC;EAqFvD"}
|
package/dist/auth/trpc.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { TRPCLink } from '@trpc/client';
|
|
|
2
2
|
/**
|
|
3
3
|
* tRPC link that refreshes the token if it's expired
|
|
4
4
|
*/
|
|
5
|
-
export declare const refreshTokenLink: () => TRPCLink
|
|
5
|
+
export declare const refreshTokenLink: () => TRPCLink</*AppRouter*/ any>;
|
|
6
6
|
//# sourceMappingURL=trpc.d.ts.map
|
package/dist/auth/trpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/auth/trpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/auth/trpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAM5C;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CA6E7D,CAAA"}
|
package/dist/auth/trpc.js
CHANGED
|
@@ -140,16 +140,16 @@ export async function dbConfigSetup(options) {
|
|
|
140
140
|
/**
|
|
141
141
|
* Prepare new environment variables block
|
|
142
142
|
*/
|
|
143
|
-
const newEnvBlock = `
|
|
144
|
-
|
|
145
|
-
####
|
|
146
|
-
# generated by the init script
|
|
147
|
-
####
|
|
148
|
-
DB_HOST=${dbHost}
|
|
149
|
-
DB_PORT=${dbPort}
|
|
150
|
-
DB_NAME=${dbName}
|
|
151
|
-
DB_USER=${dbUser}
|
|
152
|
-
DB_PASSWORD='${dbPassword}'
|
|
143
|
+
const newEnvBlock = `
|
|
144
|
+
|
|
145
|
+
####
|
|
146
|
+
# generated by the init script
|
|
147
|
+
####
|
|
148
|
+
DB_HOST=${dbHost}
|
|
149
|
+
DB_PORT=${dbPort}
|
|
150
|
+
DB_NAME=${dbName}
|
|
151
|
+
DB_USER=${dbUser}
|
|
152
|
+
DB_PASSWORD='${dbPassword}'
|
|
153
153
|
`;
|
|
154
154
|
/**
|
|
155
155
|
* Append the new credentials to the .env file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/update-sections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/update-sections.ts"],"names":[],"mappings":"AAm3EA,wBAAsB,cAAc,CAAC,SAAS,UAAQ,iBAoBrD"}
|
|
@@ -192,12 +192,7 @@ function generateFieldSQL(input) {
|
|
|
192
192
|
else if (!input.defaultValue) {
|
|
193
193
|
fieldSQL += ' DEFAULT NULL';
|
|
194
194
|
}
|
|
195
|
-
if (input.defaultValue !== null && input.defaultValue !== undefined
|
|
196
|
-
// Only add sql default when the field is required,
|
|
197
|
-
// to allow null values in non-required fields
|
|
198
|
-
// with defaultValue prop set.
|
|
199
|
-
// Example: Admin cleared the defaultValue of
|
|
200
|
-
// non-required field and submits.
|
|
195
|
+
if (input.defaultValue !== null && input.defaultValue !== undefined) {
|
|
201
196
|
fieldSQL += ` DEFAULT '${input.defaultValue}'`;
|
|
202
197
|
}
|
|
203
198
|
return fieldSQL;
|
|
@@ -389,17 +384,17 @@ function buildLocaleFieldConfig() {
|
|
|
389
384
|
});
|
|
390
385
|
}
|
|
391
386
|
async function createEditorPhotosTable(localized) {
|
|
392
|
-
await db.execute(sql `
|
|
393
|
-
CREATE TABLE IF NOT EXISTS \`editor_photos\` (
|
|
394
|
-
\`photo\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
395
|
-
\`section\` VARCHAR(100) NOT NULL,
|
|
396
|
-
\`item_id\` VARCHAR(50) NOT NULL,
|
|
397
|
-
\`field\` VARCHAR(100) NOT NULL,
|
|
398
|
-
\`meta\` LONGTEXT,
|
|
399
|
-
${localized ? sql `\`locale\` VARCHAR(10) NOT NULL,` : sql ``}
|
|
400
|
-
\`linked\` BOOLEAN DEFAULT false,
|
|
401
|
-
\`created_at\` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
402
|
-
)
|
|
387
|
+
await db.execute(sql `
|
|
388
|
+
CREATE TABLE IF NOT EXISTS \`editor_photos\` (
|
|
389
|
+
\`photo\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
390
|
+
\`section\` VARCHAR(100) NOT NULL,
|
|
391
|
+
\`item_id\` VARCHAR(50) NOT NULL,
|
|
392
|
+
\`field\` VARCHAR(100) NOT NULL,
|
|
393
|
+
\`meta\` LONGTEXT,
|
|
394
|
+
${localized ? sql `\`locale\` VARCHAR(10) NOT NULL,` : sql ``}
|
|
395
|
+
\`linked\` BOOLEAN DEFAULT false,
|
|
396
|
+
\`created_at\` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
397
|
+
)
|
|
403
398
|
`);
|
|
404
399
|
}
|
|
405
400
|
async function ensureEditorPhotosLocaleColumn(defaultLocaleCode, knownColumns) {
|
|
@@ -993,22 +988,22 @@ const main = async (s) => {
|
|
|
993
988
|
* Let's see if the table `__nextjs_cms_tables` exists in the database.
|
|
994
989
|
* If it doesn't, we'll create it using the same schema as `NextJsCmsTablesTable`.
|
|
995
990
|
*/
|
|
996
|
-
await db.execute(sql `
|
|
997
|
-
CREATE TABLE IF NOT EXISTS __nextjs_cms_tables (
|
|
998
|
-
name VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
999
|
-
section VARCHAR(200),
|
|
1000
|
-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
1001
|
-
)
|
|
991
|
+
await db.execute(sql `
|
|
992
|
+
CREATE TABLE IF NOT EXISTS __nextjs_cms_tables (
|
|
993
|
+
name VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
994
|
+
section VARCHAR(200),
|
|
995
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
996
|
+
)
|
|
1002
997
|
`);
|
|
1003
998
|
/**
|
|
1004
999
|
* Persistent key/value store for CMS-level state that must survive config removal.
|
|
1005
1000
|
*/
|
|
1006
|
-
await db.execute(sql `
|
|
1007
|
-
CREATE TABLE IF NOT EXISTS __nextjs_cms_config (
|
|
1008
|
-
\`key\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1009
|
-
\`value\` LONGTEXT,
|
|
1010
|
-
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
1011
|
-
)
|
|
1001
|
+
await db.execute(sql `
|
|
1002
|
+
CREATE TABLE IF NOT EXISTS __nextjs_cms_config (
|
|
1003
|
+
\`key\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1004
|
+
\`value\` LONGTEXT,
|
|
1005
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
1006
|
+
)
|
|
1012
1007
|
`);
|
|
1013
1008
|
await db.execute(sql `ALTER TABLE \`__nextjs_cms_config\` MODIFY COLUMN \`value\` LONGTEXT`);
|
|
1014
1009
|
/**
|
|
@@ -22,12 +22,12 @@ export class MysqlTableChecker extends DbTableChecker {
|
|
|
22
22
|
return _tables;
|
|
23
23
|
}
|
|
24
24
|
static async getColumns(tableName) {
|
|
25
|
-
const statement = sql `
|
|
26
|
-
SELECT COLUMN_NAME
|
|
27
|
-
FROM information_schema.COLUMNS c
|
|
28
|
-
inner join information_schema.TABLES t ON t.TABLE_NAME = c.TABLE_NAME
|
|
29
|
-
WHERE t.TABLE_SCHEMA = DATABASE()
|
|
30
|
-
AND c.TABLE_SCHEMA = DATABASE()
|
|
25
|
+
const statement = sql `
|
|
26
|
+
SELECT COLUMN_NAME
|
|
27
|
+
FROM information_schema.COLUMNS c
|
|
28
|
+
inner join information_schema.TABLES t ON t.TABLE_NAME = c.TABLE_NAME
|
|
29
|
+
WHERE t.TABLE_SCHEMA = DATABASE()
|
|
30
|
+
AND c.TABLE_SCHEMA = DATABASE()
|
|
31
31
|
AND t.TABLE_NAME = ${tableName}`;
|
|
32
32
|
const _cols = [];
|
|
33
33
|
const _res = await db.execute(statement);
|
|
@@ -84,10 +84,10 @@ export class MysqlTableChecker extends DbTableChecker {
|
|
|
84
84
|
fullTextKeys.push({ name: key, columns: _fullTextKeyMap[key] });
|
|
85
85
|
}
|
|
86
86
|
// Foreign keys should be retrieved from information_schema
|
|
87
|
-
const [foreignKeys] = await db.execute(sql `
|
|
88
|
-
SELECT COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
|
|
89
|
-
FROM information_schema.KEY_COLUMN_USAGE
|
|
90
|
-
WHERE TABLE_NAME = ${table} AND CONSTRAINT_NAME != 'PRIMARY' AND REFERENCED_TABLE_NAME IS NOT NULL;
|
|
87
|
+
const [foreignKeys] = await db.execute(sql `
|
|
88
|
+
SELECT COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
|
|
89
|
+
FROM information_schema.KEY_COLUMN_USAGE
|
|
90
|
+
WHERE TABLE_NAME = ${table} AND CONSTRAINT_NAME != 'PRIMARY' AND REFERENCED_TABLE_NAME IS NOT NULL;
|
|
91
91
|
`);
|
|
92
92
|
return { primaryKeys, uniqueKeys, indexKeys, foreignKeys, fullTextKeys };
|
|
93
93
|
}
|
|
@@ -460,15 +460,15 @@ export class SectionFactory {
|
|
|
460
460
|
importErr.message.includes('Cannot find module') &&
|
|
461
461
|
importErr.message.includes('.section')) {
|
|
462
462
|
this.sectionProcessingErrors[file] ??= [];
|
|
463
|
-
this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
|
|
464
|
-
|
|
465
|
-
Sections MUST use extensionless relative imports:
|
|
466
|
-
|
|
467
|
-
✅ import exampleSection from './example.section'
|
|
468
|
-
❌ import exampleSection from './example.section.ts'
|
|
469
|
-
❌ import exampleSection from './example.section.js'
|
|
470
|
-
|
|
471
|
-
This file is bundled with esbuild, so Node never resolves the import directly.
|
|
463
|
+
this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
|
|
464
|
+
|
|
465
|
+
Sections MUST use extensionless relative imports:
|
|
466
|
+
|
|
467
|
+
✅ import exampleSection from './example.section'
|
|
468
|
+
❌ import exampleSection from './example.section.ts'
|
|
469
|
+
❌ import exampleSection from './example.section.js'
|
|
470
|
+
|
|
471
|
+
This file is bundled with esbuild, so Node never resolves the import directly.
|
|
472
472
|
If you added an extension manually, remove it.`);
|
|
473
473
|
this.errorCount++;
|
|
474
474
|
continue;
|
|
@@ -417,15 +417,15 @@ export class SectionFactory {
|
|
|
417
417
|
importErr.message.includes('Cannot find module') &&
|
|
418
418
|
importErr.message.includes('.section')) {
|
|
419
419
|
this.sectionProcessingErrors[file] ??= [];
|
|
420
|
-
this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
|
|
421
|
-
|
|
422
|
-
Sections MUST use extensionless relative imports:
|
|
423
|
-
|
|
424
|
-
✅ import exampleSection from './example.section'
|
|
425
|
-
❌ import exampleSection from './example.section.ts'
|
|
426
|
-
❌ import exampleSection from './example.section.js'
|
|
427
|
-
|
|
428
|
-
This file is bundled with jiti, so Node never resolves the import directly.
|
|
420
|
+
this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
|
|
421
|
+
|
|
422
|
+
Sections MUST use extensionless relative imports:
|
|
423
|
+
|
|
424
|
+
✅ import exampleSection from './example.section'
|
|
425
|
+
❌ import exampleSection from './example.section.ts'
|
|
426
|
+
❌ import exampleSection from './example.section.js'
|
|
427
|
+
|
|
428
|
+
This file is bundled with jiti, so Node never resolves the import directly.
|
|
429
429
|
If you added an extension manually, remove it.`);
|
|
430
430
|
this.errorCount++;
|
|
431
431
|
continue;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { BaseFieldConfig } from './field.js';
|
|
2
|
+
import { Field } from './field.js';
|
|
3
|
+
import { entityKind } from '../helpers/index.js';
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
declare const configSchema: z.ZodObject<{
|
|
6
|
+
startName: z.ZodString;
|
|
7
|
+
endName: z.ZodString;
|
|
8
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
date: "date";
|
|
10
|
+
datetime: "datetime";
|
|
11
|
+
}>>;
|
|
12
|
+
defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
13
|
+
defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
type Config = z.infer<typeof configSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* DateRangeField stores two DB columns: startName and endName.
|
|
18
|
+
*
|
|
19
|
+
* Because Field expects a single `name`, we pass `startName` as `name` to the
|
|
20
|
+
* super constructor (used for label generation / identity only).
|
|
21
|
+
* The field opts out of the normal single-column SQL path via hasSqlNameAndValue()=false
|
|
22
|
+
* and instead exposes setValues() / getSqlNamesAndValues() which submit.ts calls
|
|
23
|
+
* via an is(field, DateRangeField) guard — the same pattern used for SelectField.
|
|
24
|
+
*/
|
|
25
|
+
export declare class DateRangeField extends Field<'date_range', Config> {
|
|
26
|
+
static readonly [entityKind]: string;
|
|
27
|
+
readonly startName: string;
|
|
28
|
+
readonly endName: string;
|
|
29
|
+
readonly format: 'date' | 'datetime';
|
|
30
|
+
private startValue;
|
|
31
|
+
private endValue;
|
|
32
|
+
constructor(config: Omit<BaseFieldConfig<Config>, 'name'> & Config);
|
|
33
|
+
hasSqlNameAndValue(): boolean;
|
|
34
|
+
setValues(postData: FormData): void;
|
|
35
|
+
getSqlNamesAndValues(): Record<string, string | null>;
|
|
36
|
+
getValue(): {
|
|
37
|
+
from: string | null;
|
|
38
|
+
to: string | null;
|
|
39
|
+
};
|
|
40
|
+
exportForClient(): {
|
|
41
|
+
startName: string;
|
|
42
|
+
endName: string;
|
|
43
|
+
format: "date" | "datetime";
|
|
44
|
+
startValue: any;
|
|
45
|
+
endValue: any;
|
|
46
|
+
type: "date_range";
|
|
47
|
+
name: string;
|
|
48
|
+
label: string;
|
|
49
|
+
required: boolean;
|
|
50
|
+
localized?: boolean;
|
|
51
|
+
conditionalFields: import("../types/index.js").ConditionalField[];
|
|
52
|
+
readonly: boolean;
|
|
53
|
+
defaultValue: any;
|
|
54
|
+
value: any;
|
|
55
|
+
};
|
|
56
|
+
checkRequired(): void;
|
|
57
|
+
prepareForSubmission(): Promise<void>;
|
|
58
|
+
private parseDate;
|
|
59
|
+
private formatDate;
|
|
60
|
+
}
|
|
61
|
+
export type DateRangeFieldClientConfig = ReturnType<DateRangeField['exportForClient']>;
|
|
62
|
+
declare const optionsSchema: z.ZodObject<{
|
|
63
|
+
startName: z.ZodString;
|
|
64
|
+
endName: z.ZodString;
|
|
65
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
66
|
+
date: "date";
|
|
67
|
+
datetime: "datetime";
|
|
68
|
+
}>>;
|
|
69
|
+
defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
70
|
+
defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
71
|
+
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
72
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
74
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
76
|
+
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
77
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
declare const dateRangeFieldConfigSchema: z.ZodObject<{
|
|
80
|
+
/**
|
|
81
|
+
* Auto-computed as `${startName}|${endName}`.
|
|
82
|
+
* Satisfies the `FieldConfig` union constraint that every config has a `name` property.
|
|
83
|
+
* Never set manually — use `startName` and `endName` instead.
|
|
84
|
+
*/
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
type: z.ZodLiteral<"date_range">;
|
|
87
|
+
build: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodCustom<DateRangeField, DateRangeField>>;
|
|
88
|
+
startName: z.ZodString;
|
|
89
|
+
endName: z.ZodString;
|
|
90
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
date: "date";
|
|
92
|
+
datetime: "datetime";
|
|
93
|
+
}>>;
|
|
94
|
+
defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
95
|
+
defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
|
|
96
|
+
label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
97
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
+
defaultValue: z.ZodOptional<z.ZodAny>;
|
|
99
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
|
|
101
|
+
adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
|
|
102
|
+
localized: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
}, z.core.$strict>;
|
|
104
|
+
export type DateRangeFieldConfig = z.infer<typeof dateRangeFieldConfigSchema>;
|
|
105
|
+
/**
|
|
106
|
+
* Helper to create a date range field configuration.
|
|
107
|
+
* Uses `startName` and `endName` instead of the usual `name`.
|
|
108
|
+
* The `name` property is auto-computed as `${startName}|${endName}`.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* dateRangeField({ startName: 'event_start', endName: 'event_end', label: 'Event Dates' })
|
|
112
|
+
*/
|
|
113
|
+
export declare function dateRangeField(field: z.infer<typeof optionsSchema>): DateRangeFieldConfig;
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=dateRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateRange.d.ts","sourceRoot":"","sources":["../../../src/core/fields/dateRange.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;;;;;;;;;kBAMhB,CAAA;AAEF,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H,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,oBAAoB,CAczF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Field, baseFieldConfigSchema } from './field.js';
|
|
2
|
+
import { entityKind } from '../helpers/index.js';
|
|
3
|
+
import * as z from 'zod';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import getString from '../../translations/index.js';
|
|
6
|
+
const configSchema = z.strictObject({
|
|
7
|
+
startName: z.string().describe('The DB column name for the start date'),
|
|
8
|
+
endName: z.string().describe('The DB column name for the end date'),
|
|
9
|
+
format: z.enum(['date', 'datetime']).optional().describe('The format of the date columns'),
|
|
10
|
+
defaultStartValue: z.custom().optional().describe('Default value for the start date'),
|
|
11
|
+
defaultEndValue: z.custom().optional().describe('Default value for the end date'),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* DateRangeField stores two DB columns: startName and endName.
|
|
15
|
+
*
|
|
16
|
+
* Because Field expects a single `name`, we pass `startName` as `name` to the
|
|
17
|
+
* super constructor (used for label generation / identity only).
|
|
18
|
+
* The field opts out of the normal single-column SQL path via hasSqlNameAndValue()=false
|
|
19
|
+
* and instead exposes setValues() / getSqlNamesAndValues() which submit.ts calls
|
|
20
|
+
* via an is(field, DateRangeField) guard — the same pattern used for SelectField.
|
|
21
|
+
*/
|
|
22
|
+
export class DateRangeField extends Field {
|
|
23
|
+
static [entityKind] = 'DateRangeField';
|
|
24
|
+
startName;
|
|
25
|
+
endName;
|
|
26
|
+
format;
|
|
27
|
+
startValue;
|
|
28
|
+
endValue;
|
|
29
|
+
constructor(config) {
|
|
30
|
+
// Pass startName as `name` so the base class label-generation / identity works
|
|
31
|
+
super({ ...config, name: config.startName }, 'date_range');
|
|
32
|
+
this.startName = config.startName;
|
|
33
|
+
this.endName = config.endName;
|
|
34
|
+
this.format = config.format ?? 'date';
|
|
35
|
+
this.startValue = config.defaultStartValue ?? undefined;
|
|
36
|
+
this.endValue = config.defaultEndValue ?? undefined;
|
|
37
|
+
}
|
|
38
|
+
// ─── Opt out of single-column SQL path ────────────────────────────────────
|
|
39
|
+
hasSqlNameAndValue() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
// ─── Dual-column FormData reading (called by submit.ts) ───────────────────
|
|
43
|
+
setValues(postData) {
|
|
44
|
+
const start = postData.get(this.startName);
|
|
45
|
+
const end = postData.get(this.endName);
|
|
46
|
+
if (start)
|
|
47
|
+
this.startValue = start;
|
|
48
|
+
if (end)
|
|
49
|
+
this.endValue = end;
|
|
50
|
+
}
|
|
51
|
+
// ─── Dual-column SQL output (called by submit.ts) ─────────────────────────
|
|
52
|
+
getSqlNamesAndValues() {
|
|
53
|
+
return {
|
|
54
|
+
[this.startName]: this.formatDate(this.startValue),
|
|
55
|
+
[this.endName]: this.formatDate(this.endValue),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// ─── Standard Field interface ─────────────────────────────────────────────
|
|
59
|
+
getValue() {
|
|
60
|
+
return {
|
|
61
|
+
from: this.formatDate(this.startValue),
|
|
62
|
+
to: this.formatDate(this.endValue),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exportForClient() {
|
|
66
|
+
return {
|
|
67
|
+
...super.exportForClient(),
|
|
68
|
+
startName: this.startName,
|
|
69
|
+
endName: this.endName,
|
|
70
|
+
format: this.format,
|
|
71
|
+
startValue: this.startValue ?? null,
|
|
72
|
+
endValue: this.endValue ?? null,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
checkRequired() {
|
|
76
|
+
if (!this.required)
|
|
77
|
+
return;
|
|
78
|
+
if (!this.parseDate(this.startValue) || !this.parseDate(this.endValue)) {
|
|
79
|
+
throw new Error(getString('fieldIsRequired', this.language, { field: this.getLocalizedLabel() }));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async prepareForSubmission() {
|
|
83
|
+
const start = this.parseDate(this.startValue);
|
|
84
|
+
const end = this.parseDate(this.endValue);
|
|
85
|
+
if (this.required && (!start || !end)) {
|
|
86
|
+
throw new Error(getString('invalidDatePleaseProvideValid', this.language, { field: this.getLocalizedLabel() }));
|
|
87
|
+
}
|
|
88
|
+
if (start)
|
|
89
|
+
this.startValue = start.toISOString();
|
|
90
|
+
if (end)
|
|
91
|
+
this.endValue = end.toISOString();
|
|
92
|
+
}
|
|
93
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
94
|
+
parseDate(value) {
|
|
95
|
+
if (value === undefined || value === null || value === '')
|
|
96
|
+
return null;
|
|
97
|
+
const date = new Date(value);
|
|
98
|
+
return isNaN(date.getTime()) ? null : date;
|
|
99
|
+
}
|
|
100
|
+
formatDate(value) {
|
|
101
|
+
const date = this.parseDate(value);
|
|
102
|
+
if (!date)
|
|
103
|
+
return null;
|
|
104
|
+
return this.format === 'datetime'
|
|
105
|
+
? dayjs(date).format('YYYY-MM-DD HH:mm:ss')
|
|
106
|
+
: dayjs(date).format('YYYY-MM-DD');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// ─── Config schema & factory ──────────────────────────────────────────────────
|
|
110
|
+
const optionsSchema = z.strictObject({
|
|
111
|
+
...baseFieldConfigSchema.omit({ name: true }).shape,
|
|
112
|
+
...configSchema.shape,
|
|
113
|
+
});
|
|
114
|
+
const dateRangeFieldConfigSchema = z.strictObject({
|
|
115
|
+
...optionsSchema.shape,
|
|
116
|
+
/**
|
|
117
|
+
* Auto-computed as `${startName}|${endName}`.
|
|
118
|
+
* Satisfies the `FieldConfig` union constraint that every config has a `name` property.
|
|
119
|
+
* Never set manually — use `startName` and `endName` instead.
|
|
120
|
+
*/
|
|
121
|
+
name: z.string(),
|
|
122
|
+
type: z.literal('date_range').describe('The type of the field'),
|
|
123
|
+
build: z
|
|
124
|
+
.function()
|
|
125
|
+
.output(z.instanceof(DateRangeField))
|
|
126
|
+
.describe('Build a DateRangeField instance from this config'),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Helper to create a date range field configuration.
|
|
130
|
+
* Uses `startName` and `endName` instead of the usual `name`.
|
|
131
|
+
* The `name` property is auto-computed as `${startName}|${endName}`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* dateRangeField({ startName: 'event_start', endName: 'event_end', label: 'Event Dates' })
|
|
135
|
+
*/
|
|
136
|
+
export function dateRangeField(field) {
|
|
137
|
+
const result = optionsSchema.safeParse(field);
|
|
138
|
+
if (!result.success) {
|
|
139
|
+
throw new Error(`[DateRangeField: ${field.startName}/${field.endName}]: ${z.prettifyError(result.error)}`);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...field,
|
|
143
|
+
name: `${field.startName}|${field.endName}`,
|
|
144
|
+
type: 'date_range',
|
|
145
|
+
build() {
|
|
146
|
+
return new DateRangeField(field);
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|