@byline/cli 3.0.0 → 3.0.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.
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * cd apps/webapp && pnpm tsx byline/scripts/backfill-version-locales.ts
20
20
  *
21
- * See docs/CONTENT-LOCALE-RESOLUTION.md.
21
+ * See docs/I18N.md.
22
22
  */
23
23
 
24
24
  import '../load-env.js'
@@ -287,7 +287,7 @@ async function processFile(
287
287
  // Advertise the imported locale (editorial available-locales set), merged
288
288
  // with whatever is already advertised so a later-locale re-import doesn't
289
289
  // clobber an earlier one. The public set is still gated by the version
290
- // completeness ledger (intersection). See docs/AVAILABLE-LOCALES.md.
290
+ // completeness ledger (intersection). See docs/I18N.md.
291
291
  availableLocales: [...new Set([...(existing.availableLocales ?? []), locale])],
292
292
  })
293
293
  await walkToStatus(handle, result.documentId, workflowStatuses, defaultStatus, desiredStatus)
@@ -20,7 +20,7 @@
20
20
  * cd apps/webapp && pnpm tsx byline/scripts/re-anchor.ts --to fr --collection pages
21
21
  * cd apps/webapp && pnpm tsx byline/scripts/re-anchor.ts --to fr --dry-run
22
22
  *
23
- * See docs/DEFAULT-LOCALE-SWITCHING.md.
23
+ * See docs/I18N.md.
24
24
  */
25
25
 
26
26
  import '../load-env.js'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@byline/cli",
3
3
  "private": false,
4
4
  "license": "MPL-2.0",
5
- "version": "3.0.0",
5
+ "version": "3.0.2",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },
@@ -1,106 +0,0 @@
1
- /**
2
- * This Source Code is subject to the terms of the Mozilla Public
3
- * License, v. 2.0. If a copy of the MPL was not distributed with this
4
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
- *
6
- * Copyright (c) Infonomic Company Limited
7
- */
8
-
9
- /**
10
- * **Schema-side helper.** Returns a `GroupField` schema that emits one
11
- * `checkbox` field per configured content locale. Drop the result into
12
- * a collection's `fields` array in `<collection>/schema.ts`. Pure data;
13
- * the only imports are `@byline/core` types and the i18n locale list.
14
- *
15
- * See `docs/FIELDS.md` for the schema-vs-admin model.
16
- *
17
- * @deprecated **No longer needed** as of the content-locale-resolution work.
18
- * The editorial "advertise these locales" control is now a core *system
19
- * attribute* + ledger-aware sidebar widget (`availableLocales`) — see
20
- * `docs/AVAILABLE-LOCALES.md`. This userland custom field is **left in place as
21
- * a reference example** of the schema-side field-builder pattern; it is not used
22
- * by the system widget and can be removed from collection schemas.
23
- */
24
-
25
- import type { GroupField } from '@byline/core'
26
-
27
- import { contentLocales, type LocaleDefinition } from '../i18n.js'
28
-
29
- type Options = Partial<Omit<GroupField, 'type' | 'fields'>> & {
30
- locales?: readonly LocaleDefinition[]
31
- }
32
-
33
- type LocaleFields<T extends readonly LocaleDefinition[]> = {
34
- [K in keyof T]: {
35
- name: T[K]['code']
36
- label: T[K]['label']
37
- type: 'checkbox'
38
- optional: true
39
- }
40
- }
41
-
42
- type WithOverride<O, K extends string, V, D> = O extends { [P in K]: V } ? O[K] : D
43
-
44
- type AvailableLanguagesField<Opts extends Options> = Omit<GroupField, 'name' | 'fields'> & {
45
- name: WithOverride<Opts, 'name', string, 'availableLanguages'>
46
- fields: LocaleFields<
47
- WithOverride<Opts, 'locales', readonly LocaleDefinition[], typeof contentLocales>
48
- >
49
- }
50
-
51
- const builtInValidate = (value: Record<string, boolean> | undefined): string | undefined => {
52
- const hasSelection =
53
- value != null &&
54
- typeof value === 'object' &&
55
- !Array.isArray(value) &&
56
- Object.values(value).some(Boolean)
57
- if (!hasSelection) {
58
- return 'At least one language must be selected'
59
- }
60
- return undefined
61
- }
62
-
63
- /**
64
- * Returns a `GroupField` that renders one checkbox per locale entry.
65
- * Validation requires at least one language to be selected; if the caller
66
- * supplies its own `validate`, the built-in rule runs first and the caller's
67
- * validator only runs when the built-in passes.
68
- *
69
- * @description This field is intended for use in a document's "Edit" view
70
- * to allow editors to specify which languages a document is available in.
71
- * It is orthogonal to the defined workflow system and is here as a 'signal'
72
- * to frontend websites / consumers - allowing them to implement their own
73
- * logic around content availability per language.
74
- *
75
- * @param options - Optional overrides. Accepts any `GroupField` property
76
- * except `type` and `fields` (which are computed), plus a `locales` array
77
- * that drives the generated checkbox set.
78
- */
79
- export function availableLanguagesField<const Opts extends Options>(
80
- options: Opts = {} as Opts
81
- ): AvailableLanguagesField<Opts> {
82
- const { name, label, helpText, locales, validate: userValidate, ...rest } = options
83
-
84
- const validate = userValidate
85
- ? (value: any, data: Record<string, any>) => {
86
- const builtInError = builtInValidate(value)
87
- if (builtInError) return builtInError
88
- return userValidate(value, data)
89
- }
90
- : builtInValidate
91
-
92
- return {
93
- ...rest,
94
- name: (name ?? 'availableLanguages') as any,
95
- label: label ?? 'Published Languages',
96
- helpText: helpText ?? 'Select the languages this document is available in.',
97
- type: 'group',
98
- fields: (locales ?? contentLocales).map(({ code, label }) => ({
99
- name: code,
100
- label,
101
- type: 'checkbox' as const,
102
- optional: true,
103
- })) as any,
104
- validate,
105
- }
106
- }