prostgles-types 4.0.263 → 4.0.264
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/WAL.d.ts +0 -2
- package/dist/WAL.d.ts.map +1 -1
- package/dist/WAL.js +2 -4
- package/dist/WAL.js.map +1 -1
- package/dist/index_umd.js +1 -1
- package/lib/WAL.ts +2 -4
- package/package.json +1 -1
package/dist/WAL.d.ts
CHANGED
|
@@ -68,8 +68,6 @@ export declare class WAL {
|
|
|
68
68
|
/**
|
|
69
69
|
* Used by server to avoid unnecessary data push to client.
|
|
70
70
|
* This can happen due to the same data item having been previously pushed by the client
|
|
71
|
-
* @param item data item
|
|
72
|
-
* @returns boolean
|
|
73
71
|
*/
|
|
74
72
|
isInHistory: (item: AnyObject) => boolean;
|
|
75
73
|
getIdStr(d: AnyObject): string;
|
package/dist/WAL.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WAL.d.ts","sourceRoot":"","sources":["../lib/WAL.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGtF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,oBAAoB,CAAC;IACjC,GAAG,EAAE,OAAO,CAAC;CACd,EAAE,CAAC;AAEJ,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG;IACtC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC;IACxB;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,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I,IAAI,SAAS,EAAE,IAAI,SAAS,KAAG,MAAM,CAuB3C;IAEF,SAAS,IAAI,OAAO;IAQpB;;;OAGG;IACH,WAAW,GAAI,MAAM,SAAS,KAAG,OAAO,CAgBtC;IAEF,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM;IAM9B,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS;IAOjC,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS;IAUpC,OAAO,GAAI,MAAM,OAAO,EAAE,mBAoBxB;IAEF,WAAW,UAAS;IACpB,gBAAgB,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAa;IAC7D,iBAAiB,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAa;IAC9D,OAAO,CAAC,SAAS,CAsHf;CACH"}
|
package/dist/WAL.js
CHANGED
|
@@ -42,8 +42,6 @@ class WAL {
|
|
|
42
42
|
/**
|
|
43
43
|
* Used by server to avoid unnecessary data push to client.
|
|
44
44
|
* This can happen due to the same data item having been previously pushed by the client
|
|
45
|
-
* @param item data item
|
|
46
|
-
* @returns boolean
|
|
47
45
|
*/
|
|
48
46
|
this.isInHistory = (item) => {
|
|
49
47
|
if (!item)
|
|
@@ -65,7 +63,7 @@ class WAL {
|
|
|
65
63
|
this.addData = (data) => {
|
|
66
64
|
if ((0, index_1.isEmpty)(this.changed) && this.options.onSendStart)
|
|
67
65
|
this.options.onSendStart();
|
|
68
|
-
data.
|
|
66
|
+
data.forEach((d) => {
|
|
69
67
|
var _a;
|
|
70
68
|
const { initial, current, delta } = { ...d };
|
|
71
69
|
if (!current)
|
|
@@ -208,7 +206,7 @@ class WAL {
|
|
|
208
206
|
getIdStr(d) {
|
|
209
207
|
return this.options.id_fields
|
|
210
208
|
.sort()
|
|
211
|
-
.map((key) =>
|
|
209
|
+
.map((key) => String(d[key]))
|
|
212
210
|
.join(".");
|
|
213
211
|
}
|
|
214
212
|
getIdObj(d) {
|
package/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GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;CAkJF;AA7PD,kBA6PC"}
|
package/dist/index_umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(Object(this||window),()=>(()=>{"use strict";var e={994(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(472);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(472),i=n(704),o=n(441);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const s=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:s,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&s(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},l=(0,r.getKeys)(a),c=(e,n,s=[],p)=>{const f=`${s.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,d=(0,t.getFieldTypeObj)(n),{type:y,allowedValues:m,nullable:g,optional:h}=d;if(g&&null===e)return;if(h&&void 0===e)return;if(m){if("string"!=typeof y)throw new Error("allowedValues is only supported for primitive types");const t=y.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=m.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${s.join(".")}[${e}]`:s.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(y){if((0,r.isObject)(y)){if(!(0,r.isObject)(e))return f;for(const t of(0,i.safeGetKeys)(y)){const n=(0,i.safeGetProperty)(y,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...s,t].join(".")} is missing but required`;const o=c((0,i.safeGetProperty)(e,t),n,[...s,t],p);if(void 0!==o)return o}if(!p?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(y),r=t.filter(e=>!n.includes(e));if(r.length)return`${s.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,o.includes)(l,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(y,d);return t(e,d)?void 0:f}if(d.enum){const t=[];return d.nullable&&t.push(null),d.optional&&t.push(void 0),d.enum.includes(e)?void 0:f}const b=d.arrayOf??(d.arrayOfType?{type:d.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return f+" an array";const t=e.map((e,t)=>c(e,b,[...s,`${t}`],p)).filter(r.isDefined)[0];return void 0!==t?`${f}. Error at index ${s.length>0?s.join(".")+".":""}\n\n${t}`:void 0}const O=d.oneOf??d.oneOfType?.map(e=>({type:e}));if(O){if(!O.length)return f+"to not be empty";let t;if(O.find(n=>{const r=c(e,n,s,p);return t??(t=r),void 0===r}))return;return f}if(d.record){const{keysEnum:t,partial:n,values:o}=d.record;if(!(0,r.isObject)(e))return f+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),l=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==l)return`${f} to have key ${l}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${f} has extra keys: ${u}`;if(o)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=c(n,o,[...s,t],p);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(d)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:o,optional:s,record:a}=n,l=n.oneOf??n.oneOfType?.map(e=>({type:e})),c=[];if(o&&c.push("null"),s&&c.push("undefined"),"string"==typeof i)c.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),c.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?c.push("null"):void 0===e?c.push("undefined"):"string"==typeof e?c.push(JSON.stringify(e)):c.push(e)}),l?.forEach(e=>{const t=u(e);c.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?c.push(`{ [${e.join(" | ")}]${r}: ${i} }`):c.push(`{ [key: string]${r}: ${i} }`)}return c.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,o)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const s=c(t,{type:e},[],o);return s?{error:s}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=c(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:o}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===o},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:o}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(o)throw new Error(o)}},699(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(472),i=n(704),o=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:s,arrayOf:a,arrayOfType:l,description:c,nullable:u,oneOf:p,oneOfType:f,title:d,record:y,...m}="string"==typeof e?{type:e}:e;let g={};const h={...(m.enum||m.allowedValues?.length&&("string"!=typeof s||!s.endsWith("[]")))&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!c&&{description:c},...!!d&&{title:d}};if(m.enum?.length){const e=typeof m.enum[0];h.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof s||a||l){if(s&&"string"!=typeof s)throw"Not expected";g=a||l||s?.endsWith("[]")?{type:"array",items:a||l?(0,t.getJSONSchemaObject)(a||{type:l}):s?.startsWith("any")?{type:void 0}:{type:o(s)?.type,...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:o(s)?.type}}else if((0,r.isObject)(s))g={type:"object",required:(0,i.safeGetKeys)(s).filter(e=>{const t=s[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(s).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})};else if(p||f){const e=p||f.map(e=>({type:e}));g={oneOf:e.map(e=>(0,t.getJSONSchemaObject)(e))}}else y&&(g={type:"object",...y.values&&!y.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(y.values)},...y.keysEnum&&{properties:y.keysEnum.reduce((e,n)=>({...e,[n]:y.values?(0,t.getJSONSchemaObject)(y.values):{type:{}}}),{})}});if(u){const e={type:"null"};g.oneOf?g.oneOf.push(e):g.enum&&!g.enum.includes(null)?g.enum.push(null):g={oneOf:[g,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...h,...g}}},394(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(806),i=n(897),o=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,l="",c=0)=>{const u=(0,i.getFieldTypeObj)(n),p=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let o=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;o=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${o}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return p+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return p+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:o}=u,l=a?" ":" ";let f=` {${l}`+(0,r.getObjectEntries)(o).map(([r,o])=>{const a=(0,i.getFieldTypeObj)(o),u=s(r)?r:JSON.stringify(r);return`${l}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,c+1))}).join(" ")+`${l}}`;return a||(f=n(f)),a&&(f=f.split("\n").join("")),p+f}if(u.enum)return p+u.enum.map(e=>o(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${l} | null`:"")+n.map(n=>`\n${l} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,c+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,c+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,s=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${s(`${n?.map(e=>o(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,c+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const s=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704(e,t){t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},502(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(806);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],o=+r-+i,s=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(o)?o:s}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const o=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[o]??(t[o]={initial:n,current:r,delta:i}),this.changed[o].current={...this.changed[o].current,...r},this.changed[o].delta={...this.changed[o].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:o,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,l=[],c=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},c.push({...t}),u[e]={...t.current},delete this.changed[e]}),l=c.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],o=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,o)||(t[n]=o)}),t}),e&&console.log(this.options.id," SENDING lr->",l[l.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},o)),this.isOnSending=!0;try{await t(l,c),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*s)))}catch(e){a=e,console.error("WAL onSend failed:",e,l,c)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",l[l.length-1]),(0,r.isEmpty)(this.changed)?n&&n(l,c,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},618(e,t){Object.defineProperty(t,"__esModule",{value:!0})},521(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(472);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const o=n(472),s=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,o.getKeys)(t.TS_PG_Types).find(n=>(0,s.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const o=i.columns.filter(e=>r.includes(e.name));return o.length?{ref:e,fcolsInfo:o}:void 0}).filter(o.isDefined),[i,...s]=r??[];if(!s.length)return i?.ref;const[a,...l]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!l.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(618),t);var l=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return l.CONTENT_TYPE_TO_EXT}}),i(n(209),t),i(n(319),t),i(n(699),t),i(n(394),t),i(n(994),t),i(n(897),t),i(n(164),t),i(n(472),t),i(n(502),t),i(n(778),t)},319(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(472),i=(e="$leftJoin")=>(t,n,i,o={})=>({[e]:o.path??t,filter:n,...(0,r.omitKeys)(o,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},666(e,t){function n(e,t){var n=e[0],r=e[1],l=e[2],c=e[3];n=i(n,r,l,c,t[0],7,-680876936),c=i(c,n,r,l,t[1],12,-389564586),l=i(l,c,n,r,t[2],17,606105819),r=i(r,l,c,n,t[3],22,-1044525330),n=i(n,r,l,c,t[4],7,-176418897),c=i(c,n,r,l,t[5],12,1200080426),l=i(l,c,n,r,t[6],17,-1473231341),r=i(r,l,c,n,t[7],22,-45705983),n=i(n,r,l,c,t[8],7,1770035416),c=i(c,n,r,l,t[9],12,-1958414417),l=i(l,c,n,r,t[10],17,-42063),r=i(r,l,c,n,t[11],22,-1990404162),n=i(n,r,l,c,t[12],7,1804603682),c=i(c,n,r,l,t[13],12,-40341101),l=i(l,c,n,r,t[14],17,-1502002290),n=o(n,r=i(r,l,c,n,t[15],22,1236535329),l,c,t[1],5,-165796510),c=o(c,n,r,l,t[6],9,-1069501632),l=o(l,c,n,r,t[11],14,643717713),r=o(r,l,c,n,t[0],20,-373897302),n=o(n,r,l,c,t[5],5,-701558691),c=o(c,n,r,l,t[10],9,38016083),l=o(l,c,n,r,t[15],14,-660478335),r=o(r,l,c,n,t[4],20,-405537848),n=o(n,r,l,c,t[9],5,568446438),c=o(c,n,r,l,t[14],9,-1019803690),l=o(l,c,n,r,t[3],14,-187363961),r=o(r,l,c,n,t[8],20,1163531501),n=o(n,r,l,c,t[13],5,-1444681467),c=o(c,n,r,l,t[2],9,-51403784),l=o(l,c,n,r,t[7],14,1735328473),n=s(n,r=o(r,l,c,n,t[12],20,-1926607734),l,c,t[5],4,-378558),c=s(c,n,r,l,t[8],11,-2022574463),l=s(l,c,n,r,t[11],16,1839030562),r=s(r,l,c,n,t[14],23,-35309556),n=s(n,r,l,c,t[1],4,-1530992060),c=s(c,n,r,l,t[4],11,1272893353),l=s(l,c,n,r,t[7],16,-155497632),r=s(r,l,c,n,t[10],23,-1094730640),n=s(n,r,l,c,t[13],4,681279174),c=s(c,n,r,l,t[0],11,-358537222),l=s(l,c,n,r,t[3],16,-722521979),r=s(r,l,c,n,t[6],23,76029189),n=s(n,r,l,c,t[9],4,-640364487),c=s(c,n,r,l,t[12],11,-421815835),l=s(l,c,n,r,t[15],16,530742520),n=a(n,r=s(r,l,c,n,t[2],23,-995338651),l,c,t[0],6,-198630844),c=a(c,n,r,l,t[7],10,1126891415),l=a(l,c,n,r,t[14],15,-1416354905),r=a(r,l,c,n,t[5],21,-57434055),n=a(n,r,l,c,t[12],6,1700485571),c=a(c,n,r,l,t[3],10,-1894986606),l=a(l,c,n,r,t[10],15,-1051523),r=a(r,l,c,n,t[1],21,-2054922799),n=a(n,r,l,c,t[8],6,1873313359),c=a(c,n,r,l,t[15],10,-30611744),l=a(l,c,n,r,t[6],15,-1560198380),r=a(r,l,c,n,t[13],21,1309151649),n=a(n,r,l,c,t[4],6,-145523070),c=a(c,n,r,l,t[11],10,-1120210379),l=a(l,c,n,r,t[2],15,718787259),r=a(r,l,c,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(l,e[2]),e[3]=f(c,e[3])}function r(e,t,n,r,i,o){return t=f(f(t,e),f(r,o)),f(t<<i|t>>>32-i,n)}function i(e,t,n,i,o,s,a){return r(t&n|~t&i,e,t,o,s,a)}function o(e,t,n,i,o,s,a){return r(t&i|n&~i,e,t,o,s,a)}function s(e,t,n,i,o,s,a){return r(t^n^i,e,t,o,s,a)}function a(e,t,n,i,o,s,a){return r(n^(t|~i),e,t,o,s,a)}function l(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}t.md5=p;var c="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=c[e>>8*n+4&15]+c[e>>8*n&15];return t}function p(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,l(e.substring(t-64,t)));e=e.substring(t-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(i,o),t=0;t<16;t++)o[t]=0;return o[14]=8*r,n(i,o),i}(e))}function f(e,t){return e+t&4294967295}p("hello")},164(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ReplicationProtocol=t.getSyncChannelName=void 0;const r=n(806);var i;t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join("."),function(e){e.CreateSchema={name:"Create",source:"client",request:{type:{tableName:"string",command:{enum:["sync"]},param1:{record:{values:"unknown"}},param2:{type:{select:"unknown"}}}},response:{type:{id_fields:"string[]",synced_field:"string",channelName:"string",data:"any[]",isSynced:"boolean"}}};const t={state:{enum:["syncing"]},c_fr:{optional:!0,record:{values:"unknown"}},c_lr:{optional:!0,record:{values:"unknown"}},c_count:"number"},n={state:{enum:["syncing-data"]},c_fr:{record:{values:"unknown"}},c_lr:{record:{values:"unknown"}},c_count:"number",data:{arrayOf:{record:{values:"unknown"}}}},i={from_synced:{oneOf:["string","number",{enum:[void 0]}]},to_synced:{oneOf:["string","number",{enum:[void 0]}]}};e.ServerSyncRequest={name:"ServerSyncRequest",source:"server",request:{type:{...i,end_offset:{oneOf:["number",{enum:[null]}]}}},response:{oneOfType:[t,n,{state:{enum:["error"]},err:"unknown"}]}},e.ClientSyncRequest={name:"ClientSyncRequest",source:"client",request:{oneOfType:[t,n]},response:{oneOfType:[{success:{enum:[!0]}},{success:{enum:[!1]},err:"unknown"}]}},e.PullRequest={name:"PullRequest",source:"server",request:{type:{...i,offset:{oneOf:["number",{enum:[void 0]}]},limit:{oneOf:["number",{enum:[void 0]}]}}},response:{oneOfType:[{success:{enum:[!0]},data:{arrayOf:{record:{values:"unknown"}}}},{success:{enum:[!1]},err:"unknown"}]}},e.UpdateRequest={name:"UpdateRequest",source:"server",request:{oneOfType:[{state:{enum:["error"]},err:"unknown"},{state:{enum:["synced"]},isSynced:"boolean"},{state:{enum:["syncing"]},data:{arrayOf:{record:{values:"unknown"}}}}]},response:{oneOfType:[{success:{enum:[!0]}},{success:{enum:[!1]},err:"unknown"}]}};const o={ClientSyncRequest:e.ClientSyncRequest,ServerSyncRequest:e.ServerSyncRequest,PullRequest:e.PullRequest,UpdateRequest:e.UpdateRequest},s=Object.values(o),a=(e,t,n,i)=>(t.removeAllListeners(e),t.on(e,async(e,t)=>{const{type:o,request:a}=(0,r.isObject)(e)?e:{};if("string"!=typeof o||!a)return void t("Unexpected data");const l=s.find(e=>e.name===o&&e.source!==n);if(!l)return void t("Invalid data.type");if(l.source===n)return void t("Invalid schema.source");if("server"===n){const e=(0,r.getJSONBSchemaValidationError)(l.request,a);if(void 0!==e.error)return console.error("Invalid request from client",e.error,a),void t(e.error)}const c=l.name;try{t(await(0,r.withTimeout)(Promise.resolve(i[c](a)),1e4))}catch(e){t((0,r.getSerialisableError)(e))}}),(0,r.fromEntries)((0,r.getEntries)(o).map(([i,o])=>{if(o.source===n)return[i,i=>(0,r.createPromiseWithTimeout)((s,a)=>{t.emit(e,{type:o.name,request:i},e=>{if("server"===n){const t=(0,r.getJSONBSchemaValidationError)(o.response,e);if(void 0!==t.error)return console.error("Invalid response from client for "+o.name,t.error,e),void a(t.error)}s(e)})},1e4)]}).filter(r.isDefined)));e.getServerHandlers=(e,t,n)=>a(e,t,"server",n),e.getClientHandlers=(e,t,n)=>a(e,t,"client",n)}(i||(t.ReplicationProtocol=i={}))},472(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.fromEntries=t.getEntries=t.createPromiseWithTimeout=t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=o,t.find=function(e,t){return o(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,l=Object.keys(t).sort(i&&i(t));for(s="",n=0;n<l.length;n++){var c=l[n],u=e(t[c]);u&&(s&&(s+=","),s+=JSON.stringify(c)+":"+u)}return o.splice(a,1),"{"+s+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const o=n<1?[r]:[0,r];e.slice(...o)!==t.slice(...o)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,o=e.length+n(-1)+1,s=t.length+n(-1)+1;return{from:i,to:o,text:t.slice(i,s),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:o,md5:s}=t;if(null===o||null===e)return o;let a=e.slice(0,n)+o+e.slice(i);if(s&&(0,r.md5)(a)!==s)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=s,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=l;const r=n(666);function i(e,n){return(0,t.pickKeys)(e,l(e).filter(e=>!n.includes(e)))}function o(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function s(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function l(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!s(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),o=JSON.parse((0,t.safeStringify)(r));return n?o:i(o,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])},t.createPromiseWithTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t)),r=new Promise(e);return Promise.race([r,n])},t.getEntries=e=>Object.entries(e),t.fromEntries=e=>Object.fromEntries(e)},441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(102),t),i(n(436),t),i(n(441),t)},102(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let o=r.get(e);if(o?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(o||(o=new WeakSet,r.set(e,o)),o.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const s=Array.isArray(e),a=Array.isArray(t);if(s&&a){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!n(e[o],t[o],r,i))return!1;return!0}if(s!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const l=Object.keys(e);if(l.length!==Object.keys(t).length)return!1;for(const o of l){if(!(o in t))return!1;{const s=e[o],a=t[o];if(!n(s,a,r,i))return!1}}return!0}},436(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(806)})());
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(Object(this||window),()=>(()=>{"use strict";var e={994(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(472);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(472),i=n(704),o=n(441);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const s=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:s,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&s(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},l=(0,r.getKeys)(a),c=(e,n,s=[],p)=>{const f=`${s.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,d=(0,t.getFieldTypeObj)(n),{type:y,allowedValues:m,nullable:g,optional:h}=d;if(g&&null===e)return;if(h&&void 0===e)return;if(m){if("string"!=typeof y)throw new Error("allowedValues is only supported for primitive types");const t=y.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=m.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${s.join(".")}[${e}]`:s.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(y){if((0,r.isObject)(y)){if(!(0,r.isObject)(e))return f;for(const t of(0,i.safeGetKeys)(y)){const n=(0,i.safeGetProperty)(y,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...s,t].join(".")} is missing but required`;const o=c((0,i.safeGetProperty)(e,t),n,[...s,t],p);if(void 0!==o)return o}if(!p?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(y),r=t.filter(e=>!n.includes(e));if(r.length)return`${s.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,o.includes)(l,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(y,d);return t(e,d)?void 0:f}if(d.enum){const t=[];return d.nullable&&t.push(null),d.optional&&t.push(void 0),d.enum.includes(e)?void 0:f}const b=d.arrayOf??(d.arrayOfType?{type:d.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return f+" an array";const t=e.map((e,t)=>c(e,b,[...s,`${t}`],p)).filter(r.isDefined)[0];return void 0!==t?`${f}. Error at index ${s.length>0?s.join(".")+".":""}\n\n${t}`:void 0}const O=d.oneOf??d.oneOfType?.map(e=>({type:e}));if(O){if(!O.length)return f+"to not be empty";let t;if(O.find(n=>{const r=c(e,n,s,p);return t??(t=r),void 0===r}))return;return f}if(d.record){const{keysEnum:t,partial:n,values:o}=d.record;if(!(0,r.isObject)(e))return f+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),l=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==l)return`${f} to have key ${l}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${f} has extra keys: ${u}`;if(o)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=c(n,o,[...s,t],p);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(d)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:o,optional:s,record:a}=n,l=n.oneOf??n.oneOfType?.map(e=>({type:e})),c=[];if(o&&c.push("null"),s&&c.push("undefined"),"string"==typeof i)c.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),c.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?c.push("null"):void 0===e?c.push("undefined"):"string"==typeof e?c.push(JSON.stringify(e)):c.push(e)}),l?.forEach(e=>{const t=u(e);c.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?c.push(`{ [${e.join(" | ")}]${r}: ${i} }`):c.push(`{ [key: string]${r}: ${i} }`)}return c.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,o)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const s=c(t,{type:e},[],o);return s?{error:s}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=c(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:o}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===o},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:o}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(o)throw new Error(o)}},699(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(472),i=n(704),o=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:s,arrayOf:a,arrayOfType:l,description:c,nullable:u,oneOf:p,oneOfType:f,title:d,record:y,...m}="string"==typeof e?{type:e}:e;let g={};const h={...(m.enum||m.allowedValues?.length&&("string"!=typeof s||!s.endsWith("[]")))&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!c&&{description:c},...!!d&&{title:d}};if(m.enum?.length){const e=typeof m.enum[0];h.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof s||a||l){if(s&&"string"!=typeof s)throw"Not expected";g=a||l||s?.endsWith("[]")?{type:"array",items:a||l?(0,t.getJSONSchemaObject)(a||{type:l}):s?.startsWith("any")?{type:void 0}:{type:o(s)?.type,...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:o(s)?.type}}else if((0,r.isObject)(s))g={type:"object",required:(0,i.safeGetKeys)(s).filter(e=>{const t=s[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(s).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})};else if(p||f){const e=p||f.map(e=>({type:e}));g={oneOf:e.map(e=>(0,t.getJSONSchemaObject)(e))}}else y&&(g={type:"object",...y.values&&!y.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(y.values)},...y.keysEnum&&{properties:y.keysEnum.reduce((e,n)=>({...e,[n]:y.values?(0,t.getJSONSchemaObject)(y.values):{type:{}}}),{})}});if(u){const e={type:"null"};g.oneOf?g.oneOf.push(e):g.enum&&!g.enum.includes(null)?g.enum.push(null):g={oneOf:[g,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...h,...g}}},394(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(806),i=n(897),o=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,l="",c=0)=>{const u=(0,i.getFieldTypeObj)(n),p=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let o=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;o=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${o}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return p+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return p+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:o}=u,l=a?" ":" ";let f=` {${l}`+(0,r.getObjectEntries)(o).map(([r,o])=>{const a=(0,i.getFieldTypeObj)(o),u=s(r)?r:JSON.stringify(r);return`${l}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,c+1))}).join(" ")+`${l}}`;return a||(f=n(f)),a&&(f=f.split("\n").join("")),p+f}if(u.enum)return p+u.enum.map(e=>o(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${l} | null`:"")+n.map(n=>`\n${l} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,c+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,c+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,s=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${s(`${n?.map(e=>o(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,c+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const s=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704(e,t){t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},502(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(806);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],o=+r-+i,s=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(o)?o:s}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.forEach(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const o=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[o]??(t[o]={initial:n,current:r,delta:i}),this.changed[o].current={...this.changed[o].current,...r},this.changed[o].delta={...this.changed[o].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:o,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,l=[],c=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},c.push({...t}),u[e]={...t.current},delete this.changed[e]}),l=c.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],o=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,o)||(t[n]=o)}),t}),e&&console.log(this.options.id," SENDING lr->",l[l.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},o)),this.isOnSending=!0;try{await t(l,c),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*s)))}catch(e){a=e,console.error("WAL onSend failed:",e,l,c)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",l[l.length-1]),(0,r.isEmpty)(this.changed)?n&&n(l,c,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>String(e[t])).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},618(e,t){Object.defineProperty(t,"__esModule",{value:!0})},521(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(472);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const o=n(472),s=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,o.getKeys)(t.TS_PG_Types).find(n=>(0,s.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const o=i.columns.filter(e=>r.includes(e.name));return o.length?{ref:e,fcolsInfo:o}:void 0}).filter(o.isDefined),[i,...s]=r??[];if(!s.length)return i?.ref;const[a,...l]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!l.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(618),t);var l=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return l.CONTENT_TYPE_TO_EXT}}),i(n(209),t),i(n(319),t),i(n(699),t),i(n(394),t),i(n(994),t),i(n(897),t),i(n(164),t),i(n(472),t),i(n(502),t),i(n(778),t)},319(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(472),i=(e="$leftJoin")=>(t,n,i,o={})=>({[e]:o.path??t,filter:n,...(0,r.omitKeys)(o,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},666(e,t){function n(e,t){var n=e[0],r=e[1],l=e[2],c=e[3];n=i(n,r,l,c,t[0],7,-680876936),c=i(c,n,r,l,t[1],12,-389564586),l=i(l,c,n,r,t[2],17,606105819),r=i(r,l,c,n,t[3],22,-1044525330),n=i(n,r,l,c,t[4],7,-176418897),c=i(c,n,r,l,t[5],12,1200080426),l=i(l,c,n,r,t[6],17,-1473231341),r=i(r,l,c,n,t[7],22,-45705983),n=i(n,r,l,c,t[8],7,1770035416),c=i(c,n,r,l,t[9],12,-1958414417),l=i(l,c,n,r,t[10],17,-42063),r=i(r,l,c,n,t[11],22,-1990404162),n=i(n,r,l,c,t[12],7,1804603682),c=i(c,n,r,l,t[13],12,-40341101),l=i(l,c,n,r,t[14],17,-1502002290),n=o(n,r=i(r,l,c,n,t[15],22,1236535329),l,c,t[1],5,-165796510),c=o(c,n,r,l,t[6],9,-1069501632),l=o(l,c,n,r,t[11],14,643717713),r=o(r,l,c,n,t[0],20,-373897302),n=o(n,r,l,c,t[5],5,-701558691),c=o(c,n,r,l,t[10],9,38016083),l=o(l,c,n,r,t[15],14,-660478335),r=o(r,l,c,n,t[4],20,-405537848),n=o(n,r,l,c,t[9],5,568446438),c=o(c,n,r,l,t[14],9,-1019803690),l=o(l,c,n,r,t[3],14,-187363961),r=o(r,l,c,n,t[8],20,1163531501),n=o(n,r,l,c,t[13],5,-1444681467),c=o(c,n,r,l,t[2],9,-51403784),l=o(l,c,n,r,t[7],14,1735328473),n=s(n,r=o(r,l,c,n,t[12],20,-1926607734),l,c,t[5],4,-378558),c=s(c,n,r,l,t[8],11,-2022574463),l=s(l,c,n,r,t[11],16,1839030562),r=s(r,l,c,n,t[14],23,-35309556),n=s(n,r,l,c,t[1],4,-1530992060),c=s(c,n,r,l,t[4],11,1272893353),l=s(l,c,n,r,t[7],16,-155497632),r=s(r,l,c,n,t[10],23,-1094730640),n=s(n,r,l,c,t[13],4,681279174),c=s(c,n,r,l,t[0],11,-358537222),l=s(l,c,n,r,t[3],16,-722521979),r=s(r,l,c,n,t[6],23,76029189),n=s(n,r,l,c,t[9],4,-640364487),c=s(c,n,r,l,t[12],11,-421815835),l=s(l,c,n,r,t[15],16,530742520),n=a(n,r=s(r,l,c,n,t[2],23,-995338651),l,c,t[0],6,-198630844),c=a(c,n,r,l,t[7],10,1126891415),l=a(l,c,n,r,t[14],15,-1416354905),r=a(r,l,c,n,t[5],21,-57434055),n=a(n,r,l,c,t[12],6,1700485571),c=a(c,n,r,l,t[3],10,-1894986606),l=a(l,c,n,r,t[10],15,-1051523),r=a(r,l,c,n,t[1],21,-2054922799),n=a(n,r,l,c,t[8],6,1873313359),c=a(c,n,r,l,t[15],10,-30611744),l=a(l,c,n,r,t[6],15,-1560198380),r=a(r,l,c,n,t[13],21,1309151649),n=a(n,r,l,c,t[4],6,-145523070),c=a(c,n,r,l,t[11],10,-1120210379),l=a(l,c,n,r,t[2],15,718787259),r=a(r,l,c,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(r,e[1]),e[2]=f(l,e[2]),e[3]=f(c,e[3])}function r(e,t,n,r,i,o){return t=f(f(t,e),f(r,o)),f(t<<i|t>>>32-i,n)}function i(e,t,n,i,o,s,a){return r(t&n|~t&i,e,t,o,s,a)}function o(e,t,n,i,o,s,a){return r(t&i|n&~i,e,t,o,s,a)}function s(e,t,n,i,o,s,a){return r(t^n^i,e,t,o,s,a)}function a(e,t,n,i,o,s,a){return r(n^(t|~i),e,t,o,s,a)}function l(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}t.md5=p;var c="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=c[e>>8*n+4&15]+c[e>>8*n&15];return t}function p(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,l(e.substring(t-64,t)));e=e.substring(t-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(i,o),t=0;t<16;t++)o[t]=0;return o[14]=8*r,n(i,o),i}(e))}function f(e,t){return e+t&4294967295}p("hello")},164(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ReplicationProtocol=t.getSyncChannelName=void 0;const r=n(806);var i;t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join("."),function(e){e.CreateSchema={name:"Create",source:"client",request:{type:{tableName:"string",command:{enum:["sync"]},param1:{record:{values:"unknown"}},param2:{type:{select:"unknown"}}}},response:{type:{id_fields:"string[]",synced_field:"string",channelName:"string",data:"any[]",isSynced:"boolean"}}};const t={state:{enum:["syncing"]},c_fr:{optional:!0,record:{values:"unknown"}},c_lr:{optional:!0,record:{values:"unknown"}},c_count:"number"},n={state:{enum:["syncing-data"]},c_fr:{record:{values:"unknown"}},c_lr:{record:{values:"unknown"}},c_count:"number",data:{arrayOf:{record:{values:"unknown"}}}},i={from_synced:{oneOf:["string","number",{enum:[void 0]}]},to_synced:{oneOf:["string","number",{enum:[void 0]}]}};e.ServerSyncRequest={name:"ServerSyncRequest",source:"server",request:{type:{...i,end_offset:{oneOf:["number",{enum:[null]}]}}},response:{oneOfType:[t,n,{state:{enum:["error"]},err:"unknown"}]}},e.ClientSyncRequest={name:"ClientSyncRequest",source:"client",request:{oneOfType:[t,n]},response:{oneOfType:[{success:{enum:[!0]}},{success:{enum:[!1]},err:"unknown"}]}},e.PullRequest={name:"PullRequest",source:"server",request:{type:{...i,offset:{oneOf:["number",{enum:[void 0]}]},limit:{oneOf:["number",{enum:[void 0]}]}}},response:{oneOfType:[{success:{enum:[!0]},data:{arrayOf:{record:{values:"unknown"}}}},{success:{enum:[!1]},err:"unknown"}]}},e.UpdateRequest={name:"UpdateRequest",source:"server",request:{oneOfType:[{state:{enum:["error"]},err:"unknown"},{state:{enum:["synced"]},isSynced:"boolean"},{state:{enum:["syncing"]},data:{arrayOf:{record:{values:"unknown"}}}}]},response:{oneOfType:[{success:{enum:[!0]}},{success:{enum:[!1]},err:"unknown"}]}};const o={ClientSyncRequest:e.ClientSyncRequest,ServerSyncRequest:e.ServerSyncRequest,PullRequest:e.PullRequest,UpdateRequest:e.UpdateRequest},s=Object.values(o),a=(e,t,n,i)=>(t.removeAllListeners(e),t.on(e,async(e,t)=>{const{type:o,request:a}=(0,r.isObject)(e)?e:{};if("string"!=typeof o||!a)return void t("Unexpected data");const l=s.find(e=>e.name===o&&e.source!==n);if(!l)return void t("Invalid data.type");if(l.source===n)return void t("Invalid schema.source");if("server"===n){const e=(0,r.getJSONBSchemaValidationError)(l.request,a);if(void 0!==e.error)return console.error("Invalid request from client",e.error,a),void t(e.error)}const c=l.name;try{t(await(0,r.withTimeout)(Promise.resolve(i[c](a)),1e4))}catch(e){t((0,r.getSerialisableError)(e))}}),(0,r.fromEntries)((0,r.getEntries)(o).map(([i,o])=>{if(o.source===n)return[i,i=>(0,r.createPromiseWithTimeout)((s,a)=>{t.emit(e,{type:o.name,request:i},e=>{if("server"===n){const t=(0,r.getJSONBSchemaValidationError)(o.response,e);if(void 0!==t.error)return console.error("Invalid response from client for "+o.name,t.error,e),void a(t.error)}s(e)})},1e4)]}).filter(r.isDefined)));e.getServerHandlers=(e,t,n)=>a(e,t,"server",n),e.getClientHandlers=(e,t,n)=>a(e,t,"client",n)}(i||(t.ReplicationProtocol=i={}))},472(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.fromEntries=t.getEntries=t.createPromiseWithTimeout=t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=o,t.find=function(e,t){return o(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,l=Object.keys(t).sort(i&&i(t));for(s="",n=0;n<l.length;n++){var c=l[n],u=e(t[c]);u&&(s&&(s+=","),s+=JSON.stringify(c)+":"+u)}return o.splice(a,1),"{"+s+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const o=n<1?[r]:[0,r];e.slice(...o)!==t.slice(...o)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,o=e.length+n(-1)+1,s=t.length+n(-1)+1;return{from:i,to:o,text:t.slice(i,s),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:o,md5:s}=t;if(null===o||null===e)return o;let a=e.slice(0,n)+o+e.slice(i);if(s&&(0,r.md5)(a)!==s)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=s,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=l;const r=n(666);function i(e,n){return(0,t.pickKeys)(e,l(e).filter(e=>!n.includes(e)))}function o(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function s(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function l(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!s(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),o=JSON.parse((0,t.safeStringify)(r));return n?o:i(o,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])},t.createPromiseWithTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t)),r=new Promise(e);return Promise.race([r,n])},t.getEntries=e=>Object.entries(e),t.fromEntries=e=>Object.fromEntries(e)},441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(102),t),i(n(436),t),i(n(441),t)},102(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let o=r.get(e);if(o?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(o||(o=new WeakSet,r.set(e,o)),o.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const s=Array.isArray(e),a=Array.isArray(t);if(s&&a){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!n(e[o],t[o],r,i))return!1;return!0}if(s!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const l=Object.keys(e);if(l.length!==Object.keys(t).length)return!1;for(const o of l){if(!(o in t))return!1;{const s=e[o],a=t[o];if(!n(s,a,r,i))return!1}}return!0}},436(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(806)})());
|
package/lib/WAL.ts
CHANGED
|
@@ -123,8 +123,6 @@ export class WAL {
|
|
|
123
123
|
/**
|
|
124
124
|
* Used by server to avoid unnecessary data push to client.
|
|
125
125
|
* This can happen due to the same data item having been previously pushed by the client
|
|
126
|
-
* @param item data item
|
|
127
|
-
* @returns boolean
|
|
128
126
|
*/
|
|
129
127
|
isInHistory = (item: AnyObject): boolean => {
|
|
130
128
|
if (!item) throw "Provide item";
|
|
@@ -147,7 +145,7 @@ export class WAL {
|
|
|
147
145
|
getIdStr(d: AnyObject): string {
|
|
148
146
|
return this.options.id_fields
|
|
149
147
|
.sort()
|
|
150
|
-
.map((key) =>
|
|
148
|
+
.map((key) => String(d[key]))
|
|
151
149
|
.join(".");
|
|
152
150
|
}
|
|
153
151
|
getIdObj(d: AnyObject): AnyObject {
|
|
@@ -170,7 +168,7 @@ export class WAL {
|
|
|
170
168
|
addData = (data: WALItem[]) => {
|
|
171
169
|
if (isEmpty(this.changed) && this.options.onSendStart) this.options.onSendStart();
|
|
172
170
|
|
|
173
|
-
data.
|
|
171
|
+
data.forEach((d) => {
|
|
174
172
|
const { initial, current, delta } = { ...d };
|
|
175
173
|
if (!current) throw "Expecting { current: object, initial?: object }";
|
|
176
174
|
const idStr = this.getIdStr(current);
|