From 5c9ec56c5f1d862a71330dd32e74cf631ccc3611 Mon Sep 17 00:00:00 2001 From: Chael Gutierrez Date: Tue, 2 Jul 2024 15:03:52 +0800 Subject: [PATCH] Fixed undefined collection name (#14) --- packages/dist/arm-js-library.es.js | 20 ++++++++++---------- packages/dist/arm-js-library.umd.js | 2 +- packages/src/lib/api-resource-manager.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/dist/arm-js-library.es.js b/packages/dist/arm-js-library.es.js index 811d11a..17c0b73 100644 --- a/packages/dist/arm-js-library.es.js +++ b/packages/dist/arm-js-library.es.js @@ -3,7 +3,7 @@ import Z from "lodash"; import * as K from "mobx"; import { v1 as z } from "uuid"; import ss from "crypto-js"; -const { makeObservable: es, observable: F, action: N, toJS: k } = K, { +const { makeObservable: es, observable: F, action: k, toJS: N } = K, { get: i, set: h, find: H, @@ -69,10 +69,10 @@ class us { collections: F, aliases: F, requestHashIds: F, - _pushPayloadToCollection: N, - _pushRequestHash: N, - _addCollection: N, - _addAlias: N + _pushPayloadToCollection: k, + _pushRequestHash: k, + _addCollection: k, + _addAlias: k }); } _initializeAxiosConfig() { @@ -104,9 +104,9 @@ class us { _setProperty(s, e) { h(this, s, e); const t = C( - k(this.originalRecord), + N(this.originalRecord), E - ), a = C(k(this), E); + ), a = C(N(this), E); _(t, a) ? (h(this, "isDirty", !1), h(this, "isPristine", !0)) : (h(this, "isDirty", !0), h(this, "isPristine", !1)); } _setProperties(s) { @@ -119,9 +119,9 @@ class us { const t = e(s); f(t, ({ key: d, value: n }) => h(this, d, n)); const a = C( - k(this.originalRecord), + N(this.originalRecord), E - ), r = C(k(this), E); + ), r = C(N(this), E); _(a, r) ? (h(this, "isDirty", !1), h(this, "isPristine", !0)) : (h(this, "isDirty", !0), h(this, "isPristine", !1)); } unloadRecord(s) { @@ -201,7 +201,7 @@ class us { _injectReferenceKeys(s, e, t = null) { const a = is(t) ? this._generateHashId({ id: i(e, "id"), - collectionName: i(e, "collectionName") + collectionName: s }) : t; h(e, "collectionName", s), h(e, "hashId", a), h(e, "isLoading", !1), h(e, "isError", !1), h(e, "isPristine", !0), h(e, "isDirty", !1); } diff --git a/packages/dist/arm-js-library.umd.js b/packages/dist/arm-js-library.umd.js index fd55ccc..2df736d 100644 --- a/packages/dist/arm-js-library.umd.js +++ b/packages/dist/arm-js-library.umd.js @@ -1 +1 @@ -(function(I,C){typeof exports=="object"&&typeof module<"u"?module.exports=C(require("axios"),require("lodash"),require("mobx"),require("uuid"),require("crypto-js")):typeof define=="function"&&define.amd?define(["axios","lodash","mobx","uuid","crypto-js"],C):(I=typeof globalThis<"u"?globalThis:I||self,I["arm-js-library"]=C(I.axios,I._,I.mobx,I.uuid,I.CryptoJS))})(this,function(I,C,Y,z,Z){"use strict";function K(H){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(H){for(const e in H)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(H,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>H[e]})}}return s.default=H,Object.freeze(s)}const ss=K(Y),{makeObservable:es,observable:T,action:x,toJS:D}=ss,{get:i,set:n,find:O,findIndex:b,isObject:ts,isArray:m,isPlainObject:g,isNumber:S,isNull:is,isNil:$,isEmpty:B,isEqual:_,gte:j,lt:J,flatMap:rs,map:U,entries:as,forEach:f,keysIn:E,omit:w}=C,V={isLoading:!0,isError:!1,isNew:!0,data:[],included:[],meta:{}},G={isLoading:!0,isError:!1,isNew:!0,data:{},included:[],meta:{}},L=["destroyRecord","reload","save","set","get","setProperties","isDirty","isError","isLoading","isPristine"],os=["destroyRecord","reload","save","set","get","setProperties","isDirty","isError","isLoading","isPristine","hashId","collectionName"];class ns{constructor(s=[]){this.namespace="api/v1",this.host=window.location.origin,this.collections={},this.aliases={},this.requestHashIds={},this.payloadIncludedReference="type",this._initializeCollections(s),this._initializeAxiosConfig(),es(this,{collections:T,aliases:T,requestHashIds:T,_pushPayloadToCollection:x,_pushRequestHash:x,_addCollection:x,_addAlias:x})}_initializeAxiosConfig(){I.defaults.baseURL=this._getBaseURL()}_initializeCollections(s){f(s,e=>this._addCollection(e,[]))}_getBaseURL(){return`${this.host}/${this.namespace}`}_getAuthorizationToken(){return`Token ${window.localStorage.getItem("token")}`}_addCollection(s,e){this.collections[s]=e}_addAlias(s,e){const t=m(e),r=g(e);t&&(this.aliases[s]=e||[]),r&&(this.aliases[s]=e||{})}_generateHashId(s={id:z.v1()}){const e=JSON.stringify(s);return Z.MD5(e).toString()}_getProperty(s){return i(this,s)}_setProperty(s,e){n(this,s,e);const t=w(D(this.originalRecord),L),r=w(D(this),L);_(t,r)?(n(this,"isDirty",!1),n(this,"isPristine",!0)):(n(this,"isDirty",!0),n(this,"isPristine",!1))}_setProperties(s){function e(d,c=""){return rs(as(d),([l,o])=>{const h=c?`${c}.${l}`:l;return ts(o)&&!m(o)&&o!==null?e(o,h):{key:h,value:o}})}const t=e(s);f(t,({key:d,value:c})=>n(this,d,c));const r=w(D(this.originalRecord),L),a=w(D(this),L);_(r,a)?(n(this,"isDirty",!1),n(this,"isPristine",!0)):(n(this,"isDirty",!0),n(this,"isPristine",!1))}unloadRecord(s){const e=E(this.aliases),t=i(s,"collectionName"),r=b(this.collections[t],{hashId:i(s,"hashId")});j(r,0)&&this.collections[t].splice(r,1),f(e,a=>{const d=m(this.aliases[a]),c=g(this.aliases[a]);if(d){const l=b(this.aliases[a],{hashId:i(s,"hashId")});j(l,0)&&this.aliases[a].splice(l,1)}c&&_(i(s,"hashId"),i(this.aliases[a],"hashId"))&&(this.aliases[a]={})})}_saveRecord(s){const e=i(s,"collectionName"),t=O(this.collections[e],{hashId:i(s,"hashId")}),r=S(i(t,"id")),a=r?i(t,"id"):null,o={resourceMethod:r?"put":"post",resourceName:e,resourceId:a,resourceParams:{},resourcePayload:{data:t},resourceFallback:{},resourceConfig:{}};return this._request(o)}async _deleteRecord(s){const e=O(this.collections[s.collectionName],{hashId:i(s,"hashId")}),t=i(s,"id"),d={resourceMethod:"delete",resourceName:i(e,"collectionName"),resourceId:t,resourceParams:{},resourcePayload:null,resourceFallback:{},resourceConfig:{}};return this._request(d)}async _reloadRecord(s){const e=i(s,"id"),a={resourceMethod:"get",resourceName:i(s,"collectionName"),resourceId:e,resourceParams:{},resourcePayload:null,resourceFallback:{},resourceConfig:{skip:!0}};return this._request(a)}_injectActions(s){const e={get:this._getProperty,set:this._setProperty,setProperties:this._setProperties,save:()=>this._saveRecord(s),destroyRecord:()=>this._deleteRecord(s),reload:()=>this._reloadRecord(s)},t=E(e);f(t,r=>{s[r]=e[r]})}_injectReferenceKeys(s,e,t=null){const r=is(t)?this._generateHashId({id:i(e,"id"),collectionName:i(e,"collectionName")}):t;n(e,"collectionName",s),n(e,"hashId",r),n(e,"isLoading",!1),n(e,"isError",!1),n(e,"isPristine",!0),n(e,"isDirty",!1)}_pushPayloadToCollection(s,e){const t=m(e),r=g(e),a=E(this.aliases),d=E(this.requestHashIds);let c=null;if(t){const l=U(e,"hashId");f(e,o=>{const h=b(this.collections[s],{hashId:i(o,"hashId")});this._injectActions(o),J(h,0)&&this.collections[s].push(o),j(h,0)&&(this.collections[s][h]=o)}),c=U(l,o=>O(this.collections[s],{hashId:o})),f(a,o=>{const h=m(this.aliases[o]),q=g(this.aliases[o]);h&&f(c,p=>{const y=b(this.aliases[o],{hashId:i(p,"hashId")});j(y,0)&&(this.aliases[o][y]=p)}),q&&f(c,p=>{_(i(p,"hashId"),i(this.aliases[o],"hashId"))&&(this.aliases[o]=p)})})}if(r){const l=e.hashId,o=b(this.collections[s],{hashId:i(e,"hashId")});this._injectActions(e),J(o,0)&&this.collections[s].push(e),j(o,0)&&(this.collections[s][o]=e),c=O(this.collections[s],{hashId:l}),f(a,h=>{const q=m(this.aliases[h]),p=g(this.aliases[h]);q&&f([c],y=>{const P=b(this.aliases[h],{hashId:i(y,"hashId")});j(P,0)&&(this.aliases[h][P]=y)}),p&&_(i(c,"hashId"),i(this.aliases[h],"hashId"))&&(this.aliases[h]=c)}),f(d,h=>{const q=i(this.requestHashIds[h],"data"),p=m(q),y=g(q);p&&f([c],P=>{const M=b(i(this.requestHashIds[h],"data"),{hashId:i(P,"hashId")});j(M,0)&&(this.requestHashIds[h][M]=P)}),y&&_(i(c,"hashId"),i(this.requestHashIds[h],"data.hashId"))&&n(this.requestHashIds[h],"data",c)})}return c}_pushRequestHash(s={},e={isLoading:!0,isError:!1,isNew:!0,data:null}){const t=this._generateHashId(s),r=!$(this.requestHashIds[t]),a=i(e,"isNew");return r&&a?n(this.requestHashIds[t],"isNew",!1):this.requestHashIds[t]=e,this.requestHashIds[t]}setHost(s){this.host=s,this._initializeAxiosConfig()}setNamespace(s){this.namespace=s}setHeadersCommon(s,e){I.defaults.headers.common[`${s}`]=e}setPayloadIncludeReference(s){this.payloadIncludedReference=s}setGlobal(){window&&(window.ARM=Object.freeze(this))}getCollection(s){return this.collections[s]||[]}clearCollection(s){this.collections[s]=[]}getAlias(s,e){return g(e)&&this._injectActions(e),this.aliases[s]||e}createRecord(s,e={}){return n(e,"id",z.v1()),this._injectReferenceKeys(s,e),this._injectActions(e),this.collections[s].push(e),O(this.collections[s],{hashId:i(e,"hashId")})}async _request({resourceMethod:s,resourceName:e,resourceId:t,resourceParams:r,resourcePayload:a,resourceFallback:d,resourceConfig:c}){var Q,W,X;const l={method:s,url:e},o=this._generateHashId({...arguments[0]}),h=i(c,"skip")||!1,q=_(s,"get"),p=_(s,"delete"),y=_(s,"post"),P=S(t),M=!B(r),v=!B(a),N=i(a,"data")||null;if(P&&n(l,"url",`${e}/${t}`),M&&n(l,"params",r),v){const u={data:w(N,os)};n(l,"data",u)}if(q&&!h){const u=this.requestHashIds[o],R=!$(u),F=i(u,"isNew");if(R&&!F)return}v&&n(N,"isLoading",!0);try{const u=await I(l),R=((Q=u==null?void 0:u.data)==null?void 0:Q.data)||d,F=((W=u==null?void 0:u.data)==null?void 0:W.included)||[],cs=((X=u==null?void 0:u.data)==null?void 0:X.meta)||{},hs=g(R),ds=m(R);let k=null;return ds&&f(R,A=>this._injectReferenceKeys(e,A)),hs&&this._injectReferenceKeys(e,R),f(F,A=>{this._injectReferenceKeys(i(A,this.payloadIncludedReference),A),this._pushPayloadToCollection(i(A,"collectionName"),A)}),k=await this._pushPayloadToCollection(e,R),c.alias&&this._addAlias(i(c,"alias"),k),y&&this.unloadRecord(N),p&&this.unloadRecord(k),this.requestHashIds[o]={isLoading:!1,isError:!1,isNew:!1,data:k,included:[],meta:cs},Promise.resolve(k)}catch(u){return v&&(n(N,"isError",!0),n(N,"isLoading",!1)),this.requestHashIds[o]={isLoading:!1,isError:!0,isNew:!1,data:u,included:[],meta:{}},Promise.reject(u)}}query(s,e={},t={}){const r={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:e,resourcePayload:null,resourceFallback:[],resourceConfig:t},a=V,d=this._pushRequestHash(r,a);return this._request(r),d}queryRecord(s,e={},t={}){const r={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:e,resourcePayload:null,resourceFallback:{},resourceConfig:t},a=G,d=this._pushRequestHash(r,a);return this._request(r),d}findAll(s,e={}){const t={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:null,resourcePayload:null,resourceFallback:[],resourceConfig:e},r=V,a=this._pushRequestHash(t,r);return this._request(t),a}findRecord(s,e,t={},r={}){const a={resourceMethod:"get",resourceName:s,resourceId:e,resourceParams:t,resourcePayload:null,resourceFallback:{},resourceConfig:r},d=G,c=this._pushRequestHash(a,d);return this._request(a),c}peekAll(s){return this.collections[s]}peekRecord(s,e){return O(this.collections[s],{id:e})}}return ns}); +(function(I,C){typeof exports=="object"&&typeof module<"u"?module.exports=C(require("axios"),require("lodash"),require("mobx"),require("uuid"),require("crypto-js")):typeof define=="function"&&define.amd?define(["axios","lodash","mobx","uuid","crypto-js"],C):(I=typeof globalThis<"u"?globalThis:I||self,I["arm-js-library"]=C(I.axios,I._,I.mobx,I.uuid,I.CryptoJS))})(this,function(I,C,Y,z,Z){"use strict";function K(H){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(H){for(const e in H)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(H,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>H[e]})}}return s.default=H,Object.freeze(s)}const ss=K(Y),{makeObservable:es,observable:T,action:N,toJS:D}=ss,{get:i,set:n,find:O,findIndex:b,isObject:ts,isArray:g,isPlainObject:q,isNumber:S,isNull:is,isNil:$,isEmpty:B,isEqual:_,gte:j,lt:J,flatMap:rs,map:U,entries:as,forEach:f,keysIn:E,omit:w}=C,V={isLoading:!0,isError:!1,isNew:!0,data:[],included:[],meta:{}},G={isLoading:!0,isError:!1,isNew:!0,data:{},included:[],meta:{}},L=["destroyRecord","reload","save","set","get","setProperties","isDirty","isError","isLoading","isPristine"],os=["destroyRecord","reload","save","set","get","setProperties","isDirty","isError","isLoading","isPristine","hashId","collectionName"];class ns{constructor(s=[]){this.namespace="api/v1",this.host=window.location.origin,this.collections={},this.aliases={},this.requestHashIds={},this.payloadIncludedReference="type",this._initializeCollections(s),this._initializeAxiosConfig(),es(this,{collections:T,aliases:T,requestHashIds:T,_pushPayloadToCollection:N,_pushRequestHash:N,_addCollection:N,_addAlias:N})}_initializeAxiosConfig(){I.defaults.baseURL=this._getBaseURL()}_initializeCollections(s){f(s,e=>this._addCollection(e,[]))}_getBaseURL(){return`${this.host}/${this.namespace}`}_getAuthorizationToken(){return`Token ${window.localStorage.getItem("token")}`}_addCollection(s,e){this.collections[s]=e}_addAlias(s,e){const t=g(e),r=q(e);t&&(this.aliases[s]=e||[]),r&&(this.aliases[s]=e||{})}_generateHashId(s={id:z.v1()}){const e=JSON.stringify(s);return Z.MD5(e).toString()}_getProperty(s){return i(this,s)}_setProperty(s,e){n(this,s,e);const t=w(D(this.originalRecord),L),r=w(D(this),L);_(t,r)?(n(this,"isDirty",!1),n(this,"isPristine",!0)):(n(this,"isDirty",!0),n(this,"isPristine",!1))}_setProperties(s){function e(d,c=""){return rs(as(d),([l,o])=>{const h=c?`${c}.${l}`:l;return ts(o)&&!g(o)&&o!==null?e(o,h):{key:h,value:o}})}const t=e(s);f(t,({key:d,value:c})=>n(this,d,c));const r=w(D(this.originalRecord),L),a=w(D(this),L);_(r,a)?(n(this,"isDirty",!1),n(this,"isPristine",!0)):(n(this,"isDirty",!0),n(this,"isPristine",!1))}unloadRecord(s){const e=E(this.aliases),t=i(s,"collectionName"),r=b(this.collections[t],{hashId:i(s,"hashId")});j(r,0)&&this.collections[t].splice(r,1),f(e,a=>{const d=g(this.aliases[a]),c=q(this.aliases[a]);if(d){const l=b(this.aliases[a],{hashId:i(s,"hashId")});j(l,0)&&this.aliases[a].splice(l,1)}c&&_(i(s,"hashId"),i(this.aliases[a],"hashId"))&&(this.aliases[a]={})})}_saveRecord(s){const e=i(s,"collectionName"),t=O(this.collections[e],{hashId:i(s,"hashId")}),r=S(i(t,"id")),a=r?i(t,"id"):null,o={resourceMethod:r?"put":"post",resourceName:e,resourceId:a,resourceParams:{},resourcePayload:{data:t},resourceFallback:{},resourceConfig:{}};return this._request(o)}async _deleteRecord(s){const e=O(this.collections[s.collectionName],{hashId:i(s,"hashId")}),t=i(s,"id"),d={resourceMethod:"delete",resourceName:i(e,"collectionName"),resourceId:t,resourceParams:{},resourcePayload:null,resourceFallback:{},resourceConfig:{}};return this._request(d)}async _reloadRecord(s){const e=i(s,"id"),a={resourceMethod:"get",resourceName:i(s,"collectionName"),resourceId:e,resourceParams:{},resourcePayload:null,resourceFallback:{},resourceConfig:{skip:!0}};return this._request(a)}_injectActions(s){const e={get:this._getProperty,set:this._setProperty,setProperties:this._setProperties,save:()=>this._saveRecord(s),destroyRecord:()=>this._deleteRecord(s),reload:()=>this._reloadRecord(s)},t=E(e);f(t,r=>{s[r]=e[r]})}_injectReferenceKeys(s,e,t=null){const r=is(t)?this._generateHashId({id:i(e,"id"),collectionName:s}):t;n(e,"collectionName",s),n(e,"hashId",r),n(e,"isLoading",!1),n(e,"isError",!1),n(e,"isPristine",!0),n(e,"isDirty",!1)}_pushPayloadToCollection(s,e){const t=g(e),r=q(e),a=E(this.aliases),d=E(this.requestHashIds);let c=null;if(t){const l=U(e,"hashId");f(e,o=>{const h=b(this.collections[s],{hashId:i(o,"hashId")});this._injectActions(o),J(h,0)&&this.collections[s].push(o),j(h,0)&&(this.collections[s][h]=o)}),c=U(l,o=>O(this.collections[s],{hashId:o})),f(a,o=>{const h=g(this.aliases[o]),m=q(this.aliases[o]);h&&f(c,p=>{const y=b(this.aliases[o],{hashId:i(p,"hashId")});j(y,0)&&(this.aliases[o][y]=p)}),m&&f(c,p=>{_(i(p,"hashId"),i(this.aliases[o],"hashId"))&&(this.aliases[o]=p)})})}if(r){const l=e.hashId,o=b(this.collections[s],{hashId:i(e,"hashId")});this._injectActions(e),J(o,0)&&this.collections[s].push(e),j(o,0)&&(this.collections[s][o]=e),c=O(this.collections[s],{hashId:l}),f(a,h=>{const m=g(this.aliases[h]),p=q(this.aliases[h]);m&&f([c],y=>{const P=b(this.aliases[h],{hashId:i(y,"hashId")});j(P,0)&&(this.aliases[h][P]=y)}),p&&_(i(c,"hashId"),i(this.aliases[h],"hashId"))&&(this.aliases[h]=c)}),f(d,h=>{const m=i(this.requestHashIds[h],"data"),p=g(m),y=q(m);p&&f([c],P=>{const M=b(i(this.requestHashIds[h],"data"),{hashId:i(P,"hashId")});j(M,0)&&(this.requestHashIds[h][M]=P)}),y&&_(i(c,"hashId"),i(this.requestHashIds[h],"data.hashId"))&&n(this.requestHashIds[h],"data",c)})}return c}_pushRequestHash(s={},e={isLoading:!0,isError:!1,isNew:!0,data:null}){const t=this._generateHashId(s),r=!$(this.requestHashIds[t]),a=i(e,"isNew");return r&&a?n(this.requestHashIds[t],"isNew",!1):this.requestHashIds[t]=e,this.requestHashIds[t]}setHost(s){this.host=s,this._initializeAxiosConfig()}setNamespace(s){this.namespace=s}setHeadersCommon(s,e){I.defaults.headers.common[`${s}`]=e}setPayloadIncludeReference(s){this.payloadIncludedReference=s}setGlobal(){window&&(window.ARM=Object.freeze(this))}getCollection(s){return this.collections[s]||[]}clearCollection(s){this.collections[s]=[]}getAlias(s,e){return q(e)&&this._injectActions(e),this.aliases[s]||e}createRecord(s,e={}){return n(e,"id",z.v1()),this._injectReferenceKeys(s,e),this._injectActions(e),this.collections[s].push(e),O(this.collections[s],{hashId:i(e,"hashId")})}async _request({resourceMethod:s,resourceName:e,resourceId:t,resourceParams:r,resourcePayload:a,resourceFallback:d,resourceConfig:c}){var Q,W,X;const l={method:s,url:e},o=this._generateHashId({...arguments[0]}),h=i(c,"skip")||!1,m=_(s,"get"),p=_(s,"delete"),y=_(s,"post"),P=S(t),M=!B(r),v=!B(a),k=i(a,"data")||null;if(P&&n(l,"url",`${e}/${t}`),M&&n(l,"params",r),v){const u={data:w(k,os)};n(l,"data",u)}if(m&&!h){const u=this.requestHashIds[o],R=!$(u),F=i(u,"isNew");if(R&&!F)return}v&&n(k,"isLoading",!0);try{const u=await I(l),R=((Q=u==null?void 0:u.data)==null?void 0:Q.data)||d,F=((W=u==null?void 0:u.data)==null?void 0:W.included)||[],cs=((X=u==null?void 0:u.data)==null?void 0:X.meta)||{},hs=q(R),ds=g(R);let x=null;return ds&&f(R,A=>this._injectReferenceKeys(e,A)),hs&&this._injectReferenceKeys(e,R),f(F,A=>{this._injectReferenceKeys(i(A,this.payloadIncludedReference),A),this._pushPayloadToCollection(i(A,"collectionName"),A)}),x=await this._pushPayloadToCollection(e,R),c.alias&&this._addAlias(i(c,"alias"),x),y&&this.unloadRecord(k),p&&this.unloadRecord(x),this.requestHashIds[o]={isLoading:!1,isError:!1,isNew:!1,data:x,included:[],meta:cs},Promise.resolve(x)}catch(u){return v&&(n(k,"isError",!0),n(k,"isLoading",!1)),this.requestHashIds[o]={isLoading:!1,isError:!0,isNew:!1,data:u,included:[],meta:{}},Promise.reject(u)}}query(s,e={},t={}){const r={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:e,resourcePayload:null,resourceFallback:[],resourceConfig:t},a=V,d=this._pushRequestHash(r,a);return this._request(r),d}queryRecord(s,e={},t={}){const r={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:e,resourcePayload:null,resourceFallback:{},resourceConfig:t},a=G,d=this._pushRequestHash(r,a);return this._request(r),d}findAll(s,e={}){const t={resourceMethod:"get",resourceName:s,resourceId:null,resourceParams:null,resourcePayload:null,resourceFallback:[],resourceConfig:e},r=V,a=this._pushRequestHash(t,r);return this._request(t),a}findRecord(s,e,t={},r={}){const a={resourceMethod:"get",resourceName:s,resourceId:e,resourceParams:t,resourcePayload:null,resourceFallback:{},resourceConfig:r},d=G,c=this._pushRequestHash(a,d);return this._request(a),c}peekAll(s){return this.collections[s]}peekRecord(s,e){return O(this.collections[s],{id:e})}}return ns}); diff --git a/packages/src/lib/api-resource-manager.js b/packages/src/lib/api-resource-manager.js index db54cdf..ff01aee 100644 --- a/packages/src/lib/api-resource-manager.js +++ b/packages/src/lib/api-resource-manager.js @@ -314,7 +314,7 @@ export default class ApiResourceManager { const recordHashId = isNull(collectionRecordHashId) ? this._generateHashId({ id: getProperty(collectionRecord, 'id'), - collectionName: getProperty(collectionRecord, 'collectionName'), + collectionName: collectionName, }) : collectionRecordHashId