@mossbear/protocol 0.1.0-alpha.43 → 0.1.0-alpha.44
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/bundleSlug.d.ts +61 -0
- package/dist/bundleSlug.d.ts.map +1 -1
- package/dist/bundleSlug.js +95 -0
- package/dist/bundleSlug.js.map +1 -1
- package/dist/bundleSlug.test.js +88 -1
- package/dist/bundleSlug.test.js.map +1 -1
- package/dist/schemas.d.ts +6 -6
- package/package.json +1 -1
package/dist/bundleSlug.d.ts
CHANGED
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* discovers it by slug in the bundle listing to learn its **id**, which is what
|
|
28
28
|
* a committed subscription stores (plan → "A subscription names a bundle id,
|
|
29
29
|
* not a slug").
|
|
30
|
+
*
|
|
31
|
+
* **The account's *personal* bundle, since Decision 17** — a workspace's is
|
|
32
|
+
* named after its workspace. {@link defaultGuidesBundleFor} is the rule; these
|
|
33
|
+
* two constants are its personal branch and are read nowhere else.
|
|
30
34
|
*/
|
|
31
35
|
export declare const DEFAULT_GUIDES_SLUG = "my-guides";
|
|
32
36
|
/** Display name minted alongside {@link DEFAULT_GUIDES_SLUG}. */
|
|
@@ -39,4 +43,61 @@ export declare const DEFAULT_GUIDES_NAME = "My guides";
|
|
|
39
43
|
* this only picks a candidate the common case won't bounce.
|
|
40
44
|
*/
|
|
41
45
|
export declare function deriveBundleSlug(name: string, taken: ReadonlySet<string>): string;
|
|
46
|
+
/**
|
|
47
|
+
* The slug and name of the account's default guides bundle **in one workspace**
|
|
48
|
+
* (Decision 17 of the workspace-declaration design, founder 2026-09-04).
|
|
49
|
+
*
|
|
50
|
+
* Decision 13 gave an account one capture bundle per workspace, and the mint
|
|
51
|
+
* gave every one of them {@link DEFAULT_GUIDES_SLUG}. So the first import from a
|
|
52
|
+
* repo that declares a shared workspace left the account holding two bundles at
|
|
53
|
+
* one slug, and the CLI's directory disambiguation suffixes *every* member of a
|
|
54
|
+
* colliding group — renaming the user's existing `.mossbear/context/my-guides/`
|
|
55
|
+
* on their next sync and turning `mossbear pull my-guides` into a named
|
|
56
|
+
* refusal. Neither is wrong on its own: two bundles that genuinely collide
|
|
57
|
+
* should be disambiguated. These two should never have collided.
|
|
58
|
+
*
|
|
59
|
+
* So the personal workspace's bundle keeps `my-guides` — it is the one
|
|
60
|
+
* `users.default_bundle_id` names, and the one every existing repo's
|
|
61
|
+
* `.mossbear/context/my-guides/` came from — and every other workspace's is
|
|
62
|
+
* named after its workspace. The fix is here rather than in the CLI because
|
|
63
|
+
* this is where the two names are chosen.
|
|
64
|
+
*
|
|
65
|
+
* **`isPersonal` is the caller's answer, not a lookup.** It is
|
|
66
|
+
* `users.default_workspace_id === workspaceId`, and both server callers — the
|
|
67
|
+
* bundle resolver and the unlink route — already read that column for other
|
|
68
|
+
* reasons. Passing it keeps this function total: the same inputs always give
|
|
69
|
+
* the same pair, which is what lets a data migration reuse the rule without a
|
|
70
|
+
* database handle.
|
|
71
|
+
*
|
|
72
|
+
* Workspace slugs are url-safe by construction — the column is written only by
|
|
73
|
+
* the two creators, both of which normalize — and set at creation, with no
|
|
74
|
+
* route that renames one. So on the slug side the only rule left to respect is
|
|
75
|
+
* `BundleSlugSchema`'s 64-character cap.
|
|
76
|
+
*
|
|
77
|
+
* **The name side is different, and is why `displayable` exists.** A workspace
|
|
78
|
+
* *name* is free text typed by whoever created the workspace, and this is the
|
|
79
|
+
* first thing that turns one person's text into *another* person's bundle name:
|
|
80
|
+
* a member who imports from a repo declaring a shared workspace gets a bundle
|
|
81
|
+
* of their own named after it. Bundle names are printed straight into a
|
|
82
|
+
* terminal by the CLI — `unlink` renders each still-delivering bundle by name —
|
|
83
|
+
* so a carriage return or an ANSI escape in the workspace name would let its
|
|
84
|
+
* author rewrite the line a *teammate* reads about what is still reaching their
|
|
85
|
+
* agents. Stripped here because this is the point where the two meet.
|
|
86
|
+
*
|
|
87
|
+
* **The root cause is upstream and is not fixed by this.** Nothing at the
|
|
88
|
+
* boundary rejects control characters in a workspace name or in a bundle name —
|
|
89
|
+
* neither the create-workspace body schema nor `UpdateBundleRequestSchema`
|
|
90
|
+
* (`schemas.ts`) constrains more than length — so any *other* surface that
|
|
91
|
+
* renders either one raw has the same hole, and a bundle the user names
|
|
92
|
+
* themselves can still carry one. The real fix is a shared display-name schema
|
|
93
|
+
* at those boundaries; filed as `display-name-control-characters`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function defaultGuidesBundleFor(workspace: {
|
|
96
|
+
slug: string;
|
|
97
|
+
name: string;
|
|
98
|
+
isPersonal: boolean;
|
|
99
|
+
}): {
|
|
100
|
+
slug: string;
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
42
103
|
//# sourceMappingURL=bundleSlug.d.ts.map
|
package/dist/bundleSlug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleSlug.d.ts","sourceRoot":"","sources":["../src/bundleSlug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"bundleSlug.d.ts","sourceRoot":"","sources":["../src/bundleSlug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,cAAc,CAAA;AAE9C,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,cAAc,CAAA;AAsB9C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAUjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuBjC"}
|
package/dist/bundleSlug.js
CHANGED
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* discovers it by slug in the bundle listing to learn its **id**, which is what
|
|
28
28
|
* a committed subscription stores (plan → "A subscription names a bundle id,
|
|
29
29
|
* not a slug").
|
|
30
|
+
*
|
|
31
|
+
* **The account's *personal* bundle, since Decision 17** — a workspace's is
|
|
32
|
+
* named after its workspace. {@link defaultGuidesBundleFor} is the rule; these
|
|
33
|
+
* two constants are its personal branch and are read nowhere else.
|
|
30
34
|
*/
|
|
31
35
|
export const DEFAULT_GUIDES_SLUG = 'my-guides';
|
|
32
36
|
/** Display name minted alongside {@link DEFAULT_GUIDES_SLUG}. */
|
|
@@ -36,6 +40,8 @@ export const DEFAULT_GUIDES_NAME = 'My guides';
|
|
|
36
40
|
* alphanumeric, max 64 chars (`schemas.ts`).
|
|
37
41
|
*/
|
|
38
42
|
const MAX_SLUG_LENGTH = 64;
|
|
43
|
+
/** What {@link defaultGuidesBundleFor} appends to a workspace's own slug. */
|
|
44
|
+
const GUIDES_SUFFIX = '-guides';
|
|
39
45
|
function normalize(name) {
|
|
40
46
|
return name
|
|
41
47
|
.normalize('NFKD')
|
|
@@ -65,4 +71,93 @@ export function deriveBundleSlug(name, taken) {
|
|
|
65
71
|
return candidate;
|
|
66
72
|
}
|
|
67
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The slug and name of the account's default guides bundle **in one workspace**
|
|
76
|
+
* (Decision 17 of the workspace-declaration design, founder 2026-09-04).
|
|
77
|
+
*
|
|
78
|
+
* Decision 13 gave an account one capture bundle per workspace, and the mint
|
|
79
|
+
* gave every one of them {@link DEFAULT_GUIDES_SLUG}. So the first import from a
|
|
80
|
+
* repo that declares a shared workspace left the account holding two bundles at
|
|
81
|
+
* one slug, and the CLI's directory disambiguation suffixes *every* member of a
|
|
82
|
+
* colliding group — renaming the user's existing `.mossbear/context/my-guides/`
|
|
83
|
+
* on their next sync and turning `mossbear pull my-guides` into a named
|
|
84
|
+
* refusal. Neither is wrong on its own: two bundles that genuinely collide
|
|
85
|
+
* should be disambiguated. These two should never have collided.
|
|
86
|
+
*
|
|
87
|
+
* So the personal workspace's bundle keeps `my-guides` — it is the one
|
|
88
|
+
* `users.default_bundle_id` names, and the one every existing repo's
|
|
89
|
+
* `.mossbear/context/my-guides/` came from — and every other workspace's is
|
|
90
|
+
* named after its workspace. The fix is here rather than in the CLI because
|
|
91
|
+
* this is where the two names are chosen.
|
|
92
|
+
*
|
|
93
|
+
* **`isPersonal` is the caller's answer, not a lookup.** It is
|
|
94
|
+
* `users.default_workspace_id === workspaceId`, and both server callers — the
|
|
95
|
+
* bundle resolver and the unlink route — already read that column for other
|
|
96
|
+
* reasons. Passing it keeps this function total: the same inputs always give
|
|
97
|
+
* the same pair, which is what lets a data migration reuse the rule without a
|
|
98
|
+
* database handle.
|
|
99
|
+
*
|
|
100
|
+
* Workspace slugs are url-safe by construction — the column is written only by
|
|
101
|
+
* the two creators, both of which normalize — and set at creation, with no
|
|
102
|
+
* route that renames one. So on the slug side the only rule left to respect is
|
|
103
|
+
* `BundleSlugSchema`'s 64-character cap.
|
|
104
|
+
*
|
|
105
|
+
* **The name side is different, and is why `displayable` exists.** A workspace
|
|
106
|
+
* *name* is free text typed by whoever created the workspace, and this is the
|
|
107
|
+
* first thing that turns one person's text into *another* person's bundle name:
|
|
108
|
+
* a member who imports from a repo declaring a shared workspace gets a bundle
|
|
109
|
+
* of their own named after it. Bundle names are printed straight into a
|
|
110
|
+
* terminal by the CLI — `unlink` renders each still-delivering bundle by name —
|
|
111
|
+
* so a carriage return or an ANSI escape in the workspace name would let its
|
|
112
|
+
* author rewrite the line a *teammate* reads about what is still reaching their
|
|
113
|
+
* agents. Stripped here because this is the point where the two meet.
|
|
114
|
+
*
|
|
115
|
+
* **The root cause is upstream and is not fixed by this.** Nothing at the
|
|
116
|
+
* boundary rejects control characters in a workspace name or in a bundle name —
|
|
117
|
+
* neither the create-workspace body schema nor `UpdateBundleRequestSchema`
|
|
118
|
+
* (`schemas.ts`) constrains more than length — so any *other* surface that
|
|
119
|
+
* renders either one raw has the same hole, and a bundle the user names
|
|
120
|
+
* themselves can still carry one. The real fix is a shared display-name schema
|
|
121
|
+
* at those boundaries; filed as `display-name-control-characters`.
|
|
122
|
+
*/
|
|
123
|
+
export function defaultGuidesBundleFor(workspace) {
|
|
124
|
+
if (workspace.isPersonal) {
|
|
125
|
+
return { slug: DEFAULT_GUIDES_SLUG, name: DEFAULT_GUIDES_NAME };
|
|
126
|
+
}
|
|
127
|
+
// Truncate the workspace's half rather than the whole result, so the suffix
|
|
128
|
+
// that says what this bundle *is* survives a long workspace slug. Trailing
|
|
129
|
+
// hyphens go for the reason `deriveBundleSlug` strips them: a cut can land
|
|
130
|
+
// mid-word and `foo--guides` is uglier than it needs to be.
|
|
131
|
+
const base = workspace.slug
|
|
132
|
+
.slice(0, MAX_SLUG_LENGTH - GUIDES_SUFFIX.length)
|
|
133
|
+
.replace(/-+$/g, '');
|
|
134
|
+
// A workspace slug is never empty in practice — the column is NOT NULL and
|
|
135
|
+
// both creators derive a non-empty value — but a bare `-guides` would fail
|
|
136
|
+
// `BundleSlugSchema`'s "starts alphanumeric" rule, so the fallback is one
|
|
137
|
+
// token rather than an invariant every caller has to trust.
|
|
138
|
+
return {
|
|
139
|
+
slug: `${base || 'workspace'}${GUIDES_SUFFIX}`,
|
|
140
|
+
// `|| 'Workspace'` for the same reason the slug has a fallback: a name of
|
|
141
|
+
// nothing but control characters passes the create-workspace body schema
|
|
142
|
+
// (`v.trim()` drops whitespace, not an ESC) and would leave a bundle called
|
|
143
|
+
// " guides".
|
|
144
|
+
name: `${displayable(workspace.name) || 'Workspace'} guides`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A name safe to print into a terminal line: Unicode control and format
|
|
149
|
+
* characters removed, whitespace runs collapsed, ends trimmed. The character
|
|
150
|
+
* class is the one `schemas.ts` already uses for ids, so the two agree about
|
|
151
|
+
* what "a control character" means.
|
|
152
|
+
*
|
|
153
|
+
* Removed rather than escaped or refused: the caller is a derivation with no
|
|
154
|
+
* user to report to, and a workspace whose name carries an ANSI escape is,
|
|
155
|
+
* as far as a bundle name is concerned, a workspace named without it.
|
|
156
|
+
*/
|
|
157
|
+
function displayable(name) {
|
|
158
|
+
return name
|
|
159
|
+
.replace(/[\p{Cc}\p{Cf}]+/gu, '')
|
|
160
|
+
.replace(/\s+/g, ' ')
|
|
161
|
+
.trim();
|
|
162
|
+
}
|
|
68
163
|
//# sourceMappingURL=bundleSlug.js.map
|
package/dist/bundleSlug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleSlug.js","sourceRoot":"","sources":["../src/bundleSlug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"bundleSlug.js","sourceRoot":"","sources":["../src/bundleSlug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAE9C,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAE9C;;;GAGG;AACH,MAAM,eAAe,GAAG,EAAE,CAAA;AAE1B,6EAA6E;AAC7E,MAAM,aAAa,GAAG,SAAS,CAAA;AAE/B,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI;SACR,SAAS,CAAC,MAAM,CAAC;SACjB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC;SACzB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,C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AC1E,yEAAyE;QACzE,4EAA4E;QAC5E,aAAa;QACb,IAAI,EAAE,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,WAAW,SAAS;KAC7D,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI;SACR,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAA;AACX,CAAC"}
|
package/dist/bundleSlug.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { deriveBundleSlug } from './bundleSlug.js';
|
|
2
|
+
import { defaultGuidesBundleFor, deriveBundleSlug } from './bundleSlug.js';
|
|
3
3
|
const none = new Set();
|
|
4
4
|
describe('deriveBundleSlug', () => {
|
|
5
5
|
it('kebab-cases a plain name', () => {
|
|
@@ -40,4 +40,91 @@ describe('deriveBundleSlug', () => {
|
|
|
40
40
|
expect(slug.length).toBeLessThanOrEqual(64);
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
+
describe('defaultGuidesBundleFor', () => {
|
|
44
|
+
it("keeps `my-guides` for the account's personal workspace", () => {
|
|
45
|
+
expect(defaultGuidesBundleFor({ slug: 'personal', name: 'Personal', isPersonal: true })).toEqual({ slug: 'my-guides', name: 'My guides' });
|
|
46
|
+
});
|
|
47
|
+
it("names another workspace's bundle after that workspace", () => {
|
|
48
|
+
expect(defaultGuidesBundleFor({ slug: 'acme-a1b2c3', name: 'Acme', isPersonal: false })).toEqual({ slug: 'acme-a1b2c3-guides', name: 'Acme guides' });
|
|
49
|
+
});
|
|
50
|
+
it('gives two workspaces of one account two distinct slugs', () => {
|
|
51
|
+
const personal = defaultGuidesBundleFor({
|
|
52
|
+
slug: 'personal',
|
|
53
|
+
name: 'Personal',
|
|
54
|
+
isPersonal: true,
|
|
55
|
+
});
|
|
56
|
+
const shared = defaultGuidesBundleFor({
|
|
57
|
+
slug: 'personal',
|
|
58
|
+
name: 'Personal',
|
|
59
|
+
isPersonal: false,
|
|
60
|
+
});
|
|
61
|
+
// Same workspace slug on both sides, so the personal flag is doing the
|
|
62
|
+
// whole job: a shared workspace that happens to be called "personal" still
|
|
63
|
+
// does not collide with the bundle `users.default_bundle_id` names.
|
|
64
|
+
expect(shared.slug).not.toBe(personal.slug);
|
|
65
|
+
});
|
|
66
|
+
it('stays within the 64-char cap `BundleSlugSchema` enforces', () => {
|
|
67
|
+
const { slug } = defaultGuidesBundleFor({
|
|
68
|
+
slug: 'w'.repeat(80),
|
|
69
|
+
name: 'Long',
|
|
70
|
+
isPersonal: false,
|
|
71
|
+
});
|
|
72
|
+
expect(slug.length).toBe(64);
|
|
73
|
+
expect(slug.endsWith('-guides')).toBe(true);
|
|
74
|
+
expect(slug).toMatch(/^[a-z0-9][a-z0-9-]*$/);
|
|
75
|
+
});
|
|
76
|
+
it('does not double the hyphen when truncation lands on one', () => {
|
|
77
|
+
const { slug } = defaultGuidesBundleFor({
|
|
78
|
+
// 57 characters ending in a hyphen — exactly where the cut falls.
|
|
79
|
+
slug: `${'w'.repeat(56)}-tail`,
|
|
80
|
+
name: 'Long',
|
|
81
|
+
isPersonal: false,
|
|
82
|
+
});
|
|
83
|
+
expect(slug).toBe(`${'w'.repeat(56)}-guides`);
|
|
84
|
+
expect(slug).toMatch(/^[a-z0-9][a-z0-9-]*$/);
|
|
85
|
+
});
|
|
86
|
+
it('falls back to a valid slug when a workspace slug is empty', () => {
|
|
87
|
+
expect(defaultGuidesBundleFor({ slug: '', name: 'Nameless', isPersonal: false })).toEqual({ slug: 'workspace-guides', name: 'Nameless guides' });
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('defaultGuidesBundleFor — the name a teammate ends up reading', () => {
|
|
91
|
+
// A workspace name is typed by whoever created the workspace, and a member who
|
|
92
|
+
// imports from a repo declaring it gets a bundle of their own named after it.
|
|
93
|
+
// The CLI prints bundle names straight into a terminal line, so without this
|
|
94
|
+
// the workspace's author could rewrite what a teammate reads.
|
|
95
|
+
const ESC = String.fromCharCode(27);
|
|
96
|
+
const CR = String.fromCharCode(13);
|
|
97
|
+
it('strips the ESC that arms an ANSI sequence, leaving inert text', () => {
|
|
98
|
+
// Only the ESC is removed, and only the ESC needs to be: `[31m` on its own
|
|
99
|
+
// is ordinary printable text that colours nothing and moves no cursor. The
|
|
100
|
+
// assertion says so rather than pretending the whole sequence disappears.
|
|
101
|
+
const { name } = defaultGuidesBundleFor({
|
|
102
|
+
slug: 'acme',
|
|
103
|
+
name: `Acme${ESC}[31m`,
|
|
104
|
+
isPersonal: false,
|
|
105
|
+
});
|
|
106
|
+
expect(name).not.toContain(ESC);
|
|
107
|
+
expect(name).toBe('Acme[31m guides');
|
|
108
|
+
});
|
|
109
|
+
it('strips a carriage return, which is what rewrites the line', () => {
|
|
110
|
+
const { name } = defaultGuidesBundleFor({
|
|
111
|
+
slug: 'acme',
|
|
112
|
+
name: `Acme${CR}Still delivered by another bundle: nothing`,
|
|
113
|
+
isPersonal: false,
|
|
114
|
+
});
|
|
115
|
+
expect(name).not.toContain(CR);
|
|
116
|
+
expect(name).toBe('AcmeStill delivered by another bundle: nothing guides');
|
|
117
|
+
});
|
|
118
|
+
it('collapses whitespace runs and trims, so padding cannot push text off a line', () => {
|
|
119
|
+
expect(defaultGuidesBundleFor({ slug: 'acme', name: ' Acme Team ', isPersonal: false })
|
|
120
|
+
.name).toBe('Acme Team guides');
|
|
121
|
+
});
|
|
122
|
+
it('falls back when nothing survives, rather than naming a bundle " guides"', () => {
|
|
123
|
+
expect(defaultGuidesBundleFor({ slug: 'acme', name: `${ESC}${CR}`, isPersonal: false })
|
|
124
|
+
.name).toBe('Workspace guides');
|
|
125
|
+
});
|
|
126
|
+
it('leaves an ordinary name, including non-ASCII, alone', () => {
|
|
127
|
+
expect(defaultGuidesBundleFor({ slug: 'cafe', name: 'Café Ménü', isPersonal: false }).name).toBe('Café Ménü guides');
|
|
128
|
+
});
|
|
129
|
+
});
|
|
43
130
|
//# sourceMappingURL=bundleSlug.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleSlug.test.js","sourceRoot":"","sources":["../src/bundleSlug.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"bundleSlug.test.js","sourceRoot":"","sources":["../src/bundleSlug.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAE1E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;AAE9B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,CAAC,gBAAgB,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAChE,oBAAoB,CACrB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,CAA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AAK;SAClB,CAAC,CAAA;QACF,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9B,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,CACJ,sBAAsB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aACjF,IAAI,CACR,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,CACJ,sBAAsB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aAC7E,IAAI,CACR,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CACJ,sBAAsB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CACpF,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1000,38 +1000,38 @@ export declare const UpdateContextItemBodySchema: Omit<v.ObjectSchema<{
|
|
|
1000
1000
|
readonly sourceItemIds: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.MaxLengthAction<string[], 100, undefined>]>, undefined>;
|
|
1001
1001
|
}, "itemId">;
|
|
1002
1002
|
readonly "~standard": v.StandardProps<{
|
|
1003
|
+
name?: string | undefined;
|
|
1003
1004
|
content?: string | undefined;
|
|
1004
1005
|
expectedVersion?: number | undefined;
|
|
1005
1006
|
projectId?: string | undefined;
|
|
1006
|
-
name?: string | undefined;
|
|
1007
1007
|
sourceItemIds?: string[] | undefined;
|
|
1008
1008
|
}, {
|
|
1009
|
+
name?: string | undefined;
|
|
1009
1010
|
content?: string | undefined;
|
|
1010
1011
|
expectedVersion?: number | undefined;
|
|
1011
1012
|
projectId?: string | undefined;
|
|
1012
|
-
name?: string | undefined;
|
|
1013
1013
|
sourceItemIds?: string[] | undefined;
|
|
1014
1014
|
}>;
|
|
1015
1015
|
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
1016
|
+
name?: string | undefined;
|
|
1016
1017
|
content?: string | undefined;
|
|
1017
1018
|
expectedVersion?: number | undefined;
|
|
1018
1019
|
projectId?: string | undefined;
|
|
1019
|
-
name?: string | undefined;
|
|
1020
1020
|
sourceItemIds?: string[] | undefined;
|
|
1021
1021
|
}, v.StringIssue | v.MinLengthIssue<string, 1> | v.CheckIssue<string> | v.NumberIssue | v.IntegerIssue<number> | v.ArrayIssue | v.ObjectIssue | v.MinValueIssue<number, 1> | v.MaxLengthIssue<string, 200> | v.MaxLengthIssue<string[], 100>>;
|
|
1022
1022
|
readonly "~types"?: {
|
|
1023
1023
|
readonly input: {
|
|
1024
|
+
name?: string | undefined;
|
|
1024
1025
|
content?: string | undefined;
|
|
1025
1026
|
expectedVersion?: number | undefined;
|
|
1026
1027
|
projectId?: string | undefined;
|
|
1027
|
-
name?: string | undefined;
|
|
1028
1028
|
sourceItemIds?: string[] | undefined;
|
|
1029
1029
|
};
|
|
1030
1030
|
readonly output: {
|
|
1031
|
+
name?: string | undefined;
|
|
1031
1032
|
content?: string | undefined;
|
|
1032
1033
|
expectedVersion?: number | undefined;
|
|
1033
1034
|
projectId?: string | undefined;
|
|
1034
|
-
name?: string | undefined;
|
|
1035
1035
|
sourceItemIds?: string[] | undefined;
|
|
1036
1036
|
};
|
|
1037
1037
|
readonly issue: v.StringIssue | v.MinLengthIssue<string, 1> | v.CheckIssue<string> | v.NumberIssue | v.IntegerIssue<number> | v.ArrayIssue | v.ObjectIssue | v.MinValueIssue<number, 1> | v.MaxLengthIssue<string, 200> | v.MaxLengthIssue<string[], 100>;
|
|
@@ -2822,10 +2822,10 @@ export declare function parseUpdateContextItemResponse(data: unknown): {
|
|
|
2822
2822
|
updated: boolean;
|
|
2823
2823
|
};
|
|
2824
2824
|
export declare function parseUpdateContextItemBody(data: unknown): {
|
|
2825
|
+
name?: string | undefined;
|
|
2825
2826
|
content?: string | undefined;
|
|
2826
2827
|
expectedVersion?: number | undefined;
|
|
2827
2828
|
projectId?: string | undefined;
|
|
2828
|
-
name?: string | undefined;
|
|
2829
2829
|
sourceItemIds?: string[] | undefined;
|
|
2830
2830
|
};
|
|
2831
2831
|
export declare function parseContextItemResponse(data: unknown): {
|
package/package.json
CHANGED