@musnows/scriverse 0.6.11 → 0.7.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/app.js CHANGED
@@ -150,6 +150,11 @@ const settingSchema = z.object({
150
150
  scope: jsonObject.optional(),
151
151
  authorNote: z.string().max(20_000).optional()
152
152
  });
153
+ const globalReplaceSchema = z.object({
154
+ find: z.string().min(1).max(500),
155
+ replacement: z.string().max(200_000),
156
+ scope: z.enum(["prose", "settings", "prose-and-settings"]).default("prose")
157
+ }).strict();
153
158
  const draftSchema = z.object({
154
159
  draftType: z.enum(["prose", "setting"]),
155
160
  volumeId: identifier.nullable().optional(),
@@ -654,6 +659,9 @@ function redactTaskCharacterNames(record, permissions) {
654
659
  const { targetCharacters: _targetCharacters, ...redactedScope } = scope;
655
660
  result.scope = redactedScope;
656
661
  }
662
+ const scopeTarget = recordValue(result.scopeTarget);
663
+ if (scopeTarget?.type === "character")
664
+ delete result.scopeTarget;
657
665
  const taskResult = recordValue(result.result);
658
666
  if (taskResult) {
659
667
  const redactedTaskResult = { ...taskResult };
@@ -679,6 +687,11 @@ function redactTaskCharacterNames(record, permissions) {
679
687
  result.result = redactedTaskResult;
680
688
  }
681
689
  }
690
+ if (proseRestricted) {
691
+ const scopeTarget = recordValue(result.scopeTarget);
692
+ if (scopeTarget?.type === "chapter")
693
+ delete result.scopeTarget;
694
+ }
682
695
  if (permissions.relationships === "none") {
683
696
  const taskResult = recordValue(result.result);
684
697
  const changePreview = recordValue(taskResult?.relationshipChangePreview);
@@ -1291,6 +1304,9 @@ export function createRuntime(options) {
1291
1304
  const expectedVersionNo = parse(expectedVersionNoSchema, request.body.expectedVersionNo);
1292
1305
  data(response, store.importNovel(String(request.params.workId), originalFileName, extension.slice(1), parsed, mode, expectedVersionNo), 201);
1293
1306
  });
1307
+ app.post("/api/works/:workId/replace", (request, response) => {
1308
+ data(response, store.replaceWorkText(request.params.workId, parse(globalReplaceSchema, request.body)));
1309
+ });
1294
1310
  app.post("/api/works/:workId/volumes", (request, response) => {
1295
1311
  const input = parse(z.object({ title: nonEmpty.max(200), kind: z.enum(["main", "prequel", "extra", "epilogue", "appendix"]).optional(), description: z.string().max(5_000).optional(), keywords: z.array(nonEmpty.max(100)).max(100).optional() }), request.body);
1296
1312
  data(response, store.createVolume(request.params.workId, input), 201);