monorepo icon indicating copy to clipboard operation
monorepo copied to clipboard

Unique ids for v2 Message and Variant types

Open jldec opened this issue 1 year ago • 6 comments

Adds persisted unique identifiers for v2 Messages and Variants.
Resolves https://github.com/opral/inlang-message-sdk/issues/92 (MESDK-132)
Step 4 in https://github.com/opral/inlang-message-sdk/issues/70

The main goal of this change is to enable lint reports to reference Messages and Variants. This should also help apps to perform crud operations on Messages and Variants without resorting to array indexes for ids.

NOTE: This is a breaking change on the v2 MessageBundle AST

  • [x] add id string property on v2 Message and Variant types
  • [x] randomId() function - returns new unique id string using ~~crypto.randomUUID()~~ uuid npm package (for now)
  • [x] modify createMessageBundle() and createMessage() helpers, and add createVariant() helper
  • [x] fix v1 <=> v2 message conversion - note that the new Message and Variant ids are not preserved round trip (this conversion is only used temporarily in the experimental persistence feature-flagged version of cli translate)
  • [x] fix mocks and tests to add id properties, and accommodate non-deterministic (random) ids
  • [x] minimal changes to message-bundle-component to make tests work
  • [x] changeset

cc: @martin-lysk because of impact on Slot persistence
cc: @NilsJacobsen because of impact on the WIP message-bundle-component

jldec avatar Jun 17 '24 13:06 jldec

🦋 Changeset detected

Latest commit: 2f603a63842bf26e6df672d54fe53b45dd8dc72d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@inlang/sdk Minor
@inlang/message-bundle-component Patch
@inlang/badge Patch
@inlang/doc-layout-component Patch
@inlang/editor Patch
@inlang/github-lint-action Patch
vs-code-extension Patch
@inlang/rpc Patch
@inlang/settings-component Patch
@inlang/telemetry Patch
@inlang/cross-sell-ninja Patch
@inlang/plugin-i18next Patch
@inlang/plugin-json Patch
@inlang/plugin-m-function-matcher Patch
@inlang/plugin-next-intl Patch
@inlang/plugin-t-function-matcher Patch
@inlang/paraglide-unplugin Patch
@inlang/paraglide-js-e2e Patch
@inlang/paraglide-next-e2e Patch
@inlang/paraglide-rollup Patch
@inlang/paraglide-vite Patch
@inlang/paraglide-webpack Patch
@inlang/paraglide-astro Patch
@inlang/paraglide-sveltekit Patch
@inlang/paraglide-sveltekit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jun 17 '24 13:06 changeset-bot[bot]

Thanks @NilsJacobsen I make a few message-bundle-component changes to fix tests and the build is working locally, but still failing in CI. Any ideas? https://github.com/opral/monorepo/actions/runs/9549090991/job/26317852306?pr=2937#step:8:3542

jldec avatar Jun 17 '24 14:06 jldec

Okey wait, I gonna make the adjustments in this PR. Give me some minutes.

NilsJacobsen avatar Jun 17 '24 14:06 NilsJacobsen

Hmm I don't know where the problem comes from. Maybe the nx cache gets confused somewhere and links still to an old version of the sdk/v2. We can try to reset and try again.

NilsJacobsen avatar Jun 17 '24 14:06 NilsJacobsen

Trying again with latest from main.

jldec avatar Jun 18 '24 10:06 jldec

@NilsJacobsen I believe I have found the issue - I missed on place where you used upsertVariant with a literal variant object. For some reason the build was working locally even though it should not. I think you may be right about the NX cache. 😬

jldec avatar Jun 18 '24 10:06 jldec

closing because outdated

samuelstroschein avatar Aug 01 '24 18:08 samuelstroschein