@phtngyn/cms 0.2.0-beta.1 → 0.2.0-beta.3
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/CHANGELOG.md +13 -0
- package/README.md +40 -45
- package/package.json +7 -5
- package/src/ApplicationTypes.d.ts +7 -5
- package/src/{Configuration-CjVUBBwa.js → Configuration-BU-UyGoH.js} +4 -4
- package/src/{Configuration-CjVUBBwa.js.map → Configuration-BU-UyGoH.js.map} +1 -1
- package/src/Configuration.d.ts +41 -24
- package/src/Configuration.js.map +1 -1
- package/src/Content.js +42 -19
- package/src/Content.js.map +1 -1
- package/src/{ContentTransfer-CTzGGKFV.js → ContentTransfer-BhF9G56s.js} +2 -2
- package/src/{ContentTransfer-CTzGGKFV.js.map → ContentTransfer-BhF9G56s.js.map} +1 -1
- package/src/{DocumentEngine-BbhfnTAc.js → DocumentEngine-ClhFXW9M.js} +4 -4
- package/src/{DocumentEngine-BbhfnTAc.js.map → DocumentEngine-ClhFXW9M.js.map} +1 -1
- package/src/DocumentModel.d.ts +6 -1
- package/src/DocumentModel.js +4 -3
- package/src/DocumentModel.js.map +1 -1
- package/src/{Forms-CfcI3tPU.js → Forms-BbkE7QfC.js} +47 -16
- package/src/Forms-BbkE7QfC.js.map +1 -0
- package/src/{Forms-02-p8qEw.js → Forms-DoB56hfe.js} +24 -7
- package/src/Forms-DoB56hfe.js.map +1 -0
- package/src/{Forms-BorTcIlp.d.ts → Forms-R0HoTR-o.d.ts} +30 -9
- package/src/Forms.d.ts +16 -15
- package/src/Forms.js.map +1 -1
- package/src/{I18n-BXlVunfa.d.ts → I18n-zbqpWxki.d.ts} +3 -1
- package/src/I18n.d.ts +1 -1
- package/src/Module.js +4 -2
- package/src/Module.js.map +1 -1
- package/src/{S3MediaObjects-DC0c8sYC.js → S3MediaObjects-CR3p1WTg.js} +21 -13
- package/src/S3MediaObjects-CR3p1WTg.js.map +1 -0
- package/src/cli.js +60 -34
- package/src/cli.js.map +1 -1
- package/src/{connection-BPf4BQUZ.js → connection-D5S9Iph-.js} +2 -2
- package/src/{connection-BPf4BQUZ.js.map → connection-D5S9Iph-.js.map} +1 -1
- package/src/{dev-lifecycle-vQLxwCFq.js → dev-lifecycle-D3f9-upa.js} +129 -42
- package/src/dev-lifecycle-D3f9-upa.js.map +1 -0
- package/src/{installation-DsGst1BH.js → installation-fZtNxtoW.js} +68 -41
- package/src/installation-fZtNxtoW.js.map +1 -0
- package/src/internal/authoring-catalog.js +2 -2
- package/src/internal/authoring-metadata.js +1 -1
- package/src/internal/configuration.js +149 -50
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/dev-lifecycle.js +2 -2
- package/src/internal/diagnostics.js +47 -0
- package/src/internal/diagnostics.js.map +1 -0
- package/src/internal/document-model.js +2 -2
- package/src/internal/form-capabilities.js +1 -1
- package/src/internal/i18n.js +6 -1
- package/src/internal/i18n.js.map +1 -1
- package/src/internal/studio-app.js +8 -6
- package/src/internal/studio-app.js.map +1 -1
- package/src/{location-BgYhXEZp.js → location-CPX7oj0o.js} +2 -2
- package/src/{location-BgYhXEZp.js.map → location-CPX7oj0o.js.map} +1 -1
- package/src/{models-k2nXyD6q.js → models-C9kF9JlQ.js} +2 -2
- package/src/{models-k2nXyD6q.js.map → models-C9kF9JlQ.js.map} +1 -1
- package/src/{models-DgkGTFus.js → models-ChRxBChy.js} +4 -2
- package/src/{models-DgkGTFus.js.map → models-ChRxBChy.js.map} +1 -1
- package/src/runtime/delivery/context.js +1 -1
- package/src/runtime/delivery/plugin.js +3 -2
- package/src/runtime/delivery/plugin.js.map +1 -1
- package/src/runtime/forms/document.js +1 -1
- package/src/runtime/forms/useCmsForm.js +73 -46
- package/src/runtime/forms/useCmsForm.js.map +1 -1
- package/src/runtime/i18n/useCmsI18n.d.ts +1 -1
- package/src/runtime/i18n/useCmsI18n.js.map +1 -1
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +12 -4
- package/src/runtime/plugin.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +2 -2
- package/src/runtime/preview/plugin.client.js +3 -3
- package/src/runtime/preview/plugin.client.js.map +1 -1
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/sitemap.js +1 -1
- package/src/{store-BYgSt7E3.js → store-CCsjHaZm.js} +8 -8
- package/src/store-CCsjHaZm.js.map +1 -0
- package/studio/{CreateDocumentDialog-BdiM77bb.js → CreateDocumentDialog-DJ8c0WZb.js} +3 -3
- package/studio/{documentPlanning-B7fyUj9r.js → documentPlanning-CDb31mnl.js} +6417 -6358
- package/studio/host.css +1 -1
- package/studio/host.js +7612 -7249
- package/src/Forms-02-p8qEw.js.map +0 -1
- package/src/Forms-CfcI3tPU.js.map +0 -1
- package/src/S3MediaObjects-DC0c8sYC.js.map +0 -1
- package/src/dev-lifecycle-vQLxwCFq.js.map +0 -1
- package/src/installation-DsGst1BH.js.map +0 -1
- package/src/store-BYgSt7E3.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as formAuthoring } from "../Forms-
|
|
2
|
-
import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-
|
|
1
|
+
import { n as formAuthoring } from "../Forms-DoB56hfe.js";
|
|
2
|
+
import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-BU-UyGoH.js";
|
|
3
3
|
import { resolveBlockAuthoring } from "./authoring-metadata.js";
|
|
4
4
|
import { Crypto, Effect, Encoding, FileSystem, Path, Schema } from "effect";
|
|
5
5
|
import { addTemplate, addVitePlugin, updateTemplates } from "@nuxt/kit";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-
|
|
1
|
+
import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-BU-UyGoH.js";
|
|
2
2
|
import { compileCmsBlock, readAuthoringDefault } from "./authoring-compiler.js";
|
|
3
3
|
import { Effect, Result, Schema } from "effect";
|
|
4
4
|
import ts from "typescript";
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { R as SeoConfiguration } from "../models-
|
|
2
|
-
import { j as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-
|
|
1
|
+
import { R as SeoConfiguration } from "../models-ChRxBChy.js";
|
|
2
|
+
import { j as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-CR3p1WTg.js";
|
|
3
3
|
import { validateFormCapabilities } from "./form-capabilities.js";
|
|
4
4
|
import { compileCmsI18n } from "./i18n.js";
|
|
5
|
-
import { i as PreviewOrigin } from "../models-
|
|
5
|
+
import { i as PreviewOrigin } from "../models-C9kF9JlQ.js";
|
|
6
6
|
import { compileCmsDocumentModel } from "./document-model.js";
|
|
7
|
-
import { Predicate, Result, Schema } from "effect";
|
|
7
|
+
import { Config, Effect, Predicate, Redacted, Result, Schema } from "effect";
|
|
8
8
|
|
|
9
9
|
//#region src/internal/configuration.ts
|
|
10
10
|
const DEFAULT_CLEANUP_INTERVAL_MILLIS = 864e5;
|
|
11
11
|
const DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 6e4;
|
|
12
12
|
const DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 1e7;
|
|
13
|
-
const
|
|
14
|
-
const InstallationConfiguration = Schema.Struct({
|
|
15
|
-
baseUrl: PreviewOrigin,
|
|
13
|
+
const AuthoredInstallationConfiguration = Schema.Struct({
|
|
16
14
|
cleanup: Schema.optionalKey(Schema.Union([Schema.Literals([false]), Schema.Struct({
|
|
17
15
|
initialDelayMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
18
16
|
intervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0)))
|
|
19
17
|
})])),
|
|
20
|
-
database: Schema.Struct({
|
|
21
|
-
schema: Schema.NonEmptyString.check(Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), { expected: "a lowercase PostgreSQL identifier" })),
|
|
22
|
-
url: Schema.NonEmptyString
|
|
23
|
-
}),
|
|
24
|
-
initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),
|
|
18
|
+
database: Schema.Struct({ schema: Schema.NonEmptyString.check(Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), { expected: "a lowercase PostgreSQL identifier" })) }),
|
|
25
19
|
media: Schema.optionalKey(Schema.Union([Schema.Literals([false]), Schema.Struct({
|
|
26
20
|
maxUploadBytes: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
27
21
|
minimum: 1,
|
|
28
22
|
maximum: maxS3SingleCopyBytes
|
|
29
23
|
}))),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})),
|
|
38
|
-
endpoint: optionalString,
|
|
39
|
-
forcePathStyle: Schema.optionalKey(Schema.Boolean),
|
|
40
|
-
provisionBucket: Schema.optionalKey(Schema.Boolean),
|
|
41
|
-
prefix: Schema.NonEmptyString.check(Schema.makeFilter((value) => !value.startsWith("/") && value.endsWith("/") && !value.includes(".."), { expected: "a relative object prefix ending in /" })),
|
|
42
|
-
region: Schema.NonEmptyString
|
|
43
|
-
})
|
|
44
|
-
})])),
|
|
45
|
-
seo: Schema.optionalKey(SeoConfiguration),
|
|
24
|
+
prefix: Schema.NonEmptyString.check(Schema.makeFilter((value) => !value.startsWith("/") && value.endsWith("/") && !value.includes(".."), { expected: "a relative object prefix ending in /" }))
|
|
25
|
+
})]))
|
|
26
|
+
});
|
|
27
|
+
const RuntimeConfiguration = Schema.Struct({
|
|
28
|
+
baseUrl: PreviewOrigin,
|
|
29
|
+
databaseUrl: Schema.NonEmptyString,
|
|
30
|
+
initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),
|
|
46
31
|
secret: Schema.NonEmptyString.check(Schema.isMinLength(32))
|
|
47
32
|
});
|
|
33
|
+
const RuntimeMediaConfiguration = Schema.Struct({
|
|
34
|
+
accessKeyId: Schema.optionalKey(Schema.NonEmptyString),
|
|
35
|
+
bucket: Schema.NonEmptyString,
|
|
36
|
+
endpoint: Schema.optionalKey(Schema.NonEmptyString),
|
|
37
|
+
forcePathStyle: Schema.optionalKey(Schema.Boolean),
|
|
38
|
+
provisionBucket: Schema.optionalKey(Schema.Boolean),
|
|
39
|
+
publicBaseUrl: Schema.NonEmptyString,
|
|
40
|
+
region: Schema.NonEmptyString,
|
|
41
|
+
secretAccessKey: Schema.optionalKey(Schema.NonEmptyString),
|
|
42
|
+
sessionToken: Schema.optionalKey(Schema.NonEmptyString)
|
|
43
|
+
});
|
|
44
|
+
var CmsRuntimeConfigurationMissing = class extends Schema.TaggedError()("CmsRuntimeConfigurationMissing", {
|
|
45
|
+
environmentVariable: Schema.String,
|
|
46
|
+
message: Schema.String,
|
|
47
|
+
path: Schema.String
|
|
48
|
+
}) {};
|
|
48
49
|
function compileCmsConfiguration(configuration) {
|
|
49
|
-
const
|
|
50
|
-
if (Result.isFailure(decodedConfiguration)) throw new Error(`Invalid CMS configuration: ${String(decodedConfiguration.failure)}`);
|
|
50
|
+
const installation = decodeOrThrow(AuthoredInstallationConfiguration, configuration.installation, "authored installation");
|
|
51
51
|
for (const [name, form] of Object.entries(configuration.forms ?? {})) {
|
|
52
52
|
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(name)) throw new Error(`Form ${name} needs a kebab-case Vue component name.`);
|
|
53
53
|
validateFormCapabilities(form.definition);
|
|
@@ -55,51 +55,150 @@ function compileCmsConfiguration(configuration) {
|
|
|
55
55
|
}
|
|
56
56
|
const i18n = compileCmsI18n(configuration.i18n);
|
|
57
57
|
const documents = compileCmsDocumentModel(configuration.documents, configuration.i18n);
|
|
58
|
+
const seo = configuration.seo === void 0 ? void 0 : decodeOrThrow(SeoConfiguration, configuration.seo, "SEO");
|
|
58
59
|
return {
|
|
59
60
|
i18n,
|
|
60
61
|
documentModel: documents.executable,
|
|
61
62
|
documents: documents.authoring,
|
|
62
|
-
installation
|
|
63
|
+
installation,
|
|
64
|
+
...seo === void 0 ? void 0 : { seo }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Adds the keys Nitro needs in order to apply NUXT_CMS_* runtime environment overrides. */
|
|
68
|
+
function cmsRuntimeConfigurationDefaults(authored, input) {
|
|
69
|
+
const configured = Predicate.isObject(input) ? input : {};
|
|
70
|
+
const mediaEnabled = authored.installation.media !== false && authored.installation.media !== void 0;
|
|
71
|
+
const configuredMedia = Predicate.isObject(configured.media) ? configured.media : void 0;
|
|
72
|
+
const string = (value) => Schema.is(Schema.String)(value) ? value : "";
|
|
73
|
+
const boolean = (value) => Schema.is(Schema.Boolean)(value) ? value : false;
|
|
74
|
+
return {
|
|
75
|
+
baseUrl: string(configured.baseUrl),
|
|
76
|
+
databaseUrl: string(configured.databaseUrl),
|
|
77
|
+
initializationToken: string(configured.initializationToken),
|
|
78
|
+
media: mediaEnabled ? configured.media === false ? false : {
|
|
79
|
+
accessKeyId: string(configuredMedia?.accessKeyId),
|
|
80
|
+
bucket: string(configuredMedia?.bucket),
|
|
81
|
+
endpoint: string(configuredMedia?.endpoint),
|
|
82
|
+
forcePathStyle: boolean(configuredMedia?.forcePathStyle),
|
|
83
|
+
provisionBucket: boolean(configuredMedia?.provisionBucket),
|
|
84
|
+
publicBaseUrl: string(configuredMedia?.publicBaseUrl),
|
|
85
|
+
region: string(configuredMedia?.region),
|
|
86
|
+
secretAccessKey: string(configuredMedia?.secretAccessKey),
|
|
87
|
+
sessionToken: string(configuredMedia?.sessionToken)
|
|
88
|
+
} : false,
|
|
89
|
+
secret: string(configured.secret)
|
|
63
90
|
};
|
|
64
91
|
}
|
|
65
|
-
|
|
92
|
+
/** Reads the same NUXT_CMS_* values that Nitro applies to runtimeConfig at process startup. */
|
|
93
|
+
const cmsRuntimeConfigurationFromEnvironment = Effect.fn("CmsConfiguration.runtimeFromEnvironment")(function* (defaults) {
|
|
94
|
+
const string = (name, fallback) => Config.String(name).pipe(Config.withDefault(fallback));
|
|
95
|
+
const secret = (name, fallback) => Config.Redacted(name).pipe(Config.withDefault(Redacted.make(fallback)), Effect.map(Redacted.value));
|
|
96
|
+
return {
|
|
97
|
+
baseUrl: yield* string("NUXT_CMS_BASE_URL", defaults.baseUrl),
|
|
98
|
+
databaseUrl: yield* string("NUXT_CMS_DATABASE_URL", defaults.databaseUrl),
|
|
99
|
+
initializationToken: yield* secret("NUXT_CMS_INITIALIZATION_TOKEN", defaults.initializationToken),
|
|
100
|
+
media: defaults.media === false || defaults.media === void 0 ? false : {
|
|
101
|
+
accessKeyId: yield* string("NUXT_CMS_MEDIA_ACCESS_KEY_ID", defaults.media.accessKeyId ?? ""),
|
|
102
|
+
bucket: yield* string("NUXT_CMS_MEDIA_BUCKET", defaults.media.bucket),
|
|
103
|
+
endpoint: yield* string("NUXT_CMS_MEDIA_ENDPOINT", defaults.media.endpoint ?? ""),
|
|
104
|
+
forcePathStyle: yield* Config.Boolean("NUXT_CMS_MEDIA_FORCE_PATH_STYLE").pipe(Config.withDefault(defaults.media.forcePathStyle ?? false)),
|
|
105
|
+
provisionBucket: yield* Config.Boolean("NUXT_CMS_MEDIA_PROVISION_BUCKET").pipe(Config.withDefault(defaults.media.provisionBucket ?? false)),
|
|
106
|
+
publicBaseUrl: yield* string("NUXT_CMS_MEDIA_PUBLIC_BASE_URL", defaults.media.publicBaseUrl),
|
|
107
|
+
region: yield* string("NUXT_CMS_MEDIA_REGION", defaults.media.region),
|
|
108
|
+
secretAccessKey: yield* secret("NUXT_CMS_MEDIA_SECRET_ACCESS_KEY", defaults.media.secretAccessKey ?? ""),
|
|
109
|
+
sessionToken: yield* secret("NUXT_CMS_MEDIA_SESSION_TOKEN", defaults.media.sessionToken ?? "")
|
|
110
|
+
},
|
|
111
|
+
secret: yield* secret("NUXT_CMS_SECRET", defaults.secret)
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
function resolveCmsInstallation(authored, runtimeInput, authoring) {
|
|
66
115
|
const compiled = compileCmsConfiguration(authored);
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
116
|
+
const runtimeObject = Predicate.isObject(runtimeInput) ? runtimeInput : {};
|
|
117
|
+
requireRuntimeValue(runtimeObject.baseUrl, "cms.baseUrl", "NUXT_CMS_BASE_URL");
|
|
118
|
+
requireRuntimeValue(runtimeObject.databaseUrl, "cms.databaseUrl", "NUXT_CMS_DATABASE_URL");
|
|
119
|
+
requireRuntimeValue(runtimeObject.initializationToken, "cms.initializationToken", "NUXT_CMS_INITIALIZATION_TOKEN");
|
|
120
|
+
requireRuntimeValue(runtimeObject.secret, "cms.secret", "NUXT_CMS_SECRET");
|
|
121
|
+
const runtimeResult = Schema.decodeUnknownResult(RuntimeConfiguration)(runtimeInput);
|
|
122
|
+
if (Result.isFailure(runtimeResult)) throw new Error(`Invalid CMS runtime installation configuration: ${String(runtimeResult.failure)}`);
|
|
123
|
+
const runtime = runtimeResult.success;
|
|
124
|
+
const cleanup = compiled.installation.cleanup === false ? void 0 : compiled.installation.cleanup;
|
|
125
|
+
const authoredMedia = compiled.installation.media === false ? void 0 : compiled.installation.media;
|
|
126
|
+
const runtimeMedia = authoredMedia ? decodeRuntimeMedia(runtimeObject.media) : void 0;
|
|
70
127
|
const bootstrap = Result.getOrThrow(Schema.decodeResult(StudioBootstrap)({
|
|
71
128
|
basePath: "/",
|
|
72
129
|
documents: compiled.documents,
|
|
73
130
|
media: {
|
|
74
|
-
enabled:
|
|
75
|
-
maxUploadBytes:
|
|
131
|
+
enabled: runtimeMedia !== void 0,
|
|
132
|
+
maxUploadBytes: authoredMedia?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES
|
|
76
133
|
},
|
|
77
|
-
seo:
|
|
134
|
+
seo: compiled.seo ?? makeDefaultSeoOptions(runtime.baseUrl),
|
|
78
135
|
version: "1"
|
|
79
136
|
}));
|
|
80
137
|
return {
|
|
81
138
|
formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),
|
|
82
139
|
authoring,
|
|
83
|
-
baseUrl:
|
|
140
|
+
baseUrl: runtime.baseUrl,
|
|
84
141
|
bootstrap,
|
|
85
142
|
cleanup: {
|
|
86
|
-
enabled:
|
|
143
|
+
enabled: compiled.installation.cleanup !== false,
|
|
87
144
|
initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,
|
|
88
145
|
intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS
|
|
89
146
|
},
|
|
90
|
-
database:
|
|
147
|
+
database: {
|
|
148
|
+
schema: compiled.installation.database.schema,
|
|
149
|
+
url: runtime.databaseUrl
|
|
150
|
+
},
|
|
91
151
|
documentModel: compiled.documentModel,
|
|
92
|
-
initializationToken:
|
|
93
|
-
...
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
152
|
+
initializationToken: runtime.initializationToken,
|
|
153
|
+
...runtimeMedia && authoredMedia ? { media: {
|
|
154
|
+
...runtimeMedia,
|
|
155
|
+
credentials: runtimeMedia.accessKeyId && runtimeMedia.secretAccessKey ? {
|
|
156
|
+
accessKeyId: runtimeMedia.accessKeyId,
|
|
157
|
+
secretAccessKey: runtimeMedia.secretAccessKey,
|
|
158
|
+
...runtimeMedia.sessionToken ? { sessionToken: runtimeMedia.sessionToken } : void 0
|
|
159
|
+
} : void 0,
|
|
160
|
+
forcePathStyle: runtimeMedia.forcePathStyle ?? false,
|
|
161
|
+
prefix: authoredMedia.prefix,
|
|
162
|
+
provisionBucket: runtimeMedia.provisionBucket ?? false,
|
|
163
|
+
publicBaseUrl: `${runtimeMedia.publicBaseUrl.replace(/\/+$/gu, "")}/${authoredMedia.prefix.replace(/\/+$/gu, "")}`
|
|
164
|
+
} } : void 0,
|
|
165
|
+
secret: runtime.secret
|
|
100
166
|
};
|
|
101
167
|
}
|
|
168
|
+
function decodeRuntimeMedia(input) {
|
|
169
|
+
const raw = Predicate.isObject(input) ? input : {};
|
|
170
|
+
requireRuntimeValue(raw.bucket, "cms.media.bucket", "NUXT_CMS_MEDIA_BUCKET");
|
|
171
|
+
requireRuntimeValue(raw.publicBaseUrl, "cms.media.publicBaseUrl", "NUXT_CMS_MEDIA_PUBLIC_BASE_URL");
|
|
172
|
+
requireRuntimeValue(raw.region, "cms.media.region", "NUXT_CMS_MEDIA_REGION");
|
|
173
|
+
const optionalString = (value) => Schema.is(Schema.NonEmptyString)(value) ? value : void 0;
|
|
174
|
+
const accessKeyId = optionalString(raw.accessKeyId);
|
|
175
|
+
const endpoint = optionalString(raw.endpoint);
|
|
176
|
+
const secretAccessKey = optionalString(raw.secretAccessKey);
|
|
177
|
+
const sessionToken = optionalString(raw.sessionToken);
|
|
178
|
+
const normalized = Object.assign({
|
|
179
|
+
bucket: raw.bucket,
|
|
180
|
+
publicBaseUrl: raw.publicBaseUrl,
|
|
181
|
+
region: raw.region
|
|
182
|
+
}, accessKeyId ? { accessKeyId } : void 0, endpoint ? { endpoint } : void 0, Schema.is(Schema.Boolean)(raw.forcePathStyle) ? { forcePathStyle: raw.forcePathStyle } : void 0, Schema.is(Schema.Boolean)(raw.provisionBucket) ? { provisionBucket: raw.provisionBucket } : void 0, secretAccessKey ? { secretAccessKey } : void 0, sessionToken ? { sessionToken } : void 0);
|
|
183
|
+
const result = Schema.decodeUnknownResult(RuntimeMediaConfiguration)(normalized);
|
|
184
|
+
if (Result.isFailure(result)) throw new Error(`Invalid CMS runtime media configuration: ${String(result.failure)}`);
|
|
185
|
+
const decoded = result.success;
|
|
186
|
+
if (decoded.accessKeyId === void 0 !== (decoded.secretAccessKey === void 0)) throw new Error("Invalid CMS runtime media configuration: accessKeyId and secretAccessKey must be provided together.");
|
|
187
|
+
return decoded;
|
|
188
|
+
}
|
|
189
|
+
function requireRuntimeValue(value, path, environmentVariable) {
|
|
190
|
+
if (!Schema.is(Schema.NonEmptyString)(value)) throw new CmsRuntimeConfigurationMissing({
|
|
191
|
+
environmentVariable,
|
|
192
|
+
message: `Missing ${environmentVariable} for ${path}.`,
|
|
193
|
+
path
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function decodeOrThrow(schema, input, label) {
|
|
197
|
+
const decoded = Schema.decodeUnknownResult(schema)(input);
|
|
198
|
+
if (Result.isFailure(decoded)) throw new Error(`Invalid CMS ${label} configuration: ${String(decoded.failure)}`);
|
|
199
|
+
return decoded.success;
|
|
200
|
+
}
|
|
102
201
|
|
|
103
202
|
//#endregion
|
|
104
|
-
export { compileCmsConfiguration, resolveCmsInstallation };
|
|
203
|
+
export { cmsRuntimeConfigurationDefaults, cmsRuntimeConfigurationFromEnvironment, compileCmsConfiguration, resolveCmsInstallation };
|
|
105
204
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","names":["PreviewOriginSchema"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import { compileCmsI18n, type CompiledCmsI18n } from './i18n'\nimport type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { AuthoringCatalog, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { CmsConfiguration } from '../Configuration'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { SeoConfiguration } from '@internal/protocol/Seo'\nimport { makeDefaultSeoOptions } from '@internal/server/Seo'\nimport { maxS3SingleCopyBytes } from '@internal/s3/S3MediaObjects'\nimport { Predicate, Result, Schema } from 'effect'\nimport { compileCmsDocumentModel } from './document-model'\nimport { validateFormCapabilities } from './form-capabilities'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\n\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\n\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst optionalString = Schema.optionalKey(Schema.NonEmptyString)\n\nconst InstallationConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\n cleanup: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n initialDelayMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n intervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n }),\n ]),\n ),\n database: Schema.Struct({\n schema: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), {\n expected: 'a lowercase PostgreSQL identifier',\n }),\n ),\n url: Schema.NonEmptyString,\n }),\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: maxS3SingleCopyBytes })),\n ),\n publicBaseUrl: Schema.NonEmptyString,\n storage: Schema.Struct({\n bucket: Schema.NonEmptyString,\n credentials: Schema.optionalKey(\n Schema.Struct({\n accessKeyId: Schema.NonEmptyString,\n secretAccessKey: Schema.NonEmptyString,\n sessionToken: optionalString,\n }),\n ),\n endpoint: optionalString,\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n prefix: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => !value.startsWith('/') && value.endsWith('/') && !value.includes('..'), {\n expected: 'a relative object prefix ending in /',\n }),\n ),\n region: Schema.NonEmptyString,\n }),\n }),\n ]),\n ),\n seo: Schema.optionalKey(SeoConfiguration),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\n\ntype CmsInstallationConfiguration = Schema.Schema.Type<typeof InstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly i18n: CompiledCmsI18n\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly installation: CmsInstallationConfiguration\n}\n\nexport function compileCmsConfiguration(configuration: CmsConfiguration): CompiledCmsConfiguration {\n const decodedConfiguration = Schema.decodeResult(InstallationConfiguration)(configuration)\n\n if (Result.isFailure(decodedConfiguration)) {\n throw new Error(`Invalid CMS configuration: ${String(decodedConfiguration.failure)}`)\n }\n\n for (const [name, form] of Object.entries(configuration.forms ?? {})) {\n if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(name))\n throw new Error(`Form ${name} needs a kebab-case Vue component name.`)\n validateFormCapabilities(form.definition)\n\n if (!Predicate.isFunction(form.onSubmit)) throw new Error(`Form ${name} needs a server submission handler.`)\n }\n\n const i18n = compileCmsI18n(configuration.i18n)\n const documents = compileCmsDocumentModel(configuration.documents, configuration.i18n)\n\n return {\n i18n,\n documentModel: documents.executable,\n documents: documents.authoring,\n installation: decodedConfiguration.success,\n }\n}\n\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n authoring: AuthoringCatalog,\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored)\n const configuration = compiled.installation\n const cleanup = configuration.cleanup === false ? undefined : configuration.cleanup\n const media = configuration.media === false ? undefined : configuration.media\n\n const bootstrap = Result.getOrThrow(\n Schema.decodeResult(StudioBootstrap)({\n basePath: '/',\n documents: compiled.documents,\n media: {\n enabled: media !== undefined,\n maxUploadBytes: media?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n seo: configuration.seo ?? makeDefaultSeoOptions(configuration.baseUrl),\n version: '1',\n }),\n )\n\n return {\n formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),\n authoring,\n baseUrl: configuration.baseUrl,\n bootstrap,\n cleanup: {\n enabled: configuration.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n database: configuration.database,\n documentModel: compiled.documentModel,\n initializationToken: configuration.initializationToken,\n ...(media === undefined\n ? undefined\n : {\n media: {\n publicBaseUrl: `${media.publicBaseUrl.replace(/\\/+$/gu, '')}/${media.storage.prefix.replace(/\\/+$/gu, '')}`,\n ...media.storage,\n forcePathStyle: media.storage.forcePathStyle ?? false,\n provisionBucket: media.storage.provisionBucket ?? false,\n },\n }),\n secret: configuration.secret,\n }\n}\n"],"mappings":";;;;;;;;;AAcA,MAAM,kCAAkC;AAExC,MAAM,uCAAuC;AAE7C,MAAM,iCAAiC;AAEvC,MAAM,iBAAiB,OAAO,YAAY,OAAO,cAAc;AAE/D,MAAM,4BAA4B,OAAO,OAAO;CAC9C,SAASA;CACT,SAAS,OAAO,YACd,OAAO,MAAM,CACX,OAAO,SAAS,CAAC,KAAK,CAAC,GACvB,OAAO,OAAO;EACZ,oBAAoB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC,CAAC;EACzF,gBAAgB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC,CAAC;CAC9E,CAAC,CACH,CAAC,CACH;CACA,UAAU,OAAO,OAAO;EACtB,QAAQ,OAAO,eAAe,MAC5B,OAAO,YAAY,UAAU,2BAA2B,KAAK,KAAK,GAAG,EACnE,UAAU,oCACZ,CAAC,CACH;EACA,KAAK,OAAO;CACd,CAAC;CACD,qBAAqB,OAAO,eAAe,MAAM,OAAO,YAAY,EAAE,CAAC;CACvE,OAAO,OAAO,YACZ,OAAO,MAAM,CACX,OAAO,SAAS,CAAC,KAAK,CAAC,GACvB,OAAO,OAAO;EACZ,gBA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AO;EACL;EACA,eAAe,UAAU;EACzB,WAAW,UAAU;EACrB,cAAc,qBAAqB;CACrC;AACF;AAEA,SAAgB,uBACd,UACA,WAC4B;CAC5B,MAAM,WAAW,wBAAwB,QAAQ;CACjD,MAAM,gBAAgB,SAAS;CAC/B,MAAM,UAAU,cAAc,YAAY,QAAQ,SAAY,cAAc;CAC5E,MAAM,QAAQ,cAAc,UAAU,QAAQ,SAAY,cAAc;CAExE,MAAM,YAAY,OAAO,WACvB,OAAO,aAAa,eAAe,CAAC,CAAC;EACnC,UAAU;EACV,WAAW,SAAS;EACpB,OAAO;GACL,SAAS,UAAU;GACnB,gBAAgB,OAAO,kBAAkB;EAC3C;EACA,KAAK,cAAc,OAAO,sBAAsB,cAAc,OAAO;EACrE,SAAS;CACX,CAAC,CACH;CAEA,OAAO;EACL,cAAc,OAAO,YAAY,OAAO,QAAQ,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;EAClH;EACA,SAAS,cAAc;EACvB;EACA,SAAS;GACP,SAAS,cAAc,YAAY;GACnC,oBAAoB,SAAS,sBAAsB;GACnD,gBAAgB,SAAS,kBAAkB;EAC7C;EACA,UAAU,cAAc;EACxB,eAAe,SAAS;EACxB,qBAAqB,cAAc;EACnC,GAAI,UAAU,SACV,SACA,EACE,OAAO;GACL,eAAe,GAAG,MAAM,cAAc,QAAQ,UAAU,EAAE,EAAE,GAAG,MAAM,QAAQ,OAAO,QAAQ,UAAU,EAAE;GACxG,GAAG,MAAM;GACT,gBAAgB,MAAM,QAAQ,kBAAkB;GAChD,iBAAiB,MAAM,QAAQ,mBAAmB;EACpD,EACF;EACJ,QAAQ,cAAc;CACxB;AACF"}
|
|
1
|
+
{"version":3,"file":"configuration.js","names":["PreviewOriginSchema"],"sources":["../../../../src/internal/configuration.ts"],"sourcesContent":["import { compileCmsI18n, type CompiledCmsI18n } from './i18n'\nimport type { ExecutableDocumentModel } from '@internal/document/DocumentEngine'\nimport type { AuthoringCatalog, DocumentConfiguration } from '@internal/protocol/Configuration'\nimport type { CmsConfiguration, CmsRuntimeConfiguration } from '../Configuration'\nimport type { NuxtCmsInstallationOptions } from '../runtime/installation'\nimport { PreviewOrigin as PreviewOriginSchema } from '@internal/protocol/Preview'\nimport { StudioBootstrap } from '@internal/protocol/StudioHttp'\nimport { SeoConfiguration } from '@internal/protocol/Seo'\nimport { makeDefaultSeoOptions } from '@internal/server/Seo'\nimport { maxS3SingleCopyBytes } from '@internal/s3/S3MediaObjects'\nimport { Config, Effect, Predicate, Redacted, Result, Schema } from 'effect'\nimport { compileCmsDocumentModel } from './document-model'\nimport { validateFormCapabilities } from './form-capabilities'\n\nconst DEFAULT_CLEANUP_INTERVAL_MILLIS = 24 * 60 * 60_000\n\nconst DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS = 60_000\n\nconst DEFAULT_MEDIA_MAX_UPLOAD_BYTES = 10_000_000\n\nconst AuthoredInstallationConfiguration = Schema.Struct({\n cleanup: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n initialDelayMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n intervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n }),\n ]),\n ),\n database: Schema.Struct({\n schema: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => /^[a-z_][a-z0-9_]{0,62}$/u.test(value), {\n expected: 'a lowercase PostgreSQL identifier',\n }),\n ),\n }),\n media: Schema.optionalKey(\n Schema.Union([\n Schema.Literals([false]),\n Schema.Struct({\n maxUploadBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: maxS3SingleCopyBytes })),\n ),\n prefix: Schema.NonEmptyString.check(\n Schema.makeFilter((value) => !value.startsWith('/') && value.endsWith('/') && !value.includes('..'), {\n expected: 'a relative object prefix ending in /',\n }),\n ),\n }),\n ]),\n ),\n})\n\nconst RuntimeConfiguration = Schema.Struct({\n baseUrl: PreviewOriginSchema,\n databaseUrl: Schema.NonEmptyString,\n initializationToken: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n secret: Schema.NonEmptyString.check(Schema.isMinLength(32)),\n})\n\nconst RuntimeMediaConfiguration = Schema.Struct({\n accessKeyId: Schema.optionalKey(Schema.NonEmptyString),\n bucket: Schema.NonEmptyString,\n endpoint: Schema.optionalKey(Schema.NonEmptyString),\n forcePathStyle: Schema.optionalKey(Schema.Boolean),\n provisionBucket: Schema.optionalKey(Schema.Boolean),\n publicBaseUrl: Schema.NonEmptyString,\n region: Schema.NonEmptyString,\n secretAccessKey: Schema.optionalKey(Schema.NonEmptyString),\n sessionToken: Schema.optionalKey(Schema.NonEmptyString),\n})\n\nclass CmsRuntimeConfigurationMissing extends Schema.TaggedError<CmsRuntimeConfigurationMissing>()(\n 'CmsRuntimeConfigurationMissing',\n {\n environmentVariable: Schema.String,\n message: Schema.String,\n path: Schema.String,\n },\n) {}\n\ntype CmsAuthoredInstallationConfiguration = Schema.Schema.Type<typeof AuthoredInstallationConfiguration>\n\nexport interface CompiledCmsConfiguration {\n readonly i18n: CompiledCmsI18n\n readonly documents: DocumentConfiguration\n readonly documentModel: ExecutableDocumentModel\n readonly installation: CmsAuthoredInstallationConfiguration\n readonly seo?: Schema.Schema.Type<typeof SeoConfiguration>\n}\n\nexport function compileCmsConfiguration(configuration: CmsConfiguration): CompiledCmsConfiguration {\n const installation = decodeOrThrow(\n AuthoredInstallationConfiguration,\n configuration.installation,\n 'authored installation',\n )\n\n for (const [name, form] of Object.entries(configuration.forms ?? {})) {\n if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(name))\n throw new Error(`Form ${name} needs a kebab-case Vue component name.`)\n validateFormCapabilities(form.definition)\n\n if (!Predicate.isFunction(form.onSubmit)) throw new Error(`Form ${name} needs a server submission handler.`)\n }\n\n const i18n = compileCmsI18n(configuration.i18n)\n const documents = compileCmsDocumentModel(configuration.documents, configuration.i18n)\n const seo = configuration.seo === undefined ? undefined : decodeOrThrow(SeoConfiguration, configuration.seo, 'SEO')\n\n return {\n i18n,\n documentModel: documents.executable,\n documents: documents.authoring,\n installation,\n ...(seo === undefined ? undefined : { seo }),\n }\n}\n\n/** Adds the keys Nitro needs in order to apply NUXT_CMS_* runtime environment overrides. */\nexport function cmsRuntimeConfigurationDefaults(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Nuxt runtime config is an external input parsed field by field here.\n input?: unknown,\n): CmsRuntimeConfiguration {\n const configured = Predicate.isObject(input) ? input : {}\n const mediaEnabled = authored.installation.media !== false && authored.installation.media !== undefined\n const configuredMedia = Predicate.isObject(configured.media) ? configured.media : undefined\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const string = (value: unknown) => (Schema.is(Schema.String)(value) ? value : '')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const boolean = (value: unknown) => (Schema.is(Schema.Boolean)(value) ? value : false)\n\n return {\n baseUrl: string(configured.baseUrl),\n databaseUrl: string(configured.databaseUrl),\n initializationToken: string(configured.initializationToken),\n media: mediaEnabled\n ? configured.media === false\n ? false\n : {\n accessKeyId: string(configuredMedia?.accessKeyId),\n bucket: string(configuredMedia?.bucket),\n endpoint: string(configuredMedia?.endpoint),\n forcePathStyle: boolean(configuredMedia?.forcePathStyle),\n provisionBucket: boolean(configuredMedia?.provisionBucket),\n publicBaseUrl: string(configuredMedia?.publicBaseUrl),\n region: string(configuredMedia?.region),\n secretAccessKey: string(configuredMedia?.secretAccessKey),\n sessionToken: string(configuredMedia?.sessionToken),\n }\n : false,\n secret: string(configured.secret),\n }\n}\n\n/** Reads the same NUXT_CMS_* values that Nitro applies to runtimeConfig at process startup. */\nexport const cmsRuntimeConfigurationFromEnvironment = Effect.fn('CmsConfiguration.runtimeFromEnvironment')(function* (\n defaults: CmsRuntimeConfiguration,\n) {\n const string = (name: string, fallback: string) => Config.String(name).pipe(Config.withDefault(fallback))\n\n const secret = (name: string, fallback: string) =>\n Config.Redacted(name).pipe(Config.withDefault(Redacted.make(fallback)), Effect.map(Redacted.value))\n\n return {\n baseUrl: yield* string('NUXT_CMS_BASE_URL', defaults.baseUrl),\n databaseUrl: yield* string('NUXT_CMS_DATABASE_URL', defaults.databaseUrl),\n initializationToken: yield* secret('NUXT_CMS_INITIALIZATION_TOKEN', defaults.initializationToken),\n media:\n defaults.media === false || defaults.media === undefined\n ? false\n : {\n accessKeyId: yield* string('NUXT_CMS_MEDIA_ACCESS_KEY_ID', defaults.media.accessKeyId ?? ''),\n bucket: yield* string('NUXT_CMS_MEDIA_BUCKET', defaults.media.bucket),\n endpoint: yield* string('NUXT_CMS_MEDIA_ENDPOINT', defaults.media.endpoint ?? ''),\n forcePathStyle: yield* Config.Boolean('NUXT_CMS_MEDIA_FORCE_PATH_STYLE').pipe(\n Config.withDefault(defaults.media.forcePathStyle ?? false),\n ),\n provisionBucket: yield* Config.Boolean('NUXT_CMS_MEDIA_PROVISION_BUCKET').pipe(\n Config.withDefault(defaults.media.provisionBucket ?? false),\n ),\n publicBaseUrl: yield* string('NUXT_CMS_MEDIA_PUBLIC_BASE_URL', defaults.media.publicBaseUrl),\n region: yield* string('NUXT_CMS_MEDIA_REGION', defaults.media.region),\n secretAccessKey: yield* secret('NUXT_CMS_MEDIA_SECRET_ACCESS_KEY', defaults.media.secretAccessKey ?? ''),\n sessionToken: yield* secret('NUXT_CMS_MEDIA_SESSION_TOKEN', defaults.media.sessionToken ?? ''),\n },\n secret: yield* secret('NUXT_CMS_SECRET', defaults.secret),\n } satisfies CmsRuntimeConfiguration\n})\n\nexport function resolveCmsInstallation(\n authored: CmsConfiguration,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Shared Nitro/CLI boundary validates this value before resource acquisition.\n runtimeInput: unknown,\n authoring: AuthoringCatalog,\n): NuxtCmsInstallationOptions {\n const compiled = compileCmsConfiguration(authored)\n const runtimeObject = Predicate.isObject(runtimeInput) ? runtimeInput : {}\n requireRuntimeValue(runtimeObject.baseUrl, 'cms.baseUrl', 'NUXT_CMS_BASE_URL')\n requireRuntimeValue(runtimeObject.databaseUrl, 'cms.databaseUrl', 'NUXT_CMS_DATABASE_URL')\n requireRuntimeValue(runtimeObject.initializationToken, 'cms.initializationToken', 'NUXT_CMS_INITIALIZATION_TOKEN')\n requireRuntimeValue(runtimeObject.secret, 'cms.secret', 'NUXT_CMS_SECRET')\n const runtimeResult = Schema.decodeUnknownResult(RuntimeConfiguration)(runtimeInput)\n\n if (Result.isFailure(runtimeResult))\n throw new Error(`Invalid CMS runtime installation configuration: ${String(runtimeResult.failure)}`)\n const runtime = runtimeResult.success\n const cleanup = compiled.installation.cleanup === false ? undefined : compiled.installation.cleanup\n const authoredMedia = compiled.installation.media === false ? undefined : compiled.installation.media\n const runtimeMedia = authoredMedia ? decodeRuntimeMedia(runtimeObject.media) : undefined\n\n const bootstrap = Result.getOrThrow(\n Schema.decodeResult(StudioBootstrap)({\n basePath: '/',\n documents: compiled.documents,\n media: {\n enabled: runtimeMedia !== undefined,\n maxUploadBytes: authoredMedia?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES,\n },\n seo: compiled.seo ?? makeDefaultSeoOptions(runtime.baseUrl),\n version: '1',\n }),\n )\n\n return {\n formHandlers: Object.fromEntries(Object.entries(authored.forms ?? {}).map(([name, form]) => [name, form.onSubmit])),\n authoring,\n baseUrl: runtime.baseUrl,\n bootstrap,\n cleanup: {\n enabled: compiled.installation.cleanup !== false,\n initialDelayMillis: cleanup?.initialDelayMillis ?? DEFAULT_CLEANUP_INITIAL_DELAY_MILLIS,\n intervalMillis: cleanup?.intervalMillis ?? DEFAULT_CLEANUP_INTERVAL_MILLIS,\n },\n database: { schema: compiled.installation.database.schema, url: runtime.databaseUrl },\n documentModel: compiled.documentModel,\n initializationToken: runtime.initializationToken,\n ...(runtimeMedia && authoredMedia\n ? {\n media: {\n ...runtimeMedia,\n credentials:\n runtimeMedia.accessKeyId && runtimeMedia.secretAccessKey\n ? {\n accessKeyId: runtimeMedia.accessKeyId,\n secretAccessKey: runtimeMedia.secretAccessKey,\n ...(runtimeMedia.sessionToken ? { sessionToken: runtimeMedia.sessionToken } : undefined),\n }\n : undefined,\n forcePathStyle: runtimeMedia.forcePathStyle ?? false,\n prefix: authoredMedia.prefix,\n provisionBucket: runtimeMedia.provisionBucket ?? false,\n publicBaseUrl: `${runtimeMedia.publicBaseUrl.replace(/\\/+$/gu, '')}/${authoredMedia.prefix.replace(/\\/+$/gu, '')}`,\n },\n }\n : undefined),\n secret: runtime.secret,\n }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Runtime media is validated before use.\nfunction decodeRuntimeMedia(input: unknown) {\n const raw = Predicate.isObject(input) ? input : {}\n requireRuntimeValue(raw.bucket, 'cms.media.bucket', 'NUXT_CMS_MEDIA_BUCKET')\n requireRuntimeValue(raw.publicBaseUrl, 'cms.media.publicBaseUrl', 'NUXT_CMS_MEDIA_PUBLIC_BASE_URL')\n requireRuntimeValue(raw.region, 'cms.media.region', 'NUXT_CMS_MEDIA_REGION')\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Each external field is narrowed immediately.\n const optionalString = (value: unknown) => (Schema.is(Schema.NonEmptyString)(value) ? value : undefined)\n const accessKeyId = optionalString(raw.accessKeyId)\n const endpoint = optionalString(raw.endpoint)\n const secretAccessKey = optionalString(raw.secretAccessKey)\n const sessionToken = optionalString(raw.sessionToken)\n\n const normalized = Object.assign(\n { bucket: raw.bucket, publicBaseUrl: raw.publicBaseUrl, region: raw.region },\n accessKeyId ? { accessKeyId } : undefined,\n endpoint ? { endpoint } : undefined,\n Schema.is(Schema.Boolean)(raw.forcePathStyle) ? { forcePathStyle: raw.forcePathStyle } : undefined,\n Schema.is(Schema.Boolean)(raw.provisionBucket) ? { provisionBucket: raw.provisionBucket } : undefined,\n secretAccessKey ? { secretAccessKey } : undefined,\n sessionToken ? { sessionToken } : undefined,\n )\n\n const result = Schema.decodeUnknownResult(RuntimeMediaConfiguration)(normalized)\n\n if (Result.isFailure(result)) throw new Error(`Invalid CMS runtime media configuration: ${String(result.failure)}`)\n const decoded = result.success\n\n if ((decoded.accessKeyId === undefined) !== (decoded.secretAccessKey === undefined))\n throw new Error(\n 'Invalid CMS runtime media configuration: accessKeyId and secretAccessKey must be provided together.',\n )\n\n return decoded\n}\n\nfunction requireRuntimeValue(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- This external field is narrowed immediately to a non-empty string.\n value: unknown,\n path: string,\n environmentVariable: string,\n): void {\n if (!Schema.is(Schema.NonEmptyString)(value))\n throw new CmsRuntimeConfigurationMissing({\n environmentVariable,\n message: `Missing ${environmentVariable} for ${path}.`,\n path,\n })\n}\n\nfunction decodeOrThrow<Decoded, Encoded>(\n schema: Schema.Codec<Decoded, Encoded>,\n input: Encoded,\n label: string,\n): Decoded {\n const decoded = Schema.decodeUnknownResult(schema)(input)\n\n if (Result.isFailure(decoded)) throw new Error(`Invalid CMS ${label} configuration: ${String(decoded.failure)}`)\n\n return decoded.success\n}\n"],"mappings":";;;;;;;;;AAcA,MAAM,kCAAkC;AAExC,MAAM,uCAAuC;AAE7C,MAAM,iCAAiC;AAEvC,MAAM,oCAAoC,OAAO,OAAO;CACtD,SAAS,OAAO,YACd,OAAO,MAAM,CACX,OAAO,SAAS,CAAC,KAAK,CAAC,GACvB,OAAO,OAAO;EACZ,oBAAoB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC,CAAC;EACzF,gBAAgB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC,CAAC;CAC9E,CAAC,CACH,CAAC,CACH;CACA,UAAU,OAAO,OAAO,EACtB,QAAQ,OAAO,eAAe,MAC5B,OAAO,YAAY,UAAU,2BAA2B,KAAK,KAAK,GAAG,EACnE,UAAU,oCACZ,CA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AAO,OAAO,CAAC,CAAC,IAAI,eAAe,IAAI,EAAE,iBAAiB,IAAI,gBAAgB,IAAI,QAC5F,kBAAkB,EAAE,gBAAgB,IAAI,QACxC,eAAe,EAAE,aAAa,IAAI,MACpC;CAEA,MAAM,SAAS,OAAO,oBAAoB,yBAAyB,CAAC,CAAC,UAAU;CAE/E,IAAI,OAAO,UAAU,MAAM,GAAG,MAAM,IAAI,MAAM,4CAA4C,OAAO,OAAO,OAAO,GAAG;CAClH,MAAM,UAAU,OAAO;CAEvB,IAAK,QAAQ,gBAAgB,YAAgB,QAAQ,oBAAoB,SACvE,MAAM,IAAI,MACR,qGACF;CAEF,OAAO;AACT;AAEA,SAAS,oBAEP,OACA,MACA,qBACM;CACN,IAAI,CAAC,OAAO,GAAG,OAAO,cAAc,CAAC,CAAC,KAAK,GACzC,MAAM,IAAI,+BAA+B;EACvC;EACA,SAAS,WAAW,oBAAoB,OAAO,KAAK;EACpD;CACF,CAAC;AACL;AAEA,SAAS,cACP,QACA,OACA,OACS;CACT,MAAM,UAAU,OAAO,oBAAoB,MAAM,CAAC,CAAC,KAAK;CAExD,IAAI,OAAO,UAAU,OAAO,GAAG,MAAM,IAAI,MAAM,eAAe,MAAM,kBAAkB,OAAO,QAAQ,OAAO,GAAG;CAE/G,OAAO,QAAQ;AACjB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as doctorCmsDevelopment, r as
|
|
1
|
+
import { i as resetCmsDevelopment, n as doctorCmsDevelopment, r as loadCmsProjectEnvironment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-D3f9-upa.js";
|
|
2
2
|
|
|
3
|
-
export { bootstrapCmsDevelopment, doctorCmsDevelopment, resetCmsDevelopment };
|
|
3
|
+
export { bootstrapCmsDevelopment, doctorCmsDevelopment, loadCmsProjectEnvironment, resetCmsDevelopment };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Predicate } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/diagnostics.ts
|
|
4
|
+
function diagnosticFromCause(phase, cause) {
|
|
5
|
+
const chain = causeChain(cause);
|
|
6
|
+
const tagged = [...chain].reverse().find((item) => item._tag)?._tag;
|
|
7
|
+
const message = [...chain].reverse().find((item) => item.message)?.message ?? String(cause);
|
|
8
|
+
const missing = message.match(/Missing (NUXT_CMS_[A-Z0-9_]+)/u)?.[1];
|
|
9
|
+
const resolvedPhase = chain.find((item) => item.phase)?.phase ?? phase;
|
|
10
|
+
return {
|
|
11
|
+
code: tagged ? kebabCase(tagged) : `${resolvedPhase.replaceAll(".", "-")}-failed`,
|
|
12
|
+
details: chain.flatMap((item) => item.stack ? [item.stack] : item.message ? [item.message] : []),
|
|
13
|
+
message,
|
|
14
|
+
phase: resolvedPhase,
|
|
15
|
+
...missing ? { remediation: `Define ${missing} in .env, pass --env-file, or provide it in the process environment.` } : void 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function renderDiagnostic(diagnostic, verbose) {
|
|
19
|
+
return [
|
|
20
|
+
`✗ ${diagnostic.phase}`,
|
|
21
|
+
"",
|
|
22
|
+
` ${diagnostic.message}`,
|
|
23
|
+
...diagnostic.remediation ? ["", ` ${diagnostic.remediation}`] : [],
|
|
24
|
+
...verbose && diagnostic.details.length ? ["", ...diagnostic.details.map((detail) => ` ${detail}`)] : []
|
|
25
|
+
].join("\n");
|
|
26
|
+
}
|
|
27
|
+
function causeChain(cause) {
|
|
28
|
+
const chain = [];
|
|
29
|
+
const visited = /* @__PURE__ */ new Set();
|
|
30
|
+
let current = cause;
|
|
31
|
+
while (isErrorLike(current) && !visited.has(current) && chain.length < 16) {
|
|
32
|
+
visited.add(current);
|
|
33
|
+
chain.push(current);
|
|
34
|
+
current = current.cause;
|
|
35
|
+
}
|
|
36
|
+
return chain;
|
|
37
|
+
}
|
|
38
|
+
function isErrorLike(value) {
|
|
39
|
+
return Predicate.isObject(value);
|
|
40
|
+
}
|
|
41
|
+
function kebabCase(value) {
|
|
42
|
+
return value.replaceAll(/([a-z0-9])([A-Z])/gu, "$1-$2").replaceAll(/[^a-zA-Z0-9]+/gu, "-").replaceAll(/^-|-$/gu, "").toLocaleLowerCase();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { diagnosticFromCause, renderDiagnostic };
|
|
47
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","names":[],"sources":["../../../../src/internal/diagnostics.ts"],"sourcesContent":["import { Predicate } from 'effect'\n\nexport interface CmsDiagnostic {\n readonly code: string\n readonly details: ReadonlyArray<string>\n readonly message: string\n readonly phase: string\n readonly remediation?: string\n}\n\ninterface ErrorLike {\n readonly _tag?: string\n readonly cause?: unknown\n readonly message?: string\n readonly phase?: string\n readonly stack?: string\n}\n\nexport function diagnosticFromCause(phase: string, cause: unknown): CmsDiagnostic {\n const chain = causeChain(cause)\n const tagged = [...chain].reverse().find((item) => item._tag)?._tag\n const message = [...chain].reverse().find((item) => item.message)?.message ?? String(cause)\n const missing = message.match(/Missing (NUXT_CMS_[A-Z0-9_]+)/u)?.[1]\n const resolvedPhase = chain.find((item) => item.phase)?.phase ?? phase\n\n return {\n code: tagged ? kebabCase(tagged) : `${resolvedPhase.replaceAll('.', '-')}-failed`,\n details: chain.flatMap((item) => (item.stack ? [item.stack] : item.message ? [item.message] : [])),\n message,\n phase: resolvedPhase,\n ...(missing\n ? { remediation: `Define ${missing} in .env, pass --env-file, or provide it in the process environment.` }\n : undefined),\n }\n}\n\nexport function renderDiagnostic(diagnostic: CmsDiagnostic, verbose: boolean): string {\n return [\n `✗ ${diagnostic.phase}`,\n '',\n ` ${diagnostic.message}`,\n ...(diagnostic.remediation ? ['', ` ${diagnostic.remediation}`] : []),\n ...(verbose && diagnostic.details.length ? ['', ...diagnostic.details.map((detail) => ` ${detail}`)] : []),\n ].join('\\n')\n}\n\nfunction causeChain(cause: unknown): ErrorLike[] {\n const chain: ErrorLike[] = []\n const visited = new Set<unknown>()\n let current: unknown = cause\n\n while (isErrorLike(current) && !visited.has(current) && chain.length < 16) {\n visited.add(current)\n chain.push(current)\n current = current.cause\n }\n\n return chain\n}\n\nfunction isErrorLike(value: unknown): value is ErrorLike {\n return Predicate.isObject(value)\n}\n\nfunction kebabCase(value: string): string {\n return value\n .replaceAll(/([a-z0-9])([A-Z])/gu, '$1-$2')\n .replaceAll(/[^a-zA-Z0-9]+/gu, '-')\n .replaceAll(/^-|-$/gu, '')\n .toLocaleLowerCase()\n}\n"],"mappings":";;;AAkBA,SAAgB,oBAAoB,OAAe,OAA+B;CAChF,MAAM,QAAQ,WAAW,KAAK;CAC9B,MAAM,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,SAAS,KAAK,IAAI,CAAC,EAAE;CAC/D,MAAM,UAAU,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,SAAS,KAAK,OAAO,CAAC,EAAE,WAAW,OAAO,KAAK;CAC1F,MAAM,UAAU,QAAQ,MAAM,gCAAgC,CAAC,GAAG;CAClE,MAAM,gBAAgB,MAAM,MAAM,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS;CAEjE,OAAO;EACL,MAAM,SAAS,UAAU,MAAM,IAAI,GAAG,cAAc,WAAW,KAAK,GAAG,EAAE;EACzE,SAAS,MAAM,SAAS,SAAU,KAAK,QAAQ,CAAC,KAAK,KAAK,IAAI,KAAK,UAAU,CAAC,KAAK,OAAO,IAAI,CAAC,CAAE;EACjG;EACA,OAAO;EACP,GAAI,UACA,EAAE,aAAa,UAAU,QAAQ,sEAAsE,IACvG;CACN;AACF;AAEA,SAAgB,iBAAiB,YAA2B,SAA0B;CACpF,OAAO;EACL,KAAK,WAAW;EAChB;EACA,KAAK,WAAW;EAChB,GAAI,WAAW,cAAc,CAAC,IAAI,KAAK,WAAW,aAAa,IAAI,CAAC;EACpE,GAAI,WAAW,WAAW,QAAQ,SAAS,CAAC,IAAI,GAAG,WAAW,QAAQ,KAAK,WAAW,KAAK,QAAQ,CAAC,IAAI,CAAC;CAC3G,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,WAAW,OAA6B;CAC/C,MAAM,QAAqB,CAAC;CAC5B,MAAM,0BAAU,IAAI,IAAa;CACjC,IAAI,UAAmB;CAEvB,OAAO,YAAY,OAAO,KAAK,CAAC,QAAQ,IAAI,OAAO,KAAK,MAAM,SAAS,IAAI;EACzE,QAAQ,IAAI,OAAO;EACnB,MAAM,KAAK,OAAO;EAClB,UAAU,QAAQ;CACpB;CAEA,OAAO;AACT;AAEA,SAAS,YAAY,OAAoC;CACvD,OAAO,UAAU,SAAS,KAAK;AACjC;AAEA,SAAS,UAAU,OAAuB;CACxC,OAAO,MACJ,WAAW,uBAAuB,OAAO,CAAC,CAC1C,WAAW,mBAAmB,GAAG,CAAC,CAClC,WAAW,WAAW,EAAE,CAAC,CACzB,kBAAkB;AACvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FIELD_INPUT_METADATA } from "./field-metadata.js";
|
|
2
|
-
import { r as DocumentConfiguration } from "../Configuration-
|
|
3
|
-
import { t as createDocumentEngine } from "../DocumentEngine-
|
|
2
|
+
import { r as DocumentConfiguration } from "../Configuration-BU-UyGoH.js";
|
|
3
|
+
import { t as createDocumentEngine } from "../DocumentEngine-ClhFXW9M.js";
|
|
4
4
|
import { Effect, Predicate, Result, Schema } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/internal/document-model.ts
|
package/src/internal/i18n.js
CHANGED
|
@@ -7,6 +7,7 @@ function compileCmsI18n(options) {
|
|
|
7
7
|
defaultLocale: "",
|
|
8
8
|
fallbackLocale: null,
|
|
9
9
|
prefixDefaultLocale: false,
|
|
10
|
+
siteConfig: "documents",
|
|
10
11
|
messageParameters: {},
|
|
11
12
|
locales: {}
|
|
12
13
|
};
|
|
@@ -55,14 +56,18 @@ function compileCmsI18n(options) {
|
|
|
55
56
|
defaultLocale: options.defaultLocale,
|
|
56
57
|
fallbackLocale: options.fallbackLocale ?? null,
|
|
57
58
|
prefixDefaultLocale: options.prefixDefaultLocale ?? false,
|
|
59
|
+
siteConfig: options.siteConfig ?? "documents",
|
|
58
60
|
messageParameters,
|
|
59
61
|
locales
|
|
60
62
|
};
|
|
61
63
|
}
|
|
64
|
+
function ownsCmsLocale(configuration, documentRoute) {
|
|
65
|
+
return Boolean(configuration.defaultLocale) && (configuration.siteConfig === "localized-routes" || documentRoute);
|
|
66
|
+
}
|
|
62
67
|
function placeholders(message) {
|
|
63
68
|
return [...message.matchAll(/\{([\w]+)\}/gu)].flatMap((match) => match[1] ? [match[1]] : []).filter((name, index, names) => names.indexOf(name) === index).sort((left, right) => left.localeCompare(right));
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
//#endregion
|
|
67
|
-
export { compileCmsI18n };
|
|
72
|
+
export { compileCmsI18n, ownsCmsLocale };
|
|
68
73
|
//# sourceMappingURL=i18n.js.map
|
package/src/internal/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":[],"sources":["../../../../src/internal/i18n.ts"],"sourcesContent":["import { Result, Schema } from 'effect'\nimport type { CmsI18nOptions } from '../I18n'\n\nexport interface CompiledCmsI18n {\n readonly defaultLocale: string\n readonly fallbackLocale: string | null\n readonly prefixDefaultLocale: boolean\n readonly messageParameters: Readonly<Record<string, ReadonlyArray<string>>>\n readonly locales: Readonly<\n Record<string, { readonly name: string; readonly messages: Readonly<Record<string, string>> }>\n >\n}\n\n/** Copies only public, serializable fields; executable installation configuration stays on the server. */\nexport function compileCmsI18n(options?: CmsI18nOptions): CompiledCmsI18n {\n if (!options)\n return {
|
|
1
|
+
{"version":3,"file":"i18n.js","names":[],"sources":["../../../../src/internal/i18n.ts"],"sourcesContent":["import { Result, Schema } from 'effect'\nimport type { CmsI18nOptions } from '../I18n'\n\nexport interface CompiledCmsI18n {\n readonly defaultLocale: string\n readonly fallbackLocale: string | null\n readonly prefixDefaultLocale: boolean\n readonly siteConfig: 'documents' | 'localized-routes'\n readonly messageParameters: Readonly<Record<string, ReadonlyArray<string>>>\n readonly locales: Readonly<\n Record<string, { readonly name: string; readonly messages: Readonly<Record<string, string>> }>\n >\n}\n\n/** Copies only public, serializable fields; executable installation configuration stays on the server. */\nexport function compileCmsI18n(options?: CmsI18nOptions): CompiledCmsI18n {\n if (!options)\n return {\n defaultLocale: '',\n fallbackLocale: null,\n prefixDefaultLocale: false,\n siteConfig: 'documents',\n messageParameters: {},\n locales: {},\n }\n const codes = Object.keys(options.locales)\n\n if (\n !codes.includes(options.defaultLocale) ||\n (options.fallbackLocale != null && !codes.includes(options.fallbackLocale))\n ) {\n throw new Error('i18n defaultLocale and fallbackLocale must be declared in i18n.locales.')\n }\n\n const locales = Object.fromEntries(\n Object.entries(options.locales).map(([code, locale]) => {\n if (\n !/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(code) ||\n !Schema.is(Schema.String)(locale.name) ||\n !locale.name.trim()\n ) {\n throw new Error(`Invalid i18n locale: ${code}. Supply a locale code and display name.`)\n }\n\n const entries: [string, string][] = []\n const ancestors = new Set<object>()\n\n function visit(value: Schema.Json, path: string): void {\n if (Schema.is(Schema.String)(value)) {\n entries.push([path, value])\n\n return\n }\n\n if (!Schema.is(Schema.JsonObject)(value) || ancestors.has(value)) {\n throw new Error(`Invalid i18n message ${code}.${path}: expected a string or nested dictionary.`)\n }\n\n ancestors.add(value)\n\n for (const [key, child] of Object.entries(value)) {\n if (!key || key.includes('.')) throw new Error(`Invalid i18n message key: ${code}.${path}.${key}`)\n visit(child, path ? `${path}.${key}` : key)\n }\n\n ancestors.delete(value)\n }\n\n visit(Result.getOrThrow(Schema.decodeResult(Schema.JsonObject)(locale.messages ?? {})), '')\n\n return [code, { name: locale.name, messages: Object.fromEntries(entries) }]\n }),\n )\n\n const canonicalLocale = options.fallbackLocale ?? options.defaultLocale\n const canonicalMessages = locales[canonicalLocale]?.messages ?? {}\n const canonicalKeys = Object.keys(canonicalMessages)\n\n const messageParameters = Object.fromEntries(\n canonicalKeys.map((key) => [key, placeholders(canonicalMessages[key] ?? '')]),\n )\n\n for (const [code, locale] of Object.entries(locales)) {\n for (const key of Object.keys(locale.messages)) {\n if (!Object.hasOwn(canonicalMessages, key))\n throw new Error(`Invalid i18n message ${code}.${key}: the canonical locale ${canonicalLocale} has no such key.`)\n\n const expected = messageParameters[key] ?? []\n const actual = placeholders(locale.messages[key] ?? '')\n\n if (expected.join('\\0') !== actual.join('\\0'))\n throw new Error(\n `Invalid i18n message ${code}.${key}: placeholders must match ${canonicalLocale}.${key} (${expected.join(', ')}).`,\n )\n }\n\n if (options.fallbackLocale == null) {\n const missing = canonicalKeys.find((key) => !Object.hasOwn(locale.messages, key))\n\n if (missing)\n throw new Error(`Invalid i18n locale ${code}: missing message ${missing} and no fallback locale is configured.`)\n }\n }\n\n return {\n defaultLocale: options.defaultLocale,\n fallbackLocale: options.fallbackLocale ?? null,\n prefixDefaultLocale: options.prefixDefaultLocale ?? false,\n siteConfig: options.siteConfig ?? 'documents',\n messageParameters,\n locales,\n }\n}\n\nexport function ownsCmsLocale(configuration: CompiledCmsI18n, documentRoute: boolean): boolean {\n return Boolean(configuration.defaultLocale) && (configuration.siteConfig === 'localized-routes' || documentRoute)\n}\n\nfunction placeholders(message: string): ReadonlyArray<string> {\n return [...message.matchAll(/\\{([\\w]+)\\}/gu)]\n .flatMap((match) => (match[1] ? [match[1]] : []))\n .filter((name, index, names) => names.indexOf(name) === index)\n .sort((left, right) => left.localeCompare(right))\n}\n"],"mappings":";;;;AAeA,SAAgB,eAAe,SAA2C;CACxE,IAAI,CAAC,SACH,OAAO;EACL,eAAe;EACf,gBAAgB;EAChB,qBAAqB;EACrB,YAAY;EACZ,mBAAmB,CAAC;EACpB,SAAS,CAAC;CACZ;CACF,MAAM,QAAQ,OAAO,KAAK,QAAQ,OAAO;CAEzC,IACE,C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,CAAC,GAAG,QAAQ,SAAS,eAAe,CAAC,CAAC,CAC1C,SAAS,UAAW,MAAM,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAE,CAAC,CAChD,QAAQ,MAAM,OAAO,UAAU,MAAM,QAAQ,IAAI,MAAM,KAAK,CAAC,CAC7D,MAAM,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;AACpD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as STUDIO_APP_PATH } from "../HttpPaths-c9nLZ9H2.js";
|
|
2
|
-
import { Effect, FileSystem, Path } from "effect";
|
|
2
|
+
import { Config, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin } from "@nuxt/kit";
|
|
5
5
|
|
|
@@ -19,12 +19,14 @@ const registerStudioApp = Effect.fn("CmsNuxtModule.registerStudioApp")(function*
|
|
|
19
19
|
if (!packaged) {
|
|
20
20
|
const source = fileURLToPath(import.meta.resolve("@internal/studio/host"));
|
|
21
21
|
const root = path.dirname(path.dirname(source));
|
|
22
|
-
const { build } = yield* Effect.promise(() => import("vite"));
|
|
23
|
-
yield* Effect.promise(() => build({
|
|
24
|
-
root,
|
|
25
|
-
configFile: `${root}/vite.config.ts`
|
|
26
|
-
}));
|
|
27
22
|
host = `${root}/dist/host.js`;
|
|
23
|
+
if (!(yield* Config.Boolean("CMS_REUSE_STUDIO_BUILD").pipe(Config.withDefault(false))) || !(yield* fileSystem.exists(host)) || !(yield* fileSystem.exists(host.replace(/\.js$/u, ".css")))) {
|
|
24
|
+
const { build } = yield* Effect.promise(() => import("vite"));
|
|
25
|
+
yield* Effect.promise(() => build({
|
|
26
|
+
root,
|
|
27
|
+
configFile: `${root}/vite.config.ts`
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
nuxt.options.alias["#cms/studio"] = host;
|
|
30
32
|
nuxt.options.alias["#cms/studio-styles"] = host.replace(/\.js$/u, ".css?url");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/internal/studio-app.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\nimport { fileURLToPath } from 'node:url'\nimport { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin, createResolver } from '@nuxt/kit'\nimport { Effect, FileSystem, Path } from 'effect'\nimport { STUDIO_APP_PATH } from '@internal/protocol/HttpPaths'\n\n/** A separate HTML entry shares Nuxt's Vite graph, but never its document or Vue app. */\nexport const registerStudioApp = Effect.fn('CmsNuxtModule.registerStudioApp')(function* (\n nuxt: Nuxt,\n resolver: ReturnType<typeof createResolver>,\n) {\n addRouteMiddleware({\n name: 'cms-studio-document',\n path: resolver.resolve('./runtime/studio-navigation'),\n global: true,\n })\n const fileSystem = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const packagedHost = resolver.resolve('../studio/host.js')\n const packaged = yield* fileSystem.exists(packagedHost)\n let host = packagedHost\n\n if (!packaged) {\n const source = fileURLToPath(import.meta.resolve('@internal/studio/host'))\n const root = path.dirname(path.dirname(source))\n const { build } = yield* Effect.promise(() => import('vite'))\n
|
|
1
|
+
{"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/internal/studio-app.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\nimport { fileURLToPath } from 'node:url'\nimport { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin, createResolver } from '@nuxt/kit'\nimport { Config, Effect, FileSystem, Path } from 'effect'\nimport { STUDIO_APP_PATH } from '@internal/protocol/HttpPaths'\n\n/** A separate HTML entry shares Nuxt's Vite graph, but never its document or Vue app. */\nexport const registerStudioApp = Effect.fn('CmsNuxtModule.registerStudioApp')(function* (\n nuxt: Nuxt,\n resolver: ReturnType<typeof createResolver>,\n) {\n addRouteMiddleware({\n name: 'cms-studio-document',\n path: resolver.resolve('./runtime/studio-navigation'),\n global: true,\n })\n const fileSystem = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const packagedHost = resolver.resolve('../studio/host.js')\n const packaged = yield* fileSystem.exists(packagedHost)\n let host = packagedHost\n\n if (!packaged) {\n const source = fileURLToPath(import.meta.resolve('@internal/studio/host'))\n const root = path.dirname(path.dirname(source))\n host = `${root}/dist/host.js`\n const reuseStudioBuild = yield* Config.Boolean('CMS_REUSE_STUDIO_BUILD').pipe(Config.withDefault(false))\n\n if (\n !reuseStudioBuild ||\n !(yield* fileSystem.exists(host)) ||\n !(yield* fileSystem.exists(host.replace(/\\.js$/u, '.css')))\n ) {\n const { build } = yield* Effect.promise(() => import('vite'))\n yield* Effect.promise(() => build({ root, configFile: `${root}/vite.config.ts` }))\n }\n }\n\n nuxt.options.alias['#cms/studio'] = host\n nuxt.options.alias['#cms/studio-styles'] = host.replace(/\\.js$/u, '.css?url')\n const entryBase = resolver.resolve('./runtime/studio-entry')\n const entry = `${entryBase}.${(yield* fileSystem.exists(`${entryBase}.ts`)) ? 'ts' : 'js'}`\n const assets = `${nuxt.options.app.baseURL}${nuxt.options.app.buildAssetsDir}`.replace(/\\/+/gu, '/')\n let entryUrl = `${assets}@fs${entry}`\n addVitePlugin(\n {\n name: 'cms-studio-entry',\n apply: 'build',\n buildStart() {\n this.emitFile({ type: 'chunk', id: entry, name: 'cms-studio' })\n },\n generateBundle(_options, bundle) {\n const chunk = Object.values(bundle).find((output) => output.type === 'chunk' && output.name === 'cms-studio')\n\n if (chunk) entryUrl = `${nuxt.options.app.baseURL}${chunk.fileName}`\n },\n },\n { server: false },\n )\n\n const handler = addServerTemplate({\n filename: resolver.resolve('./runtime/studio-shell.virtual.mjs'),\n getContents: () =>\n [\n `import { createStudioAppHandler } from ${JSON.stringify(resolver.resolve('./runtime/studio-app'))}`,\n `export default createStudioAppHandler(${JSON.stringify(entryUrl)}, ${JSON.stringify(nuxt.options.dev ? `${assets}@vite/client` : undefined)})`,\n ].join('\\n'),\n })\n\n addServerHandler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IAAI,WAAW,GAAG,OAAO,KAAK;CAC9B,cACE;EACE,MAAM;EACN,OAAO;EACP,aAAa;GACX,KAAK,SAAS;IAAE,MAAM;IAAS,IAAI;IAAO,MAAM;GAAa,CAAC;EAChE;EACA,eAAe,UAAU,QAAQ;GAC/B,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,YAAY;GAE5G,IAAI,OAAO,WAAW,GAAG,KAAK,QAAQ,IAAI,UAAU,MAAM;EAC5D;CACF,GACA,EAAE,QAAQ,MAAM,CAClB;CAEA,MAAM,UAAU,kBAAkB;EAChC,UAAU,SAAS,QAAQ,oCAAoC;EAC/D,mBACE,CACE,0CAA0C,KAAK,UAAU,SAAS,QAAQ,sBAAsB,CAAC,KACjG,yCAAyC,KAAK,UAAU,QAAQ,EAAE,IAAI,KAAK,UAAU,KAAK,QAAQ,MAAM,GAAG,OAAO,gBAAgB,MAAS,EAAE,EAC/I,CAAC,CAAC,KAAK,IAAI;CACf,CAAC;CAED,iBAAiB;EAAE,SAAS,QAAQ;EAAU,OAAO;CAAgB,CAAC;CACtE,iBAAiB;EAAE,SAAS,QAAQ;EAAU,OAAO,GAAG,gBAAgB;CAAU,CAAC;AACrF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as PreviewSessionId, i as PreviewOrigin } from "./models-
|
|
1
|
+
import { a as PreviewSessionId, i as PreviewOrigin } from "./models-C9kF9JlQ.js";
|
|
2
2
|
import { Option, Schema } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region ../protocol/src/internal/preview/location.ts
|
|
@@ -32,4 +32,4 @@ function previewRedirect(url, parameters) {
|
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
export { readPreviewLocation as n, withPreviewLocation as r, previewRedirect as t };
|
|
35
|
-
//# sourceMappingURL=location-
|
|
35
|
+
//# sourceMappingURL=location-CPX7oj0o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-
|
|
1
|
+
{"version":3,"file":"location-CPX7oj0o.js","names":["PreviewOriginSchema","PreviewSessionIdSchema"],"sources":["../../../../protocol/src/internal/preview/location.ts"],"sourcesContent":["import { Option, Schema } from 'effect'\nimport { PreviewOrigin as PreviewOriginSchema, PreviewSessionId as PreviewSessionIdSchema } from './models'\n\nconst ENABLED_PARAMETER = '_cms_preview'\n\nconst EDITOR_ORIGIN_PARAMETER = '_cms_preview_editor_origin'\n\nconst SESSION_PARAMETER = '_cms_preview_session'\n\nconst PreviewLocationParameters = Schema.Struct({\n editorOrigin: PreviewOriginSchema,\n sessionId: PreviewSessionIdSchema,\n})\n\nexport interface PreviewLocationParameters extends Schema.Schema.Type<typeof PreviewLocationParameters> {}\n\nexport function readPreviewLocation(url: URL): PreviewLocationParameters | undefined {\n if (url.searchParams.get(ENABLED_PARAMETER) !== '1' || url.searchParams.get(EDITOR_ORIGIN_PARAMETER) !== url.origin)\n return undefined\n\n return Schema.decodeUnknownOption(PreviewLocationParameters)({\n editorOrigin: url.searchParams.get(EDITOR_ORIGIN_PARAMETER),\n sessionId: url.searchParams.get(SESSION_PARAMETER),\n }).pipe(Option.getOrUndefined)\n}\n\nexport function withPreviewLocation(url: URL, parameters: PreviewLocationParameters): URL {\n const next = new URL(url)\n next.searchParams.set(ENABLED_PARAMETER, '1')\n next.searchParams.set(EDITOR_ORIGIN_PARAMETER, parameters.editorOrigin)\n next.searchParams.set(SESSION_PARAMETER, parameters.sessionId)\n\n return next\n}\n\nexport function withoutPreviewLocation(url: URL): URL {\n const next = new URL(url)\n next.searchParams.delete(ENABLED_PARAMETER)\n next.searchParams.delete(EDITOR_ORIGIN_PARAMETER)\n next.searchParams.delete(SESSION_PARAMETER)\n\n return next\n}\n\nexport function previewRedirect(url: URL, parameters: PreviewLocationParameters): string | undefined {\n const current = readPreviewLocation(url)\n\n if (current?.sessionId === parameters.sessionId && current.editorOrigin === parameters.editorOrigin) return undefined\n const next = withPreviewLocation(url, parameters)\n\n return `${next.pathname}${next.search}${next.hash}`\n}\n"],"mappings":";;;;AAGA,MAAM,oBAAoB;AAE1B,MAAM,0BAA0B;AAEhC,MAAM,oBAAoB;AAE1B,MAAM,4BAA4B,OAAO,OAAO;CAC9C,cAAcA;CACd,WAAWC;AACb,CAAC;AAID,SAAgB,oBAAoB,KAAiD;CACnF,IAAI,IAAI,aAAa,IAAI,iBAAiB,MAAM,OAAO,IAAI,aAAa,IAAI,uBAAuB,MAAM,IAAI,QAC3G,OAAO;CAET,OAAO,OAAO,oBAAoB,yBAAyB,CAAC,CAAC;EAC3D,cAAc,IAAI,aAAa,IAAI,uBAAuB;EAC1D,WAAW,IAAI,aAAa,IAAI,iBAAiB;CACnD,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc;AAC/B;AAEA,SAAgB,oBAAoB,KAAU,YAA4C;CACxF,MAAM,OAAO,IAAI,IAAI,GAAG;CACxB,KAAK,aAAa,IAAI,mBAAmB,GAAG;CAC5C,KAAK,aAAa,IAAI,yBAAyB,WAAW,YAAY;CACtE,KAAK,aAAa,IAAI,mBAAmB,WAAW,SAAS;CAE7D,OAAO;AACT;AAWA,SAAgB,gBAAgB,KAAU,YAA2D;CACnG,MAAM,UAAU,oBAAoB,GAAG;CAEvC,IAAI,SAAS,cAAc,WAAW,aAAa,QAAQ,iBAAiB,WAAW,cAAc,OAAO;CAC5G,MAAM,OAAO,oBAAoB,KAAK,UAAU;CAEhD,OAAO,GAAG,KAAK,WAAW,KAAK,SAAS,KAAK;AAC/C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as EditorNodeId, l as RevisionNumber, o as PublicPath, r as DocumentId } from "./scalars-B2lgGUnj.js";
|
|
2
|
-
import { Ct as CollectionName, Et as RequestId, r as CompiledDocument } from "./models-
|
|
2
|
+
import { Ct as CollectionName, Et as RequestId, r as CompiledDocument } from "./models-ChRxBChy.js";
|
|
3
3
|
import { Schema } from "effect";
|
|
4
4
|
|
|
5
5
|
//#region ../protocol/src/internal/preview/models.ts
|
|
@@ -128,4 +128,4 @@ const isDocumentPreviewMessage = Schema.is(DocumentPreviewMessage);
|
|
|
128
128
|
|
|
129
129
|
//#endregion
|
|
130
130
|
export { PreviewSessionId as a, PreviewOrigin as i, DocumentPreviewMessage as n, isDocumentPreviewMessage as o, PreviewIntentId as r, DOCUMENT_PREVIEW_CHANNEL as t };
|
|
131
|
-
//# sourceMappingURL=models-
|
|
131
|
+
//# sourceMappingURL=models-C9kF9JlQ.js.map
|