@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.
- package/LICENSE +202 -0
- package/README.md +79 -2
- package/dist/column.d.ts +92 -0
- package/dist/column.js +51 -0
- package/dist/delta.d.ts +15 -0
- package/dist/delta.js +26 -0
- package/dist/drive-item.d.ts +147 -0
- package/dist/drive-item.js +70 -0
- package/dist/drive.d.ts +13 -0
- package/dist/drive.js +13 -0
- package/dist/errors.d.ts +53 -0
- package/dist/errors.js +69 -0
- package/dist/graph-retry.d.ts +7 -0
- package/dist/graph-retry.js +47 -0
- package/dist/graph-values.d.ts +25 -0
- package/dist/graph-values.js +16 -0
- package/dist/graph.d.ts +30 -0
- package/dist/graph.js +97 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +3 -0
- package/dist/list-item.d.ts +107 -0
- package/dist/list-item.js +21 -0
- package/dist/list.d.ts +21 -0
- package/dist/list.js +21 -0
- package/dist/page.d.ts +137 -0
- package/dist/page.js +53 -0
- package/dist/sharepoint-client.d.ts +56 -0
- package/dist/sharepoint-client.js +109 -0
- package/dist/site-version.d.ts +14 -0
- package/dist/site-version.js +30 -0
- package/dist/site.d.ts +19 -0
- package/dist/site.js +24 -0
- package/package.json +46 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 ezzabuzaid
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @eltjs/sdk-microsoft-sharepoint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reads SharePoint Online through Microsoft Graph, as one app with an app-only token. This SDK knows nothing of elt. [@eltjs/source-microsoft-sharepoint](../../../sources/microsoft/sharepoint/README.md) uses it to make the streams of a pipeline. The words of this README are in the [glossary](./CONTEXT.md).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { SharePointClient } from '@eltjs/sdk-microsoft-sharepoint';
|
|
7
|
+
|
|
8
|
+
const client = new SharePointClient({
|
|
9
|
+
tenantId: '0b7f3f60-1f2c-4c5e-9d0a-6a1f2e3d4c5b',
|
|
10
|
+
clientId: 'c3a1f0e2-5b6d-4e7f-8a9b-0c1d2e3f4a5b',
|
|
11
|
+
clientSecret: 'the client secret of the app',
|
|
12
|
+
clock: globalThis,
|
|
13
|
+
});
|
|
14
|
+
const signal = AbortSignal.timeout(10 * 60_000);
|
|
15
|
+
|
|
16
|
+
const site = await client.site(
|
|
17
|
+
'https://contoso.sharepoint.com/sites/Sales',
|
|
18
|
+
signal,
|
|
19
|
+
);
|
|
20
|
+
const deltaLinks = new Map<string, string>();
|
|
21
|
+
for (const drive of await client.drives(site.id, signal)) {
|
|
22
|
+
for await (const page of client.driveDelta(drive.id, undefined, signal)) {
|
|
23
|
+
if ('deltaLink' in page) deltaLinks.set(drive.id, page.deltaLink);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `SharePointClient` takes the app registration of Microsoft Entra ID (`tenantId`, `clientId`, `clientSecret`) and a `clock`, which an app gives as `globalThis`. It gets the app-only token for `https://graph.microsoft.com/.default` with `@azure/msal-node`, which keeps the token in memory until it expires. The client reads no environment variable: the host gives each value.
|
|
29
|
+
- Each call is a GET to `https://graph.microsoft.com/v1.0` and takes a `signal`, which stops the request and each wait between tries.
|
|
30
|
+
- `site(url, signal)` gives the site at a URL such as `https://contoso.sharepoint.com/sites/Sales`. Every other call takes the `id` of this site, not its URL ([ADR 0002](./docs/adr/0002-a-sites-selected-app-cannot-list-its-sites-so-callers-name-site-urls.md)).
|
|
31
|
+
- `drives(siteId, signal)` gives the document libraries of the site.
|
|
32
|
+
- `lists(siteId, signal)` gives the lists of the site, with their template and their hidden flag. The document libraries are lists too.
|
|
33
|
+
- `columns(siteId, listId, signal)` gives the columns of a list. `type` is the facet that Graph gives for the type of the column, such as `text` or `choice`, with its settings, or `null` for a type that Graph does not model.
|
|
34
|
+
- `pages(siteId, signal)` gives the modern pages of the site, without their content. `textWebParts(siteId, pageId, signal)` gives the HTML of the text web parts of one page, in the order of its canvas.
|
|
35
|
+
- `driveDelta(driveId, link, signal)` and `listItemsDelta(siteId, listId, link, signal)` give the pages of a delta query ([ADR 0001](./docs/adr/0001-delta-queries-are-the-change-feed.md)). Without `link`, they give every item. With `link`, a `nextLink` or a `deltaLink` of an earlier page, they give the pages after it. Each page has `items` and a `nextLink`, or `items` and a `deltaLink` on the last page. An item with `deleted` was deleted. A drive delta selects the fields that a file or a folder needs, such as `size`, `file.hashes`, `parentReference.path` and `sharepointIds.listItemId`, and never `@microsoft.graph.downloadUrl`, a pre-signed URL that changes at each read. A list items delta gives the `fields` of each item.
|
|
36
|
+
- `download(driveId, itemId, path, signal)` writes the content of a file to `path` as it arrives. The file is not kept in memory.
|
|
37
|
+
- `SiteVersion` is a `Gauge<string>` of `@zukhruf/async` for a site URL. Its value changes when the `lastModifiedDateTime` of a list or a page of the site changes, or when a list or a page is added or removed. Each read asks Graph for the site, its lists and its pages: three requests.
|
|
38
|
+
|
|
39
|
+
## Retries
|
|
40
|
+
|
|
41
|
+
A request that Graph answers with 429, 503 or 504 is sent again, five times in all. The `Retry-After` of Graph is the wait. A `Retry-After` of more than 60 seconds fails the call at once. Without a `Retry-After`, the wait doubles from 1 second to at most 60 seconds, with full jitter. Each wait runs on the `clock` of the client. This code is a copy of the retry of `@eltjs/google-auth` ([the ledger](./docs/copied-from-google-auth-retry.md)).
|
|
42
|
+
|
|
43
|
+
## Errors
|
|
44
|
+
|
|
45
|
+
| Error | The cause |
|
|
46
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
47
|
+
| `SharePointAccessError` | Graph refused the token (401) or the access (403). `resource` names the site URL, the site ID or the drive of the call. The app needs a Sites.Selected read grant on the site. |
|
|
48
|
+
| `SharePointSiteNotFoundError` | No site is at the URL that `site` got (404). |
|
|
49
|
+
| `DeltaExpiredError` | Graph no longer serves the changes after the link (410). Read the collection again, with no link. |
|
|
50
|
+
| `GraphError` | Graph refused the request for another reason. `status` and `code` are those of Graph, such as 400 `invalidRequest` for a malformed delta link. |
|
|
51
|
+
|
|
52
|
+
Each error of the first three kinds keeps the `GraphError` as its `cause`.
|
|
53
|
+
|
|
54
|
+
## Live checks
|
|
55
|
+
|
|
56
|
+
On 2026-11-17, with the app-only token of an app that holds only `Sites.Selected`, against a tenant of SharePoint Online:
|
|
57
|
+
|
|
58
|
+
- The token holds only the role `Sites.Selected`.
|
|
59
|
+
- `GET /sites?search=*`, `GET /sites/getAllSites` and `GET /sites/root` answer 403. The app cannot list its sites.
|
|
60
|
+
- A site that exists and that the app has no grant on answers 403. A site that does not exist answers 404.
|
|
61
|
+
- `GET /sites/{id}/permissions` answers 403, so the app cannot read the role of its own grant.
|
|
62
|
+
- The drive delta of each document library of the granted site, and the list items delta, end with `@odata.deltaLink`.
|
|
63
|
+
- A malformed delta token answers 400 `invalidRequest`. An expired one answers 410, as Graph documents. No expired link was available to check.
|
|
64
|
+
- With `$select`, the items of a drive delta include `parentReference.path` and `cTag`.
|
|
65
|
+
- Two full reads 5 seconds apart, with no edits, gave the same site, drives, lists, columns, pages and drive delta items, byte for byte.
|
|
66
|
+
- `GET /sites/{id}/pages/{id}/microsoft.graph.sitePage?$expand=canvasLayout` answers 200.
|
|
67
|
+
- A drive delta gives the root folder of the drive on each of its pages: 31 times over the 31 pages of a library of 5,725 files. The root has no `eTag`.
|
|
68
|
+
- The item delta of the hidden list of template `accessRequest` answers 503 `serviceNotAvailable` at each try, while `GET /sites/{id}/lists/{id}/items` answers 200. `listItems` reads such a list in full.
|
|
69
|
+
- One full pass of the granted site parsed with these schemas: 6 drives, 10 lists, 5,727 files, 314 folders, about 6,450 list items and 4 pages. The drive deltas gave the 314 folders 682 times: a delta gives a folder again when its children change, and the last time is the current one.
|
|
70
|
+
|
|
71
|
+
Not checked live: that the `lastModifiedDateTime` of a list moves when one of its items changes, which `SiteVersion` uses. The app has only a read grant, and no test site is available. The next changes that people make to the site show it.
|
|
72
|
+
|
|
73
|
+
## Limits
|
|
74
|
+
|
|
75
|
+
- Graph leaves out the lists that it marks `system`. The columns of a list and the `fields` of its items leave out the hidden columns.
|
|
76
|
+
- A delta query can give the same item more than once. The last one is the current one. Graph documents that a delta can leave out `parentReference.path` and `cTag`, so both are optional.
|
|
77
|
+
- `textWebParts` reads only the text web parts. Other web parts, such as images and embedded documents, give no text. It is one request for each page.
|
|
78
|
+
- The client reads no versions of files and no permissions of items.
|
|
79
|
+
- A download is one request with no resume. Graph redirects it to a pre-signed URL on the SharePoint host. `fetch` follows the redirect and does not send the `Authorization` header to the other origin (checked on Node.js 26.13).
|
|
80
|
+
- The client takes a client secret, not a certificate.
|
package/dist/column.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A column of a list: the name of a field that its items have, and its type,
|
|
4
|
+
* or null for a type that Graph does not model.
|
|
5
|
+
*/
|
|
6
|
+
export declare const column: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
|
|
7
|
+
fields: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
displayName: z.ZodString;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
columnGroup: z.ZodOptional<z.ZodString>;
|
|
13
|
+
hidden: z.ZodBoolean;
|
|
14
|
+
indexed: z.ZodBoolean;
|
|
15
|
+
readOnly: z.ZodBoolean;
|
|
16
|
+
required: z.ZodBoolean;
|
|
17
|
+
enforceUniqueValues: z.ZodBoolean;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
facets: z.ZodObject<{
|
|
20
|
+
boolean: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
21
|
+
calculated: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
22
|
+
choice: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
23
|
+
contentApprovalStatus: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
24
|
+
currency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
25
|
+
dateTime: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
26
|
+
geolocation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
27
|
+
hyperlinkOrPicture: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
28
|
+
lookup: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
29
|
+
number: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
30
|
+
personOrGroup: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
31
|
+
term: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
32
|
+
text: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
33
|
+
thumbnail: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
}, z.core.$strip>, unknown>, z.ZodTransform<{
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
displayName: string;
|
|
39
|
+
description?: string | undefined;
|
|
40
|
+
columnGroup?: string | undefined;
|
|
41
|
+
hidden: boolean;
|
|
42
|
+
indexed: boolean;
|
|
43
|
+
readOnly: boolean;
|
|
44
|
+
required: boolean;
|
|
45
|
+
enforceUniqueValues: boolean;
|
|
46
|
+
type: {
|
|
47
|
+
name: "boolean" | "calculated" | "choice" | "contentApprovalStatus" | "currency" | "dateTime" | "geolocation" | "hyperlinkOrPicture" | "lookup" | "number" | "personOrGroup" | "term" | "text" | "thumbnail";
|
|
48
|
+
settings: Record<string, z.JSONType>;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
displayName: string;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
columnGroup?: string | undefined;
|
|
56
|
+
hidden: boolean;
|
|
57
|
+
indexed: boolean;
|
|
58
|
+
readOnly: boolean;
|
|
59
|
+
required: boolean;
|
|
60
|
+
enforceUniqueValues: boolean;
|
|
61
|
+
type: null;
|
|
62
|
+
}, {
|
|
63
|
+
fields: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
displayName: string;
|
|
67
|
+
description?: string | undefined;
|
|
68
|
+
columnGroup?: string | undefined;
|
|
69
|
+
hidden: boolean;
|
|
70
|
+
indexed: boolean;
|
|
71
|
+
readOnly: boolean;
|
|
72
|
+
required: boolean;
|
|
73
|
+
enforceUniqueValues: boolean;
|
|
74
|
+
};
|
|
75
|
+
facets: {
|
|
76
|
+
boolean?: Record<string, z.JSONType> | undefined;
|
|
77
|
+
calculated?: Record<string, z.JSONType> | undefined;
|
|
78
|
+
choice?: Record<string, z.JSONType> | undefined;
|
|
79
|
+
contentApprovalStatus?: Record<string, z.JSONType> | undefined;
|
|
80
|
+
currency?: Record<string, z.JSONType> | undefined;
|
|
81
|
+
dateTime?: Record<string, z.JSONType> | undefined;
|
|
82
|
+
geolocation?: Record<string, z.JSONType> | undefined;
|
|
83
|
+
hyperlinkOrPicture?: Record<string, z.JSONType> | undefined;
|
|
84
|
+
lookup?: Record<string, z.JSONType> | undefined;
|
|
85
|
+
number?: Record<string, z.JSONType> | undefined;
|
|
86
|
+
personOrGroup?: Record<string, z.JSONType> | undefined;
|
|
87
|
+
term?: Record<string, z.JSONType> | undefined;
|
|
88
|
+
text?: Record<string, z.JSONType> | undefined;
|
|
89
|
+
thumbnail?: Record<string, z.JSONType> | undefined;
|
|
90
|
+
};
|
|
91
|
+
}>>;
|
|
92
|
+
export type Column = z.infer<typeof column>;
|
package/dist/column.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const fields = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
displayName: z.string(),
|
|
6
|
+
description: z.string().optional(),
|
|
7
|
+
columnGroup: z.string().optional(),
|
|
8
|
+
hidden: z.boolean(),
|
|
9
|
+
indexed: z.boolean(),
|
|
10
|
+
readOnly: z.boolean(),
|
|
11
|
+
required: z.boolean(),
|
|
12
|
+
enforceUniqueValues: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
// Graph gives the type of a column as one facet, such as `text` or `choice`,
|
|
15
|
+
// that holds the settings of that type. The facets are mutually exclusive,
|
|
16
|
+
// and a column of a type that Graph does not model has none
|
|
17
|
+
// (columnDefinition).
|
|
18
|
+
const settings = z.record(z.string(), z.json()).optional();
|
|
19
|
+
const facets = z.object({
|
|
20
|
+
boolean: settings,
|
|
21
|
+
calculated: settings,
|
|
22
|
+
choice: settings,
|
|
23
|
+
contentApprovalStatus: settings,
|
|
24
|
+
currency: settings,
|
|
25
|
+
dateTime: settings,
|
|
26
|
+
geolocation: settings,
|
|
27
|
+
hyperlinkOrPicture: settings,
|
|
28
|
+
lookup: settings,
|
|
29
|
+
number: settings,
|
|
30
|
+
personOrGroup: settings,
|
|
31
|
+
term: settings,
|
|
32
|
+
text: settings,
|
|
33
|
+
thumbnail: settings,
|
|
34
|
+
});
|
|
35
|
+
const TYPES = facets.keyof().options;
|
|
36
|
+
/**
|
|
37
|
+
* A column of a list: the name of a field that its items have, and its type,
|
|
38
|
+
* or null for a type that Graph does not model.
|
|
39
|
+
*/
|
|
40
|
+
export const column = z
|
|
41
|
+
// One body holds both the fields and the facets; each schema reads its own
|
|
42
|
+
// keys of it.
|
|
43
|
+
.preprocess((body) => ({ fields: body, facets: body }), z.object({ fields, facets }))
|
|
44
|
+
.transform(({ fields, facets }) => {
|
|
45
|
+
for (const name of TYPES) {
|
|
46
|
+
const settings = facets[name];
|
|
47
|
+
if (settings !== undefined)
|
|
48
|
+
return { ...fields, type: { name, settings } };
|
|
49
|
+
}
|
|
50
|
+
return { ...fields, type: null };
|
|
51
|
+
});
|
package/dist/delta.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* One page of a delta query. A page with a `nextLink` has more pages after
|
|
4
|
+
* it; the last page has a `deltaLink`, the link that a later delta starts at
|
|
5
|
+
* to read the changes after this one.
|
|
6
|
+
*/
|
|
7
|
+
export type DeltaPage<T> = {
|
|
8
|
+
readonly items: readonly T[];
|
|
9
|
+
readonly nextLink: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly items: readonly T[];
|
|
12
|
+
readonly deltaLink: string;
|
|
13
|
+
};
|
|
14
|
+
/** The schema of a delta page whose items `item` parses. */
|
|
15
|
+
export declare function deltaPage<T>(item: z.ZodType<T>): z.ZodType<DeltaPage<T>>;
|
package/dist/delta.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The schema of a delta page whose items `item` parses. */
|
|
3
|
+
export function deltaPage(item) {
|
|
4
|
+
return z.union([
|
|
5
|
+
z
|
|
6
|
+
.object({
|
|
7
|
+
value: z.array(item),
|
|
8
|
+
'@odata.nextLink': z.string(),
|
|
9
|
+
'@odata.deltaLink': z.never().optional(),
|
|
10
|
+
})
|
|
11
|
+
.transform((body) => ({
|
|
12
|
+
items: body.value,
|
|
13
|
+
nextLink: body['@odata.nextLink'],
|
|
14
|
+
})),
|
|
15
|
+
z
|
|
16
|
+
.object({
|
|
17
|
+
value: z.array(item),
|
|
18
|
+
'@odata.nextLink': z.never().optional(),
|
|
19
|
+
'@odata.deltaLink': z.string(),
|
|
20
|
+
})
|
|
21
|
+
.transform((body) => ({
|
|
22
|
+
items: body.value,
|
|
23
|
+
deltaLink: body['@odata.deltaLink'],
|
|
24
|
+
})),
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DRIVE_ITEM_FIELDS: string;
|
|
3
|
+
/** A file or a folder of a drive, as it is now. */
|
|
4
|
+
declare const presentDriveItem: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
size: z.ZodNumber;
|
|
8
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
mimeType: z.ZodString;
|
|
10
|
+
hashes: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
quickXorHash: z.ZodOptional<z.ZodString>;
|
|
12
|
+
sha1Hash: z.ZodOptional<z.ZodString>;
|
|
13
|
+
sha256Hash: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
folder: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
childCount: z.ZodNumber;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
root: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
20
|
+
deleted: z.ZodOptional<z.ZodNever>;
|
|
21
|
+
parentReference: z.ZodObject<{
|
|
22
|
+
driveId: z.ZodString;
|
|
23
|
+
id: z.ZodOptional<z.ZodString>;
|
|
24
|
+
path: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
webUrl: z.ZodString;
|
|
27
|
+
createdDateTime: z.ZodISODateTime;
|
|
28
|
+
lastModifiedDateTime: z.ZodISODateTime;
|
|
29
|
+
createdBy: 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
|
+
lastModifiedBy: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
50
|
+
email: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
application: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
id: z.ZodOptional<z.ZodString>;
|
|
54
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
55
|
+
email: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
group: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
id: z.ZodOptional<z.ZodString>;
|
|
59
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
60
|
+
email: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
eTag: z.ZodOptional<z.ZodString>;
|
|
64
|
+
cTag: z.ZodOptional<z.ZodString>;
|
|
65
|
+
sharepointIds: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
listItemId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export declare const driveItem: z.ZodUnion<readonly [z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
size: z.ZodNumber;
|
|
73
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
74
|
+
mimeType: z.ZodString;
|
|
75
|
+
hashes: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
quickXorHash: z.ZodOptional<z.ZodString>;
|
|
77
|
+
sha1Hash: z.ZodOptional<z.ZodString>;
|
|
78
|
+
sha256Hash: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
folder: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
childCount: z.ZodNumber;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
root: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
85
|
+
deleted: z.ZodOptional<z.ZodNever>;
|
|
86
|
+
parentReference: z.ZodObject<{
|
|
87
|
+
driveId: z.ZodString;
|
|
88
|
+
id: z.ZodOptional<z.ZodString>;
|
|
89
|
+
path: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
webUrl: z.ZodString;
|
|
92
|
+
createdDateTime: z.ZodISODateTime;
|
|
93
|
+
lastModifiedDateTime: z.ZodISODateTime;
|
|
94
|
+
createdBy: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
id: z.ZodOptional<z.ZodString>;
|
|
97
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
98
|
+
email: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
application: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
id: z.ZodOptional<z.ZodString>;
|
|
102
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
103
|
+
email: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
group: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
108
|
+
email: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
lastModifiedBy: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
id: z.ZodOptional<z.ZodString>;
|
|
114
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
115
|
+
email: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
application: z.ZodOptional<z.ZodObject<{
|
|
118
|
+
id: z.ZodOptional<z.ZodString>;
|
|
119
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
120
|
+
email: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
group: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
id: z.ZodOptional<z.ZodString>;
|
|
124
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
125
|
+
email: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
eTag: z.ZodOptional<z.ZodString>;
|
|
129
|
+
cTag: z.ZodOptional<z.ZodString>;
|
|
130
|
+
sharepointIds: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
listItemId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
deleted: z.ZodObject<{
|
|
136
|
+
state: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
parentReference: z.ZodOptional<z.ZodObject<{
|
|
139
|
+
driveId: z.ZodString;
|
|
140
|
+
id: z.ZodOptional<z.ZodString>;
|
|
141
|
+
path: z.ZodOptional<z.ZodString>;
|
|
142
|
+
}, z.core.$strip>>;
|
|
143
|
+
}, z.core.$strip>]>;
|
|
144
|
+
export type DriveItem = z.infer<typeof driveItem>;
|
|
145
|
+
/** A file or a folder of a drive as it is now: a drive item that is not deleted. */
|
|
146
|
+
export type PresentDriveItem = z.infer<typeof presentDriveItem>;
|
|
147
|
+
export {};
|