@happyvertical/smrt-content 0.40.65 → 0.40.66

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.
@@ -25,6 +25,7 @@ import {
25
25
  } from './shared.js';
26
26
 
27
27
  interface ContentContributionsRouteProps {
28
+ client?: ReturnType<typeof createClient>;
28
29
  navigation?: ContentRouteNavigationItem[];
29
30
  apiBaseUrl?: string;
30
31
  embedded?: boolean;
@@ -34,9 +35,10 @@ let {
34
35
  navigation = CONTENT_DEFAULT_ROUTE_NAVIGATION,
35
36
  apiBaseUrl = '/api/v1',
36
37
  embedded = false,
38
+ client = undefined,
37
39
  }: ContentContributionsRouteProps = $props();
38
40
 
39
- const client = $derived(createClient(apiBaseUrl));
41
+ const apiClient = $derived(client ?? createClient(apiBaseUrl));
40
42
  const { t } = useI18n();
41
43
 
42
44
  let contributionTypes = $state<ContentContributionTypeConfigStateData | null>(
@@ -79,12 +81,12 @@ function mapFilesToAttachments(files: File[]) {
79
81
  }
80
82
 
81
83
  async function loadContributionTypes() {
82
- const response = await client.contentContributions.getContributionTypes();
84
+ const response = await apiClient.contentContributions.getContributionTypes();
83
85
  contributionTypes = response.data;
84
86
  }
85
87
 
86
88
  async function loadContributors() {
87
- const response = await client.contentContributors.list();
89
+ const response = await apiClient.contentContributors.list();
88
90
  contributors = response.data;
89
91
 
90
92
  if (!portalEmail) {
@@ -93,7 +95,7 @@ async function loadContributors() {
93
95
  }
94
96
 
95
97
  async function loadInbox() {
96
- const response = await client.contentContributions.listInbox();
98
+ const response = await apiClient.contentContributions.listInbox();
97
99
  inboxContributions = response.data;
98
100
  selectedInboxId = response.data[0]?.id || null;
99
101
  }
@@ -105,7 +107,7 @@ async function loadPortal() {
105
107
  return;
106
108
  }
107
109
 
108
- const response = await client.contentContributions.listForContributor({
110
+ const response = await apiClient.contentContributions.listForContributor({
109
111
  contributorEmail: portalEmail,
110
112
  });
111
113
  portalContributions = response.data;
@@ -178,18 +180,19 @@ async function handleSubmitContribution(
178
180
  await runContributionAction(
179
181
  'Submitting contribution...',
180
182
  async () => {
181
- const response = await client.contentContributions.submitWebContribution({
182
- typeKey: payload.typeKey,
183
- contributorEmail: payload.contributorEmail,
184
- contributorName: payload.contributorName,
185
- title: payload.title || null,
186
- description: payload.description || null,
187
- body: payload.body || null,
188
- attachments: mapFilesToAttachments(payload.files),
189
- metadata: {
190
- source: 'content-route',
191
- },
192
- });
183
+ const response =
184
+ await apiClient.contentContributions.submitWebContribution({
185
+ typeKey: payload.typeKey,
186
+ contributorEmail: payload.contributorEmail,
187
+ contributorName: payload.contributorName,
188
+ title: payload.title || null,
189
+ description: payload.description || null,
190
+ body: payload.body || null,
191
+ attachments: mapFilesToAttachments(payload.files),
192
+ metadata: {
193
+ source: 'content-route',
194
+ },
195
+ });
193
196
 
194
197
  portalEmail = payload.contributorEmail || portalEmail;
195
198
  const contribution =
@@ -205,7 +208,7 @@ async function handleSubmitContribution(
205
208
 
206
209
  async function handleWithdraw(contribution: ContentContributionData) {
207
210
  await runContributionAction('Withdrawing contribution...', async () => {
208
- await client.contentContributions.withdraw(contribution.id || '', {
211
+ await apiClient.contentContributions.withdraw(contribution.id || '', {
209
212
  reason: 'Withdrawn from the contribution route.',
210
213
  });
211
214
  notice = `Withdrew "${contribution.title || contribution.id}".`;
@@ -217,7 +220,7 @@ async function handleApprove(
217
220
  options: { targetStatus: 'draft' | 'review'; note: string },
218
221
  ) {
219
222
  await runContributionAction('Approving contribution...', async () => {
220
- await client.contentContributions.approve(contribution.id || '', {
223
+ await apiClient.contentContributions.approve(contribution.id || '', {
221
224
  editorNote: options.note,
222
225
  targetStatus: options.targetStatus,
223
226
  });
@@ -230,7 +233,7 @@ async function handleRequestChanges(
230
233
  options: { note: string },
231
234
  ) {
232
235
  await runContributionAction('Requesting changes...', async () => {
233
- await client.contentContributions.requestChanges(contribution.id || '', {
236
+ await apiClient.contentContributions.requestChanges(contribution.id || '', {
234
237
  editorNote: options.note,
235
238
  });
236
239
  notice = `Requested changes for "${contribution.title || contribution.id}".`;
@@ -242,7 +245,7 @@ async function handleReject(
242
245
  options: { note: string },
243
246
  ) {
244
247
  await runContributionAction('Rejecting contribution...', async () => {
245
- await client.contentContributions.reject(contribution.id || '', {
248
+ await apiClient.contentContributions.reject(contribution.id || '', {
246
249
  editorNote: options.note,
247
250
  });
248
251
  notice = `Rejected "${contribution.title || contribution.id}".`;
@@ -254,9 +257,9 @@ async function handleSaveType(data: Partial<ContentContributionTypeData>) {
254
257
  'Saving contribution type...',
255
258
  async () => {
256
259
  if (data.id) {
257
- await client.contentContributionTypes.update(data.id, data);
260
+ await apiClient.contentContributionTypes.update(data.id, data);
258
261
  } else {
259
- await client.contentContributionTypes.create(data);
262
+ await apiClient.contentContributionTypes.create(data);
260
263
  }
261
264
  notice = `Saved contribution type "${data.label || data.key}".`;
262
265
  },
@@ -268,7 +271,7 @@ async function handleDeleteType(data: Partial<ContentContributionTypeData>) {
268
271
  await runContributionAction(
269
272
  'Deleting contribution type...',
270
273
  async () => {
271
- await client.contentContributionTypes.delete(data.id || '');
274
+ await apiClient.contentContributionTypes.delete(data.id || '');
272
275
  notice = `Deleted contribution type "${data.label || data.key}".`;
273
276
  },
274
277
  { refreshTypes: true },
@@ -280,9 +283,9 @@ async function handleSaveContributor(data: Partial<ContentContributorData>) {
280
283
  'Saving contributor...',
281
284
  async () => {
282
285
  if (data.id) {
283
- await client.contentContributors.update(data.id, data);
286
+ await apiClient.contentContributors.update(data.id, data);
284
287
  } else {
285
- await client.contentContributors.create(data);
288
+ await apiClient.contentContributors.create(data);
286
289
  }
287
290
  portalEmail = data.email || portalEmail;
288
291
  notice = `Saved contributor "${data.name || data.email}".`;
@@ -295,7 +298,7 @@ async function handleDeleteContributor(data: Partial<ContentContributorData>) {
295
298
  await runContributionAction(
296
299
  'Deleting contributor...',
297
300
  async () => {
298
- await client.contentContributors.delete(data.id || '');
301
+ await apiClient.contentContributors.delete(data.id || '');
299
302
  if (portalEmail === data.email) {
300
303
  portalEmail = '';
301
304
  }
@@ -1,5 +1,7 @@
1
+ import { createClient } from '../../mock-smrt-client.js';
1
2
  import { type ContentRouteNavigationItem } from './shared.js';
2
3
  interface ContentContributionsRouteProps {
4
+ client?: ReturnType<typeof createClient>;
3
5
  navigation?: ContentRouteNavigationItem[];
4
6
  apiBaseUrl?: string;
5
7
  embedded?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentContributionsRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentContributionsRoute.svelte.ts"],"names":[],"mappings":"AAsBA,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AAGrB,UAAU,8BAA8B;IACtC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA0cD,QAAA,MAAM,yBAAyB,oEAAwC,CAAC;AACxE,KAAK,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC9E,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"ContentContributionsRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentContributionsRoute.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,YAAY,EACb,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AAGrB,UAAU,8BAA8B;IACtC,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA4cD,QAAA,MAAM,yBAAyB,oEAAwC,CAAC;AACxE,KAAK,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC9E,eAAe,yBAAyB,CAAC"}
@@ -12,6 +12,7 @@ import {
12
12
  } from './shared.js';
13
13
 
14
14
  interface ContentFactsRouteProps {
15
+ client?: ReturnType<typeof createClient>;
15
16
  navigation?: ContentRouteNavigationItem[];
16
17
  apiBaseUrl?: string;
17
18
  createHref?: string | null;
@@ -23,9 +24,10 @@ let {
23
24
  apiBaseUrl = '/api/v1',
24
25
  createHref = null,
25
26
  embedded = false,
27
+ client = undefined,
26
28
  }: ContentFactsRouteProps = $props();
27
29
 
28
- const client = $derived(createClient(apiBaseUrl));
30
+ const apiClient = $derived(client ?? createClient(apiBaseUrl));
29
31
  const { t } = useI18n();
30
32
 
31
33
  let query = $state('');
@@ -61,7 +63,7 @@ async function loadFacts() {
61
63
  refreshing = true;
62
64
 
63
65
  try {
64
- const response = await client.contents.browseFacts(query, {
66
+ const response = await apiClient.contents.browseFacts(query, {
65
67
  limit: 100,
66
68
  latestOnly,
67
69
  includeSuperseded,
@@ -1,5 +1,7 @@
1
+ import { createClient } from '../../mock-smrt-client.js';
1
2
  import { type ContentRouteNavigationItem } from './shared.js';
2
3
  interface ContentFactsRouteProps {
4
+ client?: ReturnType<typeof createClient>;
3
5
  navigation?: ContentRouteNavigationItem[];
4
6
  apiBaseUrl?: string;
5
7
  createHref?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentFactsRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentFactsRoute.svelte.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AAGrB,UAAU,sBAAsB;IAC9B,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAsND,QAAA,MAAM,iBAAiB,4DAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"ContentFactsRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentFactsRoute.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AAGrB,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuND,QAAA,MAAM,iBAAiB,4DAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { useI18n } from '@happyvertical/smrt-ui/i18n';
3
3
  import ContentGovernanceManager from '../components/ContentGovernanceManager.svelte';
4
+ import type { ContentGovernanceManagerClient } from '../governance-manager-client.js';
4
5
  import { M } from '../i18n.routes.js';
5
6
  import {
6
7
  CONTENT_DEFAULT_ROUTE_NAVIGATION,
@@ -10,12 +11,14 @@ import {
10
11
  } from './shared.js';
11
12
 
12
13
  interface ContentGovernanceRouteProps {
14
+ client?: ContentGovernanceManagerClient;
13
15
  navigation?: ContentRouteNavigationItem[];
14
16
  apiBaseUrl?: string;
15
17
  embedded?: boolean;
16
18
  }
17
19
 
18
20
  let {
21
+ client = undefined,
19
22
  navigation = CONTENT_DEFAULT_ROUTE_NAVIGATION,
20
23
  apiBaseUrl = '/api/v1',
21
24
  embedded = false,
@@ -66,7 +69,7 @@ const { t } = useI18n();
66
69
  </section>
67
70
 
68
71
  <section class="panel">
69
- <ContentGovernanceManager {apiBaseUrl} />
72
+ <ContentGovernanceManager {apiBaseUrl} {client} />
70
73
  </section>
71
74
  </main>
72
75
  </div>
@@ -1,5 +1,7 @@
1
+ import type { ContentGovernanceManagerClient } from '../governance-manager-client.js';
1
2
  import { type ContentRouteNavigationItem } from './shared.js';
2
3
  interface ContentGovernanceRouteProps {
4
+ client?: ContentGovernanceManagerClient;
3
5
  navigation?: ContentRouteNavigationItem[];
4
6
  apiBaseUrl?: string;
5
7
  embedded?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentGovernanceRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentGovernanceRoute.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,0BAA0B,EAEhC,MAAM,aAAa,CAAC;AAGrB,UAAU,2BAA2B;IACnC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiED,QAAA,MAAM,sBAAsB,iEAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"ContentGovernanceRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentGovernanceRoute.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAGL,KAAK,0BAA0B,EAEhC,MAAM,aAAa,CAAC;AAGrB,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,8BAA8B,CAAC;IACxC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAmED,QAAA,MAAM,sBAAsB,iEAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
@@ -17,6 +17,7 @@ import {
17
17
  } from './shared.js';
18
18
 
19
19
  interface ContentWorkspaceRouteProps {
20
+ client?: ReturnType<typeof createClient>;
20
21
  navigation?: ContentRouteNavigationItem[];
21
22
  apiBaseUrl?: string;
22
23
  getPublishedHref?: (content: ContentData) => string | null;
@@ -36,9 +37,10 @@ let {
36
37
  apiBaseUrl = '/api/v1',
37
38
  getPublishedHref = defaultGetPublishedHref,
38
39
  embedded = false,
40
+ client = undefined,
39
41
  }: ContentWorkspaceRouteProps = $props();
40
42
 
41
- const client = $derived(createClient(apiBaseUrl));
43
+ const apiClient = $derived(client ?? createClient(apiBaseUrl));
42
44
  const governanceHref = $derived(
43
45
  getContentRouteHref(navigation, CONTENT_ROUTE_IDS.governance),
44
46
  );
@@ -64,7 +66,7 @@ onMount(async () => {
64
66
  async function loadContents() {
65
67
  try {
66
68
  loading = true;
67
- const response = await client.contents.list();
69
+ const response = await apiClient.contents.list();
68
70
  contents = response.data;
69
71
  error = null;
70
72
  } catch (err) {
@@ -79,7 +81,7 @@ async function handleSaveContent(formData: ContentData) {
79
81
  try {
80
82
  const currentEditingContent = editingContent;
81
83
  if (currentEditingContent?.id) {
82
- const response = await client.contents.update(
84
+ const response = await apiClient.contents.update(
83
85
  currentEditingContent.id,
84
86
  formData,
85
87
  );
@@ -94,7 +96,7 @@ async function handleSaveContent(formData: ContentData) {
94
96
  contents = [response.data, ...contents];
95
97
  }
96
98
  } else {
97
- const response = await client.contents.create(formData);
99
+ const response = await apiClient.contents.create(formData);
98
100
  contents = [response.data, ...contents];
99
101
  }
100
102
 
@@ -107,7 +109,7 @@ async function handleSaveContent(formData: ContentData) {
107
109
 
108
110
  async function handleDeleteContent(content: ContentData) {
109
111
  try {
110
- await client.contents.delete(content.id || '');
112
+ await apiClient.contents.delete(content.id || '');
111
113
  contents = contents.filter((item) => item.id !== content.id);
112
114
  } catch (err) {
113
115
  error =
@@ -117,9 +119,9 @@ async function handleDeleteContent(content: ContentData) {
117
119
 
118
120
  async function handleEditContent(content: ContentData) {
119
121
  try {
120
- const response = await client.contents.get(content.id || '');
122
+ const response = await apiClient.contents.get(content.id || '');
121
123
  editingContent = response.data;
122
- const governance = await client.contents.resolveGovernance({
124
+ const governance = await apiClient.contents.resolveGovernance({
123
125
  type: response.data.type,
124
126
  variant: response.data.variant,
125
127
  });
@@ -208,6 +210,9 @@ function closeForms() {
208
210
  {apiBaseUrl}
209
211
  content={editingContent || undefined}
210
212
  contentId={editingContent?.id || 'new'}
213
+ agentChatEnabled={!embedded}
214
+ agentChatNotice="Run the content package dev server to use live editor agent chat from this route."
215
+ showGovernancePanel={!embedded}
211
216
  onSave={handleSaveContent}
212
217
  onCancel={closeForms}
213
218
  />
@@ -216,6 +221,8 @@ function closeForms() {
216
221
  {apiBaseUrl}
217
222
  content={editingContent || undefined}
218
223
  contentId={editingContent?.id || 'new'}
224
+ agentChatEnabled={!embedded}
225
+ agentChatNotice="Run the content package dev server to use live editor agent chat from this route."
219
226
  onSave={handleSaveContent}
220
227
  onCancel={closeForms}
221
228
  />
@@ -1,6 +1,8 @@
1
1
  import type { ContentData } from '../../mock-smrt-client.js';
2
+ import { createClient } from '../../mock-smrt-client.js';
2
3
  import { type ContentRouteNavigationItem } from './shared.js';
3
4
  interface ContentWorkspaceRouteProps {
5
+ client?: ReturnType<typeof createClient>;
4
6
  navigation?: ContentRouteNavigationItem[];
5
7
  apiBaseUrl?: string;
6
8
  getPublishedHref?: (content: ContentData) => string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentWorkspaceRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentWorkspaceRoute.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,OAAO,EAIL,KAAK,0BAA0B,EAEhC,MAAM,aAAa,CAAC;AAGrB,UAAU,0BAA0B;IAClC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA4ND,QAAA,MAAM,qBAAqB,gEAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"ContentWorkspaceRoute.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/routes/ContentWorkspaceRoute.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAIL,KAAK,0BAA0B,EAEhC,MAAM,aAAa,CAAC;AAGrB,UAAU,0BAA0B;IAClC,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6ND,QAAA,MAAM,qBAAqB,gEAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}