@tailor-platform/sdk 1.50.1 → 1.51.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/CHANGELOG.md +60 -0
- package/README.md +1 -0
- package/agent-skills/tailor-sdk/SKILL.md +2 -0
- package/dist/{actor-BeIEiPYM.d.mts → actor-Nag62ZDM.d.mts} +2 -3
- package/dist/application-Bcx-FbDE.mjs +4 -0
- package/dist/{application-CZMzt9jL.mjs → application-Z-fNwyZB.mjs} +50 -14
- package/dist/application-Z-fNwyZB.mjs.map +1 -0
- package/dist/authconnection-BDFTabLQ.d.mts +39 -0
- package/dist/authconnection-BUko4V6H.mjs +16 -0
- package/dist/authconnection-BUko4V6H.mjs.map +1 -0
- package/dist/{brand-D-d15jx3.mjs → brand-Ll48SMXe.mjs} +1 -1
- package/dist/{brand-D-d15jx3.mjs.map → brand-Ll48SMXe.mjs.map} +1 -1
- package/dist/chunk-DLeslSnM.mjs +21 -0
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +16 -16
- package/dist/cli/lib.d.mts +6 -7
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/skills.d.mts +0 -1
- package/dist/cli/skills.mjs +1 -1
- package/dist/{client-_kHh0Pip.mjs → client-BwV17byk.mjs} +4 -4
- package/dist/{client-_kHh0Pip.mjs.map → client-BwV17byk.mjs.map} +1 -1
- package/dist/{client-CPW1N1Rs.mjs → client-D_a50aIg.mjs} +1 -1
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs +4 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/context-BP5BUdcq.mjs +25 -0
- package/dist/context-BP5BUdcq.mjs.map +1 -0
- package/dist/context-BXDgEQK9.d.mts +68 -0
- package/dist/{crashreport-DHJuSmUc.mjs → crashreport-C4EbRoku.mjs} +1 -1
- package/dist/{crashreport-CvmdFs4i.mjs → crashreport-DauPOrKn.mjs} +5 -5
- package/dist/{crashreport-CvmdFs4i.mjs.map → crashreport-DauPOrKn.mjs.map} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs → enum-constants-DI85-fPE.mjs} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs.map → enum-constants-DI85-fPE.mjs.map} +1 -1
- package/dist/{errors-pMPXghkO.mjs → errors-C4cJ0M2K.mjs} +1 -1
- package/dist/{errors-pMPXghkO.mjs.map → errors-C4cJ0M2K.mjs.map} +1 -1
- package/dist/{field-DLSIuMTu.mjs → field-BY2vbJ8f.mjs} +1 -1
- package/dist/{field-DLSIuMTu.mjs.map → field-BY2vbJ8f.mjs.map} +1 -1
- package/dist/file-BE5Sy7lP.mjs +54 -0
- package/dist/file-BE5Sy7lP.mjs.map +1 -0
- package/dist/file-Dc4_QrlQ.d.mts +206 -0
- package/dist/{file-utils-DjNi_3U_.mjs → file-utils-BM8t5jCy.mjs} +20 -10
- package/dist/file-utils-BM8t5jCy.mjs.map +1 -0
- package/dist/iconv-BFNfdlIS.d.mts +122 -0
- package/dist/iconv-D0yL88Il.mjs +64 -0
- package/dist/iconv-D0yL88Il.mjs.map +1 -0
- package/dist/idp-B1b4O7ia.d.mts +161 -0
- package/dist/idp-CM7N7iID.mjs +76 -0
- package/dist/idp-CM7N7iID.mjs.map +1 -0
- package/dist/{index-C--7W0UO.d.mts → index-BD99GoHO.d.mts} +4 -5
- package/dist/{index-nV4ZC_Ve.d.mts → index-BXwAT_oE.d.mts} +2 -3
- package/dist/{index-BQ4oi0AI.d.mts → index-CYAZkd4b.d.mts} +2 -3
- package/dist/{index-BjXN1SdY.d.mts → index-CfSjuxzK.d.mts} +2 -3
- package/dist/index-Dy3ZH5Wm.d.mts +46 -0
- package/dist/{index-VJW98BSy.d.mts → index-aiIbrFGw.d.mts} +2 -3
- package/dist/{interceptor-DTNS0EtF.mjs → interceptor-Cr3kZWMc.mjs} +1 -1
- package/dist/{interceptor-DTNS0EtF.mjs.map → interceptor-Cr3kZWMc.mjs.map} +1 -1
- package/dist/{job-M3Avv_SV.mjs → job-4GOnasfT.mjs} +2 -2
- package/dist/{job-M3Avv_SV.mjs.map → job-4GOnasfT.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +0 -1
- package/dist/{kysely-type-B8aRz_oC.mjs → kysely-type-BUoVDC5r.mjs} +2 -2
- package/dist/{kysely-type-B8aRz_oC.mjs.map → kysely-type-BUoVDC5r.mjs.map} +1 -1
- package/dist/{logger-DTNAMYGy.mjs → logger-B1g4I9wT.mjs} +1 -1
- package/dist/{logger-DTNAMYGy.mjs.map → logger-B1g4I9wT.mjs.map} +1 -1
- package/dist/{mock-BfL09ULZ.mjs → mock-B2t5gDMl.mjs} +11 -5
- package/dist/mock-B2t5gDMl.mjs.map +1 -0
- package/dist/{multiline-e3IpANmS.mjs → multiline-G1yF18OH.mjs} +1 -1
- package/dist/{multiline-e3IpANmS.mjs.map → multiline-G1yF18OH.mjs.map} +1 -1
- package/dist/package-json-CAGKAJff.mjs +4 -0
- package/dist/{package-json-6Px8bDpG.mjs → package-json-ZL0MkZOO.mjs} +1 -1
- package/dist/{package-json-6Px8bDpG.mjs.map → package-json-ZL0MkZOO.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -2
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -2
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -2
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -3
- package/dist/{repl-editor-jZ493eQI.mjs → repl-editor-yAjwS5_M.mjs} +1 -1
- package/dist/{repl-editor-jZ493eQI.mjs.map → repl-editor-yAjwS5_M.mjs.map} +1 -1
- package/dist/runtime/authconnection.d.mts +2 -0
- package/dist/runtime/authconnection.mjs +4 -0
- package/dist/runtime/context.d.mts +2 -0
- package/dist/runtime/context.mjs +4 -0
- package/dist/runtime/file.d.mts +2 -0
- package/dist/runtime/file.mjs +4 -0
- package/dist/runtime/globals.d.mts +103 -0
- package/dist/runtime/globals.mjs +2 -0
- package/dist/runtime/iconv.d.mts +2 -0
- package/dist/runtime/iconv.mjs +4 -0
- package/dist/runtime/idp.d.mts +2 -0
- package/dist/runtime/idp.mjs +4 -0
- package/dist/runtime/index.d.mts +9 -0
- package/dist/runtime/index.mjs +10 -0
- package/dist/runtime/secretmanager.d.mts +2 -0
- package/dist/runtime/secretmanager.mjs +4 -0
- package/dist/runtime/workflow.d.mts +2 -0
- package/dist/runtime/workflow.mjs +4 -0
- package/dist/{runtime-DgsMnMrO.mjs → runtime-CyX4zeod.mjs} +55 -32
- package/dist/runtime-CyX4zeod.mjs.map +1 -0
- package/dist/{schema-C5QjYEc-.mjs → schema-DBq6hr6h.mjs} +3 -3
- package/dist/{schema-C5QjYEc-.mjs.map → schema-DBq6hr6h.mjs.map} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs → secret-file-DnbmTWec.mjs} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs.map → secret-file-DnbmTWec.mjs.map} +1 -1
- package/dist/secretmanager-CQTTuCmn.mjs +25 -0
- package/dist/secretmanager-CQTTuCmn.mjs.map +1 -0
- package/dist/secretmanager-Cjq3s2aU.d.mts +55 -0
- package/dist/seed/index.d.mts +0 -1
- package/dist/{seed-DjfAn0BC.mjs → seed-kNk-xLoB.mjs} +7 -2
- package/dist/{seed-DjfAn0BC.mjs.map → seed-kNk-xLoB.mjs.map} +1 -1
- package/dist/{service-DCgJxdg1.mjs → service-DHgJ4YEF.mjs} +3 -3
- package/dist/{service-DCgJxdg1.mjs.map → service-DHgJ4YEF.mjs.map} +1 -1
- package/dist/{tailor-db-field-4bMLe25-.d.mts → tailor-db-field-BhWvOyky.d.mts} +1 -2
- package/dist/{telemetry-C1Y56L5E.mjs → telemetry-C8xKz3GM.mjs} +2 -2
- package/dist/{telemetry-C1Y56L5E.mjs.map → telemetry-C8xKz3GM.mjs.map} +1 -1
- package/dist/telemetry-DQl47E1s.mjs +4 -0
- package/dist/types-BnphjkIJ.mjs +5 -0
- package/dist/{types-sir9UPht.mjs → types-Duhhsx3R.mjs} +2 -2
- package/dist/{types-sir9UPht.mjs.map → types-Duhhsx3R.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +3 -4
- package/dist/utils/test/index.mjs +1 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.d.mts +0 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +2 -3
- package/dist/vitest/index.mjs +3 -3
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.d.mts +0 -1
- package/dist/vitest/setup.mjs +1 -1
- package/dist/workflow-DJRr-0nl.mjs +39 -0
- package/dist/workflow-DJRr-0nl.mjs.map +1 -0
- package/dist/workflow-DV_88JEf.d.mts +96 -0
- package/dist/{workflow.generated-OYAu_6zX.d.mts → workflow.generated-DV87DJfO.d.mts} +2 -3
- package/docs/cli/application.md +1 -1
- package/docs/cli/tailordb.md +9 -8
- package/docs/cli-reference.md +17 -16
- package/docs/configuration.md +1 -0
- package/docs/generator/builtin.md +2 -0
- package/docs/runtime.md +113 -0
- package/docs/testing.md +21 -0
- package/package.json +53 -9
- package/dist/application-CZMzt9jL.mjs.map +0 -1
- package/dist/application-v_E2W-Fz.mjs +0 -4
- package/dist/file-utils-DjNi_3U_.mjs.map +0 -1
- package/dist/mock-BfL09ULZ.mjs.map +0 -1
- package/dist/package-json-7sRXVndJ.mjs +0 -4
- package/dist/runtime-DgsMnMrO.mjs.map +0 -1
- package/dist/telemetry-C13VIFpT.mjs +0 -4
- package/dist/types-DoIG6Nij.mjs +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repl-editor-jZ493eQI.mjs","names":[],"sources":["../src/cli/query/repl-editor.ts"],"sourcesContent":["import { GraphQLError, Lexer, Source, TokenKind } from \"graphql\";\nimport { getSegments } from \"sql-highlight\";\nimport type { TransformEvent, TransformState } from \"@toiroakr/read-multiline\";\n\n// ANSI colour sequences. Kept inline (rather than going through `node:util`\n// styleText) so that tests running outside a TTY still produce deterministic\n// escape sequences regardless of detected colour support.\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst MAGENTA = \"\\x1b[35m\";\nconst YELLOW = \"\\x1b[33m\";\nconst BRIGHT_GREEN = \"\\x1b[92m\";\nconst CYAN = \"\\x1b[36m\";\nconst BRIGHT_BLUE = \"\\x1b[94m\";\nconst BOLD_CYAN = \"\\x1b[1;36m\";\nconst BOLD_MAGENTA = \"\\x1b[1;35m\";\nconst ITALIC_YELLOW = \"\\x1b[3;33m\";\nconst GREEN = \"\\x1b[32m\";\nconst DIM = \"\\x1b[90m\";\nconst DIM_YELLOW = \"\\x1b[2;33m\";\n\nconst SQL_STYLE_MAP: Record<string, string> = {\n keyword: BLUE,\n function: MAGENTA,\n identifier: YELLOW,\n string: BRIGHT_GREEN,\n number: CYAN,\n bracket: DIM_YELLOW,\n special: DIM,\n};\n\n/**\n * Highlight a single SQL line using the `sql-highlight` tokenizer.\n * @param line - SQL text for a single editor line\n * @returns ANSI-decorated line safe for terminal output\n */\nexport function highlightSqlLine(line: string): string {\n const segments = getSegments(line);\n let result = \"\";\n for (const seg of segments) {\n const style = SQL_STYLE_MAP[seg.name];\n result += style ? style + seg.content + RESET : seg.content;\n }\n return result;\n}\n\nconst GQL_KEYWORDS = new Set([\n \"query\",\n \"mutation\",\n \"subscription\",\n \"fragment\",\n \"on\",\n \"type\",\n \"input\",\n \"enum\",\n \"interface\",\n \"union\",\n \"scalar\",\n \"extend\",\n \"schema\",\n \"directive\",\n \"implements\",\n]);\n\n// Keywords that introduce a definition name (next NAME token is the def).\nconst GQL_DEF_KEYWORDS = new Set([\"query\", \"mutation\", \"subscription\", \"fragment\"]);\n\nconst GQL_BUILTINS = new Set([\"true\", \"false\", \"null\"]);\n\n/**\n * Highlight a single GraphQL line using the official `graphql` Lexer. Tracks\n * paren depth and the previous token to provide semantic-level colouring\n * (field names vs argument names vs types).\n * @param line - GraphQL text for a single editor line\n * @returns ANSI-decorated line, or the input unchanged when the lexer rejects it\n */\nexport function highlightGraphqlLine(line: string): string {\n if (line.trimStart().startsWith(\"#\")) {\n return `${DIM}${line}${RESET}`;\n }\n\n try {\n const source = new Source(line);\n const lexer = new Lexer(source);\n let result = \"\";\n let pos = 0;\n\n let parenDepth = 0;\n let prevKind: string = \"\";\n let prevText = \"\";\n let afterColon = false;\n\n let token = lexer.advance();\n while (token.kind !== TokenKind.EOF) {\n if (token.start > pos) {\n result += line.slice(pos, token.start);\n }\n\n const text = line.slice(token.start, token.end);\n switch (token.kind) {\n case TokenKind.NAME: {\n if (prevKind === TokenKind.DOLLAR) {\n result += `${MAGENTA}${text}${RESET}`;\n } else if (prevKind === TokenKind.AT) {\n result += `${BOLD_MAGENTA}${text}${RESET}`;\n } else if (GQL_BUILTINS.has(text) || GQL_KEYWORDS.has(text)) {\n result += `${BLUE}${text}${RESET}`;\n } else if (GQL_DEF_KEYWORDS.has(prevText)) {\n result += `${BOLD_CYAN}${text}${RESET}`;\n } else if (afterColon) {\n result += `${CYAN}${text}${RESET}`;\n } else if (parenDepth > 0) {\n result += `${ITALIC_YELLOW}${text}${RESET}`;\n } else {\n result += `${BRIGHT_BLUE}${text}${RESET}`;\n }\n afterColon = false;\n break;\n }\n case TokenKind.INT:\n case TokenKind.FLOAT:\n result += `${BLUE}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n result += `${GREEN}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.DOLLAR:\n result += `${MAGENTA}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.AT:\n result += `${BOLD_MAGENTA}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.BRACE_L:\n case TokenKind.BRACE_R:\n result += `${YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.PAREN_L:\n parenDepth += 1;\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.PAREN_R:\n parenDepth = Math.max(0, parenDepth - 1);\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.BRACKET_L:\n case TokenKind.BRACKET_R:\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.COLON:\n result += `${DIM}${text}${RESET}`;\n afterColon = true;\n break;\n case TokenKind.BANG:\n case TokenKind.EQUALS:\n case TokenKind.PIPE:\n case TokenKind.AMP:\n case TokenKind.SPREAD:\n result += `${DIM}${text}${RESET}`;\n afterColon = false;\n break;\n default:\n result += text;\n afterColon = false;\n }\n\n prevKind = token.kind;\n prevText = text;\n pos = token.end;\n token = lexer.advance();\n }\n\n if (pos < line.length) {\n result += line.slice(pos);\n }\n return result;\n } catch (error) {\n // The lexer throws GraphQLError on partial or invalid input (e.g. an\n // unterminated string while the user is still typing). Fall back to the\n // raw line so the editor keeps rendering without colour until the input\n // is valid. Any other error is a real bug and should surface.\n if (error instanceof GraphQLError) {\n return line;\n }\n throw error;\n }\n}\n\nconst BRACKET_PAIRS: Record<string, string> = { \"(\": \")\", \"[\": \"]\", \"{\": \"}\" };\nconst CLOSE_BRACKETS = new Set(Object.values(BRACKET_PAIRS));\n\n/**\n * Apply auto-close brackets and auto-indent on newline. Works for both SQL\n * and GraphQL because both languages share the `()`, `[]`, `{}` bracket set.\n * @param state - Editor state after the last edit\n * @param event - Event describing the edit that just occurred\n * @returns A new editor state to apply, or `undefined` to leave the state unchanged\n */\nexport function replTransform(\n state: TransformState,\n event: TransformEvent,\n): TransformState | undefined {\n const { lines, row, col } = state;\n\n if (event.type === \"insert\" && event.char in BRACKET_PAIRS) {\n const close = BRACKET_PAIRS[event.char];\n const line = lines[row];\n const newLine = line.slice(0, col) + close + line.slice(col);\n return { lines: lines.with(row, newLine), row, col };\n }\n\n if (event.type === \"insert\" && CLOSE_BRACKETS.has(event.char)) {\n const line = lines[row];\n if (line[col] === event.char) {\n const newLine = line.slice(0, col) + line.slice(col + 1);\n return { lines: lines.with(row, newLine), row, col };\n }\n }\n\n if (event.type === \"backspace\") {\n const line = lines[row];\n const beforeCursor = line.slice(0, col);\n if (beforeCursor.length >= 1 && /^ +$/.test(beforeCursor)) {\n const newIndent = beforeCursor.slice(0, -1);\n const newLine = newIndent + line.slice(col);\n return { lines: lines.with(row, newLine), row, col: newIndent.length };\n }\n }\n\n if (event.type === \"newline\" && row > 0) {\n const prevLine = lines[row - 1];\n const baseIndent = prevLine.match(/^(\\s*)/)?.[1] ?? \"\";\n const endsWithOpen = /[{([]$/.test(prevLine.trimEnd());\n const startsWithClose = /^[}\\])]/.test(lines[row].trimStart());\n\n if (endsWithOpen && startsWithClose) {\n // Bracket expansion: the cursor sits between a matching open/close\n // pair (e.g. `{|}`). Expand into a three-line block with the cursor\n // on an indented middle line.\n const innerIndent = baseIndent + \" \";\n const newLines = [...lines];\n newLines[row] = innerIndent;\n newLines.splice(row + 1, 0, baseIndent + lines[row].trimStart());\n return { lines: newLines, row, col: innerIndent.length };\n }\n if (endsWithOpen) {\n // A lone open bracket on the previous line: drop an extra indent for\n // the new line and auto-insert the matching closing bracket below.\n const openChar = prevLine.trimEnd().slice(-1);\n const closeChar = BRACKET_PAIRS[openChar] ?? \"}\";\n const indent = baseIndent + \" \";\n const newLines = [...lines];\n newLines[row] = indent + lines[row];\n newLines.splice(row + 1, 0, baseIndent + closeChar);\n return { lines: newLines, row, col: indent.length };\n }\n if (baseIndent && col === 0) {\n return { lines: lines.with(row, baseIndent + lines[row]), row, col: baseIndent.length };\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;AAOA,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAM,eAAe;AACrB,MAAM,OAAO;AACb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;IAAG;IAAK,KAAK,UAAU;GAAO;EACvE;CACF;CAEA,IAAI,MAAM,SAAS,aAAa,MAAM,GAAG;EACvC,MAAM,WAAW,MAAM,MAAM;EAC7B,MAAM,aAAa,SAAS,MAAM,QAAQ,IAAI,MAAM;EACpD,MAAM,eAAe,SAAS,KAAK,SAAS,QAAQ,CAAC;EACrD,MAAM,kBAAkB,UAAU,KAAK,MAAM,KAAK,UAAU,CAAC;EAE7D,IAAI,gBAAgB,iBAAiB;GAInC,MAAM,cAAc,aAAa;GACjC,MAAM,WAAW,CAAC,GAAG,KAAK;GAC1B,SAAS,OAAO;GAChB,SAAS,OAAO,MAAM,GAAG,GAAG,aAAa,MAAM,KAAK,UAAU,CAAC;GAC/D,OAAO;IAAE,OAAO;IAAU;IAAK,KAAK,YAAY;GAAO;EACzD;EACA,IAAI,cAAc;GAIhB,MAAM,YAAY,cADD,SAAS,QAAQ,EAAE,MAAM,EACH,MAAM;GAC7C,MAAM,SAAS,aAAa;GAC5B,MAAM,WAAW,CAAC,GAAG,KAAK;GAC1B,SAAS,OAAO,SAAS,MAAM;GAC/B,SAAS,OAAO,MAAM,GAAG,GAAG,aAAa,SAAS;GAClD,OAAO;IAAE,OAAO;IAAU;IAAK,KAAK,OAAO;GAAO;EACpD;EACA,IAAI,cAAc,QAAQ,GACxB,OAAO;GAAE,OAAO,MAAM,KAAK,KAAK,aAAa,MAAM,IAAI;GAAG;GAAK,KAAK,WAAW;EAAO;CAE1F;AAGF"}
|
|
1
|
+
{"version":3,"file":"repl-editor-yAjwS5_M.mjs","names":[],"sources":["../src/cli/query/repl-editor.ts"],"sourcesContent":["import { GraphQLError, Lexer, Source, TokenKind } from \"graphql\";\nimport { getSegments } from \"sql-highlight\";\nimport type { TransformEvent, TransformState } from \"@toiroakr/read-multiline\";\n\n// ANSI colour sequences. Kept inline (rather than going through `node:util`\n// styleText) so that tests running outside a TTY still produce deterministic\n// escape sequences regardless of detected colour support.\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst MAGENTA = \"\\x1b[35m\";\nconst YELLOW = \"\\x1b[33m\";\nconst BRIGHT_GREEN = \"\\x1b[92m\";\nconst CYAN = \"\\x1b[36m\";\nconst BRIGHT_BLUE = \"\\x1b[94m\";\nconst BOLD_CYAN = \"\\x1b[1;36m\";\nconst BOLD_MAGENTA = \"\\x1b[1;35m\";\nconst ITALIC_YELLOW = \"\\x1b[3;33m\";\nconst GREEN = \"\\x1b[32m\";\nconst DIM = \"\\x1b[90m\";\nconst DIM_YELLOW = \"\\x1b[2;33m\";\n\nconst SQL_STYLE_MAP: Record<string, string> = {\n keyword: BLUE,\n function: MAGENTA,\n identifier: YELLOW,\n string: BRIGHT_GREEN,\n number: CYAN,\n bracket: DIM_YELLOW,\n special: DIM,\n};\n\n/**\n * Highlight a single SQL line using the `sql-highlight` tokenizer.\n * @param line - SQL text for a single editor line\n * @returns ANSI-decorated line safe for terminal output\n */\nexport function highlightSqlLine(line: string): string {\n const segments = getSegments(line);\n let result = \"\";\n for (const seg of segments) {\n const style = SQL_STYLE_MAP[seg.name];\n result += style ? style + seg.content + RESET : seg.content;\n }\n return result;\n}\n\nconst GQL_KEYWORDS = new Set([\n \"query\",\n \"mutation\",\n \"subscription\",\n \"fragment\",\n \"on\",\n \"type\",\n \"input\",\n \"enum\",\n \"interface\",\n \"union\",\n \"scalar\",\n \"extend\",\n \"schema\",\n \"directive\",\n \"implements\",\n]);\n\n// Keywords that introduce a definition name (next NAME token is the def).\nconst GQL_DEF_KEYWORDS = new Set([\"query\", \"mutation\", \"subscription\", \"fragment\"]);\n\nconst GQL_BUILTINS = new Set([\"true\", \"false\", \"null\"]);\n\n/**\n * Highlight a single GraphQL line using the official `graphql` Lexer. Tracks\n * paren depth and the previous token to provide semantic-level colouring\n * (field names vs argument names vs types).\n * @param line - GraphQL text for a single editor line\n * @returns ANSI-decorated line, or the input unchanged when the lexer rejects it\n */\nexport function highlightGraphqlLine(line: string): string {\n if (line.trimStart().startsWith(\"#\")) {\n return `${DIM}${line}${RESET}`;\n }\n\n try {\n const source = new Source(line);\n const lexer = new Lexer(source);\n let result = \"\";\n let pos = 0;\n\n let parenDepth = 0;\n let prevKind: string = \"\";\n let prevText = \"\";\n let afterColon = false;\n\n let token = lexer.advance();\n while (token.kind !== TokenKind.EOF) {\n if (token.start > pos) {\n result += line.slice(pos, token.start);\n }\n\n const text = line.slice(token.start, token.end);\n switch (token.kind) {\n case TokenKind.NAME: {\n if (prevKind === TokenKind.DOLLAR) {\n result += `${MAGENTA}${text}${RESET}`;\n } else if (prevKind === TokenKind.AT) {\n result += `${BOLD_MAGENTA}${text}${RESET}`;\n } else if (GQL_BUILTINS.has(text) || GQL_KEYWORDS.has(text)) {\n result += `${BLUE}${text}${RESET}`;\n } else if (GQL_DEF_KEYWORDS.has(prevText)) {\n result += `${BOLD_CYAN}${text}${RESET}`;\n } else if (afterColon) {\n result += `${CYAN}${text}${RESET}`;\n } else if (parenDepth > 0) {\n result += `${ITALIC_YELLOW}${text}${RESET}`;\n } else {\n result += `${BRIGHT_BLUE}${text}${RESET}`;\n }\n afterColon = false;\n break;\n }\n case TokenKind.INT:\n case TokenKind.FLOAT:\n result += `${BLUE}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n result += `${GREEN}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.DOLLAR:\n result += `${MAGENTA}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.AT:\n result += `${BOLD_MAGENTA}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.BRACE_L:\n case TokenKind.BRACE_R:\n result += `${YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.PAREN_L:\n parenDepth += 1;\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.PAREN_R:\n parenDepth = Math.max(0, parenDepth - 1);\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.BRACKET_L:\n case TokenKind.BRACKET_R:\n result += `${DIM_YELLOW}${text}${RESET}`;\n afterColon = false;\n break;\n case TokenKind.COLON:\n result += `${DIM}${text}${RESET}`;\n afterColon = true;\n break;\n case TokenKind.BANG:\n case TokenKind.EQUALS:\n case TokenKind.PIPE:\n case TokenKind.AMP:\n case TokenKind.SPREAD:\n result += `${DIM}${text}${RESET}`;\n afterColon = false;\n break;\n default:\n result += text;\n afterColon = false;\n }\n\n prevKind = token.kind;\n prevText = text;\n pos = token.end;\n token = lexer.advance();\n }\n\n if (pos < line.length) {\n result += line.slice(pos);\n }\n return result;\n } catch (error) {\n // The lexer throws GraphQLError on partial or invalid input (e.g. an\n // unterminated string while the user is still typing). Fall back to the\n // raw line so the editor keeps rendering without colour until the input\n // is valid. Any other error is a real bug and should surface.\n if (error instanceof GraphQLError) {\n return line;\n }\n throw error;\n }\n}\n\nconst BRACKET_PAIRS: Record<string, string> = { \"(\": \")\", \"[\": \"]\", \"{\": \"}\" };\nconst CLOSE_BRACKETS = new Set(Object.values(BRACKET_PAIRS));\n\n/**\n * Apply auto-close brackets and auto-indent on newline. Works for both SQL\n * and GraphQL because both languages share the `()`, `[]`, `{}` bracket set.\n * @param state - Editor state after the last edit\n * @param event - Event describing the edit that just occurred\n * @returns A new editor state to apply, or `undefined` to leave the state unchanged\n */\nexport function replTransform(\n state: TransformState,\n event: TransformEvent,\n): TransformState | undefined {\n const { lines, row, col } = state;\n\n if (event.type === \"insert\" && event.char in BRACKET_PAIRS) {\n const close = BRACKET_PAIRS[event.char];\n const line = lines[row];\n const newLine = line.slice(0, col) + close + line.slice(col);\n return { lines: lines.with(row, newLine), row, col };\n }\n\n if (event.type === \"insert\" && CLOSE_BRACKETS.has(event.char)) {\n const line = lines[row];\n if (line[col] === event.char) {\n const newLine = line.slice(0, col) + line.slice(col + 1);\n return { lines: lines.with(row, newLine), row, col };\n }\n }\n\n if (event.type === \"backspace\") {\n const line = lines[row];\n const beforeCursor = line.slice(0, col);\n if (beforeCursor.length >= 1 && /^ +$/.test(beforeCursor)) {\n const newIndent = beforeCursor.slice(0, -1);\n const newLine = newIndent + line.slice(col);\n return { lines: lines.with(row, newLine), row, col: newIndent.length };\n }\n }\n\n if (event.type === \"newline\" && row > 0) {\n const prevLine = lines[row - 1];\n const baseIndent = prevLine.match(/^(\\s*)/)?.[1] ?? \"\";\n const endsWithOpen = /[{([]$/.test(prevLine.trimEnd());\n const startsWithClose = /^[}\\])]/.test(lines[row].trimStart());\n\n if (endsWithOpen && startsWithClose) {\n // Bracket expansion: the cursor sits between a matching open/close\n // pair (e.g. `{|}`). Expand into a three-line block with the cursor\n // on an indented middle line.\n const innerIndent = baseIndent + \" \";\n const newLines = [...lines];\n newLines[row] = innerIndent;\n newLines.splice(row + 1, 0, baseIndent + lines[row].trimStart());\n return { lines: newLines, row, col: innerIndent.length };\n }\n if (endsWithOpen) {\n // A lone open bracket on the previous line: drop an extra indent for\n // the new line and auto-insert the matching closing bracket below.\n const openChar = prevLine.trimEnd().slice(-1);\n const closeChar = BRACKET_PAIRS[openChar] ?? \"}\";\n const indent = baseIndent + \" \";\n const newLines = [...lines];\n newLines[row] = indent + lines[row];\n newLines.splice(row + 1, 0, baseIndent + closeChar);\n return { lines: newLines, row, col: indent.length };\n }\n if (baseIndent && col === 0) {\n return { lines: lines.with(row, baseIndent + lines[row]), row, col: baseIndent.length };\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;AAOA,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAM,eAAe;AACrB,MAAM,OAAO;AACb,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,aAAa;AAEnB,MAAM,gBAAwC;CAC5C,SAAS;CACT,UAAU;CACV,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,SAAS;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rD,MAAM,kBAAkB,UAAU,KAAK,MAAM,KAAK,UAAU,CAAC;EAE7D,IAAI,gBAAgB,iBAAiB;GAInC,MAAM,cAAc,aAAa;GACjC,MAAM,WAAW,CAAC,GAAG,KAAK;GAC1B,SAAS,OAAO;GAChB,SAAS,OAAO,MAAM,GAAG,GAAG,aAAa,MAAM,KAAK,UAAU,CAAC;GAC/D,OAAO;IAAE,OAAO;IAAU;IAAK,KAAK,YAAY;GAAO;EACzD;EACA,IAAI,cAAc;GAIhB,MAAM,YAAY,cADD,SAAS,QAAQ,EAAE,MAAM,EACH,MAAM;GAC7C,MAAM,SAAS,aAAa;GAC5B,MAAM,WAAW,CAAC,GAAG,KAAK;GAC1B,SAAS,OAAO,SAAS,MAAM;GAC/B,SAAS,OAAO,MAAM,GAAG,GAAG,aAAa,SAAS;GAClD,OAAO;IAAE,OAAO;IAAU;IAAK,KAAK,OAAO;GAAO;EACpD;EACA,IAAI,cAAc,QAAQ,GACxB,OAAO;GAAE,OAAO,MAAM,KAAK,KAAK,aAAa,MAAM,IAAI;GAAG;GAAK,KAAK,WAAW;EAAO;CAE1F;AAGF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as FileStreamIterator, b as upload, c as StreamMetadata, d as TailorDBFileError, f as TailorDBFileErrorCode, g as downloadAsBase64, h as download, i as FileMetadata, l as StreamValue, m as deleteFile, n as FileDownloadAsBase64Response, o as FileUploadOptions, p as UploadMetadata, r as FileDownloadResponse, s as FileUploadResponse, t as DownloadMetadata, u as TailorDBFileAPI, v as getMetadata, y as openDownloadStream } from "../file-Dc4_QrlQ.mjs";
|
|
2
|
+
export { DownloadMetadata, FileDownloadAsBase64Response, FileDownloadResponse, FileMetadata, FileStreamIterator, FileUploadOptions, FileUploadResponse, StreamMetadata, StreamValue, TailorDBFileAPI, TailorDBFileError, TailorDBFileErrorCode, UploadMetadata, deleteFile as delete, deleteFile, download, downloadAsBase64, getMetadata, openDownloadStream, upload };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { t as ContextInvoker } from "../context-BXDgEQK9.mjs";
|
|
2
|
+
import { f as TailorDBFileErrorCode } from "../file-Dc4_QrlQ.mjs";
|
|
3
|
+
import { r as IconvInstance } from "../iconv-BFNfdlIS.mjs";
|
|
4
|
+
import { a as IdpClientInstance, c as SendPasswordResetEmailInput, d as User, f as UserQuery, n as ClientConfig, o as ListUsersOptions, r as CreateUserInput, s as ListUsersResponse, u as UpdateUserInput } from "../idp-B1b4O7ia.mjs";
|
|
5
|
+
import { r as TriggerWorkflowOptions, t as AuthInvoker } from "../workflow-DV_88JEf.mjs";
|
|
6
|
+
import { a as TailordbQueryResult, i as TailordbCommandType, o as TailordbRuntime, r as TailordbClientInstance, t as TailorRuntime } from "../index-Dy3ZH5Wm.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/runtime/globals.d.ts
|
|
9
|
+
declare global {
|
|
10
|
+
namespace tailordb {
|
|
11
|
+
type QueryResult<T> = TailordbQueryResult<T>;
|
|
12
|
+
type CommandType = TailordbCommandType;
|
|
13
|
+
type Client = TailordbClientInstance;
|
|
14
|
+
}
|
|
15
|
+
var tailordb: TailordbRuntime;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use the lowercase `tailordb.*` namespace instead (e.g.
|
|
18
|
+
* `tailordb.QueryResult`, `tailordb.CommandType`,
|
|
19
|
+
* `typeof tailordb.Client`). This capital-cased namespace is retained
|
|
20
|
+
* only for backwards compatibility with `@tailor-platform/function-types`
|
|
21
|
+
* and will be removed in v2. Run
|
|
22
|
+
* `pnpm dlx @tailor-platform/sdk-codemod v2/tailordb-namespace`
|
|
23
|
+
* to migrate.
|
|
24
|
+
*/
|
|
25
|
+
namespace Tailordb {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `tailordb.Client` (lowercase) instead.
|
|
28
|
+
* Will be removed in v2.
|
|
29
|
+
*/
|
|
30
|
+
class Client {
|
|
31
|
+
constructor(config: {
|
|
32
|
+
namespace: string;
|
|
33
|
+
});
|
|
34
|
+
connect(): Promise<void>;
|
|
35
|
+
end(): Promise<void>;
|
|
36
|
+
queryObject<O>(sql: string, args?: readonly unknown[]): Promise<TailordbQueryResult<O>>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `tailordb.QueryResult<T>` (lowercase) instead.
|
|
40
|
+
* Will be removed in v2.
|
|
41
|
+
*/
|
|
42
|
+
type QueryResult<T> = TailordbQueryResult<T>;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use `tailordb.CommandType` (lowercase) instead.
|
|
45
|
+
* Will be removed in v2.
|
|
46
|
+
*/
|
|
47
|
+
type CommandType = TailordbCommandType;
|
|
48
|
+
}
|
|
49
|
+
namespace tailor {
|
|
50
|
+
namespace iconv {
|
|
51
|
+
type Iconv = IconvInstance;
|
|
52
|
+
}
|
|
53
|
+
namespace idp {
|
|
54
|
+
type Client = IdpClientInstance;
|
|
55
|
+
type ClientConfig = ClientConfig;
|
|
56
|
+
type User = User;
|
|
57
|
+
type UserQuery = UserQuery;
|
|
58
|
+
type ListUsersOptions = ListUsersOptions;
|
|
59
|
+
type ListUsersResponse = ListUsersResponse;
|
|
60
|
+
type CreateUserInput = CreateUserInput;
|
|
61
|
+
type UpdateUserInput = UpdateUserInput;
|
|
62
|
+
type SendPasswordResetEmailInput = SendPasswordResetEmailInput;
|
|
63
|
+
}
|
|
64
|
+
namespace workflow {
|
|
65
|
+
type AuthInvoker = AuthInvoker;
|
|
66
|
+
type TriggerWorkflowOptions = TriggerWorkflowOptions;
|
|
67
|
+
}
|
|
68
|
+
namespace context {
|
|
69
|
+
type Invoker = ContextInvoker;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
var tailor: TailorRuntime;
|
|
73
|
+
/** Custom error class for TailorDB File operations. */
|
|
74
|
+
class TailorDBFileError extends Error {
|
|
75
|
+
constructor(message: string, code?: TailorDBFileErrorCode, cause?: unknown);
|
|
76
|
+
name: "TailorDBFileError";
|
|
77
|
+
code?: TailorDBFileErrorCode;
|
|
78
|
+
cause?: unknown;
|
|
79
|
+
}
|
|
80
|
+
/** Individual error entry attached to {@link TailorErrors}. */
|
|
81
|
+
interface TailorErrorItem {
|
|
82
|
+
message: string;
|
|
83
|
+
path: (string | number)[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Aggregate validation error raised by the Tailor Platform Function runtime.
|
|
87
|
+
* The runtime serializes the items into the `message` (`"TailorErrors: {...}"`)
|
|
88
|
+
* and also exposes them on `.errors`.
|
|
89
|
+
*/
|
|
90
|
+
class TailorErrors extends Error {
|
|
91
|
+
constructor(errors: TailorErrorItem[]);
|
|
92
|
+
name: "TailorErrors";
|
|
93
|
+
errors: TailorErrorItem[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Single-message error raised by the Tailor Platform Function runtime.
|
|
97
|
+
*/
|
|
98
|
+
class TailorErrorMessage extends Error {
|
|
99
|
+
constructor(message: string);
|
|
100
|
+
name: "TailorErrorMessage";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=globals.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as convert, c as encode, i as TailorIconvAPI, l as encodings, n as IconvConstructor, o as convertBuffer, r as IconvInstance, s as decode, t as Iconv } from "../iconv-BFNfdlIS.mjs";
|
|
2
|
+
export { Iconv, IconvConstructor, IconvInstance, TailorIconvAPI, convert, convertBuffer, decode, encode, encodings };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as IdpClientInstance, c as SendPasswordResetEmailInput, d as User, f as UserQuery, i as IdpClientConstructor, l as TailorIdpAPI, n as ClientConfig, o as ListUsersOptions, r as CreateUserInput, s as ListUsersResponse, t as Client, u as UpdateUserInput } from "../idp-B1b4O7ia.mjs";
|
|
2
|
+
export { Client, ClientConfig, CreateUserInput, IdpClientConstructor, IdpClientInstance, ListUsersOptions, ListUsersResponse, SendPasswordResetEmailInput, TailorIdpAPI, UpdateUserInput, User, UserQuery };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { n as authconnection_d_exports } from "../authconnection-BDFTabLQ.mjs";
|
|
2
|
+
import { i as context_d_exports } from "../context-BXDgEQK9.mjs";
|
|
3
|
+
import { _ as file_d_exports } from "../file-Dc4_QrlQ.mjs";
|
|
4
|
+
import { u as iconv_d_exports } from "../iconv-BFNfdlIS.mjs";
|
|
5
|
+
import { p as idp_d_exports } from "../idp-B1b4O7ia.mjs";
|
|
6
|
+
import { i as secretmanager_d_exports } from "../secretmanager-Cjq3s2aU.mjs";
|
|
7
|
+
import { c as workflow_d_exports } from "../workflow-DV_88JEf.mjs";
|
|
8
|
+
import { a as TailordbQueryResult, i as TailordbCommandType, n as TailordbClientConstructor, o as TailordbRuntime, r as TailordbClientInstance, t as TailorRuntime } from "../index-Dy3ZH5Wm.mjs";
|
|
9
|
+
export { TailorRuntime, TailordbClientConstructor, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime, authconnection_d_exports as authconnection, context_d_exports as context, file_d_exports as file, iconv_d_exports as iconv, idp_d_exports as idp, secretmanager_d_exports as secretmanager, workflow_d_exports as workflow };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
import { s as iconv_exports } from "../iconv-D0yL88Il.mjs";
|
|
3
|
+
import { r as secretmanager_exports } from "../secretmanager-CQTTuCmn.mjs";
|
|
4
|
+
import { t as authconnection_exports } from "../authconnection-BUko4V6H.mjs";
|
|
5
|
+
import { n as idp_exports } from "../idp-CM7N7iID.mjs";
|
|
6
|
+
import { a as workflow_exports } from "../workflow-DJRr-0nl.mjs";
|
|
7
|
+
import { t as context_exports } from "../context-BP5BUdcq.mjs";
|
|
8
|
+
import { i as file_exports } from "../file-BE5Sy7lP.mjs";
|
|
9
|
+
|
|
10
|
+
export { authconnection_exports as authconnection, context_exports as context, file_exports as file, iconv_exports as iconv, idp_exports as idp, secretmanager_exports as secretmanager, workflow_exports as workflow };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as triggerJobFunction, i as resolve, n as TailorWorkflowAPI, o as triggerWorkflow, r as TriggerWorkflowOptions, s as wait, t as AuthInvoker } from "../workflow-DV_88JEf.mjs";
|
|
2
|
+
export { AuthInvoker, TailorWorkflowAPI, TriggerWorkflowOptions, resolve, triggerJobFunction, triggerWorkflow, wait };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as db } from "./schema-
|
|
3
|
-
import { $ as FilterSchema, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as Condition_Operator, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Subgraph_ServiceType, Y as ApplicationSchemaUpdateAttemptStatus, Z as ConditionSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as PageDirection, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-
|
|
4
|
-
import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-
|
|
5
|
-
import { C as loadConfigPath, O as writePlatformConfig, S as loadAccessToken, T as readPlatformConfig, _ as getDistDir, d as buildResolverOperationHookExpr, f as OAuth2ClientSchema, g as createBundleCache, h as loadFilesWithIgnores, m as stringifyFunction, n as generatePluginFilesIfNeeded, p as TailorDBTypeSchema, r as loadApplication, s as createExecutorService, t as defineApplication, u as buildExecutorArgsExpr, v as hashFile, w as loadWorkspaceId, y as loadConfig } from "./application-
|
|
6
|
-
import { t as multiline } from "./multiline-
|
|
7
|
-
import { t as readPackageJson } from "./package-json-
|
|
8
|
-
import { n as isCLIError, t as createCLIError } from "./errors-
|
|
9
|
-
import { r as withSpan } from "./telemetry-
|
|
2
|
+
import { t as db } from "./schema-DBq6hr6h.mjs";
|
|
3
|
+
import { $ as FilterSchema, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as Condition_Operator, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Subgraph_ServiceType, Y as ApplicationSchemaUpdateAttemptStatus, Z as ConditionSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as PageDirection, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-BwV17byk.mjs";
|
|
4
|
+
import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-B1g4I9wT.mjs";
|
|
5
|
+
import { C as loadConfigPath, O as writePlatformConfig, S as loadAccessToken, T as readPlatformConfig, _ as getDistDir, d as buildResolverOperationHookExpr, f as OAuth2ClientSchema, g as createBundleCache, h as loadFilesWithIgnores, m as stringifyFunction, n as generatePluginFilesIfNeeded, p as TailorDBTypeSchema, r as loadApplication, s as createExecutorService, t as defineApplication, u as buildExecutorArgsExpr, v as hashFile, w as loadWorkspaceId, y as loadConfig } from "./application-Z-fNwyZB.mjs";
|
|
6
|
+
import { t as multiline } from "./multiline-G1yF18OH.mjs";
|
|
7
|
+
import { t as readPackageJson } from "./package-json-ZL0MkZOO.mjs";
|
|
8
|
+
import { n as isCLIError, t as createCLIError } from "./errors-C4cJ0M2K.mjs";
|
|
9
|
+
import { r as withSpan } from "./telemetry-C8xKz3GM.mjs";
|
|
10
10
|
import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import * as fs$1 from "node:fs";
|
|
@@ -1542,16 +1542,18 @@ async function buildMetaRequest(params) {
|
|
|
1542
1542
|
* @returns Promise that resolves when applications are applied
|
|
1543
1543
|
*/
|
|
1544
1544
|
async function applyApplication(client, changeSet, phase = "create-update") {
|
|
1545
|
-
if (phase === "create-update")
|
|
1546
|
-
|
|
1547
|
-
await
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1545
|
+
if (phase === "create-update") {
|
|
1546
|
+
const updates = [...changeSet.updates, ...changeSet.unchanged];
|
|
1547
|
+
await Promise.all([...changeSet.creates.map(async (create) => {
|
|
1548
|
+
create.request.cors = await resolveStaticWebsiteUrls(client, create.request.workspaceId, create.request.cors, "CORS");
|
|
1549
|
+
await client.createApplication(create.request);
|
|
1550
|
+
await client.setMetadata(create.metaRequest);
|
|
1551
|
+
}), ...updates.map(async (update) => {
|
|
1552
|
+
update.request.cors = await resolveStaticWebsiteUrls(client, update.request.workspaceId, update.request.cors, "CORS");
|
|
1553
|
+
await client.updateApplication(update.request);
|
|
1554
|
+
await client.setMetadata(update.metaRequest);
|
|
1555
|
+
})]);
|
|
1556
|
+
} else if (phase === "delete") await Promise.all(changeSet.deletes.map(async (del) => {
|
|
1555
1557
|
await client.deleteApplication(del.request);
|
|
1556
1558
|
}));
|
|
1557
1559
|
}
|
|
@@ -1705,12 +1707,13 @@ async function planApplication(context) {
|
|
|
1705
1707
|
}
|
|
1706
1708
|
if (existing) {
|
|
1707
1709
|
const labels = await fetchAppLabels(client, workspaceId, application.name);
|
|
1708
|
-
|
|
1709
|
-
else changeSet.updates.push({
|
|
1710
|
+
const update = {
|
|
1710
1711
|
name: application.name,
|
|
1711
1712
|
request,
|
|
1712
1713
|
metaRequest
|
|
1713
|
-
}
|
|
1714
|
+
};
|
|
1715
|
+
if (isOwnedByApp(labels, application.name, application.id) && hasMatchingSdkVersion(labels, metaRequest.labels) && areApplicationsEqual(existing, desired)) changeSet.unchanged.push(update);
|
|
1716
|
+
else changeSet.updates.push(update);
|
|
1714
1717
|
} else changeSet.creates.push({
|
|
1715
1718
|
name: application.name,
|
|
1716
1719
|
request,
|
|
@@ -14021,7 +14024,7 @@ async function generate(options) {
|
|
|
14021
14024
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
14022
14025
|
let pluginManager;
|
|
14023
14026
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
14024
|
-
const { defineApplication } = await import("./application-
|
|
14027
|
+
const { defineApplication } = await import("./application-Bcx-FbDE.mjs");
|
|
14025
14028
|
const application = defineApplication({
|
|
14026
14029
|
config,
|
|
14027
14030
|
pluginManager
|
|
@@ -14171,14 +14174,30 @@ const generateCommand = defineAppCommand({
|
|
|
14171
14174
|
//#endregion
|
|
14172
14175
|
//#region src/cli/shared/config.ts
|
|
14173
14176
|
/**
|
|
14174
|
-
* Extracts
|
|
14175
|
-
*
|
|
14177
|
+
* Extracts every namespace key declared under `config.db`, including those
|
|
14178
|
+
* declared with `{ external: true }`.
|
|
14176
14179
|
* @param config - Loaded application configuration.
|
|
14177
14180
|
* @returns Namespace names in insertion order.
|
|
14178
14181
|
*/
|
|
14179
14182
|
function extractAllNamespaces(config) {
|
|
14180
14183
|
const namespaces = /* @__PURE__ */ new Set();
|
|
14181
|
-
if (config.db) for (const
|
|
14184
|
+
if (config.db) for (const namespaceName of Object.keys(config.db)) namespaces.add(namespaceName);
|
|
14185
|
+
return Array.from(namespaces);
|
|
14186
|
+
}
|
|
14187
|
+
/**
|
|
14188
|
+
* Extracts namespace keys under `config.db` that this app owns
|
|
14189
|
+
* (i.e. not declared with `{ external: true }`). Use this for destructive
|
|
14190
|
+
* operations like `tailordb truncate --all` to avoid touching namespaces
|
|
14191
|
+
* owned by other apps.
|
|
14192
|
+
* @param config - Loaded application configuration.
|
|
14193
|
+
* @returns Owned namespace names in insertion order.
|
|
14194
|
+
*/
|
|
14195
|
+
function extractOwnedNamespaces(config) {
|
|
14196
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
14197
|
+
if (config.db) for (const [namespaceName, nsConfig] of Object.entries(config.db)) {
|
|
14198
|
+
if ("external" in nsConfig && nsConfig.external === true) continue;
|
|
14199
|
+
namespaces.add(namespaceName);
|
|
14200
|
+
}
|
|
14182
14201
|
return Array.from(namespaces);
|
|
14183
14202
|
}
|
|
14184
14203
|
|
|
@@ -14273,7 +14292,7 @@ async function $truncate(options) {
|
|
|
14273
14292
|
if (optionCount === 0) throw new Error("Please specify one of: --all, --namespace <name>, or type names");
|
|
14274
14293
|
if (optionCount > 1) throw new Error("Options --all, --namespace, and type names are mutually exclusive. Please specify only one.");
|
|
14275
14294
|
const { config } = await loadConfig(options?.configPath);
|
|
14276
|
-
const namespaces =
|
|
14295
|
+
const namespaces = extractOwnedNamespaces(config);
|
|
14277
14296
|
if (hasAll) {
|
|
14278
14297
|
if (namespaces.length === 0) {
|
|
14279
14298
|
logger.warn("No namespaces found in config file.");
|
|
@@ -14282,7 +14301,7 @@ async function $truncate(options) {
|
|
|
14282
14301
|
if (!options?.yes) {
|
|
14283
14302
|
const namespaceList = namespaces.join(", ");
|
|
14284
14303
|
if (!await prompt.confirm({
|
|
14285
|
-
message: `This will truncate ALL tables in the following namespaces: ${namespaceList}. Continue?`,
|
|
14304
|
+
message: `This will truncate ALL tables in the following owned namespaces (external namespaces are excluded): ${namespaceList}. Continue?`,
|
|
14286
14305
|
default: false
|
|
14287
14306
|
})) {
|
|
14288
14307
|
logger.info("Truncate cancelled.");
|
|
@@ -14290,12 +14309,16 @@ async function $truncate(options) {
|
|
|
14290
14309
|
}
|
|
14291
14310
|
}
|
|
14292
14311
|
for (const namespace of namespaces) await truncateNamespace(workspaceId, namespace, client);
|
|
14293
|
-
logger.success("Truncated all tables in all namespaces");
|
|
14312
|
+
logger.success("Truncated all tables in all owned namespaces");
|
|
14294
14313
|
return;
|
|
14295
14314
|
}
|
|
14296
14315
|
if (hasNamespace && options?.namespace) {
|
|
14297
14316
|
const namespace = options.namespace;
|
|
14298
|
-
if (!namespaces.includes(namespace))
|
|
14317
|
+
if (!namespaces.includes(namespace)) {
|
|
14318
|
+
const dbConfig = config.db?.[namespace];
|
|
14319
|
+
if (dbConfig && "external" in dbConfig && dbConfig.external === true) throw new Error(`Namespace "${namespace}" is declared as external in this app's config and cannot be truncated from here. Run truncate from the app that owns it.`);
|
|
14320
|
+
throw new Error(`Namespace "${namespace}" not found in config. Available owned namespaces (external namespaces are excluded): ${namespaces.join(", ")}`);
|
|
14321
|
+
}
|
|
14299
14322
|
if (!options.yes) {
|
|
14300
14323
|
if (!await prompt.confirm({
|
|
14301
14324
|
message: `This will truncate ALL tables in namespace "${namespace}". Continue?`,
|
|
@@ -14351,7 +14374,7 @@ const truncateCommand = defineAppCommand({
|
|
|
14351
14374
|
}),
|
|
14352
14375
|
all: arg(z.boolean().default(false), {
|
|
14353
14376
|
alias: "a",
|
|
14354
|
-
description: "Truncate all tables in all namespaces"
|
|
14377
|
+
description: "Truncate all tables in all owned namespaces (excludes external namespaces)"
|
|
14355
14378
|
}),
|
|
14356
14379
|
namespace: arg(z.string().optional(), {
|
|
14357
14380
|
alias: "n",
|
|
@@ -15854,7 +15877,7 @@ async function runRepl(options) {
|
|
|
15854
15877
|
const execute = await prepareQueryExecutor(options);
|
|
15855
15878
|
const historyPath = getReplHistoryPath(options.engine, options.profile, options.workspaceId);
|
|
15856
15879
|
const validate = createReplValidator(options.engine);
|
|
15857
|
-
const { highlightSqlLine, highlightGraphqlLine, replTransform } = await import("./repl-editor-
|
|
15880
|
+
const { highlightSqlLine, highlightGraphqlLine, replTransform } = await import("./repl-editor-yAjwS5_M.mjs");
|
|
15858
15881
|
const highlight = options.engine === "sql" ? highlightSqlLine : highlightGraphqlLine;
|
|
15859
15882
|
const prompt = createPrompt({
|
|
15860
15883
|
prefix: "",
|
|
@@ -16188,4 +16211,4 @@ function isDeno() {
|
|
|
16188
16211
|
|
|
16189
16212
|
//#endregion
|
|
16190
16213
|
export { listCommand$5 as $, compareSnapshots as $t, truncate as A, workspaceArgs as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, configArg as Cn, triggerExecutor as Ct, resumeWorkflow as D, pagedLogArgs as Dn, jobsCommand as Dt, resumeCommand as E, isVerbose as En, getExecutorJob as Et, writeDbTypesFile as F, getWorkflowExecution as Ft, organizationTree as G, parseMigrationLabelNumber as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, listWorkflowExecutions as It, listOrganizations as J, DIFF_FILE_NAME as Jt, treeCommand as K, bundleMigrationScript as Kt, openInConfiguredEditor as L, functionExecutionStatusToString as Lt, generate as M, getCommand$5 as Mt, generateCommand as N, getWorkflow as Nt, listCommand$3 as O, paginationArgs as On, listExecutorJobs as Ot, generateMigrationScript as P, executionsCommand as Pt, updateFolder as Q, compareLocalTypesWithSnapshot as Qt, show as R, formatKeyValueTable as Rt, listApps as S, commonArgs as Sn, triggerCommand as St, healthCommand as T, deploymentArgs as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, MIGRATION_LABEL_KEY as Wt, getOrganization as X, MIGRATE_FILE_NAME as Xt, getCommand$1 as Y, INITIAL_SCHEMA_NUMBER as Yt, updateCommand$2 as Z, SCHEMA_FILE_NAME as Zt, getWorkspace as _, prompt as _n, listFunctionRegistries as _t, updateUser as a, getMigrationFiles as an, createCommand$1 as at, createCommand as b, assertWritable as bn, listWebhookExecutors as bt, listCommand as c, loadDiff as cn, listOAuth2Clients as ct, inviteUser as d, formatMigrationDiff as dn, getMachineUserToken as dt, createSnapshotFromLocalTypes as en, listFolders as et, restoreCommand as f, hasChanges as fn, tokenCommand as ft, getCommand as g, generateUserTypes as gn, listCommand$8 as gt, listWorkspaces as h, trnPrefix as hn, generate$1 as ht, updateCommand as i, getMigrationFilePath as in, deleteFolder as it, truncateCommand as j, startWorkflow as jt, listWorkflows as k, toPageDirection as kn, watchExecutorJob as kt, listUsers as l, reconstructSnapshotFromMigrations as ln, getCommand$3 as lt, listCommand$1 as m, sdkNameLabelKey as mn, listMachineUsers as mt, query as n, getLatestMigrationNumber as nn, getFolder as nt, removeCommand as o, getNextMigrationNumber as on, createFolder as ot, restoreWorkspace as p, getNamespacesWithMigrations as pn, listCommand$7 as pt, listCommand$4 as q, DB_TYPES_FILE_NAME as qt, queryCommand as r, getMigrationDirPath as rn, deleteCommand$1 as rt, removeUser as s, isValidMigrationNumber as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, formatMigrationNumber as tn, getCommand$2 as tt, inviteCommand as u, formatDiffSummary as un, getOAuth2Client as ut, deleteCommand as v, apiCommand as vn, getCommand$4 as vt, getAppHealth as w, confirmationArgs as wn, listCommand$9 as wt, createWorkspace as x, defineAppCommand as xn, webhookCommand as xt, deleteWorkspace as y, apiCall as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
|
|
16191
|
-
//# sourceMappingURL=runtime-
|
|
16214
|
+
//# sourceMappingURL=runtime-CyX4zeod.mjs.map
|