fmode-ng 0.0.236 → 0.0.237

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.cloud.mjs
7
7
  */
8
- export class FmodeCloud{static{this._singletonInstance=null}constructor(){this._cloudFunctions=new Map}static getInstance(){return this._singletonInstance||(this._singletonInstance=new FmodeCloud),this._singletonInstance}static{this._instance=null}static bindInstance(e){this._instance=e}get currentConfig(){const e=FmodeCloud._instance;if(!e)throw new Error("FmodeCloud not initialized. Call FmodeParse.initialize() first.");return e.config}static get instance(){return this._instance}define(e,t){this._cloudFunctions.set(e,t)}async run(e,t={},n={}){const s=this.currentConfig,o=`${s.serverURL}/functions/${e}`,i={...t,_ApplicationId:s.appId,_InstallationId:n.installationId||this.generateInstallationId()},r=s.sessionToken;r&&(i._SessionToken=r);try{console.log(o);const e=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":s.appId,...s.javascriptKey&&{"X-Parse-JavaScript-Key":s.javascriptKey},...s.masterKey&&{"X-Parse-Master-Key":s.masterKey},...r&&{"X-Parse-Session-Token":r}},body:JSON.stringify(i)});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=await e.json();if(t.error)throw new Error(t.error.message||"Cloud function error");return t.result}catch(t){throw console.error(`Cloud function ${e} failed:`,t),t}}async afterDelete(e,t){this.define(`afterDelete_${e}`,t)}async afterSave(e,t){this.define(`afterSave_${e}`,t)}async beforeDelete(e,t){this.define(`beforeDelete_${e}`,t)}async beforeSave(e,t){this.define(`beforeSave_${e}`,t)}async beforeFind(e,t){this.define(`beforeFind_${e}`,t)}async afterFind(e,t){this.define(`afterFind_${e}`,t)}async job(e,t){this.define(`job_${e}`,t)}generateInstallationId(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}export const Cloud=FmodeCloud.getInstance();export default Cloud;
8
+ export class FmodeCloud{static{this._singletonInstance=null}constructor(){this._cloudFunctions=new Map}static getInstance(){return this._singletonInstance||(this._singletonInstance=new FmodeCloud),this._singletonInstance}static{this._instance=null}static bindInstance(e){this._instance=e}get currentConfig(){const e=FmodeCloud._instance;if(!e)throw new Error("FmodeCloud not initialized. Call FmodeParse.initialize() first.");return e.config}static get instance(){return this._instance}define(e,t){this._cloudFunctions.set(e,t)}async run(e,t={},n={}){const o=this.currentConfig,s=`${o.serverURL}/functions/${e}`,r={...t,_ApplicationId:o.appId,_InstallationId:n.installationId||this.generateInstallationId()},a=o.sessionToken;a&&(r._SessionToken=a);try{console.log(s);const e=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":o.appId,...o.javascriptKey&&{"X-Parse-JavaScript-Key":o.javascriptKey},...o.masterKey&&{"X-Parse-Master-Key":o.masterKey},...a&&{"X-Parse-Session-Token":a}},body:JSON.stringify(r)});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=await e.json();if(t.error)throw new Error(t.error.message||"Cloud function error");return t.result}catch(t){throw console.error(`Cloud function ${e} failed:`,t),t}}async function(e={},t={}){const n=this.currentConfig,o=`${n.serverURL}/../api/functions`,s={...e,_ApplicationId:n.appId,_InstallationId:t.installationId||this.generateInstallationId()},r=n.sessionToken;r&&(s._SessionToken=r);try{console.log(o);const e=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":n.appId,...n.javascriptKey&&{"X-Parse-JavaScript-Key":n.javascriptKey},...n.masterKey&&{"X-Parse-Master-Key":n.masterKey},...r&&{"X-Parse-Session-Token":r}},body:JSON.stringify(s)});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=await e.json();if(t.error)throw new Error(t.error.message||"Cloud function error");return t}catch(e){throw console.error("Cloud function failed:",e),e}}async afterDelete(e,t){this.define(`afterDelete_${e}`,t)}async afterSave(e,t){this.define(`afterSave_${e}`,t)}async beforeDelete(e,t){this.define(`beforeDelete_${e}`,t)}async beforeSave(e,t){this.define(`beforeSave_${e}`,t)}async beforeFind(e,t){this.define(`beforeFind_${e}`,t)}async afterFind(e,t){this.define(`afterFind_${e}`,t)}async job(e,t){this.define(`job_${e}`,t)}generateInstallationId(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}export const Cloud=FmodeCloud.getInstance();export default Cloud;
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLmNsb3VkLm1qcw==`
10
10
 
@@ -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.parse.mjs
7
7
  */
8
- import{FmodeACL}from"./datatype/acl";import{FmodeFile}from"./datatype/file";import{FmodeGeoPoint}from"./datatype/geopoint";import{FmodeRelation}from"./datatype/relation";import{FmodeObject}from"./fmode.object";import{FmodeQuery}from"./fmode.query";import{FmodeUser}from"./fmode.user";import{FmodeCloud}from"./fmode.cloud";class FmodeParse{static{this._instances={}}static{this._defaultInstance=null}constructor(e){this.config=e,this.Object=this.createObjectFactory(),this.Query=this.createQueryFactory(),this.User=this.createUserFactory(),this.GeoPoint=FmodeGeoPoint,this.File=FmodeFile,this.ACL=FmodeACL,this.Relation=FmodeRelation,this.Cloud=this.createCloudFactory(),FmodeObject._instance||FmodeObject.bindInstance(this),FmodeQuery._instance||FmodeQuery.bindInstance(this),FmodeUser._instance||FmodeUser.bindInstance(this),FmodeGeoPoint._instance||FmodeGeoPoint.bindInstance(this),FmodeRelation._instance||FmodeRelation.bindInstance(this),FmodeFile._instance||FmodeFile.bindInstance(this),FmodeACL._instance||FmodeACL.bindInstance(this)}createObjectFactory(){const e=this;return class Object extends FmodeObject{constructor(t){super(t),this._parseInstance=e}static extend(e){const t=class extends Object{constructor(){super(e)}};return t.extend=Object.extend,t.create=Object.create,t.fetchAll=Object.fetchAll,t.fromFile=Object.fromFile,t}static async create(e,t,s){const n=new this(e);return n.set(t),n.save(s)}static async fetchAll(t,s){if(!e)throw new Error("Not initialized");if(0===t.length)return[];const n={"Content-Type":"application/json","X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)n["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(n["X-Parse-Session-Token"]=t)}const r=`${e.serverURL}/batch`,o=t.map((e=>({method:"GET",path:`/classes/${e.className}/${e.id}`}))),i=await fetch(r,{method:"POST",headers:n,body:JSON.stringify({requests:o})}),a=await i.json();if(a.error)throw new Error(a.error);return a.map(((e,s)=>{const n=t[s];return n.set(e.success),n}))}static async fromFile(t,s,n){if(!e)throw new Error("Not initialized");const r=new FormData;r.append("file",s,t);const o={"X-Parse-Application-Id":e.appId},i=e.sessionToken;i&&(o["X-Parse-Session-Token"]=i);const a=`${e.serverURL}/files/${t}`,c=await fetch(a,{method:"POST",headers:o,body:r}),d=await c.json();if(d.error)throw new Error(d.error);return{__type:"File",name:d.name,url:d.url}}}}createQueryFactory(){const e=this;return class Query extends FmodeQuery{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static bindInstance(e){}}}createUserFactory(){const e=this;return class User extends FmodeUser{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static{this.instanceKey=()=>"Parse/"+e.appId+"/currentUser"}static bindInstance(e){}static async logIn(t,s){const n=`${e.serverURL}/login`,r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({username:t,password:s})}),o=await r.json();if(o.error)throw o;const i=new this({...o,username:t,password:s});return i._saveToCache(),i}static async become(t){const s=`${e.serverURL}/users/me`;let n={"X-Parse-Session-Token":t,"X-Parse-Application-Id":e.appId};const r=await fetch(s,{headers:n}),o=await r.json();if(o.error)throw o.error;const i=new this({...o,sessionToken:t});return i._saveToCache(),i}static async signUp(e,t,s={}){return new this({...s,username:e,password:t}).signUp()}static async logOut(){if(this.current())try{await fetch(`${e.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":e.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(t){const s=`${e.serverURL}/requestPasswordReset`,n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({email:t})}),r=await n.json();if(r.error)throw r}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const t=localStorage.getItem(this.instanceKey());if(!t)return null;const s=JSON.parse(t);if(!s.sessionToken)return null;const n=new this(s);return this._currentUser=n,n.sessionToken&&e&&(e.sessionToken=n.sessionToken),n}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,e&&(e.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}_saveToCache(){if(!this.sessionToken)return;this.constructor._currentUser=this;const e=this._parseInstance||this.constructor.instance;e&&(e.sessionToken=this.sessionToken),localStorage.setItem(this.constructor.instanceKey(),JSON.stringify(this.toJSONForCache()))}}}createCloudFactory(){const e=this;return new class Cloud extends FmodeCloud{constructor(){super(),this._parseInstance=e}get currentConfig(){return e.config}static get instance(){return e}static bindInstance(e){}}}static initialize(e){let t;if("string"==typeof e){let s="http://dev.fmode.cn:1337/parse";"undefined"!=typeof location&&"https:"===location.protocol&&(s="https://dev.fmode.cn/parse"),t=new FmodeParse({appId:e,serverURL:s}),this._defaultInstance=t,this._instances.default=t}else t=new FmodeParse(e),e.config&&(this._instances[e.config]=t),e.config&&"default"!==e.config||(this._defaultInstance=t);return t}static with(e){if(!this._instances.nova){let e=new FmodeParse({appId:"ncloudmaster",serverURL:"https://server.fmode.cn/parse"});this._instances.nova=e}if(!this._instances.dev){let e=new FmodeParse({appId:"dev",serverURL:"https://dev.fmode.cn/parse"});this._instances.dev=e}"dev"!=e||this._defaultInstance||(this._defaultInstance=this._instances.dev),"default"!=e||this._instances.default||(this._instances.default=this._instances.dev,this._defaultInstance=this._instances.dev);const t=this._instances[e]||this._defaultInstance;return FmodeObject.bindInstance(t),FmodeQuery.bindInstance(t),FmodeUser.bindInstance(t),FmodeFile.bindInstance(t),FmodeACL.bindInstance(t),FmodeGeoPoint.bindInstance(t),FmodeRelation.bindInstance(t),t}static getAllInstances(){return{...this._instances}}static getInstanceConfigs(){const e={};return Object.entries(this._instances).forEach((([t,s])=>{e[t]=s.config})),e}get serverURL(){return this.config.serverURL}set serverURL(e){this.config.serverURL=e}get appId(){return this.config.appId}get sessionToken(){if(this.config.sessionToken)return this.config.sessionToken;const e=this.User.current();return e?.sessionToken}set sessionToken(e){this.config.sessionToken=e}}!function(e){e.Object=FmodeObject,e.Query=FmodeQuery,e.User=FmodeUser,e.File=FmodeFile,e.Relation=FmodeRelation,e.ACL=FmodeACL,e.GeoPoint=FmodeGeoPoint,e.Cloud=FmodeCloud.getInstance()}(FmodeParse||(FmodeParse={}));const defaultExport=new Proxy(FmodeParse,{apply:(e,t,s)=>FmodeParse.initialize.apply(e,s),get:(e,t)=>t in e?e[t]:t in FmodeParse?FmodeParse[t]:FmodeParse.with("default")[t]});export{FmodeParse as default,defaultExport as FmodeParse};
8
+ import{FmodeACL}from"./datatype/acl";import{FmodeFile}from"./datatype/file";import{FmodeGeoPoint}from"./datatype/geopoint";import{FmodeRelation}from"./datatype/relation";import{FmodeObject}from"./fmode.object";import{FmodeQuery}from"./fmode.query";import{FmodeUser}from"./fmode.user";import{FmodeCloud}from"./fmode.cloud";import{FmodeSchema}from"./fmode.schema";class FmodeParse{static{this._instances={}}static{this._defaultInstance=null}constructor(e){this.config=e,this.Object=this.createObjectFactory(),this.Query=this.createQueryFactory(),this.User=this.createUserFactory(),this.GeoPoint=FmodeGeoPoint,this.File=FmodeFile,this.ACL=FmodeACL,this.Relation=FmodeRelation,this.Cloud=this.createCloudFactory(),this.Schema=this.createSchemaFactory(),FmodeObject._instance||FmodeObject.bindInstance(this),FmodeQuery._instance||FmodeQuery.bindInstance(this),FmodeUser._instance||FmodeUser.bindInstance(this),FmodeGeoPoint._instance||FmodeGeoPoint.bindInstance(this),FmodeRelation._instance||FmodeRelation.bindInstance(this),FmodeFile._instance||FmodeFile.bindInstance(this),FmodeACL._instance||FmodeACL.bindInstance(this),FmodeSchema._instance||FmodeSchema.bindInstance(this)}createObjectFactory(){const e=this;return class Object extends FmodeObject{constructor(t){super(t),this._parseInstance=e}static extend(e){const t=class extends Object{constructor(){super(e)}};return t.extend=Object.extend,t.create=Object.create,t.fetchAll=Object.fetchAll,t.fromFile=Object.fromFile,t}static async create(e,t,s){const n=new this(e);return n.set(t),n.save(s)}static async fetchAll(t,s){if(!e)throw new Error("Not initialized");if(0===t.length)return[];const n={"Content-Type":"application/json","X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)n["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(n["X-Parse-Session-Token"]=t)}const r=`${e.serverURL}/batch`,o=t.map((e=>({method:"GET",path:`/classes/${e.className}/${e.id}`}))),i=await fetch(r,{method:"POST",headers:n,body:JSON.stringify({requests:o})}),a=await i.json();if(a.error)throw new Error(a.error);return a.map(((e,s)=>{const n=t[s];return n.set(e.success),n}))}static async fromFile(t,s,n){if(!e)throw new Error("Not initialized");const r=new FormData;r.append("file",s,t);const o={"X-Parse-Application-Id":e.appId},i=e.sessionToken;i&&(o["X-Parse-Session-Token"]=i);const a=`${e.serverURL}/files/${t}`,c=await fetch(a,{method:"POST",headers:o,body:r}),d=await c.json();if(d.error)throw new Error(d.error);return{__type:"File",name:d.name,url:d.url}}}}createQueryFactory(){const e=this;return class Query extends FmodeQuery{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static bindInstance(e){}}}createUserFactory(){const e=this;return class User extends FmodeUser{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static{this.instanceKey=()=>"Parse/"+e.appId+"/currentUser"}static bindInstance(e){}static async logIn(t,s){const n=`${e.serverURL}/login`,r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({username:t,password:s})}),o=await r.json();if(o.error)throw o;const i=new this({...o,username:t,password:s});return i._saveToCache(),i}static async become(t){const s=`${e.serverURL}/users/me`;let n={"X-Parse-Session-Token":t,"X-Parse-Application-Id":e.appId};const r=await fetch(s,{headers:n}),o=await r.json();if(o.error)throw o.error;const i=new this({...o,sessionToken:t});return i._saveToCache(),i}static async signUp(e,t,s={}){return new this({...s,username:e,password:t}).signUp()}static async logOut(){if(this.current())try{await fetch(`${e.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":e.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(t){const s=`${e.serverURL}/requestPasswordReset`,n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({email:t})}),r=await n.json();if(r.error)throw r}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const t=localStorage.getItem(this.instanceKey());if(!t)return null;const s=JSON.parse(t);if(!s.sessionToken)return null;const n=new this(s);return this._currentUser=n,n.sessionToken&&e&&(e.sessionToken=n.sessionToken),n}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,e&&(e.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}_saveToCache(){if(!this.sessionToken)return;this.constructor._currentUser=this;const e=this._parseInstance||this.constructor.instance;e&&(e.sessionToken=this.sessionToken),localStorage.setItem(this.constructor.instanceKey(),JSON.stringify(this.toJSONForCache()))}}}createCloudFactory(){const e=this;return new class Cloud extends FmodeCloud{constructor(){super(),this._parseInstance=e}get currentConfig(){return e.config}static get instance(){return e}static bindInstance(e){}}}createSchemaFactory(){const e=this;return class Schema extends FmodeSchema{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static bindInstance(e){}static async get(t,s){if(!e)throw new Error("Not initialized");const n=`${e.serverURL}/schemas/${t}`,r={"X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)r["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(r["X-Parse-Session-Token"]=t)}const o=await fetch(n,{method:"GET",headers:r}),i=await o.json();if(i.error)throw new Error(i.error);const a=new this(t);return i.fields&&(a._fields=i.fields),i.indexes&&(a._indexes=i.indexes),i.classLevelPermissions&&(a._clp=i.classLevelPermissions),a}static async all(t){if(!e)throw new Error("Not initialized");const s=`${e.serverURL}/schemas`,n={"X-Parse-Application-Id":e.appId};if(t?.useMasterKey&&e.config.masterKey)n["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(n["X-Parse-Session-Token"]=t)}const r=await fetch(s,{method:"GET",headers:n}),o=await r.json();if(o.error)throw new Error(o.error);console.log(o);return(o.results||o).map((e=>{const t=new this(e.className);return e.fields&&(t._fields=e.fields),e.indexes&&(t._indexes=e.indexes),e.classLevelPermissions&&(t._clp=e.classLevelPermissions),t}))}static async purge(t,s){if(!e)throw new Error("Not initialized");const n=`${e.serverURL}/purge/${t}`,r={"X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)r["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(r["X-Parse-Session-Token"]=t)}const o=await fetch(n,{method:"DELETE",headers:r});if(!o.ok){const e=await o.json();throw new Error(e.error||"Failed to purge schema")}}}}static initialize(e){let t;if("string"==typeof e){let s="http://dev.fmode.cn:1337/parse";"undefined"!=typeof location&&"https:"===location.protocol&&(s="https://dev.fmode.cn/parse"),t=new FmodeParse({appId:e,serverURL:s}),this._defaultInstance=t,this._instances.default=t}else t=new FmodeParse(e),e.config&&(this._instances[e.config]=t),e.config&&"default"!==e.config||(this._defaultInstance=t);return t}static with(e){if(!this._instances.nova){let e=new FmodeParse({appId:"ncloudmaster",serverURL:"https://server.fmode.cn/parse"});this._instances.nova=e}if(!this._instances.dev){let e=new FmodeParse({appId:"dev",serverURL:"https://dev.fmode.cn/parse"});this._instances.dev=e}"dev"!=e||this._defaultInstance||(this._defaultInstance=this._instances.dev),"default"!=e||this._instances.default||(this._instances.default=this._instances.dev,this._defaultInstance=this._instances.dev);const t=this._instances[e]||this._defaultInstance;return FmodeObject.bindInstance(t),FmodeQuery.bindInstance(t),FmodeUser.bindInstance(t),FmodeFile.bindInstance(t),FmodeACL.bindInstance(t),FmodeGeoPoint.bindInstance(t),FmodeRelation.bindInstance(t),FmodeSchema.bindInstance(t),t}static getAllInstances(){return{...this._instances}}static getInstanceConfigs(){const e={};return Object.entries(this._instances).forEach((([t,s])=>{e[t]=s.config})),e}get serverURL(){return this.config.serverURL}set serverURL(e){this.config.serverURL=e}get appId(){return this.config.appId}get sessionToken(){if(this.config.sessionToken)return this.config.sessionToken;const e=this.User.current();return e?.sessionToken}set sessionToken(e){this.config.sessionToken=e}}!function(e){e.Object=FmodeObject,e.Query=FmodeQuery,e.User=FmodeUser,e.File=FmodeFile,e.Relation=FmodeRelation,e.ACL=FmodeACL,e.GeoPoint=FmodeGeoPoint,e.Schema=FmodeSchema,e.Cloud=FmodeCloud.getInstance()}(FmodeParse||(FmodeParse={}));const defaultExport=new Proxy(FmodeParse,{apply:(e,t,s)=>FmodeParse.initialize.apply(e,s),get:(e,t)=>t in e?e[t]:t in FmodeParse?FmodeParse[t]:FmodeParse.with("default")[t]});export{FmodeParse as default,defaultExport as FmodeParse};
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnBhcnNlLm1qcw==`
10
10
 
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/parse/fmode.schema.mjs
7
+ */
8
+ export class FmodeSchema{static{this._instance=null}static bindInstance(e){this._instance=e}constructor(e){this._fields={},this._indexes={},this._clp={},this.className=e,this._parseInstance=FmodeSchema._instance}addField(e,s="String",t={}){return this._fields[e]={type:s,...t},this}addString(e,s={}){return this.addField(e,"String",s)}addNumber(e,s={}){return this.addField(e,"Number",s)}addBoolean(e,s={}){return this.addField(e,"Boolean",s)}addDate(e,s={}){return this.addField(e,"Date",s)}addFile(e,s={}){return this.addField(e,"File",s)}addGeoPoint(e,s={}){return this.addField(e,"GeoPoint",s)}addPolygon(e,s={}){return this.addField(e,"Polygon",s)}addArray(e,s={}){return this.addField(e,"Array",s)}addObject(e,s={}){return this.addField(e,"Object",s)}addPointer(e,s,t={}){return this.addField(e,"Pointer",{targetClass:s,...t})}addRelation(e,s,t={}){return this.addField(e,"Relation",{targetClass:s,...t})}deleteField(e){return this._fields[e]={type:"__op",__op:"Delete"},this}addIndex(e,s){return this._indexes[e]=s,this}deleteIndex(e){return this._indexes[e]={__op:"Delete"},this}setCLP(e){return this._clp=e,this}toJSON(){const e={className:this.className};return Object.keys(this._fields).length>0&&(e.fields=this._fields),Object.keys(this._indexes).length>0&&(e.indexes=this._indexes),Object.keys(this._clp).length>0&&(e.classLevelPermissions=this._clp),e}async save(e){const s=this._parseInstance||FmodeSchema._instance;if(!s)throw new Error("Not initialized");const t=`${s.serverURL}/schemas/${this.className}`,i={"Content-Type":"application/json","X-Parse-Application-Id":s.appId};if(e?.useMasterKey&&s.config.masterKey)i["X-Parse-Master-Key"]=s.config.masterKey;else{const e=s.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=this.toJSON();delete n.className;const a=await fetch(t,{method:"POST",headers:i,body:JSON.stringify(n)}),r=await a.json();if(r.error)throw new Error(r.error);return r.fields&&(this._fields=r.fields),r.indexes&&(this._indexes=r.indexes),r.classLevelPermissions&&(this._clp=r.classLevelPermissions),this}async update(e){const s=this._parseInstance||FmodeSchema._instance;if(!s)throw new Error("Not initialized");const t=`${s.serverURL}/schemas/${this.className}`,i={"Content-Type":"application/json","X-Parse-Application-Id":s.appId};if(e?.useMasterKey&&s.config.masterKey)i["X-Parse-Master-Key"]=s.config.masterKey;else{const e=s.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=this.toJSON();delete n.className;const a=await fetch(t,{method:"PUT",headers:i,body:JSON.stringify(n)}),r=await a.json();if(r.error)throw new Error(r.error);return r.fields&&(this._fields=r.fields),r.indexes&&(this._indexes=r.indexes),r.classLevelPermissions&&(this._clp=r.classLevelPermissions),this}async delete(e){const s=this._parseInstance||FmodeSchema._instance;if(!s)throw new Error("Not initialized");const t=`${s.serverURL}/schemas/${this.className}`,i={"X-Parse-Application-Id":s.appId};if(e?.useMasterKey&&s.config.masterKey)i["X-Parse-Master-Key"]=s.config.masterKey;else{const e=s.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=await fetch(t,{method:"DELETE",headers:i});if(!n.ok){const e=await n.json();throw new Error(e.error||"Failed to delete schema")}}async get(e,s){if(!FmodeSchema._instance)throw new Error("Not initialized");e=e||this.className;const t=`${FmodeSchema._instance.serverURL}/schemas/${e}`,i={"X-Parse-Application-Id":FmodeSchema._instance.appId};if(s?.useMasterKey&&FmodeSchema._instance.config.masterKey)i["X-Parse-Master-Key"]=FmodeSchema._instance.config.masterKey;else{const e=FmodeSchema._instance.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=await fetch(t,{method:"GET",headers:i}),a=await n.json();if(a.error)throw new Error(a.error);const r=new FmodeSchema(e);return a.fields&&(r._fields=a.fields),a.indexes&&(r._indexes=a.indexes),a.classLevelPermissions&&(r._clp=a.classLevelPermissions),r}static async all(e){if(!FmodeSchema._instance)throw new Error("Not initialized");const s=`${FmodeSchema._instance.serverURL}/schemas`,t={"X-Parse-Application-Id":FmodeSchema._instance.appId};if(e?.useMasterKey&&FmodeSchema._instance.config.masterKey)t["X-Parse-Master-Key"]=FmodeSchema._instance.config.masterKey;else{const e=FmodeSchema._instance.sessionToken;e&&(t["X-Parse-Session-Token"]=e)}const i=await fetch(s,{method:"GET",headers:t}),n=await i.json();if(n.error)throw new Error(n.error);const a=n.results||n;return console.log("schemas",a),a.map((e=>{const s=new this(e.className);return e.fields&&(s._fields=e.fields),e.indexes&&(s._indexes=e.indexes),e.classLevelPermissions&&(s._clp=e.classLevelPermissions),s}))}static async purge(e,s){if(!FmodeSchema._instance)throw new Error("Not initialized");const t=`${FmodeSchema._instance.serverURL}/purge/${e}`,i={"X-Parse-Application-Id":FmodeSchema._instance.appId};if(s?.useMasterKey&&FmodeSchema._instance.config.masterKey)i["X-Parse-Master-Key"]=FmodeSchema._instance.config.masterKey;else{const e=FmodeSchema._instance.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=await fetch(t,{method:"DELETE",headers:i});if(!n.ok){const e=await n.json();throw new Error(e.error||"Failed to purge schema")}}assertFieldExists(e){if(!this._fields[e])throw new Error(`Field ${e} does not exist`)}getField(e){return this._fields[e]}getFields(){return{...this._fields}}getIndexes(){return{...this._indexes}}getCLP(){return{...this._clp}}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnNjaGVtYS5tanM=`
10
+
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/parse/index.mjs
7
7
  */
8
- export*from"./fmode.parse";export*from"./fmode.object";export*from"./fmode.user";export*from"./fmode.query";export*from"./datatype/geopoint";
8
+ export*from"./fmode.parse";export*from"./fmode.object";export*from"./fmode.user";export*from"./fmode.query";export*from"./fmode.schema";export*from"./datatype/geopoint";
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2luZGV4Lm1qcw==`
10
10