@growi/core 1.0.0-next.0
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/dist/consts/accepted-upload-file-type.cjs +2 -0
- package/dist/consts/accepted-upload-file-type.cjs.map +1 -0
- package/dist/consts/accepted-upload-file-type.d.ts +6 -0
- package/dist/consts/accepted-upload-file-type.js +9 -0
- package/dist/consts/accepted-upload-file-type.js.map +1 -0
- package/dist/consts/growi-plugin.cjs +2 -0
- package/dist/consts/growi-plugin.cjs.map +1 -0
- package/dist/consts/growi-plugin.d.ts +7 -0
- package/dist/consts/growi-plugin.js +10 -0
- package/dist/consts/growi-plugin.js.map +1 -0
- package/dist/consts/index.cjs +2 -0
- package/dist/consts/index.cjs.map +1 -0
- package/dist/consts/index.d.ts +2 -0
- package/dist/consts/index.js +7 -0
- package/dist/consts/index.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/attachment.cjs +2 -0
- package/dist/interfaces/attachment.cjs.map +1 -0
- package/dist/interfaces/attachment.d.ts +19 -0
- package/dist/interfaces/attachment.js +2 -0
- package/dist/interfaces/attachment.js.map +1 -0
- package/dist/interfaces/color-scheme.cjs +2 -0
- package/dist/interfaces/color-scheme.cjs.map +1 -0
- package/dist/interfaces/color-scheme.d.ts +5 -0
- package/dist/interfaces/color-scheme.js +8 -0
- package/dist/interfaces/color-scheme.js.map +1 -0
- package/dist/interfaces/common.cjs +2 -0
- package/dist/interfaces/common.cjs.map +1 -0
- package/dist/interfaces/common.d.ts +6 -0
- package/dist/interfaces/common.js +6 -0
- package/dist/interfaces/common.js.map +1 -0
- package/dist/interfaces/external-account.cjs +2 -0
- package/dist/interfaces/external-account.cjs.map +1 -0
- package/dist/interfaces/external-account.d.ts +19 -0
- package/dist/interfaces/external-account.js +12 -0
- package/dist/interfaces/external-account.js.map +1 -0
- package/dist/interfaces/growi-facade.cjs +2 -0
- package/dist/interfaces/growi-facade.cjs.map +1 -0
- package/dist/interfaces/growi-facade.d.ts +11 -0
- package/dist/interfaces/growi-facade.js +2 -0
- package/dist/interfaces/growi-facade.js.map +1 -0
- package/dist/interfaces/growi-theme-metadata.cjs +2 -0
- package/dist/interfaces/growi-theme-metadata.cjs.map +1 -0
- package/dist/interfaces/growi-theme-metadata.d.ts +19 -0
- package/dist/interfaces/growi-theme-metadata.js +9 -0
- package/dist/interfaces/growi-theme-metadata.js.map +1 -0
- package/dist/interfaces/has-object-id.cjs +2 -0
- package/dist/interfaces/has-object-id.cjs.map +1 -0
- package/dist/interfaces/has-object-id.d.ts +3 -0
- package/dist/interfaces/has-object-id.js +2 -0
- package/dist/interfaces/has-object-id.js.map +1 -0
- package/dist/interfaces/index.cjs +2 -0
- package/dist/interfaces/index.cjs.map +1 -0
- package/dist/interfaces/index.d.ts +16 -0
- package/dist/interfaces/index.js +32 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/lang.cjs +2 -0
- package/dist/interfaces/lang.cjs.map +1 -0
- package/dist/interfaces/lang.d.ts +8 -0
- package/dist/interfaces/lang.js +11 -0
- package/dist/interfaces/lang.js.map +1 -0
- package/dist/interfaces/page.cjs +2 -0
- package/dist/interfaces/page.cjs.map +1 -0
- package/dist/interfaces/page.d.ts +113 -0
- package/dist/interfaces/page.js +20 -0
- package/dist/interfaces/page.js.map +1 -0
- package/dist/interfaces/revision.cjs +2 -0
- package/dist/interfaces/revision.cjs.map +1 -0
- package/dist/interfaces/revision.d.ts +36 -0
- package/dist/interfaces/revision.js +9 -0
- package/dist/interfaces/revision.js.map +1 -0
- package/dist/interfaces/subscription.cjs +2 -0
- package/dist/interfaces/subscription.cjs.map +1 -0
- package/dist/interfaces/subscription.d.ts +19 -0
- package/dist/interfaces/subscription.js +9 -0
- package/dist/interfaces/subscription.js.map +1 -0
- package/dist/interfaces/tag.cjs +2 -0
- package/dist/interfaces/tag.cjs.map +1 -0
- package/dist/interfaces/tag.d.ts +4 -0
- package/dist/interfaces/tag.js +2 -0
- package/dist/interfaces/tag.js.map +1 -0
- package/dist/interfaces/user.cjs +2 -0
- package/dist/interfaces/user.cjs.map +1 -0
- package/dist/interfaces/user.d.ts +57 -0
- package/dist/interfaces/user.js +11 -0
- package/dist/interfaces/user.js.map +1 -0
- package/dist/interfaces/vite.cjs +2 -0
- package/dist/interfaces/vite.cjs.map +1 -0
- package/dist/interfaces/vite.d.ts +9 -0
- package/dist/interfaces/vite.js +2 -0
- package/dist/interfaces/vite.js.map +1 -0
- package/dist/interfaces/websocket.cjs +2 -0
- package/dist/interfaces/websocket.cjs.map +1 -0
- package/dist/interfaces/websocket.d.ts +5 -0
- package/dist/interfaces/websocket.js +9 -0
- package/dist/interfaces/websocket.js.map +1 -0
- package/dist/models/devided-page-path.cjs +2 -0
- package/dist/models/devided-page-path.cjs.map +1 -0
- package/dist/models/devided-page-path.d.ts +7 -0
- package/dist/models/devided-page-path.js +29 -0
- package/dist/models/devided-page-path.js.map +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/vo/error-apiv3.cjs +2 -0
- package/dist/models/vo/error-apiv3.cjs.map +1 -0
- package/dist/models/vo/error-apiv3.d.ts +5 -0
- package/dist/models/vo/error-apiv3.js +9 -0
- package/dist/models/vo/error-apiv3.js.map +1 -0
- package/dist/remark-plugins/index.cjs +2 -0
- package/dist/remark-plugins/index.cjs.map +1 -0
- package/dist/remark-plugins/index.d.ts +2 -0
- package/dist/remark-plugins/index.js +5 -0
- package/dist/remark-plugins/index.js.map +1 -0
- package/dist/remark-plugins/interfaces/option-parser.cjs +2 -0
- package/dist/remark-plugins/interfaces/option-parser.cjs.map +1 -0
- package/dist/remark-plugins/interfaces/option-parser.d.ts +4 -0
- package/dist/remark-plugins/interfaces/option-parser.js +2 -0
- package/dist/remark-plugins/interfaces/option-parser.js.map +1 -0
- package/dist/remark-plugins/util/option-parser.cjs +2 -0
- package/dist/remark-plugins/util/option-parser.cjs.map +1 -0
- package/dist/remark-plugins/util/option-parser.d.ts +26 -0
- package/dist/remark-plugins/util/option-parser.js +39 -0
- package/dist/remark-plugins/util/option-parser.js.map +1 -0
- package/dist/remark-plugins/util/option-parser.spec.d.ts +1 -0
- package/dist/swr/index.cjs +2 -0
- package/dist/swr/index.cjs.map +1 -0
- package/dist/swr/index.d.ts +3 -0
- package/dist/swr/index.js +11 -0
- package/dist/swr/index.js.map +1 -0
- package/dist/swr/use-global-socket.cjs +2 -0
- package/dist/swr/use-global-socket.cjs.map +1 -0
- package/dist/swr/use-global-socket.d.ts +6 -0
- package/dist/swr/use-global-socket.js +8 -0
- package/dist/swr/use-global-socket.js.map +1 -0
- package/dist/swr/use-swr-static.cjs +2 -0
- package/dist/swr/use-swr-static.cjs.map +1 -0
- package/dist/swr/use-swr-static.d.ts +5 -0
- package/dist/swr/use-swr-static.js +17 -0
- package/dist/swr/use-swr-static.js.map +1 -0
- package/dist/swr/with-utils.cjs +2 -0
- package/dist/swr/with-utils.cjs.map +1 -0
- package/dist/swr/with-utils.d.ts +4 -0
- package/dist/swr/with-utils.js +5 -0
- package/dist/swr/with-utils.js.map +1 -0
- package/dist/utils/browser-utils.cjs +2 -0
- package/dist/utils/browser-utils.cjs.map +1 -0
- package/dist/utils/browser-utils.d.ts +2 -0
- package/dist/utils/browser-utils.js +6 -0
- package/dist/utils/browser-utils.js.map +1 -0
- package/dist/utils/env-utils.cjs +2 -0
- package/dist/utils/env-utils.cjs.map +1 -0
- package/dist/utils/env-utils.d.ts +5 -0
- package/dist/utils/env-utils.js +7 -0
- package/dist/utils/env-utils.js.map +1 -0
- package/dist/utils/env-utils.spec.d.ts +1 -0
- package/dist/utils/growi-theme-metadata.cjs +2 -0
- package/dist/utils/growi-theme-metadata.cjs.map +1 -0
- package/dist/utils/growi-theme-metadata.d.ts +4 -0
- package/dist/utils/growi-theme-metadata.js +6 -0
- package/dist/utils/growi-theme-metadata.js.map +1 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/objectid-utils.cjs +2 -0
- package/dist/utils/objectid-utils.cjs.map +1 -0
- package/dist/utils/objectid-utils.d.ts +3 -0
- package/dist/utils/objectid-utils.js +8 -0
- package/dist/utils/objectid-utils.js.map +1 -0
- package/dist/utils/objectid-utils.spec.d.ts +1 -0
- package/dist/utils/page-path-utils/index.cjs +2 -0
- package/dist/utils/page-path-utils/index.cjs.map +1 -0
- package/dist/utils/page-path-utils/index.d.ts +125 -0
- package/dist/utils/page-path-utils/index.js +91 -0
- package/dist/utils/page-path-utils/index.js.map +1 -0
- package/dist/utils/page-path-utils/index.spec.d.ts +1 -0
- package/dist/utils/page-path-utils/is-top-page.cjs +2 -0
- package/dist/utils/page-path-utils/is-top-page.cjs.map +1 -0
- package/dist/utils/page-path-utils/is-top-page.d.ts +5 -0
- package/dist/utils/page-path-utils/is-top-page.js +5 -0
- package/dist/utils/page-path-utils/is-top-page.js.map +1 -0
- package/dist/utils/page-path-utils/is-top-page.spec.d.ts +1 -0
- package/dist/utils/page-utils.cjs +2 -0
- package/dist/utils/page-utils.cjs.map +1 -0
- package/dist/utils/page-utils.d.ts +18 -0
- package/dist/utils/page-utils.js +13 -0
- package/dist/utils/page-utils.js.map +1 -0
- package/dist/utils/path-utils.cjs +2 -0
- package/dist/utils/path-utils.cjs.map +1 -0
- package/dist/utils/path-utils.d.ts +66 -0
- package/dist/utils/path-utils.js +45 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/path-utils.spec.d.ts +1 -0
- package/dist/utils/template-checker.cjs +2 -0
- package/dist/utils/template-checker.cjs.map +1 -0
- package/dist/utils/template-checker.d.ts +4 -0
- package/dist/utils/template-checker.js +7 -0
- package/dist/utils/template-checker.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-global-socket.js","sources":["../../src/swr/use-global-socket.ts"],"sourcesContent":["import type { Socket } from 'socket.io-client';\nimport type { SWRResponse } from 'swr';\n\nimport { useSWRStatic } from './use-swr-static';\n\nexport const GLOBAL_SOCKET_NS = '/';\nexport const GLOBAL_SOCKET_KEY = 'globalSocket';\n\nexport const useGlobalSocket = (): SWRResponse<Socket, Error> => {\n return useSWRStatic(GLOBAL_SOCKET_KEY);\n};\n"],"names":["GLOBAL_SOCKET_NS","GLOBAL_SOCKET_KEY","useGlobalSocket","useSWRStatic"],"mappings":";AAKO,MAAMA,IAAmB,KACnBC,IAAoB,gBAEpBC,IAAkB,MACtBC,EAAaF,CAAiB;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("swr"),l=require("swr/immutable");function n(...o){var r;const[e,a,t]=o;if((t==null?void 0:t.fetcher)!=null)throw new Error("useSWRStatic does not support 'configuration.fetcher'");const{cache:u}=c.useSWRConfig(),s=l(e,null,{...t,fallbackData:(t==null?void 0:t.fallbackData)??(e!=null?(r=u.get(e==null?void 0:e.toString()))==null?void 0:r.data:void 0)});return e!=null&&a!==void 0&&s.mutate(a,{optimisticData:a}),s}exports.useSWRStatic=n;
|
|
2
|
+
//# sourceMappingURL=use-swr-static.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-swr-static.cjs","sources":["../../src/swr/use-swr-static.ts"],"sourcesContent":["import {\n Key, SWRConfiguration, SWRResponse, useSWRConfig,\n} from 'swr';\nimport useSWRImmutable from 'swr/immutable';\n\n\nexport function useSWRStatic<Data, Error>(key: Key): SWRResponse<Data, Error>;\nexport function useSWRStatic<Data, Error>(key: Key, data: Data | undefined): SWRResponse<Data, Error>;\nexport function useSWRStatic<Data, Error>(key: Key, data: Data | undefined,\n configuration: SWRConfiguration<Data, Error> | undefined): SWRResponse<Data, Error>;\n\nexport function useSWRStatic<Data, Error>(\n ...args: readonly [Key]\n | readonly [Key, Data | undefined]\n | readonly [Key, Data | undefined, SWRConfiguration<Data, Error> | undefined]\n): SWRResponse<Data, Error> {\n const [key, data, configuration] = args;\n\n if (configuration?.fetcher != null) {\n throw new Error(\"useSWRStatic does not support 'configuration.fetcher'\");\n }\n\n const { cache } = useSWRConfig();\n const swrResponse = useSWRImmutable(key, null, {\n ...configuration,\n fallbackData: configuration?.fallbackData ?? (\n key != null ? cache.get(key?.toString())?.data : undefined\n ),\n });\n\n // update data\n if (key != null && data !== undefined) {\n swrResponse.mutate(data, { optimisticData: data });\n }\n\n return swrResponse;\n}\n"],"names":["useSWRStatic","args","key","data","configuration","cache","useSWRConfig","swrResponse","useSWRImmutable","_a"],"mappings":"kIAWO,SAASA,KACTC,EAGqB,OAC1B,KAAM,CAACC,EAAKC,EAAMC,CAAa,EAAIH,EAE/B,IAAAG,GAAA,YAAAA,EAAe,UAAW,KACtB,MAAA,IAAI,MAAM,uDAAuD,EAGnE,KAAA,CAAE,MAAAC,GAAUC,EAAAA,eACZC,EAAcC,EAAgBN,EAAK,KAAM,CAC7C,GAAGE,EACH,cAAcA,GAAA,YAAAA,EAAe,gBAC3BF,GAAO,MAAOO,EAAAJ,EAAM,IAAIH,GAAA,YAAAA,EAAK,UAAU,IAAzB,YAAAO,EAA4B,KAAO,OAAA,CAEpD,EAGG,OAAAP,GAAO,MAAQC,IAAS,QAC1BI,EAAY,OAAOJ,EAAM,CAAE,eAAgBA,CAAM,CAAA,EAG5CI,CACT"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Key, SWRConfiguration, SWRResponse } from 'swr';
|
|
2
|
+
|
|
3
|
+
export declare function useSWRStatic<Data, Error>(key: Key): SWRResponse<Data, Error>;
|
|
4
|
+
export declare function useSWRStatic<Data, Error>(key: Key, data: Data | undefined): SWRResponse<Data, Error>;
|
|
5
|
+
export declare function useSWRStatic<Data, Error>(key: Key, data: Data | undefined, configuration: SWRConfiguration<Data, Error> | undefined): SWRResponse<Data, Error>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useSWRConfig as c } from "swr";
|
|
2
|
+
import n from "swr/immutable";
|
|
3
|
+
function f(...l) {
|
|
4
|
+
var r;
|
|
5
|
+
const [a, e, t] = l;
|
|
6
|
+
if ((t == null ? void 0 : t.fetcher) != null)
|
|
7
|
+
throw new Error("useSWRStatic does not support 'configuration.fetcher'");
|
|
8
|
+
const { cache: s } = c(), o = n(a, null, {
|
|
9
|
+
...t,
|
|
10
|
+
fallbackData: (t == null ? void 0 : t.fallbackData) ?? (a != null ? (r = s.get(a == null ? void 0 : a.toString())) == null ? void 0 : r.data : void 0)
|
|
11
|
+
});
|
|
12
|
+
return a != null && e !== void 0 && o.mutate(e, { optimisticData: e }), o;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
f as useSWRStatic
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=use-swr-static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-swr-static.js","sources":["../../src/swr/use-swr-static.ts"],"sourcesContent":["import {\n Key, SWRConfiguration, SWRResponse, useSWRConfig,\n} from 'swr';\nimport useSWRImmutable from 'swr/immutable';\n\n\nexport function useSWRStatic<Data, Error>(key: Key): SWRResponse<Data, Error>;\nexport function useSWRStatic<Data, Error>(key: Key, data: Data | undefined): SWRResponse<Data, Error>;\nexport function useSWRStatic<Data, Error>(key: Key, data: Data | undefined,\n configuration: SWRConfiguration<Data, Error> | undefined): SWRResponse<Data, Error>;\n\nexport function useSWRStatic<Data, Error>(\n ...args: readonly [Key]\n | readonly [Key, Data | undefined]\n | readonly [Key, Data | undefined, SWRConfiguration<Data, Error> | undefined]\n): SWRResponse<Data, Error> {\n const [key, data, configuration] = args;\n\n if (configuration?.fetcher != null) {\n throw new Error(\"useSWRStatic does not support 'configuration.fetcher'\");\n }\n\n const { cache } = useSWRConfig();\n const swrResponse = useSWRImmutable(key, null, {\n ...configuration,\n fallbackData: configuration?.fallbackData ?? (\n key != null ? cache.get(key?.toString())?.data : undefined\n ),\n });\n\n // update data\n if (key != null && data !== undefined) {\n swrResponse.mutate(data, { optimisticData: data });\n }\n\n return swrResponse;\n}\n"],"names":["useSWRStatic","args","key","data","configuration","cache","useSWRConfig","swrResponse","useSWRImmutable","_a"],"mappings":";;AAWO,SAASA,KACTC,GAGqB;;AAC1B,QAAM,CAACC,GAAKC,GAAMC,CAAa,IAAIH;AAE/B,OAAAG,KAAA,gBAAAA,EAAe,YAAW;AACtB,UAAA,IAAI,MAAM,uDAAuD;AAGnE,QAAA,EAAE,OAAAC,MAAUC,KACZC,IAAcC,EAAgBN,GAAK,MAAM;AAAA,IAC7C,GAAGE;AAAA,IACH,eAAcA,KAAA,gBAAAA,EAAe,kBAC3BF,KAAO,QAAOO,IAAAJ,EAAM,IAAIH,KAAA,gBAAAA,EAAK,UAAU,MAAzB,gBAAAO,EAA4B,OAAO;AAAA,EAAA,CAEpD;AAGG,SAAAP,KAAO,QAAQC,MAAS,UAC1BI,EAAY,OAAOJ,GAAM,EAAE,gBAAgBA,EAAM,CAAA,GAG5CI;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-utils.cjs","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\nexport const withUtils = <U, D = any, E = any>(response: SWRResponse<D, E>, utils: U): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"gFAIa,MAAAA,EAAY,CAAsBC,EAA6BC,IACnE,OAAO,OAAOD,EAAUC,CAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-utils.js","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\nexport const withUtils = <U, D = any, E = any>(response: SWRResponse<D, E>, utils: U): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"AAIa,MAAAA,IAAY,CAAsBC,GAA6BC,MACnE,OAAO,OAAOD,GAAUC,CAAK;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-utils.cjs","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (typeof window !== 'undefined') || (typeof navigator !== 'undefined' && navigator.webdriver);\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"gFAAO,MAAMA,EAAW,IACd,OAAO,OAAW,KAAiB,OAAO,UAAc,KAAe,UAAU,UAG9EC,EAAW,IACf,CAACD,EAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-utils.js","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (typeof window !== 'undefined') || (typeof navigator !== 'undefined' && navigator.webdriver);\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"AAAO,MAAMA,IAAW,MACd,OAAO,SAAW,OAAiB,OAAO,YAAc,OAAe,UAAU,WAG9EC,IAAW,MACf,CAACD,EAAS;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-utils.cjs","sources":["../../src/utils/env-utils.ts"],"sourcesContent":["/**\n * convert to boolean\n *\n */\nexport function toBoolean(value: string): boolean {\n return /^(true|1)$/i.test(value);\n}\n"],"names":["toBoolean","value"],"mappings":"gFAIO,SAASA,EAAUC,EAAwB,CACzC,MAAA,cAAc,KAAKA,CAAK,CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-utils.js","sources":["../../src/utils/env-utils.ts"],"sourcesContent":["/**\n * convert to boolean\n *\n */\nexport function toBoolean(value: string): boolean {\n return /^(true|1)$/i.test(value);\n}\n"],"names":["toBoolean","value"],"mappings":"AAIO,SAASA,EAAUC,GAAwB;AACzC,SAAA,cAAc,KAAKA,CAAK;AACjC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"growi-theme-metadata.cjs","sources":["../../src/utils/growi-theme-metadata.ts"],"sourcesContent":["import type { ColorScheme } from '../interfaces/color-scheme';\nimport { GrowiThemeSchemeType } from '../interfaces/growi-theme-metadata';\n\nexport const getForcedColorScheme = (growiThemeSchemeType?: GrowiThemeSchemeType): ColorScheme | undefined => {\n return growiThemeSchemeType == null || growiThemeSchemeType === GrowiThemeSchemeType.BOTH\n ? undefined\n : growiThemeSchemeType as ColorScheme;\n};\n"],"names":["getForcedColorScheme","growiThemeSchemeType","GrowiThemeSchemeType"],"mappings":"0IAGaA,EAAwBC,GAC5BA,GAAwB,MAAQA,IAAyBC,EAAA,qBAAqB,KACjF,OACAD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"growi-theme-metadata.js","sources":["../../src/utils/growi-theme-metadata.ts"],"sourcesContent":["import type { ColorScheme } from '../interfaces/color-scheme';\nimport { GrowiThemeSchemeType } from '../interfaces/growi-theme-metadata';\n\nexport const getForcedColorScheme = (growiThemeSchemeType?: GrowiThemeSchemeType): ColorScheme | undefined => {\n return growiThemeSchemeType == null || growiThemeSchemeType === GrowiThemeSchemeType.BOTH\n ? undefined\n : growiThemeSchemeType as ColorScheme;\n};\n"],"names":["getForcedColorScheme","growiThemeSchemeType","GrowiThemeSchemeType"],"mappings":";AAGa,MAAAA,IAAuB,CAACC,MAC5BA,KAAwB,QAAQA,MAAyBC,EAAqB,OACjF,SACAD;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./env-utils.cjs"),r=require("./template-checker.cjs"),i=require("./objectid-utils.cjs"),s=require("./page-path-utils/index.cjs"),o=require("./path-utils.cjs"),l=require("./page-utils.cjs"),e=require("./browser-utils.cjs"),c=require("./growi-theme-metadata.cjs"),n=t;exports.templateChecker=r;exports.objectIdUtils=i;exports.pagePathUtils=s;exports.pathUtils=o;exports.pageUtils=l;exports.isClient=e.isClient;exports.isServer=e.isServer;exports.getForcedColorScheme=c.getForcedColorScheme;exports.envUtils=n;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/utils/index.ts"],"sourcesContent":["import * as _envUtils from './env-utils';\n\n// export utils by *.js\nexport const envUtils = _envUtils;\n\n// export utils with namespace\nexport * as templateChecker from './template-checker';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pathUtils from './path-utils';\nexport * as pageUtils from './page-utils';\n\nexport * from './browser-utils';\nexport * from './growi-theme-metadata';\n"],"names":["envUtils","_envUtils"],"mappings":"uWAGaA,EAAWC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _envUtils from './env-utils';
|
|
2
|
+
export declare const envUtils: typeof _envUtils;
|
|
3
|
+
export * as templateChecker from './template-checker';
|
|
4
|
+
export * as objectIdUtils from './objectid-utils';
|
|
5
|
+
export * as pagePathUtils from './page-path-utils';
|
|
6
|
+
export * as pathUtils from './path-utils';
|
|
7
|
+
export * as pageUtils from './page-utils';
|
|
8
|
+
export * from './browser-utils';
|
|
9
|
+
export * from './growi-theme-metadata';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as t from "./env-utils.js";
|
|
2
|
+
import * as o from "./template-checker.js";
|
|
3
|
+
import * as r from "./objectid-utils.js";
|
|
4
|
+
import * as e from "./page-path-utils/index.js";
|
|
5
|
+
import * as i from "./path-utils.js";
|
|
6
|
+
import * as p from "./page-utils.js";
|
|
7
|
+
import { isClient as l, isServer as x } from "./browser-utils.js";
|
|
8
|
+
import { getForcedColorScheme as U } from "./growi-theme-metadata.js";
|
|
9
|
+
const s = t;
|
|
10
|
+
export {
|
|
11
|
+
s as envUtils,
|
|
12
|
+
U as getForcedColorScheme,
|
|
13
|
+
l as isClient,
|
|
14
|
+
x as isServer,
|
|
15
|
+
r as objectIdUtils,
|
|
16
|
+
e as pagePathUtils,
|
|
17
|
+
p as pageUtils,
|
|
18
|
+
i as pathUtils,
|
|
19
|
+
o as templateChecker
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import * as _envUtils from './env-utils';\n\n// export utils by *.js\nexport const envUtils = _envUtils;\n\n// export utils with namespace\nexport * as templateChecker from './template-checker';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pathUtils from './path-utils';\nexport * as pageUtils from './page-utils';\n\nexport * from './browser-utils';\nexport * from './growi-theme-metadata';\n"],"names":["envUtils","_envUtils"],"mappings":";;;;;;;;AAGO,MAAMA,IAAWC;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("bson-objectid");function r(e){return e==null?!1:typeof e=="string"?t.isValid(e)&&new t(e).toHexString()===e:t.isValid(e)}exports.isValidObjectId=r;
|
|
2
|
+
//# sourceMappingURL=objectid-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectid-utils.cjs","sources":["../../src/utils/objectid-utils.ts"],"sourcesContent":["import ObjectId from 'bson-objectid';\n\nexport function isValidObjectId(id: string | ObjectId | null | undefined): boolean {\n if (id == null) {\n return false;\n }\n\n // implement according to https://www.geeksforgeeks.org/how-to-check-if-a-string-is-valid-mongodb-objectid-in-node-js/\n if (typeof id === 'string') {\n return ObjectId.isValid(id) && new ObjectId(id).toHexString() === id;\n }\n\n return ObjectId.isValid(id);\n}\n"],"names":["isValidObjectId","id","ObjectId"],"mappings":"iHAEO,SAASA,EAAgBC,EAAmD,CACjF,OAAIA,GAAM,KACD,GAIL,OAAOA,GAAO,SACTC,EAAS,QAAQD,CAAE,GAAK,IAAIC,EAASD,CAAE,EAAE,YAAkB,IAAAA,EAG7DC,EAAS,QAAQD,CAAE,CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectid-utils.js","sources":["../../src/utils/objectid-utils.ts"],"sourcesContent":["import ObjectId from 'bson-objectid';\n\nexport function isValidObjectId(id: string | ObjectId | null | undefined): boolean {\n if (id == null) {\n return false;\n }\n\n // implement according to https://www.geeksforgeeks.org/how-to-check-if-a-string-is-valid-mongodb-objectid-in-node-js/\n if (typeof id === 'string') {\n return ObjectId.isValid(id) && new ObjectId(id).toHexString() === id;\n }\n\n return ObjectId.isValid(id);\n}\n"],"names":["isValidObjectId","id","ObjectId"],"mappings":";AAEO,SAASA,EAAgBC,GAAmD;AACjF,SAAIA,KAAM,OACD,KAIL,OAAOA,KAAO,WACTC,EAAS,QAAQD,CAAE,KAAK,IAAIC,EAASD,CAAE,EAAE,YAAkB,MAAAA,IAG7DC,EAAS,QAAQD,CAAE;AAC5B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("escape-string-regexp"),P=require("../objectid-utils.cjs"),i=require("../path-utils.cjs"),m=require("./is-top-page.cjs"),o=m.isTopPage,c=e=>e==="/user",f=e=>{const t=e.substring(1);return P.isValidObjectId(t)},u=e=>!!e.match(/^\/user\/[^/]+$/),l=e=>c(e)||u(e),d=e=>!o(e)&&!l(e),$=e=>!!e.match(/^\/user\/.*?$/),E=e=>e==="/trash",T=e=>!!e.match(/^\/trash(\/.*)?$/),w=e=>!!e.match(/^\/share(\/.*)?$/),S=[/\^|\$|\*|\+|#|<|>|%|\?/,/^\/-\/.*/,/^\/_r\/.*/,/^\/_apix?(\/.*)?/,/^\/?https?:\/\/.+$/,/\/{2,}/,/\s+\/\s+/,/.+\/edit$/,/.+\.md$/,/^(\.\.)$/,/(\/\.\.)\/?/,/\\/,/^\/(_search|_private-legacy-pages)(\/.*|$)/,/^\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\/.*|$)/,/^\/user(?:\/[^/]+)?$/],h=e=>!S.some(t=>e.match(t)),v=e=>(e==null?void 0:e.username)==null?"":`/user/${e.username}`,A=(e,t,r)=>{if(t==null)throw new Error("Please input the new page path");const a=new RegExp(`^${s(e)}`,"i");return r.replace(a,t)},x=e=>{if(e!=null)return e.replace(/ /g,"%20").replace(/\u3000/g,"%E3%80%80")},R=(...e)=>{const t=[...e].join("/");if(!h(t))throw new Error("Invalid characters on path");try{return`${new URL(t,"https://dummy").pathname}#edit`}catch{throw new Error("Invalid path format")}},U=e=>{const t=Array.from(new Set(e));return t.filter(r=>!(t.filter(n=>new RegExp(`^${n}\\/.+`,"i").test(r)).length>0))},y=e=>e.filter(t=>!e.some(a=>new RegExp(`^${a.path}\\/.+`,"i").test(t.path))),b=(e,t)=>{if(e===t)return!0;const r=i.addTrailingSlash(e),a=i.addTrailingSlash(t),n=new RegExp(`^${s(r)}`,"i"),p=new RegExp(`^${s(a)}`,"i");return!!(n.test(t)||p.test(e))},g=(e,t)=>{if(e===t)return!0;const r=i.addTrailingSlash(e);return!!new RegExp(`^${s(r)}`,"i").test(t)},D=(e,t)=>!g(e,t),O=e=>e.includes("/"),j=e=>o(e)?new RegExp(/^\/[^/]+$/):new RegExp(`^${e}(\\/[^/]+)\\/?$`),q=e=>{let t=null;const r=e.match(/^\/user\/([^/]+)\/?/);return r&&(t=r[1]),t};exports.canMoveByPath=D;exports.convertToNewAffiliationPath=A;exports.encodeSpaces=x;exports.generateChildrenRegExp=j;exports.generateEditorPath=R;exports.getUsernameByPath=q;exports.hasSlash=O;exports.isCreatablePage=h;exports.isEitherOfPathAreaOverlap=b;exports.isMovablePage=d;exports.isPathAreaOverlap=g;exports.isPermalink=f;exports.isSharedPage=w;exports.isTopPage=o;exports.isTrashPage=T;exports.isTrashTopPage=E;exports.isUserPage=$;exports.isUsersHomepage=u;exports.isUsersProtectedPages=l;exports.isUsersTopPage=c;exports.omitDuplicateAreaPageFromPages=y;exports.omitDuplicateAreaPathFromPaths=U;exports.userHomepagePath=v;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\n\nimport { IUser } from '~/interfaces';\n\nimport { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\n\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s+\\/\\s+/, // avoid miss in renaming\n /.+\\/edit$/,\n /.+\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/weseek/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/weseek/growi/issues/3582\n /\\\\/, // see: https://github.com/weseek/growi/issues/7241\n /^\\/(_search|_private-legacy-pages)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\nexport const isCreatablePage = (path: string): boolean => {\n return !restrictedPatternsToCreate.some(pattern => path.match(pattern));\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (user: IUser | null | undefined): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (oldPath: string, newPath: string, childPath: string): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${escapeStringRegexp(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?:string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n }\n catch (err) {\n throw new Error('Invalid path format');\n }\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n const isDuplicate = uniquePaths.filter(p => (new RegExp(`^${p}\\\\/.+`, 'i')).test(path)).length > 0;\n\n return !isDuplicate;\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some(p => (new RegExp(`^${p.path}\\\\/.+`, 'i')).test(page.path));\n\n return !isDuplicate;\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (path1: string, path2: string): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${escapeStringRegexp(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${escapeStringRegexp(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (pathToTest: string, pathToBeTested: string): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${escapeStringRegexp(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Generate RegExp instance for one level lower path\n */\nexport const generateChildrenRegExp = (path: string): RegExp => {\n // https://regex101.com/r/laJGzj/1\n // ex. /any_level1\n if (isTopPage(path)) return new RegExp(/^\\/[^/]+$/);\n\n // https://regex101.com/r/mrDJrx/1\n // ex. /parent/any_child OR /any_level1\n return new RegExp(`^${path}(\\\\/[^/]+)\\\\/?$`);\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\n\nexport * from './is-top-page';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","escapeStringRegexp","encodeSpaces","generateEditorPath","paths","joinedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toPath","hasSlash","str","generateChildrenRegExp","getUsernameByPath","username","match"],"mappings":"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"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IUser } from '../../interfaces';
|
|
2
|
+
|
|
3
|
+
export declare const isTopPage: (path: string) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Whether path is the top page of users
|
|
6
|
+
* @param path
|
|
7
|
+
*/
|
|
8
|
+
export declare const isUsersTopPage: (path: string) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the path is permalink
|
|
11
|
+
* @param path
|
|
12
|
+
*/
|
|
13
|
+
export declare const isPermalink: (path: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether path is user's homepage
|
|
16
|
+
* @param path
|
|
17
|
+
*/
|
|
18
|
+
export declare const isUsersHomepage: (path: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether path is the protected pages for systems
|
|
21
|
+
* @param path
|
|
22
|
+
*/
|
|
23
|
+
export declare const isUsersProtectedPages: (path: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether path is movable
|
|
26
|
+
* @param path
|
|
27
|
+
*/
|
|
28
|
+
export declare const isMovablePage: (path: string) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether path belongs to the user page
|
|
31
|
+
* @param path
|
|
32
|
+
*/
|
|
33
|
+
export declare const isUserPage: (path: string) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether path is the top page of users
|
|
36
|
+
* @param path
|
|
37
|
+
*/
|
|
38
|
+
export declare const isTrashTopPage: (path: string) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether path belongs to the trash page
|
|
41
|
+
* @param path
|
|
42
|
+
*/
|
|
43
|
+
export declare const isTrashPage: (path: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether path belongs to the shared page
|
|
46
|
+
* @param path
|
|
47
|
+
*/
|
|
48
|
+
export declare const isSharedPage: (path: string) => boolean;
|
|
49
|
+
export declare const isCreatablePage: (path: string) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* return user's homepage path
|
|
52
|
+
* @param user
|
|
53
|
+
*/
|
|
54
|
+
export declare const userHomepagePath: (user: IUser | null | undefined) => string;
|
|
55
|
+
/**
|
|
56
|
+
* return user path
|
|
57
|
+
* @param parentPath
|
|
58
|
+
* @param childPath
|
|
59
|
+
* @param newPath
|
|
60
|
+
*/
|
|
61
|
+
export declare const convertToNewAffiliationPath: (oldPath: string, newPath: string, childPath: string) => string;
|
|
62
|
+
/**
|
|
63
|
+
* Encode SPACE and IDEOGRAPHIC SPACE
|
|
64
|
+
* @param {string} path
|
|
65
|
+
* @returns {string}
|
|
66
|
+
*/
|
|
67
|
+
export declare const encodeSpaces: (path?: string) => string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Generate editor path
|
|
70
|
+
* @param {string} paths
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
export declare const generateEditorPath: (...paths: string[]) => string;
|
|
74
|
+
/**
|
|
75
|
+
* return paths without duplicate area of regexp /^${path}\/.+/i
|
|
76
|
+
* ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])
|
|
77
|
+
* @param paths paths to be tested
|
|
78
|
+
* @returns omitted paths
|
|
79
|
+
*/
|
|
80
|
+
export declare const omitDuplicateAreaPathFromPaths: (paths: string[]) => string[];
|
|
81
|
+
/**
|
|
82
|
+
* return pages with path without duplicate area of regexp /^${path}\/.+/i
|
|
83
|
+
* if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same
|
|
84
|
+
* @param paths paths to be tested
|
|
85
|
+
* @returns omitted paths
|
|
86
|
+
*/
|
|
87
|
+
export declare const omitDuplicateAreaPageFromPages: (pages: any[]) => any[];
|
|
88
|
+
/**
|
|
89
|
+
* Check if the area of either path1 or path2 includes the area of the other path
|
|
90
|
+
* The area of path is the same as /^\/hoge\//i
|
|
91
|
+
* @param pathToTest string
|
|
92
|
+
* @param pathToBeTested string
|
|
93
|
+
* @returns boolean
|
|
94
|
+
*/
|
|
95
|
+
export declare const isEitherOfPathAreaOverlap: (path1: string, path2: string) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Check if the area of pathToTest includes the area of pathToBeTested
|
|
98
|
+
* The area of path is the same as /^\/hoge\//i
|
|
99
|
+
* @param pathToTest string
|
|
100
|
+
* @param pathToBeTested string
|
|
101
|
+
* @returns boolean
|
|
102
|
+
*/
|
|
103
|
+
export declare const isPathAreaOverlap: (pathToTest: string, pathToBeTested: string) => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Determine whether can move by fromPath and toPath
|
|
106
|
+
* @param fromPath string
|
|
107
|
+
* @param toPath string
|
|
108
|
+
* @returns boolean
|
|
109
|
+
*/
|
|
110
|
+
export declare const canMoveByPath: (fromPath: string, toPath: string) => boolean;
|
|
111
|
+
/**
|
|
112
|
+
* check if string has '/' in it
|
|
113
|
+
*/
|
|
114
|
+
export declare const hasSlash: (str: string) => boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Generate RegExp instance for one level lower path
|
|
117
|
+
*/
|
|
118
|
+
export declare const generateChildrenRegExp: (path: string) => RegExp;
|
|
119
|
+
/**
|
|
120
|
+
* Get username from user page path
|
|
121
|
+
* @param path string
|
|
122
|
+
* @returns string | null
|
|
123
|
+
*/
|
|
124
|
+
export declare const getUsernameByPath: (path: string) => string | null;
|
|
125
|
+
export * from './is-top-page';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import n from "escape-string-regexp";
|
|
2
|
+
import { isValidObjectId as u } from "../objectid-utils.js";
|
|
3
|
+
import { addTrailingSlash as i } from "../path-utils.js";
|
|
4
|
+
import { isTopPage as l } from "./is-top-page.js";
|
|
5
|
+
const o = l, h = (e) => e === "/user", x = (e) => {
|
|
6
|
+
const t = e.substring(1);
|
|
7
|
+
return u(t);
|
|
8
|
+
}, p = (e) => !!e.match(/^\/user\/[^/]+$/), g = (e) => h(e) || p(e), R = (e) => !o(e) && !g(e), A = (e) => !!e.match(/^\/user\/.*?$/), S = (e) => e === "/trash", T = (e) => !!e.match(/^\/trash(\/.*)?$/), v = (e) => !!e.match(/^\/share(\/.*)?$/), m = [
|
|
9
|
+
/\^|\$|\*|\+|#|<|>|%|\?/,
|
|
10
|
+
/^\/-\/.*/,
|
|
11
|
+
/^\/_r\/.*/,
|
|
12
|
+
/^\/_apix?(\/.*)?/,
|
|
13
|
+
/^\/?https?:\/\/.+$/,
|
|
14
|
+
// avoid miss in renaming
|
|
15
|
+
/\/{2,}/,
|
|
16
|
+
// avoid miss in renaming
|
|
17
|
+
/\s+\/\s+/,
|
|
18
|
+
// avoid miss in renaming
|
|
19
|
+
/.+\/edit$/,
|
|
20
|
+
/.+\.md$/,
|
|
21
|
+
/^(\.\.)$/,
|
|
22
|
+
// see: https://github.com/weseek/growi/issues/3582
|
|
23
|
+
/(\/\.\.)\/?/,
|
|
24
|
+
// see: https://github.com/weseek/growi/issues/3582
|
|
25
|
+
/\\/,
|
|
26
|
+
// see: https://github.com/weseek/growi/issues/7241
|
|
27
|
+
/^\/(_search|_private-legacy-pages)(\/.*|$)/,
|
|
28
|
+
/^\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\/.*|$)/,
|
|
29
|
+
/^\/user(?:\/[^/]+)?$/
|
|
30
|
+
// https://regex101.com/r/9Eh2S1/1
|
|
31
|
+
], f = (e) => !m.some((t) => e.match(t)), y = (e) => (e == null ? void 0 : e.username) == null ? "" : `/user/${e.username}`, D = (e, t, r) => {
|
|
32
|
+
if (t == null)
|
|
33
|
+
throw new Error("Please input the new page path");
|
|
34
|
+
const s = new RegExp(`^${n(e)}`, "i");
|
|
35
|
+
return r.replace(s, t);
|
|
36
|
+
}, U = (e) => {
|
|
37
|
+
if (e != null)
|
|
38
|
+
return e.replace(/ /g, "%20").replace(/\u3000/g, "%E3%80%80");
|
|
39
|
+
}, b = (...e) => {
|
|
40
|
+
const t = [...e].join("/");
|
|
41
|
+
if (!f(t))
|
|
42
|
+
throw new Error("Invalid characters on path");
|
|
43
|
+
try {
|
|
44
|
+
return `${new URL(t, "https://dummy").pathname}#edit`;
|
|
45
|
+
} catch {
|
|
46
|
+
throw new Error("Invalid path format");
|
|
47
|
+
}
|
|
48
|
+
}, I = (e) => {
|
|
49
|
+
const t = Array.from(new Set(e));
|
|
50
|
+
return t.filter((r) => !(t.filter((a) => new RegExp(`^${a}\\/.+`, "i").test(r)).length > 0));
|
|
51
|
+
}, O = (e) => e.filter((t) => !e.some((s) => new RegExp(`^${s.path}\\/.+`, "i").test(t.path))), _ = (e, t) => {
|
|
52
|
+
if (e === t)
|
|
53
|
+
return !0;
|
|
54
|
+
const r = i(e), s = i(t), a = new RegExp(`^${n(r)}`, "i"), c = new RegExp(`^${n(s)}`, "i");
|
|
55
|
+
return !!(a.test(t) || c.test(e));
|
|
56
|
+
}, P = (e, t) => {
|
|
57
|
+
if (e === t)
|
|
58
|
+
return !0;
|
|
59
|
+
const r = i(e);
|
|
60
|
+
return !!new RegExp(`^${n(r)}`, "i").test(t);
|
|
61
|
+
}, j = (e, t) => !P(e, t), C = (e) => e.includes("/"), W = (e) => o(e) ? new RegExp(/^\/[^/]+$/) : new RegExp(`^${e}(\\/[^/]+)\\/?$`), F = (e) => {
|
|
62
|
+
let t = null;
|
|
63
|
+
const r = e.match(/^\/user\/([^/]+)\/?/);
|
|
64
|
+
return r && (t = r[1]), t;
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
j as canMoveByPath,
|
|
68
|
+
D as convertToNewAffiliationPath,
|
|
69
|
+
U as encodeSpaces,
|
|
70
|
+
W as generateChildrenRegExp,
|
|
71
|
+
b as generateEditorPath,
|
|
72
|
+
F as getUsernameByPath,
|
|
73
|
+
C as hasSlash,
|
|
74
|
+
f as isCreatablePage,
|
|
75
|
+
_ as isEitherOfPathAreaOverlap,
|
|
76
|
+
R as isMovablePage,
|
|
77
|
+
P as isPathAreaOverlap,
|
|
78
|
+
x as isPermalink,
|
|
79
|
+
v as isSharedPage,
|
|
80
|
+
o as isTopPage,
|
|
81
|
+
T as isTrashPage,
|
|
82
|
+
S as isTrashTopPage,
|
|
83
|
+
A as isUserPage,
|
|
84
|
+
p as isUsersHomepage,
|
|
85
|
+
g as isUsersProtectedPages,
|
|
86
|
+
h as isUsersTopPage,
|
|
87
|
+
O as omitDuplicateAreaPageFromPages,
|
|
88
|
+
I as omitDuplicateAreaPathFromPaths,
|
|
89
|
+
y as userHomepagePath
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\n\nimport { IUser } from '~/interfaces';\n\nimport { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\n\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s+\\/\\s+/, // avoid miss in renaming\n /.+\\/edit$/,\n /.+\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/weseek/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/weseek/growi/issues/3582\n /\\\\/, // see: https://github.com/weseek/growi/issues/7241\n /^\\/(_search|_private-legacy-pages)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\nexport const isCreatablePage = (path: string): boolean => {\n return !restrictedPatternsToCreate.some(pattern => path.match(pattern));\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (user: IUser | null | undefined): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (oldPath: string, newPath: string, childPath: string): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${escapeStringRegexp(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?:string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n }\n catch (err) {\n throw new Error('Invalid path format');\n }\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n const isDuplicate = uniquePaths.filter(p => (new RegExp(`^${p}\\\\/.+`, 'i')).test(path)).length > 0;\n\n return !isDuplicate;\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some(p => (new RegExp(`^${p.path}\\\\/.+`, 'i')).test(page.path));\n\n return !isDuplicate;\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (path1: string, path2: string): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${escapeStringRegexp(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${escapeStringRegexp(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (pathToTest: string, pathToBeTested: string): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${escapeStringRegexp(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Generate RegExp instance for one level lower path\n */\nexport const generateChildrenRegExp = (path: string): RegExp => {\n // https://regex101.com/r/laJGzj/1\n // ex. /any_level1\n if (isTopPage(path)) return new RegExp(/^\\/[^/]+$/);\n\n // https://regex101.com/r/mrDJrx/1\n // ex. /parent/any_child OR /any_level1\n return new RegExp(`^${path}(\\\\/[^/]+)\\\\/?$`);\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\n\nexport * from './is-top-page';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","escapeStringRegexp","encodeSpaces","generateEditorPath","paths","joinedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toPath","hasSlash","str","generateChildrenRegExp","getUsernameByPath","username","match"],"mappings":";;;;AASO,MAAMA,IAAYC,GAMZC,IAAiB,CAACC,MACtBA,MAAS,SAOLC,IAAc,CAACD,MAA0B;AAC9C,QAAAE,IAAYF,EAAK,UAAU,CAAC;AAClC,SAAOG,EAAgBD,CAAS;AAClC,GAMaE,IAAkB,CAACJ,MAE1B,EAAAA,EAAK,MAAM,iBAAiB,GAUrBK,IAAwB,CAACL,MAC7BD,EAAeC,CAAI,KAAKI,EAAgBJ,CAAI,GAOxCM,IAAgB,CAACN,MACrB,CAACH,EAAUG,CAAI,KAAK,CAACK,EAAsBL,CAAI,GAO3CO,IAAa,CAACP,MAErB,EAAAA,EAAK,MAAM,eAAe,GAWnBQ,IAAiB,CAACR,MACtBA,MAAS,UAOLS,IAAc,CAACT,MAEtB,EAAAA,EAAK,MAAM,kBAAkB,GAWtBU,IAAe,CAACV,MAEvB,EAAAA,EAAK,MAAM,kBAAkB,GAO7BW,IAA4C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AACF,GACaC,IAAkB,CAACZ,MACvB,CAACW,EAA2B,KAAK,OAAWX,EAAK,MAAMa,CAAO,CAAC,GAO3DC,IAAmB,CAACC,OAC3BA,KAAA,gBAAAA,EAAM,aAAY,OACb,KAEF,SAASA,EAAK,QAAQ,IASlBC,IAA8B,CAACC,GAAiBC,GAAiBC,MAA8B;AAC1G,MAAID,KAAW;AACP,UAAA,IAAI,MAAM,gCAAgC;AAE5C,QAAAE,IAAa,IAAI,OAAO,IAAIC,EAAmBJ,CAAO,CAAC,IAAI,GAAG;AAC7D,SAAAE,EAAU,QAAQC,GAAYF,CAAO;AAC9C,GAOaI,IAAe,CAACtB,MAAqC;AAChE,MAAIA,KAAQ;AAKZ,WAAOA,EAAK,QAAQ,MAAM,KAAK,EAAE,QAAQ,WAAW,WAAW;AACjE,GAOauB,IAAqB,IAAIC,MAA4B;AAChE,QAAMC,IAAa,CAAC,GAAGD,CAAK,EAAE,KAAK,GAAG;AAElC,MAAA,CAACZ,EAAgBa,CAAU;AACvB,UAAA,IAAI,MAAM,4BAA4B;AAG1C,MAAA;AAEK,WAAA,GADK,IAAI,IAAIA,GAAY,eAAe,EACjC,QAAQ;AAAA,UAEZ;AACJ,UAAA,IAAI,MAAM,qBAAqB;AAAA,EACvC;AACF,GAQaC,IAAiC,CAACF,MAA8B;AAC3E,QAAMG,IAAc,MAAM,KAAK,IAAI,IAAIH,CAAK,CAAC;AACtC,SAAAG,EAAY,OAAO,CAAC3B,MAGlB,EAFa2B,EAAY,OAAO,CAAAC,MAAM,IAAI,OAAO,IAAIA,CAAC,SAAS,GAAG,EAAG,KAAK5B,CAAI,CAAC,EAAE,SAAS,EAGlG;AACH,GAQa6B,IAAiC,CAACC,MACtCA,EAAM,OAAO,CAACC,MAGZ,CAFaD,EAAM,KAAK,CAAAF,MAAM,IAAI,OAAO,IAAIA,EAAE,IAAI,SAAS,GAAG,EAAG,KAAKG,EAAK,IAAI,CAAC,CAGzF,GAUUC,IAA4B,CAACC,GAAeC,MAA2B;AAClF,MAAID,MAAUC;AACL,WAAA;AAGH,QAAAC,IAAiBC,EAAiBH,CAAK,GACvCI,IAAiBD,EAAiBF,CAAK,GAEvCI,IAAY,IAAI,OAAO,IAAIjB,EAAmBc,CAAc,CAAC,IAAI,GAAG,GACpEI,IAAY,IAAI,OAAO,IAAIlB,EAAmBgB,CAAc,CAAC,IAAI,GAAG;AAE1E,SAAI,GAAAC,EAAU,KAAKJ,CAAK,KAAKK,EAAU,KAAKN,CAAK;AAKnD,GASaO,IAAoB,CAACC,GAAoBC,MAAoC;AACxF,MAAID,MAAeC;AACV,WAAA;AAGH,QAAAC,IAAgBP,EAAiBK,CAAU;AAG7C,SAAA,EADmB,IAAI,OAAO,IAAIpB,EAAmBsB,CAAa,CAAC,IAAI,GAAG,EAC3D,KAAKD,CAAc;AAKxC,GAQaE,IAAgB,CAACC,GAAkBC,MACvC,CAACN,EAAkBK,GAAUC,CAAM,GAM/BC,IAAW,CAACC,MAChBA,EAAI,SAAS,GAAG,GAMZC,IAAyB,CAACjD,MAGjCH,EAAUG,CAAI,IAAU,IAAI,OAAO,WAAW,IAI3C,IAAI,OAAO,IAAIA,CAAI,iBAAiB,GAQhCkD,IAAoB,CAAClD,MAAgC;AAChE,MAAImD,IAA0B;AAExB,QAAAC,IAAQpD,EAAK,MAAM,qBAAqB;AAC9C,SAAIoD,MACFD,IAAWC,EAAM,CAAC,IAGbD;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-top-page.cjs","sources":["../../../src/utils/page-path-utils/is-top-page.ts"],"sourcesContent":["/**\n * Whether path is the top page\n * @param path\n */\nexport const isTopPage = (path: string): boolean => {\n return path === '/';\n};\n"],"names":["isTopPage","path"],"mappings":"gFAIa,MAAAA,EAAaC,GACjBA,IAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-top-page.js","sources":["../../../src/utils/page-path-utils/is-top-page.ts"],"sourcesContent":["/**\n * Whether path is the top page\n * @param path\n */\nexport const isTopPage = (path: string): boolean => {\n return path === '/';\n};\n"],"names":["isTopPage","path"],"mappings":"AAIa,MAAAA,IAAY,CAACC,MACjBA,MAAS;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./page-path-utils/is-top-page.cjs"),u=2,i=3,o="deleted",n=e=>{const{path:t,parent:r}=e;return!!(s.isTopPage(t)||r!=null)},a=e=>{const{grant:t,status:r}=e;return t===u||t===i||r===o||n(e),!0};exports.isOnTree=n;exports.isPageNormalized=a;
|
|
2
|
+
//# sourceMappingURL=page-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-utils.cjs","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import { IPage } from '..';\n\nimport { isTopPage } from './page-path-utils/is-top-page';\n\n// const GRANT_PUBLIC = 1;\nconst GRANT_RESTRICTED = 2;\nconst GRANT_SPECIFIED = 3; // DEPRECATED\n// const GRANT_OWNER = 4;\n// const GRANT_USER_GROUP = 5;\n// const PAGE_GRANT_ERROR = 1;\n// const STATUS_PUBLISHED = 'published';\nconst STATUS_DELETED = 'deleted';\n\n/**\n * Returns true if the page is on tree including the top page.\n * @param page Page\n * @returns boolean\n */\nexport const isOnTree = (page: IPage): boolean => {\n const { path, parent } = page;\n\n if (isTopPage(path)) {\n return true;\n }\n\n if (parent != null) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Returns true if the page meet the condition below.\n * - The page is on tree (has parent or the top page)\n * - The page's grant is GRANT_RESTRICTED or GRANT_SPECIFIED\n * - The page's status is STATUS_DELETED\n * This does not check grantedUser or grantedGroup.\n * @param page PageDocument\n * @returns boolean\n */\nexport const isPageNormalized = (page: IPage): boolean => {\n const { grant, status } = page;\n\n if (grant === GRANT_RESTRICTED || grant === GRANT_SPECIFIED) {\n return true;\n }\n\n if (status === STATUS_DELETED) {\n return true;\n }\n\n if (isOnTree(page)) {\n return true;\n }\n\n return true;\n};\n"],"names":["GRANT_RESTRICTED","GRANT_SPECIFIED","STATUS_DELETED","isOnTree","page","path","parent","isTopPage","isPageNormalized","grant","status"],"mappings":"qIAKMA,EAAmB,EACnBC,EAAkB,EAKlBC,EAAiB,UAOVC,EAAYC,GAAyB,CAC1C,KAAA,CAAE,KAAAC,EAAM,OAAAC,CAAW,EAAAF,EAMzB,MAJIG,GAAAA,EAAAA,UAAUF,CAAI,GAIdC,GAAU,KAKhB,EAWaE,EAAoBJ,GAAyB,CAClD,KAAA,CAAE,MAAAK,EAAO,OAAAC,CAAW,EAAAN,EAUtB,OARAK,IAAUT,GAAoBS,IAAUR,GAIxCS,IAAWR,GAIXC,EAASC,CAAI,EACR,EAIX"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IPage } from '..';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the page is on tree including the top page.
|
|
5
|
+
* @param page Page
|
|
6
|
+
* @returns boolean
|
|
7
|
+
*/
|
|
8
|
+
export declare const isOnTree: (page: IPage) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the page meet the condition below.
|
|
11
|
+
* - The page is on tree (has parent or the top page)
|
|
12
|
+
* - The page's grant is GRANT_RESTRICTED or GRANT_SPECIFIED
|
|
13
|
+
* - The page's status is STATUS_DELETED
|
|
14
|
+
* This does not check grantedUser or grantedGroup.
|
|
15
|
+
* @param page PageDocument
|
|
16
|
+
* @returns boolean
|
|
17
|
+
*/
|
|
18
|
+
export declare const isPageNormalized: (page: IPage) => boolean;
|