@data-client/endpoint
Advanced tools
Comparing version 0.11.1 to 0.11.3
@@ -947,3 +947,3 @@ 'use strict'; | ||
const value = unvisit(input, this.schema); | ||
return typeof value === 'symbol' ? undefined : this.process(value, ...args); | ||
return typeof value === 'symbol' ? value : this.process(value, ...args); | ||
} | ||
@@ -950,0 +950,0 @@ queryKey(args, queryKey, getEntity, getIndex) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Endpoint={})}(this,(function(e){"use strict";function t(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}class s{constructor(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){"_schemaAttribute"in e&&!this._schemaAttribute?(this.schema=e.schema,this._schemaAttribute=e._schemaAttribute):this.schema=e}getSchemaAttribute(e,t,s){return!this.isSingleSchema&&this._schemaAttribute(e,t,s)}inferSchema(e,t,s){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,s);return this.schema[r]}normalizeValue(e,t,s,r,n,i,o,c){if(!e)return e;const a=this.inferSchema(e,t,s);if(!a)return e;const h=r(e,t,s,a,n,i,o,c);return this.isSingleSchema||null==h?h:{id:h,schema:this.getSchemaAttribute(e,t,s)}}denormalizeValue(e,s){const r=!this.isSingleSchema&&e&&(t(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!r)return e;return s((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r])}}class r extends s{normalize(e,t,s,r,n,i,o,c){return Object.keys(e).reduce(((t,s,a)=>{const h=e[s];return null!=h?Object.assign({},t,{[s]:this.normalizeValue(h,e,s,r,n,i,o,c)}):t}),{})}denormalize(e,t,s){return Object.keys(e).reduce(((t,r)=>{const n=e[r],i=this.denormalizeValue(n,s);return i&&"symbol"!=typeof i?Object.assign({},t,{[r]:i}):t}),{})}queryKey(e,t,s,r){}}const n=e=>void 0!==e&&"symbol"!=typeof e;class i extends s{normalize(e,t,s,r,n,i,o,c){const a=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return a.map(((e,a)=>this.normalizeValue(e,t,s,r,n,i,o,c)))}denormalize(e,t,s){return e.map?e.map((e=>this.denormalizeValue(e,s))).filter(n):e}queryKey(e,t,s,r){}toJSON(){return[this.schema]}}const o=Symbol("INVALID");function c(e,s,r,n){if(t(s))return function(e,t,s){var r;let n;const i=Object.keys(e).reduce(((t,r)=>{const i=`${r}`,o=s(t.get(i),e[i]);return"symbol"==typeof o&&(n=o),t.has(i)?t.set(i,o):t}),t);return null!=(r=n)?r:i}(e,s,n);const i=Object.assign({},s);for(const t of Object.keys(e)){const s=n(i[t],e[t]);if(void 0!==i[t]&&(i[t]=s),"symbol"==typeof s)return s}return i}const a=Symbol("create"),h=(e,t)=>[...e,...t],u=(e,t)=>[...t,...e],l=(e,t)=>Object.assign({},e,t),m=e=>[...e],y=e=>Object.assign({},e);function f(e,t,s){const r={merge:{value:t},normalize:{value:p},infer:{value:d}};return e.schema instanceof i&&(r.createIfValid={value:b},r.denormalize={value:g}),s&&(r.createCollectionFilter={value:s}),Object.create(e,r)}function d(){}function p(e,t,s,r,n,o,c,h){o[a]={};const u=this.schema.normalize(this.schema instanceof i&&!Array.isArray(e)?[e]:e,t,s,r,n,o,c,h),l=this.createCollectionFilter(...h);return c[this.key]&&Object.keys(c[this.key]).forEach((e=>{l(JSON.parse(e))&&n(this,u,e)})),u}function b(e){return Array.isArray(e)?[...e]:Object.assign({},e)}function g(e,t,s){return Array.isArray(e)?this.schema.denormalize(e,t,s):this.schema.denormalize([e],t,s)[0]}var O,k=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(e,t){if(null==e)return{};var s,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||(n[s]=e[s]);return n},e.exports.__esModule=!0,e.exports.default=e.exports})),j=(O=k)&&O.__esModule&&Object.prototype.hasOwnProperty.call(O,"default")?O.default:O;const v=["pk","schema","key"];function S(e,t={}){class s extends e{static toString(){return this.key}static toJSON(){return{name:this.name,schema:this.schema,key:this.key}}static pk(e,t,s,r){return this.prototype.pk.call(e,t,s,r)}static shouldUpdate(e,t,s,r){return!0}static shouldReorder(e,t,s,r){return t.fetchedAt<e.fetchedAt}static merge(e,t){return Object.assign({},e,t)}static mergeWithStore(e,t,s,r){return this.shouldUpdate(e,t,s,r)?typeof r!=typeof s?r:this.shouldReorder(e,t,s,r)?this.merge(r,s):this.merge(s,r):s}static mergeMetaWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?e:t}static fromJS(e={}){const t=new this(e);return Object.assign(t,e),t}static createIfValid(e){if(!this.validate(e))return this.fromJS(e)}static process(e,t,s,r){return Object.assign({},e)}static normalize(e,t,s,r,n,i,o,c){const a=this.process(e,t,s,c);let h=this.pk(a,t,s,c);h=void 0===h||""===h||"undefined"===h?`MISS-${Math.random()}`:`${h}`;const u=this.key;if(u in i||(i[u]={}),h in i[u]||(i[u][h]=[]),i[u][h].some((t=>t===e)))return h;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(a)),i[u][h].push(e),Object.keys(this.schema).forEach((e=>{Object.hasOwn(a,e)&&(a[e]=r(a[e],a,e,this.schema[e],n,i,o,c))})),n(this,a,h),h}static validate(e){}static queryKey(e,t,s,r){if(!e[0])return;const n=function(e,t,s){if(["string","number"].includes(typeof t[0]))return`${t[0]}`;const r=e.pk(t[0],void 0,"",t);if(void 0!==r&&""!==r)return r;const n=(i=t[0],o=e.indexes,o?o.find((e=>Object.hasOwn(i,e))):void 0);var i,o;if(!n)return;const c=t[0][n];return s(e.key,n,c)[c]}(this,e,r);return s(this.key,n)?n:void 0}static denormalize(e,t,s){if("symbol"==typeof e)return e;for(const t of Object.keys(this.schema)){const r=this.schema[t],n=s(e[t],r);if("symbol"==typeof n){if(this.defaults[t])return n;e[t]=void 0}else e[t]=n}return e}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const r=j(t,v);if(Object.assign(s,r),"schema"in t?s.schema=t.schema:e.schema||(s.schema={}),"pk"in t?"function"==typeof t.pk?s.prototype.pk=function(e,s){return t.pk(this,e,s)}:s.prototype.pk=function(){return this[t.pk]}:"function"!=typeof e.prototype.pk&&(s.prototype.pk=function(){return this.id}),"key"in t)Object.defineProperty(s,"key",{value:t.key,configurable:!0,writable:!0,enumerable:!0});else if(!("key"in e)){function n(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0,configurable:!0})}const i=function(){return"EntityMixin"===this.name?e.name:this.name},o="undefined"!=typeof document&&document.CLS_MANGLE?function(){return null==document.CLS_MANGLE||document.CLS_MANGLE(this),Object.defineProperty(s,"key",{get:i,set:n,enumerable:!0,configurable:!0}),i.call(this)}:i;Object.defineProperty(s,"key",{get:o,set:n,enumerable:!0,configurable:!0})}return s}var _=Object.freeze({__proto__:null,Union:class extends s{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,s,r,n,i,o,c){return this.normalizeValue(e,t,s,r,n,i,o,c)}denormalize(e,t,s){return this.denormalizeValue(e,s)}queryKey(e,t,s,r){if(!e[0])return;const n=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[n];if(void 0===i)return;const o=t(i,e,s,r);return void 0!==o?{id:o,schema:n}:void 0}},Values:r,Array:i,All:class extends i{constructor(e,t){super(e,t)}normalize(e,t,s,r,n,i,o,c){super.normalize(e,t,s,r,n,i,o,c)}queryKey(e,t,s,r){if(this.isSingleSchema){const e=s(this.schema.key);return void 0===e?o:Object.values(e).map((e=>e&&this.schema.pk(e)))}let n=!1;const i=Object.values(this.schema).flatMap((e=>{const t=s(e.key);return void 0===t?[]:(n=!0,Object.values(t).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)}))))}));return n?i:o}},Object:class{constructor(e){this.schema=void 0,this.define(e)}define(e){this.schema=Object.keys(e).reduce(((t,s)=>{const r=e[s];return Object.assign({},t,{[s]:r})}),this.schema||{})}normalize(...e){return((e,t,s,r,n,i,o,c,a)=>{const h=Object.assign({},t);return Object.keys(e).forEach((s=>{const r=e[s],u=n(t[s],t,s,r,i,o,c,a);void 0===u?delete h[s]:h[s]=u})),h})(this.schema,...e)}denormalize(e,t,s){return c(this.schema,e,0,s)}queryKey(e,t,s,r){return function(e,t,s,r,n){const i={};return Object.keys(e).forEach((o=>{i[o]=s(e[o],t,r,n)})),i}(this.schema,e,t,s,r)}},Invalidate:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,s,r,n,i,c,a){const h=this._entity.process(e,t,s,a),u=this._entity.pk(h,t,s,a);return n(this,o,u),u}merge(e,t){return t}mergeWithStore(e,t,s,r){return this.merge(s,r)}mergeMetaWithStore(e,t,s,r){return t}queryKey(e,t,s,r){}denormalize(e,t,s){return s(e,this._entity)}_denormalizeNullable(){return{}}_normalizeNullable(){return{}}},Collection:class{addWith(e,t){return f(this,e,t)}createCollectionFilter(...e){return t=>Object.entries(t).every((([t,s])=>{var r;return this.nonFilterArgumentKeys(t)||`${e[0][t]}`===s||`${null==(r=e[1])?void 0:r[t]}`===s}))}nonFilterArgumentKeys(e){return e.startsWith("order")}constructor(e,t){if(this.schema=Array.isArray(e)?new i(e[0]):e,t?"nestKey"in t?this.nestKey=t.nestKey:this.argsKey="argsKey"in t?t.argsKey:e=>Object.assign({},e):this.argsKey=e=>Object.assign({},e),this.key=`COLLECT:${this.schema.constructor.name}(${this.schema.schema.key})`,null!=t&&t.nonFilterArgumentKeys){const{nonFilterArgumentKeys:e}=t;"function"==typeof e?this.nonFilterArgumentKeys=e:e instanceof RegExp?this.nonFilterArgumentKeys=t=>e.test(t):this.nonFilterArgumentKeys=t=>e.includes(t)}else null!=t&&t.createCollectionFilter&&(this.createCollectionFilter=t.createCollectionFilter.bind(this));this.schema instanceof i?(this.createIfValid=m,this.push=f(this,h),this.unshift=f(this,u)):e instanceof r&&(this.createIfValid=y,this.assign=f(this,l))}get cacheWith(){return this.schema.schema}toJSON(){return{name:`Collection(${this.schema.schema.name})`,schema:this.schema.schema.toJSON(),key:this.key}}pk(e,t,s,r){const n=this.argsKey?this.argsKey(...r):this.nestKey(t,s);for(const e in n)"string"!=typeof n[e]&&void 0!==n[e]&&(n[e]=`${n[e]}`);return function(e){const t=Object.keys(e).sort(),s={};for(const r of t)s[r]=e[r];return JSON.stringify(s)}(n)}normalize(e,t,s,r,n,i,o,c){const a=this.schema.normalize(e,t,s,r,n,i,o,c),h=this.pk(a,t,s,c);return n(this,a,h),h}merge(e,t){return t}shouldReorder(e,t,s,r){return t.fetchedAt<e.fetchedAt}mergeWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?this.merge(r,s):this.merge(s,r)}mergeMetaWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?e:t}queryKey(e,t,s,r){if(this.argsKey){const t=this.pk(void 0,void 0,"",e);if(s(this.key,t))return t}}denormalize(e,t,s){return this.schema.denormalize(e,t,s)}},Entity:S,Query:class{constructor(e,t){this.schema=e,this.process=t}normalize(...e){return this.schema.normalize(...e)}denormalize(e,t,s){const r=s(e,this.schema);return"symbol"==typeof r?void 0:this.process(r,...t)}queryKey(e,t,s,r){return t(this.schema,e,s,r)}}});const A=class{};class z extends(S(A)){static process(e,t,s,r){return super.process(e,t,s,r)}}var K;const w="undefined"!=typeof document;let x=w&&!(null!=(K=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&K.getAttribute("content"));try{x||Function()}catch(e){x=!0,w&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @data-client/endpoint will use setPrototypeOf instead")}var E;class N extends Function{constructor(e,t){let s,r;return x?(s=(...e)=>s.fetch(...e),Object.setPrototypeOf(s,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),s=this),e&&(s.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(r=e.name),Object.defineProperty(s,"name",{get(){return r||this.__name},set(e){this.__name=e}}),Object.assign(s,t),s}key(...e){return`${this.name} ${JSON.stringify(e)}`}testKey(e){return e.startsWith(this.name)}bind(e,...t){const s=this.fetch,r=this.key;return this.extend({fetch(){return s.apply(null!=e?e:this,t)},key(){return r.apply(this,t)}})}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(e.fetch,e)}}E=N,(()=>{if("undefined"!=typeof document&&document.FUNC_MANGLE){const e=E.prototype.key;E.prototype.key=function(...t){return null==document.FUNC_MANGLE||document.FUNC_MANGLE(this),this.prototype.key=e,e.call(this,...t)}}})();const C=N;Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.Endpoint=N,e.Entity=z,e.ExtendableEndpoint=C,e.INVALID=o,e.schema=_,e.validateRequired=function(e,t){let s="";if(Object.keys(t).some((t=>!Object.hasOwn(e,t)&&(s=t,!0))))return`Missing key ${s}`},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Endpoint={})}(this,(function(e){"use strict";function t(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}class s{constructor(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){"_schemaAttribute"in e&&!this._schemaAttribute?(this.schema=e.schema,this._schemaAttribute=e._schemaAttribute):this.schema=e}getSchemaAttribute(e,t,s){return!this.isSingleSchema&&this._schemaAttribute(e,t,s)}inferSchema(e,t,s){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,s);return this.schema[r]}normalizeValue(e,t,s,r,n,i,o,c){if(!e)return e;const a=this.inferSchema(e,t,s);if(!a)return e;const h=r(e,t,s,a,n,i,o,c);return this.isSingleSchema||null==h?h:{id:h,schema:this.getSchemaAttribute(e,t,s)}}denormalizeValue(e,s){const r=!this.isSingleSchema&&e&&(t(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!r)return e;return s((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r])}}class r extends s{normalize(e,t,s,r,n,i,o,c){return Object.keys(e).reduce(((t,s,a)=>{const h=e[s];return null!=h?Object.assign({},t,{[s]:this.normalizeValue(h,e,s,r,n,i,o,c)}):t}),{})}denormalize(e,t,s){return Object.keys(e).reduce(((t,r)=>{const n=e[r],i=this.denormalizeValue(n,s);return i&&"symbol"!=typeof i?Object.assign({},t,{[r]:i}):t}),{})}queryKey(e,t,s,r){}}const n=e=>void 0!==e&&"symbol"!=typeof e;class i extends s{normalize(e,t,s,r,n,i,o,c){const a=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return a.map(((e,a)=>this.normalizeValue(e,t,s,r,n,i,o,c)))}denormalize(e,t,s){return e.map?e.map((e=>this.denormalizeValue(e,s))).filter(n):e}queryKey(e,t,s,r){}toJSON(){return[this.schema]}}const o=Symbol("INVALID");function c(e,s,r,n){if(t(s))return function(e,t,s){var r;let n;const i=Object.keys(e).reduce(((t,r)=>{const i=`${r}`,o=s(t.get(i),e[i]);return"symbol"==typeof o&&(n=o),t.has(i)?t.set(i,o):t}),t);return null!=(r=n)?r:i}(e,s,n);const i=Object.assign({},s);for(const t of Object.keys(e)){const s=n(i[t],e[t]);if(void 0!==i[t]&&(i[t]=s),"symbol"==typeof s)return s}return i}const a=Symbol("create"),h=(e,t)=>[...e,...t],u=(e,t)=>[...t,...e],l=(e,t)=>Object.assign({},e,t),m=e=>[...e],y=e=>Object.assign({},e);function f(e,t,s){const r={merge:{value:t},normalize:{value:p},infer:{value:d}};return e.schema instanceof i&&(r.createIfValid={value:b},r.denormalize={value:g}),s&&(r.createCollectionFilter={value:s}),Object.create(e,r)}function d(){}function p(e,t,s,r,n,o,c,h){o[a]={};const u=this.schema.normalize(this.schema instanceof i&&!Array.isArray(e)?[e]:e,t,s,r,n,o,c,h),l=this.createCollectionFilter(...h);return c[this.key]&&Object.keys(c[this.key]).forEach((e=>{l(JSON.parse(e))&&n(this,u,e)})),u}function b(e){return Array.isArray(e)?[...e]:Object.assign({},e)}function g(e,t,s){return Array.isArray(e)?this.schema.denormalize(e,t,s):this.schema.denormalize([e],t,s)[0]}var O,k=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(e,t){if(null==e)return{};var s,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||(n[s]=e[s]);return n},e.exports.__esModule=!0,e.exports.default=e.exports})),j=(O=k)&&O.__esModule&&Object.prototype.hasOwnProperty.call(O,"default")?O.default:O;const v=["pk","schema","key"];function S(e,t={}){class s extends e{static toString(){return this.key}static toJSON(){return{name:this.name,schema:this.schema,key:this.key}}static pk(e,t,s,r){return this.prototype.pk.call(e,t,s,r)}static shouldUpdate(e,t,s,r){return!0}static shouldReorder(e,t,s,r){return t.fetchedAt<e.fetchedAt}static merge(e,t){return Object.assign({},e,t)}static mergeWithStore(e,t,s,r){return this.shouldUpdate(e,t,s,r)?typeof r!=typeof s?r:this.shouldReorder(e,t,s,r)?this.merge(r,s):this.merge(s,r):s}static mergeMetaWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?e:t}static fromJS(e={}){const t=new this(e);return Object.assign(t,e),t}static createIfValid(e){if(!this.validate(e))return this.fromJS(e)}static process(e,t,s,r){return Object.assign({},e)}static normalize(e,t,s,r,n,i,o,c){const a=this.process(e,t,s,c);let h=this.pk(a,t,s,c);h=void 0===h||""===h||"undefined"===h?`MISS-${Math.random()}`:`${h}`;const u=this.key;if(u in i||(i[u]={}),h in i[u]||(i[u][h]=[]),i[u][h].some((t=>t===e)))return h;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(a)),i[u][h].push(e),Object.keys(this.schema).forEach((e=>{Object.hasOwn(a,e)&&(a[e]=r(a[e],a,e,this.schema[e],n,i,o,c))})),n(this,a,h),h}static validate(e){}static queryKey(e,t,s,r){if(!e[0])return;const n=function(e,t,s){if(["string","number"].includes(typeof t[0]))return`${t[0]}`;const r=e.pk(t[0],void 0,"",t);if(void 0!==r&&""!==r)return r;const n=(i=t[0],o=e.indexes,o?o.find((e=>Object.hasOwn(i,e))):void 0);var i,o;if(!n)return;const c=t[0][n];return s(e.key,n,c)[c]}(this,e,r);return s(this.key,n)?n:void 0}static denormalize(e,t,s){if("symbol"==typeof e)return e;for(const t of Object.keys(this.schema)){const r=this.schema[t],n=s(e[t],r);if("symbol"==typeof n){if(this.defaults[t])return n;e[t]=void 0}else e[t]=n}return e}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const r=j(t,v);if(Object.assign(s,r),"schema"in t?s.schema=t.schema:e.schema||(s.schema={}),"pk"in t?"function"==typeof t.pk?s.prototype.pk=function(e,s){return t.pk(this,e,s)}:s.prototype.pk=function(){return this[t.pk]}:"function"!=typeof e.prototype.pk&&(s.prototype.pk=function(){return this.id}),"key"in t)Object.defineProperty(s,"key",{value:t.key,configurable:!0,writable:!0,enumerable:!0});else if(!("key"in e)){function n(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0,configurable:!0})}const i=function(){return"EntityMixin"===this.name?e.name:this.name},o="undefined"!=typeof document&&document.CLS_MANGLE?function(){return null==document.CLS_MANGLE||document.CLS_MANGLE(this),Object.defineProperty(s,"key",{get:i,set:n,enumerable:!0,configurable:!0}),i.call(this)}:i;Object.defineProperty(s,"key",{get:o,set:n,enumerable:!0,configurable:!0})}return s}var _=Object.freeze({__proto__:null,Union:class extends s{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,s,r,n,i,o,c){return this.normalizeValue(e,t,s,r,n,i,o,c)}denormalize(e,t,s){return this.denormalizeValue(e,s)}queryKey(e,t,s,r){if(!e[0])return;const n=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[n];if(void 0===i)return;const o=t(i,e,s,r);return void 0!==o?{id:o,schema:n}:void 0}},Values:r,Array:i,All:class extends i{constructor(e,t){super(e,t)}normalize(e,t,s,r,n,i,o,c){super.normalize(e,t,s,r,n,i,o,c)}queryKey(e,t,s,r){if(this.isSingleSchema){const e=s(this.schema.key);return void 0===e?o:Object.values(e).map((e=>e&&this.schema.pk(e)))}let n=!1;const i=Object.values(this.schema).flatMap((e=>{const t=s(e.key);return void 0===t?[]:(n=!0,Object.values(t).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)}))))}));return n?i:o}},Object:class{constructor(e){this.schema=void 0,this.define(e)}define(e){this.schema=Object.keys(e).reduce(((t,s)=>{const r=e[s];return Object.assign({},t,{[s]:r})}),this.schema||{})}normalize(...e){return((e,t,s,r,n,i,o,c,a)=>{const h=Object.assign({},t);return Object.keys(e).forEach((s=>{const r=e[s],u=n(t[s],t,s,r,i,o,c,a);void 0===u?delete h[s]:h[s]=u})),h})(this.schema,...e)}denormalize(e,t,s){return c(this.schema,e,0,s)}queryKey(e,t,s,r){return function(e,t,s,r,n){const i={};return Object.keys(e).forEach((o=>{i[o]=s(e[o],t,r,n)})),i}(this.schema,e,t,s,r)}},Invalidate:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,s,r,n,i,c,a){const h=this._entity.process(e,t,s,a),u=this._entity.pk(h,t,s,a);return n(this,o,u),u}merge(e,t){return t}mergeWithStore(e,t,s,r){return this.merge(s,r)}mergeMetaWithStore(e,t,s,r){return t}queryKey(e,t,s,r){}denormalize(e,t,s){return s(e,this._entity)}_denormalizeNullable(){return{}}_normalizeNullable(){return{}}},Collection:class{addWith(e,t){return f(this,e,t)}createCollectionFilter(...e){return t=>Object.entries(t).every((([t,s])=>{var r;return this.nonFilterArgumentKeys(t)||`${e[0][t]}`===s||`${null==(r=e[1])?void 0:r[t]}`===s}))}nonFilterArgumentKeys(e){return e.startsWith("order")}constructor(e,t){if(this.schema=Array.isArray(e)?new i(e[0]):e,t?"nestKey"in t?this.nestKey=t.nestKey:this.argsKey="argsKey"in t?t.argsKey:e=>Object.assign({},e):this.argsKey=e=>Object.assign({},e),this.key=`COLLECT:${this.schema.constructor.name}(${this.schema.schema.key})`,null!=t&&t.nonFilterArgumentKeys){const{nonFilterArgumentKeys:e}=t;"function"==typeof e?this.nonFilterArgumentKeys=e:e instanceof RegExp?this.nonFilterArgumentKeys=t=>e.test(t):this.nonFilterArgumentKeys=t=>e.includes(t)}else null!=t&&t.createCollectionFilter&&(this.createCollectionFilter=t.createCollectionFilter.bind(this));this.schema instanceof i?(this.createIfValid=m,this.push=f(this,h),this.unshift=f(this,u)):e instanceof r&&(this.createIfValid=y,this.assign=f(this,l))}get cacheWith(){return this.schema.schema}toJSON(){return{name:`Collection(${this.schema.schema.name})`,schema:this.schema.schema.toJSON(),key:this.key}}pk(e,t,s,r){const n=this.argsKey?this.argsKey(...r):this.nestKey(t,s);for(const e in n)"string"!=typeof n[e]&&void 0!==n[e]&&(n[e]=`${n[e]}`);return function(e){const t=Object.keys(e).sort(),s={};for(const r of t)s[r]=e[r];return JSON.stringify(s)}(n)}normalize(e,t,s,r,n,i,o,c){const a=this.schema.normalize(e,t,s,r,n,i,o,c),h=this.pk(a,t,s,c);return n(this,a,h),h}merge(e,t){return t}shouldReorder(e,t,s,r){return t.fetchedAt<e.fetchedAt}mergeWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?this.merge(r,s):this.merge(s,r)}mergeMetaWithStore(e,t,s,r){return this.shouldReorder(e,t,s,r)?e:t}queryKey(e,t,s,r){if(this.argsKey){const t=this.pk(void 0,void 0,"",e);if(s(this.key,t))return t}}denormalize(e,t,s){return this.schema.denormalize(e,t,s)}},Entity:S,Query:class{constructor(e,t){this.schema=e,this.process=t}normalize(...e){return this.schema.normalize(...e)}denormalize(e,t,s){const r=s(e,this.schema);return"symbol"==typeof r?r:this.process(r,...t)}queryKey(e,t,s,r){return t(this.schema,e,s,r)}}});const A=class{};class z extends(S(A)){static process(e,t,s,r){return super.process(e,t,s,r)}}var K;const w="undefined"!=typeof document;let x=w&&!(null!=(K=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&K.getAttribute("content"));try{x||Function()}catch(e){x=!0,w&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @data-client/endpoint will use setPrototypeOf instead")}var E;class N extends Function{constructor(e,t){let s,r;return x?(s=(...e)=>s.fetch(...e),Object.setPrototypeOf(s,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),s=this),e&&(s.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(r=e.name),Object.defineProperty(s,"name",{get(){return r||this.__name},set(e){this.__name=e}}),Object.assign(s,t),s}key(...e){return`${this.name} ${JSON.stringify(e)}`}testKey(e){return e.startsWith(this.name)}bind(e,...t){const s=this.fetch,r=this.key;return this.extend({fetch(){return s.apply(null!=e?e:this,t)},key(){return r.apply(this,t)}})}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(e.fetch,e)}}E=N,(()=>{if("undefined"!=typeof document&&document.FUNC_MANGLE){const e=E.prototype.key;E.prototype.key=function(...t){return null==document.FUNC_MANGLE||document.FUNC_MANGLE(this),this.prototype.key=e,e.call(this,...t)}}})();const C=N;Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.Endpoint=N,e.Entity=z,e.ExtendableEndpoint=C,e.INVALID=o,e.schema=_,e.validateRequired=function(e,t){let s="";if(Object.keys(t).some((t=>!Object.hasOwn(e,t)&&(s=t,!0))))return`Missing key ${s}`},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -16,3 +16,3 @@ /** | ||
const value = unvisit(input, this.schema); | ||
return typeof value === 'symbol' ? undefined : this.process(value, ...args); | ||
return typeof value === 'symbol' ? value : this.process(value, ...args); | ||
} | ||
@@ -23,2 +23,2 @@ queryKey(args, queryKey, getEntity, getIndex) { | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJRdWVyeSIsImNvbnN0cnVjdG9yIiwic2NoZW1hIiwicHJvY2VzcyIsIm5vcm1hbGl6ZSIsImFyZ3MiLCJkZW5vcm1hbGl6ZSIsImlucHV0IiwidW52aXNpdCIsInZhbHVlIiwidW5kZWZpbmVkIiwicXVlcnlLZXkiLCJnZXRFbnRpdHkiLCJnZXRJbmRleCJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL1F1ZXJ5LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHtcbiAgR2V0SW5kZXgsXG4gIEdldEVudGl0eSxcbiAgUXVlcnlhYmxlLFxuICBTY2hlbWFTaW1wbGUsXG59IGZyb20gJy4uL2ludGVyZmFjZS5qcyc7XG5pbXBvcnQgdHlwZSB7XG4gIERlbm9ybWFsaXplTnVsbGFibGUsXG4gIE5vcm1hbGl6ZU51bGxhYmxlLFxuICBTY2hlbWFBcmdzLFxufSBmcm9tICcuLi9ub3JtYWwuanMnO1xuXG4vKipcbiAqIFByb2dyYW1tYXRpYyBjYWNoZSByZWFkaW5nXG4gKlxuICogQHNlZSBodHRwczovL2RhdGFjbGllbnQuaW8vcmVzdC9hcGkvUXVlcnlcbiAqL1xuZXhwb3J0IGRlZmF1bHQgY2xhc3MgUXVlcnk8XG4gIFMgZXh0ZW5kcyBRdWVyeWFibGUsXG4gIFAgZXh0ZW5kcyAoZW50cmllczogRGVub3JtYWxpemV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FDcEIsSUFBSSxDQUFDQyxPQUFPLEdBQUdBLE9BQU87RUFDeEI7RUFFQUMsU0FBU0EsQ0FBQyxHQUFHQyxJQUFTLEVBQUU7SUFDdEIsT0FBUSxJQUFJLENBQUNILE1BQU0sQ0FBU0UsU0FBUyxDQUFDLEdBQUdDLElBQUksQ0FBQztFQUNoRDtFQUVBQyxXQUFXQSxDQUFDQyxLQUFTLEVBQUVGLElBQVMsRUFBRUcsT0FBWSxFQUFpQjtJQUM3RCxNQUFNQyxLQUFLLEdBQUdELE9BQU8sQ0FBQ0QsS0FBSyxFQUFFLElBQUksQ0FBQ0wsTUFBTSxDQUFDO0lBQ3pDLE9BQU8sT0FBT08sS0FBSyxLQUFLLFFBQVEsR0FBR0EsS0FBSyxHQUFHLElBQUksQ0FBQ04sT0FBTyxDQUFDTSxLQUFLLEVBQUUsR0FBR0osSUFBSSxDQUFDO0VBQ3pFO0VBRUFLLFFBQVFBLENBQ05MLElBQTZCLEVBQzdCSyxRQUtRLEVBQ1JDLFNBQW9CLEVBQ3BCQyxRQUFrQixFQUNsQjtJQUNBLE9BQU9GLFFBQVEsQ0FBQyxJQUFJLENBQUNSLE1BQU0sRUFBRUcsSUFBSSxFQUFFTSxTQUFTLEVBQUVDLFFBQVEsQ0FBQztFQUN6RDtBQVNGIiwiaWdub3JlTGlzdCI6W119 |
@@ -130,3 +130,5 @@ import type { | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
_denormalizeNullable(): | ||
| (S extends EntityMap<infer T> ? T : Denormalize<S>)[] | ||
| undefined; | ||
@@ -133,0 +135,0 @@ denormalize( |
import type { GetIndex, GetEntity, Queryable, SchemaSimple } from '../interface.js'; | ||
import type { DenormalizeNullable, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
import type { Denormalize, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Programmatic cache reading | ||
*/ | ||
export default class Query<S extends Queryable, P extends (entries: DenormalizeNullable<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
export default class Query<S extends Queryable, P extends (entries: Denormalize<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
schema: S; | ||
@@ -14,3 +14,3 @@ process: P; | ||
normalize(...args: any): any; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> | undefined; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P>; | ||
queryKey(args: ProcessParameters<P, S>, queryKey: (schema: any, args: any, getEntity: GetEntity, getIndex: GetIndex) => any, getEntity: GetEntity, getIndex: GetIndex): any; | ||
@@ -17,0 +17,0 @@ _denormalizeNullable: (input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any) => ReturnType<P> | undefined; |
@@ -16,3 +16,3 @@ /** | ||
const value = unvisit(input, this.schema); | ||
return typeof value === 'symbol' ? undefined : this.process(value, ...args); | ||
return typeof value === 'symbol' ? value : this.process(value, ...args); | ||
} | ||
@@ -23,2 +23,2 @@ queryKey(args, queryKey, getEntity, getIndex) { | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJRdWVyeSIsImNvbnN0cnVjdG9yIiwic2NoZW1hIiwicHJvY2VzcyIsIm5vcm1hbGl6ZSIsImFyZ3MiLCJkZW5vcm1hbGl6ZSIsImlucHV0IiwidW52aXNpdCIsInZhbHVlIiwidW5kZWZpbmVkIiwicXVlcnlLZXkiLCJnZXRFbnRpdHkiLCJnZXRJbmRleCJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL1F1ZXJ5LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHtcbiAgR2V0SW5kZXgsXG4gIEdldEVudGl0eSxcbiAgUXVlcnlhYmxlLFxuICBTY2hlbWFTaW1wbGUsXG59IGZyb20gJy4uL2ludGVyZmF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RDtBQVNGIiwiaWdub3JlTGlzdCI6W119 |
{ | ||
"name": "@data-client/endpoint", | ||
"version": "0.11.1", | ||
"version": "0.11.3", | ||
"description": "Declarative Network Interface Definitions", | ||
@@ -5,0 +5,0 @@ "homepage": "https://dataclient.io/docs/guides/custom-protocol", |
@@ -130,3 +130,5 @@ import type { | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
_denormalizeNullable(): | ||
| (S extends EntityMap<infer T> ? T : Denormalize<S>)[] | ||
| undefined; | ||
@@ -133,0 +135,0 @@ denormalize( |
// eslint-env jest | ||
import { MemoCache } from '@data-client/normalizr'; | ||
import { useQuery, useSuspense } from '@data-client/react'; | ||
import { RestEndpoint } from '@data-client/rest'; | ||
import { IDEntity } from '__tests__/new'; | ||
@@ -191,3 +193,2 @@ import { fromJS } from 'immutable'; | ||
(results, { asc } = { asc: false }, ...args) => { | ||
if (!results) return results; | ||
const sorted = [...results].sort((a, b) => a.name.localeCompare(b.name)); | ||
@@ -218,2 +219,45 @@ if (asc) return sorted; | ||
test('works if base entity suspends', () => { | ||
const entities = { | ||
User: { | ||
1: { id: '1', name: 'Milo' }, | ||
2: { id: '2', name: 'Jake' }, | ||
3: { id: '3', name: 'Zeta' }, | ||
4: { id: '4', name: 'Alpha' }, | ||
}, | ||
}; | ||
const users = new MemoCache().query('', sortedUsers, [], entities, {}); | ||
expect(users).toBeUndefined(); | ||
}); | ||
test('works if base entity suspends', () => { | ||
const allSortedUsers = new schema.Query( | ||
new schema.All(User), | ||
(results, { asc } = { asc: false }, ...args) => { | ||
const sorted = [...results].sort((a, b) => | ||
a.name.localeCompare(b.name), | ||
); | ||
if (asc) return sorted; | ||
return sorted.reverse(); | ||
}, | ||
); | ||
const users = new MemoCache().query('', allSortedUsers, [], {}, {}); | ||
expect(users).toBeUndefined(); | ||
}); | ||
test('works with nested schemas', () => { | ||
const allSortedUsers = new schema.Query( | ||
new schema.All(User), | ||
(results, { asc } = { asc: false }, ...args) => { | ||
const sorted = [...results].sort((a, b) => | ||
a.name.localeCompare(b.name), | ||
); | ||
if (asc) return sorted; | ||
return sorted.reverse(); | ||
}, | ||
); | ||
const users = new MemoCache().query('', allSortedUsers, [], {}, {}); | ||
expect(users).toBeUndefined(); | ||
}); | ||
test('denormalizes should not be found when no entities are present', () => { | ||
@@ -231,2 +275,18 @@ const entities = { | ||
}); | ||
test('', () => { | ||
const getUsers = new RestEndpoint({ | ||
path: '/users', | ||
searchParams: {} as { asc?: boolean }, | ||
schema: sortedUsers, | ||
}); | ||
() => { | ||
const users = useSuspense(getUsers, { asc: true }); | ||
users.map(user => user.name); | ||
const others = useQuery(getUsers.schema, { asc: true }); | ||
// @ts-expect-error | ||
others.map(user => user.name); | ||
others?.map(user => user.name); | ||
}; | ||
}); | ||
}); |
@@ -8,2 +8,3 @@ import type { | ||
import type { | ||
Denormalize, | ||
DenormalizeNullable, | ||
@@ -21,3 +22,3 @@ NormalizeNullable, | ||
S extends Queryable, | ||
P extends (entries: DenormalizeNullable<S>, ...args: any) => any, | ||
P extends (entries: Denormalize<S>, ...args: any) => any, | ||
> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> | ||
@@ -37,5 +38,5 @@ { | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> | undefined { | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> { | ||
const value = unvisit(input, this.schema); | ||
return typeof value === 'symbol' ? undefined : this.process(value, ...args); | ||
return typeof value === 'symbol' ? value : this.process(value, ...args); | ||
} | ||
@@ -42,0 +43,0 @@ |
@@ -39,3 +39,3 @@ import { Schema, EntityInterface, PolymorphicInterface, SchemaClass, GetIndex, GetEntity, } from './interface.js'; | ||
_normalizeNullable(): (S extends EntityMap ? UnionResult<S> : Normalize<S>)[] | undefined; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[] | undefined; | ||
denormalize(input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
@@ -42,0 +42,0 @@ queryKey( |
import { GetIndex, GetEntity, Queryable, SchemaSimple } from '../interface.js'; | ||
import { DenormalizeNullable, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
import { Denormalize, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Programmatic cache reading | ||
*/ | ||
export default class Query<S extends Queryable, P extends (entries: DenormalizeNullable<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
export default class Query<S extends Queryable, P extends (entries: Denormalize<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
schema: S; | ||
@@ -14,3 +14,3 @@ process: P; | ||
normalize(...args: any): any; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> | undefined; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P>; | ||
queryKey(args: ProcessParameters<P, S>, queryKey: (schema: any, args: any, getEntity: GetEntity, getIndex: GetIndex) => any, getEntity: GetEntity, getIndex: GetIndex): any; | ||
@@ -17,0 +17,0 @@ _denormalizeNullable: (input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any) => ReturnType<P> | undefined; |
@@ -39,3 +39,3 @@ import type { Schema, EntityInterface, PolymorphicInterface, SchemaClass, GetIndex, GetEntity, } from './interface.js'; | ||
_normalizeNullable(): (S extends EntityMap ? UnionResult<S> : Normalize<S>)[] | undefined; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[] | undefined; | ||
denormalize(input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
@@ -42,0 +42,0 @@ queryKey( |
import type { GetIndex, GetEntity, Queryable, SchemaSimple } from '../interface.js'; | ||
import type { DenormalizeNullable, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
import type { Denormalize, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Programmatic cache reading | ||
*/ | ||
export default class Query<S extends Queryable, P extends (entries: DenormalizeNullable<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
export default class Query<S extends Queryable, P extends (entries: Denormalize<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
schema: S; | ||
@@ -14,3 +14,3 @@ process: P; | ||
normalize(...args: any): any; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> | undefined; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P>; | ||
queryKey(args: ProcessParameters<P, S>, queryKey: (schema: any, args: any, getEntity: GetEntity, getIndex: GetIndex) => any, getEntity: GetEntity, getIndex: GetIndex): any; | ||
@@ -17,0 +17,0 @@ _denormalizeNullable: (input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any) => ReturnType<P> | undefined; |
@@ -39,3 +39,3 @@ import type { Schema, EntityInterface, PolymorphicInterface, SchemaClass, GetIndex, GetEntity, } from './interface.js'; | ||
_normalizeNullable(): (S extends EntityMap ? UnionResult<S> : Normalize<S>)[] | undefined; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
_denormalizeNullable(): (S extends EntityMap<infer T> ? T : Denormalize<S>)[] | undefined; | ||
denormalize(input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any): (S extends EntityMap<infer T> ? T : Denormalize<S>)[]; | ||
@@ -42,0 +42,0 @@ queryKey( |
import type { GetIndex, GetEntity, Queryable, SchemaSimple } from '../interface.js'; | ||
import type { DenormalizeNullable, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
import type { Denormalize, NormalizeNullable, SchemaArgs } from '../normal.js'; | ||
/** | ||
@@ -8,3 +8,3 @@ * Programmatic cache reading | ||
*/ | ||
export default class Query<S extends Queryable, P extends (entries: DenormalizeNullable<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
export default class Query<S extends Queryable, P extends (entries: Denormalize<S>, ...args: any) => any> implements SchemaSimple<ReturnType<P> | undefined, ProcessParameters<P, S>> { | ||
schema: S; | ||
@@ -14,3 +14,3 @@ process: P; | ||
normalize(...args: any): any; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P> | undefined; | ||
denormalize(input: {}, args: any, unvisit: any): ReturnType<P>; | ||
queryKey(args: ProcessParameters<P, S>, queryKey: (schema: any, args: any, getEntity: GetEntity, getIndex: GetIndex) => any, getEntity: GetEntity, getIndex: GetIndex): any; | ||
@@ -17,0 +17,0 @@ _denormalizeNullable: (input: {}, args: readonly any[], unvisit: (input: any, schema: any) => any) => ReturnType<P> | undefined; |
Sorry, the diff of this file is not supported yet
1161146
17427