fmode-ng 0.0.228 → 0.0.231
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.
- package/esm2022/lib/core/parse/fmode.object.mjs +1 -1
- package/esm2022/lib/core/parse/fmode.parse.mjs +1 -1
- package/esm2022/lib/core/parse/fmode.query.mjs +1 -1
- package/esm2022/lib/core/parse/fmode.user.mjs +1 -1
- package/esm2022/lib/core/social/dingtalk/dingtalk-auth.mjs +10 -0
- package/esm2022/lib/core/social/dingtalk/index.mjs +10 -0
- package/esm2022/lib/core/social/dingtalk/interface.mjs +10 -0
- package/esm2022/lib/core/social/index.mjs +1 -1
- package/fesm2022/fmode-ng.mjs +1 -1
- package/fesm2022/fmode-ng.mjs.map +1 -1
- package/lib/aigc/service-fmai/service-imagine/imagine.service.d.ts +3 -3
- package/lib/core/agent/story/agent.story.d.ts +1 -1
- package/lib/core/parse/fmode.object.d.ts +1 -0
- package/lib/core/parse/fmode.parse.d.ts +7 -2
- package/lib/core/parse/fmode.query.d.ts +4 -2
- package/lib/core/parse/fmode.user.d.ts +5 -5
- package/lib/core/social/dingtalk/dingtalk-auth.d.ts +118 -0
- package/lib/core/social/dingtalk/index.d.ts +1 -0
- package/lib/core/social/dingtalk/interface.d.ts +30 -0
- package/lib/core/social/index.d.ts +1 -0
- package/lib/payment/payment.service.d.ts +1 -1
- package/lib/user/login/auth.service.d.ts +1 -1
- package/lib/user/profile/auth-profile.service.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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
|
-
import{FmodeRelation}from"./datatype/relation";export class FmodeObject{static{this._instance=null}static bindInstance(
|
|
8
|
+
import{FmodeRelation}from"./datatype/relation";export class FmodeObject{static{this._instance=null}static bindInstance(t){this._instance=t}constructor(t){this.data={},this.className=t,this._parseInstance=FmodeObject._instance}static extend(t){const e=class extends FmodeObject{constructor(){super(t)}};return e.extend=FmodeObject.extend,e.create=FmodeObject.create,e.fetchAll=FmodeObject.fetchAll,e.fromFile=FmodeObject.fromFile,e.bindInstance=FmodeObject.bindInstance,e._instance=FmodeObject._instance,e}toPointer(){return{__type:"Pointer",className:this.className,objectId:this.id}}toJSON(){const t={__type:"Object",className:this.className,...this.data};this.id&&(t.objectId=this.id),Object.keys(t).forEach((e=>{t[e]?.getTime?.()&&(t[e]={__type:"Date",iso:t[e].toISOString()})}));try{this.createdAt&&("string"==typeof this.createdAt&&(this.createdAt=new Date(this.createdAt)),t.createdAt={__type:"Date",iso:this.createdAt.toISOString()}),this.updatedAt&&("string"==typeof this.updatedAt&&(this.updatedAt=new Date(this.updatedAt)),console.log(this.updatedAt),t.updatedAt={__type:"Date",iso:this.updatedAt.toISOString()})}catch(t){}return this.ACL&&(t.ACL=this.ACL),t}get(t){return"Date"==this.data[t]?.__type?new Date(this.data[t]?.iso):this.data[t]}isoStrToDate(t){if(t?.indexOf?.("T")>-1&&t?.indexOf?.("Z")>-1&&24==t?.length)try{return new Date(t)}catch(t){}return t}set(t,e){return"object"==typeof t?(Object.keys(t).forEach((e=>{t[e]?.indexOf?.("T")>-1&&t[e]?.indexOf?.("Z")>-1&&(t[e]=this.isoStrToDate(t[e]))})),Object.assign(this.data,t)):(e&&(e=this.isoStrToDate(e)),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)||[],i=new Set(e);return this.set(t,s.filter((t=>!i.has(t)))),this}async save(t){const e=this._parseInstance||FmodeObject._instance;if(!e)throw new Error("Not initialized");const s=this.id?"PUT":"POST";let i=`${e.serverURL}/classes/${this.className}`;this.id&&(i+=`/${this.id}`);const n={"Content-Type":"application/json","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 a=this.toJSON();delete a.createdAt,delete a.updatedAt,delete a.__type,delete a.className;for(const t in a)this.get(t)?.toPointer&&(a[t]=this.get(t).toPointer());let r,o;console.log(i,a);try{o=await fetch(i,{method:s,headers:n,body:JSON.stringify(a)}),console.log(JSON.stringify(a)),r=await o.json()}catch(t){alert(t)}if(console.log(r),r.error)throw new Error(r.error);return this.id=r.objectId||this.id,this.createdAt=new Date(r.createdAt||this.createdAt),this.updatedAt=new Date(r.updatedAt||this.updatedAt),this}async destroy(t){if(!this.id)throw new Error("Cannot destroy unsaved object");const e=this._parseInstance||FmodeObject._instance;if(!e)throw new Error("Not initialized");const s={"X-Parse-Application-Id":e.appId};if(t?.useMasterKey&&e.config.masterKey)s["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(s["X-Parse-Session-Token"]=t)}const i=`${e.serverURL}/classes/${this.className}/${this.id}`,n=await fetch(i,{method:"DELETE",headers:s});if(!n.ok){const t=await n.json();throw new Error(t.error||"Failed to delete object")}}static async create(t,e,s){const i=new this(t);return i.set(e),i.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};if(e?.useMasterKey&&FmodeObject._instance.config.masterKey)s["X-Parse-Master-Key"]=FmodeObject._instance.config.masterKey;else{const t=FmodeObject._instance.sessionToken;t&&(s["X-Parse-Session-Token"]=t)}const i=`${FmodeObject._instance.serverURL}/batch`,n=t.map((t=>({method:"GET",path:`/classes/${t.className}/${t.id}`}))),a=await fetch(i,{method:"POST",headers:s,body:JSON.stringify({requests:n})}),r=await a.json();if(r.error)throw new Error(r.error);return r.map(((e,s)=>{const i=t[s];return i.set(e.success),i}))}relation(t){return new FmodeRelation(this,t)}static async fromFile(t,e,s){if(!FmodeObject._instance)throw new Error("Not initialized");const i=new FormData;i.append("file",e,t);const n={"X-Parse-Application-Id":FmodeObject._instance.appId},a=FmodeObject._instance.sessionToken;a&&(n["X-Parse-Session-Token"]=a);const r=`${FmodeObject._instance.serverURL}/files/${t}`,o=await fetch(r,{method:"POST",headers:n,body:i}),c=await o.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
|
|
|
@@ -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=
|
|
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=FmodeCloud.getInstance(),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),this.Cloud.bindInstance(this.config)}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()))}}}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}return"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),this._instances[e]||this._defaultInstance}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};
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnBhcnNlLm1qcw==`
|
|
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.query.mjs
|
|
7
7
|
*/
|
|
8
|
-
import{FmodeObject}from"./fmode.object";export class FmodeQuery{static{this._instance=null}static bindInstance(e){this._instance=e}static get instance(){if(!this._instance)throw new Error("FmodeParse not initialized");return this._instance}static convertIncludedObjects(e){if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map((e=>this.convertIncludedObjects(e)));if(e.objectId&&(e.createdAt||e.updatedAt)){const t=e.className||"Object",r=new FmodeObject(t);r.id=e.objectId,e.createdAt&&(r.createdAt="string"==typeof e.createdAt?new Date(e.createdAt):e.createdAt),e.updatedAt&&(r.updatedAt="string"==typeof e.updatedAt?new Date(e.updatedAt):e.updatedAt),e.ACL&&(r.ACL=e.ACL);const s={};for(const[t,r]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(s[t]=this.convertIncludedObjects(r));return r.set(s),r}if("Object"===e.__type&&e.className&&e.objectId){const t=new FmodeObject(e.className);t.id=e.objectId,e.createdAt&&(t.createdAt=new Date(e.createdAt)),e.updatedAt&&(t.updatedAt=new Date(e.updatedAt)),e.ACL&&(t.ACL=e.ACL);const r={};for(const[t,s]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(r[t]=this.convertIncludedObjects(s));return t.set(r),t}if("Pointer"===e.__type&&e.className&&e.objectId)return e;const t={};for(const[r,s]of Object.entries(e))t[r]=this.convertIncludedObjects(s);return t}constructor(e){this.where={},this._include=[],this._exclude=[],this._select=[],this._count=!1,this.className="string"==typeof e?e:e.prototype.constructor.name}equalTo(e,t){return t=this.fixPointer(t),this.where[e]=t,this}fixPointer(e){return e?.className&&e?.data?{__type:"Pointer",className:e?.className,objectId:e?.data?.id||e?.id}:e}notEqualTo(e,t){return t=this.fixPointer(t),this.where[e]={$ne:t},this}lessThan(e,t){return this.where[e]={$lt:t},this}lessThanOrEqualTo(e,t){return this.where[e]={$lte:t},this}greaterThan(e,t){return this.where[e]={$gt:t},this}greaterThanOrEqualTo(e,t){return this.where[e]={$gte:t},this}containedIn(e,t){return this.where[e]={$in:t},this}notContainedIn(e,t){return this.where[e]={$nin:t},this}exists(e){return this.where[e]={$exists:!0},this}doesNotExist(e){return this.where[e]={$exists:!1},this}containsAll(e,t){return this.where[e]={$all:t},this}contains(e,t){return this.where[e]={$regex:t,$options:"i"},this}startsWith(e,t){return this.where[e]={$regex:`^${t}`,$options:"i"},this}endsWith(e,t){return this.where[e]={$regex:`${t}$`,$options:"i"},this}matches(e,t,r){return this.where[e]={$regex:t.source,$options:r},this}matchesQuery(e,t){return this.where[e]={$inQuery:{className:t.className,where:t.where}},this}doesNotMatchQuery(e,t){return this.where[e]={$notInQuery:{className:t.className,where:t.where}},this}matchesKeyInQuery(e,t,r){return this.where[e]={$select:{key:t,query:{className:r.className,where:r.where}}},this}doesNotMatchKeyInQuery(e,t,r){return this.where[e]={$dontSelect:{key:t,query:{className:r.className,where:r.where}}},this}near(e,t){return this.where[e]={$nearSphere:t},this}withinRadians(e,t,r){return this.where[e]={$nearSphere:t,$maxDistance:r},this}withinMiles(e,t,r){return this.withinRadians(e,t,r/3959)}withinKilometers(e,t,r){return this.withinRadians(e,t,r/6371)}withinGeoBox(e,t,r){return this.where[e]={$within:{$box:[t,r]}},this}polygonContains(e,t){return this.where[e]={$geoWithin:{$polygon:t}},this}containedBy(e,t){return this.where[e]={$containedBy:t},this}fullText(e,t,r){return this.where[e]={$text:{$search:t,$caseSensitive:r?.caseSensitive,$diacriticSensitive:r?.diacriticSensitive}},this}containsAllStartingWith(e,t){return this.where[e]={$all:t.map((e=>({$regex:`^${e}`})))},this}sizeEqualTo(e,t){return this.where[e]={$size:t},this}relatedTo(e,t){if(!e.id)throw new Error("Parent object must have an ID");return this.where.$relatedTo={object:e.toPointer(),key:t},this}relatedToObject(e,t){if(!e.id)throw new Error("Parent object must have an ID");return this.where.$relatedTo={object:e.toPointer(),key:t},this}relatedToQuery(e,t,r){return this.where.$relatedTo={key:t,query:{className:e,where:r.where}},this}matchesPointer(e,t){if(!t.id)throw new Error("Object must have an ID");return this.where[e]=t.toPointer(),this}matchesAnyPointer(e,t){const r=t.map((e=>{if(!e.id)throw new Error("All objects must have IDs");return e.toPointer()}));return this.where[e]={$in:r},this}static async findRelation(e,t,r){if(!e.id)throw new Error("Parent object must have an ID");return new FmodeQuery(e.className).relatedTo(e,t).find(r)}static async countRelation(e,t,r){if(!e.id)throw new Error("Parent object must have an ID");return new FmodeQuery(e.className).relatedTo(e,t).count(r)}static async addToRelation(e,t,r,s){if(!e.id)throw new Error("Parent object must have an ID");if(r.some((e=>!e.id)))throw new Error("All objects to add must have IDs");const i=r.map((e=>e.toPointer())),n=`${FmodeQuery.instance.serverURL}/classes/${e.className}/${e.id}`,a={"Content-Type":"application/json","X-Parse-Application-Id":FmodeQuery.instance.appId};if(s?.useMasterKey&&FmodeQuery.instance.config.masterKey)a["X-Parse-Master-Key"]=FmodeQuery.instance.config.masterKey;else{const e=FmodeQuery.instance.sessionToken;e&&(a["X-Parse-Session-Token"]=e)}const o=await fetch(n,{method:"PUT",headers:a,body:JSON.stringify({[t]:{__op:"AddRelation",objects:i}})});if(!o.ok){const e=await o.json();throw new Error(e.error||"Failed to add to relation")}}static async removeFromRelation(e,t,r,s){if(!e.id)throw new Error("Parent object must have an ID");if(r.some((e=>!e.id)))throw new Error("All objects to remove must have IDs");const i=r.map((e=>e.toPointer())),n=`${FmodeQuery.instance.serverURL}/classes/${e.className}/${e.id}`,a={"Content-Type":"application/json","X-Parse-Application-Id":FmodeQuery.instance.appId};if(s?.useMasterKey&&FmodeQuery.instance.config.masterKey)a["X-Parse-Master-Key"]=FmodeQuery.instance.config.masterKey;else{const e=FmodeQuery.instance.sessionToken;e&&(a["X-Parse-Session-Token"]=e)}const o=await fetch(n,{method:"PUT",headers:a,body:JSON.stringify({[t]:{__op:"RemoveRelation",objects:i}})});if(!o.ok){const e=await o.json();throw new Error(e.error||"Failed to remove from relation")}}exclude(...e){let t={};return this._exclude.concat(e).forEach((e=>{t[e]=!0})),this._exclude=Object.keys(t),this}include(...e){let t={};return this._include.concat(e).forEach((e=>{t[e]=!0})),this._include=Object.keys(t),this}select(...e){return this._select=e,this}limit(e){return this._limit=e,this}skip(e){return this._skip=e,this}ascending(...e){return this._order=e.map((e=>e.startsWith("-")?e.substring(1):e)),this}descending(...e){return this._order=e.map((e=>e.startsWith("-")?e.substring(1):`-${e}`)),this}addAscending(...e){return this._order||(this._order=[]),this._order.push(...e),this}addDescending(...e){return this._order||(this._order=[]),this._order.push(...e.map((e=>`-${e}`))),this}readPreference(e){return this._readPreference=e,this}includeReadPreference(e){return this._includeReadPreference=e,this}excludeReadPreference(e){return this._excludeReadPreference=e,this}subqueryReadPreference(e){return this._subqueryReadPreference=e,this}hint(e){return this.hint=e,this}maxTimeMS(e){return this._maxTimeMS=e,this}explain(e=!0){return this._explain=e,this}withCount(e=!0){return this._count=e,this}async find(e){const t=new URL(`${FmodeQuery.instance.serverURL}/classes/${this.className}`),r=this._buildQueryParams();Object.entries(r).forEach((([e,r])=>{void 0!==r&&t.searchParams.set(e,"string"==typeof r?r:JSON.stringify(r))}));const s={"X-Parse-Application-Id":FmodeQuery.instance.appId};if(e?.useMasterKey&&FmodeQuery.instance.config.masterKey)s["X-Parse-Master-Key"]=FmodeQuery.instance.config.masterKey;else{const e=this._sessionToken||FmodeQuery.instance.sessionToken;e&&(s["X-Parse-Session-Token"]=e)}const i=await fetch(t.toString(),{headers:s}),n=await i.json();if(209==n.code&&FmodeQuery.instance.User.logOut(),n.error)throw console.error(i),new Error(n.error);return n.results.map((e=>{const t=new FmodeObject(this.className);t.id=e.objectId,e.createdAt&&(t.createdAt=new Date(e.createdAt)),e.updatedAt&&(t.updatedAt=new Date(e.updatedAt||e.createdAt)),e.ACL&&(t.ACL=e.ACL);const r={};for(const[t,s]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(this._include.includes(t)&&s&&"object"==typeof s&&s.objectId,r[t]=FmodeQuery.convertIncludedObjects(s));return t.set(r),t}))}async first(e){this.limit(1);return(await this.find(e))[0]||null}async get(e,t){const r=new URL(`${FmodeQuery.instance.serverURL}/classes/${this.className}/${e}`);this._include.length>0&&r.searchParams.set("include",this._include.join(","));const s={"X-Parse-Application-Id":FmodeQuery.instance.appId};if(t?.useMasterKey&&FmodeQuery.instance.config.masterKey)s["X-Parse-Master-Key"]=FmodeQuery.instance.config.masterKey;else{const e=this._sessionToken||FmodeQuery.instance.sessionToken;e&&(s["X-Parse-Session-Token"]=e)}const i=await fetch(r.toString(),{headers:s}),n=await i.json();if(n.error)throw new Error(n.error);const a=new FmodeObject(this.className);a.id=n.objectId,n.createdAt&&(a.createdAt=new Date(n.createdAt)),n.updatedAt&&(a.updatedAt=new Date(n.updatedAt||n.createdAt)),n.ACL&&(a.ACL=n.ACL);const o={};for(const[e,t]of Object.entries(n))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(e)||(this._include.includes(e)&&t&&"object"==typeof t&&t.objectId,o[e]=FmodeQuery.convertIncludedObjects(t));return a.set(o),a}async count(e){this.withCount();const t=new URL(`${FmodeQuery.instance.serverURL}/classes/${this.className}`);t.searchParams.set("count","1"),t.searchParams.set("limit","0"),Object.keys(this.where).length>0&&t.searchParams.set("where",JSON.stringify(this.where));const r={"X-Parse-Application-Id":FmodeQuery.instance.appId};if(e?.useMasterKey&&FmodeQuery.instance.config.masterKey)r["X-Parse-Master-Key"]=FmodeQuery.instance.config.masterKey;else{const e=this._sessionToken||FmodeQuery.instance.sessionToken;e&&(r["X-Parse-Session-Token"]=e)}const s=await fetch(t.toString(),{headers:r}),i=await s.json();if(i.error)throw new Error(i.error);return i.count||0}toJSON(){const e={className:this.className};return Object.keys(this.where).length>0&&(e.where=this.where),this._include.length>0&&(e.include=this._include.join(",")),this._exclude.length>0&&(e.exclude=this._exclude.join(",")),this._select.length>0&&(e.keys=this._select.join(",")),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._skip&&(e.skip=this._skip),this._order&&this._order.length>0&&(e.order=this._order.join(",")),this._count&&(e.count=1),this._explain&&(e.explain=!0),this._hint&&(e.hint=this._hint),this._maxTimeMS&&(e.maxTimeMS=this._maxTimeMS),this._readPreference&&(e.readPreference=this._readPreference),this._includeReadPreference&&(e.includeReadPreference=this._includeReadPreference),this._excludeReadPreference&&(e.excludeReadPreference=this._excludeReadPreference),this._subqueryReadPreference&&(e.subqueryReadPreference=this._subqueryReadPreference),e}static fromJSON(e,t){const r=new FmodeQuery(e=e||t?.className);if(t.where&&(r.where=t.where),t.include){const e="string"==typeof t.include?t.include.split(","):t.include;r._include=e}if(t.exclude){const e="string"==typeof t.exclude?t.exclude.split(","):t.exclude;r._exclude=e}if(t.keys){const e="string"==typeof t.keys?t.keys.split(","):t.keys;r._select=e}if(void 0!==t.limit&&(r._limit=t.limit),void 0!==t.skip&&(r._skip=t.skip),t.order){const e="string"==typeof t.order?t.order.split(","):t.order;r._order=e}return t.count&&(r._count=!!t.count),t.explain&&(r._explain=!!t.explain),t.hint&&(r._hint=t.hint),t.maxTimeMS&&(r._maxTimeMS=t.maxTimeMS),t.readPreference&&(r._readPreference=t.readPreference),t.includeReadPreference&&(r._includeReadPreference=t.includeReadPreference),t.excludeReadPreference&&(r._excludeReadPreference=t.excludeReadPreference),t.subqueryReadPreference&&(r._subqueryReadPreference=t.subqueryReadPreference),r}_buildQueryParams(){const e={};return Object.keys(this.where).length>0&&(e.where=this.where),this._include.length>0&&(e.include=this._include.join(",")),this._exclude.length>0&&(e.excludeKeys=this._exclude.join(",")),this._select.length>0&&(e.keys=this._select.join(",")),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._skip&&(e.skip=this._skip),this._order&&(e.order=this._order.join(",")),this._count&&(e.count=1),this._explain&&(e.explain=!0),this._hint&&(e.hint=this._hint),this._maxTimeMS&&(e.maxTimeMS=this._maxTimeMS),e}subscribe(){const e=new EventTarget,t=setInterval((async()=>{try{const t=await this.find();e.dispatchEvent(new CustomEvent("update",{detail:t}))}catch(t){e.dispatchEvent(new CustomEvent("error",{detail:t}))}}),5e3);return e.unsubscribe=()=>{clearInterval(t)},e}static or(...e){if(0===e.length)throw new Error("At least one query required");const t=e[0].className;if(e.some((e=>e.className!==t)))throw new Error("All queries must be for the same class");const r=new FmodeQuery(t);return r.where={$or:e.map((e=>e.where))},r}static and(...e){if(0===e.length)throw new Error("At least one query required");const t=e[0].className;if(e.some((e=>e.className!==t)))throw new Error("All queries must be for the same class");const r=new FmodeQuery(t);return r.where={$and:e.map((e=>e.where))},r}or(...e){return FmodeQuery.or(this,...e)}and(...e){return FmodeQuery.and(this,...e)}}
|
|
8
|
+
import{FmodeObject}from"./fmode.object";export class FmodeQuery{static{this._instance=null}static bindInstance(e){this._instance=e}static get instance(){if(!this._instance)throw new Error("FmodeParse not initialized");return this._instance}get currentInstance(){return this._parseInstance||FmodeQuery.instance}static convertIncludedObjects(e){if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map((e=>this.convertIncludedObjects(e)));if(e.objectId&&(e.createdAt||e.updatedAt)){const t=e.className||"Object",r=new FmodeObject(t);r.id=e.objectId,e.createdAt&&(r.createdAt="string"==typeof e.createdAt?new Date(e.createdAt):e.createdAt),e.updatedAt&&(r.updatedAt="string"==typeof e.updatedAt?new Date(e.updatedAt):e.updatedAt),e.ACL&&(r.ACL=e.ACL);const s={};for(const[t,r]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(s[t]=this.convertIncludedObjects(r));return r.set(s),r}if("Object"===e.__type&&e.className&&e.objectId){const t=new FmodeObject(e.className);t.id=e.objectId,e.createdAt&&(t.createdAt=new Date(e.createdAt)),e.updatedAt&&(t.updatedAt=new Date(e.updatedAt)),e.ACL&&(t.ACL=e.ACL);const r={};for(const[t,s]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(r[t]=this.convertIncludedObjects(s));return t.set(r),t}if("Pointer"===e.__type&&e.className&&e.objectId)return e;const t={};for(const[r,s]of Object.entries(e))t[r]=this.convertIncludedObjects(s);return t}constructor(e){this.where={},this._include=[],this._exclude=[],this._select=[],this._count=!1,this.className="string"==typeof e?e:e.prototype.constructor.name}equalTo(e,t){return t=this.fixPointer(t),this.where[e]=t,this}fixPointer(e){return e?.className&&e?.data?{__type:"Pointer",className:e?.className,objectId:e?.data?.id||e?.id}:e}notEqualTo(e,t){return t=this.fixPointer(t),this.where[e]={$ne:t},this}lessThan(e,t){return this.where[e]={$lt:t},this}lessThanOrEqualTo(e,t){return this.where[e]={$lte:t},this}greaterThan(e,t){return this.where[e]={$gt:t},this}greaterThanOrEqualTo(e,t){return this.where[e]={$gte:t},this}containedIn(e,t){return this.where[e]={$in:t},this}notContainedIn(e,t){return this.where[e]={$nin:t},this}exists(e){return this.where[e]={$exists:!0},this}doesNotExist(e){return this.where[e]={$exists:!1},this}containsAll(e,t){return this.where[e]={$all:t},this}contains(e,t){return this.where[e]={$regex:t,$options:"i"},this}startsWith(e,t){return this.where[e]={$regex:`^${t}`,$options:"i"},this}endsWith(e,t){return this.where[e]={$regex:`${t}$`,$options:"i"},this}matches(e,t,r){return this.where[e]={$regex:t.source,$options:r},this}matchesQuery(e,t){return this.where[e]={$inQuery:{className:t.className,where:t.where}},this}doesNotMatchQuery(e,t){return this.where[e]={$notInQuery:{className:t.className,where:t.where}},this}matchesKeyInQuery(e,t,r){return this.where[e]={$select:{key:t,query:{className:r.className,where:r.where}}},this}doesNotMatchKeyInQuery(e,t,r){return this.where[e]={$dontSelect:{key:t,query:{className:r.className,where:r.where}}},this}near(e,t){return this.where[e]={$nearSphere:t},this}withinRadians(e,t,r){return this.where[e]={$nearSphere:t,$maxDistance:r},this}withinMiles(e,t,r){return this.withinRadians(e,t,r/3959)}withinKilometers(e,t,r){return this.withinRadians(e,t,r/6371)}withinGeoBox(e,t,r){return this.where[e]={$within:{$box:[t,r]}},this}polygonContains(e,t){return this.where[e]={$geoWithin:{$polygon:t}},this}containedBy(e,t){return this.where[e]={$containedBy:t},this}fullText(e,t,r){return this.where[e]={$text:{$search:t,$caseSensitive:r?.caseSensitive,$diacriticSensitive:r?.diacriticSensitive}},this}containsAllStartingWith(e,t){return this.where[e]={$all:t.map((e=>({$regex:`^${e}`})))},this}sizeEqualTo(e,t){return this.where[e]={$size:t},this}relatedTo(e,t){if(!e.id)throw new Error("Parent object must have an ID");return this.where.$relatedTo={object:e.toPointer(),key:t},this}relatedToObject(e,t){if(!e.id)throw new Error("Parent object must have an ID");return this.where.$relatedTo={object:e.toPointer(),key:t},this}relatedToQuery(e,t,r){return this.where.$relatedTo={key:t,query:{className:e,where:r.where}},this}matchesPointer(e,t){if(!t.id)throw new Error("Object must have an ID");return this.where[e]=t.toPointer(),this}matchesAnyPointer(e,t){const r=t.map((e=>{if(!e.id)throw new Error("All objects must have IDs");return e.toPointer()}));return this.where[e]={$in:r},this}static async findRelation(e,t,r){if(!e.id)throw new Error("Parent object must have an ID");return new FmodeQuery(e.className).relatedTo(e,t).find(r)}static async countRelation(e,t,r){if(!e.id)throw new Error("Parent object must have an ID");return new FmodeQuery(e.className).relatedTo(e,t).count(r)}static async addToRelation(e,t,r,s){if(!e.id)throw new Error("Parent object must have an ID");if(r.some((e=>!e.id)))throw new Error("All objects to add must have IDs");const i=r.map((e=>e.toPointer())),n=e._parseInstance||FmodeQuery.instance,a=`${n.serverURL}/classes/${e.className}/${e.id}`,o={"Content-Type":"application/json","X-Parse-Application-Id":n.appId};if(s?.useMasterKey&&n.config.masterKey)o["X-Parse-Master-Key"]=n.config.masterKey;else{const e=n.sessionToken;e&&(o["X-Parse-Session-Token"]=e)}const c=await fetch(a,{method:"PUT",headers:o,body:JSON.stringify({[t]:{__op:"AddRelation",objects:i}})});if(!c.ok){const e=await c.json();throw new Error(e.error||"Failed to add to relation")}}static async removeFromRelation(e,t,r,s){if(!e.id)throw new Error("Parent object must have an ID");if(r.some((e=>!e.id)))throw new Error("All objects to remove must have IDs");const i=r.map((e=>e.toPointer())),n=e._parseInstance||FmodeQuery.instance,a=`${n.serverURL}/classes/${e.className}/${e.id}`,o={"Content-Type":"application/json","X-Parse-Application-Id":n.appId};if(s?.useMasterKey&&n.config.masterKey)o["X-Parse-Master-Key"]=n.config.masterKey;else{const e=n.sessionToken;e&&(o["X-Parse-Session-Token"]=e)}const c=await fetch(a,{method:"PUT",headers:o,body:JSON.stringify({[t]:{__op:"RemoveRelation",objects:i}})});if(!c.ok){const e=await c.json();throw new Error(e.error||"Failed to remove from relation")}}exclude(...e){let t={};return this._exclude.concat(e).forEach((e=>{t[e]=!0})),this._exclude=Object.keys(t),this}include(...e){let t={};return this._include.concat(e).forEach((e=>{t[e]=!0})),this._include=Object.keys(t),this}select(...e){return this._select=e,this}limit(e){return this._limit=e,this}skip(e){return this._skip=e,this}ascending(...e){return this._order=e.map((e=>e.startsWith("-")?e.substring(1):e)),this}descending(...e){return this._order=e.map((e=>e.startsWith("-")?e.substring(1):`-${e}`)),this}addAscending(...e){return this._order||(this._order=[]),this._order.push(...e),this}addDescending(...e){return this._order||(this._order=[]),this._order.push(...e.map((e=>`-${e}`))),this}readPreference(e){return this._readPreference=e,this}includeReadPreference(e){return this._includeReadPreference=e,this}excludeReadPreference(e){return this._excludeReadPreference=e,this}subqueryReadPreference(e){return this._subqueryReadPreference=e,this}hint(e){return this.hint=e,this}maxTimeMS(e){return this._maxTimeMS=e,this}explain(e=!0){return this._explain=e,this}withCount(e=!0){return this._count=e,this}async find(e){const t=this.currentInstance,r=new URL(`${t.serverURL}/classes/${this.className}`),s=this._buildQueryParams();Object.entries(s).forEach((([e,t])=>{void 0!==t&&r.searchParams.set(e,"string"==typeof t?t:JSON.stringify(t))}));const i={"X-Parse-Application-Id":t.appId};if(e?.useMasterKey&&t.config.masterKey)i["X-Parse-Master-Key"]=t.config.masterKey;else{const e=this._sessionToken||t.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=await fetch(r.toString(),{headers:i}),a=await n.json();if(209==a.code&&t.User.logOut(),a.error)throw console.error(n),new Error(a.error);return a.results.map((e=>{const t=new FmodeObject(this.className);t._parseInstance=this._parseInstance,t.id=e.objectId,e.createdAt&&(t.createdAt=new Date(e.createdAt)),e.updatedAt&&(t.updatedAt=new Date(e.updatedAt||e.createdAt)),e.ACL&&(t.ACL=e.ACL);const r={};for(const[t,s]of Object.entries(e))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(t)||(this._include.includes(t)&&s&&"object"==typeof s&&s.objectId,r[t]=FmodeQuery.convertIncludedObjects(s));return t.set(r),t}))}async first(e){this.limit(1);return(await this.find(e))[0]||null}async get(e,t){const r=this.currentInstance,s=new URL(`${r.serverURL}/classes/${this.className}/${e}`);this._include.length>0&&s.searchParams.set("include",this._include.join(","));const i={"X-Parse-Application-Id":r.appId};if(t?.useMasterKey&&r.config.masterKey)i["X-Parse-Master-Key"]=r.config.masterKey;else{const e=this._sessionToken||r.sessionToken;e&&(i["X-Parse-Session-Token"]=e)}const n=await fetch(s.toString(),{headers:i}),a=await n.json();if(a.error)throw new Error(a.error);const o=new FmodeObject(this.className);o._parseInstance=this._parseInstance,o.id=a.objectId,a.createdAt&&(o.createdAt=new Date(a.createdAt)),a.updatedAt&&(o.updatedAt=new Date(a.updatedAt||a.createdAt)),a.ACL&&(o.ACL=a.ACL);const c={};for(const[e,t]of Object.entries(a))["__type","className","objectId","createdAt","updatedAt","ACL"].includes(e)||(this._include.includes(e)&&t&&"object"==typeof t&&t.objectId,c[e]=FmodeQuery.convertIncludedObjects(t));return o.set(c),o}async count(e){this.withCount();const t=this.currentInstance,r=new URL(`${t.serverURL}/classes/${this.className}`);r.searchParams.set("count","1"),r.searchParams.set("limit","0"),Object.keys(this.where).length>0&&r.searchParams.set("where",JSON.stringify(this.where));const s={"X-Parse-Application-Id":t.appId};if(e?.useMasterKey&&t.config.masterKey)s["X-Parse-Master-Key"]=t.config.masterKey;else{const e=this._sessionToken||t.sessionToken;e&&(s["X-Parse-Session-Token"]=e)}console.log(s,r?.href);const i=await fetch(r.toString(),{headers:s}),n=await i.json();if(n.error)throw new Error(n.error);return n.count||0}toJSON(){const e={className:this.className};return Object.keys(this.where).length>0&&(e.where=this.where),this._include.length>0&&(e.include=this._include.join(",")),this._exclude.length>0&&(e.exclude=this._exclude.join(",")),this._select.length>0&&(e.keys=this._select.join(",")),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._skip&&(e.skip=this._skip),this._order&&this._order.length>0&&(e.order=this._order.join(",")),this._count&&(e.count=1),this._explain&&(e.explain=!0),this._hint&&(e.hint=this._hint),this._maxTimeMS&&(e.maxTimeMS=this._maxTimeMS),this._readPreference&&(e.readPreference=this._readPreference),this._includeReadPreference&&(e.includeReadPreference=this._includeReadPreference),this._excludeReadPreference&&(e.excludeReadPreference=this._excludeReadPreference),this._subqueryReadPreference&&(e.subqueryReadPreference=this._subqueryReadPreference),e}static fromJSON(e,t){const r=new FmodeQuery(e=e||t?.className);if(t.where&&(r.where=t.where),t.include){const e="string"==typeof t.include?t.include.split(","):t.include;r._include=e}if(t.exclude){const e="string"==typeof t.exclude?t.exclude.split(","):t.exclude;r._exclude=e}if(t.keys){const e="string"==typeof t.keys?t.keys.split(","):t.keys;r._select=e}if(void 0!==t.limit&&(r._limit=t.limit),void 0!==t.skip&&(r._skip=t.skip),t.order){const e="string"==typeof t.order?t.order.split(","):t.order;r._order=e}return t.count&&(r._count=!!t.count),t.explain&&(r._explain=!!t.explain),t.hint&&(r._hint=t.hint),t.maxTimeMS&&(r._maxTimeMS=t.maxTimeMS),t.readPreference&&(r._readPreference=t.readPreference),t.includeReadPreference&&(r._includeReadPreference=t.includeReadPreference),t.excludeReadPreference&&(r._excludeReadPreference=t.excludeReadPreference),t.subqueryReadPreference&&(r._subqueryReadPreference=t.subqueryReadPreference),r}_buildQueryParams(){const e={};return Object.keys(this.where).length>0&&(e.where=this.where),this._include.length>0&&(e.include=this._include.join(",")),this._exclude.length>0&&(e.excludeKeys=this._exclude.join(",")),this._select.length>0&&(e.keys=this._select.join(",")),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._skip&&(e.skip=this._skip),this._order&&(e.order=this._order.join(",")),this._count&&(e.count=1),this._explain&&(e.explain=!0),this._hint&&(e.hint=this._hint),this._maxTimeMS&&(e.maxTimeMS=this._maxTimeMS),e}subscribe(){const e=new EventTarget,t=setInterval((async()=>{try{const t=await this.find();e.dispatchEvent(new CustomEvent("update",{detail:t}))}catch(t){e.dispatchEvent(new CustomEvent("error",{detail:t}))}}),5e3);return e.unsubscribe=()=>{clearInterval(t)},e}static or(...e){if(0===e.length)throw new Error("At least one query required");const t=e[0].className;if(e.some((e=>e.className!==t)))throw new Error("All queries must be for the same class");const r=new FmodeQuery(t);return r.where={$or:e.map((e=>e.where))},r}static and(...e){if(0===e.length)throw new Error("At least one query required");const t=e[0].className;if(e.some((e=>e.className!==t)))throw new Error("All queries must be for the same class");const r=new FmodeQuery(t);return r.where={$and:e.map((e=>e.where))},r}or(...e){return FmodeQuery.or(this,...e)}and(...e){return FmodeQuery.and(this,...e)}}
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnF1ZXJ5Lm1qcw==`
|
|
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.user.mjs
|
|
7
7
|
*/
|
|
8
|
-
import{FmodeObject}from"./fmode.object";export class FmodeUser extends FmodeObject{static{this._instance=null}static{this.instanceKey=()=>{if(!this._instance)throw new Error("FmodeParse not initialized before using User");return"Parse/"+this._instance.appId+"/currentUser"}}static bindInstance(e){this._instance=e}static get instance(){if(!this._instance)throw new Error("FmodeParse not initialized");return this._instance}get username(){return this.get("username")}set username(e){this.set("username",e)}get email(){return this.get("email")}set email(e){this.set("email",e)}get password(){return this.get("password")}set password(e){this.set("password",e)}constructor(e){super("_User"),e&&(this.id=e?.objectId,this.createdAt=new Date(e?.createdAt),this.updatedAt=new Date(e?.updatedAt),e.sessionToken&&(this.sessionToken=e.sessionToken,delete e.sessionToken),this.set(e))}static async logIn(e,s){const t=`${this.instance.serverURL}/login`,n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":this.instance.appId},body:JSON.stringify({username:e,password:s})}),r=await n.json();if(r.error)throw r;const i=new this({...r,username:e,password:s});return i._saveToCache(),i}static async become(e){const s=`${this.instance.serverURL}/users/me`;let t={"X-Parse-Session-Token":e,"X-Parse-Application-Id":this.instance.appId};const n=await fetch(s,{headers:t}),r=await n.json();if(r.error)throw r.error;const i=new this({...r,sessionToken:e});return i._saveToCache(),i}static async signUp(e,s,t={}){return new this({...t,username:e,password:s}).signUp()}static async logOut(){if(this.current())try{await fetch(`${this.instance.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":this.instance.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(e){const s=`${this.instance.serverURL}/requestPasswordReset`,t=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":this.instance.appId},body:JSON.stringify({email:e})}),n=await t.json();if(n.error)throw n}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const e=localStorage.getItem(this.instanceKey());if(!e)return null;const s=JSON.parse(e);if(!s.sessionToken)return null;const t=new this(s);return this._currentUser=t,t.sessionToken&&this._instance&&(this._instance.sessionToken=t.sessionToken),t}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,this._instance&&(this._instance.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}async signUp(e){if(e&&this.set(e),!this.username)throw new Error("Username is required");if(!this.password)throw new Error("Password is required");
|
|
8
|
+
import{FmodeObject}from"./fmode.object";export class FmodeUser extends FmodeObject{static{this._instance=null}static{this.instanceKey=()=>{if(!this._instance)throw new Error("FmodeParse not initialized before using User");return"Parse/"+this._instance.appId+"/currentUser"}}static bindInstance(e){this._instance=e}static get instance(){if(!this._instance)throw new Error("FmodeParse not initialized");return this._instance}get username(){return this.get("username")}set username(e){this.set("username",e)}get email(){return this.get("email")}set email(e){this.set("email",e)}get password(){return this.get("password")}set password(e){this.set("password",e)}constructor(e){super("_User"),e&&(this.id=e?.objectId,this.createdAt=new Date(e?.createdAt),this.updatedAt=new Date(e?.updatedAt),e.sessionToken&&(this.sessionToken=e.sessionToken,delete e.sessionToken),this.set(e))}static async logIn(e,s){const t=`${this.instance.serverURL}/login`,n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":this.instance.appId},body:JSON.stringify({username:e,password:s})}),r=await n.json();if(r.error)throw r;const i=new this({...r,username:e,password:s});return i._saveToCache(),i}static async become(e){const s=`${this.instance.serverURL}/users/me`;let t={"X-Parse-Session-Token":e,"X-Parse-Application-Id":this.instance.appId};const n=await fetch(s,{headers:t}),r=await n.json();if(r.error)throw r.error;const i=new this({...r,sessionToken:e});return i._saveToCache(),i}static async signUp(e,s,t={}){return new this({...t,username:e,password:s}).signUp()}static async logOut(){if(this.current())try{await fetch(`${this.instance.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":this.instance.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(e){const s=`${this.instance.serverURL}/requestPasswordReset`,t=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":this.instance.appId},body:JSON.stringify({email:e})}),n=await t.json();if(n.error)throw n}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const e=localStorage.getItem(this.instanceKey());if(!e)return null;const s=JSON.parse(e);if(!s.sessionToken)return null;const t=new this(s);return this._currentUser=t,t.sessionToken&&this._instance&&(this._instance.sessionToken=t.sessionToken),t}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,this._instance&&(this._instance.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}async signUp(e){if(e&&this.set(e),!this.username)throw new Error("Username is required");if(!this.password)throw new Error("Password is required");const s=this._parseInstance||FmodeUser.instance;let t=this.toJSON();delete t.__type,delete t.className;const n=`${s.serverURL}/users`,r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":s.appId},body:JSON.stringify(t)}),i=await r.json();if(i.error)throw i;return this.id=i.objectId,this.createdAt=new Date(i.createdAt),this.sessionToken=i.sessionToken,this._saveToCache(),this}async save(){const e=this._parseInstance||FmodeUser.instance,s=`${e.serverURL}/users/${this.id||this.data.objectId}`,t={"Content-Type":"application/json","X-Parse-Application-Id":e.appId,"X-Parse-Session-Token":this.sessionToken},n=this.toJSON();delete n.__type,delete n.objectId,delete n.className,delete n.sessionToken,delete n.username,delete n.createdAt,delete n.updatedAt;const r=await fetch(s,{method:"PUT",headers:t,body:JSON.stringify(n)}),i=await r.json();if(i.error)throw 209===i.code&&FmodeUser._clearCurrentUser(),new Error(i.error);return this.set("updatedAt",new Date(i.updatedAt)),this._saveToCache(),this}_saveToCache(){if(!this.sessionToken)return;FmodeUser._currentUser=this;const e=this._parseInstance||FmodeUser._instance;e&&(e.sessionToken=this.sessionToken),localStorage.setItem(FmodeUser.instanceKey(),JSON.stringify(this.toJSONForCache()))}toJSONForCache(){return{...super.toJSON(),sessionToken:this.sessionToken}}getSessionToken(){return this.sessionToken}async destroy(e){if(!this.id)throw new Error("Cannot destroy unsaved user");const s=this._parseInstance||FmodeUser.instance,t=`${s.serverURL}/users/${this.id}`,n={"X-Parse-Session-Token":this.sessionToken,"X-Parse-Application-Id":s.appId};e?.useMasterKey&&s.config.masterKey&&(n["X-Parse-Master-Key"]=s.config.masterKey);const r=await fetch(t,{method:"DELETE",headers:n});if(!r.ok){const e=await r.json();throw new Error(e.error||"Failed to delete user")}FmodeUser._clearCurrentUser()}}
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnVzZXIubWpz`
|
|
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/social/dingtalk/dingtalk-auth.mjs
|
|
7
|
+
*/
|
|
8
|
+
import*as dd from"dingtalk-jsapi";import{FmodeParse}from"../../parse";let PARSE_APP_ID=localStorage.getItem("PARSE_APP_ID")||"nova";const Parse=FmodeParse.with(PARSE_APP_ID);export class DingTalkAuth{constructor(e){this.config={clientId:e.clientId,corpId:e.corpId,redirectUri:e.redirectUri,agentId:e.agentId,apiOauthWeb:e.apiOauthWeb||"https://server.fmode.cn/api/dingtalk/oauth2/login",apiOauthDingtalk:e.apiOauthWeb||"https://server.fmode.cn/api/dingtalk/oauth2/dingtalk"},this.loadDingTalkSDK()}loadDingTalkSDK(){return new Promise(((e,o)=>{if(window.DTFrameLogin)return void e();const n=document.createElement("script");n.src="https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js",n.onload=()=>e(),n.onerror=()=>o(new Error("Failed to load DingTalk SDK")),document.head.appendChild(n)}))}isInDingTalkApp(){const e=navigator.userAgent.toLowerCase();return e.includes("dingtalk")||e.includes("dingtalk")}async getDingTalkAuthCode(){try{if(console.log("🔐 开始钉钉内免登录流程"),!this.isInDingTalkApp())return{success:!1,error:"不在钉钉环境内,请使用网页登录",loginType:"dingtalk"};await this.loadDingTalkSDK();const e=await this.getAuthCode();if(e){console.log("✅ 钉钉授权码获取成功:",e);return await this.completeDingTalkLogin(e,"dingtalk")}return{success:!1,error:"获取钉钉授权码失败",loginType:"dingtalk"}}catch(e){return console.error("❌ 钉钉免登录失败:",e),{success:!1,error:e.message||"钉钉免登录失败",loginType:"dingtalk"}}}async getAuthCode(){return new Promise(((e,o)=>{if(this.isInDingTalkApp())try{dd.requestAuthCode({corpId:this.config.corpId,clientId:this.config.clientId,onSuccess:o=>{console.log("📱 钉钉授权码获取成功:",o),e(o.code)},onFail:e=>{console.error("❌ 钉钉授权码获取失败:",e),o(new Error(e.errorMessage||"获取授权码失败"))}})}catch(n){if(console.error("❌ 钉钉JSAPI调用失败:",n),dd&&dd.ready)dd.ready((()=>{dd.getAuthCode({corpId:this.config.corpId,onSuccess:o=>{console.log("📱 钉钉授权码获取成功 (兼容模式):",o),e(o.code)},onFail:e=>{console.error("❌ 钉钉授权码获取失败 (兼容模式):",e),o(new Error(e.errorMessage||"获取授权码失败"))}})})),dd.error((e=>{console.error("❌ 钉钉SDK初始化失败:",e),o(new Error("钉钉SDK初始化失败"))}));else{const e=this.buildWebLoginUrl();console.log("📱 跳转到钉钉网页登录:",e),window.location.href=e,o(new Error("需要跳转到网页登录"))}}else o(new Error("不在钉钉环境内"))}))}async getUserInfoByDingTalkCode(e){console.log("🔄 使用钉钉免登授权码获取用户信息:",e);try{const o=await fetch(this.config.apiOauthDingtalk||"",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:this.config.clientId,code:e})}),n=await o.json();if(console.log("🔍 钉钉免登接口返回:",n),1===n.code){const{userInfo:e,sessionToken:o}=n.data;return{userId:e.objectId,username:e.username||e.nickname,nickname:e.nickname,openId:e.openId,unionId:e.unionId,avatar:e.avatar,email:e.email,mobile:e.mobile,corpId:this.config.corpId,sessionToken:o,rawUserInfo:e}}throw new Error(n.mess||"获取用户信息失败")}catch(e){throw console.error("❌ 调用钉钉免登接口失败:",e),e instanceof Error?e:new Error("网络请求失败")}}async getUserInfoByQRCode(e){console.log("🔄 使用二维码授权码获取用户信息:",e);try{const o=await fetch(this.config.apiOauthWeb||"",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:this.config.clientId,code:e,grantType:"authorization_code"})}),n=await o.json();if(console.log("🔍 OAuth2登录接口返回:",n),1===n.code){const{userInfo:e,tokenInfo:o,sessionToken:r}=n.data;return{userId:e.objectId,username:e.username||e.nick,nickname:e.nick||e.username,openId:e.openId,unionId:e.unionId,avatar:e.avatarUrl||e.avatar,email:e.email,mobile:e.mobile,corpId:this.config.corpId,sessionToken:r,tokenInfo:o,rawUserInfo:e}}throw new Error(n.mess||"获取用户信息失败")}catch(e){throw console.error("❌ 调用OAuth2登录接口失败:",e),e instanceof Error?e:new Error("网络请求失败")}}validateConfig(){const e=[];return this.config.clientId||e.push("Client ID 未配置"),this.config.corpId||e.push("Corp ID 未配置"),this.config.redirectUri?this.config.redirectUri.startsWith("http")||e.push("Redirect URI 格式不正确,应以 http 或 https 开头"):e.push("Redirect URI 未配置"),console.log("🔍 钉钉应用配置验证:",{clientId:this.config.clientId,corpId:this.config.corpId,redirectUri:this.config.redirectUri,agentId:this.config.agentId,errors:e,isValid:0===e.length}),{isValid:0===e.length,errors:e}}buildWebLoginUrl(e="nanchi_login"){const o=`https://login.dingtalk.com/oauth2/auth?${new URLSearchParams({client_id:this.config.clientId,response_type:"code",scope:"openid",state:e,redirect_uri:this.config.redirectUri,prompt:"consent"}).toString()}`;return console.log("🔗 构造钉钉网页登录URL:",o),o}initQRCodeLogin(e,o,n){console.log("📱 初始化二维码登录");const r=this.validateConfig();r.isValid?this.loadDingTalkSDK().then((()=>{const r={id:e,width:300,height:300},t={redirect_uri:encodeURIComponent(this.config.redirectUri),response_type:"code",client_id:this.config.clientId,scope:"openid",prompt:"consent",state:"nanchi_qr_login"};console.log("🔍 钉钉登录参数:",{clientId:this.config.clientId,corpId:this.config.corpId,redirectUri:this.config.redirectUri,redirectUriEncoded:encodeURIComponent(this.config.redirectUri),loginParams:t}),window.DTFrameLogin(r,t,(async e=>{console.log("✅ 二维码登录成功:",e);try{const r=await this.completeDingTalkLogin(e.authCode,"qrcode");r.success?o(r):n(r.error||"登录失败")}catch(e){console.error("❌ 二维码登录流程失败:",e),n(e.message||"登录失败")}}),(e=>{console.error("❌ 二维码登录失败:",e),n(e)}))})).catch((e=>{console.error("❌ 加载钉钉SDK失败:",e),n("加载钉钉SDK失败")})):n(`配置验证失败: ${r.errors.join(", ")}`)}async handleAuthCallback(e,o){try{if(console.log("🔄 处理网页登录回调:",{code:e,state:o}),!e)return{success:!1,error:"授权码缺失",loginType:"dingtalk"};return await this.completeDingTalkLogin(e,"dingtalk")}catch(e){return console.error("❌ 处理网页登录回调失败:",e),{success:!1,error:e.message||"处理登录回调失败",loginType:"dingtalk"}}}async webLogin(e,o){try{if(console.log("🔐 开始网页登录:",{username:e}),!e||!o)return{success:!1,error:"用户名或密码不能为空",loginType:"web"};console.log("🔄 调用Parse.User.logIn()进行用户登录...");const n=await Parse.User.logIn(e,o);console.log("✅ Parse用户登录成功:",n.id);const r=n.getSessionToken();return{success:!0,userInfo:{userId:n.id,username:n.get("username"),nickname:n.get("nickname")||n.get("username"),email:n.get("email"),mobile:n.get("mobile"),avatar:n.get("avatar"),sessionToken:r,parseUser:n,loginType:"web"},loginType:"web"}}catch(e){console.error("❌ 网页登录失败:",e);let o="登录失败,请重试";return 101===e.code?o="用户名或密码错误":200===e.code?o="连接服务器失败,请检查网络":e.message&&(o=e.message),{success:!1,error:o,loginType:"web"}}}setLogoutCallback(e){this.onLogoutCallback=e}async loginWithSessionToken(e){console.log("🔐 使用sessionToken完成Parse登录");try{const o=await Parse.User.become(e);return console.log("✅ Parse用户登录成功:",o.id),{parseUser:o,sessionToken:e,userId:o.id,username:o.get("username")}}catch(e){throw console.error("❌ Parse用户登录失败:",e),new Error("Parse用户登录失败: "+e.message)}}async completeDingTalkLogin(e,o="dingtalk"){try{let n;if(console.log("🚀 开始完整钉钉登录流程,类型:",o),"dingtalk"===o)n=await this.getUserInfoByDingTalkCode(e);else{if("qrcode"!==o)throw new Error("不支持的登录类型");n=await this.getUserInfoByQRCode(e)}if(n.sessionToken){const r=await this.loginWithSessionToken(n.sessionToken);return console.log("✅ 完整钉钉登录流程成功"),{success:!0,code:e,userInfo:{...n,parseUser:r.parseUser},loginType:o}}throw new Error("未获取到sessionToken,无法完成登录")}catch(e){return console.error("❌ 完整钉钉登录流程失败:",e),{success:!1,error:e.message,loginType:o}}}async logout(){console.log("🚪 用户退出登录"),Parse.User.logOut(),localStorage.removeItem("nanchi_user_info"),localStorage.removeItem("nanchi_auth_token"),localStorage.removeItem("nanchi_session_token"),localStorage.removeItem("nanchi_login_time"),console.log("🗑️ 本地存储已清除"),this.onLogoutCallback&&this.onLogoutCallback()}saveUserInfo(e){localStorage.setItem("nanchi_user_info",JSON.stringify(e)),localStorage.setItem("nanchi_login_time",Date.now().toString()),e.sessionToken&&localStorage.setItem("nanchi_session_token",e.sessionToken),console.log("💾 用户信息已保存到本地存储")}getUserInfo(){const e=localStorage.getItem("nanchi_user_info");return e?JSON.parse(e):null}isLoggedIn(){const e=this.getUserInfo(),o=localStorage.getItem("nanchi_login_time");if(!e||!o)return!1;return(Date.now()-parseInt(o))/36e5<24}async isParseUserLoggedIn(){try{return null!==Parse.User.current()}catch(e){return console.warn("检查Parse用户登录状态失败:",e),!1}}async getCurrentParseUser(){try{return Parse.User.current()}catch(e){return console.warn("获取当前Parse用户失败:",e),null}}}
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3NvY2lhbC9kaW5ndGFsay9kaW5ndGFsay1hdXRoLm1qcw==`
|
|
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/social/dingtalk/index.mjs
|
|
7
|
+
*/
|
|
8
|
+
export*from"./dingtalk-auth";
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3NvY2lhbC9kaW5ndGFsay9pbmRleC5tanM=`
|
|
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/social/dingtalk/interface.mjs
|
|
7
|
+
*/
|
|
8
|
+
export{};
|
|
9
|
+
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3NvY2lhbC9kaW5ndGFsay9pbnRlcmZhY2UubWpz`
|
|
10
|
+
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* 保留所有权利 All Rights Reserved.
|
|
6
6
|
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/social/index.mjs
|
|
7
7
|
*/
|
|
8
|
-
export*from"./wxwork/wxwork.corp";export*from"./wxwork/wxwork.sdk";export*from"./wxwork/wxwork.auth";
|
|
8
|
+
export*from"./wxwork/wxwork.corp";export*from"./wxwork/wxwork.sdk";export*from"./wxwork/wxwork.auth";export*from"./dingtalk";
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3NvY2lhbC9pbmRleC5tanM=`
|
|
10
10
|
|