@graffiti-garden/implementation-local 0.2.6 → 0.2.7
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/cjs/database.js +2 -0
- package/dist/cjs/database.js.map +7 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/session-manager.js +4 -0
- package/dist/cjs/session-manager.js.map +7 -0
- package/dist/cjs/synchronize.js +2 -0
- package/dist/cjs/synchronize.js.map +7 -0
- package/dist/cjs/tests.spec.js +2 -0
- package/dist/cjs/tests.spec.js.map +7 -0
- package/dist/cjs/utilities.js +2 -0
- package/dist/cjs/utilities.js.map +7 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/esm/database.js +2 -0
- package/dist/esm/database.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/session-manager.js +4 -0
- package/dist/esm/session-manager.js.map +7 -0
- package/dist/esm/synchronize.js +2 -0
- package/dist/esm/synchronize.js.map +7 -0
- package/dist/esm/tests.spec.js +2 -0
- package/dist/esm/tests.spec.js.map +7 -0
- package/dist/esm/utilities.js +2 -0
- package/dist/esm/utilities.js.map +7 -0
- package/dist/index.browser.js +50 -29
- package/dist/index.browser.js.map +7 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/synchronize.d.ts.map +1 -0
- package/dist/{src/tests.spec.d.ts.map → tests.spec.d.ts.map} +1 -1
- package/dist/utilities.d.ts.map +1 -0
- package/package.json +27 -61
- package/dist/database.browser.js +0 -27
- package/dist/database.browser.js.map +0 -1
- package/dist/database.cjs.js +0 -2
- package/dist/database.cjs.js.map +0 -1
- package/dist/database.js +0 -2
- package/dist/database.js.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/session-manager.browser.js +0 -2
- package/dist/session-manager.browser.js.map +0 -1
- package/dist/session-manager.cjs.js +0 -2
- package/dist/session-manager.cjs.js.map +0 -1
- package/dist/session-manager.js +0 -2
- package/dist/session-manager.js.map +0 -1
- package/dist/src/database.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/session-manager.d.ts.map +0 -1
- package/dist/src/synchronize.d.ts.map +0 -1
- package/dist/src/utilities.d.ts.map +0 -1
- package/dist/synchronize.browser.js +0 -18
- package/dist/synchronize.browser.js.map +0 -1
- package/dist/synchronize.cjs.js +0 -2
- package/dist/synchronize.cjs.js.map +0 -1
- package/dist/synchronize.js +0 -2
- package/dist/synchronize.js.map +0 -1
- package/dist/utilities.browser.js +0 -2
- package/dist/utilities.browser.js.map +0 -1
- package/dist/utilities.cjs.js +0 -2
- package/dist/utilities.cjs.js.map +0 -1
- package/dist/utilities.js +0 -2
- package/dist/utilities.js.map +0 -1
- /package/dist/{src/database.d.ts → database.d.ts} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/session-manager.d.ts → session-manager.d.ts} +0 -0
- /package/dist/{src/synchronize.d.ts → synchronize.d.ts} +0 -0
- /package/dist/{src/tests.spec.d.ts → tests.spec.d.ts} +0 -0
- /package/dist/{src/utilities.d.ts → utilities.d.ts} +0 -0
package/dist/synchronize.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("ajv-draft-04"),t=require("@repeaterjs/repeater"),n=require("fast-json-patch"),r=require("@graffiti-garden/api");const o=e=>`${e.source}/${encodeURIComponent(e.actor)}/${encodeURIComponent(e.name)}`,i=e=>{const t=e.split("/"),n=t.pop(),o=t.pop();if(!n||!o||!t.length)throw new r.GraffitiErrorInvalidUri;return{name:decodeURIComponent(n),actor:decodeURIComponent(o),source:t.join("/")}};function a(e,t,n,o){const i=n[t];if(i&&i.length)try{o[t]=e(o[t],i,!0,!1).newDocument}catch(e){throw"object"==typeof e&&e&&"name"in e&&"string"==typeof e.name&&"message"in e&&"string"==typeof e.message?"TEST_OPERATION_FAILED"===e.name?new r.GraffitiErrorPatchTestFailed(e.message):new r.GraffitiErrorPatchError(e.name+": "+e.message):e}}function c(e,t,n){e.actor!==n?.actor&&(e.allowed=e.allowed&&n?[n.actor]:void 0,e.channels=e.channels.filter((e=>t.includes(e))))}function s(e,t){return void 0===e.allowed||null===e.allowed||!!t?.actor&&(e.actor===t.actor||e.allowed.includes(t.actor))}exports.GraffitiSynchronize=class{synchronizeEvents=new EventTarget;ajv;graffiti;constructor(t,n){this.ajv=n??new e({strict:!1}),this.graffiti=t}synchronizeDispatch(e,t){const n=new CustomEvent("change",{detail:{oldObject:e,newObject:t}});this.synchronizeEvents.dispatchEvent(n)}get=async(...e)=>{const t=await this.graffiti.get(...e);return this.synchronizeDispatch(t),t};put=async(...e)=>{const t=await this.graffiti.put(...e),n=e[0],r={...t,value:n.value,channels:n.channels,allowed:n.allowed,tombstone:!1};return this.synchronizeDispatch(t,r),t};patch=async(...e)=>{const t=await this.graffiti.patch(...e),r={...t};r.tombstone=!1;for(const t of["value","channels","allowed"])a(n.applyPatch,t,e[0],r);return this.synchronizeDispatch(t,r),t};delete=async(...e)=>{const t=await this.graffiti.delete(...e);return this.synchronizeDispatch(t),t};objectStream(e){const t=this.synchronizeDispatch.bind(this);return async function*(){let n=await e.next();for(;!n.done;)n.value.error||t(n.value.value),yield n.value,n=await e.next();return n.value}()}discover=(...e)=>{const t=this.graffiti.discover(...e);return this.objectStream(t)};recoverOrphans=(...e)=>{const t=this.graffiti.recoverOrphans(...e);return this.objectStream(t)};synchronize(e,n,o,i){const a=function(e,t){try{return e.compile(t)}catch(e){throw new r.GraffitiErrorInvalidSchema(e instanceof Error?e.message:void 0)}}(this.ajv,o);return new t.Repeater((async(t,r)=>{const o=r=>{const{oldObject:o,newObject:h}=r.detail;for(const r of[h,o])if(r&&e(r)&&s(r,i)){const e={...r};if(c(e,n,i),a(e)){t({value:e});break}}};this.synchronizeEvents.addEventListener("change",o),await r,this.synchronizeEvents.removeEventListener("change",o)}))}synchronizeDiscover=(...e)=>{const[t,n,r]=e;return this.synchronize((function(e){return e.channels.some((e=>t.includes(e)))}),t,n,r)};synchronizeGet=(...e)=>{const[t,n,r]=e;return this.synchronize((function(e){const n=o(e),{uri:r}=function(e){return"string"==typeof e?{location:i(e),uri:e}:{location:{name:e.name,actor:e.actor,source:e.source},uri:o(e)}}(t);return n===r}),[],n,r)};synchronizeRecoverOrphans=(...e)=>{const[t,n]=e;return this.synchronize((function(e){return e.actor===n.actor&&0===e.channels.length}),[],t,n)}};
|
|
2
|
-
//# sourceMappingURL=synchronize.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/synchronize.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import t from"ajv-draft-04";import{Repeater as e}from"@repeaterjs/repeater";import{applyPatch as n}from"fast-json-patch";import{GraffitiErrorPatchTestFailed as o,GraffitiErrorPatchError as r,GraffitiErrorInvalidSchema as s,GraffitiErrorInvalidUri as c}from"@graffiti-garden/api";const i=t=>`${t.source}/${encodeURIComponent(t.actor)}/${encodeURIComponent(t.name)}`,a=t=>{const e=t.split("/"),n=e.pop(),o=e.pop();if(!n||!o||!e.length)throw new c;return{name:decodeURIComponent(n),actor:decodeURIComponent(o),source:e.join("/")}};function h(t,e,n,s){const c=n[e];if(c&&c.length)try{s[e]=t(s[e],c,!0,!1).newDocument}catch(t){throw"object"==typeof t&&t&&"name"in t&&"string"==typeof t.name&&"message"in t&&"string"==typeof t.message?"TEST_OPERATION_FAILED"===t.name?new o(t.message):new r(t.name+": "+t.message):t}}function l(t,e,n){t.actor!==n?.actor&&(t.allowed=t.allowed&&n?[n.actor]:void 0,t.channels=t.channels.filter((t=>e.includes(t))))}function u(t,e){return void 0===t.allowed||null===t.allowed||!!e?.actor&&(t.actor===e.actor||t.allowed.includes(e.actor))}class f{synchronizeEvents=new EventTarget;ajv;graffiti;constructor(e,n){this.ajv=n??new t({strict:!1}),this.graffiti=e}synchronizeDispatch(t,e){const n=new CustomEvent("change",{detail:{oldObject:t,newObject:e}});this.synchronizeEvents.dispatchEvent(n)}get=async(...t)=>{const e=await this.graffiti.get(...t);return this.synchronizeDispatch(e),e};put=async(...t)=>{const e=await this.graffiti.put(...t),n=t[0],o={...e,value:n.value,channels:n.channels,allowed:n.allowed,tombstone:!1};return this.synchronizeDispatch(e,o),e};patch=async(...t)=>{const e=await this.graffiti.patch(...t),o={...e};o.tombstone=!1;for(const e of["value","channels","allowed"])h(n,e,t[0],o);return this.synchronizeDispatch(e,o),e};delete=async(...t)=>{const e=await this.graffiti.delete(...t);return this.synchronizeDispatch(e),e};objectStream(t){const e=this.synchronizeDispatch.bind(this);return async function*(){let n=await t.next();for(;!n.done;)n.value.error||e(n.value.value),yield n.value,n=await t.next();return n.value}()}discover=(...t)=>{const e=this.graffiti.discover(...t);return this.objectStream(e)};recoverOrphans=(...t)=>{const e=this.graffiti.recoverOrphans(...t);return this.objectStream(e)};synchronize(t,n,o,r){const c=function(t,e){try{return t.compile(e)}catch(t){throw new s(t instanceof Error?t.message:void 0)}}(this.ajv,o);return new e((async(e,o)=>{const s=o=>{const{oldObject:s,newObject:i}=o.detail;for(const o of[i,s])if(o&&t(o)&&u(o,r)){const t={...o};if(l(t,n,r),c(t)){e({value:t});break}}};this.synchronizeEvents.addEventListener("change",s),await o,this.synchronizeEvents.removeEventListener("change",s)}))}synchronizeDiscover=(...t)=>{const[e,n,o]=t;return this.synchronize((function(t){return t.channels.some((t=>e.includes(t)))}),e,n,o)};synchronizeGet=(...t)=>{const[e,n,o]=t;return this.synchronize((function(t){const n=i(t),{uri:o}=function(t){return"string"==typeof t?{location:a(t),uri:t}:{location:{name:t.name,actor:t.actor,source:t.source},uri:i(t)}}(e);return n===o}),[],n,o)};synchronizeRecoverOrphans=(...t)=>{const[e,n]=t;return this.synchronize((function(t){return t.actor===n.actor&&0===t.channels.length}),[],e,n)}}export{f as GraffitiSynchronize};
|
|
2
|
-
//# sourceMappingURL=synchronize.js.map
|
package/dist/synchronize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
class t extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,t.prototype)}}class e extends Error{constructor(t){super(t),this.name="GraffitiErrorPatchTestFailed",Object.setPrototypeOf(this,e.prototype)}}class o extends Error{constructor(t){super(t),this.name="GraffitiErrorPatchError",Object.setPrototypeOf(this,o.prototype)}}class r extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidUri",Object.setPrototypeOf(this,r.prototype)}}const n=t=>`${t.source}/${encodeURIComponent(t.actor)}/${encodeURIComponent(t.name)}`,c=t=>{const e=t.split("/"),o=e.pop(),n=e.pop();if(!o||!n||!e.length)throw new r;return{name:decodeURIComponent(o),actor:decodeURIComponent(n),source:e.join("/")}};function s(t=16){const e=new Uint8Array(t);crypto.getRandomValues(e);return btoa(String.fromCodePoint(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}function a(t){return"string"==typeof t?{location:c(t),uri:t}:{location:{name:t.name,actor:t.actor,source:t.source},uri:n(t)}}function i(t,e){return t.lastModified>e.lastModified||t.lastModified===e.lastModified&&!t.tombstone&&e.tombstone}function l(t,r,n,c){const s=n[r];if(s&&s.length)try{c[r]=t(c[r],s,!0,!1).newDocument}catch(t){throw"object"==typeof t&&t&&"name"in t&&"string"==typeof t.name&&"message"in t&&"string"==typeof t.message?"TEST_OPERATION_FAILED"===t.name?new e(t.message):new o(t.name+": "+t.message):t}}function p(e,o){try{return e.compile(o)}catch(e){throw new t(e instanceof Error?e.message:void 0)}}function d(t,e,o){t.actor!==o?.actor&&(t.allowed=t.allowed&&o?[o.actor]:void 0,t.channels=t.channels.filter((t=>e.includes(t))))}function f(t,e){return void 0===t.allowed||null===t.allowed||!!e?.actor&&(t.actor===e.actor||t.allowed.includes(e.actor))}export{l as applyGraffitiPatch,p as attemptAjvCompile,f as isActorAllowedGraffitiObject,i as isObjectNewer,n as locationToUri,d as maskGraffitiObject,s as randomBase64,a as unpackLocationOrUri,c as uriToLocation};
|
|
2
|
-
//# sourceMappingURL=utilities.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.browser.js","sources":["../node_modules/@graffiti-garden/api/dist/index.js"],"sourcesContent":["class r{objectToUri(r){return this.locationToUri(r)}}class t extends Error{constructor(r){super(r),this.name=\"GraffitiErrorUnauthorized\",Object.setPrototypeOf(this,t.prototype)}}class o extends Error{constructor(r){super(r),this.name=\"GraffitiErrorForbidden\",Object.setPrototypeOf(this,o.prototype)}}class e extends Error{constructor(r){super(r),this.name=\"GraffitiErrorNotFound\",Object.setPrototypeOf(this,e.prototype)}}class s extends Error{constructor(r){super(r),this.name=\"GraffitiErrorInvalidSchema\",Object.setPrototypeOf(this,s.prototype)}}class i extends Error{constructor(r){super(r),this.name=\"GraffitiErrorSchemaMismatch\",Object.setPrototypeOf(this,i.prototype)}}class c extends Error{constructor(r){super(r),this.name=\"GraffitiErrorPatchTestFailed\",Object.setPrototypeOf(this,c.prototype)}}class a extends Error{constructor(r){super(r),this.name=\"GraffitiErrorPatchError\",Object.setPrototypeOf(this,a.prototype)}}class p extends Error{constructor(r){super(r),this.name=\"GraffitiErrorInvalidUri\",Object.setPrototypeOf(this,p.prototype)}}export{r as Graffiti,o as GraffitiErrorForbidden,s as GraffitiErrorInvalidSchema,p as GraffitiErrorInvalidUri,e as GraffitiErrorNotFound,a as GraffitiErrorPatchError,c as GraffitiErrorPatchTestFailed,i as GraffitiErrorSchemaMismatch,t as GraffitiErrorUnauthorized};\n//# sourceMappingURL=index.js.map\n"],"names":["s","Error","constructor","r","super","this","name","Object","setPrototypeOf","prototype","c","a","p"],"mappings":"AAAqa,MAAMA,UAAUC,MAAM,WAAAC,CAAYC,GAAGC,MAAMD,GAAGE,KAAKC,KAAK,6BAA6BC,OAAOC,eAAeH,KAAKL,EAAES,UAAU,EAAiI,MAAMC,UAAUT,MAAM,WAAAC,CAAYC,GAAGC,MAAMD,GAAGE,KAAKC,KAAK,+BAA+BC,OAAOC,eAAeH,KAAKK,EAAED,UAAU,EAAE,MAAME,UAAUV,MAAM,WAAAC,CAAYC,GAAGC,MAAMD,GAAGE,KAAKC,KAAK,0BAA0BC,OAAOC,eAAeH,KAAKM,EAAEF,UAAU,EAAE,MAAMG,UAAUX,MAAM,WAAAC,CAAYC,GAAGC,MAAMD,GAAGE,KAAKC,KAAK,0BAA0BC,OAAOC,eAAeH,KAAKO,EAAEH,UAAU","x_google_ignoreList":[0]}
|
package/dist/utilities.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@graffiti-garden/api");const o=e=>`${e.source}/${encodeURIComponent(e.actor)}/${encodeURIComponent(e.name)}`,t=o=>{const t=o.split("/"),r=t.pop(),n=t.pop();if(!r||!n||!t.length)throw new e.GraffitiErrorInvalidUri;return{name:decodeURIComponent(r),actor:decodeURIComponent(n),source:t.join("/")}};exports.applyGraffitiPatch=function(o,t,r,n){const a=r[t];if(a&&a.length)try{n[t]=o(n[t],a,!0,!1).newDocument}catch(o){throw"object"==typeof o&&o&&"name"in o&&"string"==typeof o.name&&"message"in o&&"string"==typeof o.message?"TEST_OPERATION_FAILED"===o.name?new e.GraffitiErrorPatchTestFailed(o.message):new e.GraffitiErrorPatchError(o.name+": "+o.message):o}},exports.attemptAjvCompile=function(o,t){try{return o.compile(t)}catch(o){throw new e.GraffitiErrorInvalidSchema(o instanceof Error?o.message:void 0)}},exports.isActorAllowedGraffitiObject=function(e,o){return void 0===e.allowed||null===e.allowed||!!o?.actor&&(e.actor===o.actor||e.allowed.includes(o.actor))},exports.isObjectNewer=function(e,o){return e.lastModified>o.lastModified||e.lastModified===o.lastModified&&!e.tombstone&&o.tombstone},exports.locationToUri=o,exports.maskGraffitiObject=function(e,o,t){e.actor!==t?.actor&&(e.allowed=e.allowed&&t?[t.actor]:void 0,e.channels=e.channels.filter((e=>o.includes(e))))},exports.randomBase64=function(e=16){const o=new Uint8Array(e);return crypto.getRandomValues(o),btoa(String.fromCodePoint(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")},exports.unpackLocationOrUri=function(e){return"string"==typeof e?{location:t(e),uri:e}:{location:{name:e.name,actor:e.actor,source:e.source},uri:o(e)}},exports.uriToLocation=t;
|
|
2
|
-
//# sourceMappingURL=utilities.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/utilities.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{GraffitiErrorInvalidUri as e,GraffitiErrorPatchTestFailed as o,GraffitiErrorPatchError as n,GraffitiErrorInvalidSchema as t}from"@graffiti-garden/api";const r=e=>`${e.source}/${encodeURIComponent(e.actor)}/${encodeURIComponent(e.name)}`,a=o=>{const n=o.split("/"),t=n.pop(),r=n.pop();if(!t||!r||!n.length)throw new e;return{name:decodeURIComponent(t),actor:decodeURIComponent(r),source:n.join("/")}};function c(e=16){const o=new Uint8Array(e);crypto.getRandomValues(o);return btoa(String.fromCodePoint(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}function i(e){return"string"==typeof e?{location:a(e),uri:e}:{location:{name:e.name,actor:e.actor,source:e.source},uri:r(e)}}function s(e,o){return e.lastModified>o.lastModified||e.lastModified===o.lastModified&&!e.tombstone&&o.tombstone}function l(e,t,r,a){const c=r[t];if(c&&c.length)try{a[t]=e(a[t],c,!0,!1).newDocument}catch(e){throw"object"==typeof e&&e&&"name"in e&&"string"==typeof e.name&&"message"in e&&"string"==typeof e.message?"TEST_OPERATION_FAILED"===e.name?new o(e.message):new n(e.name+": "+e.message):e}}function d(e,o){try{return e.compile(o)}catch(e){throw new t(e instanceof Error?e.message:void 0)}}function m(e,o,n){e.actor!==n?.actor&&(e.allowed=e.allowed&&n?[n.actor]:void 0,e.channels=e.channels.filter((e=>o.includes(e))))}function u(e,o){return void 0===e.allowed||null===e.allowed||!!o?.actor&&(e.actor===o.actor||e.allowed.includes(o.actor))}export{l as applyGraffitiPatch,d as attemptAjvCompile,u as isActorAllowedGraffitiObject,s as isObjectNewer,r as locationToUri,m as maskGraffitiObject,c as randomBase64,i as unpackLocationOrUri,a as uriToLocation};
|
|
2
|
-
//# sourceMappingURL=utilities.js.map
|
package/dist/utilities.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|