@rest-hooks/endpoint
Advanced tools
Comparing version 3.7.1 to 3.7.2
@@ -916,10 +916,14 @@ 'use strict'; | ||
var _document$querySelect; | ||
/* istanbul ignore file */ | ||
let CSP = false; | ||
const isBrowser = typeof document !== 'undefined'; | ||
let CSP = isBrowser && !((_document$querySelect = document.querySelector("meta[http-equiv='Content-Security-Policy']")) != null && _document$querySelect.getAttribute('content')); | ||
try { | ||
Function(); | ||
if (!CSP) Function(); | ||
} catch (e) { | ||
CSP = true; | ||
// TODO: figure out how to supress the error log instead of tell people it's okay | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
if (isBrowser) { | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
} | ||
} | ||
@@ -926,0 +930,0 @@ |
@@ -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).restHookEndpoint={})}(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")))}function s(e,t,s){let r=!0,i=!1;return[Object.keys(e).reduce(((t,n)=>{const o=`${n}`,[c,a,h]=s(t.get(o),e[o]);return a||(r=!1),h&&(i=!0),t.has(o)?t.set(o,c):t}),t),r,i]}class r{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){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,i,n){const o=this.inferSchema(e,t,s);if(!o)return e;const c=r(e,t,s,o,i,n);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,s)}}denormalizeValue(e,s){const r=!this.isSingleSchema&&(t(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!r)return[e,!0,!1];return s((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[r])}}const i=([e,,t])=>void 0!==e&&!t;class n extends r{normalize(e,t,s,r,i,n){const o=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return o.map(((e,o)=>this.normalizeValue(e,t,s,r,i,n))).filter((e=>null!=e))}denormalize(e,t){return[e.map?e.map((e=>this.denormalizeValue(e,t))).filter(i).map((([e])=>e)):e,!0,!1]}infer(e,t,s,r){}toJSON(){return[this.schema]}}const o=Symbol("ENTITY WAS DELETED");var c,a=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,i={},n=Object.keys(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||(i[s]=e[s]);return i},e.exports.__esModule=!0,e.exports.default=e.exports})),h=(c=a)&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c;const u=["pk","schema","key"];function l(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){return this.prototype.pk.call(e,t,s)}static useIncoming(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.useIncoming(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 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){return Object.assign({},e)}static normalize(e,t,s,r,i,n){const o=this.process(e,t,s),c=this.pk(o,t,s);if(void 0===c||""===c)return;const a=this.key;if(a in n||(n[a]={}),c in n[a]||(n[a][c]=[]),n[a][c].some((t=>t===e)))return c;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(o)),n[a][c].push(e),Object.keys(this.schema).forEach((e=>{if(Object.hasOwn(o,e)){const t=this.schema[e];o[e]=r(o[e],o,e,t,i,n)}})),i(this,o,c),c}static validate(e){}static infer(e,t,s){if(!e[0])return;if(["string","number"].includes(typeof e[0]))return`${e[0]}`;const r=this.pk(e[0],void 0,"");if(void 0!==r&&""!==r)return r;const i=function(e,t){return t?t.find((t=>Object.hasOwn(e,t))):void 0}(e[0],this.indexes);if(i&&t[this.key]){return t[this.key][i][e[0][i]]}}static expiresAt(e,t){return e.expiresAt}static denormalize(e,t){if("symbol"==typeof e)return[void 0,!0,!0];let s=!1;return Object.keys(this.schema).forEach((r=>{const i=this.schema[r],n=e[r],[o,,c]=t(n,i);c&&this.defaults[r]&&(s=!0),e[r]=o})),[e,!0,s]}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const r=h(t,u);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});else if(!("key"in e)){function i(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0})}const n="EntityMixin"!==s.name?function(){const t="EntityMixin"===this.name?e.name:this.name;return console.error("Rest Hooks Error: https://resthooks.io/errors/dklj"),Object.defineProperty(this,"key",{get:()=>t,set:i}),this.key}:function(){return"EntityMixin"===this.name?e.name:this.name};Object.defineProperty(s,"key",{get:n,set:i})}return s}var m=Object.freeze({__proto__:null,Union:class extends r{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,s,r,i,n){return this.normalizeValue(e,t,s,r,i,n)}denormalize(e,t){return this.denormalizeValue(e,t)}infer(e,t,s,r){if(!e[0])return;const i=this.getSchemaAttribute(e[0],void 0,""),n=this.schema[i];return void 0!==n?{id:s(n,e,t,r),schema:i}:void 0}},Values:class extends r{normalize(e,t,s,r,i,n){return Object.keys(e).reduce(((t,s,o)=>{const c=e[s];return null!=c?Object.assign({},t,{[s]:this.normalizeValue(c,e,s,r,i,n)}):t}),{})}denormalize(e,t){let s=!0,r=!1;return[Object.keys(e).reduce(((i,n)=>{const o=e[n],[c,a,h]=this.denormalizeValue(o,t);return a||(s=!1),h&&(r=!0),!a||h?i:Object.assign({},i,{[n]:c})}),{}),s,r]}infer(e,t,s){}},Array:n,All:class extends n{constructor(e,t){super(e,t)}normalize(e,t,s,r,i,n){super.normalize(e,t,s,r,i,n)}infer(e,t,s,r){if(this.isSingleSchema){const e=r[this.schema.key];if(void 0===e)return;return Object.values(e).map((e=>e&&this.schema.pk(e)))}let i=!1;const n=Object.values(this.schema).flatMap((e=>r[e.key]?(i=!0,Object.values(r[e.key]).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)})))):[]));if(i)return n}},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,i,n,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach((s=>{const r=e[s],a=i(t[s],t,s,r,n,o);null==a?delete c[s]:c[s]=a})),c})(this.schema,...e)}denormalize(...e){return((e,r,i)=>{if(t(r))return s(e,r,i);const n=Object.assign({},r);let o=!0,c=!1;return Object.keys(e).forEach((t=>{const[s,r,a]=i(n[t],e[t]);void 0!==n[t]&&(n[t]=s),a&&(c=!0),r||(o=!1)})),[n,o,c]})(this.schema,...e)}infer(e,t,s,r){return function(e,t,s,r,i){const n={};return Object.keys(e).forEach((o=>{n[o]=r(e[o],t,s,i)})),n}(this.schema,e,t,s,r)}},Delete:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,s,r,i,n){const c=this._entity.process(e,t,s),a=this._entity.pk(c,t,s);return i(this,o,a),a}infer(e,t,s){}denormalize(e,t){return t(e,this._entity)}_denormalizeNullable(){return[]}_normalizeNullable(){return[]}merge(e,t){return t}useIncoming(e,t,s,r){return e.date<=t.date}},Entity:l});const f=class{};class d extends(l(f)){static useIncoming(e,t,s,r){return e.fetchedAt<=t.fetchedAt}static mergeWithStore(e,t,s,r){return!e||this.useIncoming(e,t,s,r)?typeof r!=typeof s?r:this.merge(s,r):s}static process(e,t,s){return super.process(e,t,s)}static validate(e){return super.validate(e)}static denormalize(e,r){if("symbol"==typeof e)return[void 0,!0,!0];if(t(e)){if(this.validate(e.toJS()))return[void 0,!1,!0];null==r.setLocal||r.setLocal(e);const[t,i,n]=s(this.schema,e,r);return[this.fromJS(t.toObject()),!0,n]}let i;if(e instanceof this)i=e;else{if(this.validate(e))return[void 0,!1,!0];i=this.fromJS(e),null==r.setLocal||r.setLocal(i)}let n=!1;return Object.keys(this.schema).forEach((t=>{const s=this.schema[t],o=e[t],[c,,a]=r(o,s);a&&this.defaults[t]&&(n=!0),e[t]!==c&&this.set(i,t,c)})),[i,!0,n]}static set(e,t,s){e[t]=s}}let p=!1;try{Function()}catch(e){p=!0,console.error("Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead")}function y(e,t){e.type=e.sideEffect?"mutate":"read",e.options=Object.assign({},t),delete e.options.key,delete e.options.schema,delete e.options.sideEffect,delete e.options.fetch,delete e.options.getFetchKey,delete e.options.options,0===Object.keys(e.options).length&&delete e.options,void 0===e.schema&&(e.schema=null)}class b extends Function{constructor(e,t){let s,r;return p?(s=(...e)=>s.fetch(...e),Object.setPrototypeOf(s,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),s=this),s.getFetchKey=e=>s.key(e),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),y(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{}Object.assign(t.prototype,this);const s=new t(e.fetch,e);return y(s,Object.assign({},this.options,e)),s}}"runCompat"!==y.name&&(b.prototype.key=function(...e){return console.error("Rest Hooks Error: https://resthooks.io/errors/osid"),`${this.name} ${JSON.stringify(e)}`});const g=b;class O extends Error{}Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.AbortOptimistic=O,e.DELETED=o,e.Endpoint=b,e.Entity=d,e.ExtendableEndpoint=g,e.Index=class{constructor(e,t){this.getFetchKey=e=>this.key(e),this.schema=e,t&&(this.key=t)}key(e){return JSON.stringify(e)}},e.Query=class{constructor(e,t){this.sideEffect=void 0,this.schema=this.createQuerySchema(e),t?this.process=t:this.process||(this.process=e=>e)}key(...e){return`QUERY ${JSON.stringify(e)}`}createQuerySchema(e){const t=Object.create(e);return t.denormalize=({args:t,input:s},r)=>{if(void 0===s)return[void 0,!1,!0];const[i,n,o]=e.denormalize(s,r);return[n?this.process(i,...t):void 0,n,o]},t.infer=(t,s,r,i)=>({args:t,input:r(e,t,s,i)}),t}},e.schema=m,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).restHookEndpoint={})}(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")))}function s(e,t,s){let n=!0,r=!1;return[Object.keys(e).reduce(((t,i)=>{const o=`${i}`,[c,a,h]=s(t.get(o),e[o]);return a||(n=!1),h&&(r=!0),t.has(o)?t.set(o,c):t}),t),n,r]}class n{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){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 n=this.getSchemaAttribute(e,t,s);return this.schema[n]}normalizeValue(e,t,s,n,r,i){const o=this.inferSchema(e,t,s);if(!o)return e;const c=n(e,t,s,o,r,i);return this.isSingleSchema||null==c?c:{id:c,schema:this.getSchemaAttribute(e,t,s)}}denormalizeValue(e,s){const n=!this.isSingleSchema&&(t(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!n)return[e,!0,!1];return s((this.isSingleSchema?void 0:t(e)?e.get("id"):e.id)||e,this.isSingleSchema?this.schema:this.schema[n])}}const r=([e,,t])=>void 0!==e&&!t;class i extends n{normalize(e,t,s,n,r,i){const o=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return o.map(((e,o)=>this.normalizeValue(e,t,s,n,r,i))).filter((e=>null!=e))}denormalize(e,t){return[e.map?e.map((e=>this.denormalizeValue(e,t))).filter(r).map((([e])=>e)):e,!0,!1]}infer(e,t,s,n){}toJSON(){return[this.schema]}}const o=Symbol("ENTITY WAS DELETED");var c,a=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(e,t){if(null==e)return{};var s,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)s=i[n],t.indexOf(s)>=0||(r[s]=e[s]);return r},e.exports.__esModule=!0,e.exports.default=e.exports})),h=(c=a)&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c;const u=["pk","schema","key"];function l(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){return this.prototype.pk.call(e,t,s)}static useIncoming(e,t,s,n){return!0}static shouldReorder(e,t,s,n){return t.fetchedAt<e.fetchedAt}static merge(e,t){return Object.assign({},e,t)}static mergeWithStore(e,t,s,n){return this.useIncoming(e,t,s,n)?typeof n!=typeof s?n:this.shouldReorder(e,t,s,n)?this.merge(n,s):this.merge(s,n):s}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){return Object.assign({},e)}static normalize(e,t,s,n,r,i){const o=this.process(e,t,s),c=this.pk(o,t,s);if(void 0===c||""===c)return;const a=this.key;if(a in i||(i[a]={}),c in i[a]||(i[a][c]=[]),i[a][c].some((t=>t===e)))return c;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(o)),i[a][c].push(e),Object.keys(this.schema).forEach((e=>{if(Object.hasOwn(o,e)){const t=this.schema[e];o[e]=n(o[e],o,e,t,r,i)}})),r(this,o,c),c}static validate(e){}static infer(e,t,s){if(!e[0])return;if(["string","number"].includes(typeof e[0]))return`${e[0]}`;const n=this.pk(e[0],void 0,"");if(void 0!==n&&""!==n)return n;const r=function(e,t){return t?t.find((t=>Object.hasOwn(e,t))):void 0}(e[0],this.indexes);if(r&&t[this.key]){return t[this.key][r][e[0][r]]}}static expiresAt(e,t){return e.expiresAt}static denormalize(e,t){if("symbol"==typeof e)return[void 0,!0,!0];let s=!1;return Object.keys(this.schema).forEach((n=>{const r=this.schema[n],i=e[n],[o,,c]=t(i,r);c&&this.defaults[n]&&(s=!0),e[n]=o})),[e,!0,s]}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const n=h(t,u);if(Object.assign(s,n),"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});else if(!("key"in e)){function r(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0})}const i="EntityMixin"!==s.name?function(){const t="EntityMixin"===this.name?e.name:this.name;return console.error("Rest Hooks Error: https://resthooks.io/errors/dklj"),Object.defineProperty(this,"key",{get:()=>t,set:r}),this.key}:function(){return"EntityMixin"===this.name?e.name:this.name};Object.defineProperty(s,"key",{get:i,set:r})}return s}var m=Object.freeze({__proto__:null,Union:class extends n{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,s,n,r,i){return this.normalizeValue(e,t,s,n,r,i)}denormalize(e,t){return this.denormalizeValue(e,t)}infer(e,t,s,n){if(!e[0])return;const r=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[r];return void 0!==i?{id:s(i,e,t,n),schema:r}:void 0}},Values:class extends n{normalize(e,t,s,n,r,i){return Object.keys(e).reduce(((t,s,o)=>{const c=e[s];return null!=c?Object.assign({},t,{[s]:this.normalizeValue(c,e,s,n,r,i)}):t}),{})}denormalize(e,t){let s=!0,n=!1;return[Object.keys(e).reduce(((r,i)=>{const o=e[i],[c,a,h]=this.denormalizeValue(o,t);return a||(s=!1),h&&(n=!0),!a||h?r:Object.assign({},r,{[i]:c})}),{}),s,n]}infer(e,t,s){}},Array:i,All:class extends i{constructor(e,t){super(e,t)}normalize(e,t,s,n,r,i){super.normalize(e,t,s,n,r,i)}infer(e,t,s,n){if(this.isSingleSchema){const e=n[this.schema.key];if(void 0===e)return;return Object.values(e).map((e=>e&&this.schema.pk(e)))}let r=!1;const i=Object.values(this.schema).flatMap((e=>n[e.key]?(r=!0,Object.values(n[e.key]).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)})))):[]));if(r)return i}},Object:class{constructor(e){this.schema=void 0,this.define(e)}define(e){this.schema=Object.keys(e).reduce(((t,s)=>{const n=e[s];return Object.assign({},t,{[s]:n})}),this.schema||{})}normalize(...e){return((e,t,s,n,r,i,o)=>{const c=Object.assign({},t);return Object.keys(e).forEach((s=>{const n=e[s],a=r(t[s],t,s,n,i,o);null==a?delete c[s]:c[s]=a})),c})(this.schema,...e)}denormalize(...e){return((e,n,r)=>{if(t(n))return s(e,n,r);const i=Object.assign({},n);let o=!0,c=!1;return Object.keys(e).forEach((t=>{const[s,n,a]=r(i[t],e[t]);void 0!==i[t]&&(i[t]=s),a&&(c=!0),n||(o=!1)})),[i,o,c]})(this.schema,...e)}infer(e,t,s,n){return function(e,t,s,n,r){const i={};return Object.keys(e).forEach((o=>{i[o]=n(e[o],t,s,r)})),i}(this.schema,e,t,s,n)}},Delete:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,s,n,r,i){const c=this._entity.process(e,t,s),a=this._entity.pk(c,t,s);return r(this,o,a),a}infer(e,t,s){}denormalize(e,t){return t(e,this._entity)}_denormalizeNullable(){return[]}_normalizeNullable(){return[]}merge(e,t){return t}useIncoming(e,t,s,n){return e.date<=t.date}},Entity:l});const f=class{};class d extends(l(f)){static useIncoming(e,t,s,n){return e.fetchedAt<=t.fetchedAt}static mergeWithStore(e,t,s,n){return!e||this.useIncoming(e,t,s,n)?typeof n!=typeof s?n:this.merge(s,n):s}static process(e,t,s){return super.process(e,t,s)}static validate(e){return super.validate(e)}static denormalize(e,n){if("symbol"==typeof e)return[void 0,!0,!0];if(t(e)){if(this.validate(e.toJS()))return[void 0,!1,!0];null==n.setLocal||n.setLocal(e);const[t,r,i]=s(this.schema,e,n);return[this.fromJS(t.toObject()),!0,i]}let r;if(e instanceof this)r=e;else{if(this.validate(e))return[void 0,!1,!0];r=this.fromJS(e),null==n.setLocal||n.setLocal(r)}let i=!1;return Object.keys(this.schema).forEach((t=>{const s=this.schema[t],o=e[t],[c,,a]=n(o,s);a&&this.defaults[t]&&(i=!0),e[t]!==c&&this.set(r,t,c)})),[r,!0,i]}static set(e,t,s){e[t]=s}}var p;const y="undefined"!=typeof document;let b=y&&!(null!=(p=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&p.getAttribute("content"));try{b||Function()}catch(e){b=!0,y&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead")}function g(e,t){e.type=e.sideEffect?"mutate":"read",e.options=Object.assign({},t),delete e.options.key,delete e.options.schema,delete e.options.sideEffect,delete e.options.fetch,delete e.options.getFetchKey,delete e.options.options,0===Object.keys(e.options).length&&delete e.options,void 0===e.schema&&(e.schema=null)}class O extends Function{constructor(e,t){let s,n;return b?(s=(...e)=>s.fetch(...e),Object.setPrototypeOf(s,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),s=this),s.getFetchKey=e=>s.key(e),e&&(s.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(n=e.name),Object.defineProperty(s,"name",{get(){return n||this.__name},set(e){this.__name=e}}),Object.assign(s,t),g(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,n=this.key;return this.extend({fetch(){return s.apply(null!=e?e:this,t)},key(){return n.apply(this,t)}})}extend(e){class t extends this.constructor{}Object.assign(t.prototype,this);const s=new t(e.fetch,e);return g(s,Object.assign({},this.options,e)),s}}"runCompat"!==g.name&&(O.prototype.key=function(...e){return console.error("Rest Hooks Error: https://resthooks.io/errors/osid"),`${this.name} ${JSON.stringify(e)}`});const k=O;class j extends Error{}Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.AbortOptimistic=j,e.DELETED=o,e.Endpoint=O,e.Entity=d,e.ExtendableEndpoint=k,e.Index=class{constructor(e,t){this.getFetchKey=e=>this.key(e),this.schema=e,t&&(this.key=t)}key(e){return JSON.stringify(e)}},e.Query=class{constructor(e,t){this.sideEffect=void 0,this.schema=this.createQuerySchema(e),t?this.process=t:this.process||(this.process=e=>e)}key(...e){return`QUERY ${JSON.stringify(e)}`}createQuerySchema(e){const t=Object.create(e);return t.denormalize=({args:t,input:s},n)=>{if(void 0===s)return[void 0,!1,!0];const[r,i,o]=e.denormalize(s,n);return[i?this.process(r,...t):void 0,i,o]},t.infer=(t,s,n,r)=>({args:t,input:n(e,t,s,r)}),t}},e.schema=m,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})})); |
@@ -0,10 +1,14 @@ | ||
var _document$querySelect; | ||
/* istanbul ignore file */ | ||
export let CSP = false; | ||
const isBrowser = typeof document !== 'undefined'; | ||
export let CSP = isBrowser && !((_document$querySelect = document.querySelector("meta[http-equiv='Content-Security-Policy']")) != null && _document$querySelect.getAttribute('content')); | ||
try { | ||
Function(); | ||
if (!CSP) Function(); | ||
} catch (e) { | ||
CSP = true; | ||
// TODO: figure out how to supress the error log instead of tell people it's okay | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
if (isBrowser) { | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
} | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDU1AiLCJGdW5jdGlvbiIsImUiLCJjb25zb2xlIiwiZXJyb3IiXSwic291cmNlcyI6WyIuLi9zcmMvQ1NQLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGlzdGFuYnVsIGlnbm9yZSBmaWxlICovXG5leHBvcnQgbGV0IENTUCA9IGZhbHNlO1xudHJ5IHtcbiAgRnVuY3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FDQyxLQUFLLENBQ1gsNEhBQTRILENBQzdIO0VBQ0g7QUFDRiJ9 |
@@ -0,10 +1,14 @@ | ||
var _document$querySelect; | ||
/* istanbul ignore file */ | ||
export let CSP = false; | ||
const isBrowser = typeof document !== 'undefined'; | ||
export let CSP = isBrowser && !((_document$querySelect = document.querySelector("meta[http-equiv='Content-Security-Policy']")) != null && _document$querySelect.getAttribute('content')); | ||
try { | ||
Function(); | ||
if (!CSP) Function(); | ||
} catch (e) { | ||
CSP = true; | ||
// TODO: figure out how to supress the error log instead of tell people it's okay | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
if (isBrowser) { | ||
console.error('Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead'); | ||
} | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDU1AiLCJGdW5jdGlvbiIsImUiLCJjb25zb2xlIiwiZXJyb3IiXSwic291cmNlcyI6WyIuLi9zcmMvQ1NQLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qIGlzdGFuYnVsIGlnbm9yZSBmaWxlICovXG5leHBvcnQgbGV0IENTUCA9IGZhbHNlO1xudHJ5IHtcbiAgRnVuY3Rpb24oKTtcbn0gY2F0Y2ggKGUpIHtcbiAgQ1NQID0gdHJ1ZTtcbiAgLy8gVE9ETzogZmlndXJlIG91dCBob3cgdG8gc3VwcmVzcyB0aGUgZXJyb3IgbG9nIGluc3RlYWQgb2YgdGVsbCBwZW9wbGUgaXQncyBva2F5XG4gIGNvbnNvbGUuZXJyb3IoXG4gICAgJ0NvbnRlbnQgU2VjdXJpdHkgUG9saWN5OiBUaGUgcHJldmlvdXMgQ1NQIGxvZyBjYW4gYmUgc2FmZWx5IGlnbm9yZWQgLSBAcmVzdC1ob29rcy9lbmRwb2ludCB3aWxsIHVzZSBzZXRQcm90b3R5cGVPZiBpbn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uICBpZiAoaXNCcm93c2VyKSB7XG4gICAgY29uc29sZS5lcnJvcihcbiAgICAgICdDb250ZW50IFNlY3VyaXR5IFBvbGljeTogVGhlIHByZXZpb3VzIENTUCBsb2cgY2FuIGJlIHNhZmVseSBpZ25vcmVkIC0gQHJlc3QtaG9va3MvZW5kcG9pbnQgd2lsbCB1c2Ugc2V0UHJvdG90eXBlT2YgaW5zdGVhZCcsXG4gICAgKTtcbiAgfVxufVxuIl0sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQSxNQUFNQSxTQUFTLEdBQUcsT0FBT0MsUUFBUSxLQUFLLFdBQVc7QUFDakQsT0FBTyxJQUFJQyxHQUFHLEdBQ1pGLFNBQVMsSUFDVCxHQUFBRyxxQkFBQSxHQUFDRixRQUFRLENBQ05HLGFBQWEsQ0FBQyw0Q0FBNEMsQ0FBQyxhQUQ3REQscUJBQUEsQ0FFR0UsWUFBWSxDQUFDLFNBQVMsQ0FBQztBQUM3QixJQUFJO0VBQ0YsSUFBSSxDQUFDSCxHQUFHLEVBQUVJLFFBQVEsRUFBRTtBQUN0QixDQUFDLENBQUMsT0FBT0MsQ0FBQyxFQUFFO0VBQ1ZMLEdBQUcsR0FBRyxJQUFJO0VBQ1Y7RUFDQSxJQUFJRixTQUFTLEVBQUU7SUFDYlEsT0FBTyxDQUFDQyxLQUFLLENBQ1gsNEhBQTRILENBQzdIO0VBQ0g7QUFDRiJ9 |
@@ -30,3 +30,3 @@ import type { | ||
PKClass, | ||
} from './schemas/EntitySchema'; | ||
} from './schemas/EntitySchema.js'; | ||
@@ -33,0 +33,0 @@ export { Delete, EntityMap }; |
{ | ||
"name": "@rest-hooks/endpoint", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"description": "Declarative Network Interface Definitions", | ||
@@ -106,3 +106,3 @@ "sideEffects": false, | ||
"@babel/cli": "7.21.0", | ||
"@babel/core": "7.21.0", | ||
"@babel/core": "7.21.3", | ||
"@types/babel__core": "^7", | ||
@@ -121,3 +121,3 @@ "downlevel-dts": "^0.10.0", | ||
}, | ||
"gitHead": "922ed06e929151f59b51161629e220824da0b080" | ||
"gitHead": "a1c7373956f3fd885390e13840553c920da4a62f" | ||
} |
/* istanbul ignore file */ | ||
export let CSP = false; | ||
const isBrowser = typeof document !== 'undefined'; | ||
export let CSP = | ||
isBrowser && | ||
!document | ||
.querySelector("meta[http-equiv='Content-Security-Policy']") | ||
?.getAttribute('content'); | ||
try { | ||
Function(); | ||
if (!CSP) Function(); | ||
} catch (e) { | ||
CSP = true; | ||
// TODO: figure out how to supress the error log instead of tell people it's okay | ||
console.error( | ||
'Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead', | ||
); | ||
if (isBrowser) { | ||
console.error( | ||
'Content Security Policy: The previous CSP log can be safely ignored - @rest-hooks/endpoint will use setPrototypeOf instead', | ||
); | ||
} | ||
} |
@@ -30,3 +30,3 @@ import type { | ||
PKClass, | ||
} from './schemas/EntitySchema'; | ||
} from './schemas/EntitySchema.js'; | ||
@@ -33,0 +33,0 @@ export { Delete, EntityMap }; |
import { SchemaSimple, Schema, UnvisitFunction, NormalizedIndex, EntityTable, EntityInterface, } from './interface.js'; | ||
import { AbstractInstanceType, Normalize, NormalizeNullable, Denormalize, DenormalizeNullable, DenormalizeObject, DenormalizeNullableObject, NormalizeObject, NormalizedNullableObject, EntityMap, } from './normal.js'; | ||
import { default as Delete } from './schemas/Delete.js'; | ||
import { EntityOptions, IEntityClass, IEntityInstance, RequiredPKOptions, IDClass, Constructor, PKClass, } from './schemas/EntitySchema'; | ||
import { EntityOptions, IEntityClass, IEntityInstance, RequiredPKOptions, IDClass, Constructor, PKClass, } from './schemas/EntitySchema.js'; | ||
export { Delete, EntityMap }; | ||
@@ -6,0 +6,0 @@ export { EntityInterface } from './interface.js'; |
957015
14807