@giteeteam/apps-proxima-api
Advanced tools
Comparing version 0.1.7 to 0.1.8
import { ItemObjectProps, WorkflowObjectProps, UserObjectProps, ancestorOption, returnFlag, RequestCoreResponse, SupportRequestMethod } from './types'; | ||
import { ParseObject } from '../parse/object'; | ||
import { ParseObjectSubclassType, ParseFileData } from '../parse/types'; | ||
import type { ParseObject } from '../parse/object'; | ||
import type { ParseObjectSubclassType, ParseFileData } from '../parse/types'; | ||
/** | ||
@@ -65,6 +65,5 @@ * 获取界面数据 | ||
* @param params 传入一个查询条件的对象 | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export declare const getData: (isAppClass: boolean, className: string, params: Record<string, any>, applicationId?: string) => Promise<Record<string, any>>; | ||
export declare const getData: (isAppClass: boolean, className: string, params: Record<string, any>) => Promise<Record<string, any>>; | ||
/** | ||
@@ -75,7 +74,13 @@ * 根据条件查询所有的值 | ||
* @param params 传入一个查询条件的对象 | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export declare const getAllData: (isAppClass: boolean, className: string, params: Record<string, any>, applicationId?: string) => Promise<Record<string, any>[]>; | ||
export declare const getAllData: (isAppClass: boolean, className: string, params: Record<string, any>) => Promise<Record<string, any>[]>; | ||
/** | ||
* 根据条件查询查询应用中心的数据表 | ||
* @param className | ||
* @param params 传入一个查询条件的对象 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export declare const getAppsData: (className: string, params: Record<string, any>) => Promise<any>; | ||
/** | ||
* 对外提供直接调用 core 接口能力,对外暴露 GET/POST/PUT/PATCH 方法 | ||
@@ -92,6 +97,5 @@ * @param method GET/POST/PUT/PATCH | ||
* @param className | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns | ||
*/ | ||
export declare const getParseQuery: (isAppClass: boolean, className: string, applicationId?: string) => import("../parse/query").default; | ||
export declare const getParseQuery: (isAppClass: boolean, className: string) => import("../parse/query").default; | ||
/** | ||
@@ -98,0 +102,0 @@ * 根据class名称获取parse对象。注意:只是parse对象简单实现,并不是真正的parse对象 |
import { workflow2Json, getCoreApi, postCoreApi, putCoreApi, patchCoreApi, getClassName } from './utils'; | ||
import Parse from '../parse'; | ||
import { QueryAction } from '../parse/constants'; | ||
import apps from '../apps'; | ||
/** | ||
@@ -277,4 +279,4 @@ * 获取界面数据 | ||
}; | ||
const getClassQuery = (isAppClass, className, params, applicationId) => { | ||
let classQuery = new Parse.Query(getClassName(isAppClass, className), applicationId); | ||
const getClassQuery = (isAppClass, className, params) => { | ||
let classQuery = new Parse.Query(getClassName(isAppClass, className)); | ||
//TODO 拼接查询条件 | ||
@@ -300,9 +302,8 @@ for (const key in params) { | ||
* @param params 传入一个查询条件的对象 | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export const getData = async (isAppClass, className, params, applicationId) => { | ||
export const getData = async (isAppClass, className, params) => { | ||
const [queryParams, context] = getParseContextFromParams(params); | ||
const { sessionToken } = global; | ||
const classQuery = getClassQuery(isAppClass, className, queryParams, applicationId); | ||
const classQuery = getClassQuery(isAppClass, className, queryParams); | ||
const res = await classQuery.first({ sessionToken, context }); | ||
@@ -316,12 +317,27 @@ return res; | ||
* @param params 传入一个查询条件的对象 | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export const getAllData = async (isAppClass, className, params, applicationId) => { | ||
export const getAllData = async (isAppClass, className, params) => { | ||
const [queryParams, context] = getParseContextFromParams(params); | ||
const { sessionToken } = global; | ||
const classQuery = getClassQuery(isAppClass, className, queryParams, applicationId); | ||
const classQuery = getClassQuery(isAppClass, className, queryParams); | ||
const res = await classQuery.findAll({ sessionToken, context }); | ||
return res; | ||
}; | ||
/** | ||
* 根据条件查询查询应用中心的数据表 | ||
* @param className | ||
* @param params 传入一个查询条件的对象 | ||
* @returns 返回的不是Parse对象,是Json格式数据 | ||
*/ | ||
export const getAppsData = async (className, params) => { | ||
const [queryParams] = getParseContextFromParams(params); | ||
const classQuery = getClassQuery(false, className, queryParams); | ||
return await apps.fetch({ | ||
className, | ||
operateStr: classQuery.toJSON(), | ||
action: QueryAction.First, | ||
opts: {}, | ||
}); | ||
}; | ||
// 调用 core 接口时,请求方式与具体方法的映射 | ||
@@ -355,7 +371,6 @@ const REQUEST_CORE_API_METHOD = { | ||
* @param className | ||
* @param applicationId 不传时默认当前租户,可以传proxima查询该库的数据 | ||
* @returns | ||
*/ | ||
export const getParseQuery = (isAppClass, className, applicationId) => { | ||
return new Parse.Query(getClassName(isAppClass, className), applicationId); | ||
export const getParseQuery = (isAppClass, className) => { | ||
return new Parse.Query(getClassName(isAppClass, className)); | ||
}; | ||
@@ -362,0 +377,0 @@ /** |
/* eslint-disable no-var */ | ||
import type { AxiosRequestConfig } from 'axios'; | ||
import type { ParseFileData, ObjectDestroyOptions, FileSaveOptions } from './parse/types'; | ||
import type { ParseFileData, ObjectDestroyOptions, FileSaveOptions, QueryResultOptions } from './parse/types'; | ||
import type { QueryAction } from './parse/constants'; | ||
export interface ParseQueryOptions { | ||
className: string; | ||
applicationId?: string; | ||
operateStr: string; | ||
action: string; | ||
opts: QueryResultOptions; | ||
} | ||
@@ -13,3 +15,2 @@ | ||
className: string; | ||
applicationId?: string; | ||
id: string; | ||
@@ -23,6 +24,12 @@ destroyOptions?: ObjectDestroyOptions; | ||
type?: string; | ||
applicationId?: string; | ||
saveOptions: FileSaveOptions; | ||
} | ||
export interface AppsFetchOptions { | ||
className: string; | ||
operateStr: string; | ||
action: QueryAction; | ||
opts: any; | ||
} | ||
declare global { | ||
@@ -41,4 +48,7 @@ var axios: (config: AxiosRequestConfig) => any; | ||
}; | ||
var apps: { | ||
fetch: (opts: AppsFetchOptions) => Promise<any>; | ||
}; | ||
} | ||
export {}; |
@@ -5,6 +5,5 @@ import type { Operate } from './types'; | ||
operateList: Operate[]; | ||
applicationId: string; | ||
constructor(className: string, applicationId?: string); | ||
constructor(className: string); | ||
protected enqueueOperate(name: string, args: any[]): void; | ||
protected operate(name: string, args: any[]): this; | ||
} |
export default class Base { | ||
constructor(className, applicationId) { | ||
constructor(className) { | ||
this.className = className; | ||
this.applicationId = applicationId || global.applicationId; | ||
this.operateList = []; | ||
@@ -6,0 +5,0 @@ } |
@@ -6,3 +6,2 @@ import type { ParseFileData, FileSaveOptions } from './types'; | ||
type?: string; | ||
applicationId: string; | ||
constructor(name: string, data: ParseFileData, type?: string); | ||
@@ -9,0 +8,0 @@ save(options: FileSaveOptions): Promise<{ |
@@ -6,3 +6,2 @@ export default class File { | ||
this.type = type; | ||
this.applicationId = global.applicationId; | ||
} | ||
@@ -14,3 +13,2 @@ async save(options) { | ||
type: this.type, | ||
applicationId: this.applicationId, | ||
saveOptions: options, | ||
@@ -17,0 +15,0 @@ }); |
@@ -6,4 +6,4 @@ import Base from './base'; | ||
id?: string; | ||
constructor(className: string, attributes?: Record<string, any>, applicationId?: string); | ||
static extend(className: string, applicationId?: string): typeof ParseObjectSubclassType; | ||
constructor(className: string, attributes?: Record<string, any>); | ||
static extend(className: string): typeof ParseObjectSubclassType; | ||
static saveAll(list: (ParseObject | ParseObjectSubclassType)[], opts?: Record<string, any>): Promise<ParseObject[]>; | ||
@@ -13,3 +13,2 @@ toSaveJSON(): { | ||
attributes: Record<string, any> | undefined; | ||
applicationId: string; | ||
operateStr: string; | ||
@@ -16,0 +15,0 @@ }; |
import Base from './base'; | ||
export class ParseObject extends Base { | ||
constructor(className, attributes, applicationId) { | ||
constructor(className, attributes) { | ||
var _a; | ||
super(className, applicationId); | ||
super(className); | ||
this.attributes = attributes; | ||
@@ -11,6 +11,6 @@ if ((_a = this.attributes) === null || _a === void 0 ? void 0 : _a.objectId) { | ||
} | ||
static extend(className, applicationId) { | ||
static extend(className) { | ||
class ParseObjectSubclass extends ParseObject { | ||
constructor(attributes) { | ||
super(className, attributes, applicationId); | ||
super(className, attributes); | ||
} | ||
@@ -42,3 +42,2 @@ static createWithoutData(id) { | ||
attributes: this.attributes, | ||
applicationId: this.applicationId, | ||
operateStr: JSON.stringify(this.operateList), | ||
@@ -51,3 +50,3 @@ }; | ||
clone() { | ||
const clone = new this.constructor(this.className, this.attributes, this.applicationId); | ||
const clone = new this.constructor(this.className, this.attributes); | ||
return clone; | ||
@@ -79,3 +78,2 @@ } | ||
className: this.className, | ||
applicationId: this.applicationId, | ||
id: this.id, | ||
@@ -82,0 +80,0 @@ destroyOptions, |
import Base from './base'; | ||
import type { QueryResultOptions } from './types'; | ||
export default class Query extends Base { | ||
constructor(className: string, applicationId?: string); | ||
constructor(className: string); | ||
containedIn(key: string, value: any): this; | ||
@@ -14,2 +14,3 @@ equalTo(key: string, value: any): this; | ||
limit(n: number): this; | ||
toJSON(): string; | ||
private result; | ||
@@ -19,2 +20,3 @@ find(opts: QueryResultOptions): Promise<any>; | ||
first(opts: QueryResultOptions): Promise<any>; | ||
count(opts: QueryResultOptions): Promise<any>; | ||
} |
import Base from './base'; | ||
import { QueryAction } from './constants'; | ||
export default class Query extends Base { | ||
constructor(className, applicationId) { | ||
super(className, applicationId); | ||
constructor(className) { | ||
super(className); | ||
} | ||
@@ -33,19 +34,25 @@ containedIn(key, value) { | ||
} | ||
result(name, args) { | ||
this.enqueueOperate(name, args); | ||
toJSON() { | ||
return JSON.stringify(this.operateList); | ||
} | ||
result(action, opts) { | ||
return global.parse.query({ | ||
className: this.className, | ||
applicationId: this.applicationId, | ||
operateStr: JSON.stringify(this.operateList), | ||
action, | ||
opts, | ||
}); | ||
} | ||
find(opts) { | ||
return this.result(this.find.name, [opts]); | ||
return this.result(QueryAction.Default, opts); | ||
} | ||
findAll(opts) { | ||
return this.result(this.findAll.name, [opts]); | ||
return this.result(QueryAction.All, opts); | ||
} | ||
first(opts) { | ||
return this.result(this.first.name, [opts]); | ||
return this.result(QueryAction.First, opts); | ||
} | ||
count(opts) { | ||
return this.result(QueryAction.Count, opts); | ||
} | ||
} |
{ | ||
"name": "@giteeteam/apps-proxima-api", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Giteeteam Apps API For Proxima", | ||
@@ -40,3 +40,4 @@ "keywords": [ | ||
"copyfiles": "^2.4.1" | ||
} | ||
}, | ||
"gitHead": "b9c916cc5d6b3ebcc552c3ee63941d2a397af596" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36741
27
1035