@phtngyn/cms 0.2.0-beta.1 → 0.2.0-beta.2

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +38 -45
  3. package/package.json +3 -1
  4. package/src/ApplicationTypes.d.ts +7 -5
  5. package/src/{Configuration-CjVUBBwa.js → Configuration-BU-UyGoH.js} +4 -4
  6. package/src/{Configuration-CjVUBBwa.js.map → Configuration-BU-UyGoH.js.map} +1 -1
  7. package/src/Configuration.d.ts +41 -24
  8. package/src/Configuration.js.map +1 -1
  9. package/src/Content.js +1 -1
  10. package/src/{ContentTransfer-CTzGGKFV.js → ContentTransfer-BhF9G56s.js} +2 -2
  11. package/src/{ContentTransfer-CTzGGKFV.js.map → ContentTransfer-BhF9G56s.js.map} +1 -1
  12. package/src/{DocumentEngine-BbhfnTAc.js → DocumentEngine-ClhFXW9M.js} +4 -4
  13. package/src/{DocumentEngine-BbhfnTAc.js.map → DocumentEngine-ClhFXW9M.js.map} +1 -1
  14. package/src/DocumentModel.d.ts +6 -1
  15. package/src/DocumentModel.js +4 -3
  16. package/src/DocumentModel.js.map +1 -1
  17. package/src/{Forms-CfcI3tPU.js → Forms-BbkE7QfC.js} +47 -16
  18. package/src/Forms-BbkE7QfC.js.map +1 -0
  19. package/src/{Forms-02-p8qEw.js → Forms-DoB56hfe.js} +24 -7
  20. package/src/Forms-DoB56hfe.js.map +1 -0
  21. package/src/{Forms-BorTcIlp.d.ts → Forms-R0HoTR-o.d.ts} +30 -9
  22. package/src/Forms.d.ts +16 -15
  23. package/src/Forms.js.map +1 -1
  24. package/src/{I18n-BXlVunfa.d.ts → I18n-zbqpWxki.d.ts} +3 -1
  25. package/src/I18n.d.ts +1 -1
  26. package/src/Module.js +4 -2
  27. package/src/Module.js.map +1 -1
  28. package/src/{S3MediaObjects-DC0c8sYC.js → S3MediaObjects-D5Ns4FM6.js} +14 -12
  29. package/src/S3MediaObjects-D5Ns4FM6.js.map +1 -0
  30. package/src/cli.js +60 -34
  31. package/src/cli.js.map +1 -1
  32. package/src/{connection-BPf4BQUZ.js → connection-D5S9Iph-.js} +2 -2
  33. package/src/{connection-BPf4BQUZ.js.map → connection-D5S9Iph-.js.map} +1 -1
  34. package/src/{dev-lifecycle-vQLxwCFq.js → dev-lifecycle-CZ7iCzG9.js} +129 -42
  35. package/src/dev-lifecycle-CZ7iCzG9.js.map +1 -0
  36. package/src/{installation-DsGst1BH.js → installation-BNuoRDOz.js} +43 -31
  37. package/src/installation-BNuoRDOz.js.map +1 -0
  38. package/src/internal/authoring-catalog.js +2 -2
  39. package/src/internal/authoring-metadata.js +1 -1
  40. package/src/internal/configuration.js +149 -50
  41. package/src/internal/configuration.js.map +1 -1
  42. package/src/internal/dev-lifecycle.js +2 -2
  43. package/src/internal/diagnostics.js +47 -0
  44. package/src/internal/diagnostics.js.map +1 -0
  45. package/src/internal/document-model.js +2 -2
  46. package/src/internal/form-capabilities.js +1 -1
  47. package/src/internal/i18n.js +6 -1
  48. package/src/internal/i18n.js.map +1 -1
  49. package/src/{location-BgYhXEZp.js → location-CPX7oj0o.js} +2 -2
  50. package/src/{location-BgYhXEZp.js.map → location-CPX7oj0o.js.map} +1 -1
  51. package/src/{models-k2nXyD6q.js → models-C9kF9JlQ.js} +2 -2
  52. package/src/{models-k2nXyD6q.js.map → models-C9kF9JlQ.js.map} +1 -1
  53. package/src/{models-DgkGTFus.js → models-ChRxBChy.js} +4 -2
  54. package/src/{models-DgkGTFus.js.map → models-ChRxBChy.js.map} +1 -1
  55. package/src/runtime/delivery/context.js +1 -1
  56. package/src/runtime/delivery/plugin.js +3 -2
  57. package/src/runtime/delivery/plugin.js.map +1 -1
  58. package/src/runtime/forms/document.js +1 -1
  59. package/src/runtime/forms/useCmsForm.js +28 -24
  60. package/src/runtime/forms/useCmsForm.js.map +1 -1
  61. package/src/runtime/i18n/useCmsI18n.d.ts +1 -1
  62. package/src/runtime/installation.js +1 -1
  63. package/src/runtime/plugin.js +12 -4
  64. package/src/runtime/plugin.js.map +1 -1
  65. package/src/runtime/preview/connection.js +1 -1
  66. package/src/runtime/preview/controller.js +2 -2
  67. package/src/runtime/preview/plugin.client.js +3 -3
  68. package/src/runtime/preview/store.js +1 -1
  69. package/src/runtime/sitemap.js +1 -1
  70. package/src/{store-BYgSt7E3.js → store-B49J21NA.js} +3 -3
  71. package/src/{store-BYgSt7E3.js.map → store-B49J21NA.js.map} +1 -1
  72. package/studio/{CreateDocumentDialog-BdiM77bb.js → CreateDocumentDialog-DJ8c0WZb.js} +3 -3
  73. package/studio/{documentPlanning-B7fyUj9r.js → documentPlanning-CDb31mnl.js} +6417 -6358
  74. package/studio/host.css +1 -1
  75. package/studio/host.js +7608 -7250
  76. package/src/Forms-02-p8qEw.js.map +0 -1
  77. package/src/Forms-CfcI3tPU.js.map +0 -1
  78. package/src/S3MediaObjects-DC0c8sYC.js.map +0 -1
  79. package/src/dev-lifecycle-vQLxwCFq.js.map +0 -1
  80. package/src/installation-DsGst1BH.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { n as formAuthoring } from "../Forms-02-p8qEw.js";
2
- import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-CjVUBBwa.js";
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-CjVUBBwa.js";
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-DgkGTFus.js";
2
- import { j as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-DC0c8sYC.js";
1
+ import { R as SeoConfiguration } from "../models-ChRxBChy.js";
2
+ import { j as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-D5Ns4FM6.js";
3
3
  import { validateFormCapabilities } from "./form-capabilities.js";
4
4
  import { compileCmsI18n } from "./i18n.js";
5
- import { i as PreviewOrigin } from "../models-k2nXyD6q.js";
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 optionalString = Schema.optionalKey(Schema.NonEmptyString);
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
- publicBaseUrl: Schema.NonEmptyString,
31
- storage: Schema.Struct({
32
- bucket: Schema.NonEmptyString,
33
- credentials: Schema.optionalKey(Schema.Struct({
34
- accessKeyId: Schema.NonEmptyString,
35
- secretAccessKey: Schema.NonEmptyString,
36
- sessionToken: optionalString
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 decodedConfiguration = Schema.decodeResult(InstallationConfiguration)(configuration);
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: decodedConfiguration.success
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
- function resolveCmsInstallation(authored, authoring) {
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 configuration = compiled.installation;
68
- const cleanup = configuration.cleanup === false ? void 0 : configuration.cleanup;
69
- const media = configuration.media === false ? void 0 : configuration.media;
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: media !== void 0,
75
- maxUploadBytes: media?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES
131
+ enabled: runtimeMedia !== void 0,
132
+ maxUploadBytes: authoredMedia?.maxUploadBytes ?? DEFAULT_MEDIA_MAX_UPLOAD_BYTES
76
133
  },
77
- seo: configuration.seo ?? makeDefaultSeoOptions(configuration.baseUrl),
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: configuration.baseUrl,
140
+ baseUrl: runtime.baseUrl,
84
141
  bootstrap,
85
142
  cleanup: {
86
- enabled: configuration.cleanup !== false,
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: configuration.database,
147
+ database: {
148
+ schema: compiled.installation.database.schema,
149
+ url: runtime.databaseUrl
150
+ },
91
151
  documentModel: compiled.documentModel,
92
- initializationToken: configuration.initializationToken,
93
- ...media === void 0 ? void 0 : { media: {
94
- publicBaseUrl: `${media.publicBaseUrl.replace(/\/+$/gu, "")}/${media.storage.prefix.replace(/\/+$/gu, "")}`,
95
- ...media.storage,
96
- forcePathStyle: media.storage.forcePathStyle ?? false,
97
- provisionBucket: media.storage.provisionBucket ?? false
98
- } },
99
- secret: configuration.secret
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,C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Schema"],"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,EAC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G,OAAO,OAAO,CAAC,CAAC,IAAI,cAAc,IAAI,EAAE,gBAAgB,IAAI,eAAe,IAAI,QACzF,OAAO,GAAG,OAAO,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 resetCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-vQLxwCFq.js";
1
+ import { i as resetCmsDevelopment, n as doctorCmsDevelopment, r as loadCmsProjectEnvironment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-CZ7iCzG9.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])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,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-CjVUBBwa.js";
3
- import { t as createDocumentEngine } from "../DocumentEngine-BbhfnTAc.js";
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
@@ -1,4 +1,4 @@
1
- import { r as FormCapabilities } from "../Forms-CfcI3tPU.js";
1
+ import { r as FormCapabilities } from "../Forms-BbkE7QfC.js";
2
2
  import { Result, Schema } from "effect";
3
3
 
4
4
  //#region src/internal/form-capabilities.ts
@@ -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
@@ -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 { defaultLocale: '', fallbackLocale: null, prefixDefaultLocale: false, messageParameters: {}, locales: {} }\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 messageParameters,\n locales,\n }\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,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EACL,eAAe,QAAQ;EACvB,gBAAgB,QAAQ,kBAAkB;EAC1C,qBAAqB,QAAQ,uBAAuB;EACpD;EACA;CACF;AACF;AAEA,SAAS,aAAa,SAAwC;CAC5D,OAAO,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
+ {"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,CAAC,MAAM,SAAS,QAAQ,aAAa,KACpC,QAAQ,kBAAkB,QAAQ,CAAC,MAAM,SAAS,QAAQ,cAAc,GAEzE,MAAM,IAAI,MAAM,yEAAyE;CAG3F,MAAM,UAAU,OAAO,YACrB,OAAO,QAAQ,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY;EACtD,IACE,CAAC,yCAAyC,KAAK,IAAI,KACnD,CAAC,OAAO,GAAG,OAAO,MAAM,CAAC,CAAC,OAAO,IAAI,KACrC,CAAC,OAAO,KAAK,KAAK,GAElB,MAAM,IAAI,MAAM,wBAAwB,KAAK,yCAAyC;EAGxF,MAAM,UAA8B,CAAC;EACrC,MAAM,4BAAY,IAAI,IAAY;EAElC,SAAS,MAAM,OAAoB,MAAoB;GACrD,IAAI,OAAO,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,GAAG;IACnC,QAAQ,KAAK,CAAC,MAAM,KAAK,CAAC;IAE1B;GACF;GAEA,IAAI,CAAC,OAAO,GAAG,OAAO,UAAU,CAAC,CAAC,KAAK,KAAK,UAAU,IAAI,KAAK,GAC7D,MAAM,IAAI,MA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B,GAAG,IAAI,IAAI,SAAS,KAAK,IAAI,EAAE,GACjH;EACJ;EAEA,IAAI,QAAQ,kBAAkB,MAAM;GAClC,MAAM,UAAU,cAAc,MAAM,QAAQ,CAAC,OAAO,OAAO,OAAO,UAAU,GAAG,CAAC;GAEhF,IAAI,SACF,MAAM,IAAI,MAAM,uBAAuB,KAAK,oBAAoB,QAAQ,uCAAuC;EACnH;CACF;CAEA,OAAO;EACL,eAAe,QAAQ;EACvB,gBAAgB,QAAQ,kBAAkB;EAC1C,qBAAqB,QAAQ,uBAAuB;EACpD,YAAY,QAAQ,cAAc;EAClC;EACA;CACF;AACF;AAEA,SAAgB,cAAc,eAAgC,eAAiC;CAC7F,OAAO,QAAQ,cAAc,aAAa,MAAM,cAAc,eAAe,sBAAsB;AACrG;AAEA,SAAS,aAAa,SAAwC;CAC5D,OAAO,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,4 +1,4 @@
1
- import { a as PreviewSessionId, i as PreviewOrigin } from "./models-k2nXyD6q.js";
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-BgYhXEZp.js.map
35
+ //# sourceMappingURL=location-CPX7oj0o.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"location-BgYhXEZp.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
+ {"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-DgkGTFus.js";
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-k2nXyD6q.js.map
131
+ //# sourceMappingURL=models-C9kF9JlQ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models-k2nXyD6q.js","names":[],"sources":["../../../../protocol/src/internal/preview/models.ts"],"sourcesContent":["import { CompiledDocument } from '../../Documents'\nimport { RequestId } from '../../Identity'\nimport { CollectionName } from '../configuration/scalars'\nimport { DocumentId, EditorNodeId, PublicPath, RevisionNumber } from '../documents/scalars'\nimport { Schema } from 'effect'\n\nexport const DOCUMENT_PREVIEW_CHANNEL = 'cms:document-preview'\n\nexport const PreviewSessionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewSessionId'))\n\nexport type PreviewSessionId = typeof PreviewSessionId.Type\n\nexport const PreviewIntentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewIntentId'))\n\nexport type PreviewIntentId = typeof PreviewIntentId.Type\n\nconst exactOrigin = Schema.makeFilter<string>(\n (value) => {\n try {\n const url = new URL(value)\n\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.origin === value\n } catch {\n return false\n }\n },\n { expected: 'an exact HTTP or HTTPS origin without a path' },\n)\n\nexport const PreviewOrigin = Schema.NonEmptyString.check(exactOrigin).pipe(Schema.brand('PreviewOrigin'))\n\nexport type PreviewOrigin = typeof PreviewOrigin.Type\n\nexport const DocumentPreviewFocusIntent = Schema.Struct({\n id: PreviewIntentId,\n documentId: DocumentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n origin: Schema.Literals(['editor', 'preview']),\n reveal: Schema.Boolean,\n revision: RevisionNumber,\n})\n\nexport interface DocumentPreviewFocusIntent extends Schema.Schema.Type<typeof DocumentPreviewFocusIntent> {}\n\nexport const RenderedCompiledDocument = Schema.Struct({\n collection: CollectionName,\n documentId: DocumentId,\n path: PublicPath,\n role: Schema.Literals(['embedded', 'primary', 'related', 'summary']),\n title: Schema.NonEmptyString,\n})\n\nexport interface RenderedCompiledDocument extends Schema.Schema.Type<typeof RenderedCompiledDocument> {}\n\nexport const RenderedDocumentManifest = Schema.Struct({\n documents: Schema.Array(RenderedCompiledDocument),\n route: PublicPath,\n})\n\nexport interface RenderedDocumentManifest extends Schema.Schema.Type<typeof RenderedDocumentManifest> {}\n\nconst previewEnvelope = {\n channel: Schema.Literal(DOCUMENT_PREVIEW_CHANNEL),\n sessionId: PreviewSessionId,\n}\n\nconst StudioConnectMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:connect'),\n})\n\nconst StudioModeMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:mode'),\n mode: Schema.Literals(['browse', 'edit']),\n})\n\nconst StudioNavigateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:navigate'),\n path: PublicPath,\n})\n\nconst StudioPatchMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:patch'),\n document: CompiledDocument,\n fallbacks: Schema.Record(Schema.String, Schema.String),\n focus: Schema.optionalKey(DocumentPreviewFocusIntent),\n revision: RevisionNumber,\n})\n\nconst StudioFocusMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:focus'),\n focus: DocumentPreviewFocusIntent,\n})\n\nconst PreviewReadyMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:ready'),\n path: PublicPath,\n})\n\nconst PreviewManifestMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:manifest'),\n manifest: RenderedDocumentManifest,\n revision: RevisionNumber,\n})\n\nconst PreviewActivateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:activate'),\n documentId: DocumentId,\n field: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.optionalKey(EditorNodeId),\n requestId: RequestId,\n revision: RevisionNumber,\n})\n\nconst PreviewAppliedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:applied'),\n intentId: PreviewIntentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n result: Schema.Literals(['exact', 'fallback', 'missing']),\n revision: RevisionNumber,\n})\n\nconst PreviewRenderedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:rendered'),\n revision: RevisionNumber,\n})\n\nexport const DocumentPreviewMessage = Schema.Union([\n StudioConnectMessage,\n StudioModeMessage,\n StudioNavigateMessage,\n StudioPatchMessage,\n StudioFocusMessage,\n PreviewReadyMessage,\n Schema.Struct({ ...previewEnvelope, type: Schema.tag('preview:error'), message: Schema.NullOr(Schema.String) }),\n PreviewManifestMessage,\n PreviewActivateMessage,\n PreviewAppliedMessage,\n PreviewRenderedMessage,\n]).pipe(Schema.toTaggedUnion('type'))\n\nexport type DocumentPreviewMessage = typeof DocumentPreviewMessage.Type\n\nexport const isDocumentPreviewMessage = Schema.is(DocumentPreviewMessage)\n\ntype PreviewPayload<Message extends DocumentPreviewMessage> = Message extends DocumentPreviewMessage\n ? Omit<Message, 'channel' | 'sessionId'>\n : never\n\nexport type StudioPreviewPayload = PreviewPayload<\n Extract<DocumentPreviewMessage, { readonly type: `studio:${string}` }>\n>\n\nexport type PreviewSitePayload = PreviewPayload<Extract<DocumentPreviewMessage, { readonly type: `preview:${string}` }>>\n"],"mappings":";;;;;AAMA,MAAa,2BAA2B;AAExC,MAAa,mBAAmB,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAI1G,MAAa,kBAAkB,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAIxG,MAAM,cAAc,OAAO,YACxB,UAAU;CACT,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,QAAQ,IAAI,aAAa,WAAW,IAAI,aAAa,aAAa,IAAI,WAAW;CACnF,QAAQ;EACN,OAAO;CACT;AACF,GACA,EAAE,UAAU,+CAA+C,CAC7D;AAEA,MAAa,gBAAgB,OAAO,eAAe,MAAM,WAAW,CAAC,CAAC,KAAK,OAAO,MAAM,eAAe,CAAC;AAIxG,MAAa,6BAA6B,OAAO,OAAO;CACtD,IAAI;CACJ,YAAY;CACZ,QAAQ,OAAO,YAAY,YAAY;CACvC,QAAQ,OAAO,SAAS,CAAC,UAAU,SAAS,CAAC;CAC7C,QAAQ,OAAO;CACf,UAAU;AACZ,CAAC;AAID,MAAa,2BAA2B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CAC/C,QAAQ,OAAO,YAAY,YAAY;CACvC,WAAW;CACX,UAAU;AACZ,CAAC;AAED,MAAM,wBAAwB,OAAO,OAAO;CAC1C,GAAG;CACH,MAAM,OAAO,IAAI,iBAAiB;CAClC,UAAU;CACV,QAAQ,OAAO,YAAY,YAAY;CACvC,QAAQ,OAAO,SAAS;EAAC;EAAS;EAAY;CAAS,CAAC;CACxD,UAAU;AACZ,CAAC;AAED,MAAM,yBAAyB,OAAO,OAAO;CAC3C,GAAG;CACH,MAAM,OAAO,IAAI,kBAAkB;CACnC,UAAU;AACZ,CAAC;AAED,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;CACA;CACA;CACA,OAAO,OAAO;EAAE,GAAG;EAAiB,MAAM,OAAO,IAAI,eAAe;EAAG,SAAS,OAAO,OAAO,OAAO,MAAM;CAAE,CAAC;CAC9G;CACA;CACA;CACA;AACF,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,MAAM,CAAC;AAIpC,MAAa,2BAA2B,OAAO,GAAG,sBAAsB"}
1
+ {"version":3,"file":"models-C9kF9JlQ.js","names":[],"sources":["../../../../protocol/src/internal/preview/models.ts"],"sourcesContent":["import { CompiledDocument } from '../../Documents'\nimport { RequestId } from '../../Identity'\nimport { CollectionName } from '../configuration/scalars'\nimport { DocumentId, EditorNodeId, PublicPath, RevisionNumber } from '../documents/scalars'\nimport { Schema } from 'effect'\n\nexport const DOCUMENT_PREVIEW_CHANNEL = 'cms:document-preview'\n\nexport const PreviewSessionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewSessionId'))\n\nexport type PreviewSessionId = typeof PreviewSessionId.Type\n\nexport const PreviewIntentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PreviewIntentId'))\n\nexport type PreviewIntentId = typeof PreviewIntentId.Type\n\nconst exactOrigin = Schema.makeFilter<string>(\n (value) => {\n try {\n const url = new URL(value)\n\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.origin === value\n } catch {\n return false\n }\n },\n { expected: 'an exact HTTP or HTTPS origin without a path' },\n)\n\nexport const PreviewOrigin = Schema.NonEmptyString.check(exactOrigin).pipe(Schema.brand('PreviewOrigin'))\n\nexport type PreviewOrigin = typeof PreviewOrigin.Type\n\nexport const DocumentPreviewFocusIntent = Schema.Struct({\n id: PreviewIntentId,\n documentId: DocumentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n origin: Schema.Literals(['editor', 'preview']),\n reveal: Schema.Boolean,\n revision: RevisionNumber,\n})\n\nexport interface DocumentPreviewFocusIntent extends Schema.Schema.Type<typeof DocumentPreviewFocusIntent> {}\n\nexport const RenderedCompiledDocument = Schema.Struct({\n collection: CollectionName,\n documentId: DocumentId,\n path: PublicPath,\n role: Schema.Literals(['embedded', 'primary', 'related', 'summary']),\n title: Schema.NonEmptyString,\n})\n\nexport interface RenderedCompiledDocument extends Schema.Schema.Type<typeof RenderedCompiledDocument> {}\n\nexport const RenderedDocumentManifest = Schema.Struct({\n documents: Schema.Array(RenderedCompiledDocument),\n route: PublicPath,\n})\n\nexport interface RenderedDocumentManifest extends Schema.Schema.Type<typeof RenderedDocumentManifest> {}\n\nconst previewEnvelope = {\n channel: Schema.Literal(DOCUMENT_PREVIEW_CHANNEL),\n sessionId: PreviewSessionId,\n}\n\nconst StudioConnectMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:connect'),\n})\n\nconst StudioModeMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:mode'),\n mode: Schema.Literals(['browse', 'edit']),\n})\n\nconst StudioNavigateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:navigate'),\n path: PublicPath,\n})\n\nconst StudioPatchMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:patch'),\n document: CompiledDocument,\n fallbacks: Schema.Record(Schema.String, Schema.String),\n focus: Schema.optionalKey(DocumentPreviewFocusIntent),\n revision: RevisionNumber,\n})\n\nconst StudioFocusMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('studio:focus'),\n focus: DocumentPreviewFocusIntent,\n})\n\nconst PreviewReadyMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:ready'),\n path: PublicPath,\n})\n\nconst PreviewManifestMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:manifest'),\n manifest: RenderedDocumentManifest,\n revision: RevisionNumber,\n})\n\nconst PreviewActivateMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:activate'),\n documentId: DocumentId,\n field: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.optionalKey(EditorNodeId),\n requestId: RequestId,\n revision: RevisionNumber,\n})\n\nconst PreviewAppliedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:applied'),\n intentId: PreviewIntentId,\n nodeId: Schema.optionalKey(EditorNodeId),\n result: Schema.Literals(['exact', 'fallback', 'missing']),\n revision: RevisionNumber,\n})\n\nconst PreviewRenderedMessage = Schema.Struct({\n ...previewEnvelope,\n type: Schema.tag('preview:rendered'),\n revision: RevisionNumber,\n})\n\nexport const DocumentPreviewMessage = Schema.Union([\n StudioConnectMessage,\n StudioModeMessage,\n StudioNavigateMessage,\n StudioPatchMessage,\n StudioFocusMessage,\n PreviewReadyMessage,\n Schema.Struct({ ...previewEnvelope, type: Schema.tag('preview:error'), message: Schema.NullOr(Schema.String) }),\n PreviewManifestMessage,\n PreviewActivateMessage,\n PreviewAppliedMessage,\n PreviewRenderedMessage,\n]).pipe(Schema.toTaggedUnion('type'))\n\nexport type DocumentPreviewMessage = typeof DocumentPreviewMessage.Type\n\nexport const isDocumentPreviewMessage = Schema.is(DocumentPreviewMessage)\n\ntype PreviewPayload<Message extends DocumentPreviewMessage> = Message extends DocumentPreviewMessage\n ? Omit<Message, 'channel' | 'sessionId'>\n : never\n\nexport type StudioPreviewPayload = PreviewPayload<\n Extract<DocumentPreviewMessage, { readonly type: `studio:${string}` }>\n>\n\nex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,OAAO,OAAO;EAAE,GAAG;EAAiB,MAAM,OAAO,IAAI,eAAe;EAAG,SAAS,OAAO,OAAO,OAAO,MAAM;CAAE,CAAC;CAC9G;CACA;CACA;CACA;AACF,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,MAAM,CAAC;AAIpC,MAAa,2BAA2B,OAAO,GAAG,sBAAsB"}
@@ -651,7 +651,9 @@ const MoveDocumentInput = Schema.Struct({
651
651
  }).annotate({ identifier: "MoveDocumentInput" });
652
652
  const DuplicateDocumentInput = Schema.Struct({
653
653
  ...MoveDocumentInput.fields,
654
- includeChildren: Schema.Boolean
654
+ includeChildren: Schema.Boolean,
655
+ /** Copies into another independent locale variant when supplied. */
656
+ locale: Schema.optionalKey(Locale)
655
657
  }).annotate({ identifier: "DuplicateDocumentInput" });
656
658
  const UnpublishDocumentInput = Schema.Struct({
657
659
  documentId: DocumentId,
@@ -711,4 +713,4 @@ const DocumentValidationResult = Schema.Struct({
711
713
 
712
714
  //#endregion
713
715
  export { StudioActor as $, UnpublishDocumentInput as A, SeoMediaUnavailable as B, PublishedDocumentLookup as C, CollectionName as Ct, RemoveDocumentInput as D, PublishedDocumentSurroundQuery as E, RequestId as Et, SaveSeoInput as F, SeoUrl as G, SeoRevision as H, SeoCanonicalOrigin as I, AccessDenied as J, SeoVersionConflict as K, SeoCapabilities as L, DocumentSeo as M, GlobalSeoSettings as N, RestoreDocumentInput as O, PublishSeoInput as P, Role as Q, SeoConfiguration as R, PublishDocumentInput as S, AddressPattern as St, PublishedDocumentQuery as T, SourceDirectory as Tt, SeoSnapshot as U, SeoMutationResult as V, SeoState as W, DOCUMENT_ACTIONS as X, AuthenticationRequired as Y, MEDIA_ACTIONS as Z, DocumentSurround as _, MediaReference as _t, DOCUMENT_REVISION_ACTIONS as a, MediaCleanupReport as at, MarkdownNode as b, MediaTooLarge as bt, DocumentIssue as c, MediaFolder as ct, DocumentNavigationQuery as d, MediaInvalid as dt, StudioEntryDenied as et, DocumentQueryScalar as f, MediaName as ft, DocumentSummary as g, MediaQuery as gt, DocumentSourceMapping as h, MediaPage as ht, CreateDocumentInput as i, MediaByteSize as it, UpdateDocumentInput as j, UndeleteDocumentInput as k, DocumentMutationResult as l, MediaId as lt, DocumentSource as m, MediaObjectKey as mt, CmsMarkdownDocument as n, ImageMimeType as nt, DeletedDocument as o, MediaConflict as ot, DocumentRevisionAction as p, MediaNotFound as pt, SitemapEntry as q, CompiledDocument as r, MediaAsset as rt, DocumentBrowseQuery as s, MediaCursor as st, CmsDocumentAnalysis as t, StudioRequestContext as tt, DocumentNavigationItem as u, MediaIntegrityReport as ut, DocumentValidationResult as v, MediaReferenced as vt, PublishedDocumentPage as w, Locale as wt, MoveDocumentInput as x, MediaUpload as xt, DuplicateDocumentInput as y, MediaStatus as yt, SeoConfirmationRequired as z };
714
- //# sourceMappingURL=models-DgkGTFus.js.map
716
+ //# sourceMappingURL=models-ChRxBChy.js.map