@tachybase/plugin-sub-accounts 0.23.8

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.
Files changed (52) hide show
  1. package/.turbo/turbo-build.log +30 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +7 -0
  6. package/dist/client/index.js +1 -0
  7. package/dist/externalVersion.js +9 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +39 -0
  10. package/dist/node_modules/minimatch/LICENSE +15 -0
  11. package/dist/node_modules/minimatch/lib/path.js +4 -0
  12. package/dist/node_modules/minimatch/minimatch.js +1 -0
  13. package/dist/node_modules/minimatch/package.json +1 -0
  14. package/dist/server/acl/RoleActionParamsMerge.d.ts +4 -0
  15. package/dist/server/acl/RoleActionParamsMerge.js +42 -0
  16. package/dist/server/acl/RoleSnippets.d.ts +9 -0
  17. package/dist/server/acl/RoleSnippets.js +127 -0
  18. package/dist/server/acl/RoleStrategy.d.ts +19 -0
  19. package/dist/server/acl/RoleStrategy.js +84 -0
  20. package/dist/server/addMergeRoles.d.ts +5 -0
  21. package/dist/server/addMergeRoles.js +46 -0
  22. package/dist/server/collections/roles.d.ts +2 -0
  23. package/dist/server/collections/roles.js +37 -0
  24. package/dist/server/collections/users.d.ts +2 -0
  25. package/dist/server/collections/users.js +37 -0
  26. package/dist/server/hooks/index.d.ts +5 -0
  27. package/dist/server/hooks/index.js +29 -0
  28. package/dist/server/hooks/merge-role-create.d.ts +6 -0
  29. package/dist/server/hooks/merge-role-create.js +34 -0
  30. package/dist/server/hooks/refresh-datasources.d.ts +8 -0
  31. package/dist/server/hooks/refresh-datasources.js +43 -0
  32. package/dist/server/hooks/source-role-destroy.d.ts +6 -0
  33. package/dist/server/hooks/source-role-destroy.js +46 -0
  34. package/dist/server/hooks/source-role-update.d.ts +6 -0
  35. package/dist/server/hooks/source-role-update.js +57 -0
  36. package/dist/server/hooks/user-change-roles.d.ts +9 -0
  37. package/dist/server/hooks/user-change-roles.js +55 -0
  38. package/dist/server/hooks/user-create.d.ts +2 -0
  39. package/dist/server/hooks/user-create.js +38 -0
  40. package/dist/server/index.d.ts +1 -0
  41. package/dist/server/index.js +33 -0
  42. package/dist/server/middlewares/change-user-roles.d.ts +8 -0
  43. package/dist/server/middlewares/change-user-roles.js +66 -0
  44. package/dist/server/middlewares/set-self-role.d.ts +2 -0
  45. package/dist/server/middlewares/set-self-role.js +54 -0
  46. package/dist/server/model/MergeRoleModel.d.ts +49 -0
  47. package/dist/server/model/MergeRoleModel.js +205 -0
  48. package/dist/server/plugin.d.ts +11 -0
  49. package/dist/server/plugin.js +85 -0
  50. package/package.json +24 -0
  51. package/server.d.ts +2 -0
  52. package/server.js +1 -0
@@ -0,0 +1,30 @@
1
+
2
+ 
3
+ > @tachybase/plugin-sub-accounts@0.23.7 build /Users/seal/Documents/projects/tachybase/packages/plugin-sub-accounts
4
+ > tachybase-build --no-dts @tachybase/plugin-sub-accounts
5
+
6
+ node:internal/modules/cjs/loader:1228
7
+ throw err;
8
+ ^
9
+
10
+ Error: Cannot find module '../lib'
11
+ Require stack:
12
+ - /Users/seal/Documents/projects/tachybase/apps/build/bin/tachybase-build.js
13
+  at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
14
+  at Module._load (node:internal/modules/cjs/loader:1051:27)
15
+  at Module.require (node:internal/modules/cjs/loader:1311:19)
16
+  at require (node:internal/modules/helpers:179:18)
17
+ at Object.<anonymous> (/Users/seal/Documents/projects/tachybase/apps/build/bin/tachybase-build.js:7:19)
18
+  at Module._compile (node:internal/modules/cjs/loader:1469:14)
19
+  at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
20
+  at Module.load (node:internal/modules/cjs/loader:1288:32)
21
+  at Module._load (node:internal/modules/cjs/loader:1104:12)
22
+  at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {
23
+ code: 'MODULE_NOT_FOUND',
24
+ requireStack: [
25
+ '/Users/seal/Documents/projects/tachybase/apps/build/bin/tachybase-build.js'
26
+ ]
27
+ }
28
+
29
+ Node.js v20.18.0
30
+  ELIFECYCLE  Command failed with exit code 1.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @tachybase/plugin-sub-accounts
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,7 @@
1
+ import { Plugin } from '@tachybase/client';
2
+ export declare class PluginSubAccountsClient extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ }
7
+ export default PluginSubAccountsClient;
@@ -0,0 +1 @@
1
+ (function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("@tachybase/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e["@tachybase/plugin-sub-accounts"]={},e["@tachybase/client"]))})(this,function(e,n){"use strict";var s=(e,n,t)=>new Promise((o,a)=>{var l=i=>{try{u(t.next(i))}catch(c){a(c)}},d=i=>{try{u(t.throw(i))}catch(c){a(c)}},u=i=>i.done?o(i.value):Promise.resolve(i.value).then(l,d);u((t=t.apply(e,n)).next())});class t extends n.Plugin{afterAdd(){return s(this,null,function*(){})}beforeLoad(){return s(this,null,function*(){})}load(){return s(this,null,function*(){console.log(this.app)})}}e.PluginSubAccountsClient=t,e.default=t,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ "@tachybase/client": "0.23.8",
3
+ "@tachybase/server": "0.23.8",
4
+ "@tachybase/acl": "0.23.8",
5
+ "@tachybase/utils": "0.23.8",
6
+ "@tachybase/database": "0.23.8",
7
+ "@tachybase/actions": "0.23.8",
8
+ "@tachybase/module-acl": "0.23.8"
9
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,4 @@
1
+ const isWindows = typeof process === 'object' &&
2
+ process &&
3
+ process.platform === 'win32'
4
+ module.exports = isWindows ? { sep: '\\' } : { sep: '/' }
@@ -0,0 +1 @@
1
+ (function(){var t={127:function(t){"use strict";t.exports=balanced;function balanced(t,e,r){if(t instanceof RegExp)t=maybeMatch(t,r);if(e instanceof RegExp)e=maybeMatch(e,r);var n=range(t,e,r);return n&&{start:n[0],end:n[1],pre:r.slice(0,n[0]),body:r.slice(n[0]+t.length,n[1]),post:r.slice(n[1]+e.length)}}function maybeMatch(t,e){var r=e.match(t);return r?r[0]:null}balanced.range=range;function range(t,e,r){var n,s,i,a,o;var c=r.indexOf(t);var l=r.indexOf(e,c+1);var h=c;if(c>=0&&l>0){if(t===e){return[c,l]}n=[];i=r.length;while(h>=0&&!o){if(h==c){n.push(h);c=r.indexOf(t,h+1)}else if(n.length==1){o=[n.pop(),l]}else{s=n.pop();if(s<i){i=s;a=l}l=r.indexOf(e,h+1)}h=c<l&&c>=0?c:l}if(n.length){o=[i,a]}}return o}},83:function(t,e,r){var n=r(127);t.exports=expandTop;var s="\0SLASH"+Math.random()+"\0";var i="\0OPEN"+Math.random()+"\0";var a="\0CLOSE"+Math.random()+"\0";var o="\0COMMA"+Math.random()+"\0";var c="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(s).split("\\{").join(i).split("\\}").join(a).split("\\,").join(o).split("\\.").join(c)}function unescapeBraces(t){return t.split(s).join("\\").split(i).join("{").split(a).join("}").split(o).join(",").split(c).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[];var r=n("{","}",t);if(!r)return t.split(",");var s=r.pre;var i=r.body;var a=r.post;var o=s.split(",");o[o.length-1]+="{"+i+"}";var c=parseCommaParts(a);if(a.length){o[o.length-1]+=c.shift();o.push.apply(o,c)}e.push.apply(e,o);return e}function expandTop(t){if(!t)return[];if(t.substr(0,2)==="{}"){t="\\{\\}"+t.substr(2)}return expand(escapeBraces(t),true).map(unescapeBraces)}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[];var s=n("{","}",t);if(!s)return[t];var i=s.pre;var o=s.post.length?expand(s.post,false):[""];if(/\$$/.test(s.pre)){for(var c=0;c<o.length;c++){var l=i+"{"+s.body+"}"+o[c];r.push(l)}}else{var h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body);var p=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body);var f=h||p;var u=s.body.indexOf(",")>=0;if(!f&&!u){if(s.post.match(/,.*\}/)){t=s.pre+"{"+s.body+a+s.post;return expand(t)}return[t]}var g;if(f){g=s.body.split(/\.\./)}else{g=parseCommaParts(s.body);if(g.length===1){g=expand(g[0],false).map(embrace);if(g.length===1){return o.map((function(t){return s.pre+g[0]+t}))}}}var d;if(f){var b=numeric(g[0]);var v=numeric(g[1]);var x=Math.max(g[0].length,g[1].length);var y=g.length==3?Math.abs(numeric(g[2])):1;var w=lte;var _=v<b;if(_){y*=-1;w=gte}var j=g.some(isPadded);d=[];for(var E=b;w(E,v);E+=y){var M;if(p){M=String.fromCharCode(E);if(M==="\\")M=""}else{M=String(E);if(j){var O=x-M.length;if(O>0){var k=new Array(O+1).join("0");if(E<0)M="-"+k+M.slice(1);else M=k+M}}}d.push(M)}}else{d=[];for(var $=0;$<g.length;$++){d.push.apply(d,expand(g[$],false))}}for(var $=0;$<d.length;$++){for(var c=0;c<o.length;c++){var l=i+d[$]+o[c];if(!e||f||l)r.push(l)}}}return r}},697:function(t){const e=typeof process==="object"&&process&&process.platform==="win32";t.exports=e?{sep:"\\"}:{sep:"/"}},388:function(t,e,r){const n=t.exports=(t,e,r={})=>{assertValidPattern(e);if(!r.nocomment&&e.charAt(0)==="#"){return false}return new Minimatch(e,r).match(t)};t.exports=n;const s=r(697);n.sep=s.sep;const i=Symbol("globstar **");n.GLOBSTAR=i;const a=r(83);const o={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};const c="[^/]";const l=c+"*?";const h="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";const p="(?:(?!(?:\\/|^)\\.).)*?";const charSet=t=>t.split("").reduce(((t,e)=>{t[e]=true;return t}),{});const f=charSet("().*{}+?[]^$\\!");const u=charSet("[.(");const g=/\/+/;n.filter=(t,e={})=>(r,s,i)=>n(r,t,e);const ext=(t,e={})=>{const r={};Object.keys(t).forEach((e=>r[e]=t[e]));Object.keys(e).forEach((t=>r[t]=e[t]));return r};n.defaults=t=>{if(!t||typeof t!=="object"||!Object.keys(t).length){return n}const e=n;const m=(r,n,s)=>e(r,n,ext(t,s));m.Minimatch=class Minimatch extends e.Minimatch{constructor(e,r){super(e,ext(t,r))}};m.Minimatch.defaults=r=>e.defaults(ext(t,r)).Minimatch;m.filter=(r,n)=>e.filter(r,ext(t,n));m.defaults=r=>e.defaults(ext(t,r));m.makeRe=(r,n)=>e.makeRe(r,ext(t,n));m.braceExpand=(r,n)=>e.braceExpand(r,ext(t,n));m.match=(r,n,s)=>e.match(r,n,ext(t,s));return m};n.braceExpand=(t,e)=>braceExpand(t,e);const braceExpand=(t,e={})=>{assertValidPattern(t);if(e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)){return[t]}return a(t)};const d=1024*64;const assertValidPattern=t=>{if(typeof t!=="string"){throw new TypeError("invalid pattern")}if(t.length>d){throw new TypeError("pattern is too long")}};const b=Symbol("subparse");n.makeRe=(t,e)=>new Minimatch(t,e||{}).makeRe();n.match=(t,e,r={})=>{const n=new Minimatch(e,r);t=t.filter((t=>n.match(t)));if(n.options.nonull&&!t.length){t.push(e)}return t};const globUnescape=t=>t.replace(/\\(.)/g,"$1");const charUnescape=t=>t.replace(/\\([^-\]])/g,"$1");const regExpEscape=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");const braExpEscape=t=>t.replace(/[[\]\\]/g,"\\$&");class Minimatch{constructor(t,e){assertValidPattern(t);if(!e)e={};this.options=e;this.set=[];this.pattern=t;this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===false;if(this.windowsPathsNoEscape){this.pattern=this.pattern.replace(/\\/g,"/")}this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.partial=!!e.partial;this.make()}debug(){}make(){const t=this.pattern;const e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=true;return}if(!t){this.empty=true;return}this.parseNegate();let r=this.globSet=this.braceExpand();if(e.debug)this.debug=(...t)=>console.error(...t);this.debug(this.pattern,r);r=this.globParts=r.map((t=>t.split(g)));this.debug(this.pattern,r);r=r.map(((t,e,r)=>t.map(this.parse,this)));this.debug(this.pattern,r);r=r.filter((t=>t.indexOf(false)===-1));this.debug(this.pattern,r);this.set=r}parseNegate(){if(this.options.nonegate)return;const t=this.pattern;let e=false;let r=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++){e=!e;r++}if(r)this.pattern=t.slice(r);this.negate=e}matchOne(t,e,r){var n=this.options;this.debug("matchOne",{this:this,file:t,pattern:e});this.debug("matchOne",t.length,e.length);for(var s=0,a=0,o=t.length,c=e.length;s<o&&a<c;s++,a++){this.debug("matchOne loop");var l=e[a];var h=t[s];this.debug(e,l,h);if(l===false)return false;if(l===i){this.debug("GLOBSTAR",[e,l,h]);var p=s;var f=a+1;if(f===c){this.debug("** at the end");for(;s<o;s++){if(t[s]==="."||t[s]===".."||!n.dot&&t[s].charAt(0)===".")return false}return true}while(p<o){var u=t[p];this.debug("\nglobstar while",t,p,e,f,u);if(this.matchOne(t.slice(p),e.slice(f),r)){this.debug("globstar found match!",p,o,u);return true}else{if(u==="."||u===".."||!n.dot&&u.charAt(0)==="."){this.debug("dot detected!",t,p,e,f);break}this.debug("globstar swallow a segment, and continue");p++}}if(r){this.debug("\n>>> no match, partial?",t,p,e,f);if(p===o)return true}return false}var g;if(typeof l==="string"){g=h===l;this.debug("string match",l,h,g)}else{g=h.match(l);this.debug("pattern match",l,h,g)}if(!g)return false}if(s===o&&a===c){return true}else if(s===o){return r}else if(a===c){return s===o-1&&t[s]===""}throw new Error("wtf?")}braceExpand(){return braceExpand(this.pattern,this.options)}parse(t,e){assertValidPattern(t);const r=this.options;if(t==="**"){if(!r.noglobstar)return i;else t="*"}if(t==="")return"";let n="";let s=false;let a=false;const h=[];const p=[];let g;let d=false;let v=-1;let x=-1;let y;let w;let _;let j=t.charAt(0)===".";let E=r.dot||j;const patternStart=()=>j?"":E?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";const subPatternStart=t=>t.charAt(0)==="."?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";const clearStateChar=()=>{if(g){switch(g){case"*":n+=l;s=true;break;case"?":n+=c;s=true;break;default:n+="\\"+g;break}this.debug("clearStateChar %j %j",g,n);g=false}};for(let e=0,i;e<t.length&&(i=t.charAt(e));e++){this.debug("%s\t%s %s %j",t,e,n,i);if(a){if(i==="/"){return false}if(f[i]){n+="\\"}n+=i;a=false;continue}switch(i){case"/":{return false}case"\\":if(d&&t.charAt(e+1)==="-"){n+=i;continue}clearStateChar();a=true;continue;case"?":case"*":case"+":case"@":case"!":this.debug("%s\t%s %s %j <-- stateChar",t,e,n,i);if(d){this.debug(" in class");if(i==="!"&&e===x+1)i="^";n+=i;continue}this.debug("call clearStateChar %j",g);clearStateChar();g=i;if(r.noext)clearStateChar();continue;case"(":{if(d){n+="(";continue}if(!g){n+="\\(";continue}const r={type:g,start:e-1,reStart:n.length,open:o[g].open,close:o[g].close};this.debug(this.pattern,"\t",r);h.push(r);n+=r.open;if(r.start===0&&r.type!=="!"){j=true;n+=subPatternStart(t.slice(e+1))}this.debug("plType %j %j",g,n);g=false;continue}case")":{const t=h[h.length-1];if(d||!t){n+="\\)";continue}h.pop();clearStateChar();s=true;w=t;n+=w.close;if(w.type==="!"){p.push(Object.assign(w,{reEnd:n.length}))}continue}case"|":{const r=h[h.length-1];if(d||!r){n+="\\|";continue}clearStateChar();n+="|";if(r.start===0&&r.type!=="!"){j=true;n+=subPatternStart(t.slice(e+1))}continue}case"[":clearStateChar();if(d){n+="\\"+i;continue}d=true;x=e;v=n.length;n+=i;continue;case"]":if(e===x+1||!d){n+="\\"+i;continue}y=t.substring(x+1,e);try{RegExp("["+braExpEscape(charUnescape(y))+"]");n+=i}catch(t){n=n.substring(0,v)+"(?:$.)"}s=true;d=false;continue;default:clearStateChar();if(f[i]&&!(i==="^"&&d)){n+="\\"}n+=i;break}}if(d){y=t.slice(x+1);_=this.parse(y,b);n=n.substring(0,v)+"\\["+_[0];s=s||_[1]}for(w=h.pop();w;w=h.pop()){let t;t=n.slice(w.reStart+w.open.length);this.debug("setting tail",n,w);t=t.replace(/((?:\\{2}){0,64})(\\?)\|/g,((t,e,r)=>{if(!r){r="\\"}return e+e+r+"|"}));this.debug("tail=%j\n %s",t,t,w,n);const e=w.type==="*"?l:w.type==="?"?c:"\\"+w.type;s=true;n=n.slice(0,w.reStart)+e+"\\("+t}clearStateChar();if(a){n+="\\\\"}const M=u[n.charAt(0)];for(let t=p.length-1;t>-1;t--){const r=p[t];const s=n.slice(0,r.reStart);const i=n.slice(r.reStart,r.reEnd-8);let a=n.slice(r.reEnd);const o=n.slice(r.reEnd-8,r.reEnd)+a;const c=s.split(")").length;const l=s.split("(").length-c;let h=a;for(let t=0;t<l;t++){h=h.replace(/\)[+*?]?/,"")}a=h;const f=a===""&&e!==b?"(?:$|\\/)":"";n=s+i+a+f+o}if(n!==""&&s){n="(?=.)"+n}if(M){n=patternStart()+n}if(e===b){return[n,s]}if(r.nocase&&!s){s=t.toUpperCase()!==t.toLowerCase()}if(!s){return globUnescape(t)}const O=r.nocase?"i":"";try{return Object.assign(new RegExp("^"+n+"$",O),{_glob:t,_src:n})}catch(t){return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;const t=this.set;if(!t.length){this.regexp=false;return this.regexp}const e=this.options;const r=e.noglobstar?l:e.dot?h:p;const n=e.nocase?"i":"";let s=t.map((t=>{t=t.map((t=>typeof t==="string"?regExpEscape(t):t===i?i:t._src)).reduce(((t,e)=>{if(!(t[t.length-1]===i&&e===i)){t.push(e)}return t}),[]);t.forEach(((e,n)=>{if(e!==i||t[n-1]===i){return}if(n===0){if(t.length>1){t[n+1]="(?:\\/|"+r+"\\/)?"+t[n+1]}else{t[n]=r}}else if(n===t.length-1){t[n-1]+="(?:\\/|"+r+")?"}else{t[n-1]+="(?:\\/|\\/"+r+"\\/)"+t[n+1];t[n+1]=i}}));return t.filter((t=>t!==i)).join("/")})).join("|");s="^(?:"+s+")$";if(this.negate)s="^(?!"+s+").*$";try{this.regexp=new RegExp(s,n)}catch(t){this.regexp=false}return this.regexp}match(t,e=this.partial){this.debug("match",t,this.pattern);if(this.comment)return false;if(this.empty)return t==="";if(t==="/"&&e)return true;const r=this.options;if(s.sep!=="/"){t=t.split(s.sep).join("/")}t=t.split(g);this.debug(this.pattern,"split",t);const n=this.set;this.debug(this.pattern,"set",n);let i;for(let e=t.length-1;e>=0;e--){i=t[e];if(i)break}for(let s=0;s<n.length;s++){const a=n[s];let o=t;if(r.matchBase&&a.length===1){o=[i]}const c=this.matchOne(o,a,e);if(c){if(r.flipNegate)return true;return!this.negate}}if(r.flipNegate)return false;return this.negate}static defaults(t){return n.defaults(t).Minimatch}}n.Minimatch=Minimatch}};var e={};function __nccwpck_require__(r){var n=e[r];if(n!==undefined){return n.exports}var s=e[r]={exports:{}};var i=true;try{t[r](s,s.exports,__nccwpck_require__);i=false}finally{if(i)delete e[r]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(388);module.exports=r})();
@@ -0,0 +1 @@
1
+ {"author":"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)","name":"minimatch","description":"a glob matcher in javascript","publishConfig":{"tag":"legacy-v5"},"version":"5.1.6","repository":{"type":"git","url":"git://github.com/isaacs/minimatch.git"},"main":"minimatch.js","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"engines":{"node":">=10"},"dependencies":{"brace-expansion":"^2.0.1"},"devDependencies":{"tap":"^16.3.2"},"license":"ISC","files":["minimatch.js","lib"],"_lastModified":"2024-12-22T16:07:15.419Z"}
@@ -0,0 +1,4 @@
1
+ import { RoleActionParams } from '@tachybase/acl';
2
+ export declare class RoleActionParamsMerge {
3
+ static merge(params: RoleActionParams[]): RoleActionParams;
4
+ }
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var RoleActionParamsMerge_exports = {};
19
+ __export(RoleActionParamsMerge_exports, {
20
+ RoleActionParamsMerge: () => RoleActionParamsMerge
21
+ });
22
+ module.exports = __toCommonJS(RoleActionParamsMerge_exports);
23
+ var import_utils = require("@tachybase/utils");
24
+ class RoleActionParamsMerge {
25
+ static merge(params) {
26
+ const result = {};
27
+ for (const item of params) {
28
+ (0, import_utils.assign)(item, result, {
29
+ filter: "orMerge",
30
+ fields: "union",
31
+ own: (x, y) => x || y,
32
+ whitelist: "union",
33
+ blacklist: "intersect"
34
+ });
35
+ }
36
+ return result;
37
+ }
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ RoleActionParamsMerge
42
+ });
@@ -0,0 +1,9 @@
1
+ export declare class RoleSnippets {
2
+ private allowList;
3
+ private blockList;
4
+ constructor(snippets: string[]);
5
+ static mergeSet(roleSnippets: Set<string>[]): string[];
6
+ private checkAllow;
7
+ private static merge;
8
+ private static filterSubset;
9
+ }
@@ -0,0 +1,127 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var RoleSnippets_exports = {};
29
+ __export(RoleSnippets_exports, {
30
+ RoleSnippets: () => RoleSnippets
31
+ });
32
+ module.exports = __toCommonJS(RoleSnippets_exports);
33
+ var import_minimatch = __toESM(require("minimatch"));
34
+ class RoleSnippetItem {
35
+ // 类似 pm pm.mobile-client.interface ui 的写法
36
+ name;
37
+ allow = true;
38
+ constructor(str) {
39
+ this.allow = !str.startsWith("!");
40
+ if (this.allow) {
41
+ this.name = str;
42
+ } else {
43
+ this.name = str.slice(1);
44
+ }
45
+ }
46
+ }
47
+ class RoleSnippets {
48
+ allowList = [];
49
+ blockList = [];
50
+ constructor(snippets) {
51
+ snippets.forEach((snippet) => {
52
+ const roleSnippet = new RoleSnippetItem(snippet);
53
+ if (roleSnippet.allow) {
54
+ this.allowList.push(roleSnippet);
55
+ } else {
56
+ this.blockList.push(roleSnippet);
57
+ }
58
+ });
59
+ }
60
+ static mergeSet(roleSnippets) {
61
+ return RoleSnippets.merge(roleSnippets.map((snippet) => new RoleSnippets([...snippet])));
62
+ }
63
+ checkAllow(target) {
64
+ for (const item of this.blockList) {
65
+ if ((0, import_minimatch.default)(target, item.name)) {
66
+ return false;
67
+ }
68
+ }
69
+ for (const item of this.allowList) {
70
+ if ((0, import_minimatch.default)(target, item.name)) {
71
+ return true;
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+ static merge(roleSnippets) {
77
+ const invalidBlock = /* @__PURE__ */ new Set();
78
+ const validBlock = /* @__PURE__ */ new Set();
79
+ roleSnippets.forEach((left) => {
80
+ left.blockList.forEach((blockItem) => {
81
+ const target = blockItem.name;
82
+ if (invalidBlock.has(target) || validBlock.has(target)) {
83
+ return;
84
+ }
85
+ const otherAllow = roleSnippets.some((right) => right !== left && right.checkAllow(target));
86
+ if (!otherAllow) {
87
+ validBlock.add(target);
88
+ } else {
89
+ invalidBlock.add(target);
90
+ }
91
+ });
92
+ });
93
+ const validAllow = /* @__PURE__ */ new Set();
94
+ for (const roleSnippet of roleSnippets) {
95
+ for (const allowItem of roleSnippet.allowList) {
96
+ validAllow.add(allowItem.name);
97
+ }
98
+ }
99
+ RoleSnippets.filterSubset(validAllow);
100
+ RoleSnippets.filterSubset(validBlock);
101
+ const list = [];
102
+ for (const item of validAllow) {
103
+ list.push(item);
104
+ }
105
+ for (const item of validBlock) {
106
+ list.push(`!${item}`);
107
+ }
108
+ return list;
109
+ }
110
+ static filterSubset(set) {
111
+ for (const left of set) {
112
+ for (const right of set) {
113
+ if (left === right) {
114
+ continue;
115
+ }
116
+ if ((0, import_minimatch.default)(left, right)) {
117
+ set.delete(left);
118
+ break;
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ RoleSnippets
127
+ });
@@ -0,0 +1,19 @@
1
+ import { AvailableStrategyOptions } from '@tachybase/acl';
2
+ export type RoleStrategyOptions = string | AvailableStrategyOptions;
3
+ export type RoleStrategyItem = {
4
+ action: string;
5
+ scope: 'all' | 'own';
6
+ };
7
+ export declare class RoleStrategy {
8
+ private strategyList;
9
+ private constructor();
10
+ static merge(list: RoleStrategyOptions[]): {
11
+ actions: string;
12
+ } | {
13
+ actions: string[];
14
+ };
15
+ private static stringToItem;
16
+ private getRawString;
17
+ private static itemToString;
18
+ private mergeAnother;
19
+ }
@@ -0,0 +1,84 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var RoleStrategy_exports = {};
19
+ __export(RoleStrategy_exports, {
20
+ RoleStrategy: () => RoleStrategy
21
+ });
22
+ module.exports = __toCommonJS(RoleStrategy_exports);
23
+ class RoleStrategy {
24
+ strategyList = [];
25
+ constructor(list) {
26
+ for (const str of list) {
27
+ this.strategyList.push(RoleStrategy.stringToItem(str));
28
+ }
29
+ }
30
+ static merge(list) {
31
+ let actions = null;
32
+ for (const listItem of list) {
33
+ if (typeof listItem === "string") {
34
+ continue;
35
+ }
36
+ if (!listItem.actions) {
37
+ continue;
38
+ }
39
+ if (listItem.actions === "*") {
40
+ return {
41
+ actions: "*"
42
+ };
43
+ }
44
+ const strategy = new RoleStrategy(listItem.actions);
45
+ if (!actions) {
46
+ actions = strategy;
47
+ continue;
48
+ }
49
+ actions.mergeAnother(strategy);
50
+ }
51
+ return {
52
+ actions: actions ? actions.getRawString() : null
53
+ };
54
+ }
55
+ static stringToItem(str) {
56
+ const [action, scope] = str.split(":");
57
+ return {
58
+ action,
59
+ scope: scope === "own" ? "own" : "all"
60
+ };
61
+ }
62
+ getRawString() {
63
+ return this.strategyList.map(RoleStrategy.itemToString);
64
+ }
65
+ static itemToString(item) {
66
+ return `${item.action}${item.scope === "own" ? ":own" : ""}`;
67
+ }
68
+ mergeAnother(another) {
69
+ for (const item of another.strategyList) {
70
+ const index = this.strategyList.findIndex((i) => i.action === item.action);
71
+ if (index === -1) {
72
+ this.strategyList.push(item);
73
+ continue;
74
+ }
75
+ if (this.strategyList[index].scope === "all") {
76
+ this.strategyList[index].scope = item.scope;
77
+ }
78
+ }
79
+ }
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ RoleStrategy
84
+ });
@@ -0,0 +1,5 @@
1
+ import Application from '@tachybase/server';
2
+ /**
3
+ * 启动插件后给所有未设置selfRole的用户设置selfRole
4
+ */
5
+ export declare function addMergeRole(app: Application): Promise<void>;
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var addMergeRoles_exports = {};
19
+ __export(addMergeRoles_exports, {
20
+ addMergeRole: () => addMergeRole
21
+ });
22
+ module.exports = __toCommonJS(addMergeRoles_exports);
23
+ async function addMergeRole(app) {
24
+ const userRepo = app.db.getRepository("users");
25
+ const missingUsers = await userRepo.find({
26
+ fields: ["id", "roles"],
27
+ filter: {
28
+ "selfRole.name": null
29
+ },
30
+ appends: ["roles"]
31
+ });
32
+ const roleRepo = app.db.getRepository("roles");
33
+ for (const missingUser of missingUsers) {
34
+ const mergeRole = {
35
+ title: `{{${missingUser.id} + '_' + t("All")}}`,
36
+ name: `m_${missingUser.id}`,
37
+ ownerUserId: missingUser.id
38
+ };
39
+ const mergeRoleModel = await roleRepo.create({ values: mergeRole });
40
+ }
41
+ app.logger.info(`[mergeRoles] add ${missingUsers.length} users`);
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ addMergeRole
46
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tachybase/database").CollectionDef;
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var roles_exports = {};
19
+ __export(roles_exports, {
20
+ default: () => roles_default
21
+ });
22
+ module.exports = __toCommonJS(roles_exports);
23
+ var import_database = require("@tachybase/database");
24
+ var roles_default = (0, import_database.extendCollection)({
25
+ name: "roles",
26
+ model: "RoleModel",
27
+ fields: [
28
+ {
29
+ name: "ownerUser",
30
+ type: "belongsTo",
31
+ target: "users",
32
+ targetKey: "id",
33
+ foreignKey: "ownerUserId",
34
+ index: true
35
+ }
36
+ ]
37
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tachybase/database").CollectionDef;
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var users_exports = {};
19
+ __export(users_exports, {
20
+ default: () => users_default
21
+ });
22
+ module.exports = __toCommonJS(users_exports);
23
+ var import_database = require("@tachybase/database");
24
+ var users_default = (0, import_database.extendCollection)({
25
+ name: "users",
26
+ fields: [
27
+ {
28
+ interface: "oho",
29
+ type: "hasOne",
30
+ name: "selfRole",
31
+ target: "roles",
32
+ targetKey: "name",
33
+ onDelete: "CASCADE",
34
+ foreignKey: "ownerUserId"
35
+ }
36
+ ]
37
+ });
@@ -0,0 +1,5 @@
1
+ export * from './user-change-roles';
2
+ export * from './source-role-update';
3
+ export * from './source-role-destroy';
4
+ export * from './refresh-datasources';
5
+ export * from './merge-role-create';
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var hooks_exports = {};
16
+ module.exports = __toCommonJS(hooks_exports);
17
+ __reExport(hooks_exports, require("./user-change-roles"), module.exports);
18
+ __reExport(hooks_exports, require("./source-role-update"), module.exports);
19
+ __reExport(hooks_exports, require("./source-role-destroy"), module.exports);
20
+ __reExport(hooks_exports, require("./refresh-datasources"), module.exports);
21
+ __reExport(hooks_exports, require("./merge-role-create"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./user-change-roles"),
25
+ ...require("./source-role-update"),
26
+ ...require("./source-role-destroy"),
27
+ ...require("./refresh-datasources"),
28
+ ...require("./merge-role-create")
29
+ });
@@ -0,0 +1,6 @@
1
+ import { CreateOptions } from '@tachybase/database';
2
+ import { MergeRoleModel } from '../model/MergeRoleModel';
3
+ /**
4
+ * 原始角色变化会导致合成角色也发生变化
5
+ */
6
+ export declare function mergeRoleCreate(model: MergeRoleModel, options: CreateOptions): Promise<void>;