@sudobility/screenwriter_types 0.1.7 → 0.1.8

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/index.js CHANGED
@@ -150,14 +150,14 @@ const API_ROUTES = {
150
150
  health: r("GET", "/health", "P"),
151
151
  meGet: r("GET", "/me", "U,Kr"),
152
152
  mePatch: r("PATCH", "/me", "U"),
153
- // B2 workspaces
154
- workspacesList: r("GET", "/workspaces", "U,Kr"),
155
- workspaceGet: r("GET", "/workspaces/:wid", "U,Kr", "workspace.read"),
153
+ // B2 entities
154
+ entitiesList: r("GET", "/entities", "U,Kr"),
155
+ entityGetDetails: r("GET", "/entities/:entityId", "U,Kr", "entity.read"),
156
156
  // B2 projects
157
- projectsList: r("GET", "/workspaces/:wid/projects", "U,Kr", "project.read"),
157
+ projectsList: r("GET", "/entities/:wid/projects", "U,Kr", "project.read"),
158
158
  projectCreate: r(
159
159
  "POST",
160
- "/workspaces/:wid/projects",
160
+ "/entities/:wid/projects",
161
161
  "U,Krw",
162
162
  "project.create"
163
163
  ),
@@ -379,39 +379,34 @@ const API_ROUTES = {
379
379
  "document.edit"
380
380
  ),
381
381
  // B8 tenancy, roles, sharing. Keys (K) only read members and /me/shared; everything else is user-only (403 API_KEY_FORBIDDEN).
382
- workspaceCreate: r("POST", "/workspaces", "U"),
383
- workspaceUpdate: r("PATCH", "/workspaces/:wid", "U", "workspace.update"),
384
- workspaceDelete: r("DELETE", "/workspaces/:wid", "U", "workspace.delete"),
385
- workspaceTransfer: r(
382
+ entityCreate: r("POST", "/entities", "U"),
383
+ entityUpdate: r("PATCH", "/entities/:entityId", "U", "entity.update"),
384
+ entityDelete: r("DELETE", "/entities/:entityId", "U", "entity.delete"),
385
+ entityTransfer: r(
386
386
  "POST",
387
- "/workspaces/:wid/transfer",
387
+ "/entities/:entityId/transfer",
388
388
  "U",
389
- "workspace.transfer"
389
+ "entity.transfer"
390
390
  ),
391
- workspaceLeave: r("POST", "/workspaces/:wid/leave", "U", "workspace.leave"),
392
- workspaceUsage: r("GET", "/workspaces/:wid/usage", "U", "workspace.read"),
393
- workspaceAudit: r(
394
- "GET",
395
- "/workspaces/:wid/audit.csv",
396
- "U",
397
- "workspace.audit"
398
- ),
399
- membersList: r("GET", "/workspaces/:wid/members", "U,Kr", "members.read"),
391
+ entityLeave: r("POST", "/entities/:entityId/leave", "U", "entity.leave"),
392
+ managedEntityUsage: r("GET", "/entities/:entityId/usage", "U", "entity.read"),
393
+ entityAudit: r("GET", "/entities/:entityId/audit.csv", "U", "entity.audit"),
394
+ membersList: r("GET", "/entities/:wid/members", "U,Kr", "members.read"),
400
395
  memberUpdate: r(
401
396
  "PATCH",
402
- "/workspaces/:wid/members/:uid",
397
+ "/entities/:wid/members/:uid",
403
398
  "U",
404
399
  "members.updateRole"
405
400
  ),
406
401
  memberRemove: r(
407
402
  "DELETE",
408
- "/workspaces/:wid/members/:uid",
403
+ "/entities/:wid/members/:uid",
409
404
  "U",
410
405
  "members.remove"
411
406
  ),
412
- invitationCreateWorkspace: r(
407
+ invitationCreateEntity: r(
413
408
  "POST",
414
- "/workspaces/:wid/invitations",
409
+ "/entities/:entityId/invitations",
415
410
  "U",
416
411
  "members.invite"
417
412
  ),
@@ -427,9 +422,9 @@ const API_ROUTES = {
427
422
  "U",
428
423
  "share.manage"
429
424
  ),
430
- workspaceInvitationsList: r(
425
+ entityInvitationsList: r(
431
426
  "GET",
432
- "/workspaces/:wid/invitations",
427
+ "/entities/:entityId/invitations",
433
428
  "U",
434
429
  "members.invite"
435
430
  ),
@@ -501,7 +496,12 @@ const API_ROUTES = {
501
496
  // B10 projection-backed reads, search, reports, packets (spec 05 §6.7.1, §6.7.2, §6.12, §6.14, §6.15, §6.17, §6.18, §6.22).
502
497
  // `?source=live|snapshot:<id>|version:<id>` selects the state a read answers from. Keys (K) read all of these; the report
503
498
  // and resolve POSTs are reads, so a read-only key may send them.
504
- entitiesList: r("GET", "/documents/:did/entities", "U,Kr,L", "document.read"),
499
+ documentEntitiesList: r(
500
+ "GET",
501
+ "/documents/:did/entities",
502
+ "U,Kr,L",
503
+ "document.read"
504
+ ),
505
505
  entityGet: r(
506
506
  "GET",
507
507
  "/documents/:did/entities/:eid",
@@ -560,12 +560,7 @@ const API_ROUTES = {
560
560
  resolveBatch: r("POST", "/documents/:did/resolve", "U,Kr,L", "document.read"),
561
561
  resolveOne: r("GET", "/documents/:did/resolve", "U,Kr,L", "document.read"),
562
562
  documentSearch: r("GET", "/documents/:did/search", "U,Kr,L", "document.read"),
563
- workspaceSearch: r(
564
- "GET",
565
- "/workspaces/:wid/search",
566
- "U,Kr",
567
- "workspace.read"
568
- ),
563
+ workspaceSearch: r("GET", "/entities/:wid/search", "U,Kr", "entity.read"),
569
564
  search: r("GET", "/search", "U,Kr"),
570
565
  reportKinds: r("GET", "/reports/kinds", "U,Kr"),
571
566
  reportGet: r("GET", "/documents/:did/reports/:kind", "U,Kr,L", "reports.run"),
@@ -628,14 +623,14 @@ const API_ROUTES = {
628
623
  // trash-empty, workspace defaults and contacts are user-only (a key gets 403 API_KEY_FORBIDDEN).
629
624
  workspaceDocuments: r(
630
625
  "GET",
631
- "/workspaces/:wid/documents",
626
+ "/entities/:wid/documents",
632
627
  "U,Kr",
633
628
  "project.read"
634
629
  ),
635
- workspaceTrash: r("GET", "/workspaces/:wid/trash", "U,Kr", "project.read"),
630
+ workspaceTrash: r("GET", "/entities/:wid/trash", "U,Kr", "project.read"),
636
631
  workspaceTrashEmpty: r(
637
632
  "POST",
638
- "/workspaces/:wid/trash/empty",
633
+ "/entities/:wid/trash/empty",
639
634
  "U",
640
635
  "project.purge"
641
636
  ),
@@ -699,39 +694,39 @@ const API_ROUTES = {
699
694
  ),
700
695
  workspaceDefaultsGet: r(
701
696
  "GET",
702
- "/workspaces/:wid/defaults",
697
+ "/entities/:wid/defaults",
703
698
  "U,Kr",
704
- "workspace.read"
699
+ "entity.read"
705
700
  ),
706
701
  workspaceDefaultsSet: r(
707
702
  "PUT",
708
- "/workspaces/:wid/defaults",
703
+ "/entities/:wid/defaults",
709
704
  "U",
710
- "workspace.update"
705
+ "entity.update"
711
706
  ),
712
707
  workspaceContactsList: r(
713
708
  "GET",
714
- "/workspaces/:wid/contacts",
709
+ "/entities/:wid/contacts",
715
710
  "U",
716
- "workspace.read"
711
+ "entity.read"
717
712
  ),
718
713
  workspaceContactsCreate: r(
719
714
  "POST",
720
- "/workspaces/:wid/contacts",
715
+ "/entities/:wid/contacts",
721
716
  "U",
722
- "workspace.update"
717
+ "entity.update"
723
718
  ),
724
719
  workspaceContactUpdate: r(
725
720
  "PATCH",
726
- "/workspace-contacts/:cid",
721
+ "/entity-contacts/:cid",
727
722
  "U",
728
- "workspace.update"
723
+ "entity.update"
729
724
  ),
730
725
  workspaceContactDelete: r(
731
726
  "DELETE",
732
- "/workspace-contacts/:cid",
727
+ "/entity-contacts/:cid",
733
728
  "U",
734
- "workspace.update"
729
+ "entity.update"
735
730
  ),
736
731
  // B16 imports, exports and watermark as jobs (spec 05 §6.18). `POST /imports*` and `/uploads/state` are `Krw`; exports are `Kr` (a read key may
737
732
  // export what it can read); the watermark lookup is user-only (403 API_KEY_FORBIDDEN for a key). The synchronous
@@ -759,15 +754,15 @@ const API_ROUTES = {
759
754
  ),
760
755
  watermarkLookup: r(
761
756
  "POST",
762
- "/workspaces/:wid/watermark-lookup",
757
+ "/entities/:wid/watermark-lookup",
763
758
  "U",
764
- "workspace.audit"
759
+ "entity.audit"
765
760
  ),
766
761
  // B11 assets and R2 (spec 05 §6.13). Bytes go to object storage through presigned URLs, never through the API. Writes are `Krw`, reads `Kr`;
767
762
  // share-link readers (`L`) are not built (no `/share/:token/assets` route yet). The uploader routes check the caller is the uploader.
768
763
  assetUploadCreate: r(
769
764
  "POST",
770
- "/workspaces/:wid/assets/uploads",
765
+ "/entities/:wid/assets/uploads",
771
766
  "U,Krw",
772
767
  "assets.upload"
773
768
  ),
@@ -823,12 +818,7 @@ const API_ROUTES = {
823
818
  "U,Kr",
824
819
  "document.activity"
825
820
  ),
826
- workspaceActivity: r(
827
- "GET",
828
- "/workspaces/:wid/activity",
829
- "U",
830
- "workspace.read"
831
- ),
821
+ workspaceActivity: r("GET", "/entities/:wid/activity", "U", "entity.read"),
832
822
  notificationsList: r("GET", "/notifications", "U"),
833
823
  notificationsRead: r("POST", "/notifications/read", "U"),
834
824
  notificationDelete: r("DELETE", "/notifications/:nid", "U"),
@@ -849,9 +839,9 @@ const API_ROUTES = {
849
839
  meAiActivity: r("GET", "/me/ai-activity", "U"),
850
840
  workspaceAiActivity: r(
851
841
  "GET",
852
- "/workspaces/:wid/ai-activity",
842
+ "/entities/:wid/ai-activity",
853
843
  "U",
854
- "workspace.audit"
844
+ "entity.audit"
855
845
  ),
856
846
  aiEstimate: r("POST", "/documents/:did/ai/estimate", "U,Kr", "document.read"),
857
847
  aiReportsList: r(
@@ -908,7 +898,7 @@ const API_ROUTES = {
908
898
  adminJobKindUpdate: r("PATCH", "/admin/job-kinds/:kind", "U"),
909
899
  adminDocumentMeta: r("GET", "/admin/documents/:did/meta", "U")
910
900
  };
911
- const WORKSPACE_KINDS = ["personal", "team"];
901
+ const ENTITY_KINDS = ["personal", "team"];
912
902
  const ROLES = [
913
903
  "owner",
914
904
  "admin",
@@ -916,16 +906,16 @@ const ROLES = [
916
906
  "commenter",
917
907
  "viewer"
918
908
  ];
919
- const workspaceKindSchema = z.enum(WORKSPACE_KINDS);
909
+ const entityKindSchema = z.enum(ENTITY_KINDS);
920
910
  const roleSchema = z.enum(ROLES);
921
911
  const PERMISSION_MIN_ROLE = {
922
- "workspace.read": "viewer",
923
- "workspace.update": "admin",
924
- "workspace.aiToggle": "owner",
925
- "workspace.audit": "admin",
926
- "workspace.delete": "owner",
927
- "workspace.transfer": "owner",
928
- "workspace.leave": "viewer",
912
+ "entity.read": "viewer",
913
+ "entity.update": "admin",
914
+ "entity.aiToggle": "owner",
915
+ "entity.audit": "admin",
916
+ "entity.delete": "owner",
917
+ "entity.transfer": "owner",
918
+ "entity.leave": "viewer",
929
919
  "members.read": "viewer",
930
920
  "members.invite": "admin",
931
921
  "members.updateRole": "admin",
@@ -995,11 +985,11 @@ const hasPermission = (role, permission) => roleAtLeast(role, PERMISSION_MIN_ROL
995
985
  const requiredRoleFor = (permission) => PERMISSION_MIN_ROLE[permission];
996
986
  const SHARE_ROLES = ["admin", "writer", "commenter", "viewer"];
997
987
  const TEAM_WORKSPACE_LIMIT = 50;
998
- const workspaceCreateSchema = z.object({
988
+ const entityCreateSchema = z.object({
999
989
  name: z.string().trim().min(1).max(80),
1000
990
  avatarAssetId: z.string().min(1).nullable().optional()
1001
991
  });
1002
- const workspaceUpdateSchema = z.object({
992
+ const entityUpdateSchema = z.object({
1003
993
  name: z.string().trim().min(1).max(80).optional(),
1004
994
  avatarAssetId: z.string().min(1).nullable().optional(),
1005
995
  defaultTemplateId: z.string().min(1).nullable().optional(),
@@ -1007,11 +997,11 @@ const workspaceUpdateSchema = z.object({
1007
997
  aiEnabled: z.boolean().optional(),
1008
998
  allowPublicLinks: z.boolean().optional()
1009
999
  });
1010
- const workspaceDeleteSchema = z.object({ confirmName: z.string() });
1011
- const workspaceTransferSchema = z.object({
1000
+ const entityDeleteSchema = z.object({ confirmName: z.string() });
1001
+ const entityTransferSchema = z.object({
1012
1002
  toUserId: z.string().min(1)
1013
1003
  });
1014
- const workspaceAuditQuerySchema = z.object({
1004
+ const entityAuditQuerySchema = z.object({
1015
1005
  from: z.iso.datetime({ offset: true }).optional(),
1016
1006
  to: z.iso.datetime({ offset: true }).optional()
1017
1007
  });
@@ -1025,7 +1015,7 @@ const AUDIT_CSV_COLUMNS = [
1025
1015
  ];
1026
1016
  const AUDIT_MAX_RANGE_DAYS = 366;
1027
1017
  const memberUpdateSchema = z.object({ role: roleSchema });
1028
- const INVITATION_TARGETS = ["workspace", "project", "document"];
1018
+ const INVITATION_TARGETS = ["entity", "project", "document"];
1029
1019
  const INVITATION_TTL_DAYS = 14;
1030
1020
  const INVITATION_STATUSES = [
1031
1021
  "pending",
@@ -1092,7 +1082,7 @@ const projectUpdateSchema = z.object({
1092
1082
  color: z.string().max(32).nullable().optional(),
1093
1083
  kind: projectKindSchema.optional(),
1094
1084
  logline: z.string().max(2e3).nullable().optional(),
1095
- workspaceId: z.string().optional()
1085
+ entityId: z.string().optional()
1096
1086
  });
1097
1087
  const projectListQuerySchema = z.object({
1098
1088
  trashed: z.enum(["true", "false"]).transform((v) => v === "true").optional(),
@@ -1149,7 +1139,7 @@ const projectFolderDeleteQuerySchema = z.object({
1149
1139
  const projectPurgeSchema = z.object({ confirmName: z.string() });
1150
1140
  const projectDuplicateSchema = z.object({
1151
1141
  name: z.string().trim().min(1).max(200),
1152
- targetWorkspaceId: z.string().min(1).optional(),
1142
+ targetEntityId: z.string().min(1).optional(),
1153
1143
  includeSnapshots: z.boolean().default(false),
1154
1144
  /** Re-links the source's asset links onto the copy (B11); a no-op when the target is a different workspace. */
1155
1145
  includeAssets: z.boolean().default(false)
@@ -1182,7 +1172,7 @@ const workspaceDocumentsQuerySchema = cursorQuerySchema.extend({
1182
1172
  const TRASH_ITEM_TYPES = ["project", "document", "asset"];
1183
1173
  const trashEmptySchema = z.object({ confirm: z.string() });
1184
1174
  const purgeInputSchema = z.object({
1185
- workspaceId: z.string().optional(),
1175
+ entityId: z.string().optional(),
1186
1176
  projectId: z.string().optional(),
1187
1177
  documentId: z.string().optional()
1188
1178
  });
@@ -1236,7 +1226,7 @@ const workspaceContactsQuerySchema = cursorQuerySchema.extend({
1236
1226
  const projectDuplicateJobInputSchema = z.object({
1237
1227
  projectId: z.string().min(1),
1238
1228
  name: z.string().min(1),
1239
- targetWorkspaceId: z.string().min(1),
1229
+ targetEntityId: z.string().min(1),
1240
1230
  includeSnapshots: z.boolean(),
1241
1231
  includeAssets: z.boolean()
1242
1232
  });
@@ -1468,8 +1458,8 @@ const documentViewStatePutSchema = documentViewStateSchema.extend({
1468
1458
  });
1469
1459
  const templateListQuerySchema = z.object({
1470
1460
  category: z.string().optional(),
1471
- workspaceId: z.string().optional(),
1472
- scope: z.enum(["builtin", "user", "workspace"]).optional(),
1461
+ entityId: z.string().optional(),
1462
+ scope: z.enum(["builtin", "user", "entity"]).optional(),
1473
1463
  locale: z.string().optional()
1474
1464
  });
1475
1465
  const templateGetQuerySchema = z.object({
@@ -1482,12 +1472,12 @@ const templateBody = z.custom(
1482
1472
  }
1483
1473
  );
1484
1474
  const templateCreateSchema = z.object({
1485
- scope: z.enum(["user", "workspace"]),
1486
- workspaceId: z.string().min(1).optional(),
1475
+ scope: z.enum(["user", "entity"]),
1476
+ entityId: z.string().min(1).optional(),
1487
1477
  template: templateBody
1488
- }).refine((v) => v.scope !== "workspace" || !!v.workspaceId, {
1489
- message: "workspaceId is required for a workspace template",
1490
- path: ["workspaceId"]
1478
+ }).refine((v) => v.scope !== "entity" || !!v.entityId, {
1479
+ message: "entityId is required for a workspace template",
1480
+ path: ["entityId"]
1491
1481
  });
1492
1482
  const templateVersionCreateSchema = z.object({ template: templateBody });
1493
1483
  const templateUpdateSchema = z.object({
@@ -1503,13 +1493,13 @@ const TEMPLATE_FILE_FORMATS = [
1503
1493
  const FWTEMPLATE_FORMAT = "fadewright-template";
1504
1494
  const FWTEMPLATE_FORMAT_VERSION = 1;
1505
1495
  const templateImportSchema = z.object({
1506
- scope: z.enum(["user", "workspace"]),
1507
- workspaceId: z.string().min(1).optional(),
1496
+ scope: z.enum(["user", "entity"]),
1497
+ entityId: z.string().min(1).optional(),
1508
1498
  filename: z.string().min(1).max(255),
1509
1499
  contentB64: z.string().min(1)
1510
- }).refine((v) => v.scope !== "workspace" || !!v.workspaceId, {
1511
- message: "workspaceId is required for a workspace template",
1512
- path: ["workspaceId"]
1500
+ }).refine((v) => v.scope !== "entity" || !!v.entityId, {
1501
+ message: "entityId is required for a workspace template",
1502
+ path: ["entityId"]
1513
1503
  });
1514
1504
  const templateImportByIdSchema = z.object({
1515
1505
  importId: z.string().min(1)
@@ -1728,7 +1718,7 @@ const SEARCH_HIT_TYPES = [
1728
1718
  const csv = (v) => typeof v === "string" ? v.split(",").map((s) => s.trim()).filter(Boolean) : v;
1729
1719
  const searchQuerySchema = cursorQuerySchema.extend({
1730
1720
  q: z.string().min(1).max(200),
1731
- workspaceId: z.string().min(1).optional(),
1721
+ entityId: z.string().min(1).optional(),
1732
1722
  projectId: z.string().min(1).optional(),
1733
1723
  documentId: z.string().min(1).optional(),
1734
1724
  types: z.preprocess(csv, z.array(z.enum(SEARCH_HIT_TYPES)).min(1)).optional(),
@@ -1776,11 +1766,11 @@ const importFileFields = {
1776
1766
  const importCreateSchema = z.object({
1777
1767
  targetProjectId: z.string().min(1).optional(),
1778
1768
  templateTarget: z.object({
1779
- scope: z.enum(["user", "workspace"]),
1780
- workspaceId: z.string().min(1).optional()
1781
- }).refine((v) => v.scope !== "workspace" || !!v.workspaceId, {
1782
- message: "workspaceId is required for a workspace template",
1783
- path: ["workspaceId"]
1769
+ scope: z.enum(["user", "entity"]),
1770
+ entityId: z.string().min(1).optional()
1771
+ }).refine((v) => v.scope !== "entity" || !!v.entityId, {
1772
+ message: "entityId is required for a workspace template",
1773
+ path: ["entityId"]
1784
1774
  }).optional(),
1785
1775
  ...importFileFields
1786
1776
  }).refine(
@@ -3418,7 +3408,7 @@ const linkedToSchema = z.string().regex(
3418
3408
  "linkedTo is <entity|scene|shot|element>:<id>"
3419
3409
  );
3420
3410
  const assetListQuerySchema = cursorQuerySchema.extend({
3421
- workspaceId: z.string().min(1).optional(),
3411
+ entityId: z.string().min(1).optional(),
3422
3412
  documentId: z.string().min(1).optional(),
3423
3413
  linkedTo: linkedToSchema.optional(),
3424
3414
  role: assetRoleSchema.optional(),
@@ -4271,6 +4261,7 @@ export {
4271
4261
  DOCUMENT_LABEL_MAX_CHARS,
4272
4262
  DOCUMENT_VIEW_STATE_MAX_BYTES,
4273
4263
  ELEMENT_BATCH_MAX,
4264
+ ENTITY_KINDS,
4274
4265
  ERROR_STATUS,
4275
4266
  EXPORT_CODE_PREFIX,
4276
4267
  EXPORT_FORMAT_IDS,
@@ -4367,7 +4358,6 @@ export {
4367
4358
  VERSION_REASONS,
4368
4359
  WORKSPACE_CONTACTS_BATCH_MAX,
4369
4360
  WORKSPACE_DEFAULTS_MAX_BYTES,
4370
- WORKSPACE_KINDS,
4371
4361
  WRITING_GOALS_MAX,
4372
4362
  WRITING_GOAL_KINDS,
4373
4363
  WRITING_STATS_GRANULARITIES,
@@ -4455,8 +4445,14 @@ export {
4455
4445
  elementHistoryQuerySchema,
4456
4446
  elementsBatchRequestSchema,
4457
4447
  encodeFrame,
4448
+ entityAuditQuerySchema,
4449
+ entityCreateSchema,
4450
+ entityDeleteSchema,
4458
4451
  entityDialogueQuerySchema,
4452
+ entityKindSchema,
4459
4453
  entityListQuerySchema,
4454
+ entityTransferSchema,
4455
+ entityUpdateSchema,
4460
4456
  entityUsageQuerySchema,
4461
4457
  epochChangedPayloadSchema,
4462
4458
  errorResponse,
@@ -4605,19 +4601,13 @@ export {
4605
4601
  watermarkLookupSchema,
4606
4602
  watermarkStyleSchema,
4607
4603
  workspaceActivityQuerySchema,
4608
- workspaceAuditQuerySchema,
4609
4604
  workspaceContactInputSchema,
4610
4605
  workspaceContactPatchSchema,
4611
4606
  workspaceContactsCreateSchema,
4612
4607
  workspaceContactsQuerySchema,
4613
- workspaceCreateSchema,
4614
4608
  workspaceDefaultsPutSchema,
4615
4609
  workspaceDefaultsSchema,
4616
- workspaceDeleteSchema,
4617
4610
  workspaceDocumentsQuerySchema,
4618
- workspaceKindSchema,
4619
- workspaceTransferSchema,
4620
- workspaceUpdateSchema,
4621
4611
  writingGoalInputSchema,
4622
4612
  writingGoalsPutSchema,
4623
4613
  writingSessionSchema,