@orthacms/i18n-server 0.0.0-reserve.0

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/index.d.ts +13 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +15 -0
  6. package/dist/lib/content/controllers/get-entry-locales.controller.d.ts +15 -0
  7. package/dist/lib/content/controllers/get-entry-locales.controller.d.ts.map +1 -0
  8. package/dist/lib/content/controllers/get-entry-locales.controller.js +45 -0
  9. package/dist/lib/content/controllers/locale-summary.controller.d.ts +30 -0
  10. package/dist/lib/content/controllers/locale-summary.controller.d.ts.map +1 -0
  11. package/dist/lib/content/controllers/locale-summary.controller.js +61 -0
  12. package/dist/lib/content/controllers/resolve-type.d.ts +9 -0
  13. package/dist/lib/content/controllers/resolve-type.d.ts.map +1 -0
  14. package/dist/lib/content/controllers/resolve-type.js +20 -0
  15. package/dist/lib/content/dto/locale-summary.dto.d.ts +10 -0
  16. package/dist/lib/content/dto/locale-summary.dto.d.ts.map +1 -0
  17. package/dist/lib/content/dto/locale-summary.dto.js +30 -0
  18. package/dist/lib/content/locale-group-lock.d.ts +34 -0
  19. package/dist/lib/content/locale-group-lock.d.ts.map +1 -0
  20. package/dist/lib/content/locale-group-lock.js +38 -0
  21. package/dist/lib/content/services/entry-locale-extension.service.d.ts +188 -0
  22. package/dist/lib/content/services/entry-locale-extension.service.d.ts.map +1 -0
  23. package/dist/lib/content/services/entry-locale-extension.service.js +662 -0
  24. package/dist/lib/content/services/locale-group.service.d.ts +87 -0
  25. package/dist/lib/content/services/locale-group.service.d.ts.map +1 -0
  26. package/dist/lib/content/services/locale-group.service.js +135 -0
  27. package/dist/lib/copilot/i18n-tool.provider.d.ts +53 -0
  28. package/dist/lib/copilot/i18n-tool.provider.d.ts.map +1 -0
  29. package/dist/lib/copilot/i18n-tool.provider.js +157 -0
  30. package/dist/lib/copilot/translation-proposal.applier.d.ts +87 -0
  31. package/dist/lib/copilot/translation-proposal.applier.d.ts.map +1 -0
  32. package/dist/lib/copilot/translation-proposal.applier.js +242 -0
  33. package/dist/lib/copilot/translation-proposal.provider.d.ts +114 -0
  34. package/dist/lib/copilot/translation-proposal.provider.d.ts.map +1 -0
  35. package/dist/lib/copilot/translation-proposal.provider.js +419 -0
  36. package/dist/lib/domain/errors/index.d.ts +4 -0
  37. package/dist/lib/domain/errors/index.d.ts.map +1 -0
  38. package/dist/lib/domain/errors/index.js +9 -0
  39. package/dist/lib/domain/errors/invalid-locale-set.error.d.ts +10 -0
  40. package/dist/lib/domain/errors/invalid-locale-set.error.d.ts.map +1 -0
  41. package/dist/lib/domain/errors/invalid-locale-set.error.js +16 -0
  42. package/dist/lib/domain/errors/invalid-locale.error.d.ts +10 -0
  43. package/dist/lib/domain/errors/invalid-locale.error.d.ts.map +1 -0
  44. package/dist/lib/domain/errors/invalid-locale.error.js +16 -0
  45. package/dist/lib/domain/errors/unknown-locale.error.d.ts +11 -0
  46. package/dist/lib/domain/errors/unknown-locale.error.d.ts.map +1 -0
  47. package/dist/lib/domain/errors/unknown-locale.error.js +18 -0
  48. package/dist/lib/domain/locale-policy.d.ts +42 -0
  49. package/dist/lib/domain/locale-policy.d.ts.map +1 -0
  50. package/dist/lib/domain/locale-policy.js +61 -0
  51. package/dist/lib/domain/value-objects/locale-set.d.ts +41 -0
  52. package/dist/lib/domain/value-objects/locale-set.d.ts.map +1 -0
  53. package/dist/lib/domain/value-objects/locale-set.js +89 -0
  54. package/dist/lib/domain/value-objects/locale.d.ts +55 -0
  55. package/dist/lib/domain/value-objects/locale.d.ts.map +1 -0
  56. package/dist/lib/domain/value-objects/locale.js +73 -0
  57. package/dist/lib/i18n.constants.d.ts +33 -0
  58. package/dist/lib/i18n.constants.d.ts.map +1 -0
  59. package/dist/lib/i18n.constants.js +89 -0
  60. package/dist/lib/i18n.module.d.ts +14 -0
  61. package/dist/lib/i18n.module.d.ts.map +1 -0
  62. package/dist/lib/i18n.module.js +82 -0
  63. package/dist/lib/insights/http/controllers/localization-coverage.controller.d.ts +23 -0
  64. package/dist/lib/insights/http/controllers/localization-coverage.controller.d.ts.map +1 -0
  65. package/dist/lib/insights/http/controllers/localization-coverage.controller.js +46 -0
  66. package/dist/lib/insights/infrastructure/queries/localization-coverage.query.d.ts +59 -0
  67. package/dist/lib/insights/infrastructure/queries/localization-coverage.query.d.ts.map +1 -0
  68. package/dist/lib/insights/infrastructure/queries/localization-coverage.query.js +179 -0
  69. package/dist/lib/insights/types/i18n-insights-view.d.ts +83 -0
  70. package/dist/lib/insights/types/i18n-insights-view.d.ts.map +1 -0
  71. package/dist/lib/insights/types/i18n-insights-view.js +10 -0
  72. package/dist/lib/locales/controllers/list-locales.controller.d.ts +26 -0
  73. package/dist/lib/locales/controllers/list-locales.controller.d.ts.map +1 -0
  74. package/dist/lib/locales/controllers/list-locales.controller.js +48 -0
  75. package/dist/lib/locales/services/locale-registry.service.d.ts +26 -0
  76. package/dist/lib/locales/services/locale-registry.service.d.ts.map +1 -0
  77. package/dist/lib/locales/services/locale-registry.service.js +70 -0
  78. package/dist/lib/locales/services/orphaned-locale.checker.d.ts +60 -0
  79. package/dist/lib/locales/services/orphaned-locale.checker.d.ts.map +1 -0
  80. package/dist/lib/locales/services/orphaned-locale.checker.js +114 -0
  81. package/dist/lib/types/locale.d.ts +68 -0
  82. package/dist/lib/types/locale.d.ts.map +1 -0
  83. package/dist/lib/types/locale.js +8 -0
  84. package/dist/lib/utils/i18n-plugin.d.ts +41 -0
  85. package/dist/lib/utils/i18n-plugin.d.ts.map +1 -0
  86. package/dist/lib/utils/i18n-plugin.js +53 -0
  87. package/package.json +47 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Locale configuration contracts. The host declares its locales once, on the
3
+ * server plugin (`I18nServerPlugin({ locales })`) — the single source of
4
+ * truth. The admin fetches them from `GET /api/i18n/locales`; nothing is
5
+ * duplicated client-side.
6
+ */
7
+ import type { LocaleDir } from '../i18n.constants';
8
+ export type { LocaleDir };
9
+ /** One configured locale. */
10
+ export interface LocaleDef {
11
+ /**
12
+ * Stable machine slug stored on entry rows (e.g. `en`, `de`, `pt-br`).
13
+ *
14
+ * **It is a BCP-47 language tag**, and that is a contract, not a
15
+ * coincidence: the slug regex is the lowercase BCP-47 shape (a 2–3 letter
16
+ * primary tag with optional `-` subtags), and every value the plugin
17
+ * returns under `locale` — here, on `EntryLocaleItem`, on the `locale`
18
+ * column of an entry payload — may be used verbatim as an HTML `lang`
19
+ * value. A consumer therefore sets `lang={entry.locale}` on the field
20
+ * region, the preview, and the published page without a mapping table, and
21
+ * a screen reader announces German content with German pronunciation
22
+ * instead of the document's `lang="en"` (WCAG 3.1.2 Language of Parts).
23
+ * Keeping the two identical is why nothing here uppercases a region subtag.
24
+ */
25
+ slug: string;
26
+ /** Human display name (e.g. "English"). */
27
+ name: string;
28
+ /**
29
+ * The default locale — applied when a request names none. Exactly one
30
+ * locale must set it (validated eagerly at plugin construction).
31
+ */
32
+ isDefault?: boolean;
33
+ /**
34
+ * Text direction of content written in this locale — the HTML `dir` value
35
+ * a consumer sets alongside `lang`.
36
+ *
37
+ * **Optional in config, always present on the wire.** Omit it and the
38
+ * plugin infers it from the slug (`ar`, `he`, `fa`, `ur`, … → `rtl`;
39
+ * everything else `ltr`), so an RTL language is configured like any other;
40
+ * declare it to override the inference. `GET /api/i18n/locales` always
41
+ * returns a resolved value, so the admin never has to decide for itself
42
+ * whether Arabic is right-to-left (WCAG 1.3.2 Meaningful Sequence).
43
+ */
44
+ dir?: LocaleDir;
45
+ }
46
+ /** Options accepted by `I18nServerPlugin()`. */
47
+ export interface I18nPluginConfig {
48
+ /** The available locales, in display order. Exactly one `isDefault`. */
49
+ locales: LocaleDef[];
50
+ /**
51
+ * What to do at boot when entry rows exist in a locale the config no
52
+ * longer declares — `'fail'` (the default) aborts the boot, `'warn'` logs
53
+ * the report and continues.
54
+ *
55
+ * Removing a locale from this config does **not** remove its rows, and the
56
+ * rows are then invisible to every read path: `?locale=` 400s the slug, the
57
+ * locale panel iterates the configured set, coverage and the virtual
58
+ * filters exclude it. The data is intact and unreachable — the worst shape
59
+ * for a silent failure, because nothing in the product ever mentions it
60
+ * again. Failing the boot puts the choice in front of whoever changed the
61
+ * config, while it is still their change. Set `'warn'` for a deployment
62
+ * that is knowingly mid-migration.
63
+ */
64
+ orphanedLocales?: OrphanedLocalePolicy;
65
+ }
66
+ /** How the plugin reacts to rows left behind by a removed locale. */
67
+ export type OrphanedLocalePolicy = 'fail' | 'warn';
68
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../src/lib/types/locale.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,6BAA6B;AAC7B,MAAM,WAAW,SAAS;IACtB;;;;;;;;;;;;;OAaG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;;OAUG;IACH,GAAG,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC7B,wEAAwE;IACxE,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;CAC1C;AAED,qEAAqE;AACrE,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Locale configuration contracts. The host declares its locales once, on the
4
+ * server plugin (`I18nServerPlugin({ locales })`) — the single source of
5
+ * truth. The admin fetches them from `GET /api/i18n/locales`; nothing is
6
+ * duplicated client-side.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ import type { ServerPlugin } from '@orthacms/bootstrap-server';
2
+ import type { I18nPluginConfig } from '../types/locale';
3
+ /**
4
+ * Server plugin for content localization, carrying its config alongside the
5
+ * standard plugin shape.
6
+ */
7
+ export interface I18nServerPluginType extends ServerPlugin {
8
+ /** The validated locale configuration. */
9
+ i18nConfig: I18nPluginConfig;
10
+ }
11
+ /**
12
+ * Creates the i18n plugin — content localization for `i18n: true` content
13
+ * types. Register it **after** `ContentPlugin`: it binds content-server's
14
+ * `CONTENT_ENTRY_EXTENSION` port (locale scoping, create stamping,
15
+ * shared-field sync, locale filters) and serves the locale-domain API under
16
+ * `/api/i18n` (locales list, per-entry locale panel, batched summaries,
17
+ * create-translation).
18
+ *
19
+ * Owns **no tables and no migrations** — locales live in this config, and
20
+ * the `locale` / `locale_group_id` columns live on the host-owned generated
21
+ * content tables (added by the `i18n: true` type flag).
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * createServer({
26
+ * plugins: [
27
+ * DatabasePlugin({ connectionString: config.database.url }),
28
+ * IdentityPlugin(config.plugins.identity),
29
+ * ContentPlugin({ types: contentTypes }),
30
+ * I18nServerPlugin({
31
+ * locales: [
32
+ * { slug: 'en', name: 'English', isDefault: true },
33
+ * { slug: 'de', name: 'Deutsch' }
34
+ * ]
35
+ * })
36
+ * ]
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function I18nServerPlugin(config: I18nPluginConfig): I18nServerPluginType;
41
+ //# sourceMappingURL=i18n-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/i18n-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACtD,0CAA0C;IAC1C,UAAU,EAAE,gBAAgB,CAAC;CAChC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,gBAAgB,GACzB,oBAAoB,CAOtB"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I18nServerPlugin = I18nServerPlugin;
4
+ const locale_set_1 = require("../domain/value-objects/locale-set");
5
+ const i18n_module_1 = require("../i18n.module");
6
+ /**
7
+ * Validate the locale config **eagerly** (like `ContentPlugin`'s registry):
8
+ * a misconfigured host fails at construction — before boot, before the first
9
+ * request. Building the domain {@link LocaleSet} enforces every invariant (at
10
+ * least one locale; unique, well-formed slugs; non-blank names; exactly one
11
+ * default), so the raw-string rules live on the `Locale` / `LocaleSet` value
12
+ * objects rather than inline here.
13
+ */
14
+ function assertConfig(config) {
15
+ locale_set_1.LocaleSet.fromDefs(config.locales);
16
+ }
17
+ /**
18
+ * Creates the i18n plugin — content localization for `i18n: true` content
19
+ * types. Register it **after** `ContentPlugin`: it binds content-server's
20
+ * `CONTENT_ENTRY_EXTENSION` port (locale scoping, create stamping,
21
+ * shared-field sync, locale filters) and serves the locale-domain API under
22
+ * `/api/i18n` (locales list, per-entry locale panel, batched summaries,
23
+ * create-translation).
24
+ *
25
+ * Owns **no tables and no migrations** — locales live in this config, and
26
+ * the `locale` / `locale_group_id` columns live on the host-owned generated
27
+ * content tables (added by the `i18n: true` type flag).
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * createServer({
32
+ * plugins: [
33
+ * DatabasePlugin({ connectionString: config.database.url }),
34
+ * IdentityPlugin(config.plugins.identity),
35
+ * ContentPlugin({ types: contentTypes }),
36
+ * I18nServerPlugin({
37
+ * locales: [
38
+ * { slug: 'en', name: 'English', isDefault: true },
39
+ * { slug: 'de', name: 'Deutsch' }
40
+ * ]
41
+ * })
42
+ * ]
43
+ * });
44
+ * ```
45
+ */
46
+ function I18nServerPlugin(config) {
47
+ assertConfig(config);
48
+ return {
49
+ name: 'i18n',
50
+ module: i18n_module_1.I18nModule.forRoot(config),
51
+ i18nConfig: config
52
+ };
53
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@orthacms/i18n-server",
3
+ "version": "0.0.0-reserve.0",
4
+ "description": "@orthacms/i18n-server — part of Ortha CMS.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/ortha-source/ortha-cms/tree/main/packages/i18n/server",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ortha-source/ortha-cms.git",
10
+ "directory": "packages/i18n/server"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ortha-source/ortha-cms/issues"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "@nestjs/common": "^11.0.0",
29
+ "@nestjs/swagger": "^11.4.6",
30
+ "@orthacms/bootstrap-server": "^0.0.1",
31
+ "@orthacms/content-server": "^0.0.1",
32
+ "@orthacms/copilot-domain": "^0.0.1",
33
+ "@orthacms/copilot-server": "^0.0.1",
34
+ "@orthacms/database": "^0.0.1",
35
+ "@orthacms/identity-server": "^0.0.1",
36
+ "@orthacms/tools-server": "^0.0.1",
37
+ "@orthacms/utils-server": "^0.0.1",
38
+ "@orthacms/workspaces-server": "^0.0.1",
39
+ "class-transformer": "^0.5.1",
40
+ "class-validator": "^0.15.1",
41
+ "drizzle-orm": "^0.45.0",
42
+ "tslib": "^2.3.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }