@graffiti-garden/implementation-local 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +3 -3
- package/dist/cjs/database.js +4 -4
- package/dist/cjs/database.js.map +2 -2
- package/dist/cjs/utilities.js +1 -1
- package/dist/cjs/utilities.js.map +2 -2
- package/dist/database.d.ts +4 -4
- package/dist/database.d.ts.map +1 -1
- package/dist/esm/database.js +4 -4
- package/dist/esm/database.js.map +2 -2
- package/dist/esm/utilities.js +1 -1
- package/dist/esm/utilities.js.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/utilities.d.ts +2 -2
- package/dist/utilities.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/database.ts +8 -8
- package/src/utilities.ts +3 -3
package/src/database.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Graffiti,
|
|
3
3
|
GraffitiObjectBase,
|
|
4
|
-
|
|
4
|
+
GraffitiObjectUrl,
|
|
5
5
|
JSONSchema,
|
|
6
6
|
GraffitiSession,
|
|
7
7
|
} from "@graffiti-garden/api";
|
|
@@ -208,7 +208,7 @@ export class GraffitiLocalDatabase
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
protected async allDocsAtLocation(locationOrUri:
|
|
211
|
+
protected async allDocsAtLocation(locationOrUri: GraffitiObjectUrl | string) {
|
|
212
212
|
const uri = unpackLocationOrUri(locationOrUri) + "/";
|
|
213
213
|
const results = await (
|
|
214
214
|
await this.db
|
|
@@ -231,8 +231,8 @@ export class GraffitiLocalDatabase
|
|
|
231
231
|
return docs;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
protected docId(location:
|
|
235
|
-
return location.
|
|
234
|
+
protected docId(location: GraffitiObjectUrl) {
|
|
235
|
+
return location.url + "/" + randomBase64();
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
get: Graffiti["get"] = async (...args) => {
|
|
@@ -275,7 +275,7 @@ export class GraffitiLocalDatabase
|
|
|
275
275
|
* spared.
|
|
276
276
|
*/
|
|
277
277
|
protected async deleteAtLocation(
|
|
278
|
-
locationOrUri:
|
|
278
|
+
locationOrUri: GraffitiObjectUrl | string,
|
|
279
279
|
options: {
|
|
280
280
|
keepLatest?: boolean;
|
|
281
281
|
session?: GraffitiSession;
|
|
@@ -386,10 +386,10 @@ export class GraffitiLocalDatabase
|
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
if (objectPartial.
|
|
389
|
+
if (objectPartial.url) {
|
|
390
390
|
let oldObject: GraffitiObjectBase | undefined;
|
|
391
391
|
try {
|
|
392
|
-
oldObject = await this.get(objectPartial.
|
|
392
|
+
oldObject = await this.get(objectPartial.url, {}, session);
|
|
393
393
|
} catch (e) {
|
|
394
394
|
if (e instanceof GraffitiErrorNotFound) {
|
|
395
395
|
if (!this.options.allowSettingArbitraryUris) {
|
|
@@ -417,7 +417,7 @@ export class GraffitiLocalDatabase
|
|
|
417
417
|
value: objectPartial.value,
|
|
418
418
|
channels: objectPartial.channels,
|
|
419
419
|
allowed: objectPartial.allowed,
|
|
420
|
-
|
|
420
|
+
url: objectPartial.url ?? this.origin + randomBase64(),
|
|
421
421
|
actor: session.actor,
|
|
422
422
|
tombstone: false,
|
|
423
423
|
lastModified,
|
package/src/utilities.ts
CHANGED
|
@@ -10,13 +10,13 @@ import type {
|
|
|
10
10
|
GraffitiPatch,
|
|
11
11
|
JSONSchema,
|
|
12
12
|
GraffitiSession,
|
|
13
|
-
|
|
13
|
+
GraffitiObjectUrl,
|
|
14
14
|
} from "@graffiti-garden/api";
|
|
15
15
|
import type { Ajv } from "ajv";
|
|
16
16
|
import type { applyPatch } from "fast-json-patch";
|
|
17
17
|
|
|
18
|
-
export function unpackLocationOrUri(locationOrUri:
|
|
19
|
-
return typeof locationOrUri === "string" ? locationOrUri : locationOrUri.
|
|
18
|
+
export function unpackLocationOrUri(locationOrUri: GraffitiObjectUrl | string) {
|
|
19
|
+
return typeof locationOrUri === "string" ? locationOrUri : locationOrUri.url;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function randomBase64(numBytes: number = 24) {
|