@org-quicko/silo-client 1.0.0 → 1.1.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/README.md +166 -124
- package/dist/collections/collection-handle.d.cts +15 -23
- package/dist/collections/collection-handle.d.ts +15 -23
- package/dist/collections/collections.d.cts +3 -5
- package/dist/collections/collections.d.ts +3 -5
- package/dist/entries/entry-envelope.d.cts +18 -0
- package/dist/entries/entry-envelope.d.ts +18 -0
- package/dist/entries/entry-read-options.d.cts +16 -0
- package/dist/entries/entry-read-options.d.ts +16 -0
- package/dist/entries/entry-reader.d.cts +16 -16
- package/dist/entries/entry-reader.d.ts +16 -16
- package/dist/entries/entry.d.cts +11 -23
- package/dist/entries/entry.d.ts +11 -23
- package/dist/errors/network-error.d.cts +5 -0
- package/dist/errors/network-error.d.ts +5 -0
- package/dist/index.cjs +87 -170
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +87 -170
- package/dist/media/media-asset.d.cts +17 -0
- package/dist/media/media-asset.d.ts +17 -0
- package/dist/media/media-file.d.cts +16 -0
- package/dist/media/media-file.d.ts +16 -0
- package/dist/media/media-replace.d.cts +17 -0
- package/dist/media/media-replace.d.ts +17 -0
- package/dist/media/media.d.cts +0 -4
- package/dist/media/media.d.ts +0 -4
- package/dist/search/search-hit.d.cts +5 -5
- package/dist/search/search-hit.d.ts +5 -5
- package/dist/search/search.d.cts +4 -1
- package/dist/search/search.d.ts +4 -1
- package/dist/transport/api-path.d.cts +1 -0
- package/dist/transport/api-path.d.ts +1 -0
- package/dist/transport/transport.d.cts +4 -0
- package/dist/transport/transport.d.ts +4 -0
- package/package.json +58 -58
- package/dist/collections/reserved-field-names.d.cts +0 -9
- package/dist/collections/reserved-field-names.d.ts +0 -9
- package/dist/entries/entry-base.d.cts +0 -31
- package/dist/entries/entry-base.d.ts +0 -31
- package/dist/entries/entry-mapper.d.cts +0 -13
- package/dist/entries/entry-mapper.d.ts +0 -13
- package/dist/entries/entry-payload.d.cts +0 -12
- package/dist/entries/entry-payload.d.ts +0 -12
- package/dist/entries/resolved-entry.d.cts +0 -11
- package/dist/entries/resolved-entry.d.ts +0 -11
package/dist/index.cjs
CHANGED
|
@@ -53,8 +53,6 @@ __export(exports_src, {
|
|
|
53
53
|
Search: () => Search,
|
|
54
54
|
RowStream: () => RowStream,
|
|
55
55
|
RouteInventory: () => RouteInventory,
|
|
56
|
-
ResolvedEntry: () => ResolvedEntry,
|
|
57
|
-
ReservedFieldNames: () => ReservedFieldNames,
|
|
58
56
|
RequestAbortedError: () => RequestAbortedError,
|
|
59
57
|
RenameReport: () => RenameReport,
|
|
60
58
|
Projects: () => Projects,
|
|
@@ -90,8 +88,6 @@ __export(exports_src, {
|
|
|
90
88
|
EntryReader: () => EntryReader,
|
|
91
89
|
EntryPageStream: () => EntryPageStream,
|
|
92
90
|
EntryPage: () => EntryPage,
|
|
93
|
-
EntryBase: () => EntryBase,
|
|
94
|
-
Entry: () => Entry,
|
|
95
91
|
ConflictError: () => ConflictError,
|
|
96
92
|
Collections: () => Collections,
|
|
97
93
|
CollectionSchema: () => CollectionSchema,
|
|
@@ -185,6 +181,9 @@ class ApiPath {
|
|
|
185
181
|
static mediaAssetUsages(id) {
|
|
186
182
|
return `${ApiPath.mediaAsset(id)}/usages`;
|
|
187
183
|
}
|
|
184
|
+
static mediaAssetContent(id) {
|
|
185
|
+
return `${ApiPath.mediaAsset(id)}/content`;
|
|
186
|
+
}
|
|
188
187
|
static mediaBulkDelete() {
|
|
189
188
|
return "/api/media/delete";
|
|
190
189
|
}
|
|
@@ -231,6 +230,22 @@ class MediaAssetMapper {
|
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
|
|
233
|
+
// src/media/media-file.ts
|
|
234
|
+
class MediaFile {
|
|
235
|
+
static toBlob(bytes, contentType) {
|
|
236
|
+
if (bytes instanceof Blob)
|
|
237
|
+
return bytes;
|
|
238
|
+
return new Blob([bytes], contentType ? { type: contentType } : undefined);
|
|
239
|
+
}
|
|
240
|
+
static nameOf(input, explicit) {
|
|
241
|
+
if (explicit)
|
|
242
|
+
return explicit;
|
|
243
|
+
if (input instanceof File && input.name)
|
|
244
|
+
return input.name;
|
|
245
|
+
throw new Error("media: a Blob has no filename — pass { filename } explicitly");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
234
249
|
// src/media/media-reference.ts
|
|
235
250
|
class MediaReference {
|
|
236
251
|
static Scheme = "silo://media/";
|
|
@@ -392,6 +407,22 @@ class MediaAsset {
|
|
|
392
407
|
async setTags(tags, options) {
|
|
393
408
|
return this.patch({ tags: [...tags] }, options);
|
|
394
409
|
}
|
|
410
|
+
async replace(input, options) {
|
|
411
|
+
const form = new FormData;
|
|
412
|
+
if (input instanceof Blob) {
|
|
413
|
+
form.set("file", input, MediaFile.nameOf(input, options?.filename));
|
|
414
|
+
} else {
|
|
415
|
+
form.set("file", MediaFile.toBlob(input.bytes, input.contentType), input.filename);
|
|
416
|
+
}
|
|
417
|
+
const payload = await this.transport.upload({
|
|
418
|
+
method: "POST",
|
|
419
|
+
path: ApiPath.mediaAssetContent(this.id),
|
|
420
|
+
signal: options?.signal,
|
|
421
|
+
timeoutMilliseconds: options?.timeoutMilliseconds
|
|
422
|
+
}, form);
|
|
423
|
+
this.record = MediaAssetMapper.toRecord(payload);
|
|
424
|
+
return this;
|
|
425
|
+
}
|
|
395
426
|
async delete(options) {
|
|
396
427
|
await this.transport.empty({
|
|
397
428
|
method: "DELETE",
|
|
@@ -625,11 +656,11 @@ class Media {
|
|
|
625
656
|
let options;
|
|
626
657
|
if (input instanceof Blob) {
|
|
627
658
|
const fileOptions = second ?? {};
|
|
628
|
-
form.set("file", input,
|
|
659
|
+
form.set("file", input, MediaFile.nameOf(input, fileOptions.filename));
|
|
629
660
|
folder = fileOptions.folder;
|
|
630
661
|
options = third ?? fileOptions;
|
|
631
662
|
} else {
|
|
632
|
-
form.set("file",
|
|
663
|
+
form.set("file", MediaFile.toBlob(input.bytes, input.contentType), input.filename);
|
|
633
664
|
folder = input.folder;
|
|
634
665
|
options = second;
|
|
635
666
|
}
|
|
@@ -697,18 +728,6 @@ class Media {
|
|
|
697
728
|
sort: query.sort
|
|
698
729
|
};
|
|
699
730
|
}
|
|
700
|
-
static toBlob(bytes, contentType) {
|
|
701
|
-
if (bytes instanceof Blob)
|
|
702
|
-
return bytes;
|
|
703
|
-
return new Blob([bytes], contentType ? { type: contentType } : undefined);
|
|
704
|
-
}
|
|
705
|
-
static filenameOf(input, explicit) {
|
|
706
|
-
if (explicit)
|
|
707
|
-
return explicit;
|
|
708
|
-
if (input instanceof File && input.name)
|
|
709
|
-
return input.name;
|
|
710
|
-
throw new Error("media upload: a Blob has no filename — pass { filename } explicitly");
|
|
711
|
-
}
|
|
712
731
|
}
|
|
713
732
|
|
|
714
733
|
// src/variables/variable.ts
|
|
@@ -779,96 +798,6 @@ class ProjectVariables {
|
|
|
779
798
|
}
|
|
780
799
|
}
|
|
781
800
|
|
|
782
|
-
// src/entries/entry-mapper.ts
|
|
783
|
-
class EntryMapper {
|
|
784
|
-
static fieldsOf(payload) {
|
|
785
|
-
const { id: _id, rev: _rev, created_at: _createdAt, updated_at: _updatedAt, ...fields } = payload;
|
|
786
|
-
return fields;
|
|
787
|
-
}
|
|
788
|
-
static toPayload(id, rev, fields, createdAt, updatedAt) {
|
|
789
|
-
return {
|
|
790
|
-
id,
|
|
791
|
-
rev,
|
|
792
|
-
...fields,
|
|
793
|
-
created_at: createdAt.toISOString(),
|
|
794
|
-
updated_at: updatedAt.toISOString()
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// src/entries/entry-base.ts
|
|
800
|
-
class EntryBase {
|
|
801
|
-
context;
|
|
802
|
-
id;
|
|
803
|
-
rev;
|
|
804
|
-
createdAt;
|
|
805
|
-
updatedAt;
|
|
806
|
-
fields;
|
|
807
|
-
constructor(context, payload) {
|
|
808
|
-
this.context = context;
|
|
809
|
-
this.id = String(payload.id);
|
|
810
|
-
this.rev = Number(payload.rev);
|
|
811
|
-
this.createdAt = new Date(payload.created_at);
|
|
812
|
-
this.updatedAt = new Date(payload.updated_at);
|
|
813
|
-
this.fields = EntryMapper.fieldsOf(payload);
|
|
814
|
-
}
|
|
815
|
-
toJSON() {
|
|
816
|
-
return EntryMapper.toPayload(this.id, this.rev, this.fields, this.createdAt, this.updatedAt);
|
|
817
|
-
}
|
|
818
|
-
async delete(options = {}) {
|
|
819
|
-
await this.context.transport.empty({
|
|
820
|
-
method: "DELETE",
|
|
821
|
-
path: ApiPath.entry(this.context.project, this.context.environment, this.context.collection, this.id),
|
|
822
|
-
query: { rev: this.rev },
|
|
823
|
-
...options
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
// src/entries/resolved-entry.ts
|
|
829
|
-
class ResolvedEntry extends EntryBase {
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
// src/entries/entry.ts
|
|
833
|
-
class Entry extends ResolvedEntry {
|
|
834
|
-
saving = false;
|
|
835
|
-
async save(options = {}) {
|
|
836
|
-
if (this.saving) {
|
|
837
|
-
throw new Error(`cannot save entry "${this.id}": a previous save() on this instance has not finished yet`);
|
|
838
|
-
}
|
|
839
|
-
this.saving = true;
|
|
840
|
-
try {
|
|
841
|
-
const payload = await this.context.transport.json({
|
|
842
|
-
method: "PUT",
|
|
843
|
-
path: ApiPath.entry(this.context.project, this.context.environment, this.context.collection, this.id),
|
|
844
|
-
query: { rev: this.rev, variables: "raw" },
|
|
845
|
-
body: this.fields,
|
|
846
|
-
...options
|
|
847
|
-
});
|
|
848
|
-
this.adopt(payload);
|
|
849
|
-
return this;
|
|
850
|
-
} finally {
|
|
851
|
-
this.saving = false;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
async refresh(options = {}) {
|
|
855
|
-
const payload = await this.context.transport.json({
|
|
856
|
-
method: "GET",
|
|
857
|
-
path: ApiPath.entry(this.context.project, this.context.environment, this.context.collection, this.id),
|
|
858
|
-
query: { variables: "raw" },
|
|
859
|
-
...options
|
|
860
|
-
});
|
|
861
|
-
this.adopt(payload);
|
|
862
|
-
return this;
|
|
863
|
-
}
|
|
864
|
-
adopt(payload) {
|
|
865
|
-
this.rev = Number(payload.rev);
|
|
866
|
-
this.createdAt = new Date(payload.created_at);
|
|
867
|
-
this.updatedAt = new Date(payload.updated_at);
|
|
868
|
-
this.fields = EntryMapper.fieldsOf(payload);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
|
|
872
801
|
// src/transport/page-payload.ts
|
|
873
802
|
class PagePayload {
|
|
874
803
|
static read(body) {
|
|
@@ -929,40 +858,39 @@ class EntryStream extends RowStream {
|
|
|
929
858
|
|
|
930
859
|
// src/entries/entry-reader.ts
|
|
931
860
|
class EntryReader {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
this.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
const payload = await this.context.transport.json({
|
|
861
|
+
scope;
|
|
862
|
+
collection;
|
|
863
|
+
constructor(scope, collection) {
|
|
864
|
+
this.scope = scope;
|
|
865
|
+
this.collection = collection;
|
|
866
|
+
}
|
|
867
|
+
get(id, options = {}) {
|
|
868
|
+
const { variables, ...request } = options;
|
|
869
|
+
return this.scope.transport.json({
|
|
942
870
|
method: "GET",
|
|
943
|
-
path: ApiPath.entry(this.
|
|
944
|
-
query: { variables
|
|
945
|
-
...
|
|
871
|
+
path: ApiPath.entry(this.scope.project, this.scope.environment, this.collection, id),
|
|
872
|
+
query: { variables },
|
|
873
|
+
...request
|
|
946
874
|
});
|
|
947
|
-
return this.wrap(payload);
|
|
948
875
|
}
|
|
949
876
|
async list(query = {}, options = {}) {
|
|
877
|
+
const { variables, ...request } = options;
|
|
950
878
|
const loader = (window2) => this.list({ ...query, limit: window2.limit, offset: window2.offset }, options);
|
|
951
|
-
const body = await this.
|
|
879
|
+
const body = await this.scope.transport.json({
|
|
952
880
|
method: "GET",
|
|
953
|
-
path: ApiPath.entries(this.
|
|
881
|
+
path: ApiPath.entries(this.scope.project, this.scope.environment, this.collection),
|
|
954
882
|
query: {
|
|
955
883
|
limit: query.limit,
|
|
956
884
|
offset: query.offset,
|
|
957
885
|
filter: query.where?.toJSON(),
|
|
958
886
|
sort: query.sort === undefined ? undefined : String(query.sort),
|
|
959
|
-
variables
|
|
887
|
+
variables
|
|
960
888
|
},
|
|
961
|
-
...
|
|
889
|
+
...request
|
|
962
890
|
});
|
|
963
891
|
const page = PagePayload.read(body);
|
|
964
892
|
const window = new PageWindow(page.limit ?? query.limit ?? 50, page.offset ?? query.offset ?? 0);
|
|
965
|
-
return new EntryPage(page.rows
|
|
893
|
+
return new EntryPage(page.rows, page.total, window, loader);
|
|
966
894
|
}
|
|
967
895
|
all(query = {}, options = {}) {
|
|
968
896
|
const loader = async (window) => {
|
|
@@ -1136,15 +1064,15 @@ class Search {
|
|
|
1136
1064
|
const window = new PageWindow(page.limit ?? query.limit ?? 50, page.offset ?? query.offset ?? 0);
|
|
1137
1065
|
const truncated = body.truncated === true;
|
|
1138
1066
|
const engine = body.engine;
|
|
1139
|
-
const hits = page.rows.map((hit) =>
|
|
1067
|
+
const hits = page.rows.map((hit) => Search.toHit(hit));
|
|
1140
1068
|
return new SearchPage(hits, page.total, window, truncated, engine, loader);
|
|
1141
1069
|
}
|
|
1142
|
-
toHit(payload) {
|
|
1070
|
+
static toHit(payload) {
|
|
1143
1071
|
return {
|
|
1144
1072
|
project: payload.project,
|
|
1145
1073
|
environment: payload.env,
|
|
1146
1074
|
collection: payload.collection,
|
|
1147
|
-
entry:
|
|
1075
|
+
entry: payload.entry,
|
|
1148
1076
|
snippets: payload.snippets
|
|
1149
1077
|
};
|
|
1150
1078
|
}
|
|
@@ -1207,36 +1135,24 @@ class CollectionHandle {
|
|
|
1207
1135
|
name;
|
|
1208
1136
|
filter = new TypedFilter;
|
|
1209
1137
|
schema;
|
|
1210
|
-
|
|
1211
|
-
context;
|
|
1212
|
-
resolved;
|
|
1138
|
+
reader;
|
|
1213
1139
|
constructor(scope, name) {
|
|
1214
1140
|
this.scope = scope;
|
|
1215
1141
|
this.name = name;
|
|
1216
1142
|
this.schema = new CollectionSchema(scope, name);
|
|
1217
|
-
this.
|
|
1218
|
-
transport: scope.transport,
|
|
1219
|
-
project: scope.project,
|
|
1220
|
-
environment: scope.environment,
|
|
1221
|
-
collection: name
|
|
1222
|
-
};
|
|
1223
|
-
this.resolved = new EntryReader(this.context, undefined, (payload) => new ResolvedEntry(this.context, payload));
|
|
1224
|
-
this.editable = new EntryReader(this.context, "raw", (payload) => new Entry(this.context, payload));
|
|
1143
|
+
this.reader = new EntryReader(scope, name);
|
|
1225
1144
|
}
|
|
1226
1145
|
get(id, options = {}) {
|
|
1227
|
-
return this.
|
|
1228
|
-
}
|
|
1229
|
-
edit(id, options = {}) {
|
|
1230
|
-
return this.editable.get(id, options);
|
|
1146
|
+
return this.reader.get(id, options);
|
|
1231
1147
|
}
|
|
1232
1148
|
list(query = {}, options = {}) {
|
|
1233
|
-
return this.
|
|
1149
|
+
return this.reader.list(query, options);
|
|
1234
1150
|
}
|
|
1235
1151
|
all(query = {}, options = {}) {
|
|
1236
|
-
return this.
|
|
1152
|
+
return this.reader.all(query, options);
|
|
1237
1153
|
}
|
|
1238
1154
|
pages(query = {}, options = {}) {
|
|
1239
|
-
return this.
|
|
1155
|
+
return this.reader.pages(query, options);
|
|
1240
1156
|
}
|
|
1241
1157
|
create(fields, options = {}) {
|
|
1242
1158
|
return this.write("POST", ApiPath.entries(this.scope.project, this.scope.environment, this.name), fields, undefined, options);
|
|
@@ -1266,23 +1182,14 @@ class CollectionHandle {
|
|
|
1266
1182
|
});
|
|
1267
1183
|
return RenameReport.fromWire(payload);
|
|
1268
1184
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1185
|
+
write(method, path, fields, rev, options) {
|
|
1186
|
+
return this.scope.transport.json({
|
|
1271
1187
|
method,
|
|
1272
1188
|
path,
|
|
1273
1189
|
query: { rev, variables: "raw" },
|
|
1274
1190
|
body: fields,
|
|
1275
1191
|
...options
|
|
1276
1192
|
});
|
|
1277
|
-
return new Entry(this.context, payload);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
// src/collections/reserved-field-names.ts
|
|
1282
|
-
class ReservedFieldNames {
|
|
1283
|
-
static all = ["id", "rev", "seq", "created_at", "updated_at"];
|
|
1284
|
-
static isReserved(name) {
|
|
1285
|
-
return ReservedFieldNames.all.includes(name);
|
|
1286
1193
|
}
|
|
1287
1194
|
}
|
|
1288
1195
|
|
|
@@ -1301,7 +1208,6 @@ class Collections {
|
|
|
1301
1208
|
return body.items.map(Collections.toSummary);
|
|
1302
1209
|
}
|
|
1303
1210
|
async create(name, schema, options = {}) {
|
|
1304
|
-
Collections.warnOnReservedFields(schema);
|
|
1305
1211
|
return this.scope.transport.json({
|
|
1306
1212
|
method: "POST",
|
|
1307
1213
|
path: ApiPath.collections(this.scope.project, this.scope.environment),
|
|
@@ -1319,13 +1225,6 @@ class Collections {
|
|
|
1319
1225
|
updatedAt: new Date(payload.updated_at)
|
|
1320
1226
|
};
|
|
1321
1227
|
}
|
|
1322
|
-
static warnOnReservedFields(schema) {
|
|
1323
|
-
for (const name of Object.keys(schema.properties ?? {})) {
|
|
1324
|
-
if (ReservedFieldNames.isReserved(name)) {
|
|
1325
|
-
console.warn(`@org-quicko/silo-client: collection schema declares reserved field "${name}", which the server never returns`);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
1228
|
}
|
|
1330
1229
|
|
|
1331
1230
|
// src/variables/environment-variables.ts
|
|
@@ -1692,12 +1591,19 @@ class NetworkError extends Error {
|
|
|
1692
1591
|
method;
|
|
1693
1592
|
path;
|
|
1694
1593
|
constructor(method, path, cause) {
|
|
1695
|
-
super(`network error on ${method} ${path}: the request never reached the server`, { cause });
|
|
1594
|
+
super(`network error on ${method} ${path}: the request never reached the server${NetworkError.reason(cause)}`, { cause });
|
|
1696
1595
|
this.name = "NetworkError";
|
|
1697
1596
|
this.method = method;
|
|
1698
1597
|
this.path = path;
|
|
1699
1598
|
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1700
1599
|
}
|
|
1600
|
+
static reason(cause) {
|
|
1601
|
+
if (cause instanceof Error && cause.message)
|
|
1602
|
+
return ` (${cause.message})`;
|
|
1603
|
+
if (typeof cause === "string" && cause)
|
|
1604
|
+
return ` (${cause})`;
|
|
1605
|
+
return "";
|
|
1606
|
+
}
|
|
1701
1607
|
}
|
|
1702
1608
|
|
|
1703
1609
|
// src/errors/timeout-error.ts
|
|
@@ -1811,7 +1717,7 @@ class Transport {
|
|
|
1811
1717
|
this.key = options.key;
|
|
1812
1718
|
this.headers = options.headers ?? {};
|
|
1813
1719
|
this.timeoutMilliseconds = options.timeoutMilliseconds;
|
|
1814
|
-
this.fetchFunction = options.fetch
|
|
1720
|
+
this.fetchFunction = Transport.resolveFetch(options.fetch);
|
|
1815
1721
|
}
|
|
1816
1722
|
async json(request) {
|
|
1817
1723
|
const response = await this.execute(request);
|
|
@@ -1847,9 +1753,10 @@ class Transport {
|
|
|
1847
1753
|
async execute(request, form) {
|
|
1848
1754
|
const abortSignals = new AbortSignals(request.signal, request.timeoutMilliseconds ?? this.timeoutMilliseconds);
|
|
1849
1755
|
const url = `${this.url}${request.path}${QueryString.build(request.query)}`;
|
|
1756
|
+
const sendRequest = this.fetchFunction;
|
|
1850
1757
|
let response;
|
|
1851
1758
|
try {
|
|
1852
|
-
response = await
|
|
1759
|
+
response = await sendRequest(url, {
|
|
1853
1760
|
method: request.method,
|
|
1854
1761
|
headers: this.buildHeaders(request, Boolean(form)),
|
|
1855
1762
|
body: form ?? (request.body === undefined ? undefined : JSON.stringify(request.body)),
|
|
@@ -1887,6 +1794,14 @@ class Transport {
|
|
|
1887
1794
|
static normalizeUrl(url) {
|
|
1888
1795
|
return url.replace(/\/+$/, "");
|
|
1889
1796
|
}
|
|
1797
|
+
static resolveFetch(fetchFunction) {
|
|
1798
|
+
if (fetchFunction)
|
|
1799
|
+
return fetchFunction;
|
|
1800
|
+
if (typeof globalThis.fetch !== "function") {
|
|
1801
|
+
throw new Error("this runtime has no global fetch: pass one as SiloOptions.fetch");
|
|
1802
|
+
}
|
|
1803
|
+
return globalThis.fetch.bind(globalThis);
|
|
1804
|
+
}
|
|
1890
1805
|
}
|
|
1891
1806
|
|
|
1892
1807
|
// src/silo.ts
|
|
@@ -1971,6 +1886,7 @@ class RouteInventory {
|
|
|
1971
1886
|
"PATCH /api/media/:id",
|
|
1972
1887
|
"DELETE /api/media/:id",
|
|
1973
1888
|
"GET /api/media/:id/usages",
|
|
1889
|
+
"POST /api/media/:id/content",
|
|
1974
1890
|
"POST /api/media/delete",
|
|
1975
1891
|
"GET /api/media/folders",
|
|
1976
1892
|
"POST /api/media/folders",
|
|
@@ -1981,6 +1897,7 @@ class RouteInventory {
|
|
|
1981
1897
|
"GET /api/session": "key introspection, an operator surface",
|
|
1982
1898
|
"GET /api/keys": "keys and claims are an operator surface",
|
|
1983
1899
|
"POST /api/keys": "keys and claims are an operator surface",
|
|
1900
|
+
"PATCH /api/keys/:id": "keys and claims are an operator surface",
|
|
1984
1901
|
"DELETE /api/keys/:id": "keys and claims are an operator surface",
|
|
1985
1902
|
"GET /api/audit": "an operator surface",
|
|
1986
1903
|
"GET /api/observability": "an operator surface",
|
package/dist/index.d.cts
CHANGED
|
@@ -21,19 +21,17 @@ export type { DeleteOptions } from "./scope/delete-options.cjs";
|
|
|
21
21
|
export { Collections } from "./collections/collections.cjs";
|
|
22
22
|
export { CollectionHandle } from "./collections/collection-handle.cjs";
|
|
23
23
|
export { CollectionSchema } from "./collections/collection-schema.cjs";
|
|
24
|
-
export { ReservedFieldNames } from "./collections/reserved-field-names.cjs";
|
|
25
24
|
export type { CollectionSummary } from "./collections/collection-summary.cjs";
|
|
26
25
|
export type { CollectionDefinition } from "./collections/collection-definition.cjs";
|
|
27
26
|
export type { JsonSchema } from "./collections/json-schema.cjs";
|
|
28
|
-
export { EntryBase } from "./entries/entry-base.cjs";
|
|
29
|
-
export { ResolvedEntry } from "./entries/resolved-entry.cjs";
|
|
30
|
-
export { Entry } from "./entries/entry.cjs";
|
|
31
27
|
export { EntryPage } from "./entries/entry-page.cjs";
|
|
32
28
|
export { EntryStream } from "./entries/entry-stream.cjs";
|
|
33
29
|
export { EntryPageStream } from "./entries/entry-page-stream.cjs";
|
|
34
30
|
export { EntryReader } from "./entries/entry-reader.cjs";
|
|
31
|
+
export type { Entry } from "./entries/entry.cjs";
|
|
32
|
+
export type { EntryEnvelope } from "./entries/entry-envelope.cjs";
|
|
35
33
|
export type { EntryListQuery } from "./entries/entry-list-query.cjs";
|
|
36
|
-
export type {
|
|
34
|
+
export type { EntryReadOptions } from "./entries/entry-read-options.cjs";
|
|
37
35
|
export { Filter } from "./query/filter.cjs";
|
|
38
36
|
export { TypedFilter } from "./query/typed-filter.cjs";
|
|
39
37
|
export { FilterField } from "./query/filter-field.cjs";
|
|
@@ -73,6 +71,7 @@ export type { MediaAssetRecord } from "./media/media-asset.cjs";
|
|
|
73
71
|
export type { MediaQuery } from "./media/media-query.cjs";
|
|
74
72
|
export type { MediaUsage } from "./media/media-usage.cjs";
|
|
75
73
|
export type { MediaUsageQuery } from "./media/media-usage-page.cjs";
|
|
74
|
+
export type { MediaReplace, MediaReplaceBytes, MediaReplaceOptions } from "./media/media-replace.cjs";
|
|
76
75
|
export type { MediaUpload, MediaUploadBytes, MediaUploadFileOptions } from "./media/media-upload.cjs";
|
|
77
76
|
export type { MediaDeleteFailure } from "./media/media-delete-failure.cjs";
|
|
78
77
|
export type { MediaDeleteOptions } from "./media/media-delete-options.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -21,19 +21,17 @@ export type { DeleteOptions } from "./scope/delete-options.js";
|
|
|
21
21
|
export { Collections } from "./collections/collections.js";
|
|
22
22
|
export { CollectionHandle } from "./collections/collection-handle.js";
|
|
23
23
|
export { CollectionSchema } from "./collections/collection-schema.js";
|
|
24
|
-
export { ReservedFieldNames } from "./collections/reserved-field-names.js";
|
|
25
24
|
export type { CollectionSummary } from "./collections/collection-summary.js";
|
|
26
25
|
export type { CollectionDefinition } from "./collections/collection-definition.js";
|
|
27
26
|
export type { JsonSchema } from "./collections/json-schema.js";
|
|
28
|
-
export { EntryBase } from "./entries/entry-base.js";
|
|
29
|
-
export { ResolvedEntry } from "./entries/resolved-entry.js";
|
|
30
|
-
export { Entry } from "./entries/entry.js";
|
|
31
27
|
export { EntryPage } from "./entries/entry-page.js";
|
|
32
28
|
export { EntryStream } from "./entries/entry-stream.js";
|
|
33
29
|
export { EntryPageStream } from "./entries/entry-page-stream.js";
|
|
34
30
|
export { EntryReader } from "./entries/entry-reader.js";
|
|
31
|
+
export type { Entry } from "./entries/entry.js";
|
|
32
|
+
export type { EntryEnvelope } from "./entries/entry-envelope.js";
|
|
35
33
|
export type { EntryListQuery } from "./entries/entry-list-query.js";
|
|
36
|
-
export type {
|
|
34
|
+
export type { EntryReadOptions } from "./entries/entry-read-options.js";
|
|
37
35
|
export { Filter } from "./query/filter.js";
|
|
38
36
|
export { TypedFilter } from "./query/typed-filter.js";
|
|
39
37
|
export { FilterField } from "./query/filter-field.js";
|
|
@@ -73,6 +71,7 @@ export type { MediaAssetRecord } from "./media/media-asset.js";
|
|
|
73
71
|
export type { MediaQuery } from "./media/media-query.js";
|
|
74
72
|
export type { MediaUsage } from "./media/media-usage.js";
|
|
75
73
|
export type { MediaUsageQuery } from "./media/media-usage-page.js";
|
|
74
|
+
export type { MediaReplace, MediaReplaceBytes, MediaReplaceOptions } from "./media/media-replace.js";
|
|
76
75
|
export type { MediaUpload, MediaUploadBytes, MediaUploadFileOptions } from "./media/media-upload.js";
|
|
77
76
|
export type { MediaDeleteFailure } from "./media/media-delete-failure.js";
|
|
78
77
|
export type { MediaDeleteOptions } from "./media/media-delete-options.js";
|