本文整理汇总了TypeScript中tyranid.Tyr.parseUid方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tyr.parseUid方法的具体用法?TypeScript Tyr.parseUid怎么用?TypeScript Tyr.parseUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tyranid.Tyr
的用法示例。
在下文中一共展示了Tyr.parseUid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: validate
export function validate(plugin: GraclPlugin, uid: string) {
try {
Tyr.parseUid(uid);
} catch (err) {
if (
/must be a single String of 12 bytes or a string of 24 hex characters/.test(
err.message
)
) {
plugin.error(`Invalid uid: ${uid}`);
}
throw err;
}
}
示例2: extractIdAndModel
export function extractIdAndModel(
plugin: GraclPlugin,
doc: Tyr.Document | string
) {
if (typeof doc === 'string') {
validate(plugin, doc);
const components: { [key: string]: {} } = Tyr.parseUid(doc) || {};
return {
$uid: doc as string,
$model: components.collection as Tyr.CollectionInstance
};
} else {
validate(plugin, doc.$uid);
return {
$uid: doc.$uid as string,
$model: doc.$model
};
}
}
示例3: query
//.........这里部分代码省略.........
} else {
debugSubjectGraph.set(node.getId(), []);
}
}
}
// extract all collections that have a relevant permission set for the requested resource
for (const resource of resourceArray) {
const { collection, resourcePermissions } = resource;
const collectionName = collection.def.name;
const isQueriedCollection = queriedCollectionName === collectionName;
let queryRestrictionSet = false;
if (
queriedCollectionLinkFields.has(collectionName) ||
isQueriedCollection
) {
const permissionArray = [...resourcePermissions.values()];
for (const permission of permissionArray) {
const result = getAccess(permission);
switch (result.access) {
// access needs to be exactly true or false
case true:
case false:
const key = result.access ? 'positive' : 'negative';
const uid = permission.resourceId;
// if a permission was set by a collection of higher depth, keep it...
if (alreadySet.has(uid)) {
continue;
} else {
alreadySet.add(uid);
}
const resourceObjectId = Tyr.parseUid(uid).id;
if (debug) {
(result.access ? debugGraphPositive : debugGraphNegative).set(
resourceObjectId.toString(),
{
permission: permission.$id as ObjectID,
subjectId: permission.subjectId,
collectionName: permission.resourceType,
...result
}
);
}
const accessSet = queryMaps[key].get(collectionName) || new Set();
if (!queryMaps[key].has(collectionName)) {
queryMaps[key].set(collectionName, accessSet);
}
accessSet.add(resourceObjectId as string);
break;
}
queryRestrictionSet = true;
}
} else {
// otherwise, we need determine how to restricting a query of this object by
// permissions concerning parents of this object...
/**
Example:
SETUP: want to query for all posts from database, have permissions
set for access to posts on posts, blogs, and organizations...
- for the permissions set on posts specifically, we can just add something like...