Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 6, 2022
2 parents 0f0c653 + 084f4a7 commit 9606f11
Show file tree
Hide file tree
Showing 674 changed files with 3,098 additions and 1,636 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
/ee/**/lib

.pnpm-lock.yaml


!/server/bundle/**/node_modules
4 changes: 2 additions & 2 deletions packages/accounts/src/server/accounts-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { generateAccessToken, generateRefreshToken, generateRandomToken } from '

import { emailTemplates, sendMail } from './utils/email';
import { ServerHooks } from './utils/server-hooks';

import { AccountsServerOptions } from './types/accounts-server-options';
import { JwtData } from './types/jwt-data';
import { EmailTemplateType } from './types/email-template-type';
Expand Down Expand Up @@ -271,7 +270,7 @@ export class AccountsServer {
name: user.name,
email: user.email
});

const spaces = await this.db.getMySpaces(user.id);
return {
sessionId,
token,
Expand All @@ -280,6 +279,7 @@ export class AccountsServer {
accessToken,
},
space,
spaces,
user,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: [email protected]
* @Date: 2022-03-28 09:35:34
* @LastEditors: [email protected]
* @LastEditTime: 2022-06-29 16:05:04
* @LastEditTime: 2022-12-05 09:08:08
* @Description:
*/
export interface ConnectionInformations {
Expand Down
8 changes: 8 additions & 0 deletions packages/accounts/src/types/types/login-result.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* @Author: [email protected]
* @Date: 2022-08-12 14:07:01
* @LastEditors: [email protected]
* @LastEditTime: 2022-12-05 09:09:03
* @Description:
*/
import { Tokens } from './tokens';

export interface LoginResult {
Expand All @@ -6,4 +13,5 @@ export interface LoginResult {
tokens: Tokens;
user: any;
space?: string;
spaces?: Array<any>
}
16 changes: 13 additions & 3 deletions packages/data-import/src/objectImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const objectql = require("@steedos/objectql");
const Fiber = require("fibers");
const moment = require("moment");
declare var Creator: any;
const auth = require("@steedos/auth");
declare var TAPi18n;

type ImportOptions = {
objectName: string;
Expand Down Expand Up @@ -783,9 +785,17 @@ export async function importWithExcelFile(file, options) {
}
);
}
let notificationBody = `总共导入${importResult.total_count}条记录;\n成功: ${importResult.success_count}条;\n失败: ${importResult.failure_count};`;

const userSession = await auth.getSessionByUserId(options.userSession.userId);
const locale = userSession?.locale;
const total_count = importResult.total_count;
const success_count = importResult.success_count;
const failure_count = importResult.failure_count;

// let notificationBody = `总共导入${importResult.total_count}条记录;\n成功: ${importResult.success_count}条;\n失败: ${importResult.failure_count};`;
let notificationBody = TAPi18n.__('queue_import_success_notification_body', {returnObjects: true, total_count,success_count,failure_count }, locale);
if (importResult.errorList && importResult.errorList.length > 0) {
notificationBody = `${notificationBody}\n错误信息: ${importResult.errorList.join(
notificationBody = `${notificationBody}\n${TAPi18n.__('queue_import_error_info', {returnObjects: true}, locale)}: ${importResult.errorList.join(
"\n "
)}`;
}
Expand All @@ -794,7 +804,7 @@ export async function importWithExcelFile(file, options) {
return Fiber(function() {
Creator.addNotifications(
{
name: `导入完成: ${file.original.name}`,
name: `${TAPi18n.__('queue_import_tips', {returnObjects: true}, locale)}: ${file.original.name}`,
body: notificationBody,
related_to: {
o: "queue_import_history",
Expand Down
7 changes: 4 additions & 3 deletions packages/objectql/src/services/helpers/graphql/consts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: [email protected]
* @Date: 2022-06-20 19:02:47
* @LastEditors: sunhaolin@hotoa.com
* @LastEditTime: 2022-10-20 11:25:29
* @LastEditors: baozhoutao@steedos.com
* @LastEditTime: 2022-12-06 09:56:31
* @Description:
*/

Expand All @@ -23,4 +23,5 @@ export const EXPAND_SUFFIX = '__expand';
export const DISPLAY_PREFIX = '_display';
export const UI_PREFIX = '_ui';
export const RELATED_PREFIX = '_related';
export const GRAPHQL_ACTION_PREFIX = 'graphql_';
export const GRAPHQL_ACTION_PREFIX = 'graphql_';
export const PERMISSIONS_PREFIX = '_permissions';
89 changes: 86 additions & 3 deletions packages/objectql/src/services/helpers/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: [email protected]
* @Date: 2022-06-15 15:49:44
* @LastEditors: sunhaolin@hotoa.com
* @LastEditTime: 2022-11-07 20:55:13
* @LastEditors: baozhoutao@steedos.com
* @LastEditTime: 2022-12-06 10:31:30
* @Description:
*/

Expand All @@ -17,7 +17,7 @@ import { getSteedosSchema, getUserLocale } from '../../..';
import { getQueryFields } from "./getQueryFields";
import { getPrimaryFieldType } from "./getPrimaryFieldType";

import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX } from "./consts";
import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX, PERMISSIONS_PREFIX } from "./consts";

export function generateActionGraphqlProp(actionName: string, objectConfig: SteedosObjectTypeConfig) {
let gplObj: any = {};
Expand Down Expand Up @@ -76,6 +76,26 @@ export function generateActionGraphqlProp(actionName: string, objectConfig: Stee
return gplObj;
}

const callObjectServiceAction = async function(actionName, userSession, data?){
const broker = getSteedosSchema().broker;
return broker.call(actionName, data, { meta: { user: userSession}})
}

const formatFileSize = function(fileSize) {
var rev, unit;
rev = fileSize / 1024.00;
unit = 'KB';
if (rev > 1024.00) {
rev = rev / 1024.00;
unit = 'MB';
}
if (rev > 1024.00) {
rev = rev / 1024.00;
unit = 'GB';
}
return rev.toFixed(2) + unit;
};

export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) {
let objectName = objectConfig.name;
let fields = objectConfig.fields;
Expand Down Expand Up @@ -194,6 +214,27 @@ export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) {
${type}
`;

// _permissions
let _permissions_type_name = `${PERMISSIONS_PREFIX}_${objectName}`;
type += `${PERMISSIONS_PREFIX}: ${_permissions_type_name} `;
resolvers[objectName][PERMISSIONS_PREFIX] = {
action: `${getObjectServiceName(
objectName
)}.${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`,
rootParams: {
_id: "_id"
},
params: {
'__objectName': objectName
},
};
// define _permissions_type
let _permissions_type = _getPermissionsType(_permissions_type_name, fields);
type = gql`
${_permissions_type}
${type}
`;

// _related
if (objectConfig.enable_files) {
let relatedObjName = "cms_files";
Expand Down Expand Up @@ -478,6 +519,17 @@ export function getGraphqlActions(objectConfig: SteedosObjectTypeConfig) {
},
};

actions[`${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`] = {
handler: async function (ctx) {
let params = ctx.params;
let { __objectName } = params;
let userSession = ctx.meta.user;
return await callObjectServiceAction(`@${__objectName}.getRecordPermissionsById`, userSession, {
recordId: params._id
});;
},
};

return actions;
}

Expand Down Expand Up @@ -988,6 +1040,8 @@ async function translateToUI(objectName, doc, userSession: any, selectorFieldNam
}
}
displayObj[name] = fileValue;
}else if(fType == "filesize"){
displayObj[name] = formatFileSize(doc[name]);
} else {
displayObj[name] = formatBasicFieldValue(fType, field, doc[name], objConfig, userSession);
}
Expand Down Expand Up @@ -1049,6 +1103,35 @@ function _getUIType(typeName, fields) {
return type;
}

function _getPermissionsType(typeName, fields) {
return `
type ${typeName} {
allowCreate: Boolean
allowCreateFiles: Boolean
allowDelete: Boolean
allowDeleteFiles: Boolean
allowEdit: Boolean
allowEditFiles: Boolean
allowRead: Boolean
allowReadFiles: Boolean
disabled_actions: [String]
disabled_list_views: [String]
field_permissions: JSON
modifyAllFiles: Boolean
modifyAllRecords: Boolean
modifyAssignCompanysRecords: [String]
modifyCompanyRecords: Boolean
uneditable_fields: [String]
unreadable_fields: [String]
unrelated_objects: [String]
viewAllFiles: Boolean
viewAllRecords: Boolean
viewAssignCompanysRecords: [String]
viewCompanyRecords: Boolean
}
`
}

// 获取object元数据
export function getLocalService(objectApiName: string) {
let steedosSchema = getSteedosSchema();
Expand Down
8 changes: 5 additions & 3 deletions packages/objectql/src/types/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ export class SteedosObjectType extends SteedosObjectProperties {
if ('modifyAssignCompanysRecords' === k) {
if (!_.isEmpty(_v) && _.isArray(_v)) {
userObjectPermission['viewAssignCompanysRecords'].push(..._v);
// 去重
userObjectPermission['viewAssignCompanysRecords'] = _.uniq(userObjectPermission['viewAssignCompanysRecords'])
}
}
if (!_.isEmpty(_v) && _.isArray(_v)) {
Expand Down Expand Up @@ -1743,8 +1745,8 @@ export class SteedosObjectType extends SteedosObjectProperties {
}
else {
if (userSession) {
let _records = returnValue
if (method == 'findOne' && returnValue) {
let _records = values
if (method == 'findOne' && values) {
_records = [_records]
}
await this.appendRecordPermission(_records, userSession);
Expand Down Expand Up @@ -1905,7 +1907,7 @@ export class SteedosObjectType extends SteedosObjectProperties {

// 指定公司权限
let viewAssignCompanysRecordsFilter = [];
if (objPm.viewAssignCompanysRecords) {
if (!objPm.viewAllRecords && objPm.viewAssignCompanysRecords) {
_.each(objPm.viewAssignCompanysRecords, (assignCompanyId) => {
viewAssignCompanysRecordsFilter.push(`((company_id eq '${assignCompanyId}') or (company_ids eq '${assignCompanyId}'))`)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/process/src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const sendNotifications = async (from: string, to: string, {instanceHisto
ids: [linkToId]
},
related_name: relatedDocName,
from: `Process ${status}`,
from: from,
space: instance.space
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ actions:
downloadTemplate:
label: Download Template
CustomLabels:
queue_import_download: Download
queue_import_form_field_mapping_prompt: "Indicates that the data uniqueness field {$label} does not exist in the field mapping. Please configure it."
queue_import_tips: Import complete
queue_import_success_notification_body: "A total of {$total_count} records are imported; \n Success: {$total_count}; \n Failed: {$failure_count};"
queue_import_error_info: "Error message"
queue_import_action_import_execute_success: Executed
queue_import_action_import_need_file: Upload excel file, please.
queue_import_action_import_just_need_one_file: Just need one file.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ actions:
downloadTemplate:
label: 下载模板
CustomLabels:
queue_import_download: 下载
queue_import_form_field_mapping_prompt: "表示数据唯一性字段 {$label} 在字段映射中不存在,请配置。"
queue_import_tips: 导入完成
queue_import_success_notification_body: "总共导入{$total_count}条记录;\n成功: {$success_count}条;\n失败: {$failure_count};"
queue_import_error_info: "错误信息"
queue_import_action_import_execute_success: 已执行
queue_import_action_import_need_file: 请上传Excel文件
queue_import_action_import_just_need_one_file: 只需上传一个文件
Loading

0 comments on commit 9606f11

Please sign in to comment.