@eltjs/sdk-microsoft-sharepoint 0.0.0-stage → 0.3.11

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.
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ import { deleted, identitySet, timestamp } from './graph-values.js';
3
+ // A delta query gives only the properties it selects. It selects no
4
+ // @microsoft.graph.downloadUrl: that pre-signed URL changes at every read.
5
+ export const DRIVE_ITEM_FIELDS = [
6
+ 'id',
7
+ 'name',
8
+ 'size',
9
+ 'file',
10
+ 'folder',
11
+ 'root',
12
+ 'deleted',
13
+ 'parentReference',
14
+ 'webUrl',
15
+ 'createdDateTime',
16
+ 'lastModifiedDateTime',
17
+ 'createdBy',
18
+ 'lastModifiedBy',
19
+ 'eTag',
20
+ 'cTag',
21
+ 'sharepointIds',
22
+ ].join(',');
23
+ const parentReference = z.object({
24
+ driveId: z.string(),
25
+ // The root folder of a drive has no parent ID.
26
+ id: z.string().optional(),
27
+ // Graph documents that a delta can leave the path out.
28
+ path: z.string().optional(),
29
+ });
30
+ /** A file or a folder of a drive, as it is now. */
31
+ const presentDriveItem = z.object({
32
+ id: z.string(),
33
+ name: z.string(),
34
+ size: z.number(),
35
+ file: z
36
+ .object({
37
+ mimeType: z.string(),
38
+ hashes: z
39
+ .object({
40
+ quickXorHash: z.string().optional(),
41
+ sha1Hash: z.string().optional(),
42
+ sha256Hash: z.string().optional(),
43
+ })
44
+ .optional(),
45
+ })
46
+ .optional(),
47
+ folder: z.object({ childCount: z.number() }).optional(),
48
+ /** Present only on the root folder of the drive. */
49
+ root: z.object({}).optional(),
50
+ deleted: z.never().optional(),
51
+ parentReference,
52
+ webUrl: z.string(),
53
+ createdDateTime: timestamp,
54
+ lastModifiedDateTime: timestamp,
55
+ createdBy: identitySet.optional(),
56
+ lastModifiedBy: identitySet.optional(),
57
+ // The root folder of a drive has none. A delta repeats the root on each of
58
+ // its pages (live, 2026-11-17: 31 times over the 31 pages of one drive).
59
+ eTag: z.string().optional(),
60
+ // Graph documents that a delta of SharePoint can leave out the cTag.
61
+ cTag: z.string().optional(),
62
+ sharepointIds: z.object({ listItemId: z.string().optional() }).optional(),
63
+ });
64
+ /** A file or a folder that was deleted after the link that the delta started at. */
65
+ const deletedDriveItem = z.object({
66
+ id: z.string(),
67
+ deleted,
68
+ parentReference: parentReference.optional(),
69
+ });
70
+ export const driveItem = z.union([presentDriveItem, deletedDriveItem]);
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export declare const DRIVE_FIELDS = "id,name,description,driveType,webUrl,createdDateTime,lastModifiedDateTime";
3
+ /** A document library of a site, as Graph shows it: a drive of files and folders. */
4
+ export declare const drive: z.ZodObject<{
5
+ id: z.ZodString;
6
+ name: z.ZodString;
7
+ description: z.ZodOptional<z.ZodString>;
8
+ driveType: z.ZodString;
9
+ webUrl: z.ZodString;
10
+ createdDateTime: z.ZodISODateTime;
11
+ lastModifiedDateTime: z.ZodISODateTime;
12
+ }, z.core.$strip>;
13
+ export type Drive = z.infer<typeof drive>;
package/dist/drive.js ADDED
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import { timestamp } from './graph-values.js';
3
+ export const DRIVE_FIELDS = 'id,name,description,driveType,webUrl,createdDateTime,lastModifiedDateTime';
4
+ /** A document library of a site, as Graph shows it: a drive of files and folders. */
5
+ export const drive = z.object({
6
+ id: z.string(),
7
+ name: z.string(),
8
+ description: z.string().optional(),
9
+ driveType: z.string(),
10
+ webUrl: z.string(),
11
+ createdDateTime: timestamp,
12
+ lastModifiedDateTime: timestamp,
13
+ });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Graph refused a request. `code` is Graph's error code, such as
3
+ * `accessDenied` or `invalidRequest`, when the body names one.
4
+ */
5
+ export declare class GraphError extends Error {
6
+ readonly name = "GraphError";
7
+ readonly status: number;
8
+ readonly code: string | undefined;
9
+ constructor(status: number, code: string | undefined, message: string);
10
+ static of(response: Response): Promise<GraphError>;
11
+ }
12
+ /**
13
+ * Graph refused the token of the app (401) or its access (403). A
14
+ * Sites.Selected app reads only the sites that an administrator granted to
15
+ * it, and Graph answers 403 for each other site.
16
+ */
17
+ export declare class SharePointAccessError extends Error {
18
+ readonly name = "SharePointAccessError";
19
+ /** The site URL, site ID or drive that the call named. */
20
+ readonly resource: string;
21
+ constructor(resource: string, options: {
22
+ cause: GraphError;
23
+ });
24
+ }
25
+ /**
26
+ * Microsoft Entra ID refused the client ID or the client secret of the app,
27
+ * so no token was given: a wrong or expired secret, or an app that the tenant
28
+ * does not have. `cause` is MSAL's error, which names the AADSTS code.
29
+ */
30
+ export declare class SharePointCredentialsError extends Error {
31
+ readonly name = "SharePointCredentialsError";
32
+ constructor(options: {
33
+ cause: Error;
34
+ });
35
+ }
36
+ /** No site is at the URL: Graph answered 404. */
37
+ export declare class SharePointSiteNotFoundError extends Error {
38
+ readonly name = "SharePointSiteNotFoundError";
39
+ readonly url: string;
40
+ constructor(url: string, options: {
41
+ cause: GraphError;
42
+ });
43
+ }
44
+ /**
45
+ * Graph no longer serves the changes after a delta link: it answered 410
46
+ * Gone. Read the collection again from the start, with no link.
47
+ */
48
+ export declare class DeltaExpiredError extends Error {
49
+ readonly name = "DeltaExpiredError";
50
+ constructor(options: {
51
+ cause: GraphError;
52
+ });
53
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ // The body of every Graph error (Microsoft Graph error responses).
3
+ const graphErrorBody = z.object({
4
+ error: z.object({ code: z.string(), message: z.string() }),
5
+ });
6
+ /**
7
+ * Graph refused a request. `code` is Graph's error code, such as
8
+ * `accessDenied` or `invalidRequest`, when the body names one.
9
+ */
10
+ export class GraphError extends Error {
11
+ name = 'GraphError';
12
+ status;
13
+ code;
14
+ constructor(status, code, message) {
15
+ super(message);
16
+ this.status = status;
17
+ this.code = code;
18
+ }
19
+ static async of(response) {
20
+ const body = graphErrorBody.safeParse(await response.json().catch(() => undefined));
21
+ const code = body.success ? body.data.error.code : undefined;
22
+ const said = body.success ? `: ${body.data.error.message}` : '';
23
+ return new GraphError(response.status, code, `Graph answered ${response.status} ${code ?? response.statusText} to GET ${new URL(response.url).pathname}${said}`);
24
+ }
25
+ }
26
+ /**
27
+ * Graph refused the token of the app (401) or its access (403). A
28
+ * Sites.Selected app reads only the sites that an administrator granted to
29
+ * it, and Graph answers 403 for each other site.
30
+ */
31
+ export class SharePointAccessError extends Error {
32
+ name = 'SharePointAccessError';
33
+ /** The site URL, site ID or drive that the call named. */
34
+ resource;
35
+ constructor(resource, options) {
36
+ super(`SharePoint refused access to ${resource} with ${options.cause.status}. The app needs a Sites.Selected read grant on the site.`, options);
37
+ this.resource = resource;
38
+ }
39
+ }
40
+ /**
41
+ * Microsoft Entra ID refused the client ID or the client secret of the app,
42
+ * so no token was given: a wrong or expired secret, or an app that the tenant
43
+ * does not have. `cause` is MSAL's error, which names the AADSTS code.
44
+ */
45
+ export class SharePointCredentialsError extends Error {
46
+ name = 'SharePointCredentialsError';
47
+ constructor(options) {
48
+ super('Microsoft Entra ID refused the client ID or secret of the app. Check them, or ask the administrator for a new secret.', options);
49
+ }
50
+ }
51
+ /** No site is at the URL: Graph answered 404. */
52
+ export class SharePointSiteNotFoundError extends Error {
53
+ name = 'SharePointSiteNotFoundError';
54
+ url;
55
+ constructor(url, options) {
56
+ super(`No SharePoint site is at ${url}.`, options);
57
+ this.url = url;
58
+ }
59
+ }
60
+ /**
61
+ * Graph no longer serves the changes after a delta link: it answered 410
62
+ * Gone. Read the collection again from the start, with no link.
63
+ */
64
+ export class DeltaExpiredError extends Error {
65
+ name = 'DeltaExpiredError';
66
+ constructor(options) {
67
+ super('Graph no longer serves the changes after this delta link. Read the collection again from the start.', options);
68
+ }
69
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The milliseconds to wait before the request that `response` refused is
3
+ * sent again, or undefined when it is not sent again. `attempt` counts the
4
+ * tries so far, the refused one included; `now` is the wall time of the
5
+ * caller's clock.
6
+ */
7
+ export declare function retryWait(response: Response, attempt: number, now: number): number | undefined;
@@ -0,0 +1,47 @@
1
+ import { Backoff } from '@zukhruf/async';
2
+ // Copied from packages/google-auth/src/retry.ts (strike 2 of the Rule of
3
+ // Three): docs/copied-from-google-auth-retry.md lists what changed. Mirror
4
+ // every fix in both copies and name both files in the commit.
5
+ /** Total tries, including the first. */
6
+ const ATTEMPTS = 5;
7
+ /**
8
+ * The longest single wait. A Retry-After beyond it fails the call at once
9
+ * rather than stalling a pipeline for longer than anyone would wait.
10
+ */
11
+ const MAX_DELAY_MS = 60_000;
12
+ // Graph's throttling answers: 429 Too Many Requests, and 503 and 504 when the
13
+ // service is busy (Microsoft Graph throttling guidance).
14
+ const TRANSIENT_STATUSES = [429, 503, 504];
15
+ // Without a Retry-After the wait doubles from 1 s to at most 60 s with full
16
+ // jitter, so concurrent callers do not retry in lockstep.
17
+ const backoff = new Backoff({
18
+ initial: 1000,
19
+ multiplier: 2,
20
+ max: MAX_DELAY_MS,
21
+ jitter: { kind: 'full' },
22
+ });
23
+ /**
24
+ * The milliseconds to wait before the request that `response` refused is
25
+ * sent again, or undefined when it is not sent again. `attempt` counts the
26
+ * tries so far, the refused one included; `now` is the wall time of the
27
+ * caller's clock.
28
+ */
29
+ export function retryWait(response, attempt, now) {
30
+ if (attempt >= ATTEMPTS || !TRANSIENT_STATUSES.includes(response.status))
31
+ return undefined;
32
+ const asked = retryAfterMs(response.headers.get('retry-after'), now);
33
+ if (asked === undefined)
34
+ return backoff.duration(attempt - 1);
35
+ return asked <= MAX_DELAY_MS ? asked : undefined;
36
+ }
37
+ // Retry-After is either whole seconds or an HTTP date (RFC 9110 section
38
+ // 10.2.3), which counts from now.
39
+ function retryAfterMs(header, now) {
40
+ const value = header?.trim();
41
+ if (!value)
42
+ return undefined;
43
+ if (/^\d+$/.test(value))
44
+ return Number(value) * 1000;
45
+ const at = Date.parse(value);
46
+ return Number.isFinite(at) ? Math.max(0, at - now) : undefined;
47
+ }
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ /** A Graph timestamp: ISO 8601 in UTC, such as `2026-11-17T09:30:00Z`. */
3
+ export declare const timestamp: z.ZodISODateTime;
4
+ /** Graph's identitySet: the user, app or group that created or changed an item. */
5
+ export declare const identitySet: z.ZodObject<{
6
+ user: z.ZodOptional<z.ZodObject<{
7
+ id: z.ZodOptional<z.ZodString>;
8
+ displayName: z.ZodOptional<z.ZodString>;
9
+ email: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ application: z.ZodOptional<z.ZodObject<{
12
+ id: z.ZodOptional<z.ZodString>;
13
+ displayName: z.ZodOptional<z.ZodString>;
14
+ email: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>>;
16
+ group: z.ZodOptional<z.ZodObject<{
17
+ id: z.ZodOptional<z.ZodString>;
18
+ displayName: z.ZodOptional<z.ZodString>;
19
+ email: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>>;
21
+ }, z.core.$strip>;
22
+ /** Graph's `deleted` facet: the item was deleted after the last delta link. */
23
+ export declare const deleted: z.ZodObject<{
24
+ state: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /** A Graph timestamp: ISO 8601 in UTC, such as `2026-11-17T09:30:00Z`. */
3
+ export const timestamp = z.iso.datetime();
4
+ const identity = z.object({
5
+ id: z.string().optional(),
6
+ displayName: z.string().optional(),
7
+ email: z.string().optional(),
8
+ });
9
+ /** Graph's identitySet: the user, app or group that created or changed an item. */
10
+ export const identitySet = z.object({
11
+ user: identity.optional(),
12
+ application: identity.optional(),
13
+ group: identity.optional(),
14
+ });
15
+ /** Graph's `deleted` facet: the item was deleted after the last delta link. */
16
+ export const deleted = z.object({ state: z.string().optional() });
@@ -0,0 +1,30 @@
1
+ import { type WallClock } from '@zukhruf/async';
2
+ import { z } from 'zod';
3
+ /**
4
+ * An app registration of Microsoft Entra ID and its client secret, and the
5
+ * clock that the retries wait on: `globalThis` in production, a fake clock in
6
+ * a test.
7
+ */
8
+ export type SharePointClientOptions = {
9
+ readonly tenantId: string;
10
+ readonly clientId: string;
11
+ readonly clientSecret: string;
12
+ readonly clock: WallClock;
13
+ };
14
+ /**
15
+ * The GET requests of one app to Microsoft Graph. MSAL gets the app-only
16
+ * token with the client credentials and keeps it until it expires.
17
+ */
18
+ export declare class Graph {
19
+ #private;
20
+ constructor({ tenantId, clientId, clientSecret, clock, }: SharePointClientOptions);
21
+ /**
22
+ * A GET of `target`: a path under v1.0, or a link that Graph gave, such as
23
+ * a nextLink. A 401 or 403 fails with a SharePointAccessError that names
24
+ * `resource`; every other refusal fails with a GraphError.
25
+ */
26
+ get(target: string, resource: string, signal: AbortSignal): Promise<Response>;
27
+ json<T>(target: string, schema: z.ZodType<T>, resource: string, signal: AbortSignal): Promise<T>;
28
+ /** Every item of a collection, page after page of `@odata.nextLink`. */
29
+ collection<T>(path: string, item: z.ZodType<T>, resource: string, signal: AbortSignal): Promise<readonly T[]>;
30
+ }
package/dist/graph.js ADDED
@@ -0,0 +1,97 @@
1
+ import { ConfidentialClientApplication, ServerError } from '@azure/msal-node';
2
+ import { delay, untilAborted } from '@zukhruf/async';
3
+ import { z } from 'zod';
4
+ import { GraphError, SharePointAccessError, SharePointCredentialsError, } from './errors.js';
5
+ import { retryWait } from './graph-retry.js';
6
+ const GRAPH = 'https://graph.microsoft.com/v1.0';
7
+ const refusedCredentials = new Set([
8
+ 'invalid_client',
9
+ 'unauthorized_client',
10
+ ]);
11
+ /**
12
+ * The GET requests of one app to Microsoft Graph. MSAL gets the app-only
13
+ * token with the client credentials and keeps it until it expires.
14
+ */
15
+ export class Graph {
16
+ #app;
17
+ #clock;
18
+ constructor({ tenantId, clientId, clientSecret, clock, }) {
19
+ this.#app = new ConfidentialClientApplication({
20
+ auth: {
21
+ clientId,
22
+ clientSecret,
23
+ authority: `https://login.microsoftonline.com/${tenantId}`,
24
+ },
25
+ });
26
+ this.#clock = clock;
27
+ }
28
+ /**
29
+ * A GET of `target`: a path under v1.0, or a link that Graph gave, such as
30
+ * a nextLink. A 401 or 403 fails with a SharePointAccessError that names
31
+ * `resource`; every other refusal fails with a GraphError.
32
+ */
33
+ async get(target, resource, signal) {
34
+ const url = graphUrl(target);
35
+ for (let attempt = 1;; attempt += 1) {
36
+ const response = await fetch(url, {
37
+ headers: { authorization: `Bearer ${await this.#token(signal)}` },
38
+ signal,
39
+ });
40
+ if (response.ok)
41
+ return response;
42
+ const wait = retryWait(response, attempt, this.#clock.Date.now());
43
+ if (wait === undefined) {
44
+ const cause = await GraphError.of(response);
45
+ if (cause.status === 401 || cause.status === 403)
46
+ throw new SharePointAccessError(resource, { cause });
47
+ throw cause;
48
+ }
49
+ await response.body?.cancel();
50
+ await delay(wait, { clock: this.#clock, signal });
51
+ }
52
+ }
53
+ async json(target, schema, resource, signal) {
54
+ return schema.parse(await (await this.get(target, resource, signal)).json());
55
+ }
56
+ /** Every item of a collection, page after page of `@odata.nextLink`. */
57
+ async collection(path, item, resource, signal) {
58
+ const page = z.object({
59
+ value: z.array(item),
60
+ '@odata.nextLink': z.string().optional(),
61
+ });
62
+ const items = [];
63
+ let next = path;
64
+ while (next !== undefined) {
65
+ const body = await this.json(next, page, resource, signal);
66
+ items.push(...body.value);
67
+ next = body['@odata.nextLink'];
68
+ }
69
+ return items;
70
+ }
71
+ async #token(signal) {
72
+ const result = await untilAborted(this.#app
73
+ .acquireTokenByClientCredential({
74
+ scopes: ['https://graph.microsoft.com/.default'],
75
+ })
76
+ .catch((error) => {
77
+ // A wrong secret answers invalid_client (AADSTS7000215, live
78
+ // 2026-11-17); an app the tenant lacks, unauthorized_client.
79
+ if (error instanceof ServerError &&
80
+ refusedCredentials.has(error.errorCode))
81
+ throw new SharePointCredentialsError({ cause: error });
82
+ throw error;
83
+ }), signal);
84
+ if (result === null)
85
+ throw new Error('MSAL gave no token for the client credentials');
86
+ return result.accessToken;
87
+ }
88
+ }
89
+ // The bearer token goes only to Graph: a link from anywhere else is refused
90
+ // before a request is sent.
91
+ function graphUrl(target) {
92
+ if (target.startsWith('/'))
93
+ return `${GRAPH}${target}`;
94
+ if (target.startsWith(`${GRAPH}/`))
95
+ return target;
96
+ throw new TypeError(`${target} is not a Microsoft Graph v1.0 link`);
97
+ }
@@ -0,0 +1,12 @@
1
+ export type { Column } from './column.ts';
2
+ export type { DeltaPage } from './delta.ts';
3
+ export type { Drive } from './drive.ts';
4
+ export type { DriveItem, PresentDriveItem } from './drive-item.ts';
5
+ export { DeltaExpiredError, GraphError, SharePointAccessError, SharePointCredentialsError, SharePointSiteNotFoundError, } from './errors.ts';
6
+ export type { SharePointClientOptions } from './graph.ts';
7
+ export type { List } from './list.ts';
8
+ export type { ListItem, PresentListItem } from './list-item.ts';
9
+ export type { SitePage, TextWebPart } from './page.ts';
10
+ export { SharePointClient } from './sharepoint-client.ts';
11
+ export type { Site } from './site.ts';
12
+ export { SiteVersion } from './site-version.ts';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { DeltaExpiredError, GraphError, SharePointAccessError, SharePointCredentialsError, SharePointSiteNotFoundError, } from './errors.js';
2
+ export { SharePointClient } from './sharepoint-client.js';
3
+ export { SiteVersion } from './site-version.js';
@@ -0,0 +1,107 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * An item of a list, as it is now. `fields` holds its value of each column
4
+ * that is not hidden, by the column's `name`.
5
+ */
6
+ export declare const presentListItem: z.ZodObject<{
7
+ id: z.ZodString;
8
+ eTag: z.ZodString;
9
+ webUrl: z.ZodString;
10
+ createdDateTime: z.ZodISODateTime;
11
+ lastModifiedDateTime: z.ZodISODateTime;
12
+ createdBy: z.ZodOptional<z.ZodObject<{
13
+ user: z.ZodOptional<z.ZodObject<{
14
+ id: z.ZodOptional<z.ZodString>;
15
+ displayName: z.ZodOptional<z.ZodString>;
16
+ email: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>>;
18
+ application: z.ZodOptional<z.ZodObject<{
19
+ id: z.ZodOptional<z.ZodString>;
20
+ displayName: z.ZodOptional<z.ZodString>;
21
+ email: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ group: z.ZodOptional<z.ZodObject<{
24
+ id: z.ZodOptional<z.ZodString>;
25
+ displayName: z.ZodOptional<z.ZodString>;
26
+ email: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>>;
28
+ }, z.core.$strip>>;
29
+ lastModifiedBy: z.ZodOptional<z.ZodObject<{
30
+ user: z.ZodOptional<z.ZodObject<{
31
+ id: z.ZodOptional<z.ZodString>;
32
+ displayName: z.ZodOptional<z.ZodString>;
33
+ email: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>>;
35
+ application: z.ZodOptional<z.ZodObject<{
36
+ id: z.ZodOptional<z.ZodString>;
37
+ displayName: z.ZodOptional<z.ZodString>;
38
+ email: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>;
40
+ group: z.ZodOptional<z.ZodObject<{
41
+ id: z.ZodOptional<z.ZodString>;
42
+ displayName: z.ZodOptional<z.ZodString>;
43
+ email: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>>;
45
+ }, z.core.$strip>>;
46
+ contentType: z.ZodObject<{
47
+ id: z.ZodString;
48
+ name: z.ZodString;
49
+ }, z.core.$strip>;
50
+ fields: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
51
+ deleted: z.ZodOptional<z.ZodNever>;
52
+ }, z.core.$strip>;
53
+ export declare const listItem: z.ZodUnion<readonly [z.ZodObject<{
54
+ id: z.ZodString;
55
+ eTag: z.ZodString;
56
+ webUrl: z.ZodString;
57
+ createdDateTime: z.ZodISODateTime;
58
+ lastModifiedDateTime: z.ZodISODateTime;
59
+ createdBy: z.ZodOptional<z.ZodObject<{
60
+ user: z.ZodOptional<z.ZodObject<{
61
+ id: z.ZodOptional<z.ZodString>;
62
+ displayName: z.ZodOptional<z.ZodString>;
63
+ email: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strip>>;
65
+ application: z.ZodOptional<z.ZodObject<{
66
+ id: z.ZodOptional<z.ZodString>;
67
+ displayName: z.ZodOptional<z.ZodString>;
68
+ email: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strip>>;
70
+ group: z.ZodOptional<z.ZodObject<{
71
+ id: z.ZodOptional<z.ZodString>;
72
+ displayName: z.ZodOptional<z.ZodString>;
73
+ email: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>>;
76
+ lastModifiedBy: z.ZodOptional<z.ZodObject<{
77
+ user: z.ZodOptional<z.ZodObject<{
78
+ id: z.ZodOptional<z.ZodString>;
79
+ displayName: z.ZodOptional<z.ZodString>;
80
+ email: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>>;
82
+ application: z.ZodOptional<z.ZodObject<{
83
+ id: z.ZodOptional<z.ZodString>;
84
+ displayName: z.ZodOptional<z.ZodString>;
85
+ email: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>>;
87
+ group: z.ZodOptional<z.ZodObject<{
88
+ id: z.ZodOptional<z.ZodString>;
89
+ displayName: z.ZodOptional<z.ZodString>;
90
+ email: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>>;
92
+ }, z.core.$strip>>;
93
+ contentType: z.ZodObject<{
94
+ id: z.ZodString;
95
+ name: z.ZodString;
96
+ }, z.core.$strip>;
97
+ fields: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
98
+ deleted: z.ZodOptional<z.ZodNever>;
99
+ }, z.core.$strip>, z.ZodObject<{
100
+ id: z.ZodString;
101
+ deleted: z.ZodObject<{
102
+ state: z.ZodOptional<z.ZodString>;
103
+ }, z.core.$strip>;
104
+ }, z.core.$strip>]>;
105
+ export type ListItem = z.infer<typeof listItem>;
106
+ /** An item of a list read in full, which holds no deleted item. */
107
+ export type PresentListItem = z.infer<typeof presentListItem>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { deleted, identitySet, timestamp } from './graph-values.js';
3
+ /**
4
+ * An item of a list, as it is now. `fields` holds its value of each column
5
+ * that is not hidden, by the column's `name`.
6
+ */
7
+ export const presentListItem = z.object({
8
+ id: z.string(),
9
+ eTag: z.string(),
10
+ webUrl: z.string(),
11
+ createdDateTime: timestamp,
12
+ lastModifiedDateTime: timestamp,
13
+ createdBy: identitySet.optional(),
14
+ lastModifiedBy: identitySet.optional(),
15
+ contentType: z.object({ id: z.string(), name: z.string() }),
16
+ fields: z.record(z.string(), z.json()),
17
+ deleted: z.never().optional(),
18
+ });
19
+ /** An item that was deleted after the link that the delta started at. */
20
+ const deletedListItem = z.object({ id: z.string(), deleted });
21
+ export const listItem = z.union([presentListItem, deletedListItem]);
package/dist/list.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const LIST_FIELDS = "id,name,displayName,description,webUrl,createdDateTime,lastModifiedDateTime,list";
3
+ /**
4
+ * A list of a site. A document library is a list too, with the template
5
+ * `documentLibrary`.
6
+ */
7
+ export declare const list: z.ZodObject<{
8
+ id: z.ZodString;
9
+ name: z.ZodString;
10
+ displayName: z.ZodString;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ webUrl: z.ZodString;
13
+ createdDateTime: z.ZodISODateTime;
14
+ lastModifiedDateTime: z.ZodISODateTime;
15
+ list: z.ZodObject<{
16
+ template: z.ZodString;
17
+ hidden: z.ZodBoolean;
18
+ contentTypesEnabled: z.ZodBoolean;
19
+ }, z.core.$strip>;
20
+ }, z.core.$strip>;
21
+ export type List = z.infer<typeof list>;
package/dist/list.js ADDED
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { timestamp } from './graph-values.js';
3
+ export const LIST_FIELDS = 'id,name,displayName,description,webUrl,createdDateTime,lastModifiedDateTime,list';
4
+ /**
5
+ * A list of a site. A document library is a list too, with the template
6
+ * `documentLibrary`.
7
+ */
8
+ export const list = z.object({
9
+ id: z.string(),
10
+ name: z.string(),
11
+ displayName: z.string(),
12
+ description: z.string().optional(),
13
+ webUrl: z.string(),
14
+ createdDateTime: timestamp,
15
+ lastModifiedDateTime: timestamp,
16
+ list: z.object({
17
+ template: z.string(),
18
+ hidden: z.boolean(),
19
+ contentTypesEnabled: z.boolean(),
20
+ }),
21
+ });