@yuji-min/google-docs-parser 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/edge/auth.ts","../src/edge/client.ts","../src/constants.ts","../src/utils.ts","../src/tree.ts","../src/list.ts","../src/textBlock.ts","../src/section.ts","../src/cursor.ts","../src/edge/index.ts"],"names":[],"mappings":";;;AAKA,SAAS,gBAAgB,IAAA,EAA0B;AACjD,EAAA,MAAM,SAAS,IAAA,CAAK,MAAA,CAAO,YAAA,CAAa,GAAG,IAAI,CAAC,CAAA;AAChD,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAA;AACxE;AAKA,SAAS,mBAAmB,GAAA,EAAyB;AACnD,EAAA,OAAO,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,GAAG,CAAA;AACrC;AAKA,eAAe,iBAAiB,MAAA,EAAoC;AAElE,EAAA,MAAM,WAAA,GAAc,MAAA,CACjB,OAAA,CAAQ,6BAAA,EAA+B,EAAE,CAAA,CACzC,OAAA,CAAQ,2BAAA,EAA6B,EAAE,CAAA,CACvC,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAEpB,EAAA,MAAM,SAAA,GAAY,UAAA,CAAW,IAAA,CAAK,IAAA,CAAK,WAAW,CAAA,EAAG,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,CAAC,CAAC,CAAA;AAE3E,EAAA,OAAO,OAAO,MAAA,CAAO,SAAA;AAAA,IACnB,OAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,MACE,IAAA,EAAM,mBAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACR;AAAA,IACA,KAAA;AAAA,IACA,CAAC,MAAM;AAAA,GACT;AACF;AA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,sBAAA,EAAuB;AAC1D,IAAA,IAAI,mBAAA,EAAqB;AACvB,MAAA,MAAM,OAAA,GAAU,YAAY,QAAA,CAAS,IAAA;AAAA,QACnC,CAAC,CAAA,KAAM,CAAA,CAAE,KAAA,CAAM,IAAA,KAAS;AAAA,OAC1B;AACA,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,MAAA,CAAO,gBAAA,EAAiB;AACxB,QAAA,MAAM,UAAA,GAAa,mBAAA,CAAoB,MAAA,EAAQ,OAAO,CAAA;AACtD,QAAA,MAAA,CAAO,mBAAmB,CAAA,GAAI,UAAA;AAC9B,QAAA;AAAA,MACF;AAAA,IACF;AACA,IAAA,MAAA,CAAO,gBAAA,EAAiB;AAAA,EAC1B;AAEA,EAAA,OAAO,MAAA;AACT;AAqBA,eAAsB,iBAAA,CACpB,YACA,WAAA,EAC2B;AAC3B,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,WAAA,CAAY,UAAU,CAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,aAAA,CAAc,GAAA,EAAK,WAAW,CAAA;AACrD,IAAA,OAAO,cAAA;AAAA,EACT,SAAS,CAAA,EAAG;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,8FACE,CAAA,YAAa,KAAA,GAAQ,EAAE,OAAA,GAAU,MAAA,CAAO,CAAC,CAC3C,CAAA;AAAA,KACF;AAAA,EACF;AACF","file":"edge.cjs","sourcesContent":["import type { ServiceAccountCredentials, TokenResponse } from \"./types\";\n\n/**\n * Encodes data in Base64 URL format (JWT standard).\n */\nfunction base64UrlEncode(data: Uint8Array): string {\n const base64 = btoa(String.fromCharCode(...data));\n return base64.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=/g, \"\");\n}\n\n/**\n * Converts a string to Uint8Array.\n */\nfunction stringToUint8Array(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts a PEM-formatted private key to CryptoKey.\n */\nasync function importPrivateKey(pemKey: string): Promise<CryptoKey> {\n // Remove PEM header/footer and decode Base64\n const pemContents = pemKey\n .replace(/-----BEGIN PRIVATE KEY-----/, \"\")\n .replace(/-----END PRIVATE KEY-----/, \"\")\n .replace(/\\s/g, \"\");\n\n const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));\n\n return crypto.subtle.importKey(\n \"pkcs8\",\n binaryDer,\n {\n name: \"RSASSA-PKCS1-v1_5\",\n hash: \"SHA-256\",\n },\n false,\n [\"sign\"]\n );\n}\n\n/**\n * Creates and signs a JWT.\n */\nasync function createSignedJWT(\n credentials: ServiceAccountCredentials,\n scope: string\n): Promise<string> {\n const now = Math.floor(Date.now() / 1000);\n const expiry = now + 3600; // Expires in 1 hour\n\n // JWT Header\n const header = {\n alg: \"RS256\",\n typ: \"JWT\",\n };\n\n // JWT Payload\n const payload = {\n iss: credentials.client_email,\n scope,\n aud: credentials.token_uri,\n exp: expiry,\n iat: now,\n };\n\n // Base64 URL encode Header and Payload\n const encodedHeader = base64UrlEncode(\n stringToUint8Array(JSON.stringify(header))\n );\n const encodedPayload = base64UrlEncode(\n stringToUint8Array(JSON.stringify(payload))\n );\n\n const unsignedToken = `${encodedHeader}.${encodedPayload}`;\n\n // Sign with Private Key\n const privateKey = await importPrivateKey(credentials.private_key);\n const dataToSign = stringToUint8Array(unsignedToken);\n const signature = await crypto.subtle.sign(\n \"RSASSA-PKCS1-v1_5\",\n privateKey,\n dataToSign as BufferSource\n );\n\n const encodedSignature = base64UrlEncode(new Uint8Array(signature));\n\n return `${unsignedToken}.${encodedSignature}`;\n}\n\n/**\n * Obtains a Google OAuth2 access token.\n */\nasync function getAccessToken(\n credentials: ServiceAccountCredentials\n): Promise<string> {\n const scope = \"https://www.googleapis.com/auth/documents.readonly\";\n const jwt = await createSignedJWT(credentials, scope);\n\n const response = await fetch(credentials.token_uri, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:jwt-bearer\",\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Failed to get access token: ${response.status} ${errorText}`\n );\n }\n\n const data = (await response.json()) as TokenResponse;\n return data.access_token;\n}\n\n/**\n * Loads Service Account credentials from environment variables.\n */\nexport function loadCredentials(): ServiceAccountCredentials {\n const credentialsEnv = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n\n if (!credentialsEnv) {\n throw new Error(\n \"GOOGLE_APPLICATION_CREDENTIALS environment variable is not set\"\n );\n }\n\n try {\n // If it's a JSON string, parse it\n if (credentialsEnv.trim().startsWith(\"{\")) {\n return JSON.parse(credentialsEnv) as ServiceAccountCredentials;\n }\n\n // File path not supported in Edge Runtime\n throw new Error(\n \"File path credentials are not supported in Edge Runtime. Use JSON string instead.\"\n );\n } catch (error) {\n throw new Error(\n `Failed to parse credentials: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\n/**\n * Creates an authenticated Google Docs API client.\n */\nexport async function createAuthenticatedClient(): Promise<string> {\n const credentials = loadCredentials();\n return getAccessToken(credentials);\n}\n","import type { DocsDocument } from \"./types\";\nimport { createAuthenticatedClient } from \"./auth\";\n\n/**\n * Fetches a document from the Google Docs API.\n */\nexport async function fetchDocument(\n documentId: string,\n accessToken: string\n): Promise<DocsDocument> {\n const url = `https://docs.googleapis.com/v1/documents/${documentId}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Google Docs API request failed: ${response.status} ${errorText}`\n );\n }\n\n const data = (await response.json()) as DocsDocument;\n\n if (!data.body) {\n throw new Error(\"Empty document response from Google Docs API.\");\n }\n\n return data;\n}\n\n/**\n * Fetches a document with authentication (combined function).\n */\nexport async function getDocument(documentId: string): Promise<DocsDocument> {\n const accessToken = await createAuthenticatedClient();\n return fetchDocument(documentId, accessToken);\n}\n","/**\n * A constant tuple of supported Google Docs named styles that represent headings or titles.\n * These are used to identify structural nodes and section boundaries within the document tree.\n */\nexport const VALID_NAMED_STYLES = [\n \"HEADING_1\",\n \"HEADING_2\",\n \"HEADING_3\",\n \"HEADING_4\",\n \"HEADING_5\",\n \"HEADING_6\",\n \"TITLE\",\n \"SUBTITLE\",\n] as const;\n\n/**\n * A union type representing any one of the valid named styles defined in `VALID_NAMED_STYLES`.\n */\nexport type ValidNamedStyle = (typeof VALID_NAMED_STYLES)[number];\n\n/**\n * A Set containing the valid named styles for efficient O(1) validation checks.\n * This is primarily used in type guards to verify if a style string is a valid heading.\n */\nexport const VALID_NAMED_STYLES_SET = new Set<string>(VALID_NAMED_STYLES);\n","import type { docs_v1 } from \"googleapis\";\nimport { Schema, NamedStyleType } from \"./types\";\nimport { VALID_NAMED_STYLES_SET } from \"./constants\";\n\n/**\n * Extracts pure text content from a Google Docs Paragraph.\n *\n * - Joins content from all `textRun` elements.\n * - Trims leading and trailing whitespace.\n * - Normalizes newline characters (`\\n`) to spaces.\n *\n * @param paragraph - The Google Docs paragraph object.\n * @returns The extracted and cleaned text string. Returns an empty string if the paragraph is empty.\n */\nexport function extractParagraphText(\n paragraph: docs_v1.Schema$Paragraph\n): string {\n const elements = paragraph.elements ?? [];\n\n const text = elements\n .map((el: docs_v1.Schema$ParagraphElement) => el.textRun?.content || \"\")\n .join(\"\")\n .trim()\n .replace(/\\n/g, \" \");\n\n return text || \"\";\n}\n\n/**\n * Checks if a paragraph has a specific `namedStyleType` (e.g., HEADING_1).\n *\n * @param paragraph - The paragraph to check.\n * @param namedStyleType - The style type to compare against.\n * @returns `true` if the paragraph's style matches the provided type; otherwise `false`.\n */\nexport function hasNamedStyle(\n paragraph: docs_v1.Schema$Paragraph,\n namedStyleType?: NamedStyleType\n): boolean {\n if (!namedStyleType) return false;\n const style = paragraph.paragraphStyle?.namedStyleType;\n return style === namedStyleType;\n}\n\n/**\n * Retrieves the named style type of a paragraph, handling default behaviors and edge cases.\n *\n * Resolution Logic:\n * 1. Returns `undefined` if the paragraph has no style and no content (completely empty).\n * 2. Returns `\"NORMAL_TEXT\"` if the paragraph has content but no explicit style (Google Docs default).\n * 3. Returns `\"NORMAL_TEXT\"` if the style object exists but `namedStyleType` is missing.\n * 4. Returns the `namedStyleType` if it exists in the valid set (`VALID_NAMED_STYLES`).\n * 5. Returns `undefined` if the style is invalid or unknown.\n *\n * @param paragraph - The paragraph to analyze.\n * @returns The valid `NamedStyleType`, `\"NORMAL_TEXT\"`, or `undefined`.\n */\nexport function getParagraphNamedStyleType(\n paragraph: docs_v1.Schema$Paragraph\n): NamedStyleType | \"NORMAL_TEXT\" | undefined {\n if (!paragraph.paragraphStyle && !paragraph.elements?.length) {\n return undefined;\n }\n if (!paragraph.paragraphStyle) {\n return \"NORMAL_TEXT\";\n }\n\n const namedStyleType = paragraph.paragraphStyle.namedStyleType;\n\n if (!namedStyleType) {\n return \"NORMAL_TEXT\";\n }\n\n if (VALID_NAMED_STYLES_SET.has(namedStyleType)) {\n return namedStyleType as NamedStyleType;\n }\n\n return undefined;\n}\n\n/**\n * Type Guard to check if a style is a valid Heading style (HEADING_1~6, TITLE, SUBTITLE).\n *\n * - Returns `false` for `\"NORMAL_TEXT\"`.\n * - Returns `false` for undefined or invalid strings.\n *\n * @param style - The style string to check.\n * @returns `true` if the style is a valid `NamedStyleType`.\n */\nexport function isNamedStyleType(\n style: NamedStyleType | \"NORMAL_TEXT\" | undefined\n): style is NamedStyleType {\n if (typeof style !== \"string\") return false;\n if (style === \"NORMAL_TEXT\") return false;\n\n return VALID_NAMED_STYLES_SET.has(style);\n}\n\n/**\n * Splits a string by a delimiter and trims whitespace from each item.\n *\n * @param text - The string to split.\n * @param delimiter - The character to split by (e.g., \",\").\n * @param filterEmpty - If `true`, removes empty strings from the result. Defaults to `false`.\n * @returns An array of trimmed strings.\n */\nexport function splitAndTrim(\n text: string,\n delimiter: string,\n filterEmpty = false\n): string[] {\n if (text === \"\") {\n return [];\n }\n const items = text.split(delimiter).map((t) => t.trim());\n return filterEmpty ? items.filter((t) => t.length > 0) : items;\n}\n\n/**\n * Parses text into a Key-Value list structure.\n *\n * Format: \"Key: Value1, Value2\"\n *\n * @param text - The text to parse.\n * @param keyDelimiter - The separator between key and values (e.g., \":\").\n * @param listDelimiter - The separator between list items (e.g., \",\").\n * @returns An object `{ key, value[] }` if parsing succeeds, or the original text string if the key delimiter is missing.\n */\nexport function parseToKeyedList(\n text: string,\n keyDelimiter: string,\n listDelimiter: string\n): { key: string; value: string[] } | string {\n const delimiterIndex = text.indexOf(keyDelimiter);\n\n if (delimiterIndex <= 0) {\n return text;\n }\n\n const key = text.substring(0, delimiterIndex).trim();\n const valuePart = text.substring(delimiterIndex + keyDelimiter.length).trim();\n\n const value = valuePart ? splitAndTrim(valuePart, listDelimiter, true) : [];\n\n return { key, value };\n}\n\n/**\n * Maps delimited text values to a list of keys by position.\n *\n * Format: \"Value1 | Value2 | Value3\" -> { Key1: \"Value1\", Key2: \"Value2\", ... }\n *\n * @param text - The text to parse.\n * @param keys - The list of field names (keys) to map values to.\n * @param delimiter - The separator between values (e.g., \"|\").\n * @returns A record object mapping keys to values. Missing values are filled with empty strings.\n */\nexport function parseToFields(\n text: string,\n keys: readonly string[],\n delimiter: string\n): Record<string, unknown> {\n const values = splitAndTrim(text, delimiter, false);\n\n return keys.reduce((acc, key, index) => {\n const value = values[index];\n acc[key] = value !== undefined && value !== \"\" ? value : \"\";\n return acc;\n }, {} as Record<string, unknown>);\n}\n\n/**\n * Parses a simple delimited string into an array, filtering out empty items.\n *\n * Example: \"Apple, , Banana\" -> [\"Apple\", \"Banana\"]\n *\n * @param text - The text to parse.\n * @param delimiter - The separator (e.g., \",\").\n * @returns An array of non-empty strings.\n */\nexport function parseDelimitedList(text: string, delimiter: string): string[] {\n const values = text\n .split(delimiter)\n .map((v) => v.trim())\n .filter((v) => v.length > 0);\n return values;\n}\n\n/**\n * Parses a single line of text into structured data based on the provided Schema.\n *\n * **Parsing Priorities:**\n * 1. **Keyed List**: If `schema.keyDelimiter` is set. (e.g., \"Team: A, B\")\n * 2. **Fixed Fields**: If `schema.keys` is set. (e.g., \"Google | Engineer | 2023\")\n * 3. **Default List**: Fallback to simple delimited list. (e.g., \"A, B, C\")\n *\n * @param text - The text content to parse.\n * @param schema - The schema object defining the parsing rules.\n * @returns The parsed result as an object, array, or string depending on the schema.\n */\nexport function parseStructuredText(\n text: string,\n schema: Schema\n): Record<string, unknown> | string[] | string {\n const delimiter = schema.delimiter || \",\";\n\n if (schema.keyDelimiter) {\n return parseToKeyedList(text, schema.keyDelimiter, delimiter);\n }\n\n if (schema.keys && schema.keys.length > 0) {\n return parseToFields(text, schema.keys, delimiter);\n }\n\n return parseDelimitedList(text, delimiter);\n}\n","import type { docs_v1 } from \"googleapis\";\nimport { NamedStyleType, Node, Section, Schema } from \"./types\";\nimport { ParagraphCursor } from \"./cursor\";\nimport { hasNamedStyle, parseStructuredText } from \"./utils\";\n\nconst CONTENT_KEY = \"content\";\n\n/**\n * Recursively collects all `NamedStyleType`s defined within a nested `Node` schema.\n *\n * This is used to build a set of allowed heading styles for the parser to recognize\n * valid tree nodes and detect boundaries.\n *\n * @param node - The current node schema to traverse.\n * @param set - The Set to populate with collected style types.\n */\nexport function collectNodeStylesRecursive(\n node: Node,\n set: Set<NamedStyleType>\n): void {\n if (node.title.namedStyleType) set.add(node.title.namedStyleType);\n if (node.content && node.content.kind === \"tree\") {\n collectNodeStylesRecursive(node.content.node, set);\n }\n}\n\n/**\n * Creates a normalized node object from a raw title string based on the provided schema.\n *\n * - If the schema defines parsing rules (delimiters/keys), the title is parsed into\n * structured data (Array or Object).\n * - If no parsing rules exist, the title is treated as a simple string.\n *\n * @param text - The raw text of the title/heading.\n * @param titleSchema - The schema defining how to parse the title.\n * @returns An object containing the parsed `title` and an empty `content` array.\n */\nexport function createNodeFromTitle(\n text: string,\n titleSchema: Schema\n): Record<\"title\" | \"content\", unknown> {\n const hasDelimiterSchema =\n !!titleSchema.keyDelimiter ||\n (!!titleSchema.keys && titleSchema.keys.length > 0) ||\n !!titleSchema.delimiter;\n\n if (hasDelimiterSchema) {\n const structuredText = parseStructuredText(text, titleSchema);\n if (Array.isArray(structuredText)) {\n return { title: structuredText, content: [] };\n } else if (typeof structuredText === \"object\" && structuredText !== null) {\n return { title: structuredText, content: [] };\n } else {\n return { title: text, content: [] };\n }\n } else {\n return { title: text, content: [] };\n }\n}\n\n/**\n * Represents the decision made by the parser for the current paragraph.\n */\nexport type TreeParsingAction =\n | { kind: \"exitSection\" }\n | { kind: \"createNode\" }\n | { kind: \"startChildNode\" }\n | { kind: \"finishCurrentNode\" }\n | { kind: \"appendDetail\" };\n\n/**\n * Determines the next action to take based on the current paragraph's style\n * and its relationship to the current node hierarchy.\n *\n * Decision Logic Priorities:\n * 1. New Section -> Exit.\n * 2. Matches Current Node Title -> Create Sibling Node.\n * 3. Matches Child Node Title -> Start Child Node (Recursion).\n * 4. Matches Ancestor/Same Level Heading -> Finish Current Node (Pop Stack).\n * 5. Heading outside this tree -> Exit.\n * 6. Otherwise -> Append as detail content.\n *\n * @param paragraph - The current paragraph being inspected.\n * @param cursor - The paragraph cursor.\n * @param nodeSchema - The schema for the current node level.\n * @param ancestorNodeList - The stack of ancestor nodes for context.\n * @returns The determining parsing action.\n */\nexport function determineTreeParsingAction(\n paragraph: docs_v1.Schema$Paragraph,\n cursor: ParagraphCursor,\n nodeSchema: Node,\n ancestorNodeList: Node[]\n): TreeParsingAction {\n const nodeTitleStyle = nodeSchema.title.namedStyleType;\n const childNode =\n nodeSchema.content?.kind === \"tree\" ? nodeSchema.content.node : undefined;\n\n const isCurrentNodeTitle = hasNamedStyle(paragraph, nodeTitleStyle);\n const isChildNodeTitle =\n !!childNode && hasNamedStyle(paragraph, childNode.title.namedStyleType);\n const isAncestorNodeTitle = ancestorNodeList.some((a) =>\n hasNamedStyle(paragraph, a.title.namedStyleType)\n );\n\n const isInThisTree =\n isCurrentNodeTitle || isChildNodeTitle || isAncestorNodeTitle;\n\n const isHeading = cursor.isAtParagraphHeading();\n const isAtNewSection = cursor.isAtNewSection();\n const isHeadingOutsideThisTree = isHeading && !isInThisTree;\n const isHigherLevelHeading = isHeading && isAncestorNodeTitle;\n const isSameLevelHeading = isHeading && isCurrentNodeTitle;\n\n if (isAtNewSection) return { kind: \"exitSection\" };\n if (isCurrentNodeTitle) return { kind: \"createNode\" };\n if (isChildNodeTitle) return { kind: \"startChildNode\" };\n if (isHigherLevelHeading || isSameLevelHeading)\n return { kind: \"finishCurrentNode\" };\n if (isHeadingOutsideThisTree) return { kind: \"exitSection\" };\n return { kind: \"appendDetail\" };\n}\n\n/**\n * The entry point for parsing a document section defined as a `Tree`.\n *\n * It searches for the first occurrence of the root node style to begin parsing.\n * Text preceding the first valid root node is ignored (orphan text).\n *\n * @param cursor - The cursor traversing the document paragraphs.\n * @param section - The section definition containing the tree schema.\n * @param allNodeTitleStyles - A set of all valid styles in this tree (for boundary detection).\n * @returns An array of parsed tree nodes.\n */\nexport function parseTreeSection(\n cursor: ParagraphCursor,\n section: Section,\n allNodeTitleStyles: Set<NamedStyleType>\n): unknown[] {\n const treeContent = section.content;\n const nodeSchema =\n treeContent?.kind === \"tree\" ? treeContent.node : undefined;\n if (!treeContent || !nodeSchema) return [];\n\n while (!cursor.isEndOfDocument()) {\n const info = cursor.getCurrentParagraph();\n if (!info) {\n cursor.getNextParagraph();\n continue;\n }\n\n const { paragraph, style } = info;\n\n if (cursor.isAtNewSection()) break;\n if (cursor.isAtParagraphHeading() && style && !allNodeTitleStyles.has(style)) break;\n\n if (hasNamedStyle(paragraph, nodeSchema.title.namedStyleType)) {\n return parseTreeNode(cursor, nodeSchema, [], allNodeTitleStyles);\n }\n\n cursor.getNextParagraph();\n }\n return [];\n}\n\n/**\n * Recursively parses a specific level of the tree structure.\n *\n * Handles creation of current nodes, delegating to child parsers for nested content,\n * and accumulating list details.\n *\n * @param cursor - The cursor traversing the document paragraphs.\n * @param nodeSchema - The schema for the current node level.\n * @param ancestorNodeList - Stack of ancestors to detect hierarchy boundaries.\n * @param allNodeTitleStyles - Set of all valid styles for boundary checks.\n * @returns An array of parsed nodes for this level.\n */\nexport function parseTreeNode(\n cursor: ParagraphCursor,\n nodeSchema: Node,\n ancestorNodeList: Node[],\n allNodeTitleStyles: Set<NamedStyleType>\n): unknown[] {\n const result: unknown[] = [];\n let currentNode: Record<string, unknown> | null = null;\n\n const childNodeSchema =\n nodeSchema.content?.kind === \"tree\" ? nodeSchema.content.node : undefined;\n\n while (!cursor.isEndOfDocument()) {\n const info = cursor.getCurrentParagraph();\n if (!info) {\n cursor.getNextParagraph();\n continue;\n }\n\n const { text, paragraph, style } = info;\n\n if (cursor.isAtNewSection()) {\n return result;\n }\n\n if (cursor.isAtParagraphHeading() && style && !allNodeTitleStyles.has(style)) {\n return result;\n }\n\n const decision = determineTreeParsingAction(\n paragraph,\n cursor,\n nodeSchema,\n ancestorNodeList\n );\n\n switch (decision.kind) {\n case \"exitSection\": {\n return result;\n }\n\n case \"createNode\": {\n currentNode = createNodeFromTitle(text, nodeSchema.title);\n result.push(currentNode);\n cursor.getNextParagraph();\n break;\n }\n\n case \"startChildNode\": {\n if (\n !currentNode ||\n !Array.isArray(currentNode[CONTENT_KEY]) ||\n !childNodeSchema\n ) {\n cursor.getNextParagraph();\n break;\n }\n const children = parseTreeNode(\n cursor,\n childNodeSchema,\n [nodeSchema, ...ancestorNodeList],\n allNodeTitleStyles\n );\n (currentNode[CONTENT_KEY] as unknown[]).push(...children);\n break;\n }\n\n case \"finishCurrentNode\": {\n if (currentNode) return result;\n cursor.getNextParagraph();\n break;\n }\n\n case \"appendDetail\": {\n if (nodeSchema.content?.kind === \"tree\") {\n cursor.getNextParagraph();\n break;\n }\n if (currentNode && Array.isArray(currentNode[CONTENT_KEY])) {\n (currentNode[CONTENT_KEY] as unknown[]).push(text.trim());\n }\n cursor.getNextParagraph();\n break;\n }\n }\n }\n\n return result;\n}\n","import { Section } from \"./types\";\nimport { ParagraphCursor } from \"./cursor\";\nimport { parseStructuredText } from \"./utils\";\n\n/**\n * Parses a section defined as a 'List'.\n *\n * This function iterates through paragraphs, parsing each line according to the\n * section's content schema (e.g., delimiters, keys). It supports both flat lists\n * and nested structures depending on the `isFlatten` configuration.\n *\n * @param cursor - The cursor traversing the document paragraphs.\n * @param section - The section definition containing the list schema.\n * @returns An array of parsed items (strings, objects, or arrays).\n */\nexport function parseListSection(\n cursor: ParagraphCursor,\n section: Section\n): unknown[] {\n const result: unknown[] = [];\n if (!section.content || section.content.kind !== \"list\") {\n return [];\n }\n const contentSchema = section.content;\n\n while (!cursor.isEndOfDocument()) {\n const info = cursor.getCurrentParagraph();\n if (!info) {\n cursor.getNextParagraph();\n continue;\n }\n\n if (cursor.isAtNewSection()) break;\n if (cursor.isAtParagraphHeading()) break;\n\n const parsed = parseStructuredText(info.text, contentSchema);\n\n if (contentSchema.isFlatten && Array.isArray(parsed)) {\n result.push(...parsed);\n } else {\n result.push(parsed);\n }\n cursor.getNextParagraph();\n }\n return result;\n}\n","import { ParagraphCursor } from \"./cursor\";\n\n/**\n * Parses a continuous block of text paragraphs into a single string.\n *\n * This function iterates through paragraphs starting from the current cursor position\n * and collects text until a boundary is encountered.\n *\n * **Stop Conditions:**\n * 1. **New Section:** The cursor reaches a paragraph that marks the start of a new section defined in the schema.\n * 2. **Heading:** The cursor reaches any paragraph with a named heading style (e.g., HEADING_1, HEADING_2).\n *\n * @param cursor - The cursor traversing the document paragraphs.\n * @returns The combined text content of the block, joined by spaces.\n */\nexport function parseTextBlockSection(cursor: ParagraphCursor): string {\n const textPartList: string[] = [];\n\n while (!cursor.isEndOfDocument()) {\n const paragraph = cursor.getCurrentParagraph();\n if (!paragraph) {\n cursor.getNextParagraph();\n continue;\n }\n\n if (cursor.isAtNewSection()) break;\n if (cursor.isAtParagraphHeading()) break;\n\n textPartList.push(paragraph.text);\n cursor.getNextParagraph();\n }\n return textPartList.join(\" \");\n}\n","import type { docs_v1 } from \"googleapis\";\nimport { ParseSchema, Section, NamedStyleType } from \"./types\";\nimport { hasNamedStyle } from \"./utils\";\nimport { ParagraphCursor } from \"./cursor\";\nimport { parseTreeSection, collectNodeStylesRecursive } from \"./tree\";\nimport { parseListSection } from \"./list\";\nimport { parseTextBlockSection } from \"./textBlock\";\n\n/**\n * Identifies if a paragraph corresponds to a section title defined in the schema.\n *\n * Matching Logic:\n * 1. Matches the paragraph's named style (e.g., HEADING_2) with the section's style.\n * 2. Matches the text content (case-insensitive, trimmed).\n *\n * @param paragraph - The current paragraph being inspected.\n * @param text - The extracted text content of the paragraph.\n * @param parseSchema - The global parsing schema containing section definitions.\n * @returns The canonical name of the section if found, otherwise `null`.\n */\nexport function getSectionTitle(\n paragraph: docs_v1.Schema$Paragraph,\n text: string,\n parseSchema: ParseSchema\n): string | null {\n const normalized = text.trim().toLowerCase();\n const sectionList = parseSchema.sections ?? [];\n\n for (const section of sectionList) {\n const { name, namedStyleType } = section.title;\n if (name && namedStyleType) {\n const styleMatches = hasNamedStyle(paragraph, namedStyleType);\n const textMatches = normalized === name.trim().toLowerCase();\n if (styleMatches && textMatches) {\n return name;\n }\n }\n }\n return null;\n}\n\n/**\n * Dispatches the parsing logic to the appropriate handler based on the section's content type.\n *\n * - **Tree:** Delegates to `parseTreeSection` for hierarchical data.\n * - **List:** Delegates to `parseListSection` for flat lists.\n * - **TextBlock (Default):** Delegates to `parseTextBlockSection` if no content structure is defined.\n *\n * @param cursor - The paragraph cursor.\n * @param section - The section definition containing the content schema.\n * @returns The parsed result (String, Array, or Object depending on the type).\n */\nexport function parseSectionContent(\n cursor: ParagraphCursor,\n section: Section\n): unknown {\n const content = section.content;\n\n if (!content) {\n return parseTextBlockSection(cursor);\n }\n\n switch (content.kind) {\n case \"tree\": {\n if (!content.node) {\n return [];\n }\n const allNodeTitleStyles = new Set<NamedStyleType>();\n collectNodeStylesRecursive(content.node, allNodeTitleStyles);\n return parseTreeSection(cursor, section, allNodeTitleStyles);\n }\n case \"list\":\n return parseListSection(cursor, section);\n default:\n return parseTextBlockSection(cursor);\n }\n}\n","import type { docs_v1 } from \"googleapis\";\nimport { ParseSchema, NamedStyleType } from \"./types\";\nimport {\n getParagraphNamedStyleType,\n isNamedStyleType,\n extractParagraphText,\n} from \"./utils\";\nimport { getSectionTitle } from \"./section\";\n\n/**\n * Represents a processed paragraph with extracted text and normalized style.\n */\nexport interface Paragraph {\n text: string;\n style: NamedStyleType | \"NORMAL_TEXT\" | undefined;\n paragraph: docs_v1.Schema$Paragraph;\n}\n\n/**\n * Extracts and normalizes data from a raw Google Docs paragraph.\n *\n * @param paragraph - The raw paragraph object from the API.\n * @returns A `Paragraph` object if text exists, otherwise `null` (e.g., empty lines).\n */\nexport function getParagraph(\n paragraph: docs_v1.Schema$Paragraph\n): Paragraph | null {\n const text = extractParagraphText(paragraph);\n if (!text) return null;\n const style = getParagraphNamedStyleType(paragraph);\n return { text, style, paragraph };\n}\n\n/**\n * A stateful cursor for traversing a list of Google Docs paragraphs.\n *\n * It manages the current position (index) and provides methods to inspect\n * the current paragraph's context (e.g., style, section boundaries)\n * without manually handling array indices.\n */\nexport class ParagraphCursor {\n private index = 0;\n\n constructor(\n private paragraphList: docs_v1.Schema$Paragraph[],\n private parseSchema: ParseSchema\n ) {}\n\n /**\n * Retrieves the paragraph at the current cursor position.\n *\n * @returns The current `Paragraph` object, or `null` if the cursor is at the end of the document or the line is empty.\n */\n getCurrentParagraph(): Paragraph | null {\n if (this.isEndOfDocument()) return null;\n const paragraph = this.paragraphList[this.index];\n if (!paragraph) return null;\n return getParagraph(paragraph);\n }\n\n /**\n * Advances the cursor to the next position and returns the new paragraph.\n *\n * @returns The next `Paragraph` object, or `null` if the end of the document is reached.\n */\n getNextParagraph(): Paragraph | null {\n if (this.isEndOfDocument()) return null;\n this.index++;\n return this.getCurrentParagraph();\n }\n\n /**\n * Checks if the cursor has reached the end of the paragraph list.\n */\n isEndOfDocument(): boolean {\n return this.index >= this.paragraphList.length;\n }\n\n /**\n * Determines if the current paragraph corresponds to a section title defined in the schema.\n *\n * @returns The section name if matched, otherwise `null`.\n */\n getCurrentSectionTitle(): string | null {\n const info = this.getCurrentParagraph();\n if (!info) return null;\n return getSectionTitle(info.paragraph, info.text, this.parseSchema);\n }\n\n /**\n * Checks if the current cursor position marks the start of a new section.\n */\n isAtNewSection(): boolean {\n return this.getCurrentSectionTitle() !== null;\n }\n\n /**\n * Checks if the current paragraph has a named heading style (e.g., HEADING_1).\n */\n isAtParagraphHeading(): boolean {\n const info = this.getCurrentParagraph();\n return !!info && isNamedStyleType(info.style);\n }\n}\n","import type { ParseSchema, GetParsedType, ParsedDocument } from \"../types\";\nimport type { DocsDocument } from \"./types\";\nimport { getDocument } from \"./client\";\nimport { ParagraphCursor } from \"../cursor\";\nimport { parseSectionContent } from \"../section\";\n\n/**\n * Parses a DocsDocument (same logic as the original parseDocument).\n *\n * Uses DocsDocument type instead of googleapis' docs_v1.Schema$Document.\n */\nfunction parseDocument(\n doc: DocsDocument,\n parseSchema: ParseSchema\n): ParsedDocument {\n const content = doc.body?.content || [];\n const result: ParsedDocument = {};\n\n // Convert DocsDocument type to googleapis-compatible type\n const validParagraphList = content\n .map((element) => element.paragraph)\n .filter((paragraph): paragraph is NonNullable<typeof paragraph> => !!paragraph);\n\n const cursor = new ParagraphCursor(validParagraphList as any, parseSchema);\n\n while (!cursor.isEndOfDocument()) {\n const currentSectionTitle = cursor.getCurrentSectionTitle();\n if (currentSectionTitle) {\n const section = parseSchema.sections.find(\n (s) => s.title.name === currentSectionTitle\n );\n if (section) {\n cursor.getNextParagraph();\n const parsedData = parseSectionContent(cursor, section);\n result[currentSectionTitle] = parsedData;\n continue;\n }\n }\n cursor.getNextParagraph();\n }\n\n return result;\n}\n\n/**\n * getParsedDocument for Edge Runtime.\n *\n * Compatible with Cloudflare Workers, Vercel Edge Functions, etc.\n *\n * @example\n * ```typescript\n * // Cloudflare Workers\n * import { getParsedDocument } from '@yuji-min/google-docs-parser/edge'\n *\n * export default {\n * async fetch(request, env) {\n * process.env.GOOGLE_APPLICATION_CREDENTIALS = env.GOOGLE_CREDENTIALS\n * const data = await getParsedDocument('doc-id', schema)\n * return Response.json(data)\n * }\n * }\n * ```\n */\nexport async function getParsedDocument<T extends ParseSchema>(\n documentId: string,\n parseSchema: T\n): Promise<GetParsedType<T>> {\n try {\n const doc = await getDocument(documentId);\n const parsedDocument = parseDocument(doc, parseSchema);\n return parsedDocument as GetParsedType<T>;\n } catch (e) {\n throw new Error(\n `Google Docs API call failed. Check Doc ID and Service Account permissions. Original error: ${\n e instanceof Error ? e.message : String(e)\n }`\n );\n }\n}\n\n// Export types for Edge\nexport type { ServiceAccountCredentials, DocsDocument } from \"./types\";\n"]}
@@ -0,0 +1,75 @@
1
+ import { P as ParseSchema, G as GetParsedType } from './types-BCn4M8Us.cjs';
2
+
3
+ /**
4
+ * Type definitions for Google Docs API in Edge Runtime.
5
+ * Can be used without the googleapis package.
6
+ */
7
+ /**
8
+ * Service Account credentials.
9
+ */
10
+ interface ServiceAccountCredentials {
11
+ type: string;
12
+ project_id: string;
13
+ private_key_id: string;
14
+ private_key: string;
15
+ client_email: string;
16
+ client_id: string;
17
+ auth_uri: string;
18
+ token_uri: string;
19
+ auth_provider_x509_cert_url: string;
20
+ client_x509_cert_url: string;
21
+ }
22
+ /**
23
+ * Google Docs API response type.
24
+ * Compatible with googleapis' docs_v1.Schema$Document.
25
+ */
26
+ interface DocsDocument {
27
+ documentId?: string;
28
+ title?: string;
29
+ body?: {
30
+ content?: Array<{
31
+ paragraph?: {
32
+ elements?: Array<{
33
+ textRun?: {
34
+ content?: string;
35
+ textStyle?: unknown;
36
+ };
37
+ }>;
38
+ paragraphStyle?: {
39
+ namedStyleType?: string;
40
+ [key: string]: unknown;
41
+ };
42
+ bullet?: {
43
+ listId?: string;
44
+ nestingLevel?: number;
45
+ };
46
+ [key: string]: unknown;
47
+ };
48
+ [key: string]: unknown;
49
+ }>;
50
+ };
51
+ [key: string]: unknown;
52
+ }
53
+
54
+ /**
55
+ * getParsedDocument for Edge Runtime.
56
+ *
57
+ * Compatible with Cloudflare Workers, Vercel Edge Functions, etc.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Cloudflare Workers
62
+ * import { getParsedDocument } from '@yuji-min/google-docs-parser/edge'
63
+ *
64
+ * export default {
65
+ * async fetch(request, env) {
66
+ * process.env.GOOGLE_APPLICATION_CREDENTIALS = env.GOOGLE_CREDENTIALS
67
+ * const data = await getParsedDocument('doc-id', schema)
68
+ * return Response.json(data)
69
+ * }
70
+ * }
71
+ * ```
72
+ */
73
+ declare function getParsedDocument<T extends ParseSchema>(documentId: string, parseSchema: T): Promise<GetParsedType<T>>;
74
+
75
+ export { type DocsDocument, type ServiceAccountCredentials, getParsedDocument };
package/dist/edge.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import { P as ParseSchema, G as GetParsedType } from './types-BCn4M8Us.js';
2
+
3
+ /**
4
+ * Type definitions for Google Docs API in Edge Runtime.
5
+ * Can be used without the googleapis package.
6
+ */
7
+ /**
8
+ * Service Account credentials.
9
+ */
10
+ interface ServiceAccountCredentials {
11
+ type: string;
12
+ project_id: string;
13
+ private_key_id: string;
14
+ private_key: string;
15
+ client_email: string;
16
+ client_id: string;
17
+ auth_uri: string;
18
+ token_uri: string;
19
+ auth_provider_x509_cert_url: string;
20
+ client_x509_cert_url: string;
21
+ }
22
+ /**
23
+ * Google Docs API response type.
24
+ * Compatible with googleapis' docs_v1.Schema$Document.
25
+ */
26
+ interface DocsDocument {
27
+ documentId?: string;
28
+ title?: string;
29
+ body?: {
30
+ content?: Array<{
31
+ paragraph?: {
32
+ elements?: Array<{
33
+ textRun?: {
34
+ content?: string;
35
+ textStyle?: unknown;
36
+ };
37
+ }>;
38
+ paragraphStyle?: {
39
+ namedStyleType?: string;
40
+ [key: string]: unknown;
41
+ };
42
+ bullet?: {
43
+ listId?: string;
44
+ nestingLevel?: number;
45
+ };
46
+ [key: string]: unknown;
47
+ };
48
+ [key: string]: unknown;
49
+ }>;
50
+ };
51
+ [key: string]: unknown;
52
+ }
53
+
54
+ /**
55
+ * getParsedDocument for Edge Runtime.
56
+ *
57
+ * Compatible with Cloudflare Workers, Vercel Edge Functions, etc.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Cloudflare Workers
62
+ * import { getParsedDocument } from '@yuji-min/google-docs-parser/edge'
63
+ *
64
+ * export default {
65
+ * async fetch(request, env) {
66
+ * process.env.GOOGLE_APPLICATION_CREDENTIALS = env.GOOGLE_CREDENTIALS
67
+ * const data = await getParsedDocument('doc-id', schema)
68
+ * return Response.json(data)
69
+ * }
70
+ * }
71
+ * ```
72
+ */
73
+ declare function getParsedDocument<T extends ParseSchema>(documentId: string, parseSchema: T): Promise<GetParsedType<T>>;
74
+
75
+ export { type DocsDocument, type ServiceAccountCredentials, getParsedDocument };