@dpuse/dpuse-connector-dropbox 0.2.474 → 0.2.476
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.
|
@@ -33,7 +33,7 @@ var n = {
|
|
|
33
33
|
lastUpdatedAt: null,
|
|
34
34
|
operations: [
|
|
35
35
|
"abortOperation",
|
|
36
|
-
"
|
|
36
|
+
"authenticateConnection",
|
|
37
37
|
"auditObjectContent",
|
|
38
38
|
"findObject",
|
|
39
39
|
"getReadableStream",
|
|
@@ -48,7 +48,7 @@ var n = {
|
|
|
48
48
|
vendorAccountURL: null,
|
|
49
49
|
vendorDocumentationURL: null,
|
|
50
50
|
vendorHomeURL: null,
|
|
51
|
-
version: "0.2.
|
|
51
|
+
version: "0.2.476"
|
|
52
52
|
}, r = "lo38r2co3ixibhn", i = "https://api.dpuse.app/authenticate", a = class {
|
|
53
53
|
abortController;
|
|
54
54
|
config;
|
|
@@ -60,9 +60,9 @@ var n = {
|
|
|
60
60
|
abortOperation() {
|
|
61
61
|
this.abortController &&= (this.abortController.abort(), void 0);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
let
|
|
65
|
-
if (
|
|
63
|
+
authenticateConnection(e, t, n) {
|
|
64
|
+
let a = `https://www.dropbox.com/oauth2/authorize?client_id=${r}&force_reapprove=true&redirect_uri=${i}&response_type=code&state=dropbox|${e}}&token_access_type=offline`, o = t - 700 / 2, s = n - 800 / 2, c = window.open(a, "DPUseAuthenticationWindow", `height=800,width=700,top=${s},left=${o}`);
|
|
65
|
+
if (c != null) return c.focus(), c;
|
|
66
66
|
}
|
|
67
67
|
async auditObjectContent(n, r) {
|
|
68
68
|
this.abortController = new AbortController();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-connector-dropbox.es.js","names":[],"sources":["../node_modules/@dpuse/dpuse-shared/dist/dpuse-shared-errors.es.js","../node_modules/@dpuse/dpuse-shared/dist/dpuse-shared-tools.es.js","../config.json","../src/index.ts"],"sourcesContent":["//#region src/errors/index.ts\nvar e = 2048, t = class extends Error {\n\tdata;\n\tlocator;\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, r), this.name = \"DPUseError\", this.data = n, this.locator = t;\n\t}\n}, n = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"AppError\";\n\t}\n}, r = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"APIError\";\n\t}\n}, i = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"EngineError\";\n\t}\n}, a = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"ConnectorError\";\n\t}\n}, o = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"FetchError\";\n\t}\n};\nasync function s(e, t, n) {\n\tlet r = ` - ${e.statusText}`, i = `${t} Response status '${e.status}${e.statusText ? r : \"\"}' received.`, a;\n\ttry {\n\t\ta = await e.text();\n\t} catch (e) {\n\t\ta = `<body unavailable: ${u(e).message}>`;\n\t}\n\treturn new o(i, n, { body: m(a) });\n}\nfunction c(e) {\n\treturn e.map((e) => e.message).join(\" \");\n}\nfunction l(e) {\n\ttry {\n\t\te();\n\t} catch {}\n}\nfunction u(e) {\n\tif (e instanceof Error) return e;\n\tif (typeof e == \"string\") return Error(e);\n\tif (typeof e == \"number\" || typeof e == \"boolean\" || typeof e == \"bigint\") return Error(String(e));\n\tif (typeof e == \"symbol\") return Error(e.description ?? \"Unknown error\");\n\tif (typeof e == \"object\") try {\n\t\treturn Error(JSON.stringify(e));\n\t} catch {\n\t\treturn /* @__PURE__ */ Error(\"Unknown error\");\n\t}\n\treturn /* @__PURE__ */ Error(\"Unknown error\");\n}\nfunction d(e) {\n\tlet t = /* @__PURE__ */ new Set(), n = [], r = u(e);\n\tfor (; r != null && !t.has(r);) {\n\t\tt.add(r);\n\t\tlet e;\n\t\tswitch (r.name) {\n\t\t\tcase \"APIError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"APIError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"AppError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"AppError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ConnectorError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"ConnectorError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"EngineError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"EngineError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"FetchError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"FetchError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tlet { cause: t, ...n } = Object.fromEntries(Object.entries(r));\n\t\t\t\tr.name ? (e = {\n\t\t\t\t\tdata: n,\n\t\t\t\t\tlocator: \"\",\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: r.name,\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause)) : (e = {\n\t\t\t\t\tdata: n,\n\t\t\t\t\tlocator: \"\",\n\t\t\t\t\tmessage: p(r),\n\t\t\t\t\tname: \"Error\",\n\t\t\t\t\tstack: void 0\n\t\t\t\t}, r = null);\n\t\t}\n\t\t/(?:\\.{3}|[.!?])$/.test(e.message) || (e.message += \".\"), n.push(e);\n\t}\n\treturn n;\n}\nfunction f(e) {\n\tif (e.length === 0) return;\n\tlet t;\n\tfor (let s of e.toReversed()) {\n\t\tlet e;\n\t\tswitch (s.name) {\n\t\t\tcase \"APIError\":\n\t\t\t\te = new r(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"AppError\":\n\t\t\t\te = new n(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"ConnectorError\":\n\t\t\t\te = new a(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"EngineError\":\n\t\t\t\te = new i(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"FetchError\":\n\t\t\t\te = new o(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\te = Error(s.message, { cause: t }), e.name = s.name;\n\t\t\t\tbreak;\n\t\t}\n\t\ts.stack !== void 0 && (e.stack = s.stack), t = e;\n\t}\n\treturn t;\n}\nfunction p(e) {\n\tlet t;\n\ttry {\n\t\tt = JSON.stringify(e);\n\t} catch {\n\t\tt = typeof e == \"symbol\" ? e.description ?? \"Unknown error\" : typeof e == \"bigint\" ? e.toString() : \"Unknown error\";\n\t}\n\treturn t === \"\" && (t = \"Unknown error\"), t;\n}\nfunction m(t) {\n\tif (!(t == null || t === \"\")) return t.length > e ? `${t.slice(0, e)}... [truncated]` : t;\n}\n//#endregion\nexport { r as APIError, n as AppError, a as ConnectorError, t as DPUseError, i as EngineError, o as FetchError, s as buildFetchError, c as concatenateSerialisedErrorMessages, l as ignoreErrors, u as normalizeToError, d as serialiseError, f as unserialiseError };\n","//#region src/component/tool/index.ts\nasync function e(e, t) {\n\tlet n = `dpuse-tool-${t}`, r = e.find((e) => e.id === n);\n\tif (!r) throw Error(`Connector could not load unknown tool '${t}'.`);\n\treturn new (await (import(`https://engine-eu.dpuse.app/tools/${t}_v${r.version}/${n}.es.js`))).Tool();\n}\n//#endregion\nexport { e as loadTool };\n","{\n \"id\": \"dpuse-connector-dropbox\",\n \"label\": {\n \"en\": \"Dropbox\"\n },\n \"description\": {\n \"en\": \"Dropbox is a cloud-based file storage solution. It provides for the storage and sharing of files, as well as synchronising them across multiple devices.\"\n },\n \"category\": null,\n \"categoryId\": \"fileStore\",\n \"implementations\": {\n \"default\": {\n \"authMethodId\": \"oAuth2\",\n \"maxConnectionCount\": -1\n }\n },\n \"icon\": \"<svg fill=\\\"none\\\" viewBox=\\\"0 0 128 128\\\"><path fill=\\\"#0061FE\\\" d=\\\"M0 0h128v128H0z\\\"/><path fill=\\\"#F7F5F2\\\" d=\\\"M43.7 32 23.404 44.75 43.701 57.5 64 44.75 84.3 57.5l20.298-12.75L84.299 32 64.002 44.75 43.7 32Zm0 51L23.404 70.25 43.701 57.5 64 70.25 43.702 83Zm20.302-12.75L84.299 57.5l20.298 12.75L84.299 83 64.002 70.25Zm0 29.75L43.7 87.25 64 74.5l20.3 12.75L64.002 100Z\\\"/></svg>\",\n \"iconDark\": \"\",\n \"lastUpdatedAt\": null,\n \"operations\": [\n \"abortOperation\",\n \"authenticate\",\n \"auditObjectContent\",\n \"findObject\",\n \"getReadableStream\",\n \"listNodes\",\n \"previewObject\",\n \"retrieveRecords\"\n ],\n \"status\": null,\n \"statusId\": \"beta\",\n \"typeId\": \"connector\",\n \"usageId\": \"source\",\n \"vendorAccountURL\": null,\n \"vendorDocumentationURL\": null,\n \"vendorHomeURL\": null,\n \"version\": \"0.2.474\"\n}","// External dependencies\n\n// DPU framework\nimport type { EngineUtilities } from '@dpuse/dpuse-shared/engine';\nimport { normalizeToError } from '@dpuse/dpuse-shared/errors';\nimport type {\n AuditObjectContentOptions,\n AuditObjectContentResult,\n ConnectionConfig,\n ConnectorConfig,\n ConnectorInterface,\n FindObjectOptions,\n FindObjectResult,\n GetReadableStreamOptions,\n ListNodesOptions,\n ListNodesResult,\n PreviewObjectOptions,\n RetrievalTypeId,\n RetrieveRecordsOptions,\n RetrieveRecordsSummary\n} from '@dpuse/dpuse-shared/component/connector';\nimport { loadTool, type ToolConfig } from '@dpuse/dpuse-shared/component/tool';\nimport type { ParsingRecord, PreviewConfig } from '@dpuse/dpuse-shared/component/dataView';\n\n// DPU tools\nimport type { Tool as CSVParseTool } from '@dpuse/dpuse-tool-csv-parse';\nimport type { Tool as FileOperatorsTool } from '@dpuse/dpuse-tool-file-operators';\n\n// Data\nimport config from '~/config.json';\n\n// Constants\nconst AUTHORISE_URL = 'https://www.dropbox.com/oauth2/authorize';\nconst CLIENT_ID = 'lo38r2co3ixibhn';\nconst REDIRECT_URI = 'https://api.dpuse.app/authenticate';\n\n// Connectors\nexport class Connector implements ConnectorInterface {\n abortController: AbortController | undefined;\n readonly config: ConnectorConfig;\n engineUtilities: EngineUtilities;\n readonly toolConfigs;\n\n constructor(engineUtilities: EngineUtilities, toolConfigs: ToolConfig[]) {\n this.abortController = undefined;\n this.config = config as ConnectorConfig;\n this.engineUtilities = engineUtilities;\n this.toolConfigs = toolConfigs;\n }\n\n // Operations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n // Abort the currently running operation\n abortOperation(): void {\n if (!this.abortController) return;\n this.abortController.abort();\n this.abortController = undefined;\n }\n\n // Authenticate a connection.\n authenticate(connectionConfig: ConnectionConfig, accountId: string, windowCenterX: number, windowCenterY: number): Window | undefined {\n const url =\n AUTHORISE_URL +\n `?client_id=${CLIENT_ID}` +\n '&force_reapprove=true' +\n `&redirect_uri=${REDIRECT_URI}` +\n '&response_type=code' +\n `&state=dropbox|${accountId}|${connectionConfig.id}` +\n '&token_access_type=offline';\n const popupHeight = 800;\n const popupWidth = 700;\n const popupLeft = windowCenterX - popupWidth / 2;\n const popupTop = windowCenterY - popupHeight / 2;\n const popup = window.open(url, 'DPUseAuthenticationWindow', `height=${popupHeight},width=${popupWidth},top=${popupTop},left=${popupLeft}`);\n if (popup == null) return undefined;\n popup.focus();\n return popup;\n }\n\n // Audit object content\n async auditObjectContent(options: AuditObjectContentOptions, chunk: (rowCount: number) => void): Promise<AuditObjectContentResult> {\n this.abortController = new AbortController();\n\n try {\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n const parseStreamOptions = { delimiter: options.valueDelimiterId, relax_column_count: true, relax_quotes: true };\n return { processedRowCount: 0, durationMs: 0 };\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n\n // Find the folder path containing the specified object node\n findObject(options: FindObjectOptions): Promise<FindObjectResult> {\n return Promise.reject(new Error('Not found.')); // Not found.\n }\n\n // Get a readable stream for the specified object node path\n async getReadableStream(options: GetReadableStreamOptions): Promise<ReadableStream<Uint8Array>> {\n // Create an abort controller and extract its signal.\n const { signal } = (this.abortController = new AbortController());\n\n try {\n return await Promise.resolve({} as ReadableStream<Uint8Array>);\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n\n // Lists all nodes (folders and objects) in the specified folder path\n listNodes(options: ListNodesOptions): Promise<ListNodesResult> {\n return Promise.resolve({} as ListNodesResult);\n }\n\n // Preview the contents of the object node with the specified path\n async previewObject(options: PreviewObjectOptions): Promise<PreviewConfig> {\n // Create an abort controller and extract its signal.\n const { signal } = (this.abortController = new AbortController());\n\n try {\n const asAt = Date.now();\n const startedAt = performance.now();\n\n // Preview file to determine file format and decode text.\n const fileOperatorsTool = await loadTool<FileOperatorsTool>(this.toolConfigs, 'file-operators');\n\n // Parse text, identify delimiters, and produce string value records.\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n\n return {} as PreviewConfig;\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n // Retrieves all records from a CSV object node using streaming and chunked processing\n async retrieveRecords(\n options: RetrieveRecordsOptions,\n chunk: (typeId: RetrievalTypeId, records: ParsingRecord[]) => void,\n complete: (result: RetrieveRecordsSummary) => void\n ): Promise<void> {\n this.abortController = new AbortController();\n try {\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n const parseStreamOptions = { delimiter: options.valueDelimiterId, info: true, relax_column_count: true, relax_quotes: true };\n complete({} as RetrieveRecordsSummary);\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n}\n"],"x_google_ignoreList":[0,1],"mappings":";AA6CA,SAAS,EAAE,GAAG;AACb,KAAI,aAAa,MAAO,QAAO;AAC/B,KAAI,OAAO,KAAK,SAAU,QAAO,MAAM,EAAE;AACzC,KAAI,OAAO,KAAK,YAAY,OAAO,KAAK,aAAa,OAAO,KAAK,SAAU,QAAO,MAAM,OAAO,EAAE,CAAC;AAClG,KAAI,OAAO,KAAK,SAAU,QAAO,MAAM,EAAE,eAAe,gBAAgB;AACxE,KAAI,OAAO,KAAK,SAAU,KAAI;AAC7B,SAAO,MAAM,KAAK,UAAU,EAAE,CAAC;SACxB;AACP,SAAuB,sBAAM,gBAAgB;;AAE9C,QAAuB,sBAAM,gBAAgB;;;;ACtD9C,eAAe,EAAE,GAAG,GAAG;CACtB,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE,M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AAM,EAAiB,EAAM;YACvB;AACN,QAAK,kBAAkB,KAAA;;;CAK/B,UAAU,GAAqD;AAC3D,SAAO,QAAQ,QAAQ,EAAE,CAAoB;;CAIjD,MAAM,cAAc,GAAuD;EAEvE,IAAM,EAAE,cAAY,KAAK,kBAAkB,IAAI,iBAAiB;AAEhE,MAAI;AAUA,UARkB,YAAY,KAAK,EAGT,MAAM,EAA4B,KAAK,aAAa,iBAAiB,EAG1E,MAAM,EAAuB,KAAK,aAAa,YAAY,EAEzE,EAAE;WACJ,GAAO;AACZ,SAAM,EAAiB,EAAM;YACvB;AACN,QAAK,kBAAkB,KAAA;;;CAI/B,MAAM,gBACF,GACA,GACA,GACa;AACb,OAAK,kBAAkB,IAAI,iBAAiB;AAC5C,MAAI;AAGA,GAFqB,MAAM,EAAuB,KAAK,aAAa,YAAY,EACxC,EAAQ,kBAChD,EAAS,EAAE,CAA2B;WACjC,GAAO;AACZ,SAAM,EAAiB,EAAM;YACvB;AACN,QAAK,kBAAkB,KAAA"}
|
|
1
|
+
{"version":3,"file":"dpuse-connector-dropbox.es.js","names":[],"sources":["../node_modules/@dpuse/dpuse-shared/dist/dpuse-shared-errors.es.js","../node_modules/@dpuse/dpuse-shared/dist/dpuse-shared-tools.es.js","../config.json","../src/index.ts"],"sourcesContent":["//#region src/errors/index.ts\nvar e = 2048, t = class extends Error {\n\tdata;\n\tlocator;\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, r), this.name = \"DPUseError\", this.data = n, this.locator = t;\n\t}\n}, n = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"AppError\";\n\t}\n}, r = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"APIError\";\n\t}\n}, i = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"EngineError\";\n\t}\n}, a = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"ConnectorError\";\n\t}\n}, o = class extends t {\n\tconstructor(e, t, n, r) {\n\t\tsuper(e, t, n, r), this.name = \"FetchError\";\n\t}\n};\nasync function s(e, t, n) {\n\tlet r = ` - ${e.statusText}`, i = `${t} Response status '${e.status}${e.statusText ? r : \"\"}' received.`, a;\n\ttry {\n\t\ta = await e.text();\n\t} catch (e) {\n\t\ta = `<body unavailable: ${u(e).message}>`;\n\t}\n\treturn new o(i, n, { body: m(a) });\n}\nfunction c(e) {\n\treturn e.map((e) => e.message).join(\" \");\n}\nfunction l(e) {\n\ttry {\n\t\te();\n\t} catch {}\n}\nfunction u(e) {\n\tif (e instanceof Error) return e;\n\tif (typeof e == \"string\") return Error(e);\n\tif (typeof e == \"number\" || typeof e == \"boolean\" || typeof e == \"bigint\") return Error(String(e));\n\tif (typeof e == \"symbol\") return Error(e.description ?? \"Unknown error\");\n\tif (typeof e == \"object\") try {\n\t\treturn Error(JSON.stringify(e));\n\t} catch {\n\t\treturn /* @__PURE__ */ Error(\"Unknown error\");\n\t}\n\treturn /* @__PURE__ */ Error(\"Unknown error\");\n}\nfunction d(e) {\n\tlet t = /* @__PURE__ */ new Set(), n = [], r = u(e);\n\tfor (; r != null && !t.has(r);) {\n\t\tt.add(r);\n\t\tlet e;\n\t\tswitch (r.name) {\n\t\t\tcase \"APIError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"APIError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"AppError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"AppError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ConnectorError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"ConnectorError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"EngineError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"EngineError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"FetchError\": {\n\t\t\t\tlet t = r;\n\t\t\t\te = {\n\t\t\t\t\tdata: t.data,\n\t\t\t\t\tlocator: t.locator,\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: \"FetchError\",\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tlet { cause: t, ...n } = Object.fromEntries(Object.entries(r));\n\t\t\t\tr.name ? (e = {\n\t\t\t\t\tdata: n,\n\t\t\t\t\tlocator: \"\",\n\t\t\t\t\tmessage: r.message,\n\t\t\t\t\tname: r.name,\n\t\t\t\t\tstack: r.stack\n\t\t\t\t}, r = r.cause == null ? null : u(r.cause)) : (e = {\n\t\t\t\t\tdata: n,\n\t\t\t\t\tlocator: \"\",\n\t\t\t\t\tmessage: p(r),\n\t\t\t\t\tname: \"Error\",\n\t\t\t\t\tstack: void 0\n\t\t\t\t}, r = null);\n\t\t}\n\t\t/(?:\\.{3}|[.!?])$/.test(e.message) || (e.message += \".\"), n.push(e);\n\t}\n\treturn n;\n}\nfunction f(e) {\n\tif (e.length === 0) return;\n\tlet t;\n\tfor (let s of e.toReversed()) {\n\t\tlet e;\n\t\tswitch (s.name) {\n\t\t\tcase \"APIError\":\n\t\t\t\te = new r(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"AppError\":\n\t\t\t\te = new n(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"ConnectorError\":\n\t\t\t\te = new a(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"EngineError\":\n\t\t\t\te = new i(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tcase \"FetchError\":\n\t\t\t\te = new o(s.message, s.locator, s.data, { cause: t });\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\te = Error(s.message, { cause: t }), e.name = s.name;\n\t\t\t\tbreak;\n\t\t}\n\t\ts.stack !== void 0 && (e.stack = s.stack), t = e;\n\t}\n\treturn t;\n}\nfunction p(e) {\n\tlet t;\n\ttry {\n\t\tt = JSON.stringify(e);\n\t} catch {\n\t\tt = typeof e == \"symbol\" ? e.description ?? \"Unknown error\" : typeof e == \"bigint\" ? e.toString() : \"Unknown error\";\n\t}\n\treturn t === \"\" && (t = \"Unknown error\"), t;\n}\nfunction m(t) {\n\tif (!(t == null || t === \"\")) return t.length > e ? `${t.slice(0, e)}... [truncated]` : t;\n}\n//#endregion\nexport { r as APIError, n as AppError, a as ConnectorError, t as DPUseError, i as EngineError, o as FetchError, s as buildFetchError, c as concatenateSerialisedErrorMessages, l as ignoreErrors, u as normalizeToError, d as serialiseError, f as unserialiseError };\n","//#region src/component/tool/index.ts\nasync function e(e, t) {\n\tlet n = `dpuse-tool-${t}`, r = e.find((e) => e.id === n);\n\tif (!r) throw Error(`Connector could not load unknown tool '${t}'.`);\n\treturn new (await (import(`https://engine-eu.dpuse.app/tools/${t}_v${r.version}/${n}.es.js`))).Tool();\n}\n//#endregion\nexport { e as loadTool };\n","{\n \"id\": \"dpuse-connector-dropbox\",\n \"label\": {\n \"en\": \"Dropbox\"\n },\n \"description\": {\n \"en\": \"Dropbox is a cloud-based file storage solution. It provides for the storage and sharing of files, as well as synchronising them across multiple devices.\"\n },\n \"category\": null,\n \"categoryId\": \"fileStore\",\n \"implementations\": {\n \"default\": {\n \"authMethodId\": \"oAuth2\",\n \"maxConnectionCount\": -1\n }\n },\n \"icon\": \"<svg fill=\\\"none\\\" viewBox=\\\"0 0 128 128\\\"><path fill=\\\"#0061FE\\\" d=\\\"M0 0h128v128H0z\\\"/><path fill=\\\"#F7F5F2\\\" d=\\\"M43.7 32 23.404 44.75 43.701 57.5 64 44.75 84.3 57.5l20.298-12.75L84.299 32 64.002 44.75 43.7 32Zm0 51L23.404 70.25 43.701 57.5 64 70.25 43.702 83Zm20.302-12.75L84.299 57.5l20.298 12.75L84.299 83 64.002 70.25Zm0 29.75L43.7 87.25 64 74.5l20.3 12.75L64.002 100Z\\\"/></svg>\",\n \"iconDark\": \"\",\n \"lastUpdatedAt\": null,\n \"operations\": [\n \"abortOperation\",\n \"authenticateConnection\",\n \"auditObjectContent\",\n \"findObject\",\n \"getReadableStream\",\n \"listNodes\",\n \"previewObject\",\n \"retrieveRecords\"\n ],\n \"status\": null,\n \"statusId\": \"beta\",\n \"typeId\": \"connector\",\n \"usageId\": \"source\",\n \"vendorAccountURL\": null,\n \"vendorDocumentationURL\": null,\n \"vendorHomeURL\": null,\n \"version\": \"0.2.476\"\n}","// External dependencies\n\n// DPU framework\nimport type { EngineUtilities } from '@dpuse/dpuse-shared/engine';\nimport { normalizeToError } from '@dpuse/dpuse-shared/errors';\nimport type {\n AuditObjectContentOptions,\n AuditObjectContentResult,\n ConnectionConfig,\n ConnectorConfig,\n ConnectorInterface,\n FindObjectOptions,\n FindObjectResult,\n GetReadableStreamOptions,\n ListNodesOptions,\n ListNodesResult,\n PreviewObjectOptions,\n RetrievalTypeId,\n RetrieveRecordsOptions,\n RetrieveRecordsSummary\n} from '@dpuse/dpuse-shared/component/connector';\nimport { loadTool, type ToolConfig } from '@dpuse/dpuse-shared/component/tool';\nimport type { ParsingRecord, PreviewConfig } from '@dpuse/dpuse-shared/component/dataView';\n\n// DPU tools\nimport type { Tool as CSVParseTool } from '@dpuse/dpuse-tool-csv-parse';\nimport type { Tool as FileOperatorsTool } from '@dpuse/dpuse-tool-file-operators';\n\n// Data\nimport config from '~/config.json';\n\n// Constants\nconst AUTHORISE_URL = 'https://www.dropbox.com/oauth2/authorize';\nconst CLIENT_ID = 'lo38r2co3ixibhn';\nconst REDIRECT_URI = 'https://api.dpuse.app/authenticate';\n\n// Connectors\nexport class Connector implements ConnectorInterface {\n abortController: AbortController | undefined;\n readonly config: ConnectorConfig;\n engineUtilities: EngineUtilities;\n readonly toolConfigs;\n\n constructor(engineUtilities: EngineUtilities, toolConfigs: ToolConfig[]) {\n this.abortController = undefined;\n this.config = config as ConnectorConfig;\n this.engineUtilities = engineUtilities;\n this.toolConfigs = toolConfigs;\n }\n\n // Operations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n // Abort the currently running operation\n abortOperation(): void {\n if (!this.abortController) return;\n this.abortController.abort();\n this.abortController = undefined;\n }\n\n // Authenticate a connection.\n authenticateConnection(accountId: string, windowCenterX: number, windowCenterY: number): Window | undefined {\n const url =\n AUTHORISE_URL +\n `?client_id=${CLIENT_ID}` +\n '&force_reapprove=true' +\n `&redirect_uri=${REDIRECT_URI}` +\n '&response_type=code' +\n `&state=dropbox|${accountId}}` +\n '&token_access_type=offline';\n const popupHeight = 800;\n const popupWidth = 700;\n const popupLeft = windowCenterX - popupWidth / 2;\n const popupTop = windowCenterY - popupHeight / 2;\n const popup = window.open(url, 'DPUseAuthenticationWindow', `height=${popupHeight},width=${popupWidth},top=${popupTop},left=${popupLeft}`);\n if (popup == null) return undefined;\n popup.focus();\n return popup;\n }\n\n // Audit object content\n async auditObjectContent(options: AuditObjectContentOptions, chunk: (rowCount: number) => void): Promise<AuditObjectContentResult> {\n this.abortController = new AbortController();\n\n try {\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n const parseStreamOptions = { delimiter: options.valueDelimiterId, relax_column_count: true, relax_quotes: true };\n return { processedRowCount: 0, durationMs: 0 };\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n\n // Find the folder path containing the specified object node\n findObject(options: FindObjectOptions): Promise<FindObjectResult> {\n return Promise.reject(new Error('Not found.')); // Not found.\n }\n\n // Get a readable stream for the specified object node path\n async getReadableStream(options: GetReadableStreamOptions): Promise<ReadableStream<Uint8Array>> {\n // Create an abort controller and extract its signal.\n const { signal } = (this.abortController = new AbortController());\n\n try {\n return await Promise.resolve({} as ReadableStream<Uint8Array>);\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n\n // Lists all nodes (folders and objects) in the specified folder path\n listNodes(options: ListNodesOptions): Promise<ListNodesResult> {\n return Promise.resolve({} as ListNodesResult);\n }\n\n // Preview the contents of the object node with the specified path\n async previewObject(options: PreviewObjectOptions): Promise<PreviewConfig> {\n // Create an abort controller and extract its signal.\n const { signal } = (this.abortController = new AbortController());\n\n try {\n const asAt = Date.now();\n const startedAt = performance.now();\n\n // Preview file to determine file format and decode text.\n const fileOperatorsTool = await loadTool<FileOperatorsTool>(this.toolConfigs, 'file-operators');\n\n // Parse text, identify delimiters, and produce string value records.\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n\n return {} as PreviewConfig;\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n // Retrieves all records from a CSV object node using streaming and chunked processing\n async retrieveRecords(\n options: RetrieveRecordsOptions,\n chunk: (typeId: RetrievalTypeId, records: ParsingRecord[]) => void,\n complete: (result: RetrieveRecordsSummary) => void\n ): Promise<void> {\n this.abortController = new AbortController();\n try {\n const csvParseTool = await loadTool<CSVParseTool>(this.toolConfigs, 'csv-parse');\n const parseStreamOptions = { delimiter: options.valueDelimiterId, info: true, relax_column_count: true, relax_quotes: true };\n complete({} as RetrieveRecordsSummary);\n } catch (error) {\n throw normalizeToError(error);\n } finally {\n this.abortController = undefined;\n }\n }\n}\n"],"x_google_ignoreList":[0,1],"mappings":";AA6CA,SAAS,EAAE,GAAG;AACb,KAAI,aAAa,MAAO,QAAO;AAC/B,KAAI,OAAO,KAAK,SAAU,QAAO,MAAM,EAAE;AACzC,KAAI,OAAO,KAAK,YAAY,OAAO,KAAK,aAAa,OAAO,KAAK,SAAU,QAAO,MAAM,OAAO,EAAE,CAAC;AAClG,KAAI,OAAO,KAAK,SAAU,QAAO,MAAM,EAAE,eAAe,gBAAgB;AACxE,KAAI,OAAO,KAAK,SAAU,KAAI;AAC7B,SAAO,MAAM,KAAK,UAAU,EAAE,CAAC;SACxB;AACP,SAAuB,sBAAM,gBAAgB;;AAE9C,QAAuB,sBAAM,gBAAgB;;;;ACtD9C,eAAe,EAAE,GAAG,GAAG;CACtB,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE,MAAM,MAAM,EAAE,OAAO,EAAE;AACxD,KAAI,CAAC,EAAG,OAAM,MAAM,0CAA0C,EAAE,IAAI;AACpE,QAAO,KAAK,OAAO,OAAO,qCAAqC,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GE6BhG,IAAY,mBACZ,IAAe,sCAGR,IAAb,MAAqD;CACjD;CACA;CACA;CACA;CAEA,YAAY,GAAkC,GAA2B;AAIrE,EAHA,KAAK,kBAAkB,KAAA,GACvB,KAAK,SAAS,GACd,KAAK,kBAAkB,GACvB,KAAK,cAAc;;CAMvB,iBAAuB;AACd,EAEL,KAAK,qBADL,KAAK,gBAAgB,OAAO,EACL,KAAA;;CAI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AAuB,KAAK,aAAa,YAAY,EACxC,EAAQ,kBAChD,EAAS,EAAE,CAA2B;WACjC,GAAO;AACZ,SAAM,EAAiB,EAAM;YACvB;AACN,QAAK,kBAAkB,KAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EngineUtilities } from '@dpuse/dpuse-shared/engine';
|
|
2
|
-
import { AuditObjectContentOptions, AuditObjectContentResult,
|
|
2
|
+
import { AuditObjectContentOptions, AuditObjectContentResult, ConnectorConfig, ConnectorInterface, FindObjectOptions, FindObjectResult, GetReadableStreamOptions, ListNodesOptions, ListNodesResult, PreviewObjectOptions, RetrievalTypeId, RetrieveRecordsOptions, RetrieveRecordsSummary } from '@dpuse/dpuse-shared/component/connector';
|
|
3
3
|
import { ToolConfig } from '@dpuse/dpuse-shared/component/tool';
|
|
4
4
|
import { ParsingRecord, PreviewConfig } from '@dpuse/dpuse-shared/component/dataView';
|
|
5
5
|
export declare class Connector implements ConnectorInterface {
|
|
@@ -9,7 +9,7 @@ export declare class Connector implements ConnectorInterface {
|
|
|
9
9
|
readonly toolConfigs: ToolConfig[];
|
|
10
10
|
constructor(engineUtilities: EngineUtilities, toolConfigs: ToolConfig[]);
|
|
11
11
|
abortOperation(): void;
|
|
12
|
-
|
|
12
|
+
authenticateConnection(accountId: string, windowCenterX: number, windowCenterY: number): Window | undefined;
|
|
13
13
|
auditObjectContent(options: AuditObjectContentOptions, chunk: (rowCount: number) => void): Promise<AuditObjectContentResult>;
|
|
14
14
|
findObject(options: FindObjectOptions): Promise<FindObjectResult>;
|
|
15
15
|
getReadableStream(options: GetReadableStreamOptions): Promise<ReadableStream<Uint8Array>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dpuse/dpuse-connector-dropbox",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.476",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Jonathan Terrell <terrell.jm@gmail.com>",
|
|
6
6
|
"private": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"prettier": "@dpuse/dpuse-development/prettierrc",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dpuse/dpuse-shared": "^0.3.
|
|
29
|
+
"@dpuse/dpuse-shared": "^0.3.599",
|
|
30
30
|
"@dpuse/dpuse-tool-csv-parse": "^0.0.141",
|
|
31
31
|
"@dpuse/dpuse-tool-file-operators": "^0.0.17",
|
|
32
32
|
"p-queue": "^9.1.0"
|