@anchrd/colab-sdk 0.1.2 → 0.1.4

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.
@@ -7,11 +7,13 @@ export declare const fileFormatExtensions: Record<FileFormat, readonly string[]>
7
7
  export declare function fileFormatOf(name: string): FileFormat | null;
8
8
  export declare const uploadTicketHeader = "x-colab-upload-ticket";
9
9
  export declare const uploadTicketLifetimeMs: number;
10
+ export declare const SourceUrl: z.ZodString;
10
11
  export declare const FileCreateInput: z.ZodObject<{
11
12
  parentId: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
12
- name: z.ZodString;
13
- mediaType: z.ZodString;
14
- size: z.ZodNumber;
13
+ name: z.ZodOptional<z.ZodString>;
14
+ mediaType: z.ZodOptional<z.ZodString>;
15
+ size: z.ZodOptional<z.ZodNumber>;
16
+ sourceUrl: z.ZodOptional<z.ZodString>;
15
17
  idempotencyKey: z.ZodString;
16
18
  }, z.core.$strict>;
17
19
  export type FileCreateInput = z.infer<typeof FileCreateInput>;
@@ -56,5 +58,7 @@ export declare const FileDetail: z.ZodObject<{
56
58
  rev: z.ZodNumber;
57
59
  text: z.ZodNullable<z.ZodString>;
58
60
  contentUrl: z.ZodURL;
61
+ sourceUrl: z.ZodOptional<z.ZodString>;
62
+ fetchedAt: z.ZodOptional<z.ZodISODateTime>;
59
63
  }, z.core.$strict>;
60
64
  export type FileDetail = z.infer<typeof FileDetail>;
@@ -92,13 +92,48 @@ const FileName = z
92
92
  .string()
93
93
  .max(200)
94
94
  .describe("The file's name with its extension, like Preisliste.pdf. It is the name the download carries; on a new file it is also the node's name.");
95
- export const FileCreateInput = z.strictObject({
95
+ // The address Colab fetches a file from itself (#556, E105). Only its shape is checked here; which
96
+ // addresses are allowed (https, public hosts, no redirect elsewhere) is decided where it is fetched.
97
+ export const SourceUrl = z
98
+ .string()
99
+ .trim()
100
+ .min(1)
101
+ .max(2048)
102
+ .describe("The https address of a public document on the web, like a PDF of a study. Colab downloads it itself and stores it like an upload; leave name optional and send no mediaType or size, Colab reads both from the answer. Only public hosts, at most 100 MB.");
103
+ export const FileCreateInput = z
104
+ .strictObject({
96
105
  // ⚠️ Required and nullable (trap C015): null is the top level of Shared, like a folder.
97
106
  parentId: NodeId.nullable().describe("The folder to put the file in, one you can write to; null puts it on the top level of Shared, visible to you until you share it."),
98
- name: FileName,
99
- mediaType: MediaType,
100
- size: Size,
107
+ // Required for an upload, optional with `sourceUrl`; the refinement below says so.
108
+ name: FileName.optional(),
109
+ mediaType: MediaType.optional(),
110
+ size: Size.optional(),
111
+ sourceUrl: SourceUrl.optional(),
101
112
  idempotencyKey: IdempotencyKey,
113
+ })
114
+ // An upload names its file, type and size; a file from an address is measured by Colab (#556).
115
+ .superRefine((input, ctx) => {
116
+ if (input.sourceUrl === undefined) {
117
+ for (const field of ["name", "mediaType", "size"]) {
118
+ if (input[field] === undefined) {
119
+ ctx.addIssue({
120
+ code: "custom",
121
+ path: [field],
122
+ message: `An upload needs ${field}; or send sourceUrl and Colab fetches the file itself.`,
123
+ });
124
+ }
125
+ }
126
+ return;
127
+ }
128
+ for (const field of ["mediaType", "size"]) {
129
+ if (input[field] !== undefined) {
130
+ ctx.addIssue({
131
+ code: "custom",
132
+ path: [field],
133
+ message: `With sourceUrl Colab reads ${field} from the answer; leave it out.`,
134
+ });
135
+ }
136
+ }
102
137
  });
103
138
  export const FileUpdateInput = z.strictObject({
104
139
  fileId: FileId.describe("The file to upload a new version of."),
@@ -136,4 +171,7 @@ export const FileDetail = z.strictObject({
136
171
  text: z.string().nullable(),
137
172
  // Where the bytes are read, with a session or a token and the right to read the file.
138
173
  contentUrl: z.url(),
174
+ // Only on a version Colab fetched from an address (#556): the address asked for and when.
175
+ sourceUrl: z.string().optional(),
176
+ fetchedAt: z.iso.datetime().optional(),
139
177
  });
@@ -34,7 +34,7 @@ export declare const resources: {
34
34
  readonly secret: "secrets";
35
35
  };
36
36
  export declare const actions: readonly ["list", "get", "create", "update", "archive", "restore", "purge"];
37
- export declare const verbs: readonly ["invite", "resend", "disable", "enable", "rotate", "share", "move", "start", "complete", "test", "revoke", "remove", "unlock"];
37
+ export declare const verbs: readonly ["invite", "resend", "disable", "enable", "rotate", "share", "move", "start", "complete", "test", "revoke", "remove", "unlock", "publish", "schedule", "unpublish"];
38
38
  export type Package = (typeof packages)[number];
39
39
  export type Resource = keyof typeof resources;
40
40
  export type Action = (typeof actions)[number] | (typeof verbs)[number];
@@ -78,6 +78,12 @@ export const verbs = [
78
78
  // (#357, E94), decided by the orchestrator: `intelligence_node_unlock`. Not `get` (it changes who
79
79
  // may read) and not `create` of a resource (the release is no thing anybody lists or names).
80
80
  "unlock",
81
+ // A connector's post at a CMS goes live, goes live later, or goes back off the site (#557, named by
82
+ // the ticket): `emdash_post_publish`, `_schedule`, `_unpublish`. Not `update`: each is its own right,
83
+ // so a role may write drafts without being able to publish them.
84
+ "publish",
85
+ "schedule",
86
+ "unpublish",
81
87
  ];
82
88
  export function isPackage(word) {
83
89
  return packages.includes(word);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchrd/colab-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Types, Zod schemas and the service client of Colab, the contract between its UI, backends and outside services.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",