fmode-ng 0.0.95 → 0.0.96

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.
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/parse/fmode.object.mjs
7
7
  */
8
- export class FmodeObject{static{this._instance=null}static bindInstance(t){this._instance=t}constructor(t){this.data={},this.className=t}static extend(t){return class extends FmodeObject{constructor(){super(t)}}}toPointer(){return{__type:"Pointer",className:this.className,objectId:this.id}}toJSON(){return{__type:"Object",className:this.className,objectId:this.id,...this.data,createdAt:this.createdAt,updatedAt:this.updatedAt,ACL:this.ACL}}get(t){return this.data[t]}set(t,e){return"object"==typeof t?Object.assign(this.data,t):this.data[t]=e,this}unset(t){return delete this.data[t],this}increment(t,e=1){const s=this.get(t)||0;return this.set(t,s+e),this}add(t,e){const s=this.get(t)||[];return this.set(t,[...s,...e]),this}addUnique(t,e){const s=new Set(this.get(t)||new Set);return e.forEach((t=>s.add(t))),this.set(t,Array.from(s)),this}remove(t,e){const s=this.get(t)||[],a=new Set(e);return this.set(t,s.filter((t=>!a.has(t)))),this}async save(t){if(!FmodeObject._instance)throw new Error("Not initialized");const e=this.id?"PUT":"POST";let s=`${FmodeObject._instance.serverURL}/classes/${this.className}`;this.id&&(s+=`/${this.id}`);const a={"Content-Type":"application/json","X-Parse-Application-Id":FmodeObject._instance.appId};t?.useMasterKey&&FmodeObject._instance.config.masterKey&&(a["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);const r=await fetch(s,{method:e,headers:a,body:JSON.stringify(this.data)}),i=await r.json();if(i.error)throw new Error(i.error);return this.id=i.objectId,this.createdAt=new Date(i.createdAt),this.updatedAt=new Date(i.updatedAt||i.createdAt),this}async destroy(t){if(!this.id)throw new Error("Cannot destroy unsaved object");if(!FmodeObject._instance)throw new Error("Not initialized");const e={"X-Parse-Application-Id":FmodeObject._instance.appId};t?.useMasterKey&&FmodeObject._instance.config.masterKey&&(e["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);const s=`${FmodeObject._instance.serverURL}/classes/${this.className}/${this.id}`,a=await fetch(s,{method:"DELETE",headers:e});if(!a.ok){const t=await a.json();throw new Error(t.error||"Failed to delete object")}}static async create(t,e,s){const a=new this(t);return a.set(e),a.save(s)}static async fetchAll(t,e){if(!FmodeObject._instance)throw new Error("Not initialized");if(0===t.length)return[];const s={"Content-Type":"application/json","X-Parse-Application-Id":FmodeObject._instance.appId};e?.useMasterKey&&FmodeObject._instance.config.masterKey&&(s["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);const a=`${FmodeObject._instance.serverURL}/batch`,r=t.map((t=>({method:"GET",path:`/classes/${t.className}/${t.id}`}))),i=await fetch(a,{method:"POST",headers:s,body:JSON.stringify({requests:r})}),n=await i.json();if(n.error)throw new Error(n.error);return n.map(((e,s)=>{const a=t[s];return a.set(e.success),a}))}relation(t){return{__type:"Relation",className:this.className}}static async fromFile(t,e,s){if(!FmodeObject._instance)throw new Error("Not initialized");const a=new FormData;a.append("file",e,t);const r={"X-Parse-Application-Id":FmodeObject._instance.appId},i=`${FmodeObject._instance.serverURL}/files/${t}`,n=await fetch(i,{method:"POST",headers:r,body:a}),c=await n.json();if(c.error)throw new Error(c.error);return{__type:"File",name:c.name,url:c.url}}}
8
+ export class FmodeObject{static{this._instance=null}static bindInstance(t){this._instance=t}constructor(t){this.data={},this.className=t}static extend(t){return class extends FmodeObject{constructor(){super(t)}}}toPointer(){return{__type:"Pointer",className:this.className,objectId:this.id}}toJSON(){return{__type:"Object",className:this.className,objectId:this.id,...this.data,createdAt:this.createdAt,updatedAt:this.updatedAt,ACL:this.ACL}}get(t){return this.data[t]}set(t,e){return"object"==typeof t?Object.assign(this.data,t):this.data[t]=e,this}unset(t){return delete this.data[t],this}increment(t,e=1){const s=this.get(t)||0;return this.set(t,s+e),this}add(t,e){const s=this.get(t)||[];return this.set(t,[...s,...e]),this}addUnique(t,e){const s=new Set(this.get(t)||new Set);return e.forEach((t=>s.add(t))),this.set(t,Array.from(s)),this}remove(t,e){const s=this.get(t)||[],a=new Set(e);return this.set(t,s.filter((t=>!a.has(t)))),this}async save(t){if(!FmodeObject._instance)throw new Error("Not initialized");const e=this.id?"PUT":"POST";let s=`${FmodeObject._instance.serverURL}/classes/${this.className}`;this.id&&(s+=`/${this.id}`);const a={"Content-Type":"application/json","X-Parse-Application-Id":FmodeObject._instance.appId};t?.useMasterKey&&FmodeObject._instance.config.masterKey&&(a["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);let r=this.data;delete r.createdAt,delete r.updatedAt;const i=await fetch(s,{method:e,headers:a,body:JSON.stringify(r)}),n=await i.json();if(n.error)throw new Error(n.error);return console.log(n,"result"),this.id=n.objectId||this.id,this.createdAt=new Date(n.createdAt||this.createdAt),this.updatedAt=new Date(n.updatedAt||n.updatedAt||n.createdAt),this}async destroy(t){if(!this.id)throw new Error("Cannot destroy unsaved object");if(!FmodeObject._instance)throw new Error("Not initialized");const e={"X-Parse-Application-Id":FmodeObject._instance.appId};t?.useMasterKey&&FmodeObject._instance.config.masterKey&&(e["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);const s=`${FmodeObject._instance.serverURL}/classes/${this.className}/${this.id}`,a=await fetch(s,{method:"DELETE",headers:e});if(!a.ok){const t=await a.json();throw new Error(t.error||"Failed to delete object")}}static async create(t,e,s){const a=new this(t);return a.set(e),a.save(s)}static async fetchAll(t,e){if(!FmodeObject._instance)throw new Error("Not initialized");if(0===t.length)return[];const s={"Content-Type":"application/json","X-Parse-Application-Id":FmodeObject._instance.appId};e?.useMasterKey&&FmodeObject._instance.config.masterKey&&(s["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey);const a=`${FmodeObject._instance.serverURL}/batch`,r=t.map((t=>({method:"GET",path:`/classes/${t.className}/${t.id}`}))),i=await fetch(a,{method:"POST",headers:s,body:JSON.stringify({requests:r})}),n=await i.json();if(n.error)throw new Error(n.error);return n.map(((e,s)=>{const a=t[s];return a.set(e.success),a}))}relation(t){return{__type:"Relation",className:this.className}}static async fromFile(t,e,s){if(!FmodeObject._instance)throw new Error("Not initialized");const a=new FormData;a.append("file",e,t);const r={"X-Parse-Application-Id":FmodeObject._instance.appId},i=`${FmodeObject._instance.serverURL}/files/${t}`,n=await fetch(i,{method:"POST",headers:r,body:a}),c=await n.json();if(c.error)throw new Error(c.error);return{__type:"File",name:c.name,url:c.url}}}
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLm9iamVjdC5tanM=`
10
10