From cf480d6e1ea1102d7a566d50faec749efc75b87e Mon Sep 17 00:00:00 2001 From: Alex Milenkovic Date: Tue, 13 Jun 2023 18:02:53 +0200 Subject: [PATCH 1/4] update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38f1191..d7e0da0 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@seneca/env": ">=0.2" }, "devDependencies": { - "@seneca/doc": "^4.1.0", + "@seneca/doc": "^4.2.4", "@seneca/maintain": "0.0.28", "@types/jest": "^28.1.4", "@types/node": "^18.0.3", From 156262ad59c89b82bb897e5655d24c7464b1332f Mon Sep 17 00:00:00 2001 From: Alex Milenkovic Date: Tue, 13 Jun 2023 18:03:14 +0200 Subject: [PATCH 2/4] update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d7e0da0..956b44d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-watch": "jest --coverage --watchAll", "watch": "tsc -w -d", "build": "tsc -d", - "doc": "echo seneca-doc -p @seneca/provider FIX-broken", + "doc": "seneca-doc -p @seneca/provider FIX-broken", "clean": "rm -rf node_modules dist yarn.lock package-lock.json", "reset": "npm run clean && npm i && npm test", "repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;", From abbd9fce5d3af149deec69b9157f3a97b8f1f84c Mon Sep 17 00:00:00 2001 From: Alex Milenkovic Date: Tue, 13 Jun 2023 18:09:38 +0200 Subject: [PATCH 3/4] commit --- README.md | 43 ++++++++++++++++----------------------- src/TrelloProvider-doc.ts | 24 +++++++++++++++++++--- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 2d65f1a..c9a5427 100644 --- a/README.md +++ b/README.md @@ -77,22 +77,7 @@ $ npm install @seneca/trello-provider @seneca/env ## Options -* `debug` : boolean false - - -Set plugin options when loading with: -```js - - -seneca.use('TrelloProvider', { name: value, ... }) - - -``` - - -Note: foo.bar in the list above means -{ foo: { bar: ... } } - +*None.* @@ -102,9 +87,10 @@ seneca.use('TrelloProvider', { name: value, ... }) ## Action Patterns -* [role:entity,base:trello,cmd:load,name:repo,zone:provider](#-roleentitybasetrellocmdloadnamerepozoneprovider-) -* [role:entity,base:trello,cmd:save,name:repo,zone:provider](#-roleentitybasetrellocmdsavenamerepozoneprovider-) -* [sys:provider,get:info,provider:trello](#-sysprovidergetinfoprovidertrello-) +* ["role":"entity","base":"trello","cmd":"list","name":"board","zone":"provider"](#-roleentitybasetrellocmdlistnameboardzoneprovider-) +* ["role":"entity","base":"trello","cmd":"load","name":"board","zone":"provider"](#-roleentitybasetrellocmdloadnameboardzoneprovider-) +* ["role":"entity","base":"trello","cmd":"save","name":"board","zone":"provider"](#-roleentitybasetrellocmdsavenameboardzoneprovider-) +* ["sys":"provider","get":"info","provider":"trello"](#-sysprovidergetinfoprovidertrello-) @@ -114,23 +100,30 @@ seneca.use('TrelloProvider', { name: value, ... }) ## Action Descriptions -### « `role:entity,base:trello,cmd:load,name:repo,zone:provider` » +### « `"role":"entity","base":"trello","cmd":"list","name":"board","zone":"provider"` » + +List Trello data into an entity + + + +---------- +### « `"role":"entity","base":"trello","cmd":"load","name":"board","zone":"provider"` » -Load Trello repository data into an entity. +Load Trello data into an entity ---------- -### « `role:entity,base:trello,cmd:save,name:repo,zone:provider` » +### « `"role":"entity","base":"trello","cmd":"save","name":"board","zone":"provider"` » -Update Trello repository data from an entity. +Save/Update Trello data into an entity ---------- -### « `sys:provider,get:info,provider:trello` » +### « `"sys":"provider","get":"info","provider":"trello"` » -Get information about the provider. +Get information about the Trello SDK. diff --git a/src/TrelloProvider-doc.ts b/src/TrelloProvider-doc.ts index 7d9d2f1..a0df3e3 100644 --- a/src/TrelloProvider-doc.ts +++ b/src/TrelloProvider-doc.ts @@ -1,16 +1,34 @@ /* Copyright © 2022 Seneca Project Contributors, MIT License. */ -const docs = { +const messages = { get_info: { desc: 'Get information about the Trello SDK.', }, + save_board: { + desc: 'Save/Update Trello data into an entity', + }, + load_board: { + desc: 'Load Trello data into an entity', + }, + list_board: { + desc: 'List Trello data into an entity', + }, + } -export default docs +const sections = {} + +export default { + messages, + sections +} if ('undefined' !== typeof (module)) { - module.exports = docs + module.exports = { + messages, + sections + } } From 3fdc01461fbf2fa973e306d39c152e25cb9f32a2 Mon Sep 17 00:00:00 2001 From: Alex Milenkovic Date: Tue, 13 Jun 2023 18:10:15 +0200 Subject: [PATCH 4/4] add dist --- dist/TrelloProvider-doc.d.ts | 18 +++++ dist/TrelloProvider-doc.js | 29 ++++++++ dist/TrelloProvider-doc.js.map | 1 + dist/trello-provider.d.ts | 7 ++ dist/trello-provider.js | 117 +++++++++++++++++++++++++++++++++ dist/trello-provider.js.map | 1 + 6 files changed, 173 insertions(+) create mode 100644 dist/TrelloProvider-doc.d.ts create mode 100644 dist/TrelloProvider-doc.js create mode 100644 dist/TrelloProvider-doc.js.map create mode 100644 dist/trello-provider.d.ts create mode 100644 dist/trello-provider.js create mode 100644 dist/trello-provider.js.map diff --git a/dist/TrelloProvider-doc.d.ts b/dist/TrelloProvider-doc.d.ts new file mode 100644 index 0000000..b811f61 --- /dev/null +++ b/dist/TrelloProvider-doc.d.ts @@ -0,0 +1,18 @@ +declare const _default: { + messages: { + get_info: { + desc: string; + }; + save_board: { + desc: string; + }; + load_board: { + desc: string; + }; + list_board: { + desc: string; + }; + }; + sections: {}; +}; +export default _default; diff --git a/dist/TrelloProvider-doc.js b/dist/TrelloProvider-doc.js new file mode 100644 index 0000000..df1f2d6 --- /dev/null +++ b/dist/TrelloProvider-doc.js @@ -0,0 +1,29 @@ +"use strict"; +/* Copyright © 2022 Seneca Project Contributors, MIT License. */ +Object.defineProperty(exports, "__esModule", { value: true }); +const messages = { + get_info: { + desc: 'Get information about the Trello SDK.', + }, + save_board: { + desc: 'Save/Update Trello data into an entity', + }, + load_board: { + desc: 'Load Trello data into an entity', + }, + list_board: { + desc: 'List Trello data into an entity', + }, +}; +const sections = {}; +exports.default = { + messages, + sections +}; +if ('undefined' !== typeof (module)) { + module.exports = { + messages, + sections + }; +} +//# sourceMappingURL=TrelloProvider-doc.js.map \ No newline at end of file diff --git a/dist/TrelloProvider-doc.js.map b/dist/TrelloProvider-doc.js.map new file mode 100644 index 0000000..6b9b671 --- /dev/null +++ b/dist/TrelloProvider-doc.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TrelloProvider-doc.js","sourceRoot":"","sources":["../src/TrelloProvider-doc.ts"],"names":[],"mappings":";AAAA,gEAAgE;;AAGhE,MAAM,QAAQ,GAAG;IAEf,QAAQ,EAAE;QACR,IAAI,EAAE,uCAAuC;KAC9C;IAED,UAAU,EAAE;QACV,IAAI,EAAE,wCAAwC;KAC/C;IACD,UAAU,EAAE;QACV,IAAI,EAAE,iCAAiC;KACxC;IACD,UAAU,EAAE;QACV,IAAI,EAAE,iCAAiC;KACxC;CAEF,CAAA;AAED,MAAM,QAAQ,GAAG,EAAE,CAAA;AAEnB,kBAAe;IACb,QAAQ;IACR,QAAQ;CACT,CAAA;AAED,IAAI,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE;IACnC,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ;QACR,QAAQ;KACT,CAAA;CACF"} \ No newline at end of file diff --git a/dist/trello-provider.d.ts b/dist/trello-provider.d.ts new file mode 100644 index 0000000..44dedff --- /dev/null +++ b/dist/trello-provider.d.ts @@ -0,0 +1,7 @@ +type TrelloProviderOptions = {}; +declare function TrelloProvider(this: any, _options: TrelloProviderOptions): { + exports: { + sdk: () => any; + }; +}; +export default TrelloProvider; diff --git a/dist/trello-provider.js b/dist/trello-provider.js new file mode 100644 index 0000000..330a4d3 --- /dev/null +++ b/dist/trello-provider.js @@ -0,0 +1,117 @@ +"use strict"; +/* Copyright © 2022 Seneca Project Contributors, MIT License. */ +Object.defineProperty(exports, "__esModule", { value: true }); +const Pkg = require('../package.json'); +const Trello = require('trello'); +function TrelloProvider(_options) { + const seneca = this; + const entityBuilder = this.export('provider/entityBuilder'); + seneca + .message('sys:provider,provider:trello,get:info', get_info); + async function get_info(_msg) { + return { + ok: true, + name: 'trello', + version: Pkg.version, + sdk: { + name: 'trello', + version: Pkg.dependencies['trello'], + } + }; + } + entityBuilder(this, { + provider: { + name: 'trello' + }, + entity: { + board: { + cmd: { + list: { + action: async function (entize, msg) { + let q = msg.q || {}; + let member = q.member || 'me'; + let res = await this.shared.sdk.getBoards(member); + let list = res.map((data) => entize(data)); + return list; + } + }, + load: { + action: async function (entize, msg) { + let q = msg.q || {}; + let id = q.id; + try { + let res = await this.shared.sdk.getBoard(id); + return entize(res); + } + catch (e) { + if (e.message.includes('invalid id')) { + return null; + } + else { + throw e; + } + } + } + }, + save: { + action: async function (entize, msg) { + let ent = msg.ent; + try { + let res; + if (ent.id) { + // TODO: util to handle more fields + res = await this.shared.sdk.updateBoard(ent.id, { + desc: ent.desc + }); + } + else { + // TODO: util to handle more fields + let fields = { + name: ent.name, + desc: ent.desc, + }; + res = await this.shared.sdk.addBoard(fields); + } + return entize(res); + } + catch (e) { + if (e.message.includes('invalid id')) { + return null; + } + else { + throw e; + } + } + } + } + } + } + } + }); + seneca.prepare(async function () { + let seneca = this; + let res = await seneca.post('sys:provider,get:keymap,provider:trello'); + if (!res.ok) { + this.fail('stytch-missing-keymap', res); + } + let apikey = res.keymap.apikey.value; + let usertoken = res.keymap.apikey.value; + this.shared.sdk = new Trello(apikey, usertoken); + }); + return { + exports: { + sdk: () => this.shared.sdk + } + }; +} +// Default options. +const defaults = { + // TODO: Enable debug logging + debug: false +}; +Object.assign(TrelloProvider, { defaults }); +exports.default = TrelloProvider; +if ('undefined' !== typeof (module)) { + module.exports = TrelloProvider; +} +//# sourceMappingURL=trello-provider.js.map \ No newline at end of file diff --git a/dist/trello-provider.js.map b/dist/trello-provider.js.map new file mode 100644 index 0000000..54c5d0c --- /dev/null +++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