@growi/core 2.3.0 → 2.3.1
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/interfaces/common.cjs.map +1 -1
- package/dist/interfaces/common.js.map +1 -1
- package/dist/interfaces/growi-app-info.cjs.map +1 -1
- package/dist/interfaces/growi-app-info.js.map +1 -1
- package/dist/interfaces/growi-theme-metadata.cjs.map +1 -1
- package/dist/interfaces/primitive/string.cjs.map +1 -1
- package/dist/interfaces/primitive/string.js.map +1 -1
- package/dist/interfaces/scope.cjs +1 -1
- package/dist/interfaces/scope.cjs.map +1 -1
- package/dist/interfaces/scope.d.ts +4 -2
- package/dist/interfaces/scope.js +8 -7
- package/dist/interfaces/scope.js.map +1 -1
- package/dist/models/devided-page-path.cjs.map +1 -1
- package/dist/models/devided-page-path.js.map +1 -1
- package/dist/models/serializers/attachment-serializer.cjs.map +1 -1
- package/dist/models/serializers/attachment-serializer.js.map +1 -1
- package/dist/models/serializers/user-serializer.cjs.map +1 -1
- package/dist/models/serializers/user-serializer.js +1 -8
- package/dist/models/serializers/user-serializer.js.map +1 -1
- package/dist/models/vo/error-apiv3.cjs.map +1 -1
- package/dist/models/vo/error-apiv3.js.map +1 -1
- package/dist/remark-plugins/util/option-parser.cjs.map +1 -1
- package/dist/remark-plugins/util/option-parser.js.map +1 -1
- package/dist/swr/with-utils.cjs.map +1 -1
- package/dist/swr/with-utils.js.map +1 -1
- package/dist/utils/browser-utils.cjs.map +1 -1
- package/dist/utils/browser-utils.js.map +1 -1
- package/dist/utils/env-utils.cjs.map +1 -1
- package/dist/utils/env-utils.js.map +1 -1
- package/dist/utils/escape-string-for-regex.cjs +2 -0
- package/dist/utils/escape-string-for-regex.cjs.map +1 -0
- package/dist/utils/escape-string-for-regex.d.ts +20 -0
- package/dist/utils/escape-string-for-regex.js +5 -0
- package/dist/utils/escape-string-for-regex.js.map +1 -0
- package/dist/utils/escape-string-for-regex.spec.d.ts +1 -0
- package/dist/utils/global-event-target.cjs.map +1 -1
- package/dist/utils/global-event-target.js.map +1 -1
- package/dist/utils/growi-theme-metadata.js.map +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +14 -12
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-deep-equals.cjs.map +1 -1
- package/dist/utils/is-deep-equals.js.map +1 -1
- package/dist/utils/page-path-utils/generate-children-regexp.cjs +1 -1
- package/dist/utils/page-path-utils/generate-children-regexp.cjs.map +1 -1
- package/dist/utils/page-path-utils/generate-children-regexp.js +3 -2
- package/dist/utils/page-path-utils/generate-children-regexp.js.map +1 -1
- package/dist/utils/page-path-utils/index.cjs.map +1 -1
- package/dist/utils/page-path-utils/index.js.map +1 -1
- package/dist/utils/page-path-utils/is-top-page.cjs.map +1 -1
- package/dist/utils/page-path-utils/is-top-page.js.map +1 -1
- package/dist/utils/page-utils.cjs.map +1 -1
- package/dist/utils/page-utils.js.map +1 -1
- package/dist/utils/path-utils.cjs.map +1 -1
- package/dist/utils/path-utils.js.map +1 -1
- package/dist/utils/template-checker.cjs.map +1 -1
- package/dist/utils/template-checker.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.cjs","sources":["../../src/interfaces/common.ts"],"sourcesContent":["/*\n * Common types and interfaces\n */\n\nimport type { Types } from 'mongoose';\n\nimport { isValidObjectId } from '../utils/objectid-utils';\n\ntype ObjectId = Types.ObjectId;\n\n// Foreign key field\nexport type Ref<T> = string | ObjectId | (T & { _id: string | ObjectId });\n\nexport type Nullable<T> = T | null | undefined;\n\nexport const isRef = <T>(obj: unknown): obj is Ref<T> => {\n return (\n obj != null &&\n ((typeof obj === 'string' && isValidObjectId(obj)) ||\n (typeof obj === 'object' &&\n '_bsontype' in obj &&\n obj._bsontype === 'ObjectID') ||\n (typeof obj === 'object' && '_id' in obj))\n );\n};\n\nexport const isPopulated = <T>(\n ref: Ref<T>,\n): ref is T & { _id: string | ObjectId } => {\n return (\n ref != null &&\n typeof ref !== 'string' &&\n !('_bsontype' in ref && ref._bsontype === 'ObjectID')\n );\n};\n\nexport const getIdForRef = <T>(ref: Ref<T>): string | ObjectId => {\n return isPopulated(ref) ? ref._id : ref;\n};\n\nexport const getIdStringForRef = <T>(ref: Ref<T>): string => {\n return getIdForRef(ref).toString();\n};\n"],"names":["isRef","obj","isValidObjectId","isPopulated","ref","getIdForRef","getIdStringForRef"],"mappings":"+HAeaA,EAAYC,GAErBA,GAAO,OACL,OAAOA,GAAQ,UAAYC,kBAAgBD,CAAG,GAC7C,OAAOA,GAAQ,UACd,cAAeA,GACfA,EAAI,YAAc,YACnB,OAAOA,GAAQ,UAAY,QAASA,GAI9BE,EACXC,GAGEA,GAAO,MACP,OAAOA,GAAQ,UACf,EAAE,cAAeA,GAAOA,EAAI,YAAc,YAIjCC,EAAkBD,GACtBD,EAAYC,CAAG,EAAIA,EAAI,IAAMA,EAGzBE,EAAwBF,GAC5BC,EAAYD,CAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"common.cjs","sources":["../../src/interfaces/common.ts"],"sourcesContent":["/*\n * Common types and interfaces\n */\n\nimport type { Types } from 'mongoose';\n\nimport { isValidObjectId } from '../utils/objectid-utils';\n\ntype ObjectId = Types.ObjectId;\n\n// Foreign key field\nexport type Ref<T> = string | ObjectId | (T & { _id: string | ObjectId });\n\nexport type Nullable<T> = T | null | undefined;\n\nexport const isRef = <T>(obj: unknown): obj is Ref<T> => {\n return (\n obj != null &&\n ((typeof obj === 'string' && isValidObjectId(obj)) ||\n (typeof obj === 'object' &&\n '_bsontype' in obj &&\n obj._bsontype === 'ObjectID') ||\n (typeof obj === 'object' && '_id' in obj))\n );\n};\n\nexport const isPopulated = <T>(\n ref: Ref<T>,\n): ref is T & { _id: string | ObjectId } => {\n return (\n ref != null &&\n typeof ref !== 'string' &&\n !('_bsontype' in ref && ref._bsontype === 'ObjectID')\n );\n};\n\nexport const getIdForRef = <T>(ref: Ref<T>): string | ObjectId => {\n return isPopulated(ref) ? ref._id : ref;\n};\n\nexport const getIdStringForRef = <T>(ref: Ref<T>): string => {\n return getIdForRef(ref).toString();\n};\n"],"names":["isRef","obj","isValidObjectId","isPopulated","ref","getIdForRef","getIdStringForRef"],"mappings":"+HAeaA,EAAYC,GAErBA,GAAO,OACL,OAAOA,GAAQ,UAAYC,kBAAgBD,CAAG,GAC7C,OAAOA,GAAQ,UACd,cAAeA,GACfA,EAAI,YAAc,YACnB,OAAOA,GAAQ,UAAY,QAASA,GAI9BE,EACXC,GAGEA,GAAO,MACP,OAAOA,GAAQ,UACf,EAAE,cAAeA,GAAOA,EAAI,YAAc,YAIjCC,EAAkBD,GACtBD,EAAYC,CAAG,EAAIA,EAAI,IAAMA,EAGzBE,EAAwBF,GAC5BC,EAAYD,CAAG,EAAE,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sources":["../../src/interfaces/common.ts"],"sourcesContent":["/*\n * Common types and interfaces\n */\n\nimport type { Types } from 'mongoose';\n\nimport { isValidObjectId } from '../utils/objectid-utils';\n\ntype ObjectId = Types.ObjectId;\n\n// Foreign key field\nexport type Ref<T> = string | ObjectId | (T & { _id: string | ObjectId });\n\nexport type Nullable<T> = T | null | undefined;\n\nexport const isRef = <T>(obj: unknown): obj is Ref<T> => {\n return (\n obj != null &&\n ((typeof obj === 'string' && isValidObjectId(obj)) ||\n (typeof obj === 'object' &&\n '_bsontype' in obj &&\n obj._bsontype === 'ObjectID') ||\n (typeof obj === 'object' && '_id' in obj))\n );\n};\n\nexport const isPopulated = <T>(\n ref: Ref<T>,\n): ref is T & { _id: string | ObjectId } => {\n return (\n ref != null &&\n typeof ref !== 'string' &&\n !('_bsontype' in ref && ref._bsontype === 'ObjectID')\n );\n};\n\nexport const getIdForRef = <T>(ref: Ref<T>): string | ObjectId => {\n return isPopulated(ref) ? ref._id : ref;\n};\n\nexport const getIdStringForRef = <T>(ref: Ref<T>): string => {\n return getIdForRef(ref).toString();\n};\n"],"names":["isRef","obj","isValidObjectId","isPopulated","ref","getIdForRef","getIdStringForRef"],"mappings":";
|
|
1
|
+
{"version":3,"file":"common.js","sources":["../../src/interfaces/common.ts"],"sourcesContent":["/*\n * Common types and interfaces\n */\n\nimport type { Types } from 'mongoose';\n\nimport { isValidObjectId } from '../utils/objectid-utils';\n\ntype ObjectId = Types.ObjectId;\n\n// Foreign key field\nexport type Ref<T> = string | ObjectId | (T & { _id: string | ObjectId });\n\nexport type Nullable<T> = T | null | undefined;\n\nexport const isRef = <T>(obj: unknown): obj is Ref<T> => {\n return (\n obj != null &&\n ((typeof obj === 'string' && isValidObjectId(obj)) ||\n (typeof obj === 'object' &&\n '_bsontype' in obj &&\n obj._bsontype === 'ObjectID') ||\n (typeof obj === 'object' && '_id' in obj))\n );\n};\n\nexport const isPopulated = <T>(\n ref: Ref<T>,\n): ref is T & { _id: string | ObjectId } => {\n return (\n ref != null &&\n typeof ref !== 'string' &&\n !('_bsontype' in ref && ref._bsontype === 'ObjectID')\n );\n};\n\nexport const getIdForRef = <T>(ref: Ref<T>): string | ObjectId => {\n return isPopulated(ref) ? ref._id : ref;\n};\n\nexport const getIdStringForRef = <T>(ref: Ref<T>): string => {\n return getIdForRef(ref).toString();\n};\n"],"names":["isRef","obj","isValidObjectId","isPopulated","ref","getIdForRef","getIdStringForRef"],"mappings":";AAea,MAAAA,IAAQ,CAAIC,MAErBA,KAAO,SACL,OAAOA,KAAQ,YAAYC,EAAgBD,CAAG,KAC7C,OAAOA,KAAQ,YACd,eAAeA,KACfA,EAAI,cAAc,cACnB,OAAOA,KAAQ,YAAY,SAASA,IAI9BE,IAAc,CACzBC,MAGEA,KAAO,QACP,OAAOA,KAAQ,YACf,EAAE,eAAeA,KAAOA,EAAI,cAAc,aAIjCC,IAAc,CAAID,MACtBD,EAAYC,CAAG,IAAIA,EAAI,MAAMA,GAGzBE,IAAoB,CAAIF,MAC5BC,EAAYD,CAAG,EAAE,SAAS;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-app-info.cjs","sources":["../../src/interfaces/growi-app-info.ts"],"sourcesContent":["import type * as os from 'node:os';\n\nimport type { GrowiDeploymentType, GrowiServiceType } from '../consts/system';\n\nexport const GrowiWikiType = { open: 'open', closed: 'closed' } as const;\ntype GrowiWikiType = (typeof GrowiWikiType)[keyof typeof GrowiWikiType];\n\n// Info options for additionalInfo selection\nexport interface GrowiInfoOptions {\n includeAttachmentInfo?: boolean;\n includeInstalledInfo?: boolean;\n includeUserCountInfo?: boolean;\n includePageCountInfo?: boolean;\n // Future extensions can be added here\n}\n\ninterface IGrowiOSInfo {\n type?: ReturnType<typeof os.type>;\n platform?: ReturnType<typeof os.platform>;\n arch?: ReturnType<typeof os.arch>;\n totalmem?: ReturnType<typeof os.totalmem>;\n}\n\ninterface IAdditionalAttachmentInfo {\n attachmentType: string;\n activeExternalAccountTypes: string[];\n}\n\ninterface IAdditionalInstalledAtInfo {\n installedAt: Date;\n installedAtByOldestUser: Date | null;\n}\n\ninterface IAdditionalUserCountInfo {\n currentUsersCount: number;\n currentActiveUsersCount: number;\n}\n\ninterface IAdditionalPageCountInfo {\n currentPagesCount: number;\n}\n\nexport interface IGrowiAdditionalInfo\n extends IAdditionalInstalledAtInfo,\n IAdditionalUserCountInfo,\n IAdditionalPageCountInfo,\n IAdditionalAttachmentInfo {}\n\n// Type mapping for flexible options\nexport type IGrowiAdditionalInfoByOptions<T extends GrowiInfoOptions> =\n (T['includeAttachmentInfo'] extends true\n ? IAdditionalAttachmentInfo\n : Record<string, never>) &\n (T['includeInstalledInfo'] extends true\n ? IAdditionalInstalledAtInfo\n : Record<string, never>) &\n (T['includeUserCountInfo'] extends true\n ? IAdditionalUserCountInfo\n : Record<string, never>) &\n (T['includePageCountInfo'] extends true\n ? IAdditionalPageCountInfo\n : Record<string, never>);\n\n// Helper type to check if any option is enabled\nexport type HasAnyOption<T extends GrowiInfoOptions> =\n T['includeAttachmentInfo'] extends true\n ? true\n : T['includeInstalledInfo'] extends true\n ? true\n : T['includeUserCountInfo'] extends true\n ? true\n : T['includePageCountInfo'] extends true\n ? true\n : false;\n\n// Final result type based on options\nexport type IGrowiAdditionalInfoResult<T extends GrowiInfoOptions> =\n HasAnyOption<T> extends true ? IGrowiAdditionalInfoByOptions<T> : undefined;\n\nexport interface IGrowiInfo<A extends object | undefined = undefined> {\n serviceInstanceId: string;\n appSiteUrl: string;\n osInfo: IGrowiOSInfo;\n version: string;\n type: GrowiServiceType;\n wikiType: GrowiWikiType;\n deploymentType: GrowiDeploymentType;\n additionalInfo?: A;\n}\n"],"names":["GrowiWikiType"],"mappings":"gFAIO,MAAMA,EAAgB,CAAE,KAAM,OAAQ,OAAQ,
|
|
1
|
+
{"version":3,"file":"growi-app-info.cjs","sources":["../../src/interfaces/growi-app-info.ts"],"sourcesContent":["import type * as os from 'node:os';\n\nimport type { GrowiDeploymentType, GrowiServiceType } from '../consts/system';\n\nexport const GrowiWikiType = { open: 'open', closed: 'closed' } as const;\ntype GrowiWikiType = (typeof GrowiWikiType)[keyof typeof GrowiWikiType];\n\n// Info options for additionalInfo selection\nexport interface GrowiInfoOptions {\n includeAttachmentInfo?: boolean;\n includeInstalledInfo?: boolean;\n includeUserCountInfo?: boolean;\n includePageCountInfo?: boolean;\n // Future extensions can be added here\n}\n\ninterface IGrowiOSInfo {\n type?: ReturnType<typeof os.type>;\n platform?: ReturnType<typeof os.platform>;\n arch?: ReturnType<typeof os.arch>;\n totalmem?: ReturnType<typeof os.totalmem>;\n}\n\ninterface IAdditionalAttachmentInfo {\n attachmentType: string;\n activeExternalAccountTypes: string[];\n}\n\ninterface IAdditionalInstalledAtInfo {\n installedAt: Date;\n installedAtByOldestUser: Date | null;\n}\n\ninterface IAdditionalUserCountInfo {\n currentUsersCount: number;\n currentActiveUsersCount: number;\n}\n\ninterface IAdditionalPageCountInfo {\n currentPagesCount: number;\n}\n\nexport interface IGrowiAdditionalInfo\n extends IAdditionalInstalledAtInfo,\n IAdditionalUserCountInfo,\n IAdditionalPageCountInfo,\n IAdditionalAttachmentInfo {}\n\n// Type mapping for flexible options\nexport type IGrowiAdditionalInfoByOptions<T extends GrowiInfoOptions> =\n (T['includeAttachmentInfo'] extends true\n ? IAdditionalAttachmentInfo\n : Record<string, never>) &\n (T['includeInstalledInfo'] extends true\n ? IAdditionalInstalledAtInfo\n : Record<string, never>) &\n (T['includeUserCountInfo'] extends true\n ? IAdditionalUserCountInfo\n : Record<string, never>) &\n (T['includePageCountInfo'] extends true\n ? IAdditionalPageCountInfo\n : Record<string, never>);\n\n// Helper type to check if any option is enabled\nexport type HasAnyOption<T extends GrowiInfoOptions> =\n T['includeAttachmentInfo'] extends true\n ? true\n : T['includeInstalledInfo'] extends true\n ? true\n : T['includeUserCountInfo'] extends true\n ? true\n : T['includePageCountInfo'] extends true\n ? true\n : false;\n\n// Final result type based on options\nexport type IGrowiAdditionalInfoResult<T extends GrowiInfoOptions> =\n HasAnyOption<T> extends true ? IGrowiAdditionalInfoByOptions<T> : undefined;\n\nexport interface IGrowiInfo<A extends object | undefined = undefined> {\n serviceInstanceId: string;\n appSiteUrl: string;\n osInfo: IGrowiOSInfo;\n version: string;\n type: GrowiServiceType;\n wikiType: GrowiWikiType;\n deploymentType: GrowiDeploymentType;\n additionalInfo?: A;\n}\n"],"names":["GrowiWikiType"],"mappings":"gFAIO,MAAMA,EAAgB,CAAE,KAAM,OAAQ,OAAQ,QAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-app-info.js","sources":["../../src/interfaces/growi-app-info.ts"],"sourcesContent":["import type * as os from 'node:os';\n\nimport type { GrowiDeploymentType, GrowiServiceType } from '../consts/system';\n\nexport const GrowiWikiType = { open: 'open', closed: 'closed' } as const;\ntype GrowiWikiType = (typeof GrowiWikiType)[keyof typeof GrowiWikiType];\n\n// Info options for additionalInfo selection\nexport interface GrowiInfoOptions {\n includeAttachmentInfo?: boolean;\n includeInstalledInfo?: boolean;\n includeUserCountInfo?: boolean;\n includePageCountInfo?: boolean;\n // Future extensions can be added here\n}\n\ninterface IGrowiOSInfo {\n type?: ReturnType<typeof os.type>;\n platform?: ReturnType<typeof os.platform>;\n arch?: ReturnType<typeof os.arch>;\n totalmem?: ReturnType<typeof os.totalmem>;\n}\n\ninterface IAdditionalAttachmentInfo {\n attachmentType: string;\n activeExternalAccountTypes: string[];\n}\n\ninterface IAdditionalInstalledAtInfo {\n installedAt: Date;\n installedAtByOldestUser: Date | null;\n}\n\ninterface IAdditionalUserCountInfo {\n currentUsersCount: number;\n currentActiveUsersCount: number;\n}\n\ninterface IAdditionalPageCountInfo {\n currentPagesCount: number;\n}\n\nexport interface IGrowiAdditionalInfo\n extends IAdditionalInstalledAtInfo,\n IAdditionalUserCountInfo,\n IAdditionalPageCountInfo,\n IAdditionalAttachmentInfo {}\n\n// Type mapping for flexible options\nexport type IGrowiAdditionalInfoByOptions<T extends GrowiInfoOptions> =\n (T['includeAttachmentInfo'] extends true\n ? IAdditionalAttachmentInfo\n : Record<string, never>) &\n (T['includeInstalledInfo'] extends true\n ? IAdditionalInstalledAtInfo\n : Record<string, never>) &\n (T['includeUserCountInfo'] extends true\n ? IAdditionalUserCountInfo\n : Record<string, never>) &\n (T['includePageCountInfo'] extends true\n ? IAdditionalPageCountInfo\n : Record<string, never>);\n\n// Helper type to check if any option is enabled\nexport type HasAnyOption<T extends GrowiInfoOptions> =\n T['includeAttachmentInfo'] extends true\n ? true\n : T['includeInstalledInfo'] extends true\n ? true\n : T['includeUserCountInfo'] extends true\n ? true\n : T['includePageCountInfo'] extends true\n ? true\n : false;\n\n// Final result type based on options\nexport type IGrowiAdditionalInfoResult<T extends GrowiInfoOptions> =\n HasAnyOption<T> extends true ? IGrowiAdditionalInfoByOptions<T> : undefined;\n\nexport interface IGrowiInfo<A extends object | undefined = undefined> {\n serviceInstanceId: string;\n appSiteUrl: string;\n osInfo: IGrowiOSInfo;\n version: string;\n type: GrowiServiceType;\n wikiType: GrowiWikiType;\n deploymentType: GrowiDeploymentType;\n additionalInfo?: A;\n}\n"],"names":["GrowiWikiType"],"mappings":"AAIO,MAAMA,IAAgB,EAAE,MAAM,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"file":"growi-app-info.js","sources":["../../src/interfaces/growi-app-info.ts"],"sourcesContent":["import type * as os from 'node:os';\n\nimport type { GrowiDeploymentType, GrowiServiceType } from '../consts/system';\n\nexport const GrowiWikiType = { open: 'open', closed: 'closed' } as const;\ntype GrowiWikiType = (typeof GrowiWikiType)[keyof typeof GrowiWikiType];\n\n// Info options for additionalInfo selection\nexport interface GrowiInfoOptions {\n includeAttachmentInfo?: boolean;\n includeInstalledInfo?: boolean;\n includeUserCountInfo?: boolean;\n includePageCountInfo?: boolean;\n // Future extensions can be added here\n}\n\ninterface IGrowiOSInfo {\n type?: ReturnType<typeof os.type>;\n platform?: ReturnType<typeof os.platform>;\n arch?: ReturnType<typeof os.arch>;\n totalmem?: ReturnType<typeof os.totalmem>;\n}\n\ninterface IAdditionalAttachmentInfo {\n attachmentType: string;\n activeExternalAccountTypes: string[];\n}\n\ninterface IAdditionalInstalledAtInfo {\n installedAt: Date;\n installedAtByOldestUser: Date | null;\n}\n\ninterface IAdditionalUserCountInfo {\n currentUsersCount: number;\n currentActiveUsersCount: number;\n}\n\ninterface IAdditionalPageCountInfo {\n currentPagesCount: number;\n}\n\nexport interface IGrowiAdditionalInfo\n extends IAdditionalInstalledAtInfo,\n IAdditionalUserCountInfo,\n IAdditionalPageCountInfo,\n IAdditionalAttachmentInfo {}\n\n// Type mapping for flexible options\nexport type IGrowiAdditionalInfoByOptions<T extends GrowiInfoOptions> =\n (T['includeAttachmentInfo'] extends true\n ? IAdditionalAttachmentInfo\n : Record<string, never>) &\n (T['includeInstalledInfo'] extends true\n ? IAdditionalInstalledAtInfo\n : Record<string, never>) &\n (T['includeUserCountInfo'] extends true\n ? IAdditionalUserCountInfo\n : Record<string, never>) &\n (T['includePageCountInfo'] extends true\n ? IAdditionalPageCountInfo\n : Record<string, never>);\n\n// Helper type to check if any option is enabled\nexport type HasAnyOption<T extends GrowiInfoOptions> =\n T['includeAttachmentInfo'] extends true\n ? true\n : T['includeInstalledInfo'] extends true\n ? true\n : T['includeUserCountInfo'] extends true\n ? true\n : T['includePageCountInfo'] extends true\n ? true\n : false;\n\n// Final result type based on options\nexport type IGrowiAdditionalInfoResult<T extends GrowiInfoOptions> =\n HasAnyOption<T> extends true ? IGrowiAdditionalInfoByOptions<T> : undefined;\n\nexport interface IGrowiInfo<A extends object | undefined = undefined> {\n serviceInstanceId: string;\n appSiteUrl: string;\n osInfo: IGrowiOSInfo;\n version: string;\n type: GrowiServiceType;\n wikiType: GrowiWikiType;\n deploymentType: GrowiDeploymentType;\n additionalInfo?: A;\n}\n"],"names":["GrowiWikiType"],"mappings":"AAIO,MAAMA,IAAgB,EAAE,MAAM,QAAQ,QAAQ,SAAS;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"growi-theme-metadata.cjs","sources":["../../src/interfaces/growi-theme-metadata.ts"],"sourcesContent":["import { ColorScheme } from './color-scheme';\n\nexport const GrowiThemeSchemeType = {\n ...ColorScheme,\n BOTH: 'both',\n} as const;\nexport type GrowiThemeSchemeType =\n (typeof GrowiThemeSchemeType)[keyof typeof GrowiThemeSchemeType];\n\nexport type GrowiThemeMetadata = {\n name: string;\n manifestKey: string;\n schemeType: GrowiThemeSchemeType;\n lightBg: string;\n darkBg: string;\n lightSidebar: string;\n darkSidebar: string;\n lightIcon: string;\n darkIcon: string;\n createBtn: string;\n isPresetTheme?: boolean;\n};\n\nexport const isGrowiThemeMetadata = (\n obj: unknown,\n): obj is GrowiThemeMetadata => {\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n const objAny = obj as any;\n\n return (\n objAny != null &&\n typeof objAny === 'object' &&\n Array.isArray(objAny) === false &&\n 'name' in objAny &&\n typeof objAny.name === 'string' &&\n 'manifestKey' in objAny &&\n typeof objAny.manifestKey === 'string' &&\n 'schemeType' in objAny &&\n typeof objAny.schemeType === 'string' &&\n 'lightBg' in objAny &&\n typeof objAny.lightBg === 'string' &&\n 'darkBg' in objAny &&\n typeof objAny.darkBg === 'string' &&\n 'lightSidebar' in objAny &&\n typeof objAny.lightSidebar === 'string' &&\n 'darkSidebar' in objAny &&\n typeof objAny.darkSidebar === 'string' &&\n 'lightIcon' in objAny &&\n typeof objAny.lightIcon === 'string' &&\n 'darkIcon' in objAny &&\n typeof objAny.darkIcon === 'string' &&\n 'createBtn' in objAny &&\n typeof objAny.createBtn === 'string'\n );\n};\n"],"names":["GrowiThemeSchemeType","ColorScheme","isGrowiThemeMetadata","obj","objAny"],"mappings":"sHAEaA,EAAuB,CAClC,GAAGC,
|
|
1
|
+
{"version":3,"file":"growi-theme-metadata.cjs","sources":["../../src/interfaces/growi-theme-metadata.ts"],"sourcesContent":["import { ColorScheme } from './color-scheme';\n\nexport const GrowiThemeSchemeType = {\n ...ColorScheme,\n BOTH: 'both',\n} as const;\nexport type GrowiThemeSchemeType =\n (typeof GrowiThemeSchemeType)[keyof typeof GrowiThemeSchemeType];\n\nexport type GrowiThemeMetadata = {\n name: string;\n manifestKey: string;\n schemeType: GrowiThemeSchemeType;\n lightBg: string;\n darkBg: string;\n lightSidebar: string;\n darkSidebar: string;\n lightIcon: string;\n darkIcon: string;\n createBtn: string;\n isPresetTheme?: boolean;\n};\n\nexport const isGrowiThemeMetadata = (\n obj: unknown,\n): obj is GrowiThemeMetadata => {\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n const objAny = obj as any;\n\n return (\n objAny != null &&\n typeof objAny === 'object' &&\n Array.isArray(objAny) === false &&\n 'name' in objAny &&\n typeof objAny.name === 'string' &&\n 'manifestKey' in objAny &&\n typeof objAny.manifestKey === 'string' &&\n 'schemeType' in objAny &&\n typeof objAny.schemeType === 'string' &&\n 'lightBg' in objAny &&\n typeof objAny.lightBg === 'string' &&\n 'darkBg' in objAny &&\n typeof objAny.darkBg === 'string' &&\n 'lightSidebar' in objAny &&\n typeof objAny.lightSidebar === 'string' &&\n 'darkSidebar' in objAny &&\n typeof objAny.darkSidebar === 'string' &&\n 'lightIcon' in objAny &&\n typeof objAny.lightIcon === 'string' &&\n 'darkIcon' in objAny &&\n typeof objAny.darkIcon === 'string' &&\n 'createBtn' in objAny &&\n typeof objAny.createBtn === 'string'\n );\n};\n"],"names":["GrowiThemeSchemeType","ColorScheme","isGrowiThemeMetadata","obj","objAny"],"mappings":"sHAEaA,EAAuB,CAClC,GAAGC,EAAA,YACH,KAAM,MACR,EAkBaC,EACXC,GAC8B,CAE9B,MAAMC,EAASD,EAEf,OACEC,GAAU,MACV,OAAOA,GAAW,UAClB,MAAM,QAAQA,CAAM,IAAM,IAC1B,SAAUA,GACV,OAAOA,EAAO,MAAS,UACvB,gBAAiBA,GACjB,OAAOA,EAAO,aAAgB,UAC9B,eAAgBA,GAChB,OAAOA,EAAO,YAAe,UAC7B,YAAaA,GACb,OAAOA,EAAO,SAAY,UAC1B,WAAYA,GACZ,OAAOA,EAAO,QAAW,UACzB,iBAAkBA,GAClB,OAAOA,EAAO,cAAiB,UAC/B,gBAAiBA,GACjB,OAAOA,EAAO,aAAgB,UAC9B,cAAeA,GACf,OAAOA,EAAO,WAAc,UAC5B,aAAcA,GACd,OAAOA,EAAO,UAAa,UAC3B,cAAeA,GACf,OAAOA,EAAO,WAAc,QAEhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","sources":["../../../src/interfaces/primitive/string.ts"],"sourcesContent":["/**\n * A branded type representing a string that is guaranteed to be non-empty (length > 0).\n * This type allows distinguishing non-empty strings from regular strings at compile time.\n */\nexport type NonEmptyString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-empty string.\n * @param value - The value to check\n * @returns True if the value is a string with length > 0, false otherwise\n */\nexport const isNonEmptyString = (\n value: string | null | undefined,\n): value is NonEmptyString => {\n return value != null && value.length > 0;\n};\n\n/**\n * Converts a string to NonEmptyString type.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type\n * @throws Error if the value is null, undefined, or empty string\n */\nexport const toNonEmptyString = (value: string): NonEmptyString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonEmptyString(value))\n throw new Error(`Expected a non-empty string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonEmptyString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type, or undefined if the value is null, undefined, or empty\n */\nexport const toNonEmptyStringOrUndefined = (\n value: string | null | undefined,\n): NonEmptyString | undefined => {\n // return undefined if the value is null, undefined or empty\n if (!isNonEmptyString(value)) return undefined;\n return value;\n};\n\n/**\n * A branded type representing a string that is guaranteed to be non-blank.\n * A non-blank string contains at least one non-whitespace character.\n * This type allows distinguishing non-blank strings from regular strings at compile time.\n */\nexport type NonBlankString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-blank string.\n * A non-blank string is a string that contains at least one non-whitespace character.\n * @param value - The value to check\n * @returns True if the value is a string with trimmed length > 0, false otherwise\n */\nexport const isNonBlankString = (\n value: string | null | undefined,\n): value is NonBlankString => {\n return value != null && value.trim().length > 0;\n};\n\n/**\n * Converts a string to NonBlankString type.\n * @param value - The string to convert\n * @returns The string as NonBlankString type\n * @throws Error if the value is null, undefined, empty string, or contains only whitespace characters\n */\nexport const toNonBlankString = (value: string): NonBlankString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonBlankString(value))\n throw new Error(`Expected a non-blank string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonBlankString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonBlankString type, or undefined if the value is null, undefined, empty, or contains only whitespace characters\n */\nexport const toNonBlankStringOrUndefined = (\n value: string | null | undefined,\n): NonBlankString | undefined => {\n // return undefined if the value is null, undefined or blank (empty or whitespace only)\n if (!isNonBlankString(value)) return undefined;\n return value;\n};\n"],"names":["isNonEmptyString","value","toNonEmptyString","toNonEmptyStringOrUndefined","isNonBlankString","toNonBlankString","toNonBlankStringOrUndefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.cjs","sources":["../../../src/interfaces/primitive/string.ts"],"sourcesContent":["/**\n * A branded type representing a string that is guaranteed to be non-empty (length > 0).\n * This type allows distinguishing non-empty strings from regular strings at compile time.\n */\nexport type NonEmptyString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-empty string.\n * @param value - The value to check\n * @returns True if the value is a string with length > 0, false otherwise\n */\nexport const isNonEmptyString = (\n value: string | null | undefined,\n): value is NonEmptyString => {\n return value != null && value.length > 0;\n};\n\n/**\n * Converts a string to NonEmptyString type.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type\n * @throws Error if the value is null, undefined, or empty string\n */\nexport const toNonEmptyString = (value: string): NonEmptyString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonEmptyString(value))\n throw new Error(`Expected a non-empty string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonEmptyString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type, or undefined if the value is null, undefined, or empty\n */\nexport const toNonEmptyStringOrUndefined = (\n value: string | null | undefined,\n): NonEmptyString | undefined => {\n // return undefined if the value is null, undefined or empty\n if (!isNonEmptyString(value)) return undefined;\n return value;\n};\n\n/**\n * A branded type representing a string that is guaranteed to be non-blank.\n * A non-blank string contains at least one non-whitespace character.\n * This type allows distinguishing non-blank strings from regular strings at compile time.\n */\nexport type NonBlankString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-blank string.\n * A non-blank string is a string that contains at least one non-whitespace character.\n * @param value - The value to check\n * @returns True if the value is a string with trimmed length > 0, false otherwise\n */\nexport const isNonBlankString = (\n value: string | null | undefined,\n): value is NonBlankString => {\n return value != null && value.trim().length > 0;\n};\n\n/**\n * Converts a string to NonBlankString type.\n * @param value - The string to convert\n * @returns The string as NonBlankString type\n * @throws Error if the value is null, undefined, empty string, or contains only whitespace characters\n */\nexport const toNonBlankString = (value: string): NonBlankString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonBlankString(value))\n throw new Error(`Expected a non-blank string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonBlankString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonBlankString type, or undefined if the value is null, undefined, empty, or contains only whitespace characters\n */\nexport const toNonBlankStringOrUndefined = (\n value: string | null | undefined,\n): NonBlankString | undefined => {\n // return undefined if the value is null, undefined or blank (empty or whitespace only)\n if (!isNonBlankString(value)) return undefined;\n return value;\n};\n"],"names":["isNonEmptyString","value","toNonEmptyString","toNonEmptyStringOrUndefined","isNonBlankString","toNonBlankString","toNonBlankStringOrUndefined"],"mappings":"gFAWa,MAAAA,EACXC,GAEOA,GAAS,MAAQA,EAAM,OAAS,EAS5BC,EAAoBD,GAAkC,CAE7D,GAAA,CAACD,EAAiBC,CAAK,EACzB,MAAM,IAAI,MAAM,8CAA8CA,CAAK,EAAE,EAChE,OAAAA,CACT,EAOaE,EACXF,GAC+B,CAE/B,GAAKD,EAAiBC,CAAK,EACpB,OAAAA,CACT,EAeaG,EACXH,GAEOA,GAAS,MAAQA,EAAM,OAAO,OAAS,EASnCI,EAAoBJ,GAAkC,CAE7D,GAAA,CAACG,EAAiBH,CAAK,EACzB,MAAM,IAAI,MAAM,8CAA8CA,CAAK,EAAE,EAChE,OAAAA,CACT,EAOaK,EACXL,GAC+B,CAE/B,GAAKG,EAAiBH,CAAK,EACpB,OAAAA,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sources":["../../../src/interfaces/primitive/string.ts"],"sourcesContent":["/**\n * A branded type representing a string that is guaranteed to be non-empty (length > 0).\n * This type allows distinguishing non-empty strings from regular strings at compile time.\n */\nexport type NonEmptyString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-empty string.\n * @param value - The value to check\n * @returns True if the value is a string with length > 0, false otherwise\n */\nexport const isNonEmptyString = (\n value: string | null | undefined,\n): value is NonEmptyString => {\n return value != null && value.length > 0;\n};\n\n/**\n * Converts a string to NonEmptyString type.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type\n * @throws Error if the value is null, undefined, or empty string\n */\nexport const toNonEmptyString = (value: string): NonEmptyString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonEmptyString(value))\n throw new Error(`Expected a non-empty string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonEmptyString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type, or undefined if the value is null, undefined, or empty\n */\nexport const toNonEmptyStringOrUndefined = (\n value: string | null | undefined,\n): NonEmptyString | undefined => {\n // return undefined if the value is null, undefined or empty\n if (!isNonEmptyString(value)) return undefined;\n return value;\n};\n\n/**\n * A branded type representing a string that is guaranteed to be non-blank.\n * A non-blank string contains at least one non-whitespace character.\n * This type allows distinguishing non-blank strings from regular strings at compile time.\n */\nexport type NonBlankString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-blank string.\n * A non-blank string is a string that contains at least one non-whitespace character.\n * @param value - The value to check\n * @returns True if the value is a string with trimmed length > 0, false otherwise\n */\nexport const isNonBlankString = (\n value: string | null | undefined,\n): value is NonBlankString => {\n return value != null && value.trim().length > 0;\n};\n\n/**\n * Converts a string to NonBlankString type.\n * @param value - The string to convert\n * @returns The string as NonBlankString type\n * @throws Error if the value is null, undefined, empty string, or contains only whitespace characters\n */\nexport const toNonBlankString = (value: string): NonBlankString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonBlankString(value))\n throw new Error(`Expected a non-blank string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonBlankString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonBlankString type, or undefined if the value is null, undefined, empty, or contains only whitespace characters\n */\nexport const toNonBlankStringOrUndefined = (\n value: string | null | undefined,\n): NonBlankString | undefined => {\n // return undefined if the value is null, undefined or blank (empty or whitespace only)\n if (!isNonBlankString(value)) return undefined;\n return value;\n};\n"],"names":["isNonEmptyString","value","toNonEmptyString","toNonEmptyStringOrUndefined","isNonBlankString","toNonBlankString","toNonBlankStringOrUndefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.js","sources":["../../../src/interfaces/primitive/string.ts"],"sourcesContent":["/**\n * A branded type representing a string that is guaranteed to be non-empty (length > 0).\n * This type allows distinguishing non-empty strings from regular strings at compile time.\n */\nexport type NonEmptyString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-empty string.\n * @param value - The value to check\n * @returns True if the value is a string with length > 0, false otherwise\n */\nexport const isNonEmptyString = (\n value: string | null | undefined,\n): value is NonEmptyString => {\n return value != null && value.length > 0;\n};\n\n/**\n * Converts a string to NonEmptyString type.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type\n * @throws Error if the value is null, undefined, or empty string\n */\nexport const toNonEmptyString = (value: string): NonEmptyString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonEmptyString(value))\n throw new Error(`Expected a non-empty string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonEmptyString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonEmptyString type, or undefined if the value is null, undefined, or empty\n */\nexport const toNonEmptyStringOrUndefined = (\n value: string | null | undefined,\n): NonEmptyString | undefined => {\n // return undefined if the value is null, undefined or empty\n if (!isNonEmptyString(value)) return undefined;\n return value;\n};\n\n/**\n * A branded type representing a string that is guaranteed to be non-blank.\n * A non-blank string contains at least one non-whitespace character.\n * This type allows distinguishing non-blank strings from regular strings at compile time.\n */\nexport type NonBlankString = string & { readonly __brand: unique symbol };\n\n/**\n * Checks if a value is a non-blank string.\n * A non-blank string is a string that contains at least one non-whitespace character.\n * @param value - The value to check\n * @returns True if the value is a string with trimmed length > 0, false otherwise\n */\nexport const isNonBlankString = (\n value: string | null | undefined,\n): value is NonBlankString => {\n return value != null && value.trim().length > 0;\n};\n\n/**\n * Converts a string to NonBlankString type.\n * @param value - The string to convert\n * @returns The string as NonBlankString type\n * @throws Error if the value is null, undefined, empty string, or contains only whitespace characters\n */\nexport const toNonBlankString = (value: string): NonBlankString => {\n // throw Error if the value is null, undefined or empty\n if (!isNonBlankString(value))\n throw new Error(`Expected a non-blank string, but received: ${value}`);\n return value;\n};\n\n/**\n * Converts a string to NonBlankString type or returns undefined.\n * @param value - The string to convert\n * @returns The string as NonBlankString type, or undefined if the value is null, undefined, empty, or contains only whitespace characters\n */\nexport const toNonBlankStringOrUndefined = (\n value: string | null | undefined,\n): NonBlankString | undefined => {\n // return undefined if the value is null, undefined or blank (empty or whitespace only)\n if (!isNonBlankString(value)) return undefined;\n return value;\n};\n"],"names":["isNonEmptyString","value","toNonEmptyString","toNonEmptyStringOrUndefined","isNonBlankString","toNonBlankString","toNonBlankStringOrUndefined"],"mappings":"AAWa,MAAAA,IAAmB,CAC9BC,MAEOA,KAAS,QAAQA,EAAM,SAAS,GAS5BC,IAAmB,CAACD,MAAkC;AAE7D,MAAA,CAACD,EAAiBC,CAAK;AACzB,UAAM,IAAI,MAAM,8CAA8CA,CAAK,EAAE;AAChE,SAAAA;AACT,GAOaE,IAA8B,CACzCF,MAC+B;AAE/B,MAAKD,EAAiBC,CAAK;AACpB,WAAAA;AACT,GAeaG,IAAmB,CAC9BH,MAEOA,KAAS,QAAQA,EAAM,OAAO,SAAS,GASnCI,IAAmB,CAACJ,MAAkC;AAE7D,MAAA,CAACG,EAAiBH,CAAK;AACzB,UAAM,IAAI,MAAM,8CAA8CA,CAAK,EAAE;AAChE,SAAAA;AACT,GAOaK,IAA8B,CACzCL,MAC+B;AAE/B,MAAKG,EAAiBH,CAAK;AACpB,WAAAA;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={admin:{top:{},app:{},security:{},markdown:{},customize:{},import_data:{},export_data:{},data_transfer:{},external_notification:{},slack_integration:{},legacy_slack_integration:{},user_management:{},user_group_management:{},audit_log:{},plugin:{},ai_integration:{},full_text_search:{}}},E={user_settings:{info:{},external_account:{},password:{},api:{api_token:{},access_token:{}},in_app_notification:{},other:{}},features:{ai_assistant:{},page:{},share_link:{},bookmark:{},attachment:{},page_bulk_export:{}}},S={...l,...E},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={admin:{top:{},app:{},security:{},markdown:{},customize:{},import_data:{},export_data:{},data_transfer:{},external_notification:{},slack_integration:{},legacy_slack_integration:{},user_management:{},user_group_management:{},audit_log:{},plugin:{},ai_integration:{},full_text_search:{}}},E={user_settings:{info:{},external_account:{},password:{},api:{api_token:{},access_token:{}},in_app_notification:{},other:{}},features:{ai_assistant:{},page:{},share_link:{},bookmark:{},attachment:{},page_bulk_export:{},in_app_notification:{}}},S={...l,...E},r={READ:"read",WRITE:"write"},_="*",f=Object.values(r).reduce((t,n)=>(t[n]=S,t),{}),g=()=>{const t={},n=(p,u=[],o)=>{for(const[s,e]of Object.entries(p)){const a=s.toUpperCase(),i=[...u,s],c=i.join(":");e!=null&&(typeof e=="object"&&Object.keys(e).length===0?o[a]=`${c}`:typeof e=="object"&&(o[a]={ALL:`${c}:${_}`},n(e,i,o[a])))}};return n(f,[],t),t},d=g();exports.ACTION=r;exports.ALL_SIGN=_;exports.SCOPE=d;
|
|
2
2
|
//# sourceMappingURL=scope.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.cjs","sources":["../../src/interfaces/scope.ts"],"sourcesContent":["// SCOPE_SEED defines the basic scope structure.\n// When you need to set different permissions for Admin and User\n// on specific endpoints (like /me), use SCOPE rather than modifying SCOPE_SEED.\n\n// If you want to add a new scope:\n// 1. Add a new key to the SCOPE_SEED object below\n// 2. Add the corresponding scope strings to the Scope type union at the bottom of this file\n// 3. Change translation file contents (accesstoken_scopes_desc) when scope structure is modified\n\nconst SCOPE_SEED_ADMIN = {\n admin: {\n top: {},\n app: {},\n security: {},\n markdown: {},\n customize: {},\n import_data: {},\n export_data: {},\n data_transfer: {},\n external_notification: {},\n slack_integration: {},\n legacy_slack_integration: {},\n user_management: {},\n user_group_management: {},\n audit_log: {},\n plugin: {},\n ai_integration: {},\n full_text_search: {},\n },\n} as const;\n\nconst SCOPE_SEED_USER = {\n user_settings: {\n info: {},\n external_account: {},\n password: {},\n api: {\n api_token: {},\n access_token: {},\n },\n in_app_notification: {},\n other: {},\n },\n features: {\n ai_assistant: {},\n page: {},\n share_link: {},\n bookmark: {},\n attachment: {},\n page_bulk_export: {},\n },\n} as const;\n\nconst SCOPE_SEED = {\n ...SCOPE_SEED_ADMIN,\n ...SCOPE_SEED_USER,\n} as const;\n\nexport const ACTION = {\n READ: 'read',\n WRITE: 'write',\n} as const;\n\ntype ACTION_TYPE = (typeof ACTION)[keyof typeof ACTION];\nexport const ALL_SIGN = '*';\n\nconst SCOPE_SEED_WITH_ACTION = Object.values(ACTION).reduce(\n (acc, action) => {\n acc[action] = SCOPE_SEED;\n return acc;\n },\n {} as Record<ACTION_TYPE, typeof SCOPE_SEED>,\n);\n\n// ============================================================================\n// SCOPE LITERAL TYPE\n// ============================================================================\n// This type is explicitly defined to avoid TS2589 \"Type instantiation is\n// excessively deep\" errors that occur with recursive type definitions.\n//\n// IMPORTANT: When modifying SCOPE_SEED above, update this type union accordingly.\n// The scope strings follow the pattern: {action}:{category}[:{subcategory}[:{item}]]\n// Wildcard scopes use '*' at any level: {action}:{category}:*\n// ============================================================================\n\n// Read scopes - Admin\ntype ReadAdminScope =\n | 'read:admin:top'\n | 'read:admin:app'\n | 'read:admin:security'\n | 'read:admin:markdown'\n | 'read:admin:customize'\n | 'read:admin:import_data'\n | 'read:admin:export_data'\n | 'read:admin:data_transfer'\n | 'read:admin:external_notification'\n | 'read:admin:slack_integration'\n | 'read:admin:legacy_slack_integration'\n | 'read:admin:user_management'\n | 'read:admin:user_group_management'\n | 'read:admin:audit_log'\n | 'read:admin:plugin'\n | 'read:admin:ai_integration'\n | 'read:admin:full_text_search'\n | 'read:admin:*';\n\n// Read scopes - User Settings\ntype ReadUserSettingsScope =\n | 'read:user_settings:info'\n | 'read:user_settings:external_account'\n | 'read:user_settings:password'\n | 'read:user_settings:api:api_token'\n | 'read:user_settings:api:access_token'\n | 'read:user_settings:api:*'\n | 'read:user_settings:in_app_notification'\n | 'read:user_settings:other'\n | 'read:user_settings:*';\n\n// Read scopes - Features\ntype ReadFeaturesScope =\n | 'read:features:ai_assistant'\n | 'read:features:page'\n | 'read:features:share_link'\n | 'read:features:bookmark'\n | 'read:features:attachment'\n | 'read:features:page_bulk_export'\n | 'read:features:*';\n\n// Write scopes - Admin\ntype WriteAdminScope =\n | 'write:admin:top'\n | 'write:admin:app'\n | 'write:admin:security'\n | 'write:admin:markdown'\n | 'write:admin:customize'\n | 'write:admin:import_data'\n | 'write:admin:export_data'\n | 'write:admin:data_transfer'\n | 'write:admin:external_notification'\n | 'write:admin:slack_integration'\n | 'write:admin:legacy_slack_integration'\n | 'write:admin:user_management'\n | 'write:admin:user_group_management'\n | 'write:admin:audit_log'\n | 'write:admin:plugin'\n | 'write:admin:ai_integration'\n | 'write:admin:full_text_search'\n | 'write:admin:*';\n\n// Write scopes - User Settings\ntype WriteUserSettingsScope =\n | 'write:user_settings:info'\n | 'write:user_settings:external_account'\n | 'write:user_settings:password'\n | 'write:user_settings:api:api_token'\n | 'write:user_settings:api:access_token'\n | 'write:user_settings:api:*'\n | 'write:user_settings:in_app_notification'\n | 'write:user_settings:other'\n | 'write:user_settings:*';\n\n// Write scopes - Features\ntype WriteFeaturesScope =\n | 'write:features:ai_assistant'\n | 'write:features:page'\n | 'write:features:share_link'\n | 'write:features:bookmark'\n | 'write:features:attachment'\n | 'write:features:page_bulk_export'\n | 'write:features:*';\n\n// Combined Scope type - all valid scope strings\nexport type Scope =\n | ReadAdminScope\n | ReadUserSettingsScope\n | ReadFeaturesScope\n | WriteAdminScope\n | WriteUserSettingsScope\n | WriteFeaturesScope\n | 'read:*'\n | 'write:*';\n\n// ScopeConstants type definition\ntype ScopeConstantLeaf = Scope;\n\ntype ScopeConstantNode<T> = {\n [K in keyof T as Uppercase<string & K>]: T[K] extends object\n ? keyof T[K] extends never\n ? ScopeConstantLeaf\n : ScopeConstantNode<T[K]> & { ALL: Scope }\n : ScopeConstantLeaf;\n};\n\ntype ScopeConstantType = {\n [A in keyof typeof SCOPE_SEED_WITH_ACTION as Uppercase<\n string & A\n >]: ScopeConstantNode<typeof SCOPE_SEED> & { ALL: Scope };\n};\n\nconst buildScopeConstants = (): ScopeConstantType => {\n const result = {} as Partial<ScopeConstantType>;\n\n const processObject = (\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n obj: Record<string, any>,\n path: string[] = [],\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n resultObj: Record<string, any>,\n ) => {\n for (const [key, value] of Object.entries(obj)) {\n const upperKey = key.toUpperCase();\n const currentPath = [...path, key];\n const scopePath = currentPath.join(':');\n\n if (value == null) {\n continue; // Changed from 'return' to 'continue' to match the loop behavior\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n resultObj[upperKey] = `${scopePath}` as Scope;\n } else if (typeof value === 'object') {\n resultObj[upperKey] = {\n ALL: `${scopePath}:${ALL_SIGN}` as Scope,\n };\n\n processObject(value, currentPath, resultObj[upperKey]);\n }\n }\n };\n processObject(SCOPE_SEED_WITH_ACTION, [], result);\n\n return result as ScopeConstantType;\n};\n\nexport const SCOPE = buildScopeConstants();\n"],"names":["SCOPE_SEED_ADMIN","SCOPE_SEED_USER","SCOPE_SEED","ACTION","ALL_SIGN","SCOPE_SEED_WITH_ACTION","acc","action","buildScopeConstants","result","processObject","obj","path","resultObj","key","value","upperKey","currentPath","scopePath","SCOPE"],"mappings":"gFASA,MAAMA,EAAmB,CACvB,MAAO,CACL,IAAK,
|
|
1
|
+
{"version":3,"file":"scope.cjs","sources":["../../src/interfaces/scope.ts"],"sourcesContent":["// SCOPE_SEED defines the basic scope structure.\n// When you need to set different permissions for Admin and User\n// on specific endpoints (like /me), use SCOPE rather than modifying SCOPE_SEED.\n\n// If you want to add a new scope:\n// 1. Add a new key to the SCOPE_SEED object below\n// 2. Add the corresponding scope strings to the Scope type union at the bottom of this file\n// 3. Change translation file contents (accesstoken_scopes_desc) when scope structure is modified\n\nconst SCOPE_SEED_ADMIN = {\n admin: {\n top: {},\n app: {},\n security: {},\n markdown: {},\n customize: {},\n import_data: {},\n export_data: {},\n data_transfer: {},\n external_notification: {},\n slack_integration: {},\n legacy_slack_integration: {},\n user_management: {},\n user_group_management: {},\n audit_log: {},\n plugin: {},\n ai_integration: {},\n full_text_search: {},\n },\n} as const;\n\nconst SCOPE_SEED_USER = {\n user_settings: {\n info: {},\n external_account: {},\n password: {},\n api: {\n api_token: {},\n access_token: {},\n },\n in_app_notification: {},\n other: {},\n },\n features: {\n ai_assistant: {},\n page: {},\n share_link: {},\n bookmark: {},\n attachment: {},\n page_bulk_export: {},\n in_app_notification: {},\n },\n} as const;\n\nconst SCOPE_SEED = {\n ...SCOPE_SEED_ADMIN,\n ...SCOPE_SEED_USER,\n} as const;\n\nexport const ACTION = {\n READ: 'read',\n WRITE: 'write',\n} as const;\n\ntype ACTION_TYPE = (typeof ACTION)[keyof typeof ACTION];\nexport const ALL_SIGN = '*';\n\nconst SCOPE_SEED_WITH_ACTION = Object.values(ACTION).reduce(\n (acc, action) => {\n acc[action] = SCOPE_SEED;\n return acc;\n },\n {} as Record<ACTION_TYPE, typeof SCOPE_SEED>,\n);\n\n// ============================================================================\n// SCOPE LITERAL TYPE\n// ============================================================================\n// This type is explicitly defined to avoid TS2589 \"Type instantiation is\n// excessively deep\" errors that occur with recursive type definitions.\n//\n// IMPORTANT: When modifying SCOPE_SEED above, update this type union accordingly.\n// The scope strings follow the pattern: {action}:{category}[:{subcategory}[:{item}]]\n// Wildcard scopes use '*' at any level: {action}:{category}:*\n// ============================================================================\n\n// Read scopes - Admin\ntype ReadAdminScope =\n | 'read:admin:top'\n | 'read:admin:app'\n | 'read:admin:security'\n | 'read:admin:markdown'\n | 'read:admin:customize'\n | 'read:admin:import_data'\n | 'read:admin:export_data'\n | 'read:admin:data_transfer'\n | 'read:admin:external_notification'\n | 'read:admin:slack_integration'\n | 'read:admin:legacy_slack_integration'\n | 'read:admin:user_management'\n | 'read:admin:user_group_management'\n | 'read:admin:audit_log'\n | 'read:admin:plugin'\n | 'read:admin:ai_integration'\n | 'read:admin:full_text_search'\n | 'read:admin:*';\n\n// Read scopes - User Settings\ntype ReadUserSettingsScope =\n | 'read:user_settings:info'\n | 'read:user_settings:external_account'\n | 'read:user_settings:password'\n | 'read:user_settings:api:api_token'\n | 'read:user_settings:api:access_token'\n | 'read:user_settings:api:*'\n | 'read:user_settings:in_app_notification'\n | 'read:user_settings:other'\n | 'read:user_settings:*';\n\n// Read scopes - Features\ntype ReadFeaturesScope =\n | 'read:features:ai_assistant'\n | 'read:features:page'\n | 'read:features:share_link'\n | 'read:features:bookmark'\n | 'read:features:attachment'\n | 'read:features:page_bulk_export'\n | 'read:features:in_app_notification'\n | 'read:features:*';\n\n// Write scopes - Admin\ntype WriteAdminScope =\n | 'write:admin:top'\n | 'write:admin:app'\n | 'write:admin:security'\n | 'write:admin:markdown'\n | 'write:admin:customize'\n | 'write:admin:import_data'\n | 'write:admin:export_data'\n | 'write:admin:data_transfer'\n | 'write:admin:external_notification'\n | 'write:admin:slack_integration'\n | 'write:admin:legacy_slack_integration'\n | 'write:admin:user_management'\n | 'write:admin:user_group_management'\n | 'write:admin:audit_log'\n | 'write:admin:plugin'\n | 'write:admin:ai_integration'\n | 'write:admin:full_text_search'\n | 'write:admin:*';\n\n// Write scopes - User Settings\ntype WriteUserSettingsScope =\n | 'write:user_settings:info'\n | 'write:user_settings:external_account'\n | 'write:user_settings:password'\n | 'write:user_settings:api:api_token'\n | 'write:user_settings:api:access_token'\n | 'write:user_settings:api:*'\n | 'write:user_settings:in_app_notification'\n | 'write:user_settings:other'\n | 'write:user_settings:*';\n\n// Write scopes - Features\ntype WriteFeaturesScope =\n | 'write:features:ai_assistant'\n | 'write:features:page'\n | 'write:features:share_link'\n | 'write:features:bookmark'\n | 'write:features:attachment'\n | 'write:features:page_bulk_export'\n | 'write:features:in_app_notification'\n | 'write:features:*';\n\n// Combined Scope type - all valid scope strings\nexport type Scope =\n | ReadAdminScope\n | ReadUserSettingsScope\n | ReadFeaturesScope\n | WriteAdminScope\n | WriteUserSettingsScope\n | WriteFeaturesScope\n | 'read:*'\n | 'write:*';\n\n// ScopeConstants type definition\ntype ScopeConstantLeaf = Scope;\n\ntype ScopeConstantNode<T> = {\n [K in keyof T as Uppercase<string & K>]: T[K] extends object\n ? keyof T[K] extends never\n ? ScopeConstantLeaf\n : ScopeConstantNode<T[K]> & { ALL: Scope }\n : ScopeConstantLeaf;\n};\n\ntype ScopeConstantType = {\n [A in keyof typeof SCOPE_SEED_WITH_ACTION as Uppercase<\n string & A\n >]: ScopeConstantNode<typeof SCOPE_SEED> & { ALL: Scope };\n};\n\nconst buildScopeConstants = (): ScopeConstantType => {\n const result = {} as Partial<ScopeConstantType>;\n\n const processObject = (\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n obj: Record<string, any>,\n path: string[] = [],\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n resultObj: Record<string, any>,\n ) => {\n for (const [key, value] of Object.entries(obj)) {\n const upperKey = key.toUpperCase();\n const currentPath = [...path, key];\n const scopePath = currentPath.join(':');\n\n if (value == null) {\n continue; // Changed from 'return' to 'continue' to match the loop behavior\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n resultObj[upperKey] = `${scopePath}` as Scope;\n } else if (typeof value === 'object') {\n resultObj[upperKey] = {\n ALL: `${scopePath}:${ALL_SIGN}` as Scope,\n };\n\n processObject(value, currentPath, resultObj[upperKey]);\n }\n }\n };\n processObject(SCOPE_SEED_WITH_ACTION, [], result);\n\n return result as ScopeConstantType;\n};\n\nexport const SCOPE = buildScopeConstants();\n"],"names":["SCOPE_SEED_ADMIN","SCOPE_SEED_USER","SCOPE_SEED","ACTION","ALL_SIGN","SCOPE_SEED_WITH_ACTION","acc","action","buildScopeConstants","result","processObject","obj","path","resultObj","key","value","upperKey","currentPath","scopePath","SCOPE"],"mappings":"gFASA,MAAMA,EAAmB,CACvB,MAAO,CACL,IAAK,CAAC,EACN,IAAK,CAAC,EACN,SAAU,CAAC,EACX,SAAU,CAAC,EACX,UAAW,CAAC,EACZ,YAAa,CAAC,EACd,YAAa,CAAC,EACd,cAAe,CAAC,EAChB,sBAAuB,CAAC,EACxB,kBAAmB,CAAC,EACpB,yBAA0B,CAAC,EAC3B,gBAAiB,CAAC,EAClB,sBAAuB,CAAC,EACxB,UAAW,CAAC,EACZ,OAAQ,CAAC,EACT,eAAgB,CAAC,EACjB,iBAAkB,CAAA,CAAC,CAEvB,EAEMC,EAAkB,CACtB,cAAe,CACb,KAAM,CAAC,EACP,iBAAkB,CAAC,EACnB,SAAU,CAAC,EACX,IAAK,CACH,UAAW,CAAC,EACZ,aAAc,CAAA,CAChB,EACA,oBAAqB,CAAC,EACtB,MAAO,CAAA,CACT,EACA,SAAU,CACR,aAAc,CAAC,EACf,KAAM,CAAC,EACP,WAAY,CAAC,EACb,SAAU,CAAC,EACX,WAAY,CAAC,EACb,iBAAkB,CAAC,EACnB,oBAAqB,CAAA,CAAC,CAE1B,EAEMC,EAAa,CACjB,GAAGF,EACH,GAAGC,CACL,EAEaE,EAAS,CACpB,KAAM,OACN,MAAO,OACT,EAGaC,EAAW,IAElBC,EAAyB,OAAO,OAAOF,CAAM,EAAE,OACnD,CAACG,EAAKC,KACJD,EAAIC,CAAM,EAAIL,EACPI,GAET,CAAA,CACF,EAiIME,EAAsB,IAAyB,CACnD,MAAMC,EAAS,CAAC,EAEVC,EAAgB,CAEpBC,EACAC,EAAiB,CAAA,EAEjBC,IACG,CACH,SAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQJ,CAAG,EAAG,CACxC,MAAAK,EAAWF,EAAI,YAAY,EAC3BG,EAAc,CAAC,GAAGL,EAAME,CAAG,EAC3BI,EAAYD,EAAY,KAAK,GAAG,EAElCF,GAAS,OAIT,OAAOA,GAAU,UAAY,OAAO,KAAKA,CAAK,EAAE,SAAW,EACnDF,EAAAG,CAAQ,EAAI,GAAGE,CAAS,GACzB,OAAOH,GAAU,WAC1BF,EAAUG,CAAQ,EAAI,CACpB,IAAK,GAAGE,CAAS,IAAId,CAAQ,EAC/B,EAEAM,EAAcK,EAAOE,EAAaJ,EAAUG,CAAQ,CAAC,GACvD,CAEJ,EACc,OAAAN,EAAAL,EAAwB,CAAC,EAAGI,CAAM,EAEzCA,CACT,EAEaU,EAAQX,EAAoB"}
|
|
@@ -17,6 +17,7 @@ declare const SCOPE_SEED: {
|
|
|
17
17
|
readonly bookmark: {};
|
|
18
18
|
readonly attachment: {};
|
|
19
19
|
readonly page_bulk_export: {};
|
|
20
|
+
readonly in_app_notification: {};
|
|
20
21
|
};
|
|
21
22
|
readonly admin: {
|
|
22
23
|
readonly top: {};
|
|
@@ -63,6 +64,7 @@ declare const SCOPE_SEED_WITH_ACTION: Record<ACTION_TYPE, {
|
|
|
63
64
|
readonly bookmark: {};
|
|
64
65
|
readonly attachment: {};
|
|
65
66
|
readonly page_bulk_export: {};
|
|
67
|
+
readonly in_app_notification: {};
|
|
66
68
|
};
|
|
67
69
|
readonly admin: {
|
|
68
70
|
readonly top: {};
|
|
@@ -86,10 +88,10 @@ declare const SCOPE_SEED_WITH_ACTION: Record<ACTION_TYPE, {
|
|
|
86
88
|
}>;
|
|
87
89
|
type ReadAdminScope = 'read:admin:top' | 'read:admin:app' | 'read:admin:security' | 'read:admin:markdown' | 'read:admin:customize' | 'read:admin:import_data' | 'read:admin:export_data' | 'read:admin:data_transfer' | 'read:admin:external_notification' | 'read:admin:slack_integration' | 'read:admin:legacy_slack_integration' | 'read:admin:user_management' | 'read:admin:user_group_management' | 'read:admin:audit_log' | 'read:admin:plugin' | 'read:admin:ai_integration' | 'read:admin:full_text_search' | 'read:admin:*';
|
|
88
90
|
type ReadUserSettingsScope = 'read:user_settings:info' | 'read:user_settings:external_account' | 'read:user_settings:password' | 'read:user_settings:api:api_token' | 'read:user_settings:api:access_token' | 'read:user_settings:api:*' | 'read:user_settings:in_app_notification' | 'read:user_settings:other' | 'read:user_settings:*';
|
|
89
|
-
type ReadFeaturesScope = 'read:features:ai_assistant' | 'read:features:page' | 'read:features:share_link' | 'read:features:bookmark' | 'read:features:attachment' | 'read:features:page_bulk_export' | 'read:features:*';
|
|
91
|
+
type ReadFeaturesScope = 'read:features:ai_assistant' | 'read:features:page' | 'read:features:share_link' | 'read:features:bookmark' | 'read:features:attachment' | 'read:features:page_bulk_export' | 'read:features:in_app_notification' | 'read:features:*';
|
|
90
92
|
type WriteAdminScope = 'write:admin:top' | 'write:admin:app' | 'write:admin:security' | 'write:admin:markdown' | 'write:admin:customize' | 'write:admin:import_data' | 'write:admin:export_data' | 'write:admin:data_transfer' | 'write:admin:external_notification' | 'write:admin:slack_integration' | 'write:admin:legacy_slack_integration' | 'write:admin:user_management' | 'write:admin:user_group_management' | 'write:admin:audit_log' | 'write:admin:plugin' | 'write:admin:ai_integration' | 'write:admin:full_text_search' | 'write:admin:*';
|
|
91
93
|
type WriteUserSettingsScope = 'write:user_settings:info' | 'write:user_settings:external_account' | 'write:user_settings:password' | 'write:user_settings:api:api_token' | 'write:user_settings:api:access_token' | 'write:user_settings:api:*' | 'write:user_settings:in_app_notification' | 'write:user_settings:other' | 'write:user_settings:*';
|
|
92
|
-
type WriteFeaturesScope = 'write:features:ai_assistant' | 'write:features:page' | 'write:features:share_link' | 'write:features:bookmark' | 'write:features:attachment' | 'write:features:page_bulk_export' | 'write:features:*';
|
|
94
|
+
type WriteFeaturesScope = 'write:features:ai_assistant' | 'write:features:page' | 'write:features:share_link' | 'write:features:bookmark' | 'write:features:attachment' | 'write:features:page_bulk_export' | 'write:features:in_app_notification' | 'write:features:*';
|
|
93
95
|
export type Scope = ReadAdminScope | ReadUserSettingsScope | ReadFeaturesScope | WriteAdminScope | WriteUserSettingsScope | WriteFeaturesScope | 'read:*' | 'write:*';
|
|
94
96
|
type ScopeConstantLeaf = Scope;
|
|
95
97
|
type ScopeConstantNode<T> = {
|
package/dist/interfaces/scope.js
CHANGED
|
@@ -36,7 +36,8 @@ const p = {
|
|
|
36
36
|
share_link: {},
|
|
37
37
|
bookmark: {},
|
|
38
38
|
attachment: {},
|
|
39
|
-
page_bulk_export: {}
|
|
39
|
+
page_bulk_export: {},
|
|
40
|
+
in_app_notification: {}
|
|
40
41
|
}
|
|
41
42
|
}, l = {
|
|
42
43
|
...p,
|
|
@@ -48,12 +49,12 @@ const p = {
|
|
|
48
49
|
(t, n) => (t[n] = l, t),
|
|
49
50
|
{}
|
|
50
51
|
), S = () => {
|
|
51
|
-
const t = {}, n = (
|
|
52
|
-
for (const [s, e] of Object.entries(
|
|
53
|
-
const a = s.toUpperCase(),
|
|
54
|
-
e != null && (typeof e == "object" && Object.keys(e).length === 0 ? o[a] = `${
|
|
55
|
-
ALL: `${
|
|
56
|
-
}, n(e,
|
|
52
|
+
const t = {}, n = (r, _ = [], o) => {
|
|
53
|
+
for (const [s, e] of Object.entries(r)) {
|
|
54
|
+
const a = s.toUpperCase(), i = [..._, s], c = i.join(":");
|
|
55
|
+
e != null && (typeof e == "object" && Object.keys(e).length === 0 ? o[a] = `${c}` : typeof e == "object" && (o[a] = {
|
|
56
|
+
ALL: `${c}:${f}`
|
|
57
|
+
}, n(e, i, o[a])));
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
return n(g, [], t), t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sources":["../../src/interfaces/scope.ts"],"sourcesContent":["// SCOPE_SEED defines the basic scope structure.\n// When you need to set different permissions for Admin and User\n// on specific endpoints (like /me), use SCOPE rather than modifying SCOPE_SEED.\n\n// If you want to add a new scope:\n// 1. Add a new key to the SCOPE_SEED object below\n// 2. Add the corresponding scope strings to the Scope type union at the bottom of this file\n// 3. Change translation file contents (accesstoken_scopes_desc) when scope structure is modified\n\nconst SCOPE_SEED_ADMIN = {\n admin: {\n top: {},\n app: {},\n security: {},\n markdown: {},\n customize: {},\n import_data: {},\n export_data: {},\n data_transfer: {},\n external_notification: {},\n slack_integration: {},\n legacy_slack_integration: {},\n user_management: {},\n user_group_management: {},\n audit_log: {},\n plugin: {},\n ai_integration: {},\n full_text_search: {},\n },\n} as const;\n\nconst SCOPE_SEED_USER = {\n user_settings: {\n info: {},\n external_account: {},\n password: {},\n api: {\n api_token: {},\n access_token: {},\n },\n in_app_notification: {},\n other: {},\n },\n features: {\n ai_assistant: {},\n page: {},\n share_link: {},\n bookmark: {},\n attachment: {},\n page_bulk_export: {},\n },\n} as const;\n\nconst SCOPE_SEED = {\n ...SCOPE_SEED_ADMIN,\n ...SCOPE_SEED_USER,\n} as const;\n\nexport const ACTION = {\n READ: 'read',\n WRITE: 'write',\n} as const;\n\ntype ACTION_TYPE = (typeof ACTION)[keyof typeof ACTION];\nexport const ALL_SIGN = '*';\n\nconst SCOPE_SEED_WITH_ACTION = Object.values(ACTION).reduce(\n (acc, action) => {\n acc[action] = SCOPE_SEED;\n return acc;\n },\n {} as Record<ACTION_TYPE, typeof SCOPE_SEED>,\n);\n\n// ============================================================================\n// SCOPE LITERAL TYPE\n// ============================================================================\n// This type is explicitly defined to avoid TS2589 \"Type instantiation is\n// excessively deep\" errors that occur with recursive type definitions.\n//\n// IMPORTANT: When modifying SCOPE_SEED above, update this type union accordingly.\n// The scope strings follow the pattern: {action}:{category}[:{subcategory}[:{item}]]\n// Wildcard scopes use '*' at any level: {action}:{category}:*\n// ============================================================================\n\n// Read scopes - Admin\ntype ReadAdminScope =\n | 'read:admin:top'\n | 'read:admin:app'\n | 'read:admin:security'\n | 'read:admin:markdown'\n | 'read:admin:customize'\n | 'read:admin:import_data'\n | 'read:admin:export_data'\n | 'read:admin:data_transfer'\n | 'read:admin:external_notification'\n | 'read:admin:slack_integration'\n | 'read:admin:legacy_slack_integration'\n | 'read:admin:user_management'\n | 'read:admin:user_group_management'\n | 'read:admin:audit_log'\n | 'read:admin:plugin'\n | 'read:admin:ai_integration'\n | 'read:admin:full_text_search'\n | 'read:admin:*';\n\n// Read scopes - User Settings\ntype ReadUserSettingsScope =\n | 'read:user_settings:info'\n | 'read:user_settings:external_account'\n | 'read:user_settings:password'\n | 'read:user_settings:api:api_token'\n | 'read:user_settings:api:access_token'\n | 'read:user_settings:api:*'\n | 'read:user_settings:in_app_notification'\n | 'read:user_settings:other'\n | 'read:user_settings:*';\n\n// Read scopes - Features\ntype ReadFeaturesScope =\n | 'read:features:ai_assistant'\n | 'read:features:page'\n | 'read:features:share_link'\n | 'read:features:bookmark'\n | 'read:features:attachment'\n | 'read:features:page_bulk_export'\n | 'read:features:*';\n\n// Write scopes - Admin\ntype WriteAdminScope =\n | 'write:admin:top'\n | 'write:admin:app'\n | 'write:admin:security'\n | 'write:admin:markdown'\n | 'write:admin:customize'\n | 'write:admin:import_data'\n | 'write:admin:export_data'\n | 'write:admin:data_transfer'\n | 'write:admin:external_notification'\n | 'write:admin:slack_integration'\n | 'write:admin:legacy_slack_integration'\n | 'write:admin:user_management'\n | 'write:admin:user_group_management'\n | 'write:admin:audit_log'\n | 'write:admin:plugin'\n | 'write:admin:ai_integration'\n | 'write:admin:full_text_search'\n | 'write:admin:*';\n\n// Write scopes - User Settings\ntype WriteUserSettingsScope =\n | 'write:user_settings:info'\n | 'write:user_settings:external_account'\n | 'write:user_settings:password'\n | 'write:user_settings:api:api_token'\n | 'write:user_settings:api:access_token'\n | 'write:user_settings:api:*'\n | 'write:user_settings:in_app_notification'\n | 'write:user_settings:other'\n | 'write:user_settings:*';\n\n// Write scopes - Features\ntype WriteFeaturesScope =\n | 'write:features:ai_assistant'\n | 'write:features:page'\n | 'write:features:share_link'\n | 'write:features:bookmark'\n | 'write:features:attachment'\n | 'write:features:page_bulk_export'\n | 'write:features:*';\n\n// Combined Scope type - all valid scope strings\nexport type Scope =\n | ReadAdminScope\n | ReadUserSettingsScope\n | ReadFeaturesScope\n | WriteAdminScope\n | WriteUserSettingsScope\n | WriteFeaturesScope\n | 'read:*'\n | 'write:*';\n\n// ScopeConstants type definition\ntype ScopeConstantLeaf = Scope;\n\ntype ScopeConstantNode<T> = {\n [K in keyof T as Uppercase<string & K>]: T[K] extends object\n ? keyof T[K] extends never\n ? ScopeConstantLeaf\n : ScopeConstantNode<T[K]> & { ALL: Scope }\n : ScopeConstantLeaf;\n};\n\ntype ScopeConstantType = {\n [A in keyof typeof SCOPE_SEED_WITH_ACTION as Uppercase<\n string & A\n >]: ScopeConstantNode<typeof SCOPE_SEED> & { ALL: Scope };\n};\n\nconst buildScopeConstants = (): ScopeConstantType => {\n const result = {} as Partial<ScopeConstantType>;\n\n const processObject = (\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n obj: Record<string, any>,\n path: string[] = [],\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n resultObj: Record<string, any>,\n ) => {\n for (const [key, value] of Object.entries(obj)) {\n const upperKey = key.toUpperCase();\n const currentPath = [...path, key];\n const scopePath = currentPath.join(':');\n\n if (value == null) {\n continue; // Changed from 'return' to 'continue' to match the loop behavior\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n resultObj[upperKey] = `${scopePath}` as Scope;\n } else if (typeof value === 'object') {\n resultObj[upperKey] = {\n ALL: `${scopePath}:${ALL_SIGN}` as Scope,\n };\n\n processObject(value, currentPath, resultObj[upperKey]);\n }\n }\n };\n processObject(SCOPE_SEED_WITH_ACTION, [], result);\n\n return result as ScopeConstantType;\n};\n\nexport const SCOPE = buildScopeConstants();\n"],"names":["SCOPE_SEED_ADMIN","SCOPE_SEED_USER","SCOPE_SEED","ACTION","ALL_SIGN","SCOPE_SEED_WITH_ACTION","acc","action","buildScopeConstants","result","processObject","obj","path","resultObj","key","value","upperKey","currentPath","scopePath","SCOPE"],"mappings":"AASA,MAAMA,IAAmB;AAAA,EACvB,OAAO;AAAA,IACL,KAAK,
|
|
1
|
+
{"version":3,"file":"scope.js","sources":["../../src/interfaces/scope.ts"],"sourcesContent":["// SCOPE_SEED defines the basic scope structure.\n// When you need to set different permissions for Admin and User\n// on specific endpoints (like /me), use SCOPE rather than modifying SCOPE_SEED.\n\n// If you want to add a new scope:\n// 1. Add a new key to the SCOPE_SEED object below\n// 2. Add the corresponding scope strings to the Scope type union at the bottom of this file\n// 3. Change translation file contents (accesstoken_scopes_desc) when scope structure is modified\n\nconst SCOPE_SEED_ADMIN = {\n admin: {\n top: {},\n app: {},\n security: {},\n markdown: {},\n customize: {},\n import_data: {},\n export_data: {},\n data_transfer: {},\n external_notification: {},\n slack_integration: {},\n legacy_slack_integration: {},\n user_management: {},\n user_group_management: {},\n audit_log: {},\n plugin: {},\n ai_integration: {},\n full_text_search: {},\n },\n} as const;\n\nconst SCOPE_SEED_USER = {\n user_settings: {\n info: {},\n external_account: {},\n password: {},\n api: {\n api_token: {},\n access_token: {},\n },\n in_app_notification: {},\n other: {},\n },\n features: {\n ai_assistant: {},\n page: {},\n share_link: {},\n bookmark: {},\n attachment: {},\n page_bulk_export: {},\n in_app_notification: {},\n },\n} as const;\n\nconst SCOPE_SEED = {\n ...SCOPE_SEED_ADMIN,\n ...SCOPE_SEED_USER,\n} as const;\n\nexport const ACTION = {\n READ: 'read',\n WRITE: 'write',\n} as const;\n\ntype ACTION_TYPE = (typeof ACTION)[keyof typeof ACTION];\nexport const ALL_SIGN = '*';\n\nconst SCOPE_SEED_WITH_ACTION = Object.values(ACTION).reduce(\n (acc, action) => {\n acc[action] = SCOPE_SEED;\n return acc;\n },\n {} as Record<ACTION_TYPE, typeof SCOPE_SEED>,\n);\n\n// ============================================================================\n// SCOPE LITERAL TYPE\n// ============================================================================\n// This type is explicitly defined to avoid TS2589 \"Type instantiation is\n// excessively deep\" errors that occur with recursive type definitions.\n//\n// IMPORTANT: When modifying SCOPE_SEED above, update this type union accordingly.\n// The scope strings follow the pattern: {action}:{category}[:{subcategory}[:{item}]]\n// Wildcard scopes use '*' at any level: {action}:{category}:*\n// ============================================================================\n\n// Read scopes - Admin\ntype ReadAdminScope =\n | 'read:admin:top'\n | 'read:admin:app'\n | 'read:admin:security'\n | 'read:admin:markdown'\n | 'read:admin:customize'\n | 'read:admin:import_data'\n | 'read:admin:export_data'\n | 'read:admin:data_transfer'\n | 'read:admin:external_notification'\n | 'read:admin:slack_integration'\n | 'read:admin:legacy_slack_integration'\n | 'read:admin:user_management'\n | 'read:admin:user_group_management'\n | 'read:admin:audit_log'\n | 'read:admin:plugin'\n | 'read:admin:ai_integration'\n | 'read:admin:full_text_search'\n | 'read:admin:*';\n\n// Read scopes - User Settings\ntype ReadUserSettingsScope =\n | 'read:user_settings:info'\n | 'read:user_settings:external_account'\n | 'read:user_settings:password'\n | 'read:user_settings:api:api_token'\n | 'read:user_settings:api:access_token'\n | 'read:user_settings:api:*'\n | 'read:user_settings:in_app_notification'\n | 'read:user_settings:other'\n | 'read:user_settings:*';\n\n// Read scopes - Features\ntype ReadFeaturesScope =\n | 'read:features:ai_assistant'\n | 'read:features:page'\n | 'read:features:share_link'\n | 'read:features:bookmark'\n | 'read:features:attachment'\n | 'read:features:page_bulk_export'\n | 'read:features:in_app_notification'\n | 'read:features:*';\n\n// Write scopes - Admin\ntype WriteAdminScope =\n | 'write:admin:top'\n | 'write:admin:app'\n | 'write:admin:security'\n | 'write:admin:markdown'\n | 'write:admin:customize'\n | 'write:admin:import_data'\n | 'write:admin:export_data'\n | 'write:admin:data_transfer'\n | 'write:admin:external_notification'\n | 'write:admin:slack_integration'\n | 'write:admin:legacy_slack_integration'\n | 'write:admin:user_management'\n | 'write:admin:user_group_management'\n | 'write:admin:audit_log'\n | 'write:admin:plugin'\n | 'write:admin:ai_integration'\n | 'write:admin:full_text_search'\n | 'write:admin:*';\n\n// Write scopes - User Settings\ntype WriteUserSettingsScope =\n | 'write:user_settings:info'\n | 'write:user_settings:external_account'\n | 'write:user_settings:password'\n | 'write:user_settings:api:api_token'\n | 'write:user_settings:api:access_token'\n | 'write:user_settings:api:*'\n | 'write:user_settings:in_app_notification'\n | 'write:user_settings:other'\n | 'write:user_settings:*';\n\n// Write scopes - Features\ntype WriteFeaturesScope =\n | 'write:features:ai_assistant'\n | 'write:features:page'\n | 'write:features:share_link'\n | 'write:features:bookmark'\n | 'write:features:attachment'\n | 'write:features:page_bulk_export'\n | 'write:features:in_app_notification'\n | 'write:features:*';\n\n// Combined Scope type - all valid scope strings\nexport type Scope =\n | ReadAdminScope\n | ReadUserSettingsScope\n | ReadFeaturesScope\n | WriteAdminScope\n | WriteUserSettingsScope\n | WriteFeaturesScope\n | 'read:*'\n | 'write:*';\n\n// ScopeConstants type definition\ntype ScopeConstantLeaf = Scope;\n\ntype ScopeConstantNode<T> = {\n [K in keyof T as Uppercase<string & K>]: T[K] extends object\n ? keyof T[K] extends never\n ? ScopeConstantLeaf\n : ScopeConstantNode<T[K]> & { ALL: Scope }\n : ScopeConstantLeaf;\n};\n\ntype ScopeConstantType = {\n [A in keyof typeof SCOPE_SEED_WITH_ACTION as Uppercase<\n string & A\n >]: ScopeConstantNode<typeof SCOPE_SEED> & { ALL: Scope };\n};\n\nconst buildScopeConstants = (): ScopeConstantType => {\n const result = {} as Partial<ScopeConstantType>;\n\n const processObject = (\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n obj: Record<string, any>,\n path: string[] = [],\n // biome-ignore lint/suspicious/noExplicitAny: ignore\n resultObj: Record<string, any>,\n ) => {\n for (const [key, value] of Object.entries(obj)) {\n const upperKey = key.toUpperCase();\n const currentPath = [...path, key];\n const scopePath = currentPath.join(':');\n\n if (value == null) {\n continue; // Changed from 'return' to 'continue' to match the loop behavior\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n resultObj[upperKey] = `${scopePath}` as Scope;\n } else if (typeof value === 'object') {\n resultObj[upperKey] = {\n ALL: `${scopePath}:${ALL_SIGN}` as Scope,\n };\n\n processObject(value, currentPath, resultObj[upperKey]);\n }\n }\n };\n processObject(SCOPE_SEED_WITH_ACTION, [], result);\n\n return result as ScopeConstantType;\n};\n\nexport const SCOPE = buildScopeConstants();\n"],"names":["SCOPE_SEED_ADMIN","SCOPE_SEED_USER","SCOPE_SEED","ACTION","ALL_SIGN","SCOPE_SEED_WITH_ACTION","acc","action","buildScopeConstants","result","processObject","obj","path","resultObj","key","value","upperKey","currentPath","scopePath","SCOPE"],"mappings":"AASA,MAAMA,IAAmB;AAAA,EACvB,OAAO;AAAA,IACL,KAAK,CAAC;AAAA,IACN,KAAK,CAAC;AAAA,IACN,UAAU,CAAC;AAAA,IACX,UAAU,CAAC;AAAA,IACX,WAAW,CAAC;AAAA,IACZ,aAAa,CAAC;AAAA,IACd,aAAa,CAAC;AAAA,IACd,eAAe,CAAC;AAAA,IAChB,uBAAuB,CAAC;AAAA,IACxB,mBAAmB,CAAC;AAAA,IACpB,0BAA0B,CAAC;AAAA,IAC3B,iBAAiB,CAAC;AAAA,IAClB,uBAAuB,CAAC;AAAA,IACxB,WAAW,CAAC;AAAA,IACZ,QAAQ,CAAC;AAAA,IACT,gBAAgB,CAAC;AAAA,IACjB,kBAAkB,CAAA;AAAA,EAAC;AAEvB,GAEMC,IAAkB;AAAA,EACtB,eAAe;AAAA,IACb,MAAM,CAAC;AAAA,IACP,kBAAkB,CAAC;AAAA,IACnB,UAAU,CAAC;AAAA,IACX,KAAK;AAAA,MACH,WAAW,CAAC;AAAA,MACZ,cAAc,CAAA;AAAA,IAChB;AAAA,IACA,qBAAqB,CAAC;AAAA,IACtB,OAAO,CAAA;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,cAAc,CAAC;AAAA,IACf,MAAM,CAAC;AAAA,IACP,YAAY,CAAC;AAAA,IACb,UAAU,CAAC;AAAA,IACX,YAAY,CAAC;AAAA,IACb,kBAAkB,CAAC;AAAA,IACnB,qBAAqB,CAAA;AAAA,EAAC;AAE1B,GAEMC,IAAa;AAAA,EACjB,GAAGF;AAAA,EACH,GAAGC;AACL,GAEaE,IAAS;AAAA,EACpB,MAAM;AAAA,EACN,OAAO;AACT,GAGaC,IAAW,KAElBC,IAAyB,OAAO,OAAOF,CAAM,EAAE;AAAA,EACnD,CAACG,GAAKC,OACJD,EAAIC,CAAM,IAAIL,GACPI;AAAA,EAET,CAAA;AACF,GAiIME,IAAsB,MAAyB;AACnD,QAAMC,IAAS,CAAC,GAEVC,IAAgB,CAEpBC,GACAC,IAAiB,CAAA,GAEjBC,MACG;AACH,eAAW,CAACC,GAAKC,CAAK,KAAK,OAAO,QAAQJ,CAAG,GAAG;AACxC,YAAAK,IAAWF,EAAI,YAAY,GAC3BG,IAAc,CAAC,GAAGL,GAAME,CAAG,GAC3BI,IAAYD,EAAY,KAAK,GAAG;AAEtC,MAAIF,KAAS,SAIT,OAAOA,KAAU,YAAY,OAAO,KAAKA,CAAK,EAAE,WAAW,IACnDF,EAAAG,CAAQ,IAAI,GAAGE,CAAS,KACzB,OAAOH,KAAU,aAC1BF,EAAUG,CAAQ,IAAI;AAAA,QACpB,KAAK,GAAGE,CAAS,IAAId,CAAQ;AAAA,MAC/B,GAEAM,EAAcK,GAAOE,GAAaJ,EAAUG,CAAQ,CAAC;AAAA,IACvD;AAAA,EAEJ;AACc,SAAAN,EAAAL,GAAwB,CAAC,GAAGI,CAAM,GAEzCA;AACT,GAEaU,IAAQX,EAAoB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devided-page-path.cjs","sources":["../../src/models/devided-page-path.ts"],"sourcesContent":["import * as pathUtils from '../utils/path-utils';\n\n// https://regex101.com/r/BahpKX/2\nconst PATTERN_INCLUDE_DATE =\n /^(.+\\/[^/]+)\\/(\\d{4}|\\d{4}\\/\\d{2}|\\d{4}\\/\\d{2}\\/\\d{2})$/;\n\nexport class DevidedPagePath {\n isRoot: boolean;\n\n isFormerRoot: boolean;\n\n former: string;\n\n latter: string;\n\n constructor(path: string, skipNormalize = false, evalDatePath = false) {\n this.isRoot = false;\n this.isFormerRoot = false;\n this.former = '';\n\n // root\n if (path == null || path === '' || path === '/') {\n this.isRoot = true;\n this.latter = '/';\n return;\n }\n\n const pagePath = skipNormalize ? path : pathUtils.normalizePath(path);\n this.latter = pagePath;\n\n // evaluate date path\n if (evalDatePath) {\n const matchDate = pagePath.match(PATTERN_INCLUDE_DATE);\n if (matchDate != null) {\n this.former = matchDate[1];\n this.latter = matchDate[2];\n return;\n }\n }\n\n let PATTERN_DEFAULT = /^((.*)\\/(?!em>))?(.+)$/; // this will ignore em's end tags\n try {\n // for non-chrome browsers\n // biome-ignore lint/complexity/useRegexLiterals: ignore\n PATTERN_DEFAULT = new RegExp('^((.*)(?<!<)\\\\/)?(.+)$'); // https://regex101.com/r/HJNvMW/1\n } catch {\n // lookbehind regex is not supported on non-chrome browsers\n }\n\n const matchDefault = pagePath.match(PATTERN_DEFAULT);\n if (matchDefault != null) {\n this.isFormerRoot = matchDefault[1] === '/';\n this.former = matchDefault[2];\n this.latter = matchDefault[3];\n }\n }\n}\n"],"names":["PATTERN_INCLUDE_DATE","DevidedPagePath","path","skipNormalize","evalDatePath","__publicField","pagePath","pathUtils.normalizePath","matchDate","PATTERN_DEFAULT","matchDefault"],"mappings":"+RAGMA,EACJ,0DAEK,MAAMC,CAAgB,CAS3B,YAAYC,EAAcC,EAAgB,GAAOC,EAAe,GAAO,CARvEC,EAAA,eAEAA,EAAA,qBAEAA,EAAA,eAEAA,EAAA,eAQE,GALA,KAAK,OAAS,GACd,KAAK,aAAe,GACpB,KAAK,OAAS,GAGVH,GAAQ,MAAQA,IAAS,IAAMA,IAAS,IAAK,CAC/C,KAAK,OAAS,GACd,KAAK,OAAS,IACd,
|
|
1
|
+
{"version":3,"file":"devided-page-path.cjs","sources":["../../src/models/devided-page-path.ts"],"sourcesContent":["import * as pathUtils from '../utils/path-utils';\n\n// https://regex101.com/r/BahpKX/2\nconst PATTERN_INCLUDE_DATE =\n /^(.+\\/[^/]+)\\/(\\d{4}|\\d{4}\\/\\d{2}|\\d{4}\\/\\d{2}\\/\\d{2})$/;\n\nexport class DevidedPagePath {\n isRoot: boolean;\n\n isFormerRoot: boolean;\n\n former: string;\n\n latter: string;\n\n constructor(path: string, skipNormalize = false, evalDatePath = false) {\n this.isRoot = false;\n this.isFormerRoot = false;\n this.former = '';\n\n // root\n if (path == null || path === '' || path === '/') {\n this.isRoot = true;\n this.latter = '/';\n return;\n }\n\n const pagePath = skipNormalize ? path : pathUtils.normalizePath(path);\n this.latter = pagePath;\n\n // evaluate date path\n if (evalDatePath) {\n const matchDate = pagePath.match(PATTERN_INCLUDE_DATE);\n if (matchDate != null) {\n this.former = matchDate[1];\n this.latter = matchDate[2];\n return;\n }\n }\n\n let PATTERN_DEFAULT = /^((.*)\\/(?!em>))?(.+)$/; // this will ignore em's end tags\n try {\n // for non-chrome browsers\n // biome-ignore lint/complexity/useRegexLiterals: ignore\n PATTERN_DEFAULT = new RegExp('^((.*)(?<!<)\\\\/)?(.+)$'); // https://regex101.com/r/HJNvMW/1\n } catch {\n // lookbehind regex is not supported on non-chrome browsers\n }\n\n const matchDefault = pagePath.match(PATTERN_DEFAULT);\n if (matchDefault != null) {\n this.isFormerRoot = matchDefault[1] === '/';\n this.former = matchDefault[2];\n this.latter = matchDefault[3];\n }\n }\n}\n"],"names":["PATTERN_INCLUDE_DATE","DevidedPagePath","path","skipNormalize","evalDatePath","__publicField","pagePath","pathUtils.normalizePath","matchDate","PATTERN_DEFAULT","matchDefault"],"mappings":"+RAGMA,EACJ,0DAEK,MAAMC,CAAgB,CAS3B,YAAYC,EAAcC,EAAgB,GAAOC,EAAe,GAAO,CARvEC,EAAA,eAEAA,EAAA,qBAEAA,EAAA,eAEAA,EAAA,eAQE,GALA,KAAK,OAAS,GACd,KAAK,aAAe,GACpB,KAAK,OAAS,GAGVH,GAAQ,MAAQA,IAAS,IAAMA,IAAS,IAAK,CAC/C,KAAK,OAAS,GACd,KAAK,OAAS,IACd,MAAA,CAGF,MAAMI,EAAWH,EAAgBD,EAAOK,EAAAA,cAAwBL,CAAI,EAIpE,GAHA,KAAK,OAASI,EAGVF,EAAc,CACV,MAAAI,EAAYF,EAAS,MAAMN,CAAoB,EACrD,GAAIQ,GAAa,KAAM,CAChB,KAAA,OAASA,EAAU,CAAC,EACpB,KAAA,OAASA,EAAU,CAAC,EACzB,MAAA,CACF,CAGF,IAAIC,EAAkB,yBAClB,GAAA,CAGgBA,EAAA,IAAI,OAAO,wBAAwB,CAAA,MAC/C,CAAA,CAIF,MAAAC,EAAeJ,EAAS,MAAMG,CAAe,EAC/CC,GAAgB,OACb,KAAA,aAAeA,EAAa,CAAC,IAAM,IACnC,KAAA,OAASA,EAAa,CAAC,EACvB,KAAA,OAASA,EAAa,CAAC,EAC9B,CAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devided-page-path.js","sources":["../../src/models/devided-page-path.ts"],"sourcesContent":["import * as pathUtils from '../utils/path-utils';\n\n// https://regex101.com/r/BahpKX/2\nconst PATTERN_INCLUDE_DATE =\n /^(.+\\/[^/]+)\\/(\\d{4}|\\d{4}\\/\\d{2}|\\d{4}\\/\\d{2}\\/\\d{2})$/;\n\nexport class DevidedPagePath {\n isRoot: boolean;\n\n isFormerRoot: boolean;\n\n former: string;\n\n latter: string;\n\n constructor(path: string, skipNormalize = false, evalDatePath = false) {\n this.isRoot = false;\n this.isFormerRoot = false;\n this.former = '';\n\n // root\n if (path == null || path === '' || path === '/') {\n this.isRoot = true;\n this.latter = '/';\n return;\n }\n\n const pagePath = skipNormalize ? path : pathUtils.normalizePath(path);\n this.latter = pagePath;\n\n // evaluate date path\n if (evalDatePath) {\n const matchDate = pagePath.match(PATTERN_INCLUDE_DATE);\n if (matchDate != null) {\n this.former = matchDate[1];\n this.latter = matchDate[2];\n return;\n }\n }\n\n let PATTERN_DEFAULT = /^((.*)\\/(?!em>))?(.+)$/; // this will ignore em's end tags\n try {\n // for non-chrome browsers\n // biome-ignore lint/complexity/useRegexLiterals: ignore\n PATTERN_DEFAULT = new RegExp('^((.*)(?<!<)\\\\/)?(.+)$'); // https://regex101.com/r/HJNvMW/1\n } catch {\n // lookbehind regex is not supported on non-chrome browsers\n }\n\n const matchDefault = pagePath.match(PATTERN_DEFAULT);\n if (matchDefault != null) {\n this.isFormerRoot = matchDefault[1] === '/';\n this.former = matchDefault[2];\n this.latter = matchDefault[3];\n }\n }\n}\n"],"names":["PATTERN_INCLUDE_DATE","DevidedPagePath","path","skipNormalize","evalDatePath","__publicField","pagePath","pathUtils.normalizePath","matchDate","PATTERN_DEFAULT","matchDefault"],"mappings":";;;;AAGA,MAAMA,IACJ;AAEK,MAAMC,EAAgB;AAAA,EAS3B,YAAYC,GAAcC,IAAgB,IAAOC,IAAe,IAAO;AARvE,IAAAC,EAAA;AAEA,IAAAA,EAAA;AAEA,IAAAA,EAAA;AAEA,IAAAA,EAAA;AAQE,QALA,KAAK,SAAS,IACd,KAAK,eAAe,IACpB,KAAK,SAAS,IAGVH,KAAQ,QAAQA,MAAS,MAAMA,MAAS,KAAK;AAC/C,WAAK,SAAS,IACd,KAAK,SAAS;AACd;AAAA,
|
|
1
|
+
{"version":3,"file":"devided-page-path.js","sources":["../../src/models/devided-page-path.ts"],"sourcesContent":["import * as pathUtils from '../utils/path-utils';\n\n// https://regex101.com/r/BahpKX/2\nconst PATTERN_INCLUDE_DATE =\n /^(.+\\/[^/]+)\\/(\\d{4}|\\d{4}\\/\\d{2}|\\d{4}\\/\\d{2}\\/\\d{2})$/;\n\nexport class DevidedPagePath {\n isRoot: boolean;\n\n isFormerRoot: boolean;\n\n former: string;\n\n latter: string;\n\n constructor(path: string, skipNormalize = false, evalDatePath = false) {\n this.isRoot = false;\n this.isFormerRoot = false;\n this.former = '';\n\n // root\n if (path == null || path === '' || path === '/') {\n this.isRoot = true;\n this.latter = '/';\n return;\n }\n\n const pagePath = skipNormalize ? path : pathUtils.normalizePath(path);\n this.latter = pagePath;\n\n // evaluate date path\n if (evalDatePath) {\n const matchDate = pagePath.match(PATTERN_INCLUDE_DATE);\n if (matchDate != null) {\n this.former = matchDate[1];\n this.latter = matchDate[2];\n return;\n }\n }\n\n let PATTERN_DEFAULT = /^((.*)\\/(?!em>))?(.+)$/; // this will ignore em's end tags\n try {\n // for non-chrome browsers\n // biome-ignore lint/complexity/useRegexLiterals: ignore\n PATTERN_DEFAULT = new RegExp('^((.*)(?<!<)\\\\/)?(.+)$'); // https://regex101.com/r/HJNvMW/1\n } catch {\n // lookbehind regex is not supported on non-chrome browsers\n }\n\n const matchDefault = pagePath.match(PATTERN_DEFAULT);\n if (matchDefault != null) {\n this.isFormerRoot = matchDefault[1] === '/';\n this.former = matchDefault[2];\n this.latter = matchDefault[3];\n }\n }\n}\n"],"names":["PATTERN_INCLUDE_DATE","DevidedPagePath","path","skipNormalize","evalDatePath","__publicField","pagePath","pathUtils.normalizePath","matchDate","PATTERN_DEFAULT","matchDefault"],"mappings":";;;;AAGA,MAAMA,IACJ;AAEK,MAAMC,EAAgB;AAAA,EAS3B,YAAYC,GAAcC,IAAgB,IAAOC,IAAe,IAAO;AARvE,IAAAC,EAAA;AAEA,IAAAA,EAAA;AAEA,IAAAA,EAAA;AAEA,IAAAA,EAAA;AAQE,QALA,KAAK,SAAS,IACd,KAAK,eAAe,IACpB,KAAK,SAAS,IAGVH,KAAQ,QAAQA,MAAS,MAAMA,MAAS,KAAK;AAC/C,WAAK,SAAS,IACd,KAAK,SAAS;AACd;AAAA,IAAA;AAGF,UAAMI,IAAWH,IAAgBD,IAAOK,EAAwBL,CAAI;AAIpE,QAHA,KAAK,SAASI,GAGVF,GAAc;AACV,YAAAI,IAAYF,EAAS,MAAMN,CAAoB;AACrD,UAAIQ,KAAa,MAAM;AAChB,aAAA,SAASA,EAAU,CAAC,GACpB,KAAA,SAASA,EAAU,CAAC;AACzB;AAAA,MAAA;AAAA,IACF;AAGF,QAAIC,IAAkB;AAClB,QAAA;AAGgB,MAAAA,IAAA,IAAI,OAAO,wBAAwB;AAAA,IAAA,QAC/C;AAAA,IAAA;AAIF,UAAAC,IAAeJ,EAAS,MAAMG,CAAe;AACnD,IAAIC,KAAgB,SACb,KAAA,eAAeA,EAAa,CAAC,MAAM,KACnC,KAAA,SAASA,EAAa,CAAC,GACvB,KAAA,SAASA,EAAa,CAAC;AAAA,EAC9B;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-serializer.cjs","sources":["../../../src/models/serializers/attachment-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport type { IAttachment, IUser } from '~/interfaces';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport {\n type IUserSerializedSecurely,\n serializeUserSecurely,\n} from './user-serializer';\n\nexport type IAttachmentSerializedSecurely<A extends IAttachment> = Omit<\n A,\n 'creator'\n> & { creator?: Ref<IUserSerializedSecurely<IUser>> };\n\nconst omitInsecureAttributes = <A extends IAttachment>(\n attachment: A,\n): IAttachmentSerializedSecurely<A> => {\n const leanDoc =\n attachment instanceof Document ? attachment.toObject<A>() : attachment;\n\n const { creator, ...rest } = leanDoc;\n\n const secureCreator =\n creator == null ? undefined : serializeUserSecurely(creator);\n\n return {\n creator: secureCreator,\n ...rest,\n };\n};\n\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A,\n): IAttachmentSerializedSecurely<A>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: Ref<A>,\n): Ref<IAttachmentSerializedSecurely<A>>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A | Ref<A>,\n):\n | undefined\n | IAttachmentSerializedSecurely<A>\n | Ref<IAttachmentSerializedSecurely<A>> {\n if (attachment == null) return attachment;\n\n if (isRef(attachment) && !isPopulated(attachment)) return attachment;\n\n return omitInsecureAttributes(attachment);\n}\n"],"names":["omitInsecureAttributes","attachment","leanDoc","Document","creator","rest","serializeUserSecurely","serializeAttachmentSecurely","isRef","isPopulated"],"mappings":"wLAeMA,EACJC,GACqC,CACrC,MAAMC,EACJD,aAAsBE,EAAAA,SAAWF,EAAW,
|
|
1
|
+
{"version":3,"file":"attachment-serializer.cjs","sources":["../../../src/models/serializers/attachment-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport type { IAttachment, IUser } from '~/interfaces';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport {\n type IUserSerializedSecurely,\n serializeUserSecurely,\n} from './user-serializer';\n\nexport type IAttachmentSerializedSecurely<A extends IAttachment> = Omit<\n A,\n 'creator'\n> & { creator?: Ref<IUserSerializedSecurely<IUser>> };\n\nconst omitInsecureAttributes = <A extends IAttachment>(\n attachment: A,\n): IAttachmentSerializedSecurely<A> => {\n const leanDoc =\n attachment instanceof Document ? attachment.toObject<A>() : attachment;\n\n const { creator, ...rest } = leanDoc;\n\n const secureCreator =\n creator == null ? undefined : serializeUserSecurely(creator);\n\n return {\n creator: secureCreator,\n ...rest,\n };\n};\n\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A,\n): IAttachmentSerializedSecurely<A>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: Ref<A>,\n): Ref<IAttachmentSerializedSecurely<A>>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A | Ref<A>,\n):\n | undefined\n | IAttachmentSerializedSecurely<A>\n | Ref<IAttachmentSerializedSecurely<A>> {\n if (attachment == null) return attachment;\n\n if (isRef(attachment) && !isPopulated(attachment)) return attachment;\n\n return omitInsecureAttributes(attachment);\n}\n"],"names":["omitInsecureAttributes","attachment","leanDoc","Document","creator","rest","serializeUserSecurely","serializeAttachmentSecurely","isRef","isPopulated"],"mappings":"wLAeMA,EACJC,GACqC,CACrC,MAAMC,EACJD,aAAsBE,EAAAA,SAAWF,EAAW,SAAgB,EAAAA,EAExD,CAAE,QAAAG,EAAS,GAAGC,CAAA,EAASH,EAKtB,MAAA,CACL,QAHAE,GAAW,KAAO,OAAYE,EAAAA,sBAAsBF,CAAO,EAI3D,GAAGC,CACL,CACF,EAQO,SAASE,EACdN,EAIwC,CAGxC,OAFIA,GAAc,MAEdO,EAAAA,MAAMP,CAAU,GAAK,CAACQ,EAAAA,YAAYR,CAAU,EAAUA,EAEnDD,EAAuBC,CAAU,CAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-serializer.js","sources":["../../../src/models/serializers/attachment-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport type { IAttachment, IUser } from '~/interfaces';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport {\n type IUserSerializedSecurely,\n serializeUserSecurely,\n} from './user-serializer';\n\nexport type IAttachmentSerializedSecurely<A extends IAttachment> = Omit<\n A,\n 'creator'\n> & { creator?: Ref<IUserSerializedSecurely<IUser>> };\n\nconst omitInsecureAttributes = <A extends IAttachment>(\n attachment: A,\n): IAttachmentSerializedSecurely<A> => {\n const leanDoc =\n attachment instanceof Document ? attachment.toObject<A>() : attachment;\n\n const { creator, ...rest } = leanDoc;\n\n const secureCreator =\n creator == null ? undefined : serializeUserSecurely(creator);\n\n return {\n creator: secureCreator,\n ...rest,\n };\n};\n\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A,\n): IAttachmentSerializedSecurely<A>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: Ref<A>,\n): Ref<IAttachmentSerializedSecurely<A>>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A | Ref<A>,\n):\n | undefined\n | IAttachmentSerializedSecurely<A>\n | Ref<IAttachmentSerializedSecurely<A>> {\n if (attachment == null) return attachment;\n\n if (isRef(attachment) && !isPopulated(attachment)) return attachment;\n\n return omitInsecureAttributes(attachment);\n}\n"],"names":["omitInsecureAttributes","attachment","leanDoc","Document","creator","rest","serializeUserSecurely","serializeAttachmentSecurely","isRef","isPopulated"],"mappings":";;;AAeA,MAAMA,IAAyB,CAC7BC,MACqC;AACrC,QAAMC,IACJD,aAAsBE,IAAWF,EAAW,
|
|
1
|
+
{"version":3,"file":"attachment-serializer.js","sources":["../../../src/models/serializers/attachment-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport type { IAttachment, IUser } from '~/interfaces';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport {\n type IUserSerializedSecurely,\n serializeUserSecurely,\n} from './user-serializer';\n\nexport type IAttachmentSerializedSecurely<A extends IAttachment> = Omit<\n A,\n 'creator'\n> & { creator?: Ref<IUserSerializedSecurely<IUser>> };\n\nconst omitInsecureAttributes = <A extends IAttachment>(\n attachment: A,\n): IAttachmentSerializedSecurely<A> => {\n const leanDoc =\n attachment instanceof Document ? attachment.toObject<A>() : attachment;\n\n const { creator, ...rest } = leanDoc;\n\n const secureCreator =\n creator == null ? undefined : serializeUserSecurely(creator);\n\n return {\n creator: secureCreator,\n ...rest,\n };\n};\n\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A,\n): IAttachmentSerializedSecurely<A>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: Ref<A>,\n): Ref<IAttachmentSerializedSecurely<A>>;\nexport function serializeAttachmentSecurely<A extends IAttachment>(\n attachment?: A | Ref<A>,\n):\n | undefined\n | IAttachmentSerializedSecurely<A>\n | Ref<IAttachmentSerializedSecurely<A>> {\n if (attachment == null) return attachment;\n\n if (isRef(attachment) && !isPopulated(attachment)) return attachment;\n\n return omitInsecureAttributes(attachment);\n}\n"],"names":["omitInsecureAttributes","attachment","leanDoc","Document","creator","rest","serializeUserSecurely","serializeAttachmentSecurely","isRef","isPopulated"],"mappings":";;;AAeA,MAAMA,IAAyB,CAC7BC,MACqC;AACrC,QAAMC,IACJD,aAAsBE,IAAWF,EAAW,SAAgB,IAAAA,GAExD,EAAE,SAAAG,GAAS,GAAGC,EAAA,IAASH;AAKtB,SAAA;AAAA,IACL,SAHAE,KAAW,OAAO,SAAYE,EAAsBF,CAAO;AAAA,IAI3D,GAAGC;AAAA,EACL;AACF;AAQO,SAASE,EACdN,GAIwC;AAGxC,SAFIA,KAAc,QAEdO,EAAMP,CAAU,KAAK,CAACQ,EAAYR,CAAU,IAAUA,IAEnDD,EAAuBC,CAAU;AAC1C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-serializer.cjs","sources":["../../../src/models/serializers/user-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport type { IUser } from '../../interfaces/user';\n\nexport type IUserSerializedSecurely<U extends IUser> = Omit<\n U,\n 'password' | 'apiToken' | 'email'\n> & { email?: string };\n\nexport const omitInsecureAttributes = <U extends IUser>(\n user: U,\n): IUserSerializedSecurely<U> => {\n const leanDoc = user instanceof Document ? user.toObject<U>() : user;\n\n const {
|
|
1
|
+
{"version":3,"file":"user-serializer.cjs","sources":["../../../src/models/serializers/user-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport type { IUser } from '../../interfaces/user';\n\nexport type IUserSerializedSecurely<U extends IUser> = Omit<\n U,\n 'password' | 'apiToken' | 'email'\n> & { email?: string };\n\nexport const omitInsecureAttributes = <U extends IUser>(\n user: U,\n): IUserSerializedSecurely<U> => {\n const leanDoc = user instanceof Document ? user.toObject<U>() : user;\n\n const { password, apiToken, email, ...rest } = leanDoc;\n\n const secureUser: IUserSerializedSecurely<U> = rest;\n\n // omit email\n if (secureUser.isEmailPublished) {\n secureUser.email = email;\n }\n\n return secureUser;\n};\n\nexport function serializeUserSecurely<U extends IUser>(\n user?: U,\n): IUserSerializedSecurely<U>;\nexport function serializeUserSecurely<U extends IUser>(\n user?: Ref<U>,\n): Ref<IUserSerializedSecurely<U>>;\nexport function serializeUserSecurely<U extends IUser>(\n user?: U | Ref<U>,\n): undefined | IUserSerializedSecurely<U> | Ref<IUserSerializedSecurely<U>> {\n if (user == null) return user;\n\n if (isRef(user) && !isPopulated(user)) return user;\n\n return omitInsecureAttributes(user);\n}\n"],"names":["omitInsecureAttributes","user","leanDoc","Document","password","apiToken","email","rest","secureUser","serializeUserSecurely","isRef","isPopulated"],"mappings":"qJAUaA,EACXC,GAC+B,CAC/B,MAAMC,EAAUD,aAAgBE,EAAAA,SAAWF,EAAK,SAAgB,EAAAA,EAE1D,CAAE,SAAAG,EAAU,SAAAC,EAAU,MAAAC,EAAO,GAAGC,CAAS,EAAAL,EAEzCM,EAAyCD,EAG/C,OAAIC,EAAW,mBACbA,EAAW,MAAQF,GAGdE,CACT,EAQO,SAASC,EACdR,EAC0E,CAG1E,OAFIA,GAAQ,MAERS,EAAAA,MAAMT,CAAI,GAAK,CAACU,EAAAA,YAAYV,CAAI,EAAUA,EAEvCD,EAAuBC,CAAI,CACpC"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { Document as r } from "mongoose";
|
|
2
2
|
import { isRef as c, isPopulated as s } from "../../interfaces/common.js";
|
|
3
3
|
const l = (t) => {
|
|
4
|
-
const i = t instanceof r ? t.toObject() : t, {
|
|
5
|
-
// biome-ignore lint/correctness/noUnusedVariables: ignore
|
|
6
|
-
password: a,
|
|
7
|
-
// biome-ignore lint/correctness/noUnusedVariables: ignore
|
|
8
|
-
apiToken: m,
|
|
9
|
-
email: o,
|
|
10
|
-
...n
|
|
11
|
-
} = i, e = n;
|
|
4
|
+
const i = t instanceof r ? t.toObject() : t, { password: a, apiToken: m, email: o, ...n } = i, e = n;
|
|
12
5
|
return e.isEmailPublished && (e.email = o), e;
|
|
13
6
|
};
|
|
14
7
|
function u(t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-serializer.js","sources":["../../../src/models/serializers/user-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport type { IUser } from '../../interfaces/user';\n\nexport type IUserSerializedSecurely<U extends IUser> = Omit<\n U,\n 'password' | 'apiToken' | 'email'\n> & { email?: string };\n\nexport const omitInsecureAttributes = <U extends IUser>(\n user: U,\n): IUserSerializedSecurely<U> => {\n const leanDoc = user instanceof Document ? user.toObject<U>() : user;\n\n const {
|
|
1
|
+
{"version":3,"file":"user-serializer.js","sources":["../../../src/models/serializers/user-serializer.ts"],"sourcesContent":["import { Document } from 'mongoose';\n\nimport { isPopulated, isRef, type Ref } from '../../interfaces/common';\nimport type { IUser } from '../../interfaces/user';\n\nexport type IUserSerializedSecurely<U extends IUser> = Omit<\n U,\n 'password' | 'apiToken' | 'email'\n> & { email?: string };\n\nexport const omitInsecureAttributes = <U extends IUser>(\n user: U,\n): IUserSerializedSecurely<U> => {\n const leanDoc = user instanceof Document ? user.toObject<U>() : user;\n\n const { password, apiToken, email, ...rest } = leanDoc;\n\n const secureUser: IUserSerializedSecurely<U> = rest;\n\n // omit email\n if (secureUser.isEmailPublished) {\n secureUser.email = email;\n }\n\n return secureUser;\n};\n\nexport function serializeUserSecurely<U extends IUser>(\n user?: U,\n): IUserSerializedSecurely<U>;\nexport function serializeUserSecurely<U extends IUser>(\n user?: Ref<U>,\n): Ref<IUserSerializedSecurely<U>>;\nexport function serializeUserSecurely<U extends IUser>(\n user?: U | Ref<U>,\n): undefined | IUserSerializedSecurely<U> | Ref<IUserSerializedSecurely<U>> {\n if (user == null) return user;\n\n if (isRef(user) && !isPopulated(user)) return user;\n\n return omitInsecureAttributes(user);\n}\n"],"names":["omitInsecureAttributes","user","leanDoc","Document","password","apiToken","email","rest","secureUser","serializeUserSecurely","isRef","isPopulated"],"mappings":";;AAUa,MAAAA,IAAyB,CACpCC,MAC+B;AAC/B,QAAMC,IAAUD,aAAgBE,IAAWF,EAAK,SAAgB,IAAAA,GAE1D,EAAE,UAAAG,GAAU,UAAAC,GAAU,OAAAC,GAAO,GAAGC,EAAS,IAAAL,GAEzCM,IAAyCD;AAG/C,SAAIC,EAAW,qBACbA,EAAW,QAAQF,IAGdE;AACT;AAQO,SAASC,EACdR,GAC0E;AAG1E,SAFIA,KAAQ,QAERS,EAAMT,CAAI,KAAK,CAACU,EAAYV,CAAI,IAAUA,IAEvCD,EAAuBC,CAAI;AACpC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-apiv3.cjs","sources":["../../../src/models/vo/error-apiv3.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport class ErrorV3<ARGS = any> extends Error {\n code: string;\n\n args?: ARGS;\n\n constructor(\n message = '',\n code = '',\n stack = undefined,\n args: ARGS | undefined = undefined,\n ) {\n super(); // do not provide message to the super constructor\n this.message = message;\n this.code = code;\n this.stack = stack;\n this.args = args;\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const isErrorV3 = <ARGS = any>(obj: any): obj is ErrorV3<ARGS> => {\n return (\n obj != null && typeof obj === 'object' && 'code' in obj && 'message' in obj\n );\n};\n"],"names":["ErrorV3","message","code","stack","args","__publicField","isErrorV3","obj"],"mappings":"oPACO,MAAMA,UAA4B,KAAM,CAK7C,YACEC,EAAU,GACVC,EAAO,GACPC,EAAQ,OACRC,EAAyB,OACzB,
|
|
1
|
+
{"version":3,"file":"error-apiv3.cjs","sources":["../../../src/models/vo/error-apiv3.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport class ErrorV3<ARGS = any> extends Error {\n code: string;\n\n args?: ARGS;\n\n constructor(\n message = '',\n code = '',\n stack = undefined,\n args: ARGS | undefined = undefined,\n ) {\n super(); // do not provide message to the super constructor\n this.message = message;\n this.code = code;\n this.stack = stack;\n this.args = args;\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const isErrorV3 = <ARGS = any>(obj: any): obj is ErrorV3<ARGS> => {\n return (\n obj != null && typeof obj === 'object' && 'code' in obj && 'message' in obj\n );\n};\n"],"names":["ErrorV3","message","code","stack","args","__publicField","isErrorV3","obj"],"mappings":"oPACO,MAAMA,UAA4B,KAAM,CAK7C,YACEC,EAAU,GACVC,EAAO,GACPC,EAAQ,OACRC,EAAyB,OACzB,CACM,MAAA,EAVRC,EAAA,aAEAA,EAAA,aASE,KAAK,QAAUJ,EACf,KAAK,KAAOC,EACZ,KAAK,MAAQC,EACb,KAAK,KAAOC,CAAA,CAEhB,CAGa,MAAAE,EAAyBC,GAElCA,GAAO,MAAQ,OAAOA,GAAQ,UAAY,SAAUA,GAAO,YAAaA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-apiv3.js","sources":["../../../src/models/vo/error-apiv3.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport class ErrorV3<ARGS = any> extends Error {\n code: string;\n\n args?: ARGS;\n\n constructor(\n message = '',\n code = '',\n stack = undefined,\n args: ARGS | undefined = undefined,\n ) {\n super(); // do not provide message to the super constructor\n this.message = message;\n this.code = code;\n this.stack = stack;\n this.args = args;\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const isErrorV3 = <ARGS = any>(obj: any): obj is ErrorV3<ARGS> => {\n return (\n obj != null && typeof obj === 'object' && 'code' in obj && 'message' in obj\n );\n};\n"],"names":["ErrorV3","message","code","stack","args","__publicField","isErrorV3","obj"],"mappings":";;;AACO,MAAMA,UAA4B,MAAM;AAAA,EAK7C,YACEC,IAAU,IACVC,IAAO,IACPC,IAAQ,QACRC,IAAyB,QACzB;
|
|
1
|
+
{"version":3,"file":"error-apiv3.js","sources":["../../../src/models/vo/error-apiv3.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport class ErrorV3<ARGS = any> extends Error {\n code: string;\n\n args?: ARGS;\n\n constructor(\n message = '',\n code = '',\n stack = undefined,\n args: ARGS | undefined = undefined,\n ) {\n super(); // do not provide message to the super constructor\n this.message = message;\n this.code = code;\n this.stack = stack;\n this.args = args;\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const isErrorV3 = <ARGS = any>(obj: any): obj is ErrorV3<ARGS> => {\n return (\n obj != null && typeof obj === 'object' && 'code' in obj && 'message' in obj\n );\n};\n"],"names":["ErrorV3","message","code","stack","args","__publicField","isErrorV3","obj"],"mappings":";;;AACO,MAAMA,UAA4B,MAAM;AAAA,EAK7C,YACEC,IAAU,IACVC,IAAO,IACPC,IAAQ,QACRC,IAAyB,QACzB;AACM,UAAA;AAVR,IAAAC,EAAA;AAEA,IAAAA,EAAA;AASE,SAAK,UAAUJ,GACf,KAAK,OAAOC,GACZ,KAAK,QAAQC,GACb,KAAK,OAAOC;AAAA,EAAA;AAEhB;AAGa,MAAAE,IAAY,CAAaC,MAElCA,KAAO,QAAQ,OAAOA,KAAQ,YAAY,UAAUA,KAAO,aAAaA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-parser.cjs","sources":["../../../src/remark-plugins/util/option-parser.ts"],"sourcesContent":["import type { ParseRangeResult } from '../interfaces/option-parser';\n\n/**\n * Options parser for custom tag\n */\nexport const OptionParser = {\n /**\n * Parse range expression\n *\n * <ul>\n * <li>ex:</li>\n * <ul>\n * <li>1:2 -> { start: 1, end: 2 }</li>\n * <li>1: -> { start: 1, end: -1 }</li>\n * <li>2+3 -> { start: 1, end: 5 }</li>\n * </ul>\n * </ul>\n *\n * @see https://regex101.com/r/w4KCwC/4\n *\n * @static\n * @param {string} str\n * @returns {ParseRangeResult}\n */\n parseRange(str: string): ParseRangeResult | null {\n if (str == null) {\n return null;\n }\n\n // see: https://regex101.com/r/w4KCwC/4\n const match = str.match(/^(-?[0-9]+)(([:+]{1})(-?[0-9]+)?)?$/);\n if (!match) {\n return null;\n }\n\n // determine start\n let start: number;\n let end = -1;\n\n // has operator\n if (match[3] != null) {\n start = +match[1];\n const operator = match[3];\n\n // determine end\n if (operator === ':') {\n end = +match[4] || -1; // set last(-1) if undefined\n } else if (operator === '+') {\n end = +match[4] || 0; // plus zero if undefined\n end += start;\n }\n }\n // don't have operator\n else {\n start = 1;\n end = +match[1];\n }\n\n return { start, end };\n },\n};\n"],"names":["OptionParser","str","match","start","end","operator"],"mappings":"gFAKO,MAAMA,EAAe,CAmB1B,WAAWC,EAAsC,CAC/C,GAAIA,GAAO,
|
|
1
|
+
{"version":3,"file":"option-parser.cjs","sources":["../../../src/remark-plugins/util/option-parser.ts"],"sourcesContent":["import type { ParseRangeResult } from '../interfaces/option-parser';\n\n/**\n * Options parser for custom tag\n */\nexport const OptionParser = {\n /**\n * Parse range expression\n *\n * <ul>\n * <li>ex:</li>\n * <ul>\n * <li>1:2 -> { start: 1, end: 2 }</li>\n * <li>1: -> { start: 1, end: -1 }</li>\n * <li>2+3 -> { start: 1, end: 5 }</li>\n * </ul>\n * </ul>\n *\n * @see https://regex101.com/r/w4KCwC/4\n *\n * @static\n * @param {string} str\n * @returns {ParseRangeResult}\n */\n parseRange(str: string): ParseRangeResult | null {\n if (str == null) {\n return null;\n }\n\n // see: https://regex101.com/r/w4KCwC/4\n const match = str.match(/^(-?[0-9]+)(([:+]{1})(-?[0-9]+)?)?$/);\n if (!match) {\n return null;\n }\n\n // determine start\n let start: number;\n let end = -1;\n\n // has operator\n if (match[3] != null) {\n start = +match[1];\n const operator = match[3];\n\n // determine end\n if (operator === ':') {\n end = +match[4] || -1; // set last(-1) if undefined\n } else if (operator === '+') {\n end = +match[4] || 0; // plus zero if undefined\n end += start;\n }\n }\n // don't have operator\n else {\n start = 1;\n end = +match[1];\n }\n\n return { start, end };\n },\n};\n"],"names":["OptionParser","str","match","start","end","operator"],"mappings":"gFAKO,MAAMA,EAAe,CAmB1B,WAAWC,EAAsC,CAC/C,GAAIA,GAAO,KACF,OAAA,KAIH,MAAAC,EAAQD,EAAI,MAAM,qCAAqC,EAC7D,GAAI,CAACC,EACI,OAAA,KAIL,IAAAC,EACAC,EAAM,GAGN,GAAAF,EAAM,CAAC,GAAK,KAAM,CACZC,EAAA,CAACD,EAAM,CAAC,EACV,MAAAG,EAAWH,EAAM,CAAC,EAGpBG,IAAa,IACTD,EAAA,CAACF,EAAM,CAAC,GAAK,GACVG,IAAa,MAChBD,EAAA,CAACF,EAAM,CAAC,GAAK,EACZE,GAAAD,EACT,MAIQA,EAAA,EACFC,EAAA,CAACF,EAAM,CAAC,EAGT,MAAA,CAAE,MAAAC,EAAO,IAAAC,CAAI,CAAA,CAExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-parser.js","sources":["../../../src/remark-plugins/util/option-parser.ts"],"sourcesContent":["import type { ParseRangeResult } from '../interfaces/option-parser';\n\n/**\n * Options parser for custom tag\n */\nexport const OptionParser = {\n /**\n * Parse range expression\n *\n * <ul>\n * <li>ex:</li>\n * <ul>\n * <li>1:2 -> { start: 1, end: 2 }</li>\n * <li>1: -> { start: 1, end: -1 }</li>\n * <li>2+3 -> { start: 1, end: 5 }</li>\n * </ul>\n * </ul>\n *\n * @see https://regex101.com/r/w4KCwC/4\n *\n * @static\n * @param {string} str\n * @returns {ParseRangeResult}\n */\n parseRange(str: string): ParseRangeResult | null {\n if (str == null) {\n return null;\n }\n\n // see: https://regex101.com/r/w4KCwC/4\n const match = str.match(/^(-?[0-9]+)(([:+]{1})(-?[0-9]+)?)?$/);\n if (!match) {\n return null;\n }\n\n // determine start\n let start: number;\n let end = -1;\n\n // has operator\n if (match[3] != null) {\n start = +match[1];\n const operator = match[3];\n\n // determine end\n if (operator === ':') {\n end = +match[4] || -1; // set last(-1) if undefined\n } else if (operator === '+') {\n end = +match[4] || 0; // plus zero if undefined\n end += start;\n }\n }\n // don't have operator\n else {\n start = 1;\n end = +match[1];\n }\n\n return { start, end };\n },\n};\n"],"names":["OptionParser","str","match","start","end","operator"],"mappings":"AAKO,MAAMA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB1B,WAAWC,GAAsC;AAC/C,QAAIA,KAAO;
|
|
1
|
+
{"version":3,"file":"option-parser.js","sources":["../../../src/remark-plugins/util/option-parser.ts"],"sourcesContent":["import type { ParseRangeResult } from '../interfaces/option-parser';\n\n/**\n * Options parser for custom tag\n */\nexport const OptionParser = {\n /**\n * Parse range expression\n *\n * <ul>\n * <li>ex:</li>\n * <ul>\n * <li>1:2 -> { start: 1, end: 2 }</li>\n * <li>1: -> { start: 1, end: -1 }</li>\n * <li>2+3 -> { start: 1, end: 5 }</li>\n * </ul>\n * </ul>\n *\n * @see https://regex101.com/r/w4KCwC/4\n *\n * @static\n * @param {string} str\n * @returns {ParseRangeResult}\n */\n parseRange(str: string): ParseRangeResult | null {\n if (str == null) {\n return null;\n }\n\n // see: https://regex101.com/r/w4KCwC/4\n const match = str.match(/^(-?[0-9]+)(([:+]{1})(-?[0-9]+)?)?$/);\n if (!match) {\n return null;\n }\n\n // determine start\n let start: number;\n let end = -1;\n\n // has operator\n if (match[3] != null) {\n start = +match[1];\n const operator = match[3];\n\n // determine end\n if (operator === ':') {\n end = +match[4] || -1; // set last(-1) if undefined\n } else if (operator === '+') {\n end = +match[4] || 0; // plus zero if undefined\n end += start;\n }\n }\n // don't have operator\n else {\n start = 1;\n end = +match[1];\n }\n\n return { start, end };\n },\n};\n"],"names":["OptionParser","str","match","start","end","operator"],"mappings":"AAKO,MAAMA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB1B,WAAWC,GAAsC;AAC/C,QAAIA,KAAO;AACF,aAAA;AAIH,UAAAC,IAAQD,EAAI,MAAM,qCAAqC;AAC7D,QAAI,CAACC;AACI,aAAA;AAIL,QAAAC,GACAC,IAAM;AAGN,QAAAF,EAAM,CAAC,KAAK,MAAM;AACZ,MAAAC,IAAA,CAACD,EAAM,CAAC;AACV,YAAAG,IAAWH,EAAM,CAAC;AAGxB,MAAIG,MAAa,MACTD,IAAA,CAACF,EAAM,CAAC,KAAK,KACVG,MAAa,QAChBD,IAAA,CAACF,EAAM,CAAC,KAAK,GACZE,KAAAD;AAAA,IACT;AAIQ,MAAAA,IAAA,GACFC,IAAA,CAACF,EAAM,CAAC;AAGT,WAAA,EAAE,OAAAC,GAAO,KAAAC,EAAI;AAAA,EAAA;AAExB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-utils.cjs","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const withUtils = <U, D = any, E = any>(\n response: SWRResponse<D, E>,\n utils: U,\n): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-utils.cjs","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const withUtils = <U, D = any, E = any>(\n response: SWRResponse<D, E>,\n utils: U,\n): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"gFAMa,MAAAA,EAAY,CACvBC,EACAC,IAEO,OAAO,OAAOD,EAAUC,CAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-utils.js","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const withUtils = <U, D = any, E = any>(\n response: SWRResponse<D, E>,\n utils: U,\n): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-utils.js","sources":["../../src/swr/with-utils.ts"],"sourcesContent":["import type { SWRResponse } from 'swr';\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport type SWRResponseWithUtils<U, D = any, E = any> = SWRResponse<D, E> & U;\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const withUtils = <U, D = any, E = any>(\n response: SWRResponse<D, E>,\n utils: U,\n): SWRResponseWithUtils<U, D, E> => {\n return Object.assign(response, utils);\n};\n"],"names":["withUtils","response","utils"],"mappings":"AAMa,MAAAA,IAAY,CACvBC,GACAC,MAEO,OAAO,OAAOD,GAAUC,CAAK;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-utils.cjs","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (\n typeof window !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.webdriver)\n );\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"gFAAO,MAAMA,EAAW,IAEpB,OAAO,OAAW,KACjB,OAAO,UAAc,KAAe,UAAU,UAItCC,EAAW,IACf,CAACD,
|
|
1
|
+
{"version":3,"file":"browser-utils.cjs","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (\n typeof window !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.webdriver)\n );\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"gFAAO,MAAMA,EAAW,IAEpB,OAAO,OAAW,KACjB,OAAO,UAAc,KAAe,UAAU,UAItCC,EAAW,IACf,CAACD,EAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-utils.js","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (\n typeof window !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.webdriver)\n );\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"AAAO,MAAMA,IAAW,MAEpB,OAAO,SAAW,OACjB,OAAO,YAAc,OAAe,UAAU,WAItCC,IAAW,MACf,CAACD,
|
|
1
|
+
{"version":3,"file":"browser-utils.js","sources":["../../src/utils/browser-utils.ts"],"sourcesContent":["export const isClient = (): boolean => {\n return (\n typeof window !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.webdriver)\n );\n};\n\nexport const isServer = (): boolean => {\n return !isClient();\n};\n"],"names":["isClient","isServer"],"mappings":"AAAO,MAAMA,IAAW,MAEpB,OAAO,SAAW,OACjB,OAAO,YAAc,OAAe,UAAU,WAItCC,IAAW,MACf,CAACD,EAAS;"}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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;
|
|
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
|
+
{"version":3,"file":"escape-string-for-regex.cjs","sources":["../../src/utils/escape-string-for-regex.ts"],"sourcesContent":["/**\n * Escape a string for safe use inside a regular expression that is sent to MongoDB\n * (`$regex` / `new RegExp(...)` used in a query). MongoDB evaluates regular expressions\n * with the PCRE2 engine.\n *\n * Why not `RegExp.escape()`:\n * Node.js 24's built-in `RegExp.escape()` escapes non-ASCII whitespace\n * (code points >= U+0100, e.g. U+3000 IDEOGRAPHIC SPACE) into `\\uXXXX` form.\n * PCRE2 does not support `\\u`, so such a pattern makes MongoDB throw\n * \"Regular expression is invalid: PCRE2 does not support ... \\u\" (error 51091).\n *\n * This helper instead escapes only regex metacharacters and passes every other\n * character through literally — behaviourally identical to `escape-string-regexp` v5,\n * which is what GROWI used before the v7.5.0 refactor. The output never contains `\\u`,\n * so it is safe to hand to MongoDB.\n *\n * Use this (not `RegExp.escape`) whenever the resulting pattern is sent to MongoDB.\n * For in-process JS regex (`.test()` / `.replace()`), `RegExp.escape` is fine.\n */\nexport const escapeStringForMongoRegex = (str: string): string => {\n return str.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n};\n"],"names":["escapeStringForMongoRegex","str"],"mappings":"gFAmBa,MAAAA,EAA6BC,GACjCA,EAAI,QAAQ,sBAAuB,MAAM,EAAE,QAAQ,KAAM,OAAO"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape a string for safe use inside a regular expression that is sent to MongoDB
|
|
3
|
+
* (`$regex` / `new RegExp(...)` used in a query). MongoDB evaluates regular expressions
|
|
4
|
+
* with the PCRE2 engine.
|
|
5
|
+
*
|
|
6
|
+
* Why not `RegExp.escape()`:
|
|
7
|
+
* Node.js 24's built-in `RegExp.escape()` escapes non-ASCII whitespace
|
|
8
|
+
* (code points >= U+0100, e.g. U+3000 IDEOGRAPHIC SPACE) into `\uXXXX` form.
|
|
9
|
+
* PCRE2 does not support `\u`, so such a pattern makes MongoDB throw
|
|
10
|
+
* "Regular expression is invalid: PCRE2 does not support ... \u" (error 51091).
|
|
11
|
+
*
|
|
12
|
+
* This helper instead escapes only regex metacharacters and passes every other
|
|
13
|
+
* character through literally — behaviourally identical to `escape-string-regexp` v5,
|
|
14
|
+
* which is what GROWI used before the v7.5.0 refactor. The output never contains `\u`,
|
|
15
|
+
* so it is safe to hand to MongoDB.
|
|
16
|
+
*
|
|
17
|
+
* Use this (not `RegExp.escape`) whenever the resulting pattern is sent to MongoDB.
|
|
18
|
+
* For in-process JS regex (`.test()` / `.replace()`), `RegExp.escape` is fine.
|
|
19
|
+
*/
|
|
20
|
+
export declare const escapeStringForMongoRegex: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape-string-for-regex.js","sources":["../../src/utils/escape-string-for-regex.ts"],"sourcesContent":["/**\n * Escape a string for safe use inside a regular expression that is sent to MongoDB\n * (`$regex` / `new RegExp(...)` used in a query). MongoDB evaluates regular expressions\n * with the PCRE2 engine.\n *\n * Why not `RegExp.escape()`:\n * Node.js 24's built-in `RegExp.escape()` escapes non-ASCII whitespace\n * (code points >= U+0100, e.g. U+3000 IDEOGRAPHIC SPACE) into `\\uXXXX` form.\n * PCRE2 does not support `\\u`, so such a pattern makes MongoDB throw\n * \"Regular expression is invalid: PCRE2 does not support ... \\u\" (error 51091).\n *\n * This helper instead escapes only regex metacharacters and passes every other\n * character through literally — behaviourally identical to `escape-string-regexp` v5,\n * which is what GROWI used before the v7.5.0 refactor. The output never contains `\\u`,\n * so it is safe to hand to MongoDB.\n *\n * Use this (not `RegExp.escape`) whenever the resulting pattern is sent to MongoDB.\n * For in-process JS regex (`.test()` / `.replace()`), `RegExp.escape` is fine.\n */\nexport const escapeStringForMongoRegex = (str: string): string => {\n return str.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d');\n};\n"],"names":["escapeStringForMongoRegex","str"],"mappings":"AAmBa,MAAAA,IAA4B,CAACC,MACjCA,EAAI,QAAQ,uBAAuB,MAAM,EAAE,QAAQ,MAAM,OAAO;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-event-target.cjs","sources":["../../src/utils/global-event-target.ts"],"sourcesContent":["class GlobalEventTarget extends EventTarget {\n private static instance: GlobalEventTarget;\n\n static getInstance(): GlobalEventTarget {\n if (!GlobalEventTarget.instance) {\n GlobalEventTarget.instance = new GlobalEventTarget();\n }\n return GlobalEventTarget.instance;\n }\n}\n\nexport const globalEventTarget = GlobalEventTarget.getInstance();\n"],"names":["_GlobalEventTarget","__publicField","GlobalEventTarget","globalEventTarget"],"mappings":"oPAAA,MAAMA,EAAN,MAAMA,UAA0B,WAAY,CAG1C,OAAO,aAAiC,
|
|
1
|
+
{"version":3,"file":"global-event-target.cjs","sources":["../../src/utils/global-event-target.ts"],"sourcesContent":["class GlobalEventTarget extends EventTarget {\n private static instance: GlobalEventTarget;\n\n static getInstance(): GlobalEventTarget {\n if (!GlobalEventTarget.instance) {\n GlobalEventTarget.instance = new GlobalEventTarget();\n }\n return GlobalEventTarget.instance;\n }\n}\n\nexport const globalEventTarget = GlobalEventTarget.getInstance();\n"],"names":["_GlobalEventTarget","__publicField","GlobalEventTarget","globalEventTarget"],"mappings":"oPAAA,MAAMA,EAAN,MAAMA,UAA0B,WAAY,CAG1C,OAAO,aAAiC,CAClC,OAACA,EAAkB,WACHA,EAAA,SAAW,IAAIA,GAE5BA,EAAkB,QAAA,CAE7B,EAREC,EADID,EACW,YADjB,IAAME,EAANF,EAWa,MAAAG,EAAoBD,EAAkB,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-event-target.js","sources":["../../src/utils/global-event-target.ts"],"sourcesContent":["class GlobalEventTarget extends EventTarget {\n private static instance: GlobalEventTarget;\n\n static getInstance(): GlobalEventTarget {\n if (!GlobalEventTarget.instance) {\n GlobalEventTarget.instance = new GlobalEventTarget();\n }\n return GlobalEventTarget.instance;\n }\n}\n\nexport const globalEventTarget = GlobalEventTarget.getInstance();\n"],"names":["_GlobalEventTarget","__publicField","GlobalEventTarget","globalEventTarget"],"mappings":";;;AAAA,MAAMA,IAAN,MAAMA,UAA0B,YAAY;AAAA,EAG1C,OAAO,cAAiC;
|
|
1
|
+
{"version":3,"file":"global-event-target.js","sources":["../../src/utils/global-event-target.ts"],"sourcesContent":["class GlobalEventTarget extends EventTarget {\n private static instance: GlobalEventTarget;\n\n static getInstance(): GlobalEventTarget {\n if (!GlobalEventTarget.instance) {\n GlobalEventTarget.instance = new GlobalEventTarget();\n }\n return GlobalEventTarget.instance;\n }\n}\n\nexport const globalEventTarget = GlobalEventTarget.getInstance();\n"],"names":["_GlobalEventTarget","__publicField","GlobalEventTarget","globalEventTarget"],"mappings":";;;AAAA,MAAMA,IAAN,MAAMA,UAA0B,YAAY;AAAA,EAG1C,OAAO,cAAiC;AAClC,WAACA,EAAkB,aACHA,EAAA,WAAW,IAAIA,EAAkB,IAE9CA,EAAkB;AAAA,EAAA;AAE7B;AAREC,EADID,GACW;AADjB,IAAME,IAANF;AAWa,MAAAG,IAAoBD,EAAkB,YAAY;"}
|
|
@@ -1 +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 = (\n growiThemeSchemeType?: GrowiThemeSchemeType,\n): ColorScheme | undefined => {\n return growiThemeSchemeType == null ||\n growiThemeSchemeType === GrowiThemeSchemeType.BOTH\n ? undefined\n : (growiThemeSchemeType as ColorScheme);\n};\n"],"names":["getForcedColorScheme","growiThemeSchemeType","GrowiThemeSchemeType"],"mappings":";
|
|
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 = (\n growiThemeSchemeType?: GrowiThemeSchemeType,\n): ColorScheme | undefined => {\n return growiThemeSchemeType == null ||\n growiThemeSchemeType === GrowiThemeSchemeType.BOTH\n ? undefined\n : (growiThemeSchemeType as ColorScheme);\n};\n"],"names":["getForcedColorScheme","growiThemeSchemeType","GrowiThemeSchemeType"],"mappings":";AAGa,MAAAA,IAAuB,CAClCC,MAEOA,KAAwB,QAC7BA,MAAyBC,EAAqB,OAC5C,SACCD;"}
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./env-utils.cjs"),e=require("./browser-utils.cjs"),r=require("./global-event-target.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./env-utils.cjs"),e=require("./browser-utils.cjs"),r=require("./escape-string-for-regex.cjs"),i=require("./global-event-target.cjs"),o=require("./growi-theme-metadata.cjs"),s=require("./is-deep-equals.cjs"),l=require("./objectid-utils.cjs"),n=require("./page-path-utils/index.cjs"),c=require("./page-utils.cjs"),a=require("./path-utils.cjs"),g=require("./template-checker.cjs"),u=t;exports.isClient=e.isClient;exports.isServer=e.isServer;exports.escapeStringForMongoRegex=r.escapeStringForMongoRegex;exports.globalEventTarget=i.globalEventTarget;exports.getForcedColorScheme=o.getForcedColorScheme;exports.deepEquals=s;exports.objectIdUtils=l;exports.pagePathUtils=n;exports.pageUtils=c;exports.pathUtils=a;exports.templateChecker=g;exports.envUtils=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/utils/index.cjs.map
CHANGED
|
@@ -1 +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\nexport * from './browser-utils';\nexport * from './global-event-target';\nexport * from './growi-theme-metadata';\nexport * as deepEquals from './is-deep-equals';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pageUtils from './page-utils';\nexport * as pathUtils from './path-utils';\n// export utils with namespace\nexport * as templateChecker from './template-checker';\n"],"names":["envUtils","_envUtils"],"mappings":"
|
|
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\nexport * from './browser-utils';\nexport * from './escape-string-for-regex';\nexport * from './global-event-target';\nexport * from './growi-theme-metadata';\nexport * as deepEquals from './is-deep-equals';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pageUtils from './page-utils';\nexport * as pathUtils from './path-utils';\n// export utils with namespace\nexport * as templateChecker from './template-checker';\n"],"names":["envUtils","_envUtils"],"mappings":"2dAGaA,EAAWC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _envUtils from './env-utils';
|
|
2
2
|
export declare const envUtils: typeof _envUtils;
|
|
3
3
|
export * from './browser-utils';
|
|
4
|
+
export * from './escape-string-for-regex';
|
|
4
5
|
export * from './global-event-target';
|
|
5
6
|
export * from './growi-theme-metadata';
|
|
6
7
|
export * as deepEquals from './is-deep-equals';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as e from "./env-utils.js";
|
|
2
2
|
import { isClient as x, isServer as f } from "./browser-utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as o from "./
|
|
7
|
-
import * as r from "./
|
|
3
|
+
import { escapeStringForMongoRegex as n } from "./escape-string-for-regex.js";
|
|
4
|
+
import { globalEventTarget as U } from "./global-event-target.js";
|
|
5
|
+
import { getForcedColorScheme as h } from "./growi-theme-metadata.js";
|
|
6
|
+
import * as o from "./is-deep-equals.js";
|
|
7
|
+
import * as r from "./objectid-utils.js";
|
|
8
|
+
import * as t from "./page-path-utils/index.js";
|
|
8
9
|
import * as p from "./page-utils.js";
|
|
9
10
|
import * as s from "./path-utils.js";
|
|
10
11
|
import * as i from "./template-checker.js";
|
|
11
|
-
const a =
|
|
12
|
+
const a = e;
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
+
o as deepEquals,
|
|
14
15
|
a as envUtils,
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
n as escapeStringForMongoRegex,
|
|
17
|
+
h as getForcedColorScheme,
|
|
18
|
+
U as globalEventTarget,
|
|
17
19
|
x as isClient,
|
|
18
20
|
f as isServer,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
r as objectIdUtils,
|
|
22
|
+
t as pagePathUtils,
|
|
21
23
|
p as pageUtils,
|
|
22
24
|
s as pathUtils,
|
|
23
25
|
i as templateChecker
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +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\nexport * from './browser-utils';\nexport * from './global-event-target';\nexport * from './growi-theme-metadata';\nexport * as deepEquals from './is-deep-equals';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pageUtils from './page-utils';\nexport * as pathUtils from './path-utils';\n// export utils with namespace\nexport * as templateChecker from './template-checker';\n"],"names":["envUtils","_envUtils"],"mappings":"
|
|
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\nexport * from './browser-utils';\nexport * from './escape-string-for-regex';\nexport * from './global-event-target';\nexport * from './growi-theme-metadata';\nexport * as deepEquals from './is-deep-equals';\nexport * as objectIdUtils from './objectid-utils';\nexport * as pagePathUtils from './page-path-utils';\nexport * as pageUtils from './page-utils';\nexport * as pathUtils from './path-utils';\n// export utils with namespace\nexport * as templateChecker from './template-checker';\n"],"names":["envUtils","_envUtils"],"mappings":";;;;;;;;;;;AAGO,MAAMA,IAAWC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-deep-equals.cjs","sources":["../../src/utils/is-deep-equals.ts"],"sourcesContent":["const isPrimitiveComparison = (value1: unknown, value2: unknown): boolean => {\n return (\n value1 === null ||\n value2 === null ||\n typeof value1 !== 'object' ||\n typeof value2 !== 'object'\n );\n};\n\nexport const isDeepEquals = <T extends object>(\n obj1: T,\n obj2: T,\n visited = new WeakMap(),\n): boolean => {\n // If references are identical, return true\n if (obj1 === obj2) {\n return true;\n }\n\n // Use simple comparison for null or primitive values\n if (isPrimitiveComparison(obj1, obj2)) {\n return obj1 === obj2;\n }\n\n // Check for circular references\n if (visited.has(obj1)) {\n return visited.get(obj1) === obj2;\n }\n visited.set(obj1, obj2);\n\n // Compare number of properties\n const typedKeys1 = Object.keys(obj1) as (keyof typeof obj1)[];\n const typedKeys2 = Object.keys(obj2) as (keyof typeof obj2)[];\n\n if (typedKeys1.length !== typedKeys2.length) {\n return false;\n }\n\n // Compare all properties\n return typedKeys1.every((key) => {\n const val1 = obj1[key];\n const val2 = obj2[key];\n\n // Handle arrays comparison\n if (Array.isArray(val1) && Array.isArray(val2)) {\n if (val1.length !== val2.length) {\n return false;\n }\n\n return val1.every((item, i) => {\n if (!isPrimitiveComparison(item, val2[i])) {\n return isDeepEquals(item, val2[i], visited);\n }\n return item === val2[i];\n });\n }\n\n // Recursively compare objects\n if (!isPrimitiveComparison(val1, val2)) {\n return isDeepEquals(val1 as object, val2 as object, visited);\n }\n\n // Compare primitive values\n return val1 === val2;\n });\n};\n"],"names":["isPrimitiveComparison","value1","value2","isDeepEquals","obj1","obj2","visited","typedKeys1","typedKeys2","key","val1","val2","item","i"],"mappings":"gFAAA,MAAMA,EAAwB,CAACC,EAAiBC,IAE5CD,IAAW,MACXC,IAAW,MACX,OAAOD,GAAW,UAClB,OAAOC,GAAW,SAITC,EAAe,CAC1BC,EACAC,EACAC,EAAU,IAAI,UACF,CAEZ,GAAIF,IAASC,
|
|
1
|
+
{"version":3,"file":"is-deep-equals.cjs","sources":["../../src/utils/is-deep-equals.ts"],"sourcesContent":["const isPrimitiveComparison = (value1: unknown, value2: unknown): boolean => {\n return (\n value1 === null ||\n value2 === null ||\n typeof value1 !== 'object' ||\n typeof value2 !== 'object'\n );\n};\n\nexport const isDeepEquals = <T extends object>(\n obj1: T,\n obj2: T,\n visited = new WeakMap(),\n): boolean => {\n // If references are identical, return true\n if (obj1 === obj2) {\n return true;\n }\n\n // Use simple comparison for null or primitive values\n if (isPrimitiveComparison(obj1, obj2)) {\n return obj1 === obj2;\n }\n\n // Check for circular references\n if (visited.has(obj1)) {\n return visited.get(obj1) === obj2;\n }\n visited.set(obj1, obj2);\n\n // Compare number of properties\n const typedKeys1 = Object.keys(obj1) as (keyof typeof obj1)[];\n const typedKeys2 = Object.keys(obj2) as (keyof typeof obj2)[];\n\n if (typedKeys1.length !== typedKeys2.length) {\n return false;\n }\n\n // Compare all properties\n return typedKeys1.every((key) => {\n const val1 = obj1[key];\n const val2 = obj2[key];\n\n // Handle arrays comparison\n if (Array.isArray(val1) && Array.isArray(val2)) {\n if (val1.length !== val2.length) {\n return false;\n }\n\n return val1.every((item, i) => {\n if (!isPrimitiveComparison(item, val2[i])) {\n return isDeepEquals(item, val2[i], visited);\n }\n return item === val2[i];\n });\n }\n\n // Recursively compare objects\n if (!isPrimitiveComparison(val1, val2)) {\n return isDeepEquals(val1 as object, val2 as object, visited);\n }\n\n // Compare primitive values\n return val1 === val2;\n });\n};\n"],"names":["isPrimitiveComparison","value1","value2","isDeepEquals","obj1","obj2","visited","typedKeys1","typedKeys2","key","val1","val2","item","i"],"mappings":"gFAAA,MAAMA,EAAwB,CAACC,EAAiBC,IAE5CD,IAAW,MACXC,IAAW,MACX,OAAOD,GAAW,UAClB,OAAOC,GAAW,SAITC,EAAe,CAC1BC,EACAC,EACAC,EAAU,IAAI,UACF,CAEZ,GAAIF,IAASC,EACJ,MAAA,GAIL,GAAAL,EAAsBI,EAAMC,CAAI,EAClC,OAAOD,IAASC,EAId,GAAAC,EAAQ,IAAIF,CAAI,EACX,OAAAE,EAAQ,IAAIF,CAAI,IAAMC,EAEvBC,EAAA,IAAIF,EAAMC,CAAI,EAGhB,MAAAE,EAAa,OAAO,KAAKH,CAAI,EAC7BI,EAAa,OAAO,KAAKH,CAAI,EAE/B,OAAAE,EAAW,SAAWC,EAAW,OAC5B,GAIFD,EAAW,MAAOE,GAAQ,CACzB,MAAAC,EAAON,EAAKK,CAAG,EACfE,EAAON,EAAKI,CAAG,EAGrB,OAAI,MAAM,QAAQC,CAAI,GAAK,MAAM,QAAQC,CAAI,EACvCD,EAAK,SAAWC,EAAK,OAChB,GAGFD,EAAK,MAAM,CAACE,EAAMC,IAClBb,EAAsBY,EAAMD,EAAKE,CAAC,CAAC,EAGjCD,IAASD,EAAKE,CAAC,EAFbV,EAAaS,EAAMD,EAAKE,CAAC,EAAGP,CAAO,CAG7C,EAIEN,EAAsBU,EAAMC,CAAI,EAK9BD,IAASC,EAJPR,EAAaO,EAAgBC,EAAgBL,CAAO,CAI7C,CACjB,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-deep-equals.js","sources":["../../src/utils/is-deep-equals.ts"],"sourcesContent":["const isPrimitiveComparison = (value1: unknown, value2: unknown): boolean => {\n return (\n value1 === null ||\n value2 === null ||\n typeof value1 !== 'object' ||\n typeof value2 !== 'object'\n );\n};\n\nexport const isDeepEquals = <T extends object>(\n obj1: T,\n obj2: T,\n visited = new WeakMap(),\n): boolean => {\n // If references are identical, return true\n if (obj1 === obj2) {\n return true;\n }\n\n // Use simple comparison for null or primitive values\n if (isPrimitiveComparison(obj1, obj2)) {\n return obj1 === obj2;\n }\n\n // Check for circular references\n if (visited.has(obj1)) {\n return visited.get(obj1) === obj2;\n }\n visited.set(obj1, obj2);\n\n // Compare number of properties\n const typedKeys1 = Object.keys(obj1) as (keyof typeof obj1)[];\n const typedKeys2 = Object.keys(obj2) as (keyof typeof obj2)[];\n\n if (typedKeys1.length !== typedKeys2.length) {\n return false;\n }\n\n // Compare all properties\n return typedKeys1.every((key) => {\n const val1 = obj1[key];\n const val2 = obj2[key];\n\n // Handle arrays comparison\n if (Array.isArray(val1) && Array.isArray(val2)) {\n if (val1.length !== val2.length) {\n return false;\n }\n\n return val1.every((item, i) => {\n if (!isPrimitiveComparison(item, val2[i])) {\n return isDeepEquals(item, val2[i], visited);\n }\n return item === val2[i];\n });\n }\n\n // Recursively compare objects\n if (!isPrimitiveComparison(val1, val2)) {\n return isDeepEquals(val1 as object, val2 as object, visited);\n }\n\n // Compare primitive values\n return val1 === val2;\n });\n};\n"],"names":["isPrimitiveComparison","value1","value2","isDeepEquals","obj1","obj2","visited","typedKeys1","typedKeys2","key","val1","val2","item","i"],"mappings":"AAAA,MAAMA,IAAwB,CAACC,GAAiBC,MAE5CD,MAAW,QACXC,MAAW,QACX,OAAOD,KAAW,YAClB,OAAOC,KAAW,UAITC,IAAe,CAC1BC,GACAC,GACAC,IAAU,oBAAI,cACF;AAEZ,MAAIF,MAASC;
|
|
1
|
+
{"version":3,"file":"is-deep-equals.js","sources":["../../src/utils/is-deep-equals.ts"],"sourcesContent":["const isPrimitiveComparison = (value1: unknown, value2: unknown): boolean => {\n return (\n value1 === null ||\n value2 === null ||\n typeof value1 !== 'object' ||\n typeof value2 !== 'object'\n );\n};\n\nexport const isDeepEquals = <T extends object>(\n obj1: T,\n obj2: T,\n visited = new WeakMap(),\n): boolean => {\n // If references are identical, return true\n if (obj1 === obj2) {\n return true;\n }\n\n // Use simple comparison for null or primitive values\n if (isPrimitiveComparison(obj1, obj2)) {\n return obj1 === obj2;\n }\n\n // Check for circular references\n if (visited.has(obj1)) {\n return visited.get(obj1) === obj2;\n }\n visited.set(obj1, obj2);\n\n // Compare number of properties\n const typedKeys1 = Object.keys(obj1) as (keyof typeof obj1)[];\n const typedKeys2 = Object.keys(obj2) as (keyof typeof obj2)[];\n\n if (typedKeys1.length !== typedKeys2.length) {\n return false;\n }\n\n // Compare all properties\n return typedKeys1.every((key) => {\n const val1 = obj1[key];\n const val2 = obj2[key];\n\n // Handle arrays comparison\n if (Array.isArray(val1) && Array.isArray(val2)) {\n if (val1.length !== val2.length) {\n return false;\n }\n\n return val1.every((item, i) => {\n if (!isPrimitiveComparison(item, val2[i])) {\n return isDeepEquals(item, val2[i], visited);\n }\n return item === val2[i];\n });\n }\n\n // Recursively compare objects\n if (!isPrimitiveComparison(val1, val2)) {\n return isDeepEquals(val1 as object, val2 as object, visited);\n }\n\n // Compare primitive values\n return val1 === val2;\n });\n};\n"],"names":["isPrimitiveComparison","value1","value2","isDeepEquals","obj1","obj2","visited","typedKeys1","typedKeys2","key","val1","val2","item","i"],"mappings":"AAAA,MAAMA,IAAwB,CAACC,GAAiBC,MAE5CD,MAAW,QACXC,MAAW,QACX,OAAOD,KAAW,YAClB,OAAOC,KAAW,UAITC,IAAe,CAC1BC,GACAC,GACAC,IAAU,oBAAI,cACF;AAEZ,MAAIF,MAASC;AACJ,WAAA;AAIL,MAAAL,EAAsBI,GAAMC,CAAI;AAClC,WAAOD,MAASC;AAId,MAAAC,EAAQ,IAAIF,CAAI;AACX,WAAAE,EAAQ,IAAIF,CAAI,MAAMC;AAEvB,EAAAC,EAAA,IAAIF,GAAMC,CAAI;AAGhB,QAAAE,IAAa,OAAO,KAAKH,CAAI,GAC7BI,IAAa,OAAO,KAAKH,CAAI;AAE/B,SAAAE,EAAW,WAAWC,EAAW,SAC5B,KAIFD,EAAW,MAAM,CAACE,MAAQ;AACzB,UAAAC,IAAON,EAAKK,CAAG,GACfE,IAAON,EAAKI,CAAG;AAGrB,WAAI,MAAM,QAAQC,CAAI,KAAK,MAAM,QAAQC,CAAI,IACvCD,EAAK,WAAWC,EAAK,SAChB,KAGFD,EAAK,MAAM,CAACE,GAAMC,MAClBb,EAAsBY,GAAMD,EAAKE,CAAC,CAAC,IAGjCD,MAASD,EAAKE,CAAC,IAFbV,EAAaS,GAAMD,EAAKE,CAAC,GAAGP,CAAO,CAG7C,IAIEN,EAAsBU,GAAMC,CAAI,IAK9BD,MAASC,IAJPR,EAAaO,GAAgBC,GAAgBL,CAAO;AAAA,EAI7C,CACjB;AACH;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./is-top-page.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../escape-string-for-regex.cjs"),n=require("./is-top-page.cjs"),g=e=>n.isTopPage(e)?new RegExp(/^\/[^/]+$/):new RegExp(`^${r.escapeStringForMongoRegex(e)}(\\/[^/]+)\\/?$`);exports.generateChildrenRegExp=g;
|
|
2
2
|
//# sourceMappingURL=generate-children-regexp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-children-regexp.cjs","sources":["../../../src/utils/page-path-utils/generate-children-regexp.ts"],"sourcesContent":["import { isTopPage } from './is-top-page';\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(`^${
|
|
1
|
+
{"version":3,"file":"generate-children-regexp.cjs","sources":["../../../src/utils/page-path-utils/generate-children-regexp.ts"],"sourcesContent":["import { escapeStringForMongoRegex } from '../escape-string-for-regex';\nimport { isTopPage } from './is-top-page';\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 // NOTE: use escapeStringForMongoRegex (not RegExp.escape) because this pattern is sent to\n // MongoDB ($regex). RegExp.escape would emit \\uXXXX for non-ASCII whitespace (e.g. U+3000),\n // which PCRE2 rejects (error 51091).\n return new RegExp(`^${escapeStringForMongoRegex(path)}(\\\\/[^/]+)\\\\/?$`);\n};\n"],"names":["generateChildrenRegExp","path","isTopPage","escapeStringForMongoRegex"],"mappings":"iKAMaA,EAA0BC,GAGjCC,YAAUD,CAAI,EAAU,IAAI,OAAO,WAAW,EAO3C,IAAI,OAAO,IAAIE,EAA0B,0BAAAF,CAAI,CAAC,iBAAiB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { escapeStringForMongoRegex as r } from "../escape-string-for-regex.js";
|
|
2
|
+
import { isTopPage as o } from "./is-top-page.js";
|
|
3
|
+
const p = (e) => o(e) ? new RegExp(/^\/[^/]+$/) : new RegExp(`^${r(e)}(\\/[^/]+)\\/?$`);
|
|
3
4
|
export {
|
|
4
5
|
p as generateChildrenRegExp
|
|
5
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-children-regexp.js","sources":["../../../src/utils/page-path-utils/generate-children-regexp.ts"],"sourcesContent":["import { isTopPage } from './is-top-page';\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(`^${
|
|
1
|
+
{"version":3,"file":"generate-children-regexp.js","sources":["../../../src/utils/page-path-utils/generate-children-regexp.ts"],"sourcesContent":["import { escapeStringForMongoRegex } from '../escape-string-for-regex';\nimport { isTopPage } from './is-top-page';\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 // NOTE: use escapeStringForMongoRegex (not RegExp.escape) because this pattern is sent to\n // MongoDB ($regex). RegExp.escape would emit \\uXXXX for non-ASCII whitespace (e.g. U+3000),\n // which PCRE2 rejects (error 51091).\n return new RegExp(`^${escapeStringForMongoRegex(path)}(\\\\/[^/]+)\\\\/?$`);\n};\n"],"names":["generateChildrenRegExp","path","isTopPage","escapeStringForMongoRegex"],"mappings":";;AAMa,MAAAA,IAAyB,CAACC,MAGjCC,EAAUD,CAAI,IAAU,IAAI,OAAO,WAAW,IAO3C,IAAI,OAAO,IAAIE,EAA0BF,CAAI,CAAC,iBAAiB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp';\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/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/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 /^(\\/.+){130,}$/, // avoid deep layer path. see: https://regex101.com/r/L0kzOD/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 = (\n user: { username: string } | null | undefined,\n): 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 = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(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 } catch {\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 =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .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 */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\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 = (\n path1: string,\n path2: string,\n): 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(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(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 = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(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 * 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\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\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","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","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp';\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/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/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 /^(\\/.+){130,}$/, // avoid deep layer path. see: https://regex101.com/r/L0kzOD/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 = (\n user: { username: string } | null | undefined,\n): 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 = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(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 } catch {\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 =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .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 */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\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 = (\n path1: string,\n path2: string,\n): 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(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(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 = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(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 * 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\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\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","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","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp';\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/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/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 /^(\\/.+){130,}$/, // avoid deep layer path. see: https://regex101.com/r/L0kzOD/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 = (\n user: { username: string } | null | undefined,\n): 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 = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(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 } catch {\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 =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .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 */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\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 = (\n path1: string,\n path2: string,\n): 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(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(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 = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(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 * 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\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\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","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","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils';\nimport { addTrailingSlash } from '../path-utils';\nimport { isTopPage as _isTopPage } from './is-top-page';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp';\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/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/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 /^(\\/.+){130,}$/, // avoid deep layer path. see: https://regex101.com/r/L0kzOD/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 = (\n user: { username: string } | null | undefined,\n): 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 = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(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 } catch {\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 =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .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 */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\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 = (\n path1: string,\n path2: string,\n): 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(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(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 = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(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 * 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\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\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","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","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":"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"}
|
|
@@ -1 +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":"
|
|
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"}
|
|
@@ -1 +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":"
|
|
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;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-utils.cjs","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import type { IPage } from '..';\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":"qIAIMA,EAAmB,EACnBC,EAAkB,EAKlBC,EAAiB,UAOVC,EAAYC,GAAyB,
|
|
1
|
+
{"version":3,"file":"page-utils.cjs","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import type { IPage } from '..';\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":"qIAIMA,EAAmB,EACnBC,EAAkB,EAKlBC,EAAiB,UAOVC,EAAYC,GAAyB,CAC1C,KAAA,CAAE,KAAAC,EAAM,OAAAC,CAAA,EAAWF,EAMzB,MAJIG,GAAAA,EAAAA,UAAUF,CAAI,GAIdC,GAAU,KAKhB,EAWaE,EAAoBJ,GAAyB,CAClD,KAAA,CAAE,MAAAK,EAAO,OAAAC,CAAA,EAAWN,EAUtB,OARAK,IAAUT,GAAoBS,IAAUR,GAIxCS,IAAWR,GAIXC,EAASC,CAAI,EACR,EAIX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-utils.js","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import type { IPage } from '..';\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":";AAIA,MAAMA,IAAmB,GACnBC,IAAkB,GAKlBC,IAAiB,WAOVC,IAAW,CAACC,MAAyB;
|
|
1
|
+
{"version":3,"file":"page-utils.js","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import type { IPage } from '..';\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":";AAIA,MAAMA,IAAmB,GACnBC,IAAkB,GAKlBC,IAAiB,WAOVC,IAAW,CAACC,MAAyB;AAC1C,QAAA,EAAE,MAAAC,GAAM,QAAAC,EAAA,IAAWF;AAMzB,SAJI,GAAAG,EAAUF,CAAI,KAIdC,KAAU;AAKhB,GAWaE,IAAmB,CAACJ,MAAyB;AAClD,QAAA,EAAE,OAAAK,GAAO,QAAAC,EAAA,IAAWN;AAUtB,SARAK,MAAUT,KAAoBS,MAAUR,KAIxCS,MAAWR,KAIXC,EAASC,CAAI,GACR;AAIX;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.cjs","sources":["../../src/utils/path-utils.ts"],"sourcesContent":["interface PathParts {\n readonly headingSlashes: string;\n readonly content: string;\n readonly trailingSlashes: string;\n readonly hasHeadingSlash: boolean;\n readonly hasTrailingSlash: boolean;\n}\n\nfunction parsePath(path: string): PathParts | null {\n if (typeof path !== 'string' || !path || path === '') return null;\n\n // Special case for root path\n if (path === '/') {\n return {\n headingSlashes: '/',\n content: '',\n trailingSlashes: '',\n hasHeadingSlash: true,\n hasTrailingSlash: true,\n };\n }\n\n let startIndex = 0;\n let endIndex = path.length;\n\n // Find leading slashes\n while (startIndex < path.length && path[startIndex] === '/') {\n startIndex++;\n }\n\n // Find trailing slashes\n while (endIndex > startIndex && path[endIndex - 1] === '/') {\n endIndex--;\n }\n\n const headingSlashes = path.substring(0, startIndex);\n const content = path.substring(startIndex, endIndex);\n const trailingSlashes = path.substring(endIndex);\n\n return {\n headingSlashes,\n content,\n trailingSlashes,\n hasHeadingSlash: headingSlashes.length > 0,\n hasTrailingSlash: trailingSlashes.length > 0,\n };\n}\n\nexport function hasHeadingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasHeadingSlash ?? false;\n}\n\nexport function hasTrailingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasTrailingSlash ?? false;\n}\n\nexport function addHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) {\n return `/${path}`;\n }\n return path;\n}\n\nexport function addTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasTrailingSlash) {\n return `${path}/`;\n }\n return path;\n}\n\nexport function removeHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) return path;\n\n // Special case for '//' -> '/'\n if (path === '//') return '/';\n\n // Remove heading slashes and return content + trailing slashes\n return parts.content + parts.trailingSlashes;\n}\n\nexport function removeTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (parts == null) return path;\n\n // Return heading slashes + content (without trailing slashes)\n return parts.headingSlashes + parts.content;\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n */\nexport function normalizePath(path: string): string {\n if (typeof path !== 'string' || path === '' || path === '/') {\n return '/';\n }\n\n const parts = parsePath(path);\n if (parts == null) {\n return '/';\n }\n return `/${parts.content}`;\n}\n\nexport function attachTitleHeader(path: string): string {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n */\nexport function returnPathForURL(path: string, id: string): string {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n\n/**\n * Get the parent path of the specified path.\n */\nexport function getParentPath(path: string): string {\n return normalizePath(path.split('/').slice(0, -1).join('/'));\n}\n"],"names":["parsePath","path","startIndex","endIndex","headingSlashes","content","trailingSlashes","hasHeadingSlash","parts","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","attachTitleHeader","returnPathForURL","id","getParentPath"],"mappings":"gFAQA,SAASA,EAAUC,EAAgC,CACjD,GAAI,OAAOA,GAAS,UAAY,CAACA,GAAQA,IAAS,
|
|
1
|
+
{"version":3,"file":"path-utils.cjs","sources":["../../src/utils/path-utils.ts"],"sourcesContent":["interface PathParts {\n readonly headingSlashes: string;\n readonly content: string;\n readonly trailingSlashes: string;\n readonly hasHeadingSlash: boolean;\n readonly hasTrailingSlash: boolean;\n}\n\nfunction parsePath(path: string): PathParts | null {\n if (typeof path !== 'string' || !path || path === '') return null;\n\n // Special case for root path\n if (path === '/') {\n return {\n headingSlashes: '/',\n content: '',\n trailingSlashes: '',\n hasHeadingSlash: true,\n hasTrailingSlash: true,\n };\n }\n\n let startIndex = 0;\n let endIndex = path.length;\n\n // Find leading slashes\n while (startIndex < path.length && path[startIndex] === '/') {\n startIndex++;\n }\n\n // Find trailing slashes\n while (endIndex > startIndex && path[endIndex - 1] === '/') {\n endIndex--;\n }\n\n const headingSlashes = path.substring(0, startIndex);\n const content = path.substring(startIndex, endIndex);\n const trailingSlashes = path.substring(endIndex);\n\n return {\n headingSlashes,\n content,\n trailingSlashes,\n hasHeadingSlash: headingSlashes.length > 0,\n hasTrailingSlash: trailingSlashes.length > 0,\n };\n}\n\nexport function hasHeadingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasHeadingSlash ?? false;\n}\n\nexport function hasTrailingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasTrailingSlash ?? false;\n}\n\nexport function addHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) {\n return `/${path}`;\n }\n return path;\n}\n\nexport function addTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasTrailingSlash) {\n return `${path}/`;\n }\n return path;\n}\n\nexport function removeHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) return path;\n\n // Special case for '//' -> '/'\n if (path === '//') return '/';\n\n // Remove heading slashes and return content + trailing slashes\n return parts.content + parts.trailingSlashes;\n}\n\nexport function removeTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (parts == null) return path;\n\n // Return heading slashes + content (without trailing slashes)\n return parts.headingSlashes + parts.content;\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n */\nexport function normalizePath(path: string): string {\n if (typeof path !== 'string' || path === '' || path === '/') {\n return '/';\n }\n\n const parts = parsePath(path);\n if (parts == null) {\n return '/';\n }\n return `/${parts.content}`;\n}\n\nexport function attachTitleHeader(path: string): string {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n */\nexport function returnPathForURL(path: string, id: string): string {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n\n/**\n * Get the parent path of the specified path.\n */\nexport function getParentPath(path: string): string {\n return normalizePath(path.split('/').slice(0, -1).join('/'));\n}\n"],"names":["parsePath","path","startIndex","endIndex","headingSlashes","content","trailingSlashes","hasHeadingSlash","parts","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","attachTitleHeader","returnPathForURL","id","getParentPath"],"mappings":"gFAQA,SAASA,EAAUC,EAAgC,CACjD,GAAI,OAAOA,GAAS,UAAY,CAACA,GAAQA,IAAS,GAAW,OAAA,KAG7D,GAAIA,IAAS,IACJ,MAAA,CACL,eAAgB,IAChB,QAAS,GACT,gBAAiB,GACjB,gBAAiB,GACjB,iBAAkB,EACpB,EAGF,IAAIC,EAAa,EACbC,EAAWF,EAAK,OAGpB,KAAOC,EAAaD,EAAK,QAAUA,EAAKC,CAAU,IAAM,KACtDA,IAIF,KAAOC,EAAWD,GAAcD,EAAKE,EAAW,CAAC,IAAM,KACrDA,IAGF,MAAMC,EAAiBH,EAAK,UAAU,EAAGC,CAAU,EAC7CG,EAAUJ,EAAK,UAAUC,EAAYC,CAAQ,EAC7CG,EAAkBL,EAAK,UAAUE,CAAQ,EAExC,MAAA,CACL,eAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,gBAAiBF,EAAe,OAAS,EACzC,iBAAkBE,EAAgB,OAAS,CAC7C,CACF,CAEO,SAASC,EAAgBN,EAAuB,CACjD,GAAAA,IAAS,IAAY,MAAA,GAEnB,MAAAO,EAAQR,EAAUC,CAAI,EAC5B,OAAOO,GAAA,YAAAA,EAAO,kBAAmB,EACnC,CAEO,SAASC,EAAiBR,EAAuB,CAClD,GAAAA,IAAS,IAAY,MAAA,GAEnB,MAAAO,EAAQR,EAAUC,CAAI,EAC5B,OAAOO,GAAA,YAAAA,EAAO,mBAAoB,EACpC,CAEO,SAASE,EAAgBT,EAAsB,CAChD,GAAAA,IAAS,IAAY,OAAAA,EACrB,GAAAA,IAAS,GAAW,MAAA,IAElB,MAAAO,EAAQR,EAAUC,CAAI,EACxB,OAACO,GAAA,MAAAA,EAAO,gBAGLP,EAFE,IAAIA,CAAI,EAGnB,CAEO,SAASU,EAAiBV,EAAsB,CACjD,GAAAA,IAAS,IAAY,OAAAA,EACrB,GAAAA,IAAS,GAAW,MAAA,IAElB,MAAAO,EAAQR,EAAUC,CAAI,EACxB,OAACO,GAAA,MAAAA,EAAO,iBAGLP,EAFE,GAAGA,CAAI,GAGlB,CAEO,SAASW,EAAmBX,EAAsB,CAEnD,GADAA,IAAS,KACTA,IAAS,GAAW,OAAAA,EAElB,MAAAO,EAAQR,EAAUC,CAAI,EACxB,OAACO,GAAA,MAAAA,EAAO,gBAGRP,IAAS,KAAa,IAGnBO,EAAM,QAAUA,EAAM,gBANOP,CAOtC,CAEO,SAASY,EAAoBZ,EAAsB,CAEpD,GADAA,IAAS,KACTA,IAAS,GAAW,OAAAA,EAElB,MAAAO,EAAQR,EAAUC,CAAI,EACxB,OAAAO,GAAS,KAAaP,EAGnBO,EAAM,eAAiBA,EAAM,OACtC,CAKO,SAASM,EAAcb,EAAsB,CAClD,GAAI,OAAOA,GAAS,UAAYA,IAAS,IAAMA,IAAS,IAC/C,MAAA,IAGH,MAAAO,EAAQR,EAAUC,CAAI,EAC5B,OAAIO,GAAS,KACJ,IAEF,IAAIA,EAAM,OAAO,EAC1B,CAEO,SAASO,EAAkBd,EAAsB,CACtD,MAAO,KAAKA,CAAI,EAClB,CAKgB,SAAAe,EAAiBf,EAAcgB,EAAoB,CACjE,OAAIhB,IAAS,IACJA,EAGFS,EAAgBO,CAAE,CAC3B,CAKO,SAASC,EAAcjB,EAAsB,CAC3C,OAAAa,EAAcb,EAAK,MAAM,GAAG,EAAE,MAAM,EAAG,EAAE,EAAE,KAAK,GAAG,CAAC,CAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sources":["../../src/utils/path-utils.ts"],"sourcesContent":["interface PathParts {\n readonly headingSlashes: string;\n readonly content: string;\n readonly trailingSlashes: string;\n readonly hasHeadingSlash: boolean;\n readonly hasTrailingSlash: boolean;\n}\n\nfunction parsePath(path: string): PathParts | null {\n if (typeof path !== 'string' || !path || path === '') return null;\n\n // Special case for root path\n if (path === '/') {\n return {\n headingSlashes: '/',\n content: '',\n trailingSlashes: '',\n hasHeadingSlash: true,\n hasTrailingSlash: true,\n };\n }\n\n let startIndex = 0;\n let endIndex = path.length;\n\n // Find leading slashes\n while (startIndex < path.length && path[startIndex] === '/') {\n startIndex++;\n }\n\n // Find trailing slashes\n while (endIndex > startIndex && path[endIndex - 1] === '/') {\n endIndex--;\n }\n\n const headingSlashes = path.substring(0, startIndex);\n const content = path.substring(startIndex, endIndex);\n const trailingSlashes = path.substring(endIndex);\n\n return {\n headingSlashes,\n content,\n trailingSlashes,\n hasHeadingSlash: headingSlashes.length > 0,\n hasTrailingSlash: trailingSlashes.length > 0,\n };\n}\n\nexport function hasHeadingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasHeadingSlash ?? false;\n}\n\nexport function hasTrailingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasTrailingSlash ?? false;\n}\n\nexport function addHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) {\n return `/${path}`;\n }\n return path;\n}\n\nexport function addTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasTrailingSlash) {\n return `${path}/`;\n }\n return path;\n}\n\nexport function removeHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) return path;\n\n // Special case for '//' -> '/'\n if (path === '//') return '/';\n\n // Remove heading slashes and return content + trailing slashes\n return parts.content + parts.trailingSlashes;\n}\n\nexport function removeTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (parts == null) return path;\n\n // Return heading slashes + content (without trailing slashes)\n return parts.headingSlashes + parts.content;\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n */\nexport function normalizePath(path: string): string {\n if (typeof path !== 'string' || path === '' || path === '/') {\n return '/';\n }\n\n const parts = parsePath(path);\n if (parts == null) {\n return '/';\n }\n return `/${parts.content}`;\n}\n\nexport function attachTitleHeader(path: string): string {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n */\nexport function returnPathForURL(path: string, id: string): string {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n\n/**\n * Get the parent path of the specified path.\n */\nexport function getParentPath(path: string): string {\n return normalizePath(path.split('/').slice(0, -1).join('/'));\n}\n"],"names":["parsePath","path","startIndex","endIndex","headingSlashes","content","trailingSlashes","hasHeadingSlash","parts","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","attachTitleHeader","returnPathForURL","id","getParentPath"],"mappings":"AAQA,SAASA,EAAUC,GAAgC;AACjD,MAAI,OAAOA,KAAS,YAAY,CAACA,KAAQA,MAAS,
|
|
1
|
+
{"version":3,"file":"path-utils.js","sources":["../../src/utils/path-utils.ts"],"sourcesContent":["interface PathParts {\n readonly headingSlashes: string;\n readonly content: string;\n readonly trailingSlashes: string;\n readonly hasHeadingSlash: boolean;\n readonly hasTrailingSlash: boolean;\n}\n\nfunction parsePath(path: string): PathParts | null {\n if (typeof path !== 'string' || !path || path === '') return null;\n\n // Special case for root path\n if (path === '/') {\n return {\n headingSlashes: '/',\n content: '',\n trailingSlashes: '',\n hasHeadingSlash: true,\n hasTrailingSlash: true,\n };\n }\n\n let startIndex = 0;\n let endIndex = path.length;\n\n // Find leading slashes\n while (startIndex < path.length && path[startIndex] === '/') {\n startIndex++;\n }\n\n // Find trailing slashes\n while (endIndex > startIndex && path[endIndex - 1] === '/') {\n endIndex--;\n }\n\n const headingSlashes = path.substring(0, startIndex);\n const content = path.substring(startIndex, endIndex);\n const trailingSlashes = path.substring(endIndex);\n\n return {\n headingSlashes,\n content,\n trailingSlashes,\n hasHeadingSlash: headingSlashes.length > 0,\n hasTrailingSlash: trailingSlashes.length > 0,\n };\n}\n\nexport function hasHeadingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasHeadingSlash ?? false;\n}\n\nexport function hasTrailingSlash(path: string): boolean {\n if (path === '/') return true;\n\n const parts = parsePath(path);\n return parts?.hasTrailingSlash ?? false;\n}\n\nexport function addHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) {\n return `/${path}`;\n }\n return path;\n}\n\nexport function addTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return '/';\n\n const parts = parsePath(path);\n if (!parts?.hasTrailingSlash) {\n return `${path}/`;\n }\n return path;\n}\n\nexport function removeHeadingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (!parts?.hasHeadingSlash) return path;\n\n // Special case for '//' -> '/'\n if (path === '//') return '/';\n\n // Remove heading slashes and return content + trailing slashes\n return parts.content + parts.trailingSlashes;\n}\n\nexport function removeTrailingSlash(path: string): string {\n if (path === '/') return path;\n if (path === '') return path;\n\n const parts = parsePath(path);\n if (parts == null) return path;\n\n // Return heading slashes + content (without trailing slashes)\n return parts.headingSlashes + parts.content;\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n */\nexport function normalizePath(path: string): string {\n if (typeof path !== 'string' || path === '' || path === '/') {\n return '/';\n }\n\n const parts = parsePath(path);\n if (parts == null) {\n return '/';\n }\n return `/${parts.content}`;\n}\n\nexport function attachTitleHeader(path: string): string {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n */\nexport function returnPathForURL(path: string, id: string): string {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n\n/**\n * Get the parent path of the specified path.\n */\nexport function getParentPath(path: string): string {\n return normalizePath(path.split('/').slice(0, -1).join('/'));\n}\n"],"names":["parsePath","path","startIndex","endIndex","headingSlashes","content","trailingSlashes","hasHeadingSlash","parts","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","attachTitleHeader","returnPathForURL","id","getParentPath"],"mappings":"AAQA,SAASA,EAAUC,GAAgC;AACjD,MAAI,OAAOA,KAAS,YAAY,CAACA,KAAQA,MAAS,GAAW,QAAA;AAG7D,MAAIA,MAAS;AACJ,WAAA;AAAA,MACL,gBAAgB;AAAA,MAChB,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAGF,MAAIC,IAAa,GACbC,IAAWF,EAAK;AAGpB,SAAOC,IAAaD,EAAK,UAAUA,EAAKC,CAAU,MAAM;AACtD,IAAAA;AAIF,SAAOC,IAAWD,KAAcD,EAAKE,IAAW,CAAC,MAAM;AACrD,IAAAA;AAGF,QAAMC,IAAiBH,EAAK,UAAU,GAAGC,CAAU,GAC7CG,IAAUJ,EAAK,UAAUC,GAAYC,CAAQ,GAC7CG,IAAkBL,EAAK,UAAUE,CAAQ;AAExC,SAAA;AAAA,IACL,gBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAiBF,EAAe,SAAS;AAAA,IACzC,kBAAkBE,EAAgB,SAAS;AAAA,EAC7C;AACF;AAEO,SAASC,EAAgBN,GAAuB;AACjD,MAAAA,MAAS,IAAY,QAAA;AAEnB,QAAAO,IAAQR,EAAUC,CAAI;AAC5B,UAAOO,KAAA,gBAAAA,EAAO,oBAAmB;AACnC;AAEO,SAASC,EAAiBR,GAAuB;AAClD,MAAAA,MAAS,IAAY,QAAA;AAEnB,QAAAO,IAAQR,EAAUC,CAAI;AAC5B,UAAOO,KAAA,gBAAAA,EAAO,qBAAoB;AACpC;AAEO,SAASE,EAAgBT,GAAsB;AAChD,MAAAA,MAAS,IAAY,QAAAA;AACrB,MAAAA,MAAS,GAAW,QAAA;AAElB,QAAAO,IAAQR,EAAUC,CAAI;AACxB,SAACO,KAAA,QAAAA,EAAO,kBAGLP,IAFE,IAAIA,CAAI;AAGnB;AAEO,SAASU,EAAiBV,GAAsB;AACjD,MAAAA,MAAS,IAAY,QAAAA;AACrB,MAAAA,MAAS,GAAW,QAAA;AAElB,QAAAO,IAAQR,EAAUC,CAAI;AACxB,SAACO,KAAA,QAAAA,EAAO,mBAGLP,IAFE,GAAGA,CAAI;AAGlB;AAEO,SAASW,EAAmBX,GAAsB;AAEnD,MADAA,MAAS,OACTA,MAAS,GAAW,QAAAA;AAElB,QAAAO,IAAQR,EAAUC,CAAI;AACxB,SAACO,KAAA,QAAAA,EAAO,kBAGRP,MAAS,OAAa,MAGnBO,EAAM,UAAUA,EAAM,kBANOP;AAOtC;AAEO,SAASY,EAAoBZ,GAAsB;AAEpD,MADAA,MAAS,OACTA,MAAS,GAAW,QAAAA;AAElB,QAAAO,IAAQR,EAAUC,CAAI;AACxB,SAAAO,KAAS,OAAaP,IAGnBO,EAAM,iBAAiBA,EAAM;AACtC;AAKO,SAASM,EAAcb,GAAsB;AAClD,MAAI,OAAOA,KAAS,YAAYA,MAAS,MAAMA,MAAS;AAC/C,WAAA;AAGH,QAAAO,IAAQR,EAAUC,CAAI;AAC5B,SAAIO,KAAS,OACJ,MAEF,IAAIA,EAAM,OAAO;AAC1B;AAEO,SAASO,EAAkBd,GAAsB;AACtD,SAAO,KAAKA,CAAI;AAClB;AAKgB,SAAAe,EAAiBf,GAAcgB,GAAoB;AACjE,SAAIhB,MAAS,MACJA,IAGFS,EAAgBO,CAAE;AAC3B;AAKO,SAASC,EAAcjB,GAAsB;AAC3C,SAAAa,EAAcb,EAAK,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC;AAC7D;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-checker.cjs","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"gFAIO,SAASA,EAAkBC,EAAuB,
|
|
1
|
+
{"version":3,"file":"template-checker.cjs","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"gFAIO,SAASA,EAAkBC,EAAuB,CACnD,MAAA,EAAAA,EAAK,MAAM,sBAAsB,CAKvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-checker.js","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"AAIO,SAASA,EAAkBC,GAAuB;
|
|
1
|
+
{"version":3,"file":"template-checker.js","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"AAIO,SAASA,EAAkBC,GAAuB;AACnD,SAAA,EAAAA,EAAK,MAAM,sBAAsB;AAKvC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@growi/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "GROWI Core Libraries",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/express": "^4",
|
|
72
|
-
"mongoose": "^6.13.
|
|
72
|
+
"mongoose": "^6.13.9",
|
|
73
73
|
"socket.io-client": "^4.7.5",
|
|
74
74
|
"swr": "^2.2.2"
|
|
75
75
|
},
|