esm init registry | vfs | discourse
This commit is contained in:
parent
43997a8f35
commit
283d516331
5
packages/.gitignore
vendored
Normal file
5
packages/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/node_modules
|
||||
/coverage
|
||||
*.log
|
||||
.DS_Store
|
||||
part-registry
|
||||
5
packages/discourse/.gitignore
vendored
Normal file
5
packages/discourse/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/node_modules
|
||||
/coverage
|
||||
*.log
|
||||
.DS_Store
|
||||
tmp
|
||||
4
packages/discourse/.npmignore
Normal file
4
packages/discourse/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
./docs
|
||||
./scripts
|
||||
./tests
|
||||
./incoming
|
||||
178
packages/discourse/.vscode/launch.json
vendored
Normal file
178
packages/discourse/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Import - OA-Users ",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"import-users",
|
||||
"import",
|
||||
"--src='${OA_ROOT}/data/latest.json'",
|
||||
"--debug=true"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"console": "internalConsole",
|
||||
"outputCapture": "std",
|
||||
"trace": true
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Update - OA-Users ",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"import-users",
|
||||
"update",
|
||||
"--src='${OA_ROOT}/data/latest.json'",
|
||||
"--debug=true"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"console": "internalConsole",
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Index - OA-Users ",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"import-users",
|
||||
"index",
|
||||
"--src='${OA_ROOT}/data/latest.json'",
|
||||
"--debug=true"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"console": "internalConsole",
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Import - OA-Howtos",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"import-howtos",
|
||||
// "--src='${OA_ROOT}/data/latest.json'",
|
||||
"--track='${OA_ROOT}/oa-data/howtos/latest_track.json'",
|
||||
"--debug=true"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "test sync:fs",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"sync",
|
||||
"file",
|
||||
"--yaml=true",
|
||||
"--src='./tests/**/*.md'"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "test sync:component",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"sync-component",
|
||||
"--src='${PRODUCT_ROOT}/products/'"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "test sync:forum-pages",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"sync-component",
|
||||
"--src='${OSR_ROOT}/osr-forum-pages/pages/kb/**/*.md'",
|
||||
"--watch",
|
||||
"--yaml",
|
||||
"--sync=mine"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "test sync:library",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||
"args": [
|
||||
"sync-component",
|
||||
"--cache=true",
|
||||
"--skip=true",
|
||||
"--src2='${OSR_LIBRARY_MACHINES}/injection/**/config.+(json)'",
|
||||
"--src2='${OSR_LIBRARY_MACHINES}/extrusion/**/config.+(json)'",
|
||||
"--src='${OSR_LIBRARY_MACHINES}/sheetpress/**/config.+(json)'",
|
||||
"--src2='${OSR_LIBRARY_MACHINES}/shredder/**/config.+(json)'",
|
||||
"--src2='${OSR_LIBRARY_MACHINES}/zoe/config.+(json)'",
|
||||
// "--src='${OSR_LIBRARY_MACHINES}/combo/IntegrationUnitMonash/config.+(json)'",
|
||||
"--src1='${OSR_LIBRARY_MACHINES}/injection/**/config.+(json)'",
|
||||
//"--src='${OSR_LIBRARY_MACHINES}/sheetpress/cassandra-light/config.+(json)'",
|
||||
"--root='${OSR_LIBRARY_MACHINES}'",
|
||||
"--sync=mine",
|
||||
"--logLevel=debug"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"outputCapture": "std"
|
||||
}
|
||||
]
|
||||
}
|
||||
9
packages/discourse/.vscode/settings.json
vendored
Normal file
9
packages/discourse/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Discorse",
|
||||
"OSRL",
|
||||
"plastichub",
|
||||
"Salamand"
|
||||
],
|
||||
"cmake.configureOnOpen": false
|
||||
}
|
||||
9
packages/discourse/LICENSE
Normal file
9
packages/discourse/LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
Copyright (c) <year> <owner> All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
161
packages/discourse/README.md
Normal file
161
packages/discourse/README.md
Normal file
@ -0,0 +1,161 @@
|
||||
# Discourse library and CLI for OSR content
|
||||
|
||||
## Commands
|
||||
|
||||
### `info`
|
||||
|
||||
#### Print configuration and commands
|
||||
|
||||
```
|
||||
osr-discourse info
|
||||
```
|
||||
|
||||
### `deploy`
|
||||
|
||||
Create/Update post from directory, using OSR-Specs
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse deploy --src="./*"
|
||||
|
||||
```
|
||||
|
||||
### `sync <file>`
|
||||
|
||||
Sync file
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse sync <file>
|
||||
|
||||
--src="<filepath.HTML|MD|OSR / glob / pipe>"
|
||||
--cat=<category id>
|
||||
--owner="user_name|user_id"
|
||||
--config=<OSR Config Hash>
|
||||
--timestamp=<default=now>
|
||||
--download-assets=true|false
|
||||
--tags=<tag ids | tag names>
|
||||
|
||||
```
|
||||
|
||||
### `sync-kb`
|
||||
|
||||
Create/Update/Sync kb from directory
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse sync --src="./*"
|
||||
|
||||
```
|
||||
|
||||
### `list`
|
||||
|
||||
List posts per category or search query
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse list --query="discourse-query" --dst="output.[json|xls|csv]" --fields="[post-fields]"
|
||||
|
||||
```
|
||||
|
||||
### `oa-user-import`
|
||||
|
||||
Imports oa-users from dump file
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse oa-user --src="raw.json"
|
||||
|
||||
```
|
||||
|
||||
### `ig-user-sync`
|
||||
|
||||
Imports IG users from dump file
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse ig-user sync --src="raw.json"
|
||||
|
||||
```
|
||||
|
||||
### `osr-commons-sync`
|
||||
|
||||
Sync all osr-commons ( taxonomy )
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse osr-sync --src="path to commons (JSON)"
|
||||
|
||||
```
|
||||
|
||||
### `pm`
|
||||
|
||||
Notify all users, using Discourse private message
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse pm --src="path to message (MD|HTML)" --groups="osr groups"
|
||||
|
||||
```
|
||||
|
||||
### `invite`
|
||||
|
||||
Send invite to a list of users, common MC/OSR CSV format
|
||||
|
||||
**usage**
|
||||
|
||||
```sh
|
||||
|
||||
osr-discourse invite --src="path to message (MD|HTML)" --src="path to CSV"
|
||||
|
||||
```
|
||||
|
||||
## Library / API
|
||||
|
||||
## References
|
||||
|
||||
- [ts-json-schema-generator - issue - functions](https://github.com/loopingz/webda.io/blob/main/packages/shell/src/code/compiler.ts#L154-243)
|
||||
|
||||
### Todos
|
||||
|
||||
////////////////////////
|
||||
//
|
||||
// 1. Fetch Tags
|
||||
// 2. Populate Tags
|
||||
// 3. Download (oa-bot)
|
||||
// 4. Sync - Assets (osr-machines)
|
||||
// 5. Ensure/Find user
|
||||
//
|
||||
// Content
|
||||
//
|
||||
// Body (descr full)
|
||||
// each step
|
||||
// footer (refs)
|
||||
// set tags
|
||||
// set ts
|
||||
//
|
||||
// Post
|
||||
// -> sync lib
|
||||
// -> translate -> lib
|
||||
// -> digest
|
||||
// -> notifications
|
||||
// -> index
|
||||
// -> update ext refs
|
||||
// -> market place
|
||||
// -> sync externals (git, ...)
|
||||
3
packages/discourse/_cli.d.ts
vendored
Normal file
3
packages/discourse/_cli.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { IOptions, IOptionsSync } from './types';
|
||||
export declare const defaults: () => void;
|
||||
export declare const sanitize: (argv: any) => IOptionsSync | IOptions | boolean;
|
||||
71
packages/discourse/_cli.js
Normal file
71
packages/discourse/_cli.js
Normal file
@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sanitize = exports.defaults = void 0;
|
||||
const exists_1 = require("@plastichub/fs/exists");
|
||||
const _1 = require("./");
|
||||
const path = require("path");
|
||||
const globBase = require('glob-base');
|
||||
const defaults = () => {
|
||||
// default command
|
||||
const DefaultCommand = 'info';
|
||||
if (process.argv.length === 2) {
|
||||
process.argv.push(DefaultCommand);
|
||||
}
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
||||
// currently no default handler, display only :
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
console.error('Unhandled rejection, reason: ', reason);
|
||||
});
|
||||
};
|
||||
exports.defaults = defaults;
|
||||
const sanitize = (argv) => {
|
||||
let ret = {
|
||||
...argv
|
||||
};
|
||||
ret.src = argv.src;
|
||||
let srcInfo;
|
||||
let variables = {};
|
||||
/*
|
||||
if (ret.src) {
|
||||
ret.src = forward_slash(substitute(ret.alt,ret.src,variables))
|
||||
// in case a file with a glob pattern is provided, strip the glob
|
||||
// this is a special case, enabling shared scripts in Alt-Tap Salamand
|
||||
const glob_base = globBase(ret.src)
|
||||
const file = ret.src.replace(glob_base.glob, '').replace(/\/$/, '')
|
||||
|
||||
if(exists(file) && isFile(file)){
|
||||
ret.src = file
|
||||
}
|
||||
|
||||
srcInfo = pathInfo(resolve(ret.src, ret.alt, variables))
|
||||
|
||||
if (srcInfo && srcInfo.FILES && srcInfo.FILES.length) {
|
||||
ret.srcInfo = srcInfo
|
||||
for (const key in srcInfo) {
|
||||
if (Object.prototype.hasOwnProperty.call(srcInfo, key)) {
|
||||
variables['SRC_' + key] = srcInfo[key];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret.src = resolve(ret.src, ret.alt, variables)
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (argv.cwd) {
|
||||
ret.cwd = path.resolve(argv.cwd);
|
||||
if (!(0, exists_1.sync)((ret.cwd))) {
|
||||
_1.logger.error(`Invalid working directory ${argv.cwd}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret.cwd = process.cwd();
|
||||
}
|
||||
ret = {
|
||||
...ret,
|
||||
variables,
|
||||
srcInfo
|
||||
};
|
||||
return ret;
|
||||
};
|
||||
exports.sanitize = sanitize;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiX2NsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInNyYy9fY2xpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGtEQUFzRDtBQUV0RCx5QkFBMkI7QUFDM0IsNkJBQTRCO0FBTzVCLE1BQU0sUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtBQUU5QixNQUFNLFFBQVEsR0FBRyxHQUFHLEVBQUU7SUFDekIsa0JBQWtCO0lBQ2xCLE1BQU0sY0FBYyxHQUFHLE1BQU0sQ0FBQztJQUM5QixJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRTtRQUMzQixPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQztLQUNyQztJQUVELE9BQU8sQ0FBQyxHQUFHLENBQUMsOEJBQThCLENBQUMsR0FBRyxHQUFHLENBQUM7SUFFbEQsK0NBQStDO0lBQy9DLE9BQU8sQ0FBQyxFQUFFLENBQUMsb0JBQW9CLEVBQUUsQ0FBQyxNQUFjLEVBQUUsRUFBRTtRQUNoRCxPQUFPLENBQUMsS0FBSyxDQUFDLCtCQUErQixFQUFFLE1BQU0sQ0FBQyxDQUFDO0lBQzNELENB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AAI,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,IAAA,aAAM,EAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;YACpB,SAAM,CAAC,KAAK,CAAC,6BAA6B,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;SACzD;KACJ;SAAM;QACH,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;KAC3B;IAED,GAAG,mCACI,GAAG,GACH,EAAE,SAAS,EAAE,EAAE,EAAE,CACvB,CAAA;IAED,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AA/BW,QAAA,QAAQ,YA+BnB"}
|
||||
85
packages/discourse/_package.json
Normal file
85
packages/discourse/_package.json
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
"name": "@plastichub/osr-discourse",
|
||||
"description": "",
|
||||
"version": "0.1.9",
|
||||
"typings": "index.d.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"module": "main.js",
|
||||
"main": "main.js",
|
||||
"bin": {
|
||||
"osr-discourse": "main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"@plastichub/core": "^0.2.5",
|
||||
"@plastichub/fs": "^0.13.39",
|
||||
"@plastichub/osr-cache": "^0.4.7",
|
||||
"@plastichub/osr-cli-commons": "^0.5.1",
|
||||
"@plastichub/osr-commons": "^0.3.3",
|
||||
"@plastichub/osr-fs-utils": "^0.1.4",
|
||||
"@plastichub/osrl": "file:../osrl",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@types/node": "^14.17.5",
|
||||
"@types/yargs": "^17.0.11",
|
||||
"axios": "^0.27.2",
|
||||
"bluebird": "^3.7.2",
|
||||
"chalk": "^2.4.1",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"chokidar": "^3.5.3",
|
||||
"download": "^8.0.0",
|
||||
"env-var": "^7.1.1",
|
||||
"escape-html": "^1.0.3",
|
||||
"fast-glob": "^3.3.0",
|
||||
"filenamify": "^4.3.0",
|
||||
"find-up": "^5.0.0",
|
||||
"front-matter": "^4.0.2",
|
||||
"generate-password": "^1.7.0",
|
||||
"glob-base": "^0.3.0",
|
||||
"isomorphic-unfetch": "^4.0.2",
|
||||
"js-base64": "^3.7.2",
|
||||
"js-beautify": "^1.14.9",
|
||||
"json-to-pretty-yaml": "^1.2.2",
|
||||
"markdown-it": "^13.0.1",
|
||||
"md5": "^2.3.0",
|
||||
"moment": "^2.29.4",
|
||||
"native-promise-pool": "^3.19.0",
|
||||
"pretty": "^2.0.0",
|
||||
"querystring": "^0.2.1",
|
||||
"request": "^2.88.2",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"showdown": "^2.1.0",
|
||||
"simple-git": "^3.19.1",
|
||||
"slugify": "^1.6.6",
|
||||
"tslog": "^3.3.4",
|
||||
"turndown": "^7.1.2",
|
||||
"typescript": "^4.3.5",
|
||||
"uri-js": "^4.4.1",
|
||||
"yargs": "^17.5.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tsc; mocha --full-trace mocha \"spec/**/*.spec.js\"",
|
||||
"test-with-coverage": "istanbul cover node_modules/.bin/_mocha -- 'spec/**/*.spec.js'",
|
||||
"lint": "tslint --project=./tsconfig.json",
|
||||
"build": "tsc -p . --declaration",
|
||||
"dev": "tsc -p . --declaration -w",
|
||||
"typings": "tsc --declaration",
|
||||
"docs": "npx typedoc src/index.ts",
|
||||
"dev-test-watch": "mocha-typescript-watch",
|
||||
"typesafe-i18n": "typesafe-i18n",
|
||||
"link-dev": "sh scripts/link-dev.sh"
|
||||
},
|
||||
"homepage": "https://git.osr-plastic.org/plastichub/lib-content",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.osr-plastic.org/plastichub/lib-content.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.0.0"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"keywords": [
|
||||
"typescript"
|
||||
]
|
||||
}
|
||||
12
packages/discourse/commands/category.d.ts
vendored
Normal file
12
packages/discourse/commands/category.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{
|
||||
debug: boolean;
|
||||
} & {
|
||||
short: string | boolean;
|
||||
} & {
|
||||
disabled: string | boolean;
|
||||
} & {
|
||||
dry: string;
|
||||
} & {
|
||||
env_key: string;
|
||||
}>;
|
||||
103
packages/discourse/commands/category.js
Normal file
103
packages/discourse/commands/category.js
Normal file
@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const path = require("path");
|
||||
const write_1 = require("@plastichub/fs/write");
|
||||
const osr_cli_commons_1 = require("@plastichub/osr-cli-commons");
|
||||
const _cli_1 = require("../_cli");
|
||||
const options_1 = require("../options");
|
||||
const __1 = require("..");
|
||||
const lib_1 = require("../lib");
|
||||
const category_1 = require("../lib/cscart/category");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: false,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('short', {
|
||||
default: 'true',
|
||||
describe: 'Emit short info only',
|
||||
type: 'boolean'
|
||||
}).option('disabled', {
|
||||
default: 'false',
|
||||
describe: 'Enumerate disabled products',
|
||||
type: 'boolean'
|
||||
}).option('dry', {
|
||||
default: 'false',
|
||||
describe: 'Process files for debug purposes only.'
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('category <verb>', 'Category namespace', options, (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
const config = (0, osr_cli_commons_1.CONFIG_DEFAULT)(args.env_key);
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && __1.logger.debug(`CLI Args In`, argv);
|
||||
let opts = (0, options_1.parse)(options, args);
|
||||
if (!opts.verb) {
|
||||
__1.logger.error('No verb specified');
|
||||
return;
|
||||
}
|
||||
if (opts.verb == 'list') {
|
||||
let _categories = yield (0, lib_1.categories)(config.cscart);
|
||||
if (opts.dst) {
|
||||
(0, category_1.writeCategories)(_categories, opts);
|
||||
}
|
||||
else {
|
||||
__1.logger.debug('Categories', _categories);
|
||||
}
|
||||
}
|
||||
if (opts.verb == 'get') {
|
||||
let cat = yield (0, category_1.get_category)(opts.id, config.cscart);
|
||||
opts.debug && __1.logger.debug(`Get category ${opts.id} `, cat);
|
||||
if (cat && opts.dst) {
|
||||
let _path = path.resolve(opts.dst);
|
||||
(0, write_1.sync)(_path, cat);
|
||||
opts.debug && __1.logger.debug(`Writing category to ${_path}`);
|
||||
}
|
||||
}
|
||||
if (opts.verb == 'delete') {
|
||||
return yield (0, category_1.delete_category)(opts.id, config.cscart);
|
||||
}
|
||||
if (opts.verb == 'create') {
|
||||
const args = {
|
||||
category: 'cat',
|
||||
company_id: 1,
|
||||
status: 'H',
|
||||
parent_id: 6
|
||||
};
|
||||
let _item = yield (0, category_1.create_category)(args, config.cscart);
|
||||
__1.logger.debug(`Created category ! ID:`, _item);
|
||||
}
|
||||
if (opts.verb == 'update') {
|
||||
const args = {
|
||||
category: 'renamed'
|
||||
};
|
||||
let _item = yield (0, category_1.update_category)(opts.id, args, config.cscart);
|
||||
__1.logger.debug(`Updated category ! ID:${opts.id}`, _item);
|
||||
}
|
||||
return;
|
||||
}));
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=category.js.map
|
||||
1
packages/discourse/commands/category.js.map
Normal file
1
packages/discourse/commands/category.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"category.js","sourceRoot":"","sources":["../src/commands/category.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6BAA4B;AAE5B,gDAAoD;AACpD,iEAA4D;AAE5D,kCAA4C;AAC5C,wCAAkC;AAElC,0BAA2B;AAC3B,gCAAmC;AAInC,qDAM+B;AAE/B,MAAM,cAAc,GAAG,CAAC,KAAe,EAAE,EAAE;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;QACzB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,gBAAgB;QAC1B,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,sBAAsB;QAChC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACb,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,wCAAwC;KACrD,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE;QACjB,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,qCAAqC;KAClD,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,IAAI,OAAO,GAAG,CAAC,KAAe,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAElD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B"}
|
||||
2
packages/discourse/commands/import-oa-howtos.d.ts
vendored
Normal file
2
packages/discourse/commands/import-oa-howtos.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
53
packages/discourse/commands/import-oa-howtos.js
Normal file
53
packages/discourse/commands/import-oa-howtos.js
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const _cli_1 = require("../_cli");
|
||||
const index_1 = require("../index");
|
||||
const discourse_1 = require("../lib/discourse");
|
||||
const commons_1 = require("../lib/oa/commons");
|
||||
const howtos_1 = require("../lib/oa/howtos");
|
||||
const path = require("path");
|
||||
const fs_1 = require("@plastichub/osr-commons");
|
||||
const KB_ROOT = '${KB_ROOT}';
|
||||
const osr_commons_1 = require("@plastichub/osr-commons");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: true,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('src', {
|
||||
default: osr_commons_1.OA_LATEST,
|
||||
type: 'string',
|
||||
}).option('track', {
|
||||
default: '${OA_ROOT}/oa-data/howtos/latest_track.json',
|
||||
type: 'string',
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('import-howtos', 'Import oa-howtos', options, async (argv) => {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
let options = argv;
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && index_1.logger.debug(`CLI Args In`, argv);
|
||||
const discourse = (0, discourse_1.Instance)();
|
||||
const _opts = {
|
||||
src: path.resolve((0, fs_1.resolve)(options.src)),
|
||||
track: path.resolve((0, fs_1.resolve)(options.track))
|
||||
};
|
||||
let howtos = (0, commons_1.read_howtos)(_opts.src);
|
||||
howtos = (0, commons_1.filter_valid)(howtos);
|
||||
await (0, howtos_1.importHowtos)(discourse, _opts, howtos);
|
||||
await (0, howtos_1.updateHowtos)(discourse, _opts, howtos);
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0LW9hLWhvd3Rvcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9jb21tYW5kcy9pbXBvcnQtb2EtaG93dG9zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLGtDQUE0QztBQUU1QyxvQ0FBOEM7QUFFOUMsZ0RBQTJDO0FBZTNDLCtDQUswQjtBQUUxQiw2Q0FFeUI7QUFRekIsNkJBQTRCO0FBQzVCLHVEQUF3RDtBQUd4RCxNQUFNLE9BQU8sR0FBRyxZQUFZLENBQUE7QUFRNUIseURBQW1EO0FBRW5ELE1BQU0sY0FBYyxHQUFHLENBQUMsS0FBZSxFQUFFLEVBQUU7SUFDdkMsT0FBTyxLQUFLLENBQUMsTUFBTSxDQUFDLE9BQU8sRUFBRTtRQUN6QixPQUFPLEVBQUUsSUFBSTtRQUNiLFFBQVEsRUFBRSxnQkFBZ0I7UUFDMUIsSUFBSSxFQUFFLFNBQVM7S0FDbEIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUU7UUFDYixPQUFPLEVBQUUsdUJBQVM7UUFDbEIsSUFBSSxFQUFFLFFBQVE7S0FDakIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxPQUFPLEVBQUU7UUFDZixPQUFPLEVBQUUsNkNBQTZDO1FBQ3RELElBQUksRUFBRSxRQUFRO0tBQ2pCLENBQUMsQ0FBQyxNQUFNLENBQUMsU0FBUyxFQUFFO1FBQ2pCLE9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QyxNQUFNLEdBQUcsSUFBQSxzQkFBWSxFQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQzdCLE1BQU0sSUFBQSxxQkFBWSxFQUFDLFNBQVMsRUFBQyxLQUFLLEVBQUMsTUFBTSxDQUFDLENBQUE7UUFDMUMsTUFBTSxJQUFBLHFCQUFZLEVBQUMsU0FBUyxFQUFDLEtBQUssRUFBQyxNQUFNLENBQUMsQ0FBQTtJQUM5QyxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQTtBQXZCWSxRQUFBLFFBQVEsWUF1QnBCIn0=
|
||||
2
packages/discourse/commands/import-oa-users.d.ts
vendored
Normal file
2
packages/discourse/commands/import-oa-users.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
88
packages/discourse/commands/import-oa-users.js
Normal file
88
packages/discourse/commands/import-oa-users.js
Normal file
@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const _cli_1 = require("../_cli");
|
||||
const options_1 = require("../options");
|
||||
const index_1 = require("../index");
|
||||
const discourse_1 = require("../lib/discourse");
|
||||
const write_1 = require("@plastichub/fs/write");
|
||||
const users_1 = require("../lib/oa/users");
|
||||
const path = require("path");
|
||||
const fs_1 = require("@plastichub/osr-commons");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: false,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('src', {
|
||||
default: '${OA_ROOT}/data/latest.json',
|
||||
type: 'string',
|
||||
}).option('track', {
|
||||
default: '${OSR_ROOT}/osr-directory/pp/merged.json',
|
||||
type: 'string',
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('import-users <verb>', 'Import oa-users', options, async (argv) => {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && index_1.logger.debug(`CLI Args In`, argv);
|
||||
let opts = (0, options_1.parse)(options, args);
|
||||
const discourse = (0, discourse_1.Instance)();
|
||||
const _opts = {
|
||||
verb: argv.verb,
|
||||
src: path.resolve((0, fs_1.resolve)(options.src)),
|
||||
track: path.resolve((0, fs_1.resolve)(options.track))
|
||||
};
|
||||
let users = (0, users_1.read_users)(_opts.src);
|
||||
users = (0, users_1.filter_valid)(users);
|
||||
//////////////////////////
|
||||
//
|
||||
// store invalid
|
||||
let usersInvalid = (0, users_1.read_users)(_opts.src);
|
||||
usersInvalid = (0, users_1.filter_email_only)(usersInvalid);
|
||||
usersInvalid = (0, users_1.filter_invalid)(usersInvalid);
|
||||
index_1.logger.debug('write invalidUsers.json : ', (0, users_1.getDataPath)('/invalidUsers.json'));
|
||||
(0, write_1.sync)((0, users_1.getDataPath)('/invalidUsers.json'), usersInvalid.map((u) => {
|
||||
return {
|
||||
...u.detail,
|
||||
id: u._id,
|
||||
email: (0, users_1.oa_user_email)(u)
|
||||
};
|
||||
}));
|
||||
let usersInvalidEmail = (0, users_1.read_users)(_opts.src);
|
||||
usersInvalidEmail = (0, users_1.filter_email_missing)(usersInvalidEmail);
|
||||
index_1.logger.debug('write invalidUsersEMail.json : ', (0, users_1.getDataPath)('/invalidUsersEMail.json'));
|
||||
(0, write_1.sync)((0, users_1.getDataPath)('./invalidUsersEMail.json'), usersInvalidEmail.map((u) => {
|
||||
return {
|
||||
...u.detail,
|
||||
id: u._id
|
||||
};
|
||||
}));
|
||||
index_1.logger.debug('invalid users email : ', usersInvalidEmail.length);
|
||||
index_1.logger.debug('invalid users : ', usersInvalid.length);
|
||||
if (opts.verb == 'index') {
|
||||
await (0, users_1.indexUsers)(discourse, options, users);
|
||||
}
|
||||
if (opts.verb == 'import') {
|
||||
await (0, users_1.importUsers)(discourse, options, users);
|
||||
}
|
||||
if (opts.verb == 'update') {
|
||||
await (0, users_1.updateUsers)(discourse, options, users);
|
||||
}
|
||||
return;
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0LW9hLXVzZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbW1hbmRzL2ltcG9ydC1vYS11c2Vycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxrQ0FBNEM7QUFDNUMsd0NBQWtDO0FBRWxDLG9DQUE4QztBQUU5QyxnREFBMkM7QUFFM0MsZ0RBQW9EO0FBSXBELDJDQVV3QjtBQUV4Qiw2QkFBNEI7QUFDNUIsdURBQXdEO0FBRXhELE1BQU0sY0FBYyxHQUFHLENBQUMsS0FBZSxFQUFFLEVBQUU7SUFDdkMsT0FBTyxLQUFLLENBQUMsTUFBTSxDQUFDLE9BQU8sRUFBRTtRQUN6QixPQUFPLEVBQUUsS0FBSztRQUNkLFFBQVEsRUFBRSxnQkFBZ0I7UUFDMUIsSUFBSSxFQUFFLFNBQVM7S0FDbEIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUU7UUFDYixPQUFPLEVBQUUsNkJBQTZCO1FBQ3RDLElBQUksRUFBRSxRQUFRO0tBQ2pCLENBQUMsQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFO1FBQ2YsT0FBTyxFQUFFLDBDQUEwQztRQUNuRCxJQUFJLEVBQUUsUUFBUTtLQUNqQixDQUFDLENBQUMsTUFBTSxDQUFDLFNBQVMsRUFBRTtRQUNqQixPQUFPLEVBQUUsWUFBWTtRQUNyQixRQUFRLEVBQUUscUNBQ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wQiJ9
|
||||
10
packages/discourse/commands/import-oa.d.ts
vendored
Normal file
10
packages/discourse/commands/import-oa.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{
|
||||
debug: boolean;
|
||||
} & {
|
||||
src: string;
|
||||
} & {
|
||||
track: string;
|
||||
} & {
|
||||
env_key: string;
|
||||
}>;
|
||||
89
packages/discourse/commands/import-oa.js
Normal file
89
packages/discourse/commands/import-oa.js
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const _cli_1 = require("../_cli");
|
||||
const options_1 = require("../options");
|
||||
const index_1 = require("../index");
|
||||
const discourse_1 = require("../lib/discourse");
|
||||
const write_1 = require("@plastichub/fs/write");
|
||||
const users_1 = require("../lib/oa/users");
|
||||
const path = require("path");
|
||||
const fs_1 = require("@plastichub/osr-commons");
|
||||
const KB_ROOT = '${KB_ROOT}';
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: false,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('src', {
|
||||
default: '${OA_ROOT}/data/latest.json',
|
||||
type: 'string',
|
||||
}).option('track', {
|
||||
default: './latest_track.json',
|
||||
type: 'string',
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('import <verb>', 'Import oa-users', options, async (argv) => {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && index_1.logger.debug(`CLI Args In`, argv);
|
||||
let opts = (0, options_1.parse)(options, args);
|
||||
if (!opts.verb) {
|
||||
index_1.logger.error('No verb specified');
|
||||
return;
|
||||
}
|
||||
const discourse = (0, discourse_1.Instance)();
|
||||
const _opts = {
|
||||
verb: argv.verb,
|
||||
src: path.resolve((0, fs_1.resolve)(options.src)),
|
||||
track: path.resolve((0, fs_1.resolve)(options.track))
|
||||
};
|
||||
if (opts.verb == 'users') {
|
||||
let users = (0, users_1.read_users)(_opts.src);
|
||||
// users = filter_email_only(users)
|
||||
//users = filter_accepted(users as IImportUser[])
|
||||
users = (0, users_1.filter_valid)(users);
|
||||
//////////////////////////
|
||||
//
|
||||
// store invalid
|
||||
let usersInvalid = (0, users_1.read_users)(_opts.src);
|
||||
usersInvalid = (0, users_1.filter_email_only)(usersInvalid);
|
||||
usersInvalid = (0, users_1.filter_invalid)(usersInvalid);
|
||||
(0, write_1.sync)((0, users_1.getDataPath)('/invalidUsers.json'), usersInvalid.map((u) => {
|
||||
return {
|
||||
...u.detail,
|
||||
id: u._id,
|
||||
email: (0, users_1.oa_user_email)(u)
|
||||
};
|
||||
}));
|
||||
let usersInvalidEmail = (0, users_1.read_users)(_opts.src);
|
||||
usersInvalidEmail = (0, users_1.filter_email_missing)(usersInvalidEmail);
|
||||
(0, write_1.sync)((0, users_1.getDataPath)('./invalidUsersEMail.json'), usersInvalidEmail.map((u) => {
|
||||
return {
|
||||
...u.detail,
|
||||
id: u._id
|
||||
};
|
||||
}));
|
||||
console.log('invalid users : ', usersInvalidEmail.length);
|
||||
await (0, users_1.importUsers)(discourse, options, users);
|
||||
// await updateUsers(discourse, options, users)
|
||||
// const items = await discourse.search('Sheetpress - Cell','tags:sheetpress')
|
||||
// logger.info('items',items)
|
||||
}
|
||||
return;
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0LW9hLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Nv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QyxDQUFDLEdBQUc7aUJBQ1osQ0FBQTtZQUNMLENBQUMsQ0FBQyxDQUFDLENBQUE7WUFFSCxPQUFPLENBQUMsR0FBRyxDQUFDLGtCQUFrQixFQUFFLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxDQUFBO1lBS3pELE1BQU0sSUFBQSxtQkFBVyxFQUFDLFNBQVMsRUFBRSxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUE7WUFDNUMsK0NBQStDO1lBRS9DLDhFQUE4RTtZQUM5RSw2QkFBNkI7U0FDaEM7UUFDRCxPQUFNO0lBQ1YsQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUE7QUF2RVksUUFBQSxRQUFRLFlBdUVwQiJ9
|
||||
2
packages/discourse/commands/info.d.ts
vendored
Normal file
2
packages/discourse/commands/info.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
27
packages/discourse/commands/info.js
Normal file
27
packages/discourse/commands/info.js
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const osr_cli_commons_1 = require("@plastichub/osr-cli-commons");
|
||||
const index_1 = require("../index");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: 'false',
|
||||
describe: 'debug messages'
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('info', 'info', options, async (argv) => {
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
const src = (0, osr_cli_commons_1.CONFIG_DEFAULT)(args.env_key);
|
||||
index_1.logger.debug(`Reading OSR Config with key "${argv.env_key}"`, src);
|
||||
});
|
||||
};
|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FBQyxPQUFPLEdBQUcsRUFBRSxHQUFHLENBQUMsQ0FBQTtJQUN0RSxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQTtBQVBZLFFBQUEsUUFBUSxZQU9wQiJ9
|
||||
1
packages/discourse/commands/info.js.map
Normal file
1
packages/discourse/commands/info.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"info.js","sourceRoot":"","sources":["../src/commands/info.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,iEAA6D;AAC7D,2BAA4B;AAE5B,MAAM,cAAc,GAAG,CAAC,KAAe,EAAE,EAAE;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;QACzB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,gBAAgB;KAC7B,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE;QACjB,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,oCAAoC;KACjD,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,IAAI,OAAO,GAAG,CAAC,KAAe,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAElD,MAAM,QAAQ,GAAG,CAAC,GAAa,EAAE,EAAE;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAO,IAAmB,EAAE,EAAE;QACtE,IAAI,IAAI,CAAC,IAAI,EAAE;YAAE,OAAO;SAAE;QAC1B,MAAM,IAAI,GAAQ,IAAI,CAAC;QACvB,MAAM,GAAG,GAAG,IAAA,gCAAc,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,UAAM,CAAC,KAAK,CAAC,gCAAgC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC;IACvE,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC;AAPW,QAAA,QAAQ,YAOnB"}
|
||||
14
packages/discourse/commands/product.d.ts
vendored
Normal file
14
packages/discourse/commands/product.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{
|
||||
debug: boolean;
|
||||
} & {
|
||||
id: number;
|
||||
} & {
|
||||
short: string | boolean;
|
||||
} & {
|
||||
disabled: string | boolean;
|
||||
} & {
|
||||
dry: string;
|
||||
} & {
|
||||
env_key: string;
|
||||
}>;
|
||||
110
packages/discourse/commands/product.js
Normal file
110
packages/discourse/commands/product.js
Normal file
@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const path = require("path");
|
||||
const osr_cli_commons_1 = require("@plastichub/osr-cli-commons");
|
||||
const write_1 = require("@plastichub/fs/write");
|
||||
const _cli_1 = require("../_cli");
|
||||
const options_1 = require("../options");
|
||||
const __1 = require("..");
|
||||
const product_1 = require("../lib/cscart/product");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: false,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('id', {
|
||||
describe: 'Entity ID',
|
||||
type: 'number'
|
||||
}).option('short', {
|
||||
default: 'true',
|
||||
describe: 'Emit short info only',
|
||||
type: 'boolean'
|
||||
}).option('disabled', {
|
||||
default: 'false',
|
||||
describe: 'Enumerate disabled products',
|
||||
type: 'boolean'
|
||||
}).option('dry', {
|
||||
default: 'false',
|
||||
describe: 'Process files for debug purposes only.'
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('product <verb>', 'Product namespace', options, (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
const config = (0, osr_cli_commons_1.CONFIG_DEFAULT)(args.env_key);
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && __1.logger.debug(`CLI Args In`, argv);
|
||||
let opts = (0, options_1.parse)(options, args);
|
||||
if (!opts.verb) {
|
||||
__1.logger.error('No verb specified');
|
||||
return;
|
||||
}
|
||||
if (opts.verb == 'list') {
|
||||
let _products = yield (0, product_1.products)(config.cscart);
|
||||
if (opts.dst) {
|
||||
(0, product_1.writeProducts)(_products, opts);
|
||||
}
|
||||
}
|
||||
if (opts.verb == 'delete') {
|
||||
return yield (0, product_1.delete_product)(opts.id, config.cscart);
|
||||
}
|
||||
if (opts.verb == 'get') {
|
||||
let _product = yield (0, product_1.get_product)(opts.id, config.cscart);
|
||||
opts.debug && __1.logger.debug(`Get product ${opts.id} `, _product);
|
||||
if (_product && opts.dst) {
|
||||
let _path = path.resolve(opts.dst);
|
||||
(0, write_1.sync)(_path, _product);
|
||||
opts.debug && __1.logger.debug(`Writing product to ${_path}`);
|
||||
}
|
||||
}
|
||||
if (opts.verb == 'create') {
|
||||
const args = {
|
||||
product: 'xxxx2',
|
||||
price: 1234,
|
||||
main_category: 22,
|
||||
category_ids: [22],
|
||||
status: 'A',
|
||||
company_id: 1
|
||||
};
|
||||
let _product = yield (0, product_1.create_product)(args, config.cscart);
|
||||
__1.logger.debug(`Created product ! ID:`, _product);
|
||||
}
|
||||
if (opts.verb == 'update') {
|
||||
const args = {
|
||||
price: 12342,
|
||||
product: "cscart-api-test",
|
||||
status: 'H',
|
||||
full_description: "test - es>",
|
||||
meta_keywords: "pp,hdpe",
|
||||
category_ids: [22, 15],
|
||||
lang_code: 'es'
|
||||
};
|
||||
let _product = yield (0, product_1.update_product)(opts.id, args, config.cscart);
|
||||
__1.logger.debug(`Updated product ! ID:${opts.id}`, _product);
|
||||
}
|
||||
return;
|
||||
}));
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=product.js.map
|
||||
1
packages/discourse/commands/product.js.map
Normal file
1
packages/discourse/commands/product.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"product.js","sourceRoot":"","sources":["../src/commands/product.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6BAA4B;AAE5B,iEAA4D;AAC5D,gDAAoD;AAEpD,kCAA4C;AAC5C,wCAAkC;AAElC,0BAA2B;AAE3B,mDAA6H;AAI7H,MAAM,cAAc,GAAG,CAAC,KAAe,EAAE,EAAE;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;QACzB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,gBAAgB;QAC1B,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;QACZ,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,QAAQ;KACjB,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,sBAAsB;QAChC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACb,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,wCAAwC;KACrD,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE;QACj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E,EAAE,CAAC;gBACtB,SAAS,EAAE,IAAI;aAClB,CAAC;YACF,IAAI,QAAQ,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,EAAE,EAAE,IAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACzE,UAAM,CAAC,KAAK,CAAC,wBAAwB,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;SAC7D;QACD,OAAO;IACX,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC;AAtEW,QAAA,QAAQ,YAsEnB"}
|
||||
2
packages/discourse/commands/query.d.ts
vendored
Normal file
2
packages/discourse/commands/query.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
56
packages/discourse/commands/query.js
Normal file
56
packages/discourse/commands/query.js
Normal file
@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const _cli_1 = require("../_cli");
|
||||
const options_1 = require("../options");
|
||||
const index_1 = require("../index");
|
||||
const discourse_1 = require("../lib/discourse");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs.option('debug', {
|
||||
default: false,
|
||||
describe: 'debug messages',
|
||||
type: 'boolean'
|
||||
}).option('short', {
|
||||
default: 'true',
|
||||
describe: 'Emit short info only',
|
||||
type: 'boolean'
|
||||
}).option('disabled', {
|
||||
default: 'false',
|
||||
describe: 'Enumerate disabled products',
|
||||
type: 'boolean'
|
||||
}).option('dry', {
|
||||
default: 'false',
|
||||
describe: 'Process files for debug purposes only.'
|
||||
}).option('env_key', {
|
||||
default: 'OSR-CONFIG',
|
||||
describe: 'Environment key to the config path.'
|
||||
});
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('query <verb>', 'Search namespace', options, async (argv) => {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
const args = argv;
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && index_1.logger.debug(`CLI Args In`, argv);
|
||||
let opts = (0, options_1.parse)(options, args);
|
||||
if (!opts.verb) {
|
||||
index_1.logger.error('No verb specified');
|
||||
return;
|
||||
}
|
||||
const discourse = (0, discourse_1.Instance)();
|
||||
if (opts.verb == 'tags') {
|
||||
const items = await discourse.search('Sheetpress - Cell', 'tags:sheetpress');
|
||||
index_1.logger.info('items', items);
|
||||
}
|
||||
return;
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVlcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29tbWFuZHMvcXVlcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsa0NBQTRDO0FBQzVDLHdDQUFrQztBQUVsQyxvQ0FBaUM7QUFFakMsZ0RBQTJDO0FBRTNDLE1BQU0sY0FBYyxHQUFHLENBQUMsS0FBZSxFQUFFLEVBQUU7SUFDdkMsT0FBTyxLQUFLLENBQUMsTUFBTSxDQUFDLE9BQU8sRUFBRTtRQUN6QixPQUFPLEVBQUUsS0FBSztRQUNkLFFBQVEsRUFBRSxnQkFBZ0I7UUFDMUIsSUFBSSxFQUFFLFNBQVM7S0FDbEIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxPQUFPLEVBQUU7UUFDZixPQUFPLEVBQUUsTUFBTTtRQUNmLFFBQVEsRUFBRSxzQkFBc0I7UUFDaEMsSUFBSSxFQUFFLFNBQVM7S0FDbEIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxVQUFVLEVBQUU7UUFDbEIsT0FBTyxFQUFFLE9BQU87UUFDaEIsUUFBUSxFQUFFLDZCQUE2QjtRQ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sS0FBSyxDQUFDLG1CQUFtQixDQUFDLENBQUE7WUFDakMsT0FBTztTQUNWO1FBQ0QsTUFBTSxTQUFTLEdBQUcsSUFBQSxvQkFBUSxHQUFFLENBQUE7UUFDNUIsSUFBSSxJQUFJLENBQUMsSUFBSSxJQUFJLE1BQU0sRUFBRTtZQUNyQixNQUFNLEtBQUssR0FBRyxNQUFNLFNBQVMsQ0FBQyxNQUFNLENBQUMsbUJBQW1CLEVBQUMsaUJBQWlCLENBQUMsQ0FBQztZQUM1RSxjQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBQyxLQUFLLENBQUMsQ0FBQTtTQUM3QjtRQUNELE9BQU07SUFDVixDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQTtBQXpCWSxRQUFBLFFBQVEsWUF5QnBCIn0=
|
||||
1
packages/discourse/commands/query.js.map
Normal file
1
packages/discourse/commands/query.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/commands/query.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,kCAA4C;AAC5C,wCAAkC;AAElC,0BAA2B;AAE3B,gDAA2C;AAE3C,MAAM,cAAc,GAAG,CAAC,KAAe,EAAE,EAAE;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;QACzB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,gBAAgB;QAC1B,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,sBAAsB;QAChC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACb,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,wCAAwC;KACr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ts
vendored
Normal file
4
packages/discourse/commands/sync-component.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import * as CLI from 'yargs';
|
||||
import { IOptionsSyncComponent } from '../types';
|
||||
export declare const parse: (argv: any) => IOptionsSyncComponent | boolean;
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
124
packages/discourse/commands/sync-component.js
Normal file
124
packages/discourse/commands/sync-component.js
Normal file
File diff suppressed because one or more lines are too long
2
packages/discourse/commands/sync-file.d.ts
vendored
Normal file
2
packages/discourse/commands/sync-file.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as CLI from 'yargs';
|
||||
export declare const register: (cli: CLI.Argv) => CLI.Argv<{}>;
|
||||
55
packages/discourse/commands/sync-file.js
Normal file
55
packages/discourse/commands/sync-file.js
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = void 0;
|
||||
const _cli_1 = require("../_cli");
|
||||
const index_1 = require("../index");
|
||||
const file_1 = require("../lib/sync/file");
|
||||
const constants_1 = require("../lib/discourse/constants");
|
||||
const defaultOptions = (yargs) => {
|
||||
return yargs
|
||||
.option('debug', { type: 'boolean', default: true, describe: 'debug messages' })
|
||||
.option('verbose', { type: 'boolean', default: true, describe: 'even more debug messages' })
|
||||
.option('yaml', { type: 'boolean', default: true, describe: 'Parse options from YAML header' })
|
||||
.option('alt', { type: 'boolean', default: false, describe: 'alt token (%)' })
|
||||
.option('uploadLocal', { type: 'boolean', default: true, describe: 'Upload local images to Discourse' })
|
||||
.option('uploadRemote', { type: 'boolean', default: true, describe: 'Upload remote images to Discourse' })
|
||||
.option('src', {
|
||||
default: './tests/**/*.md',
|
||||
type: 'string',
|
||||
describe: 'Source : Path|Glob. Supported: HTML|MD|OSR(Options via YAML header)'
|
||||
})
|
||||
.option('title', { type: 'string', default: 'Title of the Discourse post' })
|
||||
.option('config', { type: 'string', default: 'osr_admin' })
|
||||
.option('cat', { default: constants_1.CAT_TEST, type: 'number' })
|
||||
.option('timestamp', { type: 'number', default: Date.now() })
|
||||
.option('owner', { type: 'number', default: constants_1.DEFAULT_IMPORT_OWNER })
|
||||
.option('config', { type: 'string', default: 'discourse_admin' })
|
||||
.option('env', { type: 'string', default: 'test-import' })
|
||||
.option('profile', { type: 'string', default: "${OSR_ROOT}/osr-profiles/osr/base.json" })
|
||||
.option('format', { type: 'string', default: 'html' })
|
||||
.option('root', { type: 'string', default: process.cwd() })
|
||||
.option('cwd', { type: 'string', default: process.cwd() })
|
||||
.option('cache', { type: 'boolean', default: true })
|
||||
.option('env_key', { type: 'string', default: 'OSR-CONFIG', describe: 'Environment key to the config path.' });
|
||||
};
|
||||
let options = (yargs) => defaultOptions(yargs);
|
||||
const register = (cli) => {
|
||||
return cli.command('sync <verb>', 'Sync file', options, async (argv) => {
|
||||
(0, _cli_1.defaults)();
|
||||
if (argv.help) {
|
||||
return;
|
||||
}
|
||||
let options = (0, _cli_1.sanitize)(argv);
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
options.debug && index_1.logger.debug(`CLI Args In`, argv);
|
||||
if (!options.verb) {
|
||||
index_1.logger.error('No verb specified');
|
||||
return;
|
||||
}
|
||||
return (0, file_1.syncYAML)(options);
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luYy1maWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbW1hbmRzL3N5bmMtZmlsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxrQ0FBNEM7QUFFNUMsb0NBQWlDO0FBU2pDLDJDQUEyQztBQUMzQywwREFBMkU7QUFFM0UsTUFBTSxjQUFjLEdBQUcsQ0FBQyxLQUFlLEVBQUUsRUFBRTtJQUN2QyxPQUFPLEtBQUs7U0FDUCxNQUFNLENBQU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NUIsQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUE7QUFqQlksUUFBQSxRQUFRLFlBaUJwQiJ9
|
||||
0
packages/discourse/config/machines.js
Normal file
0
packages/discourse/config/machines.js
Normal file
1
packages/discourse/constants.d.ts
vendored
Normal file
1
packages/discourse/constants.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const MODULE_NAME = "OSR-DISCOURSE";
|
||||
5
packages/discourse/constants.js
Normal file
5
packages/discourse/constants.js
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MODULE_NAME = void 0;
|
||||
exports.MODULE_NAME = `OSR-DISCOURSE`;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsic3JjL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBYSxRQUFBLFdBQVcsR0FBRyxlQUFlLENBQUEifQ==
|
||||
1
packages/discourse/constants.js.map
Normal file
1
packages/discourse/constants.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.js","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,eAAe,CAAA"}
|
||||
34
packages/discourse/discourse-sync.json
Normal file
34
packages/discourse/discourse-sync.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"./tests/image.jpg": {
|
||||
"id": 9561,
|
||||
"url": "https://forum.osr-plastic.org/uploads/default/original/2X/e/e501e5aa77623b161069805f5e84a4dcd5e9632a.jpeg",
|
||||
"original_filename": "image.jpg",
|
||||
"filesize": 130249,
|
||||
"width": 828,
|
||||
"height": 1472,
|
||||
"thumbnail_width": 281,
|
||||
"thumbnail_height": 500,
|
||||
"extension": "jpeg",
|
||||
"short_url": "upload://wFTp838ZYs2IcwTpTMT9g566ijU.jpeg",
|
||||
"short_path": "/uploads/short-url/wFTp838ZYs2IcwTpTMT9g566ijU.jpeg",
|
||||
"retain_hours": null,
|
||||
"human_filesize": "127 KB",
|
||||
"dominant_color": "4C4D4E"
|
||||
},
|
||||
"https://osr-plastic.org/machines/injection/components/304_Valve-40mm/renderings/webp/perspective.webp": {
|
||||
"id": 9562,
|
||||
"url": "https://forum.osr-plastic.org/uploads/default/original/2X/0/020b78cdced1bf3095da4ababa8347e2334f26dd.webp",
|
||||
"original_filename": "perspective.webp",
|
||||
"filesize": 14366,
|
||||
"width": 1080,
|
||||
"height": 864,
|
||||
"thumbnail_width": 625,
|
||||
"thumbnail_height": 500,
|
||||
"extension": "webp",
|
||||
"short_url": "upload://i5x4cSq74UrBXgc4Kw66mIf7rL.webp",
|
||||
"short_path": "/uploads/short-url/i5x4cSq74UrBXgc4Kw66mIf7rL.webp",
|
||||
"retain_hours": null,
|
||||
"human_filesize": "14 KB",
|
||||
"dominant_color": "E7E4E2"
|
||||
}
|
||||
}
|
||||
22
packages/discourse/docs/data.md
Normal file
22
packages/discourse/docs/data.md
Normal file
@ -0,0 +1,22 @@
|
||||
### OA - Users
|
||||
|
||||
cli::import-oa-users import|update
|
||||
|
||||
src -> export const osr-commons/OA_LATEST = '${OSR_ROOT}/osr-directory/pp/${YYYY}_${MM}.json'
|
||||
|
||||
-> write (${OSR_ROOT}/${OSR_ROOT}/osr-directory/pp/invalidUsers.json)
|
||||
-> write (${OSR_ROOT}/${OSR_ROOT}/osr-directory/pp/invalidUsersEMail.json)
|
||||
-> merge to '${OSR_ROOT}/${OSR_ROOT}/osr-directory/pp/merged.json'
|
||||
|
||||
### Discourse Directory Layout
|
||||
|
||||
- Intro Page
|
||||
- Continent (cat, +tags)
|
||||
- country page (+tags, +lang)
|
||||
- item (+tags, +lang)
|
||||
|
||||
- External feeds
|
||||
- social
|
||||
- products
|
||||
- osr content
|
||||
- news
|
||||
9
packages/discourse/index.d.ts
vendored
Normal file
9
packages/discourse/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export * from './constants';
|
||||
export * from './types';
|
||||
export * from './lib';
|
||||
export * from './lib/oa/types';
|
||||
import { Logger } from "tslog";
|
||||
export { Logger } from 'tslog';
|
||||
export declare const logger: Logger;
|
||||
import { IObjectLiteral } from "@plastichub/core";
|
||||
export declare const substitute: (alt: boolean, template: string, vars?: IObjectLiteral) => any;
|
||||
89
packages/discourse/index.js
Normal file
89
packages/discourse/index.js
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.substitute = exports.logger = exports.Logger = void 0;
|
||||
__exportStar(require("./constants"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
__exportStar(require("./lib"), exports);
|
||||
__exportStar(require("./lib/oa/types"), exports);
|
||||
const debug_1 = require("@plastichub/core/debug");
|
||||
const constants_1 = require("./constants");
|
||||
var tslog_1 = require("tslog");
|
||||
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return tslog_1.Logger; } });
|
||||
let loggers = {};
|
||||
/*
|
||||
const _logger = new Logger({
|
||||
prettyLogTemplate: "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t[{{filePathWithLine}}{{name}}]\t",
|
||||
prettyErrorTemplate: "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}",
|
||||
prettyErrorStackTemplate: " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}",
|
||||
prettyErrorParentNamesSeparator: ":",
|
||||
prettyErrorLoggerNameDelimiter: "\t",
|
||||
stylePrettyLogs: true,
|
||||
prettyLogTimeZone: "UTC",
|
||||
prettyLogStyles: {
|
||||
logLevelName: {
|
||||
"*": ["bold", "black", "bgWhiteBright", "dim"],
|
||||
SILLY: ["bold", "white"],
|
||||
TRACE: ["bold", "whiteBright"],
|
||||
DEBUG: ["bold", "green"],
|
||||
INFO: ["bold", "blue"],
|
||||
WARN: ["bold", "yellow"],
|
||||
ERROR: ["bold", "red"],
|
||||
FATAL: ["bold", "redBright"],
|
||||
},
|
||||
dateIsoStr: "white",
|
||||
filePathWithLine: "white",
|
||||
name: ["white", "bold"],
|
||||
nameWithDelimiterPrefix: ["white", "bold"],
|
||||
nameWithDelimiterSuffix: ["white", "bold"],
|
||||
errorName: ["bold", "bgRedBright", "whiteBright"],
|
||||
fileName: ["yellow"],
|
||||
fileNameWithLine: "white",
|
||||
},
|
||||
});
|
||||
*/
|
||||
/*
|
||||
export const __logger = (name: string = MODULE_NAME, options: ISettingsParam = {}): Logger => {
|
||||
if (!loggers[name]) {
|
||||
const logger: Logger = new Logger({
|
||||
name: name,
|
||||
type: 'pretty',
|
||||
...options
|
||||
});
|
||||
// const trans = (transportLogger: LogObj & ILogObjMet)
|
||||
(logger as any).attachTransport((logObj) => {
|
||||
debugger
|
||||
//transports.push(logObj);
|
||||
});
|
||||
|
||||
logger.debug('test')
|
||||
|
||||
loggers[name] = logger;
|
||||
}
|
||||
return loggers[name]
|
||||
}*/
|
||||
exports.logger = (0, debug_1.logger)(constants_1.MODULE_NAME);
|
||||
/*
|
||||
export const log = (msg: string, ...args: any) => logger().info(msg, ...args);
|
||||
export const info = (msg: string, ...args: any) => logger().info(msg, ...args);
|
||||
export const error = (msg: string, ...args: any) => logger().error(msg, ...args);
|
||||
export const warn = (msg: string, ...args: any) => logger().warn(msg, ...args);
|
||||
export const debug = (msg: string, ...args: any) => logger().debug(msg, ...args);
|
||||
*/
|
||||
const strings_1 = require("@plastichub/core/strings");
|
||||
const substitute = (alt, template, vars = {}) => alt ? (0, strings_1.substituteAlt)(template, vars) : (0, strings_1.substitute)(template, vars);
|
||||
exports.substitute = substitute;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJzcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw4Q0FBMkI7QUFDM0IsMENBQXVCO0FBQ3ZCLHdDQUFxQjtBQUNyQixpREFBOEI7QUFFOUIsa0RBQTBEO0FBRTFELDJDQUF5QztBQUV6QywrQkFBOEI7QUFBckIsK0ZBQUEsTUFBTSxPQUFBO0FBRWYsSUFBSSxPQUFPLEdBQUcsRUFBRSxDQUFDO0FBRWpCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7SUE4Qkk7QUFDSjs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW1CRztBQUdVLFFBQUEsTUFBTSxHQUFHLElBQUEsY0FBTyxFQUFDLHVCQUFXLENBQUMsQ0FBQTtBQUUxQzs7Ozs7O0VBTUU7QUFHRixzREFBcUc7QUFJOUYsTUFBTSxVQUFVLEdBQUcsQ0FBQyxHQUFZLEVBQUUsUUFBZ0IsRUFBRSxPQUF1QixFQUFFLEVBQUUsRUFBRSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsSUFBQSx1QkFBYyxFQUFDLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsSUFBQSxvQkFBVyxFQUFDLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQTtBQUE5SSxRQUFBLFVBQVUsY0FBb0kifQ==
|
||||
1
packages/discourse/index.js.map
Normal file
1
packages/discourse/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,0CAAuB;AAEvB,kDAA0D;AAE1D,2CAAyC;AAI5B,QAAA,MAAM,GAAG,IAAA,cAAO,EAAC,uBAAW,CAAC,CAAA;AAE1C,2CAAgH;AAEzG,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,QAAe,EAAE,IAAmB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,oBAAc,EAAC,QAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAW,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AAArI,QAAA,UAAU,cAA2H"}
|
||||
146
packages/discourse/index.md
Normal file
146
packages/discourse/index.md
Normal file
@ -0,0 +1,146 @@
|
||||
## Directory Index
|
||||
|
||||
**Hidden / Censored Users** :
|
||||
|
||||
**Total** :
|
||||
|
||||
## Africa
|
||||
- [Algeria (6)](/directory/users_algeria-af)
|
||||
- [Botswana (1)](/directory/users_botswana-af)
|
||||
- [Burkina Faso (2)](/directory/users_burkina-faso-af)
|
||||
- [Cabo Verde (1)](/directory/users_cabo-verde-af)
|
||||
- [Cameroon (2)](/directory/users_cameroon-af)
|
||||
- [Congo (3)](/directory/users_congo-(the-democratic-republic-of-the)-af)
|
||||
- [Egypt (7)](/directory/users_egypt-af)
|
||||
- [Eswatini (1)](/directory/users_eswatini-af)
|
||||
- [Ethiopia (2)](/directory/users_ethiopia-af)
|
||||
- [Ghana (5)](/directory/users_ghana-af)
|
||||
- [Kenya (14)](/directory/users_kenya-af)
|
||||
- [Libya (1)](/directory/users_libya-af)
|
||||
- [Madagascar (2)](/directory/users_madagascar-af)
|
||||
- [Mali (2)](/directory/users_mali-af)
|
||||
- [Mauritius (2)](/directory/users_mauritius-af)
|
||||
- [Morocco (2)](/directory/users_morocco-af)
|
||||
- [Namibia (3)](/directory/users_namibia-af)
|
||||
- [Nigeria (7)](/directory/users_nigeria-af)
|
||||
- [Reunion (1)](/directory/users_reunion-af)
|
||||
- [Senegal (1)](/directory/users_senegal-af)
|
||||
- [Somalia (1)](/directory/users_somalia-af)
|
||||
- [South Africa (16)](/directory/users_south-africa-af)
|
||||
- [Spain (58)](/directory/users_spain-af)
|
||||
- [Tanzania, the United Republic of (6)](/directory/users_tanzania-the-united-republic-of-af)
|
||||
- [Tunisia (3)](/directory/users_tunisia-af)
|
||||
- [Uganda (1)](/directory/users_uganda-af)
|
||||
- [Zambia (2)](/directory/users_zambia-af)
|
||||
## Asia
|
||||
- [Armenia (1)](/directory/users_armenia-as)
|
||||
- [Azerbaijan (2)](/directory/users_azerbaijan-as)
|
||||
- [Bangladesh (6)](/directory/users_bangladesh-as)
|
||||
- [Cambodia (2)](/directory/users_cambodia-as)
|
||||
- [China (3)](/directory/users_china-as)
|
||||
- [Christmas Island (1)](/directory/users_christmas-island-as)
|
||||
- [Cyprus (3)](/directory/users_cyprus-as)
|
||||
- [Georgia (3)](/directory/users_georgia-as)
|
||||
- [Hong Kong (7)](/directory/users_hong-kong-as)
|
||||
- [India (42)](/directory/users_india-as)
|
||||
- [Indonesia (57)](/directory/users_indonesia-as)
|
||||
- [Iran (1)](/directory/users_iran-(islamic-republic-of)-as)
|
||||
- [Iraq (2)](/directory/users_iraq-as)
|
||||
- [Israel (1)](/directory/users_israel-as)
|
||||
- [Japan (16)](/directory/users_japan-as)
|
||||
- [Jordan (4)](/directory/users_jordan-as)
|
||||
- [Kazakhstan (1)](/directory/users_kazakhstan-as)
|
||||
- [Korea (16)](/directory/users_korea-(the-republic-of)-as)
|
||||
- [Kyrgyzstan (1)](/directory/users_kyrgyzstan-as)
|
||||
- [Lao People's Democratic Republic (1)](/directory/users_lao-people's-democratic-republic-(the)-as)
|
||||
- [Lebanon (2)](/directory/users_lebanon-as)
|
||||
- [Malaysia (13)](/directory/users_malaysia-as)
|
||||
- [Mongolia (2)](/directory/users_mongolia-as)
|
||||
- [Myanmar (1)](/directory/users_myanmar-as)
|
||||
- [Pakistan (1)](/directory/users_pakistan-as)
|
||||
- [Philippines (5)](/directory/users_philippines-(the)-as)
|
||||
- [Russian Federation (31)](/directory/users_russian-federation-(the)-as)
|
||||
- [Saudi Arabia (3)](/directory/users_saudi-arabia-as)
|
||||
- [Singapore (4)](/directory/users_singapore-as)
|
||||
- [Sri Lanka (1)](/directory/users_sri-lanka-as)
|
||||
- [Taiwan (2)](/directory/users_taiwan-(province-of-china)-as)
|
||||
- [Thailand (12)](/directory/users_thailand-as)
|
||||
- [Timor-Leste (2)](/directory/users_timor-leste-as)
|
||||
- [Turkiye (16)](/directory/users_turkiye-as)
|
||||
- [United Arab Emirates (3)](/directory/users_united-arab-emirates-(the)-as)
|
||||
- [Uzbekistan (2)](/directory/users_uzbekistan-as)
|
||||
- [Viet Nam (12)](/directory/users_viet-nam-as)
|
||||
## Australian continent
|
||||
- [Australia (53)](/directory/users_australia-au)
|
||||
## Europe
|
||||
- [Albania (2)](/directory/users_albania-eu)
|
||||
- [Austria (6)](/directory/users_austria-eu)
|
||||
- [Belarus (1)](/directory/users_belarus-eu)
|
||||
- [Belgium (18)](/directory/users_belgium-eu)
|
||||
- [Bosnia and Herzegovina (3)](/directory/users_bosnia-and-herzegovina-eu)
|
||||
- [Bulgaria (5)](/directory/users_bulgaria-eu)
|
||||
- [Croatia (4)](/directory/users_croatia-eu)
|
||||
- [Czechia (7)](/directory/users_czechia-eu)
|
||||
- [Denmark (4)](/directory/users_denmark-eu)
|
||||
- [Estonia (1)](/directory/users_estonia-eu)
|
||||
- [Finland (2)](/directory/users_finland-eu)
|
||||
- [France (95)](/directory/users_france-eu)
|
||||
- [Germany (66)](/directory/users_germany-eu)
|
||||
- [Greece (14)](/directory/users_greece-eu)
|
||||
- [Hungary (5)](/directory/users_hungary-eu)
|
||||
- [Iceland (1)](/directory/users_iceland-eu)
|
||||
- [Ireland (5)](/directory/users_ireland-eu)
|
||||
- [Italy (31)](/directory/users_italy-eu)
|
||||
- [Latvia (2)](/directory/users_latvia-eu)
|
||||
- [Liechtenstein (1)](/directory/users_liechtenstein-eu)
|
||||
- [Lithuania (2)](/directory/users_lithuania-eu)
|
||||
- [Malta (1)](/directory/users_malta-eu)
|
||||
- [Montenegro (1)](/directory/users_montenegro-eu)
|
||||
- [Netherlands (37)](/directory/users_netherlands-(the)-eu)
|
||||
- [Norway (7)](/directory/users_norway-eu)
|
||||
- [Poland (4)](/directory/users_poland-eu)
|
||||
- [Portugal (17)](/directory/users_portugal-eu)
|
||||
- [Romania (5)](/directory/users_romania-eu)
|
||||
- [Russian Federation (31)](/directory/users_russian-federation-(the)-eu)
|
||||
- [Serbia (6)](/directory/users_serbia-eu)
|
||||
- [Slovakia (6)](/directory/users_slovakia-eu)
|
||||
- [Slovenia (1)](/directory/users_slovenia-eu)
|
||||
- [Spain (58)](/directory/users_spain-eu)
|
||||
- [Sweden (4)](/directory/users_sweden-eu)
|
||||
- [Switzerland (15)](/directory/users_switzerland-eu)
|
||||
- [Ukraine (16)](/directory/users_ukraine-eu)
|
||||
- [United Kingdom of Great Britain and Northern Ireland (65)](/directory/users_united-kingdom-of-great-britain-and-northern-ireland-(the)-eu)
|
||||
## North America
|
||||
- [Canada (42)](/directory/users_canada-na)
|
||||
- [Costa Rica (6)](/directory/users_costa-rica-na)
|
||||
- [Cuba (1)](/directory/users_cuba-na)
|
||||
- [Curacao (1)](/directory/users_curacao-na)
|
||||
- [Dominican Republic (9)](/directory/users_dominican-republic-(the)-na)
|
||||
- [Guatemala (2)](/directory/users_guatemala-na)
|
||||
- [Haiti (2)](/directory/users_haiti-na)
|
||||
- [Mexico (57)](/directory/users_mexico-na)
|
||||
- [Netherlands (37)](/directory/users_netherlands-(the)-na)
|
||||
- [Panama (3)](/directory/users_panama-na)
|
||||
- [Puerto Rico (3)](/directory/users_puerto-rico-na)
|
||||
- [United States of America (167)](/directory/users_united-states-of-america-(the)-na)
|
||||
## Oceania
|
||||
- [Fiji (2)](/directory/users_fiji-oc)
|
||||
- [Guam (1)](/directory/users_guam-oc)
|
||||
- [Micronesia (1)](/directory/users_micronesia-(federated-states-of)-oc)
|
||||
- [New Caledonia (1)](/directory/users_new-caledonia-oc)
|
||||
- [New Zealand (10)](/directory/users_new-zealand-oc)
|
||||
- [United States of America (167)](/directory/users_united-states-of-america-(the)-oc)
|
||||
## South America
|
||||
- [Argentina (34)](/directory/users_argentina-sa)
|
||||
- [Bolivia (2)](/directory/users_bolivia-(plurinational-state-of)-sa)
|
||||
- [Brazil (57)](/directory/users_brazil-sa)
|
||||
- [Chile (26)](/directory/users_chile-sa)
|
||||
- [Colombia (39)](/directory/users_colombia-sa)
|
||||
- [Ecuador (11)](/directory/users_ecuador-sa)
|
||||
- [Guyana (1)](/directory/users_guyana-sa)
|
||||
- [Paraguay (2)](/directory/users_paraguay-sa)
|
||||
- [Peru (9)](/directory/users_peru-sa)
|
||||
- [Uruguay (4)](/directory/users_uruguay-sa)
|
||||
- [Venezuela (5)](/directory/users_venezuela-(bolivarian-republic-of)-sa)
|
||||
|
||||
|
||||
10
packages/discourse/lib/discourse/cache.d.ts
vendored
Normal file
10
packages/discourse/lib/discourse/cache.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference types="node" />
|
||||
import { IDiscourseUser } from '../../';
|
||||
import { Discourser } from '../index';
|
||||
export declare const fileAsBuffer: (path: string) => Buffer;
|
||||
export declare const cacheCategories: (options: any, discourse: Discourser) => Promise<any>;
|
||||
export declare const cacheTopics: (options: any, discourse: Discourser) => Promise<void>;
|
||||
export declare const _getForumUsers: (d: Discourser, page: any, detail: any) => any;
|
||||
export declare const getForumUsers: (d: any, detail: any) => Promise<IDiscourseUser[]>;
|
||||
export declare const cacheUsers: (options: any, discourse: Discourser) => Promise<IDiscourseUser[]>;
|
||||
export declare const cacheTags: (options: any, discourse: Discourser) => Promise<any>;
|
||||
122
packages/discourse/lib/discourse/cache.js
Normal file
122
packages/discourse/lib/discourse/cache.js
Normal file
File diff suppressed because one or more lines are too long
70
packages/discourse/lib/discourse/constants.d.ts
vendored
Normal file
70
packages/discourse/lib/discourse/constants.d.ts
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
export type EDiscourseConfigKey = 'discourse' | 'discourse_admin';
|
||||
export declare const SYNC_TRACK_FILENAME = "discourse-sync.json";
|
||||
export declare const OSR_CACHE_ROOT = "${OSR_CACHE}";
|
||||
export declare const OSR_DISCOURSE_CACHE = "${OSR_CACHE}/discourse";
|
||||
export declare const DISCOURSE_CATEGORY_CACHE = "${OSR_CACHE}/discourse/cats.json";
|
||||
export declare const DISCOURSE_TOPICS_CACHE = "${OSR_CACHE}/discourse/topics.json";
|
||||
export declare const DISCOURSE_TAGS_CACHE = "${OSR_CACHE}/discourse/tags.json";
|
||||
export declare const DISCOURSE_USER_CACHE = "${OSR_CACHE}/discourse/users.json";
|
||||
export declare const OA_DIRECTORY_OVERVIEW_TOPIC = 28873;
|
||||
export declare const OA_USER_IMPORT_GROUP = 43;
|
||||
export declare const KB_USERS = "${KB_ROOT}/static/users";
|
||||
export declare const DATA_PATH = "${OSR_ROOT}/osr-directory/pp";
|
||||
export declare const LATEST_TRACK = "${OSR_ROOT}/osr-directory/pp/merged.json";
|
||||
export declare const LATEST_TEST = "./latest_test.json";
|
||||
export declare const FETCH_DUSERS = false;
|
||||
export declare const F_USERS_NOW = "./fusers.json";
|
||||
export declare const F_USERS_ALL = "./fusers-all.json";
|
||||
export declare const DEFAULT_PASSWORD: () => string;
|
||||
export declare const HOWTOS_ASSETS_URL: () => string;
|
||||
export declare const MACHINES_ASSETS_URL: () => string;
|
||||
export declare const CAT_TEST = 65;
|
||||
export declare const TAGS_TEST = "plastic, meta";
|
||||
export declare const DEFAULT_IMPORT_OWNER = 1;
|
||||
export declare const D_ROOT_CAT = 97;
|
||||
export declare const D_ROOT_AFRICA = 79;
|
||||
export declare const D_ROOT_ASIA = 60;
|
||||
export declare const D_ROOT_EUROPE = 59;
|
||||
export declare const D_ROOT_AUSTRALIA = 76;
|
||||
export declare const D_ROOT_NAMERICA = 101;
|
||||
export declare const D_ROOT_SAMERICA = 102;
|
||||
export declare const D_ROOT_OCEANIA = 103;
|
||||
export declare const HT_CAT_ROOT = 54;
|
||||
export declare const HT_CAT_GUIDES = 86;
|
||||
export declare const HT_CAT_MACHINES = 87;
|
||||
export declare const HT_CAT_PRODUCTS = 88;
|
||||
export declare const HT_CAT_MOULDS = 89;
|
||||
export declare const HT_CAT_IDS: {
|
||||
HT_CAT_ROOT: number;
|
||||
HT_CAT_GUIDES: number;
|
||||
HT_CAT_MACHINES: number;
|
||||
HT_CAT_PRODUCTS: number;
|
||||
HT_CAT_MOULDS: number;
|
||||
};
|
||||
export declare const HT_CATS: {
|
||||
Guides: number;
|
||||
Machines: number;
|
||||
Products: number;
|
||||
Moulds: number;
|
||||
};
|
||||
export declare const MACHINE_CAT_INJECTION = 50;
|
||||
export declare const MACHINE_CAT_EXTRUSION = 51;
|
||||
export declare const MACHINE_CAT_SHREDDER = 52;
|
||||
export declare const MACHINE_CAT_SHEETPRESS = 63;
|
||||
export declare const MACHINE_CAT_3DPRINT = 70;
|
||||
export declare const MACHINE_CAT_MOULDS = 71;
|
||||
export declare const MACHINE_CAT_IDS: {
|
||||
MACHINE_CAT_INJECTION: number;
|
||||
MACHINE_CAT_EXTRUSION: number;
|
||||
MACHINE_CAT_SHREDDER: number;
|
||||
MACHINE_CAT_SHEETPRESS: number;
|
||||
MACHINE_CAT_3DPRINT: number;
|
||||
MACHINE_CAT_MOULDS: number;
|
||||
};
|
||||
export declare const MACHINE_CATS: {
|
||||
Injection: number;
|
||||
Extrusion: number;
|
||||
Sheetpress: number;
|
||||
'3DPrint': number;
|
||||
Moulds: number;
|
||||
};
|
||||
100
packages/discourse/lib/discourse/constants.js
Normal file
100
packages/discourse/lib/discourse/constants.js
Normal file
@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Keys
|
||||
//
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MACHINE_CATS = exports.MACHINE_CAT_IDS = exports.MACHINE_CAT_MOULDS = exports.MACHINE_CAT_3DPRINT = exports.MACHINE_CAT_SHEETPRESS = exports.MACHINE_CAT_SHREDDER = exports.MACHINE_CAT_EXTRUSION = exports.MACHINE_CAT_INJECTION = exports.HT_CATS = exports.HT_CAT_IDS = exports.HT_CAT_MOULDS = exports.HT_CAT_PRODUCTS = exports.HT_CAT_MACHINES = exports.HT_CAT_GUIDES = exports.HT_CAT_ROOT = exports.D_ROOT_OCEANIA = exports.D_ROOT_SAMERICA = exports.D_ROOT_NAMERICA = exports.D_ROOT_AUSTRALIA = exports.D_ROOT_EUROPE = exports.D_ROOT_ASIA = exports.D_ROOT_AFRICA = exports.D_ROOT_CAT = exports.DEFAULT_IMPORT_OWNER = exports.TAGS_TEST = exports.CAT_TEST = exports.MACHINES_ASSETS_URL = exports.HOWTOS_ASSETS_URL = exports.DEFAULT_PASSWORD = exports.F_USERS_ALL = exports.F_USERS_NOW = exports.FETCH_DUSERS = exports.LATEST_TEST = exports.LATEST_TRACK = exports.DATA_PATH = exports.KB_USERS = exports.OA_USER_IMPORT_GROUP = exports.OA_DIRECTORY_OVERVIEW_TOPIC = exports.DISCOURSE_USER_CACHE = exports.DISCOURSE_TAGS_CACHE = exports.DISCOURSE_TOPICS_CACHE = exports.DISCOURSE_CATEGORY_CACHE = exports.OSR_DISCOURSE_CACHE = exports.OSR_CACHE_ROOT = exports.SYNC_TRACK_FILENAME = void 0;
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Paths
|
||||
//
|
||||
exports.SYNC_TRACK_FILENAME = 'discourse-sync.json';
|
||||
exports.OSR_CACHE_ROOT = '${OSR_CACHE}';
|
||||
exports.OSR_DISCOURSE_CACHE = '${OSR_CACHE}/discourse';
|
||||
exports.DISCOURSE_CATEGORY_CACHE = '${OSR_CACHE}/discourse/cats.json';
|
||||
exports.DISCOURSE_TOPICS_CACHE = '${OSR_CACHE}/discourse/topics.json';
|
||||
exports.DISCOURSE_TAGS_CACHE = '${OSR_CACHE}/discourse/tags.json';
|
||||
exports.DISCOURSE_USER_CACHE = '${OSR_CACHE}/discourse/users.json';
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OA - User Import
|
||||
//
|
||||
exports.OA_DIRECTORY_OVERVIEW_TOPIC = 28873;
|
||||
exports.OA_USER_IMPORT_GROUP = 43;
|
||||
exports.KB_USERS = '${KB_ROOT}/static/users';
|
||||
exports.DATA_PATH = '${OSR_ROOT}/osr-directory/pp';
|
||||
exports.LATEST_TRACK = '${OSR_ROOT}/osr-directory/pp/merged.json';
|
||||
exports.LATEST_TEST = './latest_test.json';
|
||||
exports.FETCH_DUSERS = false;
|
||||
exports.F_USERS_NOW = './fusers.json';
|
||||
exports.F_USERS_ALL = './fusers-all.json';
|
||||
const DEFAULT_PASSWORD = () => '4g0&KPN$e*Un';
|
||||
exports.DEFAULT_PASSWORD = DEFAULT_PASSWORD;
|
||||
const HOWTOS_ASSETS_URL = () => `https://kb.osr-plastic.org/howtos/`;
|
||||
exports.HOWTOS_ASSETS_URL = HOWTOS_ASSETS_URL;
|
||||
const MACHINES_ASSETS_URL = () => `https://assets.osr-plastic.org/machines/`;
|
||||
exports.MACHINES_ASSETS_URL = MACHINES_ASSETS_URL;
|
||||
exports.CAT_TEST = 65;
|
||||
exports.TAGS_TEST = 'plastic, meta';
|
||||
exports.DEFAULT_IMPORT_OWNER = 1;
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OA - Directory Import
|
||||
//
|
||||
exports.D_ROOT_CAT = 97;
|
||||
exports.D_ROOT_AFRICA = 79;
|
||||
exports.D_ROOT_ASIA = 60;
|
||||
exports.D_ROOT_EUROPE = 59;
|
||||
exports.D_ROOT_AUSTRALIA = 76;
|
||||
exports.D_ROOT_NAMERICA = 101;
|
||||
exports.D_ROOT_SAMERICA = 102;
|
||||
exports.D_ROOT_OCEANIA = 103;
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OA - Howto Import
|
||||
//
|
||||
exports.HT_CAT_ROOT = 54;
|
||||
exports.HT_CAT_GUIDES = 86;
|
||||
exports.HT_CAT_MACHINES = 87;
|
||||
exports.HT_CAT_PRODUCTS = 88;
|
||||
exports.HT_CAT_MOULDS = 89;
|
||||
exports.HT_CAT_IDS = {
|
||||
HT_CAT_ROOT: exports.HT_CAT_ROOT,
|
||||
HT_CAT_GUIDES: exports.HT_CAT_GUIDES,
|
||||
HT_CAT_MACHINES: exports.HT_CAT_MACHINES,
|
||||
HT_CAT_PRODUCTS: exports.HT_CAT_PRODUCTS,
|
||||
HT_CAT_MOULDS: exports.HT_CAT_MOULDS
|
||||
};
|
||||
exports.HT_CATS = {
|
||||
'Guides': exports.HT_CAT_GUIDES,
|
||||
'Machines': exports.HT_CAT_MACHINES,
|
||||
'Products': exports.HT_CAT_PRODUCTS,
|
||||
'Moulds': exports.HT_CAT_MOULDS
|
||||
};
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OA - Library Import
|
||||
//
|
||||
exports.MACHINE_CAT_INJECTION = 50;
|
||||
exports.MACHINE_CAT_EXTRUSION = 51;
|
||||
exports.MACHINE_CAT_SHREDDER = 52;
|
||||
exports.MACHINE_CAT_SHEETPRESS = 63;
|
||||
exports.MACHINE_CAT_3DPRINT = 70;
|
||||
exports.MACHINE_CAT_MOULDS = 71;
|
||||
exports.MACHINE_CAT_IDS = {
|
||||
MACHINE_CAT_INJECTION: exports.MACHINE_CAT_INJECTION,
|
||||
MACHINE_CAT_EXTRUSION: exports.MACHINE_CAT_EXTRUSION,
|
||||
MACHINE_CAT_SHREDDER: exports.MACHINE_CAT_SHREDDER,
|
||||
MACHINE_CAT_SHEETPRESS: exports.MACHINE_CAT_SHEETPRESS,
|
||||
MACHINE_CAT_3DPRINT: exports.MACHINE_CAT_3DPRINT,
|
||||
MACHINE_CAT_MOULDS: exports.MACHINE_CAT_MOULDS
|
||||
};
|
||||
exports.MACHINE_CATS = {
|
||||
'Injection': exports.MACHINE_CAT_INJECTION,
|
||||
'Extrusion': exports.MACHINE_CAT_EXTRUSION,
|
||||
'Sheetpress': exports.MACHINE_CAT_SHEETPRESS,
|
||||
'3DPrint': exports.MACHINE_CAT_3DPRINT,
|
||||
'Moulds': exports.HT_CAT_MOULDS
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9kaXNjb3Vyc2UvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFDQSw4REFBOEQ7QUFDOUQsRUFBRTtBQUNGLFFBQVE7QUFDUixFQUFFOzs7QUFJRiw4REFBOEQ7QUFDOUQsRUFBRTtBQUNGLFNBQVM7QUFDVCxFQUFFO0FBRVcsUUFBQSxtQkFBbUIsR0FBRyxxQkFBcUIsQ0FBQTtBQUUzQyxRQUFBLGNBQWMsR0FBRyxjQUFjLENBQUE7QUFDL0IsUUFBQSxtQkFBbUIsR0FBRyx3QkFBd0IsQ0FBQTtBQUU5QyxRQUFBLHdCQUF3QixHQUFHLGtDQUFrQyxDQUFBO0FBQzdELFFBQUEsc0JBQXNCLEdBQUcsb0NBQW9DLENBQUE7QUFDN0QsUUFBQSxvQkFBb0IsR0FBRyxrQ0FBa0MsQ0FBQTtBQUN6RCxRQUFBLG9CQUFvQixHQUFHLG1DQUFtQyxDQUFBO0FBRXZFLDhEQUE4RDtBQUM5RCxFQUFFO0FBQ0Ysb0JBQW9CO0FBQ3BCLE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tQkFBbUIsR0FBRyxFQUFFLENBQUE7QUFDeEIsUUFBQSxrQkFBa0IsR0FBRyxFQUFFLENBQUE7QUFFdkIsUUFBQSxlQUFlLEdBQUc7SUFDM0IscUJBQXFCLEVBQXJCLDZCQUFxQjtJQUNyQixxQkFBcUIsRUFBckIsNkJBQXFCO0lBQ3JCLG9CQUFvQixFQUFwQiw0QkFBb0I7SUFDcEIsc0JBQXNCLEVBQXRCLDhCQUFzQjtJQUN0QixtQkFBbUIsRUFBbkIsMkJBQW1CO0lBQ25CLGtCQUFrQixFQUFsQiwwQkFBa0I7Q0FDckIsQ0FBQTtBQUVZLFFBQUEsWUFBWSxHQUFHO0lBQ3hCLFdBQVcsRUFBRSw2QkFBcUI7SUFDbEMsV0FBVyxFQUFFLDZCQUFxQjtJQUNsQyxZQUFZLEVBQUUsOEJBQXNCO0lBQ3BDLFNBQVMsRUFBRSwyQkFBbUI7SUFDOUIsUUFBUSxFQUFFLHFCQUFhO0NBQzFCLENBQUEifQ==
|
||||
181
packages/discourse/lib/discourse/index.d.ts
vendored
Normal file
181
packages/discourse/lib/discourse/index.d.ts
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
export declare const logger: any;
|
||||
import PromisePool from 'native-promise-pool';
|
||||
export declare const escape: (path: string) => string;
|
||||
import { TPostStatus, TPostStatusUpdate, UserPreferencesUpdate } from './types';
|
||||
import { Category, CategoriesResponse, PostsResponse, PostResponse, TopicResponse, TopicItem, CategoryResponse, PostItem, PostUpdateItem, IDiscourserConfig, Thread, PostModifier, FetchConfig, FetchOptions, ISearchResult, ICreateUserResponse, IUserDetail, TagsResponse, Tag, TopicUpdateBasicTopic } from './types';
|
||||
import { IDiscourseUser } from '@plastichub/osr-commons';
|
||||
import { EDiscourseConfigKey } from './constants';
|
||||
import { IDImage } from '../oa/index';
|
||||
/**
|
||||
* Discourser is an API Client for the [Discourse API](https://docs.discourse.org)
|
||||
* It special features are:
|
||||
* - TypeScript Types
|
||||
* - Respecting Rate Limits
|
||||
* - Optional Heavy Caching
|
||||
* - Post Modifiers (can be used for global find and replace across all posts on the forum)
|
||||
*/
|
||||
export declare class Discourser {
|
||||
readonly host: string;
|
||||
readonly key: string;
|
||||
readonly username: string;
|
||||
readonly cache?: string;
|
||||
readonly useCache?: boolean;
|
||||
readonly dry: boolean;
|
||||
readonly pool: PromisePool<any>;
|
||||
/**
|
||||
* Construct our Discourser instance
|
||||
* See {@link IDiscourserConfig} for available configuration.
|
||||
*/
|
||||
constructor(config: IDiscourserConfig);
|
||||
/** Get the URL of a topic */
|
||||
getTopicURL(topic: TopicItem | TopicResponse | number): string;
|
||||
/** Fetch a discourse API URL, with rate limit concurrency and optional caching */
|
||||
fetch<T>({ url, useCache, request }: FetchConfig): Promise<T>;
|
||||
/** Fetch a discourse API URL, with rate limit retries */
|
||||
private _post;
|
||||
/** Fetch a discourse API URL, with rate limit retries */
|
||||
private _fetch;
|
||||
/**
|
||||
* API Helper for {@link .search}
|
||||
* https://docs.discourse.org/#tag/Search/operation/search
|
||||
*/
|
||||
search(query: string, params?: string, opts?: FetchOptions): Promise<ISearchResult>;
|
||||
/**
|
||||
* API Helper for {@link .getTags}
|
||||
*/
|
||||
protected getTagsResponse(opts?: FetchOptions): Promise<TagsResponse>;
|
||||
/**
|
||||
* Fetch the whole information, for all categories of the forum
|
||||
*/
|
||||
getTags(opts?: FetchOptions): Promise<Tag[]>;
|
||||
createTag(name: any): Promise<any>;
|
||||
/**
|
||||
* API Helper for {@link .getCategories}
|
||||
*/
|
||||
protected getCategoriesResponse(opts?: FetchOptions): Promise<CategoriesResponse>;
|
||||
/**
|
||||
* Fetch the whole information, for all categories of the forum
|
||||
*/
|
||||
getCategories(opts?: FetchOptions): Promise<Category[]>;
|
||||
/**
|
||||
* API Helper for {@link .getTopicItemsOfCategory}
|
||||
* Discourse does not provide an API for fetching category information for a specific category.
|
||||
* Instead, all that it provides is a way of getting the topics for a specific category.
|
||||
*/
|
||||
protected getCategoryResponse(categoryID: number, opts?: FetchOptions): Promise<CategoryResponse>;
|
||||
/**
|
||||
* Fetch the partial information, for all topics of a specific category
|
||||
*/
|
||||
getTopicItemsOfCategory(categoryID: number, opts?: FetchOptions): Promise<TopicItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all topics of specific categoires
|
||||
*/
|
||||
getTopicItemsOfCategories(categoryIDs: number[], opts?: FetchOptions): Promise<TopicItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all topics of the forum
|
||||
*/
|
||||
getTopicItems(opts?: FetchOptions): Promise<TopicItem[]>;
|
||||
/**
|
||||
* Fetch the whole information, for a specific topic of the forum
|
||||
*/
|
||||
getTopic(id: number, opts?: FetchOptions): Promise<TopicResponse>;
|
||||
/**
|
||||
* Fetch the whole information, for all topics, or specific topics, of the forum
|
||||
*/
|
||||
getTopics(topicIDs?: number[] | null, opts?: FetchOptions): Promise<TopicItem[] | TopicResponse[]>;
|
||||
updateTopicVisibility(topicID: number, listed?: boolean, visible?: TPostStatus): Promise<TPostStatusUpdate>;
|
||||
updateTopicTimestamp(topicID: number, timestamp: Date | string | number, token: string): Promise<any>;
|
||||
/**
|
||||
* API Helper for {@link .getPostItemsOfTopic}
|
||||
*/
|
||||
protected getPostItemsOfTopicResponse(topicID: number, opts?: FetchOptions): Promise<PostsResponse>;
|
||||
_createUser(name: any, email: any, pUserGroup: any): Promise<ICreateUserResponse>;
|
||||
getUsers(page: any): Promise<IDiscourseUser>;
|
||||
getUser(id: any): Promise<IUserDetail>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of a specific topic
|
||||
*/
|
||||
getPostItemsOfTopic(topicID: number, opts?: FetchOptions): Promise<PostItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of specific topics
|
||||
*/
|
||||
getPostItemsOfTopics(topicIDs: number[], opts?: FetchOptions): Promise<PostItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of a specific category
|
||||
*/
|
||||
getPostItemsOfCategory(categoryID: number, opts?: FetchOptions): Promise<PostItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of specific categories
|
||||
*/
|
||||
getPostItemsOfCategories(categoryIDs: number[], opts?: FetchOptions): Promise<PostItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of the forum
|
||||
*/
|
||||
getPostItems(opts?: FetchOptions): Promise<PostItem[]>;
|
||||
/**
|
||||
* Fetch the whole information, for a specific post of the forum
|
||||
*/
|
||||
getPost(id: number, opts?: FetchOptions): Promise<PostResponse>;
|
||||
createReply(postId: any, raw: any, category: any): Promise<unknown>;
|
||||
changeOwner(postId: string | number, topicId: string | number, owner: string): Promise<unknown>;
|
||||
createUser(data: any): Promise<ICreateUserResponse>;
|
||||
getUserByUsername(username: any): Promise<IUserDetail>;
|
||||
setUserAvatar(user_name: any, upload_id: any): Promise<PostResponse[]>;
|
||||
updateUser(user_name: any, args: any): Promise<PostResponse[]>;
|
||||
updateGroup(user_name: any, group: any): Promise<import("axios").AxiosResponse<any, any>>;
|
||||
upload(userId: any, file: any): Promise<IDImage[]>;
|
||||
uploadFile(userId: any, file: any): Promise<PostResponse[]>;
|
||||
/**
|
||||
* Fetch the whole information, for all posts, or specific posts, of the forum
|
||||
*/
|
||||
getPosts(postIDs?: number[] | null, opts?: FetchOptions): Promise<PostResponse[]>;
|
||||
createPost(title: string, raw: string, category: number): Promise<unknown>;
|
||||
/**
|
||||
* Update a post with the content
|
||||
* @param postID the identifier of the post to update
|
||||
* @param content the new raw content for the post
|
||||
* @param reason the reason, if provided, for modifying the post
|
||||
* @param old if the old raw content is provided, then the update verified that you are working with the latest post content before applying the update
|
||||
*/
|
||||
updatePost(postID: number, content: string, reason?: string, old?: string): Promise<PostUpdateItem>;
|
||||
/**
|
||||
* Update post meta
|
||||
*/
|
||||
updateTopic(postId: number, category_id: number, title: string, tags?: string[]): Promise<TopicUpdateBasicTopic>;
|
||||
rebakePost(postID: number): Promise<any>;
|
||||
/**
|
||||
* Modify a post using a modifier
|
||||
*/
|
||||
modifyPost(post: PostResponse, modifier: PostModifier): Promise<PostUpdateItem | null>;
|
||||
/**
|
||||
* Modify a post (via its post identifier) using a modifier
|
||||
*/
|
||||
modifyPostID(post: number, modifier: PostModifier): Promise<PostUpdateItem>;
|
||||
/**
|
||||
* Modify a post (via fetching the whole post from the partial post identifier) using a modifier
|
||||
*/
|
||||
modifyPostItem(post: PostItem, modifier: PostModifier): Promise<PostUpdateItem>;
|
||||
/**
|
||||
* Run the post modifier on all specified posts
|
||||
*/
|
||||
modifyPosts(posts: PostResponse[], modifier: PostModifier): Promise<PostUpdateItem[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of a specific topic
|
||||
* Alias of {@link .getPostItemsOfTopic}.
|
||||
*/
|
||||
getThread(topicID: number, opts?: FetchOptions): Promise<Thread>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of specific topics, grouped by topic
|
||||
*/
|
||||
getThreads(topicIDs: number[], opts?: FetchOptions): Promise<Thread[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of specific categories, grouped by topic
|
||||
*/
|
||||
getThreadsOfCategory(categoryID: number, opts?: FetchOptions): Promise<Thread[]>;
|
||||
/**
|
||||
* Fetch the partial information, for all posts of specific categories, grouped by category, then topic
|
||||
*/
|
||||
getThreadsOfCategories(categoryIDs: number[], opts?: FetchOptions): Promise<Thread[][]>;
|
||||
updateUserProfile(userId: any, prefs: UserPreferencesUpdate): Promise<any>;
|
||||
}
|
||||
export declare const Instance: (config?: IDiscourseConfig, key?: EDiscourseConfigKey) => Discourser;
|
||||
936
packages/discourse/lib/discourse/index.js
Normal file
936
packages/discourse/lib/discourse/index.js
Normal file
File diff suppressed because one or more lines are too long
1
packages/discourse/lib/discourse/index.js.map
Normal file
1
packages/discourse/lib/discourse/index.js.map
Normal file
File diff suppressed because one or more lines are too long
697
packages/discourse/lib/discourse/types.d.ts
vendored
Normal file
697
packages/discourse/lib/discourse/types.d.ts
vendored
Normal file
@ -0,0 +1,697 @@
|
||||
export interface Failure {
|
||||
success: 'OK';
|
||||
}
|
||||
export interface Success {
|
||||
failed: 'FAILED';
|
||||
}
|
||||
export type Response = Failure & Success;
|
||||
export interface Action {
|
||||
can_act: boolean;
|
||||
id: number;
|
||||
count?: number;
|
||||
hidden?: boolean;
|
||||
}
|
||||
export interface Poster {
|
||||
description: string;
|
||||
extras: string;
|
||||
user_id: number;
|
||||
}
|
||||
export interface Person {
|
||||
avatar_template: string;
|
||||
id: number;
|
||||
username: string;
|
||||
}
|
||||
export interface Participant extends Person {
|
||||
post_count: number;
|
||||
}
|
||||
export interface Link {
|
||||
url: string;
|
||||
internal: boolean;
|
||||
reflection: boolean;
|
||||
title: string;
|
||||
clicks: number;
|
||||
}
|
||||
/**
|
||||
* Update a Topic Timestamp
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}~1change-timestamp/put
|
||||
*/
|
||||
export interface TopicUpdateTimestampRequest {
|
||||
timestamp: number;
|
||||
}
|
||||
export type TopicUpdateTimestampResponse = Response;
|
||||
/**
|
||||
* Update a Post
|
||||
* https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/put
|
||||
*/
|
||||
export interface PostUpdateResponse {
|
||||
post: PostUpdateItem;
|
||||
}
|
||||
export interface TopicUpdateBasicTopic {
|
||||
fancy_title: string;
|
||||
id: number;
|
||||
posts_count: number;
|
||||
slug: string;
|
||||
title: string;
|
||||
}
|
||||
export interface TopicUpdateResponse {
|
||||
basic_topic: TopicUpdateBasicTopic;
|
||||
}
|
||||
export interface PostUpdateItem {
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
avg_time: object;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
display_username: string;
|
||||
draft_sequence: number;
|
||||
edit_reason: object;
|
||||
hidden_reason_id: object;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: object;
|
||||
primary_group_flair_color: object;
|
||||
primary_group_flair_url: object;
|
||||
primary_group_name: object;
|
||||
quote_count: number;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: object;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
export interface PostUpdateRequest {
|
||||
post: {
|
||||
raw: string;
|
||||
raw_old?: string;
|
||||
edit_reason?: string;
|
||||
cooked?: string;
|
||||
};
|
||||
}
|
||||
export interface TagsResponse {
|
||||
tags: Tag[];
|
||||
extras: TagsExtras;
|
||||
}
|
||||
export interface TagsExtras {
|
||||
categories: any[];
|
||||
}
|
||||
export interface Tag {
|
||||
count: number;
|
||||
description: null;
|
||||
id: string;
|
||||
name: string;
|
||||
pm_only: boolean;
|
||||
target_tag: null;
|
||||
text: string;
|
||||
}
|
||||
/** https://docs.discourse.org/#tag/Categories/paths/~1categories.json/get */
|
||||
export interface CategoriesResponse {
|
||||
category_list: {
|
||||
can_create_category: boolean;
|
||||
can_create_topic: boolean;
|
||||
categories: Category[];
|
||||
draft_key: string;
|
||||
draft_sequence: number;
|
||||
draft: boolean;
|
||||
};
|
||||
}
|
||||
export interface Category {
|
||||
background_url: string;
|
||||
can_edit: boolean;
|
||||
color: string;
|
||||
description_excerpt: string;
|
||||
description_text: string;
|
||||
description: string;
|
||||
has_children: boolean;
|
||||
id: number;
|
||||
logo_url: string;
|
||||
name: string;
|
||||
notification_level: string;
|
||||
permission: number;
|
||||
position: number;
|
||||
post_count: number;
|
||||
read_restricted: boolean;
|
||||
slug: string;
|
||||
text_color: string;
|
||||
topic_count: number;
|
||||
topic_template: string;
|
||||
topic_url: string;
|
||||
topics_all_time: number;
|
||||
topics_day: number;
|
||||
topics_month: number;
|
||||
topics_week: number;
|
||||
topics_year: number;
|
||||
}
|
||||
/**
|
||||
* Get Single Topic
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}.json/get
|
||||
*/
|
||||
export interface TopicResponse {
|
||||
actions_summary: Array<Action>;
|
||||
archetype: string;
|
||||
archived: boolean;
|
||||
bookmarked: object;
|
||||
category_id: number;
|
||||
chunk_size: number;
|
||||
closed: boolean;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
deleted_by: object;
|
||||
details: TopicDetails;
|
||||
draft_key: string;
|
||||
draft_sequence: object;
|
||||
draft: object;
|
||||
fancy_title: string;
|
||||
has_summary: boolean;
|
||||
highest_post_number: number;
|
||||
id: number;
|
||||
last_posted_at: object;
|
||||
like_count: number;
|
||||
participant_count: number;
|
||||
pinned_at: string;
|
||||
pinned_globally: boolean;
|
||||
pinned_until: object;
|
||||
pinned: boolean;
|
||||
posts_count: number;
|
||||
reply_count: number;
|
||||
slug: string;
|
||||
tags: string[];
|
||||
title: string;
|
||||
unpinned: object;
|
||||
user_id: number;
|
||||
views: number;
|
||||
visible: boolean;
|
||||
word_count: object;
|
||||
post_stream: {
|
||||
posts: Array<PostItem>;
|
||||
stream: Array<object>;
|
||||
};
|
||||
timeline_lookup: [
|
||||
{
|
||||
'0': Array<object>;
|
||||
}
|
||||
];
|
||||
}
|
||||
export interface TopicDetails {
|
||||
auto_close_at: object;
|
||||
auto_close_based_on_last_post: boolean;
|
||||
auto_close_hours: object;
|
||||
can_flag_topic: boolean;
|
||||
created_by: Person;
|
||||
last_poster: Person;
|
||||
notification_level: number;
|
||||
participants: Array<Participant>;
|
||||
suggested_topics: Array<TopicItem>;
|
||||
}
|
||||
export interface TopicItem {
|
||||
archetype: string;
|
||||
archived: boolean;
|
||||
bookmarked: object;
|
||||
bumped_at: string;
|
||||
bumped: boolean;
|
||||
category_id: number;
|
||||
closed: boolean;
|
||||
created_at: string;
|
||||
excerpt: string;
|
||||
fancy_title: string;
|
||||
has_summary: boolean;
|
||||
highest_post_number: number;
|
||||
id: number;
|
||||
image_url: string;
|
||||
last_posted_at: string;
|
||||
last_poster_username: string;
|
||||
like_count: number;
|
||||
liked: object;
|
||||
pinned_globally: boolean;
|
||||
pinned: boolean;
|
||||
posters: Array<Poster>;
|
||||
posts_count: number;
|
||||
reply_count: number;
|
||||
slug: string;
|
||||
title: string;
|
||||
unpinned: boolean;
|
||||
unseen: boolean;
|
||||
views: number;
|
||||
visible: boolean;
|
||||
}
|
||||
/**
|
||||
* Get Topics for Category
|
||||
* https://docs.discourse.org/#tag/Categories/paths/~1c~1{id}.json/get
|
||||
*/
|
||||
export interface CategoryResponse {
|
||||
users: Person[];
|
||||
topic_list: {
|
||||
can_create_topic: boolean;
|
||||
draft: boolean;
|
||||
draft_key: string;
|
||||
draft_sequence: number;
|
||||
per_page: number;
|
||||
topics: Array<TopicItem>;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Whole Post Information
|
||||
* As returned by getting a single Post
|
||||
* https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/get
|
||||
*/
|
||||
export interface PostResponse {
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
avg_time: object;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
display_username: string;
|
||||
edit_reason: object;
|
||||
hidden_reason_id: object;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: object;
|
||||
primary_group_flair_color: object;
|
||||
primary_group_flair_url: object;
|
||||
primary_group_name: object;
|
||||
quote_count: number;
|
||||
raw: string;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: object;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
export interface ICreateUserResponse {
|
||||
success: boolean;
|
||||
active: boolean;
|
||||
message: string;
|
||||
user_id: number;
|
||||
password: string;
|
||||
}
|
||||
/**
|
||||
* Get the Posts of a Topic
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}~1posts.json/get
|
||||
*/
|
||||
export interface PostsResponse {
|
||||
post_stream: {
|
||||
posts: Array<PostItem>;
|
||||
};
|
||||
id: number;
|
||||
}
|
||||
/**
|
||||
* Partial Post Information
|
||||
* As returned by a listing
|
||||
*/
|
||||
export interface PostItem {
|
||||
accepted_answer: boolean;
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
can_accept_answer: boolean;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_unaccept_answer: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: null;
|
||||
display_username: string;
|
||||
edit_reason: null;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
link_counts: Array<Link>;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: null | object;
|
||||
primary_group_flair_color: null | object;
|
||||
primary_group_flair_url: null | object;
|
||||
primary_group_name: null | object;
|
||||
quote_count: number;
|
||||
read: boolean;
|
||||
readers_count: number;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: null | number;
|
||||
reviewable_id: number;
|
||||
reviewable_score_count: number;
|
||||
reviewable_score_pending_count: number;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: null | object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
export type Thread = {
|
||||
topic: TopicResponse;
|
||||
post: PostItem;
|
||||
replies: PostItem[];
|
||||
};
|
||||
/** When finding and replacing, determine replacements using a method that matches this */
|
||||
export type PostModifier = (post: PostResponse) => {
|
||||
result: string;
|
||||
reason?: string;
|
||||
};
|
||||
/** Configuration for Discourser */
|
||||
export interface IDiscourserConfig {
|
||||
/** the discourse hostname to connect to, including protocol */
|
||||
host: string;
|
||||
/** the API key to connect with */
|
||||
key: string;
|
||||
/** the username to behave as */
|
||||
username: string;
|
||||
/** the cache directory to use, if we are caching */
|
||||
cache?: string;
|
||||
/** Whether or not we should read from the cache */
|
||||
useCache?: boolean;
|
||||
/** whether or not updates should be dry (non-applying) */
|
||||
dry?: boolean;
|
||||
/** how many concurrency requests to send to the server at once */
|
||||
rateLimitConcurrency?: number;
|
||||
}
|
||||
export interface FetchOptions {
|
||||
/** Whether or not we should read from the cache */
|
||||
useCache?: boolean;
|
||||
/** Only applicable to fetching topics of category */
|
||||
page?: number;
|
||||
/** Any thing to init the fetch call with? */
|
||||
request?: RequestInit;
|
||||
include_subcategories?: boolean;
|
||||
}
|
||||
export interface FetchConfig extends FetchOptions {
|
||||
url: string;
|
||||
}
|
||||
export interface PostConfig extends FetchOptions {
|
||||
url: string;
|
||||
data: any;
|
||||
}
|
||||
export interface ISearchPost {
|
||||
id: number;
|
||||
name: string;
|
||||
username: string;
|
||||
avatar_template: string;
|
||||
created_at: Date;
|
||||
like_count: number;
|
||||
blurb: string;
|
||||
post_number: number;
|
||||
topic_id: number;
|
||||
}
|
||||
export interface ISearchTagsDescriptions {
|
||||
}
|
||||
export interface ISearchTopic {
|
||||
id: number;
|
||||
title: string;
|
||||
fancy_title: string;
|
||||
slug: string;
|
||||
posts_count: number;
|
||||
reply_count: number;
|
||||
highest_post_number: number;
|
||||
created_at: Date;
|
||||
last_posted_at: Date;
|
||||
bumped: boolean;
|
||||
bumped_at: Date;
|
||||
archetype: string;
|
||||
unseen: boolean;
|
||||
pinned: boolean;
|
||||
unpinned?: any;
|
||||
excerpt: string;
|
||||
visible: boolean;
|
||||
closed: boolean;
|
||||
archived: boolean;
|
||||
bookmarked?: any;
|
||||
liked?: any;
|
||||
tags: any[];
|
||||
tags_descriptions: ISearchTagsDescriptions;
|
||||
category_id: number;
|
||||
has_accepted_answer: boolean;
|
||||
}
|
||||
export interface IGroupedSearchResult {
|
||||
more_posts?: any;
|
||||
more_users?: any;
|
||||
more_categories?: any;
|
||||
term: string;
|
||||
search_log_id: number;
|
||||
more_full_page_results?: any;
|
||||
can_create_topic: boolean;
|
||||
error?: any;
|
||||
post_ids: number[];
|
||||
user_ids: any[];
|
||||
category_ids: any[];
|
||||
tag_ids: any[];
|
||||
group_ids: any[];
|
||||
}
|
||||
export interface ISearchResult {
|
||||
posts: ISearchPost[];
|
||||
topics: ISearchTopic[];
|
||||
users: any[];
|
||||
categories: any[];
|
||||
tags: any[];
|
||||
groups: any[];
|
||||
grouped_search_result: IGroupedSearchResult;
|
||||
}
|
||||
export interface IUserDetail {
|
||||
id: number;
|
||||
username: string;
|
||||
name: string;
|
||||
avatar_template: string;
|
||||
email: string;
|
||||
secondary_emails: any[];
|
||||
active: boolean;
|
||||
admin: boolean;
|
||||
moderator: boolean;
|
||||
last_seen_at: string;
|
||||
last_emailed_at: string;
|
||||
created_at: string;
|
||||
last_seen_age: number;
|
||||
last_emailed_age: number;
|
||||
created_at_age: number;
|
||||
trust_level: number;
|
||||
manual_locked_trust_level: any;
|
||||
flag_level: number;
|
||||
title: string;
|
||||
time_read: number;
|
||||
staged: boolean;
|
||||
days_visited: number;
|
||||
posts_read_count: number;
|
||||
topics_entered: number;
|
||||
post_count: number;
|
||||
associated_accounts: AssociatedAccount[];
|
||||
can_send_activation_email: boolean;
|
||||
can_activate: boolean;
|
||||
can_deactivate: boolean;
|
||||
ip_address: string;
|
||||
registration_ip_address: string;
|
||||
can_grant_admin: boolean;
|
||||
can_revoke_admin: boolean;
|
||||
can_grant_moderation: boolean;
|
||||
can_revoke_moderation: boolean;
|
||||
can_impersonate: boolean;
|
||||
like_count: number;
|
||||
like_given_count: number;
|
||||
topic_count: number;
|
||||
post_edits_count: number;
|
||||
flags_given_count: number;
|
||||
flags_received_count: number;
|
||||
private_topics_count: number;
|
||||
can_delete_all_posts: boolean;
|
||||
can_be_deleted: boolean;
|
||||
can_be_anonymized: boolean;
|
||||
can_be_merged: boolean;
|
||||
full_suspend_reason: any;
|
||||
silence_reason: any;
|
||||
penalty_counts: PenaltyCounts;
|
||||
next_penalty: string;
|
||||
primary_group_id: any;
|
||||
badge_count: number;
|
||||
warnings_received_count: number;
|
||||
user_fields: UserFields;
|
||||
bounce_score: number;
|
||||
reset_bounce_score_after: any;
|
||||
can_view_action_logs: boolean;
|
||||
can_disable_second_factor: boolean;
|
||||
can_delete_sso_record: boolean;
|
||||
api_key_count: number;
|
||||
external_ids: ExternalIds;
|
||||
single_sign_on_record: any;
|
||||
approved_by: ApprovedBy;
|
||||
suspended_by: any;
|
||||
silenced_by: any;
|
||||
tl3_requirements: Tl3Requirements;
|
||||
groups: Group[];
|
||||
}
|
||||
export interface AssociatedAccount {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
export interface PenaltyCounts {
|
||||
silenced: number;
|
||||
suspended: number;
|
||||
}
|
||||
export interface UserFields {
|
||||
"1": string;
|
||||
"2": string;
|
||||
"3": string;
|
||||
"4": string;
|
||||
"5": string;
|
||||
}
|
||||
export interface ExternalIds {
|
||||
google_oauth2: string;
|
||||
}
|
||||
export interface ApprovedBy {
|
||||
id: number;
|
||||
username: string;
|
||||
name: string;
|
||||
avatar_template: string;
|
||||
}
|
||||
export interface Tl3Requirements {
|
||||
time_period: number;
|
||||
requirements_met: boolean;
|
||||
requirements_lost: boolean;
|
||||
trust_level_locked: boolean;
|
||||
on_grace_period: boolean;
|
||||
days_visited: number;
|
||||
min_days_visited: number;
|
||||
num_topics_replied_to: number;
|
||||
min_topics_replied_to: number;
|
||||
topics_viewed: number;
|
||||
min_topics_viewed: number;
|
||||
posts_read: number;
|
||||
min_posts_read: number;
|
||||
topics_viewed_all_time: number;
|
||||
min_topics_viewed_all_time: number;
|
||||
posts_read_all_time: number;
|
||||
min_posts_read_all_time: number;
|
||||
num_flagged_posts: number;
|
||||
max_flagged_posts: number;
|
||||
num_flagged_by_users: number;
|
||||
max_flagged_by_users: number;
|
||||
num_likes_given: number;
|
||||
min_likes_given: number;
|
||||
num_likes_received: number;
|
||||
min_likes_received: number;
|
||||
num_likes_received_days: number;
|
||||
min_likes_received_days: number;
|
||||
num_likes_received_users: number;
|
||||
min_likes_received_users: number;
|
||||
penalty_counts: PenaltyCounts2;
|
||||
}
|
||||
export interface PenaltyCounts2 {
|
||||
silenced: number;
|
||||
suspended: number;
|
||||
total: number;
|
||||
}
|
||||
export interface Group {
|
||||
id: number;
|
||||
automatic: boolean;
|
||||
name: string;
|
||||
display_name?: string;
|
||||
user_count: number;
|
||||
mentionable_level: number;
|
||||
messageable_level: number;
|
||||
visibility_level: number;
|
||||
primary_group: boolean;
|
||||
title: any;
|
||||
grant_trust_level?: number;
|
||||
incoming_email: any;
|
||||
has_messages: boolean;
|
||||
flair_url: any;
|
||||
flair_bg_color?: string;
|
||||
flair_color?: string;
|
||||
bio_raw?: string;
|
||||
bio_cooked?: string;
|
||||
bio_excerpt?: string;
|
||||
public_admission: boolean;
|
||||
public_exit: boolean;
|
||||
allow_membership_requests: boolean;
|
||||
full_name?: string;
|
||||
default_notification_level: number;
|
||||
membership_request_template: any;
|
||||
members_visibility_level: number;
|
||||
can_see_members: boolean;
|
||||
can_admin_group: boolean;
|
||||
publish_read_state: boolean;
|
||||
can_edit_group?: boolean;
|
||||
}
|
||||
export type TPostStatus = 'visible' | 'archived' | 'pinned' | 'closed';
|
||||
export interface TPostStatusUpdate {
|
||||
success: string;
|
||||
topic_status_update: any;
|
||||
}
|
||||
export interface UserPreferencesUpdate {
|
||||
bio_raw?: string;
|
||||
website?: string;
|
||||
location?: string;
|
||||
custom_fields?: CustomFields;
|
||||
timezone?: string;
|
||||
default_calendar?: string;
|
||||
profile_background_upload_url?: string;
|
||||
card_background_upload_url?: string;
|
||||
}
|
||||
export interface CustomFields {
|
||||
geo_location: GeoLocation;
|
||||
}
|
||||
export interface GeoLocation {
|
||||
lat: string;
|
||||
lon: string;
|
||||
address: string;
|
||||
countrycode: string;
|
||||
city: string;
|
||||
state: string;
|
||||
country: string;
|
||||
postalcode: string;
|
||||
boundingbox: string[];
|
||||
type: string;
|
||||
}
|
||||
5
packages/discourse/lib/discourse/types.js
Normal file
5
packages/discourse/lib/discourse/types.js
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
// Attempt at TypeScript Types for the Discourse API
|
||||
// https://docs.discourse.org
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2Rpc2NvdXJzZS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsb0RBQW9EO0FBQ3BELDZCQUE2QiJ9
|
||||
1
packages/discourse/lib/discourse/types.js.map
Normal file
1
packages/discourse/lib/discourse/types.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/discourse/types.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,6BAA6B"}
|
||||
130
packages/discourse/lib/discourse/types/bevry.d.ts
vendored
Normal file
130
packages/discourse/lib/discourse/types/bevry.d.ts
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
import { YoutubeVideoData } from '../youtube';
|
||||
import { PostItem, TopicResponse } from './discourse';
|
||||
export interface DatabaseJSON {
|
||||
users: {
|
||||
[id: string]: User;
|
||||
};
|
||||
videos: {
|
||||
[id: string]: VideoJSON;
|
||||
};
|
||||
series: {
|
||||
[id: string]: SeriesJSON;
|
||||
};
|
||||
youtube: {
|
||||
[id: string]: YoutubeVideoData;
|
||||
};
|
||||
transcripts: {
|
||||
[videoID: string]: string;
|
||||
};
|
||||
}
|
||||
export interface Database {
|
||||
users: {
|
||||
[id: string]: User;
|
||||
};
|
||||
videos: {
|
||||
[id: string]: Video;
|
||||
};
|
||||
series: {
|
||||
[id: string]: Series;
|
||||
};
|
||||
youtube: {
|
||||
[id: string]: YoutubeVideoData;
|
||||
};
|
||||
transcripts: {
|
||||
[videoID: string]: string;
|
||||
};
|
||||
}
|
||||
export interface YoutubeBase {
|
||||
youtubeID: string;
|
||||
youtubeURL: string;
|
||||
/** for videos, this is the video topic, for series, this is the tag, for meetings, this is null for now */
|
||||
forumURL?: string | null;
|
||||
studyURL?: string | null;
|
||||
/** utc iso string */
|
||||
datetime: string;
|
||||
name: string;
|
||||
}
|
||||
export interface YoutubeJSON extends YoutubeBase {
|
||||
author: string;
|
||||
}
|
||||
export interface Youtube extends YoutubeBase {
|
||||
author: User;
|
||||
toJSON: () => YoutubeJSON;
|
||||
}
|
||||
export interface NoteBase {
|
||||
forumURL: string;
|
||||
content: string;
|
||||
}
|
||||
export interface NoteJSON extends NoteBase {
|
||||
video: string;
|
||||
author: string;
|
||||
}
|
||||
export interface Note extends NoteBase {
|
||||
video: Video;
|
||||
author: User;
|
||||
toJSON: () => NoteJSON;
|
||||
}
|
||||
export interface CommentJSON extends NoteJSON {
|
||||
seconds: number;
|
||||
}
|
||||
export interface Comment extends Note {
|
||||
seconds: number;
|
||||
toJSON: () => CommentJSON;
|
||||
}
|
||||
export interface DiscussionBase {
|
||||
forumURL: string;
|
||||
name: string;
|
||||
datetime: string;
|
||||
}
|
||||
export interface DiscussionJSON extends DiscussionBase {
|
||||
video?: string | null;
|
||||
}
|
||||
export interface Discussion extends DiscussionBase {
|
||||
video?: Video | null;
|
||||
toJSON: () => DiscussionJSON;
|
||||
}
|
||||
export interface VideoBase {
|
||||
notes: Note[];
|
||||
discussions: Discussion[];
|
||||
comments: Comment[];
|
||||
thread: Thread;
|
||||
}
|
||||
export interface VideoJSON extends VideoBase, YoutubeJSON {
|
||||
series?: string | null;
|
||||
youtube: string;
|
||||
}
|
||||
export interface Video extends VideoBase, Youtube {
|
||||
series?: Series | null;
|
||||
youtube: YoutubeVideoData;
|
||||
toJSON: () => VideoJSON;
|
||||
}
|
||||
export interface SeriesRaw {
|
||||
youtubeID: string;
|
||||
youtubeURL: string;
|
||||
studyURL?: string | null;
|
||||
name: string;
|
||||
forumURL: string;
|
||||
}
|
||||
export interface SeriesJSON extends YoutubeJSON {
|
||||
videos: SeriesRaw[];
|
||||
}
|
||||
export interface Series extends Youtube {
|
||||
videos: Video[];
|
||||
toJSON: () => SeriesJSON;
|
||||
}
|
||||
export interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
profiles: Profile[];
|
||||
}
|
||||
export interface Profile {
|
||||
service: 'bevry' | 'youtube' | 'goodreads' | 'twitter' | 'email';
|
||||
value: string;
|
||||
url?: string;
|
||||
data?: object;
|
||||
}
|
||||
export type Thread = {
|
||||
topic: TopicResponse;
|
||||
post: PostItem;
|
||||
replies: PostItem[];
|
||||
};
|
||||
3
packages/discourse/lib/discourse/types/bevry.js
Normal file
3
packages/discourse/lib/discourse/types/bevry.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=bevry.js.map
|
||||
1
packages/discourse/lib/discourse/types/bevry.js.map
Normal file
1
packages/discourse/lib/discourse/types/bevry.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"bevry.js","sourceRoot":"","sources":["../../../src/lib/discourse/types/bevry.ts"],"names":[],"mappings":""}
|
||||
364
packages/discourse/lib/discourse/types/discourse.d.ts
vendored
Normal file
364
packages/discourse/lib/discourse/types/discourse.d.ts
vendored
Normal file
@ -0,0 +1,364 @@
|
||||
export interface Failure {
|
||||
success: 'OK';
|
||||
}
|
||||
export interface Success {
|
||||
failed: 'FAILED';
|
||||
}
|
||||
export type Response = Failure & Success;
|
||||
export interface Action {
|
||||
can_act: boolean;
|
||||
id: number;
|
||||
count?: number;
|
||||
hidden?: boolean;
|
||||
}
|
||||
export interface Poster {
|
||||
description: string;
|
||||
extras: string;
|
||||
user_id: number;
|
||||
}
|
||||
export interface Person {
|
||||
avatar_template: string;
|
||||
id: number;
|
||||
username: string;
|
||||
}
|
||||
export interface Participant extends Person {
|
||||
post_count: number;
|
||||
}
|
||||
export interface Link {
|
||||
url: string;
|
||||
internal: boolean;
|
||||
reflection: boolean;
|
||||
title: string;
|
||||
clicks: number;
|
||||
}
|
||||
/**
|
||||
* Update a Topic Timestamp
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}~1change-timestamp/put
|
||||
*/
|
||||
export interface TopicUpdateTimestampRequest {
|
||||
timestamp: number;
|
||||
}
|
||||
export type TopicUpdateTimestampResponse = Response;
|
||||
/**
|
||||
* Update a Post
|
||||
* https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/put
|
||||
*/
|
||||
export interface PostUpdateResponse {
|
||||
post: PostUpdateItem;
|
||||
}
|
||||
export interface PostUpdateItem {
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
avg_time: object;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
display_username: string;
|
||||
draft_sequence: number;
|
||||
edit_reason: object;
|
||||
hidden_reason_id: object;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: object;
|
||||
primary_group_flair_color: object;
|
||||
primary_group_flair_url: object;
|
||||
primary_group_name: object;
|
||||
quote_count: number;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: object;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
export interface PostUpdateRequest {
|
||||
post: {
|
||||
raw: string;
|
||||
raw_old?: string;
|
||||
edit_reason?: string;
|
||||
cooked?: string;
|
||||
};
|
||||
}
|
||||
/** https://docs.discourse.org/#tag/Categories/paths/~1categories.json/get */
|
||||
export interface CategoriesResponse {
|
||||
category_list: {
|
||||
can_create_category: boolean;
|
||||
can_create_topic: boolean;
|
||||
categories: Category[];
|
||||
draft_key: string;
|
||||
draft_sequence: number;
|
||||
draft: boolean;
|
||||
};
|
||||
}
|
||||
export interface Category {
|
||||
background_url: string;
|
||||
can_edit: boolean;
|
||||
color: string;
|
||||
description_excerpt: string;
|
||||
description_text: string;
|
||||
description: string;
|
||||
has_children: boolean;
|
||||
id: number;
|
||||
logo_url: string;
|
||||
name: string;
|
||||
notification_level: string;
|
||||
permission: number;
|
||||
position: number;
|
||||
post_count: number;
|
||||
read_restricted: boolean;
|
||||
slug: string;
|
||||
text_color: string;
|
||||
topic_count: number;
|
||||
topic_template: string;
|
||||
topic_url: string;
|
||||
topics_all_time: number;
|
||||
topics_day: number;
|
||||
topics_month: number;
|
||||
topics_week: number;
|
||||
topics_year: number;
|
||||
}
|
||||
/**
|
||||
* Get Single Topic
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}.json/get
|
||||
*/
|
||||
export interface TopicResponse {
|
||||
actions_summary: Array<Action>;
|
||||
archetype: string;
|
||||
archived: boolean;
|
||||
bookmarked: object;
|
||||
category_id: number;
|
||||
chunk_size: number;
|
||||
closed: boolean;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
deleted_by: object;
|
||||
details: TopicDetails;
|
||||
draft_key: string;
|
||||
draft_sequence: object;
|
||||
draft: object;
|
||||
fancy_title: string;
|
||||
has_summary: boolean;
|
||||
highest_post_number: number;
|
||||
id: number;
|
||||
last_posted_at: object;
|
||||
like_count: number;
|
||||
participant_count: number;
|
||||
pinned_at: string;
|
||||
pinned_globally: boolean;
|
||||
pinned_until: object;
|
||||
pinned: boolean;
|
||||
posts_count: number;
|
||||
reply_count: number;
|
||||
slug: string;
|
||||
tags: string[];
|
||||
title: string;
|
||||
unpinned: object;
|
||||
user_id: number;
|
||||
views: number;
|
||||
visible: boolean;
|
||||
word_count: object;
|
||||
post_stream: {
|
||||
posts: Array<PostItem>;
|
||||
stream: Array<object>;
|
||||
};
|
||||
timeline_lookup: [
|
||||
{
|
||||
'0': Array<object>;
|
||||
}
|
||||
];
|
||||
}
|
||||
export interface TopicDetails {
|
||||
auto_close_at: object;
|
||||
auto_close_based_on_last_post: boolean;
|
||||
auto_close_hours: object;
|
||||
can_flag_topic: boolean;
|
||||
created_by: Person;
|
||||
last_poster: Person;
|
||||
notification_level: number;
|
||||
participants: Array<Participant>;
|
||||
suggested_topics: Array<TopicItem>;
|
||||
}
|
||||
export interface TopicItem {
|
||||
archetype: string;
|
||||
archived: boolean;
|
||||
bookmarked: object;
|
||||
bumped_at: string;
|
||||
bumped: boolean;
|
||||
category_id: number;
|
||||
closed: boolean;
|
||||
created_at: string;
|
||||
excerpt: string;
|
||||
fancy_title: string;
|
||||
has_summary: boolean;
|
||||
highest_post_number: number;
|
||||
id: number;
|
||||
image_url: string;
|
||||
last_posted_at: string;
|
||||
last_poster_username: string;
|
||||
like_count: number;
|
||||
liked: object;
|
||||
pinned_globally: boolean;
|
||||
pinned: boolean;
|
||||
posters: Array<Poster>;
|
||||
posts_count: number;
|
||||
reply_count: number;
|
||||
slug: string;
|
||||
title: string;
|
||||
unpinned: boolean;
|
||||
unseen: boolean;
|
||||
views: number;
|
||||
visible: boolean;
|
||||
}
|
||||
/**
|
||||
* Get Topics for Category
|
||||
* https://docs.discourse.org/#tag/Categories/paths/~1c~1{id}.json/get
|
||||
*/
|
||||
export interface CategoryResponse {
|
||||
users: Person[];
|
||||
topic_list: {
|
||||
can_create_topic: boolean;
|
||||
draft: boolean;
|
||||
draft_key: string;
|
||||
draft_sequence: number;
|
||||
per_page: number;
|
||||
topics: Array<TopicItem>;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Whole Post Information
|
||||
* As returned by getting a single Post
|
||||
* https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/get
|
||||
*/
|
||||
export interface PostResponse {
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
avg_time: object;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: object;
|
||||
display_username: string;
|
||||
edit_reason: object;
|
||||
hidden_reason_id: object;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: object;
|
||||
primary_group_flair_color: object;
|
||||
primary_group_flair_url: object;
|
||||
primary_group_name: object;
|
||||
quote_count: number;
|
||||
raw: string;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: object;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
/**
|
||||
* Get the Posts of a Topic
|
||||
* https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}~1posts.json/get
|
||||
*/
|
||||
export interface PostsResponse {
|
||||
post_stream: {
|
||||
posts: Array<PostItem>;
|
||||
};
|
||||
id: number;
|
||||
}
|
||||
/**
|
||||
* Partial Post Information
|
||||
* As returned by a listing
|
||||
*/
|
||||
export interface PostItem {
|
||||
accepted_answer: boolean;
|
||||
actions_summary: Array<Action>;
|
||||
admin: boolean;
|
||||
avatar_template: string;
|
||||
can_accept_answer: boolean;
|
||||
can_delete: boolean;
|
||||
can_edit: boolean;
|
||||
can_recover: boolean;
|
||||
can_unaccept_answer: boolean;
|
||||
can_view_edit_history: boolean;
|
||||
can_wiki: boolean;
|
||||
cooked: string;
|
||||
created_at: string;
|
||||
deleted_at: null;
|
||||
display_username: string;
|
||||
edit_reason: null;
|
||||
hidden: boolean;
|
||||
id: number;
|
||||
incoming_link_count: number;
|
||||
link_counts: Array<Link>;
|
||||
moderator: boolean;
|
||||
name: string;
|
||||
post_number: number;
|
||||
post_type: number;
|
||||
primary_group_flair_bg_color: null | object;
|
||||
primary_group_flair_color: null | object;
|
||||
primary_group_flair_url: null | object;
|
||||
primary_group_name: null | object;
|
||||
quote_count: number;
|
||||
read: boolean;
|
||||
readers_count: number;
|
||||
reads: number;
|
||||
reply_count: number;
|
||||
reply_to_post_number: null | number;
|
||||
reviewable_id: number;
|
||||
reviewable_score_count: number;
|
||||
reviewable_score_pending_count: number;
|
||||
score: number;
|
||||
staff: boolean;
|
||||
topic_id: number;
|
||||
topic_slug: string;
|
||||
trust_level: number;
|
||||
updated_at: string;
|
||||
user_deleted: boolean;
|
||||
user_id: number;
|
||||
user_title: null | object;
|
||||
username: string;
|
||||
version: number;
|
||||
wiki: boolean;
|
||||
yours: boolean;
|
||||
}
|
||||
5
packages/discourse/lib/discourse/types/discourse.js
Normal file
5
packages/discourse/lib/discourse/types/discourse.js
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
// Attempt at TypeScript Types for the Discourse API
|
||||
// https://docs.discourse.org
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=discourse.js.map
|
||||
1
packages/discourse/lib/discourse/types/discourse.js.map
Normal file
1
packages/discourse/lib/discourse/types/discourse.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"discourse.js","sourceRoot":"","sources":["../../../src/lib/discourse/types/discourse.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,6BAA6B"}
|
||||
26
packages/discourse/lib/discourse/util.d.ts
vendored
Normal file
26
packages/discourse/lib/discourse/util.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import { Discourser } from './index';
|
||||
export declare const uploadFile: (discourse: any, forum: any, name: any, filePath: any) => Promise<any>;
|
||||
export declare const findReplyPage: (b: any, pages: any) => any;
|
||||
export declare const findReplyUpload: (u: any, page: any) => any;
|
||||
export declare const getPages: (topics: any, topic: any) => any;
|
||||
export declare const getReplies: (topics: any, topic: any) => any[];
|
||||
export declare const findFile: (folder: any, filename: any) => any;
|
||||
export declare const topicFolder: (forum: any, folder: any, title: any) => string;
|
||||
export declare const dOptions: {
|
||||
host: string;
|
||||
key: string;
|
||||
username: string;
|
||||
rateLimitConcurrency: number;
|
||||
};
|
||||
export declare const getFUser: (users: any, user_name: any) => any;
|
||||
export declare const getOAvatar: (index: any, user: any) => any;
|
||||
export declare const getTopics: (index: any) => any[];
|
||||
export declare const convert: (input: string) => any;
|
||||
export declare const getDiscourse: () => Discourser;
|
||||
export declare function inspect(arg: any): string;
|
||||
export declare function log(...args: any[]): void;
|
||||
export declare function mkdirp(path: string): Promise<void>;
|
||||
export declare function readJSON<T extends object>(path: string): Promise<T>;
|
||||
export declare function writeJSON(path: string, data: object): Promise<void>;
|
||||
export declare function exists(path: string): Promise<boolean>;
|
||||
export declare function escape(path: string): string;
|
||||
184
packages/discourse/lib/discourse/util.js
Normal file
184
packages/discourse/lib/discourse/util.js
Normal file
@ -0,0 +1,184 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.escape = exports.exists = exports.writeJSON = exports.readJSON = exports.mkdirp = exports.log = exports.inspect = exports.getDiscourse = exports.convert = exports.getTopics = exports.getOAvatar = exports.getFUser = exports.dOptions = exports.topicFolder = exports.findFile = exports.getReplies = exports.getPages = exports.findReplyUpload = exports.findReplyPage = exports.uploadFile = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const util_1 = require("util");
|
||||
const cwd = process.cwd();
|
||||
var TurndownService = require('turndown');
|
||||
const index_1 = require("./index");
|
||||
const path = require("path");
|
||||
const fg = require('fast-glob');
|
||||
const slugify_1 = require("slugify");
|
||||
var sanitize = require("sanitize-filename");
|
||||
var mom = require('moment');
|
||||
const uploadFile = (discourse, forum, name, filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
return yield discourse.upload(1, filePath);
|
||||
});
|
||||
exports.uploadFile = uploadFile;
|
||||
const findReplyPage = (b, pages) => {
|
||||
return pages.find((p) => {
|
||||
return p.replies.find((r) => {
|
||||
return r.replyBody == b;
|
||||
});
|
||||
});
|
||||
};
|
||||
exports.findReplyPage = findReplyPage;
|
||||
const findReplyUpload = (u, page) => {
|
||||
const f_pics = page.f_pics || [];
|
||||
return f_pics.find((p) => {
|
||||
return p.url === u;
|
||||
});
|
||||
};
|
||||
exports.findReplyUpload = findReplyUpload;
|
||||
const getPages = (topics, topic) => {
|
||||
return topics.filter((t) => {
|
||||
return t.title == topic.title;
|
||||
});
|
||||
};
|
||||
exports.getPages = getPages;
|
||||
const getReplies = (topics, topic) => {
|
||||
if (topic.nextPages) {
|
||||
const all = topics.filter((t) => {
|
||||
return t.title == topic.title;
|
||||
});
|
||||
let replies = all.map((t) => t.replies);
|
||||
replies = [].concat.apply([], replies);
|
||||
replies = replies.sort((a, b) => {
|
||||
const d1 = mom(a.replyDate, 'DD/MM/YYYY AT HH:mm').toDate();
|
||||
const d2 = mom(b.replyDate, 'DD/MM/YYYY AT HH:mm').toDate();
|
||||
return new Date(d1).getTime() > new Date(d2).getTime() ? 1 : -1;
|
||||
});
|
||||
return replies;
|
||||
/*
|
||||
const findReply = (b, pages) => {
|
||||
return pages.find((p) => {
|
||||
return p.replies.find((r) => {
|
||||
return r.replyBody == b;
|
||||
})
|
||||
})
|
||||
}
|
||||
const p = findReply('\n\n\n<p>sounds great, let me get Old Tony´s Schaeubling 13 and a surface grinder first, after that I can do the parts for the espresso machine in the best <a href=\"https://www.youtube.com/watch?v=hpenv1ZqGx4\" rel=\"nofollow\" target=\"_blank\">maker porn fashion possible,</a> no seriously, every time I thought I know something, there’s just another video around the next corner making me cry like a baby, incl. the coffee machine <img draggable=\"false\" class=\"emoji\" alt=\"🙁\" src=\"https://s.w.org/images/core/emoji/11/svg/1f641.svg\"></p>\n', all);
|
||||
debugger;
|
||||
*/
|
||||
}
|
||||
return [];
|
||||
};
|
||||
exports.getReplies = getReplies;
|
||||
const findFile = (folder, filename) => {
|
||||
const files = fg.sync('**/**/*' + filename + '*', { dot: true, cwd: folder, absolute: true });
|
||||
if (files.length == 0) {
|
||||
return false;
|
||||
}
|
||||
return files[0];
|
||||
};
|
||||
exports.findFile = findFile;
|
||||
const topicFolder = (forum, folder, title) => {
|
||||
const _title = sanitize((0, slugify_1.default)(title));
|
||||
const tf = path.resolve(forum + '/' + folder + '/' + _title);
|
||||
return tf;
|
||||
};
|
||||
exports.topicFolder = topicFolder;
|
||||
exports.dOptions = {
|
||||
host: 'https://forum.osr-plastic.org',
|
||||
key: 'f624b8385fb2219cb49de63d1e22883afdf7b7367a0bebf822523f49f2678031',
|
||||
username: 'admin',
|
||||
rateLimitConcurrency: 1
|
||||
};
|
||||
const getFUser = (users, user_name) => {
|
||||
return users.find((u) => {
|
||||
return u.name == user_name;
|
||||
});
|
||||
};
|
||||
exports.getFUser = getFUser;
|
||||
const getOAvatar = (index, user) => {
|
||||
const topics = (0, exports.getTopics)(index);
|
||||
let topic = topics.find((t) => {
|
||||
return t.authorName == user;
|
||||
});
|
||||
if (topic) {
|
||||
return topic.authorImage;
|
||||
}
|
||||
for (let i = 0; i < topics.length; i++) {
|
||||
const t = topics[i];
|
||||
if (t.replies) {
|
||||
const r = t.replies.find((r) => {
|
||||
return r.user == user;
|
||||
});
|
||||
if (r) {
|
||||
return r.avatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
exports.getOAvatar = getOAvatar;
|
||||
const getTopics = (index) => {
|
||||
let topics = [];
|
||||
for (let t in index) {
|
||||
topics.push(index[t]);
|
||||
}
|
||||
return topics;
|
||||
};
|
||||
exports.getTopics = getTopics;
|
||||
const convert = (input) => {
|
||||
var turndownService = new TurndownService();
|
||||
return turndownService.turndown(input);
|
||||
};
|
||||
exports.convert = convert;
|
||||
const getDiscourse = () => {
|
||||
return new index_1.Discourser(exports.dOptions);
|
||||
};
|
||||
exports.getDiscourse = getDiscourse;
|
||||
function inspect(arg) {
|
||||
return (0, util_1.inspect)(arg, {
|
||||
depth: 5,
|
||||
colors: true,
|
||||
});
|
||||
}
|
||||
exports.inspect = inspect;
|
||||
function log(...args) {
|
||||
console.log(...args.map((arg) => inspect(arg)));
|
||||
}
|
||||
exports.log = log;
|
||||
function mkdirp(path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
yield fs_1.default.promises.mkdir(path);
|
||||
}
|
||||
catch (err) {
|
||||
// don't care if it already exists
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.mkdirp = mkdirp;
|
||||
function readJSON(path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const text = yield fs_1.default.promises.readFile(path, 'utf8');
|
||||
return JSON.parse(text);
|
||||
});
|
||||
}
|
||||
exports.readJSON = readJSON;
|
||||
function writeJSON(path, data) {
|
||||
return fs_1.default.promises.writeFile(path, JSON.stringify(data));
|
||||
}
|
||||
exports.writeJSON = writeJSON;
|
||||
function exists(path) {
|
||||
return new Promise(function (resolve) {
|
||||
fs_1.default.exists(path, resolve);
|
||||
});
|
||||
}
|
||||
exports.exists = exists;
|
||||
function escape(path) {
|
||||
return path.replace(/[^\w]/g, '-').replace(/-+/, '-');
|
||||
}
|
||||
exports.escape = escape;
|
||||
//# sourceMappingURL=util.js.map
|
||||
1
packages/discourse/lib/discourse/util.js.map
Normal file
1
packages/discourse/lib/discourse/util.js.map
Normal file
File diff suppressed because one or more lines are too long
260
packages/discourse/lib/discourse/youtube.d.ts
vendored
Normal file
260
packages/discourse/lib/discourse/youtube.d.ts
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
export declare function getYoutubeVideo(videoID: string): Promise<YoutubeVideoData>;
|
||||
export interface YoutubeVideoData {
|
||||
playabilityStatus: PlayabilityStatus;
|
||||
streamingData: StreamingData;
|
||||
playbackTracking: PlaybackTracking;
|
||||
captions: Captions;
|
||||
videoDetails: VideoDetails;
|
||||
playerConfig: PlayerConfig;
|
||||
storyboards: Storyboards;
|
||||
microformat: Microformat;
|
||||
trackingParams: string;
|
||||
attestation: Attestation;
|
||||
videoQualityPromoSupportedRenderers: VideoQualityPromoSupportedRenderers;
|
||||
}
|
||||
export interface Attestation {
|
||||
playerAttestationRenderer: PlayerAttestationRenderer;
|
||||
}
|
||||
export interface PlayerAttestationRenderer {
|
||||
challenge: string;
|
||||
botguardData: BotguardData;
|
||||
}
|
||||
export interface BotguardData {
|
||||
program: string;
|
||||
interpreterUrl: string;
|
||||
}
|
||||
export interface Captions {
|
||||
playerCaptionsRenderer: PlayerCaptionsRenderer;
|
||||
playerCaptionsTracklistRenderer: PlayerCaptionsTracklistRenderer;
|
||||
}
|
||||
export interface PlayerCaptionsRenderer {
|
||||
baseUrl: string;
|
||||
visibility: string;
|
||||
contribute: Contribute;
|
||||
}
|
||||
export interface Contribute {
|
||||
captionsMetadataRenderer: CaptionsMetadataRenderer;
|
||||
}
|
||||
export interface CaptionsMetadataRenderer {
|
||||
addSubtitlesText: AddSubtitlesText;
|
||||
noSubtitlesText: Description;
|
||||
promoSubtitlesText: Description;
|
||||
}
|
||||
export interface AddSubtitlesText {
|
||||
runs: AddSubtitlesTextRun[];
|
||||
}
|
||||
export interface AddSubtitlesTextRun {
|
||||
text: string;
|
||||
navigationEndpoint: NavigationEndpoint;
|
||||
}
|
||||
export interface NavigationEndpoint {
|
||||
clickTrackingParams: string;
|
||||
urlEndpoint: NavigationEndpointURLEndpoint;
|
||||
}
|
||||
export interface NavigationEndpointURLEndpoint {
|
||||
url: string;
|
||||
}
|
||||
export interface Description {
|
||||
simpleText: string;
|
||||
}
|
||||
export interface PlayerCaptionsTracklistRenderer {
|
||||
captionTracks: CaptionTrack[];
|
||||
audioTracks: AudioTrack[];
|
||||
translationLanguages: TranslationLanguage[];
|
||||
defaultAudioTrackIndex: number;
|
||||
contribute: Contribute;
|
||||
}
|
||||
export interface AudioTrack {
|
||||
captionTrackIndices: number[];
|
||||
}
|
||||
export interface CaptionTrack {
|
||||
baseUrl: string;
|
||||
name: Description;
|
||||
vssId: string;
|
||||
languageCode: string;
|
||||
kind: string;
|
||||
isTranslatable: boolean;
|
||||
}
|
||||
export interface TranslationLanguage {
|
||||
languageCode: string;
|
||||
languageName: Description;
|
||||
}
|
||||
export interface Microformat {
|
||||
playerMicroformatRenderer: PlayerMicroformatRenderer;
|
||||
}
|
||||
export interface PlayerMicroformatRenderer {
|
||||
thumbnail: PlayerMicroformatRendererThumbnail;
|
||||
embed: Embed;
|
||||
title: Description;
|
||||
description: Description;
|
||||
lengthSeconds: string;
|
||||
ownerProfileUrl: string;
|
||||
externalChannelId: string;
|
||||
availableCountries: string[];
|
||||
isUnlisted: boolean;
|
||||
hasYpcMetadata: boolean;
|
||||
viewCount: string;
|
||||
category: string;
|
||||
publishDate: Date;
|
||||
ownerChannelName: string;
|
||||
uploadDate: Date;
|
||||
}
|
||||
export interface Embed {
|
||||
iframeUrl: string;
|
||||
flashUrl: string;
|
||||
width: number;
|
||||
height: number;
|
||||
flashSecureUrl: string;
|
||||
}
|
||||
export interface PlayerMicroformatRendererThumbnail {
|
||||
thumbnails: ThumbnailElement[];
|
||||
}
|
||||
export interface ThumbnailElement {
|
||||
url: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
export interface PlayabilityStatus {
|
||||
status: string;
|
||||
playableInEmbed: boolean;
|
||||
contextParams: string;
|
||||
}
|
||||
export interface PlaybackTracking {
|
||||
videostatsPlaybackUrl: PtrackingURLClass;
|
||||
videostatsDelayplayUrl: PtrackingURLClass;
|
||||
videostatsWatchtimeUrl: PtrackingURLClass;
|
||||
ptrackingUrl: PtrackingURLClass;
|
||||
qoeUrl: PtrackingURLClass;
|
||||
setAwesomeUrl: AtrURLClass;
|
||||
atrUrl: AtrURLClass;
|
||||
}
|
||||
export interface AtrURLClass {
|
||||
baseUrl: string;
|
||||
elapsedMediaTimeSeconds: number;
|
||||
}
|
||||
export interface PtrackingURLClass {
|
||||
baseUrl: string;
|
||||
}
|
||||
export interface PlayerConfig {
|
||||
audioConfig: AudioConfig;
|
||||
streamSelectionConfig: StreamSelectionConfig;
|
||||
mediaCommonConfig: MediaCommonConfig;
|
||||
}
|
||||
export interface AudioConfig {
|
||||
loudnessDb: number;
|
||||
perceptualLoudnessDb: number;
|
||||
enablePerFormatLoudness: boolean;
|
||||
}
|
||||
export interface MediaCommonConfig {
|
||||
dynamicReadaheadConfig: DynamicReadaheadConfig;
|
||||
}
|
||||
export interface DynamicReadaheadConfig {
|
||||
maxReadAheadMediaTimeMs: number;
|
||||
minReadAheadMediaTimeMs: number;
|
||||
readAheadGrowthRateMs: number;
|
||||
}
|
||||
export interface StreamSelectionConfig {
|
||||
maxBitrate: string;
|
||||
}
|
||||
export interface Storyboards {
|
||||
playerStoryboardSpecRenderer: PlayerStoryboardSpecRenderer;
|
||||
}
|
||||
export interface PlayerStoryboardSpecRenderer {
|
||||
spec: string;
|
||||
}
|
||||
export interface StreamingData {
|
||||
expiresInSeconds: string;
|
||||
formats: Format[];
|
||||
adaptiveFormats: Format[];
|
||||
}
|
||||
export interface Format {
|
||||
itag: number;
|
||||
url: string;
|
||||
mimeType: string;
|
||||
bitrate: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
initRange?: Range;
|
||||
indexRange?: Range;
|
||||
lastModified: string;
|
||||
contentLength?: string;
|
||||
quality: string;
|
||||
fps?: number;
|
||||
qualityLabel?: string;
|
||||
projectionType: ProjectionType;
|
||||
averageBitrate?: number;
|
||||
approxDurationMs: string;
|
||||
colorInfo?: ColorInfo;
|
||||
highReplication?: boolean;
|
||||
audioQuality?: string;
|
||||
audioSampleRate?: string;
|
||||
audioChannels?: number;
|
||||
}
|
||||
export interface ColorInfo {
|
||||
primaries: string;
|
||||
transferCharacteristics: string;
|
||||
matrixCoefficients: string;
|
||||
}
|
||||
export interface Range {
|
||||
start: string;
|
||||
end: string;
|
||||
}
|
||||
export declare enum ProjectionType {
|
||||
Rectangular = "RECTANGULAR"
|
||||
}
|
||||
export interface VideoDetails {
|
||||
videoId: string;
|
||||
title: string;
|
||||
lengthSeconds: string;
|
||||
keywords: string[];
|
||||
channelId: string;
|
||||
isOwnerViewing: boolean;
|
||||
shortDescription: string;
|
||||
isCrawlable: boolean;
|
||||
thumbnail: PlayerMicroformatRendererThumbnail;
|
||||
averageRating: number;
|
||||
allowRatings: boolean;
|
||||
viewCount: string;
|
||||
author: string;
|
||||
isPrivate: boolean;
|
||||
isUnpluggedCorpus: boolean;
|
||||
isLiveContent: boolean;
|
||||
}
|
||||
export interface VideoQualityPromoSupportedRenderers {
|
||||
videoQualityPromoRenderer: VideoQualityPromoRenderer;
|
||||
}
|
||||
export interface VideoQualityPromoRenderer {
|
||||
triggerCriteria: TriggerCriteria;
|
||||
text: Text;
|
||||
endpoint: Endpoint;
|
||||
trackingParams: string;
|
||||
closeButton: CloseButton;
|
||||
}
|
||||
export interface CloseButton {
|
||||
videoQualityPromoCloseRenderer: VideoQualityPromoCloseRenderer;
|
||||
}
|
||||
export interface VideoQualityPromoCloseRenderer {
|
||||
trackingParams: string;
|
||||
}
|
||||
export interface Endpoint {
|
||||
clickTrackingParams: string;
|
||||
urlEndpoint: EndpointURLEndpoint;
|
||||
}
|
||||
export interface EndpointURLEndpoint {
|
||||
url: string;
|
||||
target: string;
|
||||
}
|
||||
export interface Text {
|
||||
runs: TextRun[];
|
||||
}
|
||||
export interface TextRun {
|
||||
text: string;
|
||||
bold?: boolean;
|
||||
}
|
||||
export interface TriggerCriteria {
|
||||
connectionWhitelists: string[];
|
||||
joinLatencySeconds: number;
|
||||
rebufferTimeSeconds: number;
|
||||
watchTimeWindowSeconds: number;
|
||||
refractorySeconds: number;
|
||||
}
|
||||
30
packages/discourse/lib/discourse/youtube.js
Normal file
30
packages/discourse/lib/discourse/youtube.js
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ProjectionType = exports.getYoutubeVideo = void 0;
|
||||
const isomorphic_unfetch_1 = require("isomorphic-unfetch");
|
||||
function getYoutubeVideo(videoID) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const eurl = `https://youtube.googleapis.com/v/${videoID}`;
|
||||
const response = yield (0, isomorphic_unfetch_1.default)(`https://www.youtube.com/get_video_info?video_id=${videoID}&el=embedded&eurl=${eurl}&sts=18333`);
|
||||
const text = yield response.text();
|
||||
const params = new URLSearchParams(text);
|
||||
//const data = JSON.parse(Object.fromEntries(params).player_response)
|
||||
// return data as YoutubeVideoData
|
||||
return {};
|
||||
});
|
||||
}
|
||||
exports.getYoutubeVideo = getYoutubeVideo;
|
||||
var ProjectionType;
|
||||
(function (ProjectionType) {
|
||||
ProjectionType["Rectangular"] = "RECTANGULAR";
|
||||
})(ProjectionType = exports.ProjectionType || (exports.ProjectionType = {}));
|
||||
//# sourceMappingURL=youtube.js.map
|
||||
1
packages/discourse/lib/discourse/youtube.js.map
Normal file
1
packages/discourse/lib/discourse/youtube.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../src/lib/discourse/youtube.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAsC;AAEtC,SAAsB,eAAe,CACpC,OAAe;;QAEf,MAAM,IAAI,GAAG,oCAAoC,OAAO,EAAE,CAAA;QAC1D,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAK,EAC3B,mDAAmD,OAAO,qBAAqB,IAAI,YAAY,CAC/F,CAAA;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;QACxC,qEAAqE;QACrE,kCAAkC;QAClC,OAAO,EAAsB,CAAC;IAC/B,CAAC;CAAA;AAZD,0CAYC;AAiPD,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,6CAA2B,CAAA;AAC5B,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB"}
|
||||
5
packages/discourse/lib/git/index.d.ts
vendored
Normal file
5
packages/discourse/lib/git/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export declare function git_status(cwd: any, dir: any): Promise<any>;
|
||||
export declare function git_log(cwd: any, dir: any): Promise<{
|
||||
files: any;
|
||||
last: any;
|
||||
}>;
|
||||
39
packages/discourse/lib/git/index.js
Normal file
39
packages/discourse/lib/git/index.js
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.git_log = exports.git_status = void 0;
|
||||
const index_1 = require("../../index");
|
||||
const GIT_CHANGELOG_MESSAGE_PREFIX = '';
|
||||
const simpleGit = require("simple-git/promise");
|
||||
const moment = require("moment");
|
||||
async function git_status(cwd, dir) {
|
||||
const git = simpleGit(cwd);
|
||||
let statusSummary = null;
|
||||
try {
|
||||
statusSummary = await git.log(['--stat', dir]);
|
||||
}
|
||||
catch (e) {
|
||||
index_1.logger.error('Error Git', e);
|
||||
}
|
||||
return statusSummary;
|
||||
}
|
||||
exports.git_status = git_status;
|
||||
async function git_log(cwd, dir) {
|
||||
const stats = await git_status(cwd, dir);
|
||||
index_1.logger.info(`Reading Git log at ${cwd}/${dir}`);
|
||||
let changelogs = stats.all.filter((e) => e.message.trim().toLowerCase().startsWith(GIT_CHANGELOG_MESSAGE_PREFIX.toLowerCase()));
|
||||
if (!changelogs.length) {
|
||||
return { files: [], last: stats.latest };
|
||||
}
|
||||
let pretty = changelogs.map((e) => {
|
||||
return {
|
||||
files: e.diff.files.map((f) => { return { path: f.file }; }),
|
||||
msg: e.message.toLowerCase().replace(GIT_CHANGELOG_MESSAGE_PREFIX.toLowerCase(), '').trim(),
|
||||
hash: e.hash,
|
||||
date: moment(e.date).format('LLLL')
|
||||
};
|
||||
});
|
||||
return { files: pretty, last: stats.latest };
|
||||
}
|
||||
exports.git_log = git_log;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2dpdC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSx1Q0FBa0M7QUFFbEMsTUFBTSw0QkFBNEIsR0FBRyxFQUFFLENBQUE7QUFJdkMsZ0RBQWdEO0FBRWhELGlDQUFpQztBQUUxQixLQUFLLFVBQVUsVUFBVSxDQUFDLEdBQUcsRUFBRSxHQUFHO0lBRXJDLE1BQU0sR0FBRyxHQUFjLFNBQVMsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUN0QyxJQUFJLGFBQWEsR0FBTyxJQUFJLENBQUM7SUFDN0IsSUFBSTtRQUNBLGFBQWEsR0FBRyxNQUFNLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQyxRQUFRLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQztLQUNsRDtJQUNELE9BQU8sQ0FBQyxFQUFFO1FBQ04sY0FBTSxDQUFDLEtBQUssQ0FBQyxXQUFXLEVBQUUsQ0FBQyxDQUFDLENBQUM7S0FDaEM7SUFDRCxPQUFPLGFBQWEsQ0FBQztBQUN6QixDQUFDO0FBWEQsZ0NBV0M7QUFFTSxLQUFLLFVBQVUsT0FBTyxDQUFDLEdBQUcsRUFBRSxHQUFHO0lBQ2xDLE1BQU0sS0FBSyxHQUFHLE1BQU0sVUFBVSxDQUFDLEdBQUcsRUFBRSxHQUFHLENBQUMsQ0FBQztJQUN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BO0lBQ0wsQ0FBQyxDQUFDLENBQUM7SUFFSCxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsS0FBSyxDQUFDLE1BQU0sRUFBRSxDQUFDO0FBQ2pELENBQUM7QUFqQkQsMEJBaUJDO0FBQUEsQ0FBQyJ9
|
||||
2
packages/discourse/lib/index.d.ts
vendored
Normal file
2
packages/discourse/lib/index.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './discourse';
|
||||
export * from './discourse/types';
|
||||
19
packages/discourse/lib/index.js
Normal file
19
packages/discourse/lib/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./discourse"), exports);
|
||||
__exportStar(require("./discourse/types"), exports);
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbGliL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw4Q0FBMkI7QUFDM0Isb0RBQWlDIn0=
|
||||
1
packages/discourse/lib/index.js.map
Normal file
1
packages/discourse/lib/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,oDAAiC"}
|
||||
7
packages/discourse/lib/markdown/Pattern.d.ts
vendored
Normal file
7
packages/discourse/lib/markdown/Pattern.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { RegExCallback } from './types';
|
||||
export declare class Pattern {
|
||||
regex: RegExp;
|
||||
replacement: RegExCallback;
|
||||
constructor(regex: RegExp, replacement: any);
|
||||
apply(raw: string): string;
|
||||
}
|
||||
14
packages/discourse/lib/markdown/Pattern.js
Normal file
14
packages/discourse/lib/markdown/Pattern.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Pattern = void 0;
|
||||
class Pattern {
|
||||
constructor(regex, replacement) {
|
||||
this.regex = regex;
|
||||
this.replacement = replacement;
|
||||
}
|
||||
apply(raw) {
|
||||
return raw.replace(this.regex, this.replacement);
|
||||
}
|
||||
}
|
||||
exports.Pattern = Pattern;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGF0dGVybi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvbWFya2Rvd24vUGF0dGVybi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSxNQUFhLE9BQU87SUFHbEIsWUFBWSxLQUFhLEVBQUUsV0FBZ0I7UUFDekMsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUE7UUFDbEIsSUFBSSxDQUFDLFdBQVcsR0FBRyxXQUFXLENBQUE7SUFDaEMsQ0FBQztJQUVELEtBQUssQ0FBQyxHQUFXO1FBQ2YsT0FBTyxHQUFHLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFBO0lBQ2xELENBQUM7Q0FDRjtBQVhELDBCQVdDIn0=
|
||||
7
packages/discourse/lib/markdown/Rule.d.ts
vendored
Normal file
7
packages/discourse/lib/markdown/Rule.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { Pattern } from './Pattern';
|
||||
export declare class Rule {
|
||||
name: string;
|
||||
patterns: Pattern[];
|
||||
constructor(name: string, patterns: Pattern[]);
|
||||
apply(raw: string): string;
|
||||
}
|
||||
14
packages/discourse/lib/markdown/Rule.js
Normal file
14
packages/discourse/lib/markdown/Rule.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Rule = void 0;
|
||||
class Rule {
|
||||
constructor(name, patterns) {
|
||||
this.name = name;
|
||||
this.patterns = patterns;
|
||||
}
|
||||
apply(raw) {
|
||||
return this.patterns.reduce((result, pattern) => pattern.apply(result), raw);
|
||||
}
|
||||
}
|
||||
exports.Rule = Rule;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvbWFya2Rvd24vUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxNQUFhLElBQUk7SUFHZixZQUFZLElBQVksRUFBRSxRQUFtQjtRQUMzQyxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUNqQixJQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQztJQUMzQixDQUFDO0lBRUQsS0FBSyxDQUFDLEdBQVc7UUFDZixPQUFPLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUN6QixDQUFDLE1BQU0sRUFBRSxPQUFPLEVBQUUsRUFBRSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLEVBQzFDLEdBQUcsQ0FDSixDQUFDO0lBQ0osQ0FBQztDQUNGO0FBZEQsb0JBY0MifQ==
|
||||
14
packages/discourse/lib/markdown/index.d.ts
vendored
Normal file
14
packages/discourse/lib/markdown/index.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { Rule } from './Rule';
|
||||
import { RMarkOptions } from './types';
|
||||
export declare const RE_IMAGES: RegExp;
|
||||
export declare const RE_LINKS: RegExp;
|
||||
export declare class RMark {
|
||||
constructor(options: RMarkOptions);
|
||||
private rules;
|
||||
addRuleBefore(rule: Rule, before: string): RMark;
|
||||
addRule(rule: Rule): RMark;
|
||||
render(raw: string): string;
|
||||
}
|
||||
export { Rule } from './Rule';
|
||||
export { Pattern } from './Pattern';
|
||||
export declare const toHTML: (content: any) => string;
|
||||
104
packages/discourse/lib/markdown/index.js
Normal file
104
packages/discourse/lib/markdown/index.js
Normal file
@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toHTML = exports.Pattern = exports.Rule = exports.RMark = exports.RE_LINKS = exports.RE_IMAGES = void 0;
|
||||
const Rule_1 = require("./Rule");
|
||||
const Pattern_1 = require("./Pattern");
|
||||
exports.RE_IMAGES = /\!\[([^\]]+)\]\((\S+)\)/g;
|
||||
exports.RE_LINKS = /\[([^\n]+)\]\(([^\n]+)\)/g;
|
||||
const markdown = require("markdown-it");
|
||||
const defaultRules = [
|
||||
new Rule_1.Rule('header', [
|
||||
new Pattern_1.Pattern(/^#{6}\s?([^\n]+)/gm, '<h6>$1</h6>'),
|
||||
new Pattern_1.Pattern(/^#{5}\s?([^\n]+)/gm, '<h5>$1</h5>'),
|
||||
new Pattern_1.Pattern(/^#{4}\s?([^\n]+)/gm, '<h4>$1</h4>'),
|
||||
new Pattern_1.Pattern(/^#{3}\s?([^\n]+)/gm, '<h3>$1</h3>'),
|
||||
new Pattern_1.Pattern(/^#{2}\s?([^\n]+)/gm, '<h2>$1</h2>'),
|
||||
new Pattern_1.Pattern(/^#{1}\s?([^\n]+)/gm, '<h1>$1</h1>'),
|
||||
]),
|
||||
new Rule_1.Rule('bold', [
|
||||
new Pattern_1.Pattern(/\*\*\s?([^\n]+)\*\*/g, '<b>$1</b>'),
|
||||
new Pattern_1.Pattern(/\_\_\s?([^\n]+)\_\_/g, '<b>$1</b>'),
|
||||
]),
|
||||
new Rule_1.Rule('italic', [
|
||||
new Pattern_1.Pattern(/\*\s?([^\n]+)\*/g, '<i>$1</i>'),
|
||||
new Pattern_1.Pattern(/\_\s?([^\n]+)\_/g, '<i>$1</i>'),
|
||||
]),
|
||||
new Rule_1.Rule('image', [
|
||||
new Pattern_1.Pattern(/\!\[([^\]]+)\]\((\S+)\)/g, '<img src="$2" alt="$1" />'),
|
||||
]),
|
||||
new Rule_1.Rule('link', [
|
||||
new Pattern_1.Pattern(/\[([^\n]+)\]\(([^\n]+)\)/g, '<a href2="$2" target="_blank" rel="noopener">$1</a>'),
|
||||
]),
|
||||
new Rule_1.Rule('paragraph', [
|
||||
// this regex can't skip processed HTML
|
||||
new Pattern_1.Pattern(/([^\n]+\n?)/g, '\n<p>$1</p>\n'),
|
||||
// another possible regex that can't skip processed HTML
|
||||
// new Pattern(/(?:^|\n)([^\n\<]+(?:\n[^\n\>]+)*)(?:\n|$)/gm, '\n<p>$1</p>\n'),
|
||||
])
|
||||
];
|
||||
const defaultRulesDiscourse = (images, links) => {
|
||||
return [
|
||||
new Rule_1.Rule('image', [
|
||||
new Pattern_1.Pattern(exports.RE_LINKS, images)
|
||||
]) /*,
|
||||
new Rule('link', [
|
||||
new Pattern(
|
||||
RE_LINKS,
|
||||
links
|
||||
)
|
||||
])*/
|
||||
];
|
||||
};
|
||||
class RMark {
|
||||
constructor(options) {
|
||||
this.rules = defaultRulesDiscourse(options.images, options.links);
|
||||
}
|
||||
addRuleBefore(rule, before) {
|
||||
const index = this.rules.findIndex((r) => r.name === before);
|
||||
if (index !== -1) {
|
||||
this.rules.splice(index, 0, rule);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
addRule(rule) {
|
||||
this.addRuleBefore(rule, 'paragraph');
|
||||
return this;
|
||||
}
|
||||
render(raw) {
|
||||
let result = raw;
|
||||
this.rules.forEach((rule) => {
|
||||
result = rule.apply(result);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.RMark = RMark;
|
||||
var Rule_2 = require("./Rule");
|
||||
Object.defineProperty(exports, "Rule", { enumerable: true, get: function () { return Rule_2.Rule; } });
|
||||
var Pattern_2 = require("./Pattern");
|
||||
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return Pattern_2.Pattern; } });
|
||||
// export const find = (content:string, reg:RegExp) => content.match(reg)
|
||||
const toHTML = (content) => {
|
||||
const md = new markdown({
|
||||
html: true,
|
||||
breaks: true
|
||||
});
|
||||
return md.render(content);
|
||||
};
|
||||
exports.toHTML = toHTML;
|
||||
function image_urls(input) {
|
||||
const regex = /https?:\/\/(?:[a-z0-9\-]+\.)+[a-z]{2,}(?:\/[^\/#\s]*)*\.(?:jpe?g|gif|png|webp)/g;
|
||||
const matches = input.match(regex);
|
||||
return matches || [];
|
||||
}
|
||||
function image_urls_local(input) {
|
||||
const regex = /\/(?:[^\/#\s]+\/)*[^\/#\s]+\.(?:jpe?g|gif|png|webp)/g;
|
||||
const matches = input.match(regex);
|
||||
return matches || [];
|
||||
}
|
||||
function findUploadImageUrls(input) {
|
||||
const regex = /upload:\/\/[^\s]+?\.(?:jpe?g|gif|png)/gi;
|
||||
const matches = input.match(regex);
|
||||
return matches || [];
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL21hcmtkb3duL2luZGV4LnRzIl0sIm5hbWVzIjp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UNsQyxPQUFPLE9BQU8sSUFBSSxFQUFFLENBQUE7QUFDdEIsQ0FBQztBQUVELFNBQVMsZ0JBQWdCLENBQUMsS0FBYTtJQUNyQyxNQUFNLEtBQUssR0FBRyxzREFBc0QsQ0FBQTtJQUNwRSxNQUFNLE9BQU8sR0FBRyxLQUFLLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2xDLE9BQU8sT0FBTyxJQUFJLEVBQUUsQ0FBQTtBQUN0QixDQUFDO0FBRUQsU0FBUyxtQkFBbUIsQ0FBQyxLQUFhO0lBQ3hDLE1BQU0sS0FBSyxHQUFHLHlDQUF5QyxDQUFDO0lBQ3hELE1BQU0sT0FBTyxHQUFHLEtBQUssQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDbkMsT0FBTyxPQUFPLElBQUksRUFBRSxDQUFDO0FBQ3ZCLENBQUMifQ==
|
||||
5
packages/discourse/lib/markdown/types.d.ts
vendored
Normal file
5
packages/discourse/lib/markdown/types.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export type RegExCallback = (match: any, capture: any, arg1: any, arg2: any) => string;
|
||||
export interface RMarkOptions {
|
||||
images: RegExCallback;
|
||||
links?: RegExCallback;
|
||||
}
|
||||
3
packages/discourse/lib/markdown/types.js
Normal file
3
packages/discourse/lib/markdown/types.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL21hcmtkb3duL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
||||
27
packages/discourse/lib/oa/commons.d.ts
vendored
Normal file
27
packages/discourse/lib/oa/commons.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
import { IUploadedFileMeta } from '@plastichub/osr-commons';
|
||||
import { IImportUser, IOAHowto, IOACategory, IOATags, IOAHowtoImport } from '../../';
|
||||
export declare const DEFAULT_HT_CATEGORY: {
|
||||
_modified: string;
|
||||
label: string;
|
||||
_id: string;
|
||||
_created: string;
|
||||
_deleted: boolean;
|
||||
};
|
||||
export declare const LATEST_TRACK = "${OSR_ROOT}/oa-data/howtos/latest_track.json";
|
||||
export declare const LATEST_TEST = "./latest_test.json";
|
||||
export declare const DEFAULT_USER = "katharinaelleke";
|
||||
export declare const getDataPath: (_path?: string) => string;
|
||||
export declare const getHowtosPath: () => string;
|
||||
export declare const getHowtos: () => IOAHowtoImport[];
|
||||
export declare const read_howtos: (src: string) => IOAHowtoImport[];
|
||||
export declare const read_categories: (src: string) => IOACategory[];
|
||||
export declare const read_tags: (src: string) => IOATags[];
|
||||
export declare const filter_valid: (users: IOAHowtoImport[]) => IOAHowtoImport[];
|
||||
export declare const kb_howto_folder: (howto: any) => string;
|
||||
export declare const kb_howto_file: (howto: any, filename: any) => string;
|
||||
export declare const getHowtoUser: (howto: IOAHowto) => IImportUser;
|
||||
export declare const toMDImage: (image: IUploadedFileMeta) => string;
|
||||
export declare const md_edit_wrap: (content: any, f: any, prefix?: string, context?: string) => any;
|
||||
export declare const removeEmojis: (string: any) => any;
|
||||
export declare const toHTML: (path: any, markdown: any) => any;
|
||||
export declare const createTextLinks_: (text: any) => any;
|
||||
106
packages/discourse/lib/oa/commons.js
Normal file
106
packages/discourse/lib/oa/commons.js
Normal file
File diff suppressed because one or more lines are too long
10
packages/discourse/lib/oa/howtos.d.ts
vendored
Normal file
10
packages/discourse/lib/oa/howtos.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { IOptions, IOAHowtoImport } from '../../';
|
||||
import { Discourser } from '../index';
|
||||
export declare const mergeLatest: (discorse: any, options: IOptions, oa_howtos: IOAHowtoImport[]) => IOAHowtoImport[];
|
||||
export declare const read_fragments: (src: any, config: any, prefix?: string, context?: string) => any;
|
||||
export declare function howto_content(howto: IOAHowtoImport, folder: string, fragments: any, templates: any): Promise<any>;
|
||||
export declare const createHowtoTopic: (discourse: any, howto: IOAHowtoImport, create?: boolean) => Promise<boolean>;
|
||||
export declare const importHowto: (discorse: any, howto: IOAHowtoImport) => Promise<boolean>;
|
||||
export declare const importHowtos: (discorse: any, options: IOptions, howtos: IOAHowtoImport[]) => Promise<any>;
|
||||
export declare const updateHowto: (discourse: Discourser, howto: IOAHowtoImport, options: IOptions) => Promise<boolean>;
|
||||
export declare const updateHowtos: (discorse: any, options: IOptions, howtos: IOAHowtoImport[]) => Promise<any>;
|
||||
475
packages/discourse/lib/oa/howtos.js
Normal file
475
packages/discourse/lib/oa/howtos.js
Normal file
File diff suppressed because one or more lines are too long
3
packages/discourse/lib/oa/index.d.ts
vendored
Normal file
3
packages/discourse/lib/oa/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './lib';
|
||||
export * from './users';
|
||||
export * from './types';
|
||||
20
packages/discourse/lib/oa/index.js
Normal file
20
packages/discourse/lib/oa/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./lib"), exports);
|
||||
__exportStar(require("./users"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL29hL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSx3Q0FBcUI7QUFDckIsMENBQXVCO0FBQ3ZCLDBDQUF1QiJ9
|
||||
3
packages/discourse/lib/oa/lib.d.ts
vendored
Normal file
3
packages/discourse/lib/oa/lib.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare const sanitize: (f: any) => string;
|
||||
export declare const getImageName: (url: any) => string;
|
||||
export declare const convert: (input: string) => any;
|
||||
197
packages/discourse/lib/oa/lib.js
Normal file
197
packages/discourse/lib/oa/lib.js
Normal file
@ -0,0 +1,197 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convert = exports.getImageName = exports.sanitize = void 0;
|
||||
const _sanitize = require("sanitize-filename");
|
||||
const URI = require("uri-js");
|
||||
const path = require("path");
|
||||
const filenamify = require('filenamify');
|
||||
var TurndownService = require('turndown');
|
||||
const sanitize = (f) => {
|
||||
let str = filenamify(_sanitize(f)).replace(/[^\x00-\x7F]/g, "");
|
||||
if (str.startsWith('_')) {
|
||||
str = str.substring(1);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
exports.sanitize = sanitize;
|
||||
const getImageName = (url) => {
|
||||
const parsed = URI.parse(decodeURIComponent(url));
|
||||
const pParsed = path.parse(parsed.path);
|
||||
const fileName = (0, exports.sanitize)(decodeURIComponent(pParsed.base));
|
||||
return fileName;
|
||||
};
|
||||
exports.getImageName = getImageName;
|
||||
const convert = (input) => {
|
||||
var turndownService = new TurndownService();
|
||||
return turndownService.turndown(input);
|
||||
};
|
||||
exports.convert = convert;
|
||||
/*
|
||||
|
||||
|
||||
const getFUser = (users, user_name) => {
|
||||
return users.find((u) => {
|
||||
return u.name == user_name
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const indexUsers = async (d, forum: string, detail) => {
|
||||
|
||||
const forumUsers = await getForumUsers(d, detail)
|
||||
const raw = (read(path.resolve(forum + '/index.json'), 'json') as any)
|
||||
const users_raw = raw.users
|
||||
let users = []
|
||||
for (let u in users_raw) {
|
||||
const user = users_raw[u];
|
||||
const avatar = getOAvatar(raw, u);
|
||||
let aFileName = '';
|
||||
let fUser = getFUser(forumUsers, u);
|
||||
if (avatar) {
|
||||
const parsed = URI.parse(avatar);
|
||||
const pParsed = path.parse(parsed.path);
|
||||
aFileName = pParsed.base;
|
||||
}
|
||||
users.push({
|
||||
name: u,
|
||||
avatar: avatar,
|
||||
avatarFileName: aFileName,
|
||||
user_id: fUser ? fUser.id : -1
|
||||
});
|
||||
}
|
||||
write(path.resolve(forum + '/user.json'), users);
|
||||
}
|
||||
|
||||
const _createUser = async (discorse, forum, name, email) => {
|
||||
|
||||
const users = getUsers()
|
||||
const index = users.findIndex((u) => u.detail.name == name)
|
||||
let user = await createUser(discorse, null)
|
||||
|
||||
|
||||
if (user && users[index].upload_id) {
|
||||
await discorse.setUserAvatar(name, users[index].upload_id);
|
||||
//return users;
|
||||
}
|
||||
|
||||
if (user > 0 && index) {
|
||||
users[index].f_id = user;
|
||||
console.log('created ' + name + ' ' + user);
|
||||
write(getUsersPath(), users);
|
||||
} else {
|
||||
console.error('cant create user - error', name, user)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const _updateGroup = async (discorse, forum, name, id, forumUsers) => {
|
||||
const users = (read(path.resolve(forum + '/user.json'), 'json') as any);
|
||||
const index = users.findIndex((u) => u.name == name);
|
||||
try {
|
||||
const d = await discorse.updateGroup(name, pUserGroup);
|
||||
console.log('updated user group for ' + name);
|
||||
users[index].g_id = pUserGroup;
|
||||
write(path.resolve(forum + '/user.json'), users);
|
||||
if (users[index].upload_id) {
|
||||
//await discorse.setUserAvatar(name, users[index].upload_id);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.data && e.data.status == 422) {
|
||||
users[index].g_id = pUserGroup;
|
||||
write(path.resolve(forum + '/user.json'), users);
|
||||
console.log('updated user group for ' + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const _updateAvatar = async (discorse, forum, name) => {
|
||||
const users = (read(path.resolve(forum + '/user.json'), 'json') as any);
|
||||
const index = users.findIndex((u) => u.name == name);
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
setTimeout(() => {
|
||||
discorse.setUserAvatar(name, users[index].upload_id).then(() => {
|
||||
console.log('updated avatar for ' + name);
|
||||
users[index].avatarSet = true;
|
||||
write(path.resolve(forum + '/user.json'), users);
|
||||
resolve(1);
|
||||
});
|
||||
}, 200);
|
||||
} catch (e) {
|
||||
console.error('-error setting avatar', e);
|
||||
debugger;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const createUsers = async (d, forum) => {
|
||||
|
||||
const forumUsers = await getForumUsers(d, true)
|
||||
const users = (read(path.resolve(forum + '/user.json'), 'json') as any);
|
||||
const toBeCreated = users.filter((u) => {
|
||||
if (u.f_id || u.f_id < 0) {
|
||||
return false;
|
||||
}
|
||||
if (u.name === 'plastichub' || u.name === 'lu' || u.name === 'timberstar' || u.name === 'nickname') {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
console.log('Create Users ' + users.length + ' Total | Left: ' + toBeCreated.length);
|
||||
|
||||
return await BPromise.resolve(toBeCreated).map((u: any) => {
|
||||
const t = _createUser(d, forum, u.name, u.email);
|
||||
return t;
|
||||
}, { concurrency: 1 })
|
||||
|
||||
}
|
||||
|
||||
const updateUserGroups = async (forum) => {
|
||||
const forumUsers = (read(path.resolve(forum + '/fusers.json'), 'json') as any);
|
||||
const users = (read(path.resolve(forum + '/user.json'), 'json') as any);
|
||||
const toBeUpdated = users.filter((u) => {
|
||||
if (u.g_id) {
|
||||
return false;
|
||||
}
|
||||
if (u.name === 'plastichub' || u.name === 'lu' || u.name === 'timberstar' || u.name === 'nickname') {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const d = getDiscourse();
|
||||
console.log('Update Users ' + users.length + ' Total | Left: ' + toBeUpdated.length);
|
||||
return await BPromise.resolve(toBeUpdated).map((u: any) => {
|
||||
const t = _updateGroup(d, forum, u.name, u.f_id, forumUsers);
|
||||
return t;
|
||||
}, { concurrency: 1 })
|
||||
|
||||
}
|
||||
|
||||
const updateUserAvatars = async (forum) => {
|
||||
const users = (read(path.resolve(forum + '/user.json'), 'json') as any);
|
||||
const toBeUpdated = users.filter((u) => {
|
||||
if (!u.upload_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (u.avatarSet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (u.name === 'plastichub' || u.name === 'lu' || u.name === 'timberstar' || u.name === 'nickname') {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const d = getDiscourse();
|
||||
console.log('Update User Avatar ' + users.length + ' Total | Left: ' + toBeUpdated.length);
|
||||
return await BPromise.resolve(toBeUpdated).map((u: any) => {
|
||||
const t = _updateAvatar(d, forum, u.name);
|
||||
return t;
|
||||
}, { concurrency: 1 })
|
||||
|
||||
}
|
||||
*/
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGliLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9vYS9saWIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsTUFBTSxTQUFTLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBQUE7QUFDOUMsTUFBTSxHQUFHLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0FBQzdCLDZCQUE0QjtBQUM1QixNQUFNLFVBQVUsR0FBRyxPQUFP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BQWUsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUM7QUFDeEMsQ0FBQyxDQUFBO0FBSFksUUFBQSxPQUFPLFdBR25CO0FBRUQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0VBdUtFIn0=
|
||||
91
packages/discourse/lib/oa/types.d.ts
vendored
Normal file
91
packages/discourse/lib/oa/types.d.ts
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
import { IUploadedFileMeta, I_OSR_USER } from '@plastichub/osr-commons';
|
||||
export interface IOACategory {
|
||||
_created: string;
|
||||
_id: string;
|
||||
_deleted: boolean;
|
||||
label: string;
|
||||
_modified: string;
|
||||
}
|
||||
export interface IOATag {
|
||||
categories: string[];
|
||||
image: string;
|
||||
_created: string;
|
||||
_deleted: boolean;
|
||||
label: string;
|
||||
_createdBy: string;
|
||||
_modified: string;
|
||||
_id: string;
|
||||
}
|
||||
export type IOADifficultyLevel = 'Easy' | 'Medium' | 'Hard' | 'Very Hard';
|
||||
export interface IDImage {
|
||||
id: number;
|
||||
url: string;
|
||||
original_filename: string;
|
||||
filesize: number;
|
||||
width: number;
|
||||
height: number;
|
||||
thumbnail_width: number;
|
||||
thumbnail_height: number;
|
||||
extension: string;
|
||||
short_url: string;
|
||||
short_path: string;
|
||||
retain_hours: any;
|
||||
human_filesize: string;
|
||||
}
|
||||
export interface IOAHowto {
|
||||
moderation: string;
|
||||
category: IOACategory;
|
||||
previousSlugs: string[];
|
||||
total_downloads: number;
|
||||
_createdBy: string;
|
||||
slug: string;
|
||||
cover_image: IUploadedFileMeta;
|
||||
_modified: string;
|
||||
files: any[];
|
||||
description: string;
|
||||
mentions: any[];
|
||||
time: string;
|
||||
_created: string;
|
||||
fileLink: string;
|
||||
steps: IOAStep[];
|
||||
creatorCountry: string;
|
||||
title: string;
|
||||
tags: IOATags;
|
||||
_id: string;
|
||||
_deleted: boolean;
|
||||
total_views: number;
|
||||
difficulty_level: IOADifficultyLevel;
|
||||
comments: any[];
|
||||
user: IImportUser;
|
||||
pics?: string[];
|
||||
}
|
||||
export interface IOAStep {
|
||||
_animationKey: string;
|
||||
images: IUploadedFileMeta[];
|
||||
text: string;
|
||||
title: string;
|
||||
}
|
||||
export interface IOATags {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
export type IOAHowtoImport = IOAHowto & {
|
||||
post_id?: number | string;
|
||||
topic_id?: number;
|
||||
oF?: boolean;
|
||||
updatedTags?: boolean;
|
||||
updatedTime8?: boolean;
|
||||
_updatedContent1?: boolean;
|
||||
};
|
||||
export interface IImportUser extends I_OSR_USER {
|
||||
f_id: number;
|
||||
upload_id: number;
|
||||
avatar: string;
|
||||
_didSetAvatar: boolean;
|
||||
_didSetGroup: boolean;
|
||||
alreadyExists: boolean;
|
||||
invalidData: boolean;
|
||||
didUpdateName: boolean;
|
||||
profileHeader?: IDImage;
|
||||
cardBackground?: IDImage;
|
||||
avatarImage?: IDImage;
|
||||
}
|
||||
3
packages/discourse/lib/oa/types.js
Normal file
3
packages/discourse/lib/oa/types.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL29hL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
||||
30
packages/discourse/lib/oa/users.d.ts
vendored
Normal file
30
packages/discourse/lib/oa/users.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
import { I_OSR_USER } from '@plastichub/osr-commons';
|
||||
import { IOptions, IImportUser, IDiscourseUser } from '../../';
|
||||
import { Discourser } from '../index';
|
||||
export declare const read_users: (src: string) => I_OSR_USER[];
|
||||
export declare const filter_valid: (users: IImportUser[]) => IImportUser[];
|
||||
export declare const filter_email_only: (users: any[]) => any[];
|
||||
export declare const filter_invalid: (users: any[]) => any[];
|
||||
export declare const filter_email_missing: (users: any[]) => any[];
|
||||
export declare const filter_accepted: (users: IImportUser[]) => IImportUser[];
|
||||
export declare const oa_user_email: (user: I_OSR_USER) => string | false;
|
||||
export declare const get_user_name: (user: IImportUser) => string;
|
||||
export declare const get_user_display_name: (user: IImportUser) => string;
|
||||
export declare const getDataPath: (_path?: string) => string;
|
||||
export declare const getUsersPath: () => string;
|
||||
export declare const getUsers: () => IImportUser[];
|
||||
export declare const _getForumUsers: (d: Discourser, page: any, detail: any) => any;
|
||||
export declare const getForumUsers: (d: any, detail: any) => Promise<IDiscourseUser[]>;
|
||||
export declare const createUser: (discourse: Discourser, oa_user: IImportUser) => Promise<any>;
|
||||
export declare const uploadAvatar: (discourse: any, name: any, filePath: any) => Promise<IImportUser[]>;
|
||||
export declare const updateUser: (discorse: Discourser, oa_user: IImportUser) => Promise<void>;
|
||||
export declare const importUser: (discorse: Discourser, oa_user: IImportUser) => Promise<false | IImportUser>;
|
||||
export declare const mergeLatestUsers: (discorse: any, options: IOptions, oa_users: I_OSR_USER[]) => IImportUser[];
|
||||
export declare const mergeLatestUsersTest: (discorse: any, options: IOptions, oa_users: I_OSR_USER[]) => IImportUser[];
|
||||
export declare const importUsers: (discorse: any, options: IOptions, oa_users: I_OSR_USER[]) => Promise<any>;
|
||||
export declare const updateUsers: (discorse: any, options: IOptions, oa_users: I_OSR_USER[]) => Promise<any>;
|
||||
export declare const md_edit_wrap: (content: any, f: any, prefix?: string, context?: string) => any;
|
||||
export declare const toHTML: (path: any, markdown: any) => any;
|
||||
export declare const imageName: (url: any) => string;
|
||||
export declare const read_fragments: (src: any, config: any, prefix?: string, context?: string) => any;
|
||||
export declare const indexUsers: (discorse: any, options: IOptions, oa_users: I_OSR_USER[]) => Promise<void>;
|
||||
936
packages/discourse/lib/oa/users.js
Normal file
936
packages/discourse/lib/oa/users.js
Normal file
File diff suppressed because one or more lines are too long
26
packages/discourse/lib/oa/utils.d.ts
vendored
Normal file
26
packages/discourse/lib/oa/utils.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import { Discourser } from '../index';
|
||||
export declare const uploadFile: (discourse: any, forum: any, name: any, filePath: any) => Promise<any>;
|
||||
export declare const findReplyPage: (b: any, pages: any) => any;
|
||||
export declare const findReplyUpload: (u: any, page: any) => any;
|
||||
export declare const getPages: (topics: any, topic: any) => any;
|
||||
export declare const getReplies: (topics: any, topic: any) => any[];
|
||||
export declare const findFile: (folder: any, filename: any) => any;
|
||||
export declare const topicFolder: (forum: any, folder: any, title: any) => string;
|
||||
export declare const getFUser: (users: any, user_name: any) => any;
|
||||
export declare const dOptions: {
|
||||
host: string;
|
||||
key: string;
|
||||
username: string;
|
||||
rateLimitConcurrency: number;
|
||||
};
|
||||
export declare const getOAvatar: (index: any, user: any) => any;
|
||||
export declare const getTopics: (index: any) => any[];
|
||||
export declare const convert: (input: string) => any;
|
||||
export declare const getDiscourse: () => Discourser;
|
||||
export declare function inspect(arg: any): string;
|
||||
export declare function log(...args: any[]): void;
|
||||
export declare function mkdirp(path: string): Promise<void>;
|
||||
export declare function readJSON<T extends object>(path: string): Promise<T>;
|
||||
export declare function writeJSON(path: string, data: object): Promise<void>;
|
||||
export declare function exists(path: string): Promise<boolean>;
|
||||
export declare function escape(path: string): string;
|
||||
172
packages/discourse/lib/oa/utils.js
Normal file
172
packages/discourse/lib/oa/utils.js
Normal file
File diff suppressed because one or more lines are too long
1
packages/discourse/lib/osr/index.d.ts
vendored
Normal file
1
packages/discourse/lib/osr/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './urls';
|
||||
18
packages/discourse/lib/osr/index.js
Normal file
18
packages/discourse/lib/osr/index.js
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./urls"), exports);
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL29zci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseUNBQXNCIn0=
|
||||
1
packages/discourse/lib/osr/urls.d.ts
vendored
Normal file
1
packages/discourse/lib/osr/urls.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const marketplaceUrl: (store: any, product_id: any) => string;
|
||||
6
packages/discourse/lib/osr/urls.js
Normal file
6
packages/discourse/lib/osr/urls.js
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.marketplaceUrl = void 0;
|
||||
const marketplaceUrl = (store, product_id) => `${store}/dispatch=products.view&product_id=${product_id}`;
|
||||
exports.marketplaceUrl = marketplaceUrl;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvb3NyL3VybHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQU8sTUFBTSxjQUFjLEdBQUcsQ0FBQyxLQUFLLEVBQUUsVUFBVSxFQUFFLEVBQUUsQ0FDaEQsR0FBRyxLQUFLLHNDQUFzQyxVQUFVLEVBQUUsQ0FBQTtBQURqRCxRQUFBLGNBQWMsa0JBQ21DIn0=
|
||||
12
packages/discourse/lib/sync/commons.d.ts
vendored
Normal file
12
packages/discourse/lib/sync/commons.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference types="node" />
|
||||
import { IOptionsSync, IOptionsSyncComponent } from '../../';
|
||||
export declare const fileAsBuffer: (path: string) => Buffer;
|
||||
export declare const images_urls: (content: string) => any[];
|
||||
export declare const adjustUrls: (content: string, options: IOptionsSync) => string;
|
||||
export declare const fromJSON: (content: string, file: string, options: IOptionsSyncComponent) => void;
|
||||
export declare const fromYAML: (content: string, options: IOptionsSync) => {
|
||||
attributes: any;
|
||||
body: any;
|
||||
};
|
||||
export declare const option: (option: string, taskOptions: any, col: any, _default?: any) => any;
|
||||
export declare const createContent: (file: any, _options: any) => Promise<any>;
|
||||
174
packages/discourse/lib/sync/commons.js
Normal file
174
packages/discourse/lib/sync/commons.js
Normal file
File diff suppressed because one or more lines are too long
6
packages/discourse/lib/sync/component.d.ts
vendored
Normal file
6
packages/discourse/lib/sync/component.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import { IOptionsSync } from '../../types';
|
||||
import { Discourser } from '../discourse';
|
||||
export declare const createPost: (discourse: Discourser, options: IOptionsSync, content: any) => Promise<boolean>;
|
||||
export declare const updatePost: (discourse: Discourser, options: IOptionsSync, topic_id: any, content: any) => Promise<boolean>;
|
||||
export declare const syncComponent: (options: IOptionsSync) => Promise<void>;
|
||||
export declare const sync: (options: IOptionsSync) => Promise<void>;
|
||||
373
packages/discourse/lib/sync/component.js
Normal file
373
packages/discourse/lib/sync/component.js
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user