@localness/contract 0.3.0 → 0.4.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.
package/dist/rules.d.mts CHANGED
@@ -8,8 +8,16 @@ type RowId = string | number;
8
8
  /** Whitespace is not part of the sentence: `'Save\n As'` and `'SaveAs'` collide on purpose. */
9
9
  export declare const fpTranslation: (text: string) => string;
10
10
  /** Keys that only carry a text's fingerprint, awaiting a real name. */
11
- export declare const DRAFT_KEY_PREFIX = "__draft_";
12
- /** What a person sees for a key: a draft key's fingerprint is cut to five characters. */
11
+ export declare const UNNAMED_KEY_PREFIX = "__unnamed_";
12
+ /**
13
+ * The prefix before `__unnamed_`. It collided with the Draft publish status, so
14
+ * it was renamed; keys and clients minted under it still exist, so it is
15
+ * recognised everywhere but never written.
16
+ */
17
+ export declare const LEGACY_DRAFT_KEY_PREFIX = "__draft_";
18
+ /** Whether a key is a placeholder awaiting a real name, under either prefix. */
19
+ export declare const isUnnamedKey: (key: string) => boolean;
20
+ /** What a person sees for a key: an unnamed key's fingerprint is cut to five characters. */
13
21
  export declare function formatI18nKeyDisplay(key: string | null | undefined): string;
14
22
  /**
15
23
  * Which release the workspace is looking at: `'all'`, `'unassigned'`, or one
package/dist/rules.mjs CHANGED
@@ -626,14 +626,24 @@ const fpTranslation = (text) => {
626
626
  return import_spark_md5.default.hash(normalized);
627
627
  };
628
628
  /** Keys that only carry a text's fingerprint, awaiting a real name. */
629
- const DRAFT_KEY_PREFIX = "__draft_";
630
- /** What a person sees for a key: a draft key's fingerprint is cut to five characters. */
629
+ const UNNAMED_KEY_PREFIX = "__unnamed_";
630
+ /**
631
+ * The prefix before `__unnamed_`. It collided with the Draft publish status, so
632
+ * it was renamed; keys and clients minted under it still exist, so it is
633
+ * recognised everywhere but never written.
634
+ */
635
+ const LEGACY_DRAFT_KEY_PREFIX = "__draft_";
636
+ const unnamedPrefixOf = (key) => [UNNAMED_KEY_PREFIX, LEGACY_DRAFT_KEY_PREFIX].find((prefix) => key.startsWith(prefix));
637
+ /** Whether a key is a placeholder awaiting a real name, under either prefix. */
638
+ const isUnnamedKey = (key) => unnamedPrefixOf(key) !== void 0;
639
+ /** What a person sees for a key: an unnamed key's fingerprint is cut to five characters. */
631
640
  function formatI18nKeyDisplay(key) {
632
641
  if (!key) return "";
633
- if (!key.startsWith("__draft_")) return key;
634
- const hash = key.slice(8);
642
+ const prefix = unnamedPrefixOf(key);
643
+ if (!prefix) return key;
644
+ const hash = key.slice(prefix.length);
635
645
  if (hash.length <= 5) return key;
636
- return `${DRAFT_KEY_PREFIX}${hash.slice(0, 5)}`;
646
+ return `${prefix}${hash.slice(0, 5)}`;
637
647
  }
638
648
  /** Ids are compared as strings: a row's ids come back from JSON while a picker emits numbers. */
639
649
  function entryMatchesReleaseFilter(releaseIds, filter) {
@@ -642,4 +652,4 @@ function entryMatchesReleaseFilter(releaseIds, filter) {
642
652
  if (filter === "unassigned") return ids.length === 0;
643
653
  return ids.some((releaseId) => String(releaseId) === String(filter));
644
654
  }
645
- export { DRAFT_KEY_PREFIX, entryMatchesReleaseFilter, formatI18nKeyDisplay, fpTranslation };
655
+ export { LEGACY_DRAFT_KEY_PREFIX, UNNAMED_KEY_PREFIX, entryMatchesReleaseFilter, formatI18nKeyDisplay, fpTranslation, isUnnamedKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localness/contract",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Response contracts of the Localness public /api/v1: zod schemas and the types inferred from them.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",