fix(core): update

This commit is contained in:
Philipp Kunz 2021-07-23 13:53:33 +02:00
parent 7937d9aeff
commit 04872e7ae9
12 changed files with 24624 additions and 702 deletions

3
dist_ts/index.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export * from './slack.classes.slackaccount';
export * from './slack.classes.slackmessage';
export * from './slack.classes.slacklog';

16
dist_ts/index.js Normal file
View File

@ -0,0 +1,16 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./slack.classes.slackaccount"), exports);
__exportStar(require("./slack.classes.slackmessage"), exports);
__exportStar(require("./slack.classes.slacklog"), exports);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSwrREFBNkM7QUFDN0MsK0RBQTZDO0FBQzdDLDJEQUF5QyJ9

14
dist_ts/slack.classes.slackaccount.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import * as plugins from './slack.plugins';
import { IMessageOptions } from './slack.classes.slackmessage';
export declare class SlackAccount {
private postUrl;
private updateUrl;
private slackToken;
constructor(slackTokenArg: string);
sendMessage(optionsArg: {
messageOptions: IMessageOptions;
channelArg: string;
ts?: string;
mode: 'new' | 'threaded' | 'update';
}): Promise<plugins.smartrequest.IExtendedIncomingMessage>;
}

View File

@ -0,0 +1,65 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlackAccount = void 0;
const plugins = __importStar(require("./slack.plugins"));
class SlackAccount {
constructor(slackTokenArg) {
this.postUrl = 'https://slack.com/api/chat.postMessage';
this.updateUrl = 'https://slack.com/api/chat.update';
this.slackToken = slackTokenArg;
}
async sendMessage(optionsArg) {
let requestBody = {
channel: optionsArg.channelArg,
text: optionsArg.messageOptions.text
};
if (optionsArg.messageOptions.fields) {
requestBody = Object.assign(Object.assign({}, requestBody), { attachments: [
{
pretext: optionsArg.messageOptions.pretext,
fields: optionsArg.messageOptions.fields,
ts: optionsArg.messageOptions.ts,
color: optionsArg.messageOptions.color
}
] });
}
let postUrl = this.postUrl;
switch (true) {
case optionsArg.ts && optionsArg.mode === 'update':
requestBody = Object.assign(Object.assign({}, requestBody), { ts: optionsArg.ts });
postUrl = this.updateUrl;
break;
case optionsArg.ts && optionsArg.mode === 'threaded':
requestBody = Object.assign(Object.assign({}, requestBody), { thread_ts: optionsArg.ts });
break;
}
const response = await plugins.smartrequest.postJson(postUrl, {
headers: {
Authorization: `Bearer ${this.slackToken}`
},
requestBody
});
return response;
}
}
exports.SlackAccount = SlackAccount;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2suY2xhc3Nlcy5zbGFja2FjY291bnQ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QUFJLEtBQUssUUFBUTtnQkFDaEQsV0FBVyxtQ0FDTixXQUFXLEtBQ2QsRUFBRSxFQUFFLFVBQVUsQ0FBQyxFQUFFLEdBQ2xCLENBQUM7Z0JBQ0YsT0FBTyxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUM7Z0JBQ3pCLE1BQU07WUFDUixLQUFLLFVBQVUsQ0FBQyxFQUFFLElBQUksVUFBVSxDQUFDLElBQUksS0FBSyxVQUFVO2dCQUNsRCxXQUFXLG1DQUNOLFdBQVcsS0FDZCxTQUFTLEVBQUUsVUFBVSxDQUFDLEVBQUUsR0FDekIsQ0FBQztnQkFDRixNQUFNO1NBQ1Q7UUFFRCxNQUFNLFFBQVEsR0FBRyxNQUFNLE9BQU8sQ0FBQyxZQUFZLENBQUMsUUFBUSxDQUFDLE9BQU8sRUFBRTtZQUM1RCxPQUFPLEVBQUU7Z0JBQ1AsYUFBYSxFQUFFLFVBQVUsSUFBSSxDQUFDLFVBQVUsRUFBRTthQUMzQztZQUNELFdBQVc7U0FDWixDQUFDLENBQUM7UUFDSCxPQUFPLFFBQVEsQ0FBQztJQUNsQixDQUFDO0NBQ0Y7QUEzREQsb0NBMkRDIn0=

13
dist_ts/slack.classes.slacklog.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
import { SlackAccount } from './slack.classes.slackaccount';
import { SlackMessage } from './slack.classes.slackmessage';
export declare class SlackLog {
slackAccount: SlackAccount;
slackMessage: SlackMessage;
channelName: string;
completeLog: string;
constructor(optionsArg: {
slackAccount: SlackAccount;
channelName: string;
});
sendLogLine(logText: string): Promise<void>;
}

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlackLog = void 0;
const slack_classes_slackmessage_1 = require("./slack.classes.slackmessage");
class SlackLog {
constructor(optionsArg) {
this.completeLog = ``;
this.slackAccount = optionsArg.slackAccount;
this.channelName = optionsArg.channelName;
}
async sendLogLine(logText) {
if (!this.slackMessage) {
this.slackMessage = new slack_classes_slackmessage_1.SlackMessage(this.slackAccount, {
text: '``` log is loading... ```'
});
await this.slackMessage.sendToRoom(this.channelName);
}
const date = new Date();
this.completeLog +=
`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()} - ` + logText + '\n';
await this.slackMessage.updateAndSend({
text: '```\n' + this.completeLog + '\n```'
});
}
}
exports.SlackLog = SlackLog;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2suY2xhc3Nlcy5zbGFja2xvZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NsYWNrLmNsYXNzZXMuc2xhY2tsb2cudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsNkVBQTREO0FBRTVELE1BQWEsUUFBUTtJQU9uQixZQUFZLFVBQStEO1FBRnBFLGdCQUFXLEdBQUcsRUFBRSxDQUFDO1FBR3RCLElBQUksQ0FBQyxZQUFZLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQztRQUM1QyxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUM7SUFDNUMsQ0FBQztJQUNNLEtBQUssQ0FBQyxXQUFXLENBQUMsT0FBZTtRQUN0QyxJQUFJLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBRTtZQUN0QixJQUFJLENBQUMsWUFBWSxHQUFHLElBQUkseUNBQVksQ0FBQyxJQUFJLENBQUMsWUFBWSxFQUFFO2dCQUN0RCxJQUFJLEVBQUUsMkJBQTJCO2FBQ2xDLENBQUMsQ0FBQztZQUNILE1BQU0sSUFBSSxDQUFDLFlBQVksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1NBQ3REO1FBQ0QsTUFBTSxJQUFJLEdBQUcsSUFBSSxJQUFJLEVBQUUsQ0FBQztRQUN4QixJQUFJLENBQUMsV0FBVztZQUNkLEdBQUcsSUFBSSxDQUFDLFFBQVEsRUFBRSxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUUsSUFBSSxJQUFJLENBQUMsVUFBVSxFQUFFLEtBQUssR0FBRyxPQUFPLEdBQUcsSUFBSSxDQUFDO1FBQ3JGLE1BQU0sSUFBSSxDQUFDLFlBQVksQ0FBQyxhQUFhLENBQUM7WUFDcEMsSUFBSSxFQUFFLE9BQU8sR0FBRyxJQUFJLENBQUMsV0FBVyxHQUFHLE9BQU87U0FDM0MsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztDQUNGO0FBekJELDRCQXlCQyJ9

62
dist_ts/slack.classes.slackmessage.d.ts vendored Normal file
View File

@ -0,0 +1,62 @@
import * as plugins from './slack.plugins';
import { SlackAccount } from './slack.classes.slackaccount';
export interface IAttachmentField {
title: string;
value: string;
short?: boolean;
}
export interface IMessageOptions {
/**
* "Required plain-text summary of the attachment."
*/
fallback?: string;
/**
* a side color
*/
color?: string;
/**
* a message to show above
*/
pretext?: string;
/**
* author name of the attachment
*/
author_name?: string;
/**
* a link to the author
*/
author_link?: string;
/**
* a string to the author
*/
author_icon?: string;
/**
* a title for the attachment
*/
title?: string;
/**
* a link for the title
*/
title_link?: string;
/**
* the main text of the message
*/
text?: string;
fields?: IAttachmentField[];
image_url?: string;
thumb_url?: string;
footer?: string;
footer_icon?: string;
ts?: number;
}
export declare class SlackMessage {
slackAccountRef: SlackAccount;
messageOptions: IMessageOptions;
channel: string;
ts: string;
requestRunning: plugins.smartpromise.Deferred<unknown>;
constructor(slackAccountArg: SlackAccount, messageOptionsArg: IMessageOptions);
updateAndSend(messageOptionsArg: IMessageOptions): Promise<void>;
startThread(messageOptionsArg: IMessageOptions): Promise<void>;
sendToRoom(channelNameArg: string, modeArg?: 'new' | 'update' | 'threaded'): Promise<void>;
}

View File

@ -0,0 +1,61 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlackMessage = void 0;
const plugins = __importStar(require("./slack.plugins"));
class SlackMessage {
constructor(slackAccountArg, messageOptionsArg) {
this.requestRunning = plugins.smartpromise.defer();
if (slackAccountArg) {
this.slackAccountRef = slackAccountArg;
}
this.messageOptions = messageOptionsArg;
this.requestRunning.resolve();
}
async updateAndSend(messageOptionsArg) {
this.messageOptions = messageOptionsArg;
await this.sendToRoom(this.channel, 'update');
}
async startThread(messageOptionsArg) {
this.messageOptions = messageOptionsArg;
this.sendToRoom(this.channel, 'threaded');
}
async sendToRoom(channelNameArg, modeArg = 'new') {
this.channel = channelNameArg;
if (this.slackAccountRef) {
const response = await this.slackAccountRef.sendMessage({
channelArg: this.channel,
messageOptions: this.messageOptions,
mode: modeArg,
ts: this.ts
});
if (modeArg === 'new') {
this.ts = response.body.message.ts;
this.channel = response.body.channel;
}
}
else {
throw new Error('you need to set a slackRef before sending the message!');
}
}
}
exports.SlackMessage = SlackMessage;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2suY2xhc3Nlcy5zbGFja21lc3NhZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbGFjay5jbGFzc2VzLnNsYWNrbWVzc2FnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Oz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JBQ25DLElBQUksRUFBRSxPQUFPO2dCQUNiLEVBQUUsRUFBRSxJQUFJLENBQUMsRUFBRTthQUNaLENBQUMsQ0FBQztZQUNILElBQUksT0FBTyxLQUFLLEtBQUssRUFBRTtnQkFDckIsSUFBSSxDQUFDLEVBQUUsR0FBRyxRQUFRLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUM7Z0JBQ25DLElBQUksQ0FBQyxPQUFPLEdBQUcsUUFBUSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7YUFDdEM7U0FDRjthQUFNO1lBQ0wsTUFBTSxJQUFJLEtBQUssQ0FBQyx3REFBd0QsQ0FBQyxDQUFDO1NBQzNFO0lBQ0gsQ0FBQztDQUNGO0FBM0NELG9DQTJDQyJ9

3
dist_ts/slack.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export { smartpromise, smartrequest };

28
dist_ts/slack.plugins.js Normal file
View File

@ -0,0 +1,28 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.smartrequest = exports.smartpromise = void 0;
// pushrocks scope
const smartpromise = __importStar(require("@pushrocks/smartpromise"));
exports.smartpromise = smartpromise;
const smartrequest = __importStar(require("@pushrocks/smartrequest"));
exports.smartrequest = smartrequest;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2sucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NsYWNrLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLGtCQUFrQjtBQUNsQixzRUFBd0Q7QUFHL0Msb0NBQVk7QUFGckIsc0VBQXdEO0FBRWpDLG9DQUFZIn0=

25014
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,21 +9,21 @@
"license": "MIT",
"scripts": {
"test": "tstest test/",
"build": "tsbuild"
"build": "tsbuild --web"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/qenv": "^4.0.4",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.4",
"tslint": "^5.20.0",
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.17",
"@gitzone/tstest": "^1.0.54",
"@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.4.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartpromise": "^3.0.5",
"@pushrocks/smartrequest": "^1.1.23"
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartrequest": "^1.1.52"
},
"files": [
"ts/*",