@todoist/ui-extensions-server 0.0.0-stage → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/analytics/events.d.ts +8 -0
- package/dist/analytics/events.js +15 -0
- package/dist/analytics/events.js.map +1 -0
- package/dist/buffer/cloneBuffer.d.ts +1 -0
- package/dist/buffer/cloneBuffer.js +12 -0
- package/dist/buffer/cloneBuffer.js.map +1 -0
- package/dist/buffer/incomingMessageWithRawBody.d.ts +4 -0
- package/dist/buffer/incomingMessageWithRawBody.js +8 -0
- package/dist/buffer/incomingMessageWithRawBody.js.map +1 -0
- package/dist/buffer/index.d.ts +2 -0
- package/dist/buffer/index.js +19 -0
- package/dist/buffer/index.js.map +1 -0
- package/dist/config/configurationBase.d.ts +29 -0
- package/dist/config/configurationBase.js +58 -0
- package/dist/config/configurationBase.js.map +1 -0
- package/dist/constants/card-actions.d.ts +12 -0
- package/dist/constants/card-actions.js +17 -0
- package/dist/constants/card-actions.js.map +1 -0
- package/dist/constants/core-strings.d.ts +61 -0
- package/dist/constants/core-strings.js +66 -0
- package/dist/constants/core-strings.js.map +1 -0
- package/dist/constants/images.d.ts +25 -0
- package/dist/constants/images.js +29 -0
- package/dist/constants/images.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/ui-constants.d.ts +1 -0
- package/dist/constants/ui-constants.js +5 -0
- package/dist/constants/ui-constants.js.map +1 -0
- package/dist/controllers/app.controller.d.ts +15 -0
- package/dist/controllers/app.controller.js +76 -0
- package/dist/controllers/app.controller.js.map +1 -0
- package/dist/controllers/auth.controller.d.ts +47 -0
- package/dist/controllers/auth.controller.js +348 -0
- package/dist/controllers/auth.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.js +20 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/controllers/ping.controller.d.ts +3 -0
- package/dist/controllers/ping.controller.js +30 -0
- package/dist/controllers/ping.controller.js.map +1 -0
- package/dist/decorators/action-decorators.d.ts +12 -0
- package/dist/decorators/action-decorators.js +12 -0
- package/dist/decorators/action-decorators.js.map +1 -0
- package/dist/decorators/app-token.decorator.d.ts +1 -0
- package/dist/decorators/app-token.decorator.js +12 -0
- package/dist/decorators/app-token.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/typed-method-decorator.d.ts +1 -0
- package/dist/decorators/typed-method-decorator.js +3 -0
- package/dist/decorators/typed-method-decorator.js.map +1 -0
- package/dist/entities/User.d.ts +24 -0
- package/dist/entities/User.js +89 -0
- package/dist/entities/User.js.map +1 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.js +18 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +18 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/integration.exception.d.ts +32 -0
- package/dist/exceptions/integration.exception.js +17 -0
- package/dist/exceptions/integration.exception.js.map +1 -0
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +18 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/integration-exception.filter.d.ts +10 -0
- package/dist/filters/integration-exception.filter.js +83 -0
- package/dist/filters/integration-exception.filter.js.map +1 -0
- package/dist/guards/extensionVerification.guard.d.ts +6 -0
- package/dist/guards/extensionVerification.guard.js +55 -0
- package/dist/guards/extensionVerification.guard.js.map +1 -0
- package/dist/guards/index.d.ts +1 -0
- package/dist/guards/index.js +18 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/sentry.interceptor.d.ts +5 -0
- package/dist/interceptors/sentry.interceptor.js +30 -0
- package/dist/interceptors/sentry.interceptor.js.map +1 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +18 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/json.logger.d.ts +7 -0
- package/dist/logging/json.logger.js +23 -0
- package/dist/logging/json.logger.js.map +1 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.js +18 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/request-header.middleware.d.ts +8 -0
- package/dist/middleware/request-header.middleware.js +29 -0
- package/dist/middleware/request-header.middleware.js.map +1 -0
- package/dist/middleware/workflow-initial-action.middleware.d.ts +13 -0
- package/dist/middleware/workflow-initial-action.middleware.js +23 -0
- package/dist/middleware/workflow-initial-action.middleware.js.map +1 -0
- package/dist/modules/analytics.module.d.ts +5 -0
- package/dist/modules/analytics.module.js +37 -0
- package/dist/modules/analytics.module.js.map +1 -0
- package/dist/modules/app-token.module.d.ts +2 -0
- package/dist/modules/app-token.module.js +22 -0
- package/dist/modules/app-token.module.js.map +1 -0
- package/dist/modules/auth.module.d.ts +17 -0
- package/dist/modules/auth.module.js +44 -0
- package/dist/modules/auth.module.js.map +1 -0
- package/dist/modules/core.module.d.ts +4 -0
- package/dist/modules/core.module.js +38 -0
- package/dist/modules/core.module.js.map +1 -0
- package/dist/modules/error.module.d.ts +7 -0
- package/dist/modules/error.module.js +39 -0
- package/dist/modules/error.module.js.map +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +20 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/request-headers.module.d.ts +2 -0
- package/dist/modules/request-headers.module.js +22 -0
- package/dist/modules/request-headers.module.js.map +1 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +52 -0
- package/dist/server.js.map +1 -0
- package/dist/services/actions.service.d.ts +19 -0
- package/dist/services/actions.service.js +126 -0
- package/dist/services/actions.service.js.map +1 -0
- package/dist/services/adaptive-card.service.d.ts +57 -0
- package/dist/services/adaptive-card.service.js +284 -0
- package/dist/services/adaptive-card.service.js.map +1 -0
- package/dist/services/analytics.service.d.ts +7 -0
- package/dist/services/analytics.service.js +20 -0
- package/dist/services/analytics.service.js.map +1 -0
- package/dist/services/app-token.service.d.ts +6 -0
- package/dist/services/app-token.service.js +47 -0
- package/dist/services/app-token.service.js.map +1 -0
- package/dist/services/authentication-client.d.ts +42 -0
- package/dist/services/authentication-client.js +95 -0
- package/dist/services/authentication-client.js.map +1 -0
- package/dist/services/composer-append-formatting.service.d.ts +9 -0
- package/dist/services/composer-append-formatting.service.js +37 -0
- package/dist/services/composer-append-formatting.service.js.map +1 -0
- package/dist/services/composer-append-settings.service.d.ts +7 -0
- package/dist/services/composer-append-settings.service.js +39 -0
- package/dist/services/composer-append-settings.service.js.map +1 -0
- package/dist/services/errorCard.service.d.ts +14 -0
- package/dist/services/errorCard.service.js +129 -0
- package/dist/services/errorCard.service.js.map +1 -0
- package/dist/services/google-analytics.service.d.ts +10 -0
- package/dist/services/google-analytics.service.js +56 -0
- package/dist/services/google-analytics.service.js.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.js +32 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/legacy-google-analytics.service.d.ts +10 -0
- package/dist/services/legacy-google-analytics.service.js +56 -0
- package/dist/services/legacy-google-analytics.service.js.map +1 -0
- package/dist/services/login.service.d.ts +31 -0
- package/dist/services/login.service.js +165 -0
- package/dist/services/login.service.js.map +1 -0
- package/dist/services/request-headers.service.d.ts +9 -0
- package/dist/services/request-headers.service.js +53 -0
- package/dist/services/request-headers.service.js.map +1 -0
- package/dist/services/state.service.d.ts +18 -0
- package/dist/services/state.service.js +96 -0
- package/dist/services/state.service.js.map +1 -0
- package/dist/services/theme.service.d.ts +5 -0
- package/dist/services/theme.service.js +28 -0
- package/dist/services/theme.service.js.map +1 -0
- package/dist/services/translation.service.d.ts +3 -0
- package/dist/services/translation.service.js +20 -0
- package/dist/services/translation.service.js.map +1 -0
- package/dist/services/user-database.service.d.ts +18 -0
- package/dist/services/user-database.service.js +87 -0
- package/dist/services/user-database.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/auth.d.ts +8 -0
- package/dist/types/auth.js +3 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/data.d.ts +12 -0
- package/dist/types/data.js +10 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/endpoints.d.ts +1 -0
- package/dist/types/endpoints.js +3 -0
- package/dist/types/endpoints.js.map +1 -0
- package/dist/types/error-card-options.d.ts +11 -0
- package/dist/types/error-card-options.js +3 -0
- package/dist/types/error-card-options.js.map +1 -0
- package/dist/types/error.d.ts +2 -0
- package/dist/types/error.js +12 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/logging.d.ts +1 -0
- package/dist/types/logging.js +3 -0
- package/dist/types/logging.js.map +1 -0
- package/dist/types/product.d.ts +1 -0
- package/dist/types/product.js +3 -0
- package/dist/types/product.js.map +1 -0
- package/dist/types/retry.d.ts +11 -0
- package/dist/types/retry.js +12 -0
- package/dist/types/retry.js.map +1 -0
- package/dist/ui/back-button.d.ts +7 -0
- package/dist/ui/back-button.js +33 -0
- package/dist/ui/back-button.js.map +1 -0
- package/dist/ui/button.d.ts +15 -0
- package/dist/ui/button.js +27 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/column.d.ts +4 -0
- package/dist/ui/column.js +23 -0
- package/dist/ui/column.js.map +1 -0
- package/dist/ui/container.d.ts +11 -0
- package/dist/ui/container.js +31 -0
- package/dist/ui/container.js.map +1 -0
- package/dist/ui/date-time-input.d.ts +17 -0
- package/dist/ui/date-time-input.js +59 -0
- package/dist/ui/date-time-input.js.map +1 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +26 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/profile-details.d.ts +3 -0
- package/dist/ui/profile-details.js +16 -0
- package/dist/ui/profile-details.js.map +1 -0
- package/dist/ui/stock-button.d.ts +20 -0
- package/dist/ui/stock-button.js +131 -0
- package/dist/ui/stock-button.js.map +1 -0
- package/dist/ui/text-block.d.ts +9 -0
- package/dist/ui/text-block.js +24 -0
- package/dist/ui/text-block.js.map +1 -0
- package/dist/ui/ui-builder-context.d.ts +7 -0
- package/dist/ui/ui-builder-context.js +3 -0
- package/dist/ui/ui-builder-context.js.map +1 -0
- package/dist/utils/action-utils.d.ts +5 -0
- package/dist/utils/action-utils.js +29 -0
- package/dist/utils/action-utils.js.map +1 -0
- package/dist/utils/card-bridge.d.ts +7 -0
- package/dist/utils/card-bridge.js +30 -0
- package/dist/utils/card-bridge.js.map +1 -0
- package/dist/utils/context-utils.d.ts +3 -0
- package/dist/utils/context-utils.js +21 -0
- package/dist/utils/context-utils.js.map +1 -0
- package/dist/utils/dateUtils.d.ts +10 -0
- package/dist/utils/dateUtils.js +88 -0
- package/dist/utils/dateUtils.js.map +1 -0
- package/dist/utils/encryption.d.ts +10 -0
- package/dist/utils/encryption.js +70 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/endpointUtils.d.ts +2 -0
- package/dist/utils/endpointUtils.js +7 -0
- package/dist/utils/endpointUtils.js.map +1 -0
- package/dist/utils/envUtils.d.ts +1 -0
- package/dist/utils/envUtils.js +7 -0
- package/dist/utils/envUtils.js.map +1 -0
- package/dist/utils/errorUtils.d.ts +6 -0
- package/dist/utils/errorUtils.js +51 -0
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/header-utils.d.ts +9 -0
- package/dist/utils/header-utils.js +24 -0
- package/dist/utils/header-utils.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +30 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paginationDataUtils.d.ts +6 -0
- package/dist/utils/paginationDataUtils.js +52 -0
- package/dist/utils/paginationDataUtils.js.map +1 -0
- package/dist/utils/urlUtils.d.ts +2 -0
- package/dist/utils/urlUtils.js +20 -0
- package/dist/utils/urlUtils.js.map +1 -0
- package/dist/utils/validationUtils.d.ts +3 -0
- package/dist/utils/validationUtils.js +22 -0
- package/dist/utils/validationUtils.js.map +1 -0
- package/package.json +63 -5
- package/views/authDetails.hbs +97 -0
- package/views/partials/errorBody.hbs +7 -0
- package/views/partials/errorTitle.hbs +1 -0
- package/views/partials/successBody.hbs +2 -0
- package/views/partials/successTitle.hbs +1 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AdaptiveCardService = exports.ERROR_CONTENT_ID = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const integrations_common_1 = require("@todoist/integrations-common");
|
|
15
|
+
const ui_extensions_core_1 = require("@todoist/ui-extensions-core");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
const types_1 = require("../types");
|
|
18
|
+
const ui_1 = require("../ui");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const theme_service_1 = require("./theme.service");
|
|
21
|
+
const translation_service_1 = require("./translation.service");
|
|
22
|
+
exports.ERROR_CONTENT_ID = 'ErrorContent';
|
|
23
|
+
let AdaptiveCardService = class AdaptiveCardService {
|
|
24
|
+
constructor(translationService, themeService) {
|
|
25
|
+
this.translationService = translationService;
|
|
26
|
+
this.themeService = themeService;
|
|
27
|
+
}
|
|
28
|
+
get spacingImageUrl() {
|
|
29
|
+
return this.createStaticUrl(constants_1.SPACING_IMAGE);
|
|
30
|
+
}
|
|
31
|
+
createStaticUrl(path) {
|
|
32
|
+
return (0, utils_1.createStaticUrl)(path);
|
|
33
|
+
}
|
|
34
|
+
createThemeBasedUrl(pathFormat) {
|
|
35
|
+
return this.themeService.createThemeBasedUrl(pathFormat);
|
|
36
|
+
}
|
|
37
|
+
createEmptyCard() {
|
|
38
|
+
const emptyCard = new ui_extensions_core_1.TodoistCard();
|
|
39
|
+
emptyCard.todoistCardVersion = '0.3';
|
|
40
|
+
return emptyCard;
|
|
41
|
+
}
|
|
42
|
+
createHeader(leftColumnItems, middleColumnItems, rightColumnItems, includeEmptySpacing = true) {
|
|
43
|
+
return (0, ui_extensions_core_1.createHeader)({
|
|
44
|
+
leftColumnItems,
|
|
45
|
+
middleColumnItems,
|
|
46
|
+
rightColumnItems,
|
|
47
|
+
emptySpaceImageUrl: includeEmptySpacing ? this.spacingImageUrl : undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
createCardWithItems(items) {
|
|
51
|
+
const card = this.createEmptyCard();
|
|
52
|
+
items.forEach((item) => {
|
|
53
|
+
card.addItem(item);
|
|
54
|
+
});
|
|
55
|
+
return card;
|
|
56
|
+
}
|
|
57
|
+
errorCard(errorCardOptions) {
|
|
58
|
+
const { showSignout = true, showGoHome = true, errorMessage = this.translationService.getTranslation(constants_1.Core.ERROR_CONTENT), retryRequest, helpCenterLink, errorId, maximumDoistCardVersion = 0.3, } = errorCardOptions !== null && errorCardOptions !== void 0 ? errorCardOptions : {};
|
|
59
|
+
const card = this.createEmptyCard();
|
|
60
|
+
card.verticalContentAlignment = 'center';
|
|
61
|
+
card.minHeight = 200;
|
|
62
|
+
const errorImage = new ui_extensions_core_1.Image();
|
|
63
|
+
errorImage.pixelWidth = 200;
|
|
64
|
+
errorImage.url = this.createThemeBasedUrl(constants_1.ERROR_IMAGE);
|
|
65
|
+
errorImage.horizontalAlignment = 'center';
|
|
66
|
+
const content = new ui_extensions_core_1.TextBlock(errorMessage);
|
|
67
|
+
content.id = exports.ERROR_CONTENT_ID;
|
|
68
|
+
content.horizontalAlignment = 'center';
|
|
69
|
+
content.wrap = true;
|
|
70
|
+
card.addItem(errorImage);
|
|
71
|
+
card.addItem(content);
|
|
72
|
+
if (retryRequest) {
|
|
73
|
+
const data = {
|
|
74
|
+
[types_1.RetryAttributes.ORIGINAL_DATA]: retryRequest.retryAction.data,
|
|
75
|
+
[types_1.RetryAttributes.ORIGINAL_INPUTS]: retryRequest.retryAction.inputs,
|
|
76
|
+
[types_1.RetryAttributes.COMMAND]: retryRequest.retryAction.actionId,
|
|
77
|
+
[types_1.RetryAttributes.ACTION_TYPE]: retryRequest.retryAction.actionType,
|
|
78
|
+
};
|
|
79
|
+
const retryButton = new ui_extensions_core_1.SubmitAction();
|
|
80
|
+
retryButton.id = constants_1.CardActions.Retry;
|
|
81
|
+
retryButton.data = data;
|
|
82
|
+
retryButton.style = 'positive';
|
|
83
|
+
retryButton.title = this.translationService.getTranslation(constants_1.Core.RETRY);
|
|
84
|
+
const column = new ui_extensions_core_1.Column(new ui_extensions_core_1.SizeAndUnit(100, 'pixel'));
|
|
85
|
+
const actions = new ui_extensions_core_1.ActionSet();
|
|
86
|
+
actions.id = 'RetryActions';
|
|
87
|
+
actions.addAction(retryButton);
|
|
88
|
+
column.addItem(actions);
|
|
89
|
+
const columns = new ui_extensions_core_1.ColumnSet();
|
|
90
|
+
columns.horizontalAlignment = 'center';
|
|
91
|
+
columns.spacing = 'medium';
|
|
92
|
+
columns.addColumn(column);
|
|
93
|
+
card.addItem(columns);
|
|
94
|
+
}
|
|
95
|
+
const actionSet = new ui_extensions_core_1.ActionSet();
|
|
96
|
+
actionSet.spacing = 'medium';
|
|
97
|
+
if (showGoHome) {
|
|
98
|
+
const goHomeButton = new ui_extensions_core_1.SubmitAction();
|
|
99
|
+
goHomeButton.id = constants_1.CardActions.GoHome;
|
|
100
|
+
goHomeButton.title = this.translationService.getTranslation(constants_1.Core.GO_BACK);
|
|
101
|
+
goHomeButton.associatedInputs = 'none';
|
|
102
|
+
actionSet.addAction(goHomeButton);
|
|
103
|
+
}
|
|
104
|
+
if (helpCenterLink) {
|
|
105
|
+
const contactUsButton = new ui_extensions_core_1.OpenUrlAction();
|
|
106
|
+
contactUsButton.title = this.translationService.getTranslation(constants_1.Core.CONTACT_US);
|
|
107
|
+
contactUsButton.url = helpCenterLink;
|
|
108
|
+
actionSet.addAction(contactUsButton);
|
|
109
|
+
}
|
|
110
|
+
if (errorId && maximumDoistCardVersion >= 0.6) {
|
|
111
|
+
const copySupportDataButton = new ui_extensions_core_1.ClipboardAction();
|
|
112
|
+
copySupportDataButton.id = constants_1.CardActions.CopySupportInfo;
|
|
113
|
+
copySupportDataButton.title = this.translationService.getTranslation(constants_1.Core.COPY_SUPPORT_INFORMATION);
|
|
114
|
+
copySupportDataButton.text = JSON.stringify({ errorId });
|
|
115
|
+
actionSet.addAction(copySupportDataButton);
|
|
116
|
+
}
|
|
117
|
+
if (showSignout) {
|
|
118
|
+
const signOutButton = new ui_extensions_core_1.SubmitAction();
|
|
119
|
+
signOutButton.id = constants_1.CardActions.LogOut;
|
|
120
|
+
signOutButton.title = this.translationService.getTranslation(constants_1.Core.LOGOUT);
|
|
121
|
+
signOutButton.style = 'destructive';
|
|
122
|
+
actionSet.addAction(signOutButton);
|
|
123
|
+
}
|
|
124
|
+
card.addItem(actionSet);
|
|
125
|
+
return card;
|
|
126
|
+
}
|
|
127
|
+
confirmationCard(options) {
|
|
128
|
+
const { title, body, confirmationText, confirmationData, confirmationActionId, cancelData, cancelActionId, } = options;
|
|
129
|
+
const card = this.createEmptyCard();
|
|
130
|
+
const titleText = (0, ui_1.createTitleTextBlock)({ text: title });
|
|
131
|
+
const bodyText = ui_extensions_core_1.TextBlock.from({
|
|
132
|
+
text: body,
|
|
133
|
+
wrap: true,
|
|
134
|
+
});
|
|
135
|
+
card.addItem(titleText);
|
|
136
|
+
card.addItem(bodyText);
|
|
137
|
+
const confirmationButton = new ui_extensions_core_1.SubmitAction();
|
|
138
|
+
confirmationButton.title =
|
|
139
|
+
confirmationText !== null && confirmationText !== void 0 ? confirmationText : this.translationService.getTranslation(constants_1.Core.YES);
|
|
140
|
+
confirmationButton.data = confirmationData;
|
|
141
|
+
confirmationButton.id = confirmationActionId;
|
|
142
|
+
confirmationButton.style = 'positive';
|
|
143
|
+
const cancelButton = new ui_extensions_core_1.SubmitAction();
|
|
144
|
+
cancelButton.id = cancelActionId !== null && cancelActionId !== void 0 ? cancelActionId : constants_1.CardActions.GoHome;
|
|
145
|
+
cancelButton.title = this.translationService.getTranslation(constants_1.Core.CANCEL);
|
|
146
|
+
cancelButton.associatedInputs = 'none';
|
|
147
|
+
cancelButton.data = cancelData;
|
|
148
|
+
const actions = new ui_extensions_core_1.ActionSet();
|
|
149
|
+
actions.addAction(cancelButton);
|
|
150
|
+
actions.addAction(confirmationButton);
|
|
151
|
+
card.addItem((0, ui_1.pageActions)(actions));
|
|
152
|
+
return card;
|
|
153
|
+
}
|
|
154
|
+
createTextWithLearnMore(options) {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
return ui_extensions_core_1.RichTextBlock.fromWithInlines({
|
|
157
|
+
spacing: (_a = options.spacing) !== null && _a !== void 0 ? _a : 'medium',
|
|
158
|
+
horizontalAlignment: (_b = options.horizontalAlignment) !== null && _b !== void 0 ? _b : 'left',
|
|
159
|
+
inlines: [
|
|
160
|
+
ui_extensions_core_1.TextRun.from({
|
|
161
|
+
text: this.translationService.getTranslation(options.textKey),
|
|
162
|
+
isSubtle: true,
|
|
163
|
+
size: 'small',
|
|
164
|
+
}),
|
|
165
|
+
ui_extensions_core_1.TextRun.from({ text: ' ' }),
|
|
166
|
+
ui_extensions_core_1.TextRun.from({
|
|
167
|
+
text: this.translationService.getTranslation(constants_1.Core.LEARN_MORE),
|
|
168
|
+
selectAction: ui_extensions_core_1.OpenUrlAction.from({
|
|
169
|
+
url: options.learnMoreUrl,
|
|
170
|
+
}),
|
|
171
|
+
size: 'small',
|
|
172
|
+
color: 'attention',
|
|
173
|
+
}),
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
notFoundImage() {
|
|
178
|
+
const notFoundImage = new ui_extensions_core_1.Image();
|
|
179
|
+
notFoundImage.pixelWidth = 200;
|
|
180
|
+
notFoundImage.url = this.createThemeBasedUrl(constants_1.ERROR_IMAGE);
|
|
181
|
+
notFoundImage.horizontalAlignment = 'center';
|
|
182
|
+
return notFoundImage;
|
|
183
|
+
}
|
|
184
|
+
createNotFoundCard(options) {
|
|
185
|
+
return ui_extensions_core_1.TodoistCard.fromWithItems({
|
|
186
|
+
items: [
|
|
187
|
+
this.notFoundImage(),
|
|
188
|
+
this.createTextWithLearnMore({
|
|
189
|
+
textKey: options.textKey,
|
|
190
|
+
learnMoreUrl: options.learnMoreUrl,
|
|
191
|
+
}),
|
|
192
|
+
],
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
noResultsImage() {
|
|
196
|
+
const noResultsImage = new ui_extensions_core_1.Image();
|
|
197
|
+
noResultsImage.pixelWidth = 200;
|
|
198
|
+
noResultsImage.url = this.createThemeBasedUrl(constants_1.NO_RESULTS_IMAGE);
|
|
199
|
+
noResultsImage.horizontalAlignment = 'center';
|
|
200
|
+
return noResultsImage;
|
|
201
|
+
}
|
|
202
|
+
createProOnlyCard(options) {
|
|
203
|
+
const proOnlyImage = new ui_extensions_core_1.Image();
|
|
204
|
+
proOnlyImage.pixelWidth = 200;
|
|
205
|
+
proOnlyImage.url = this.createThemeBasedUrl(constants_1.PRO_ONLY_IMAGE);
|
|
206
|
+
proOnlyImage.horizontalAlignment = 'center';
|
|
207
|
+
return ui_extensions_core_1.TodoistCard.fromWithItems({
|
|
208
|
+
items: [
|
|
209
|
+
proOnlyImage,
|
|
210
|
+
ui_extensions_core_1.TextBlock.from({
|
|
211
|
+
text: this.translationService.getTranslation(constants_1.Core.CANNOT_ACCESS_EXTENSION),
|
|
212
|
+
horizontalAlignment: 'center',
|
|
213
|
+
}),
|
|
214
|
+
this.createTextWithLearnMore({
|
|
215
|
+
textKey: constants_1.Core.PRO_USERS_ONLY,
|
|
216
|
+
learnMoreUrl: options.learnMoreUrl,
|
|
217
|
+
spacing: 'small',
|
|
218
|
+
horizontalAlignment: 'center',
|
|
219
|
+
}),
|
|
220
|
+
ui_extensions_core_1.Container.from({ minHeight: 12 }),
|
|
221
|
+
this.createConfirmAndCancelActions({
|
|
222
|
+
confirmationButtonKey: constants_1.Core.UPGRADE_TO_PRO,
|
|
223
|
+
confirmationButtonActionUrl: (0, integrations_common_1.formatString)(constants_1.Core.PRICING_URL, options.product),
|
|
224
|
+
}),
|
|
225
|
+
],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
createConfirmAndCancelActions(options) {
|
|
229
|
+
var _a, _b, _c, _d;
|
|
230
|
+
const confirmActionProps = {
|
|
231
|
+
id: (_a = options.confirmationButtonId) !== null && _a !== void 0 ? _a : constants_1.CardActions.Confirm,
|
|
232
|
+
title: this.translationService.getTranslation((_b = options.confirmationButtonKey) !== null && _b !== void 0 ? _b : constants_1.Core.CONFIRM),
|
|
233
|
+
style: 'positive',
|
|
234
|
+
};
|
|
235
|
+
return (0, ui_1.pageActions)(ui_extensions_core_1.ActionSet.fromWithActions({
|
|
236
|
+
actions: [
|
|
237
|
+
ui_extensions_core_1.SubmitAction.from({
|
|
238
|
+
id: (_c = options.cancelButtonId) !== null && _c !== void 0 ? _c : constants_1.CardActions.Close,
|
|
239
|
+
title: this.translationService.getTranslation((_d = options.cancelButtonKey) !== null && _d !== void 0 ? _d : constants_1.Core.CANCEL),
|
|
240
|
+
}),
|
|
241
|
+
options.confirmationButtonActionUrl
|
|
242
|
+
? ui_extensions_core_1.OpenUrlAction.from({
|
|
243
|
+
...confirmActionProps,
|
|
244
|
+
url: options.confirmationButtonActionUrl,
|
|
245
|
+
})
|
|
246
|
+
: ui_extensions_core_1.SubmitAction.from(confirmActionProps),
|
|
247
|
+
],
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
createWarningMessage(textKey) {
|
|
251
|
+
return ui_extensions_core_1.ColumnSet.fromWithColumns({
|
|
252
|
+
columns: [
|
|
253
|
+
ui_extensions_core_1.Column.fromWithItems({
|
|
254
|
+
width: 'auto',
|
|
255
|
+
items: [
|
|
256
|
+
ui_extensions_core_1.Image.from({
|
|
257
|
+
url: (0, utils_1.createStaticUrl)('icons/shared/warning-icon.svg'),
|
|
258
|
+
width: '24px',
|
|
259
|
+
aspectRatio: 1,
|
|
260
|
+
}),
|
|
261
|
+
],
|
|
262
|
+
}),
|
|
263
|
+
ui_extensions_core_1.Column.fromWithItems({
|
|
264
|
+
width: 'auto',
|
|
265
|
+
items: [
|
|
266
|
+
ui_extensions_core_1.TextBlock.from({
|
|
267
|
+
text: this.translationService.getTranslation(textKey),
|
|
268
|
+
color: 'attention',
|
|
269
|
+
size: 'small',
|
|
270
|
+
wrap: true,
|
|
271
|
+
}),
|
|
272
|
+
],
|
|
273
|
+
}),
|
|
274
|
+
],
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
exports.AdaptiveCardService = AdaptiveCardService;
|
|
279
|
+
exports.AdaptiveCardService = AdaptiveCardService = __decorate([
|
|
280
|
+
(0, common_1.Injectable)(),
|
|
281
|
+
__metadata("design:paramtypes", [translation_service_1.TranslationService,
|
|
282
|
+
theme_service_1.ThemeService])
|
|
283
|
+
], AdaptiveCardService);
|
|
284
|
+
//# sourceMappingURL=adaptive-card.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptive-card.service.js","sourceRoot":"","sources":["../../src/services/adaptive-card.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,sEAA2D;AAC3D,oEAoBoC;AAEpC,4CAOqB;AACrB,oCAA4D;AAE5D,8BAA2E;AAC3E,oCAA0C;AAC1C,mDAA8C;AAC9C,+DAA0D;AAI7C,QAAA,gBAAgB,GAAG,cAAc,CAAA;AAsCvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,YACa,kBAAsC,EACtC,YAA0B;QAD1B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,iBAAY,GAAZ,YAAY,CAAc;IACpC,CAAC;IAEJ,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,yBAAa,CAAC,CAAA;IAC9C,CAAC;IAED,eAAe,CAAC,IAAY;QACxB,OAAO,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,mBAAmB,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAC5D,CAAC;IAED,eAAe;QACX,MAAM,SAAS,GAAG,IAAI,gCAAW,EAAE,CAAA;QACnC,SAAS,CAAC,kBAAkB,GAAG,KAAK,CAAA;QAEpC,OAAO,SAAS,CAAA;IACpB,CAAC;IAWD,YAAY,CACR,eAA8B,EAC9B,iBAAgC,EAChC,gBAA+B,EAC/B,mBAAmB,GAAG,IAAI;QAE1B,OAAO,IAAA,iCAAY,EAAC;YAChB,eAAe;YACf,iBAAiB;YACjB,gBAAgB;YAChB,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;SAC7E,CAAC,CAAA;IACN,CAAC;IAED,mBAAmB,CAAC,KAAoB;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,E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BAAoB,CAAC,OAAe;QAChC,OAAO,8BAAS,CAAC,eAAe,CAAC;YAC7B,OAAO,EAAE;gBACL,2BAAM,CAAC,aAAa,CAAC;oBACjB,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE;wBACH,0BAAK,CAAC,IAAI,CAAC;4BACP,GAAG,EAAE,IAAA,uBAAe,EAAC,+BAA+B,CAAC;4BACrD,KAAK,EAAE,MAAM;4BACb,WAAW,EAAE,CAAC;yBACjB,CAAC;qBACL;iBACJ,CAAC;gBACF,2BAAM,CAAC,aAAa,CAAC;oBACjB,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE;wBACH,8BAAS,CAAC,IAAI,CAAC;4BACX,IAAI,EAAE,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,CAAC;4BACrD,KAAK,EAAE,WAAW;4BAClB,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,IAAI;yBACb,CAAC;qBACL;iBACJ,CAAC;aACL;SACJ,CAAC,CAAA;IACN,CAAC;CACJ,CAAA;AA/VY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAGwB,wCAAkB;QACxB,4BAAY;GAH9B,mBAAmB,CA+V/B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnalyticsEvent } from '@todoist/integrations-common';
|
|
2
|
+
export declare class AnalyticsError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare abstract class AnalyticsService {
|
|
5
|
+
abstract setUserId(userId: number): void;
|
|
6
|
+
abstract trackEvents(events: AnalyticsEvent[]): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AnalyticsService = exports.AnalyticsError = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
class AnalyticsError extends Error {
|
|
12
|
+
}
|
|
13
|
+
exports.AnalyticsError = AnalyticsError;
|
|
14
|
+
let AnalyticsService = class AnalyticsService {
|
|
15
|
+
};
|
|
16
|
+
exports.AnalyticsService = AnalyticsService;
|
|
17
|
+
exports.AnalyticsService = AnalyticsService = __decorate([
|
|
18
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.REQUEST })
|
|
19
|
+
], AnalyticsService);
|
|
20
|
+
//# sourceMappingURL=analytics.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.service.js","sourceRoot":"","sources":["../../src/services/analytics.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkD;AAGlD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C;AAGrC,IAAe,gBAAgB,GAA/B,MAAe,gBAAgB;CAGrC,CAAA;AAHqB,4CAAgB;2BAAhB,gBAAgB;IADrC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;GACf,gBAAgB,CAGrC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
14
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
15
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
16
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
17
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
18
|
+
};
|
|
19
|
+
var _AppTokenService_appToken;
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AppTokenService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const exceptions_1 = require("../exceptions");
|
|
24
|
+
let AppTokenService = class AppTokenService {
|
|
25
|
+
constructor() {
|
|
26
|
+
_AppTokenService_appToken.set(this, void 0);
|
|
27
|
+
}
|
|
28
|
+
get appToken() {
|
|
29
|
+
if (!__classPrivateFieldGet(this, _AppTokenService_appToken, "f")) {
|
|
30
|
+
throw new exceptions_1.IntegrationException({
|
|
31
|
+
error: new common_1.UnauthorizedException('Missing authentication token'),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return __classPrivateFieldGet(this, _AppTokenService_appToken, "f");
|
|
35
|
+
}
|
|
36
|
+
set appToken(appToken) {
|
|
37
|
+
__classPrivateFieldSet(this, _AppTokenService_appToken, appToken, "f");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.AppTokenService = AppTokenService;
|
|
41
|
+
_AppTokenService_appToken = new WeakMap();
|
|
42
|
+
exports.AppTokenService = AppTokenService = __decorate([
|
|
43
|
+
(0, common_1.Injectable)({
|
|
44
|
+
scope: common_1.Scope.REQUEST,
|
|
45
|
+
})
|
|
46
|
+
], AppTokenService);
|
|
47
|
+
//# sourceMappingURL=app-token.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-token.service.js","sourceRoot":"","sources":["../../src/services/app-token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AAEzE,8CAAoD;AAc7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QACH,4CAAmC;IAmBvC,CAAC;IAZG,IAAI,QAAQ;QACR,IAAI,CAAC,uBAAA,IAAI,iCAAU,EAAE,CAAC;YAClB,MAAM,IAAI,iCAAoB,CAAC;gBAC3B,KAAK,EAAE,IAAI,8BAAqB,CAAC,8BAA8B,CAAC;aACnE,CAAC,CAAA;QACN,CAAC;QACD,OAAO,uBAAA,IAAI,iCAAU,CAAA;IACzB,CAAC;IAED,IAAI,QAAQ,CAAC,QAAkC;QAC3C,uBAAA,IAAI,6BAAa,QAAQ,MAAA,CAAA;IAC7B,CAAC;CACJ,CAAA;AApBY,0CAAe;;0BAAf,eAAe;IAH3B,IAAA,mBAAU,EAAC;QACR,KAAK,EAAE,cAAK,CAAC,OAAO;KACvB,CAAC;GACW,eAAe,CAoB3B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { User } from '../entities';
|
|
2
|
+
import type { StateService } from './state.service';
|
|
3
|
+
import type { UserDatabaseService } from './user-database.service';
|
|
4
|
+
export type GrantType = 'refresh_token' | 'authorization_code';
|
|
5
|
+
export type AccessTokenData = {
|
|
6
|
+
accessToken: string;
|
|
7
|
+
refreshToken?: string;
|
|
8
|
+
expiresAt?: Date;
|
|
9
|
+
};
|
|
10
|
+
export type AuthenticatedUser = {
|
|
11
|
+
id: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
};
|
|
15
|
+
export type AuthData = {
|
|
16
|
+
redirect_uri?: string;
|
|
17
|
+
code?: string;
|
|
18
|
+
grant_type: GrantType;
|
|
19
|
+
refresh_token?: string;
|
|
20
|
+
};
|
|
21
|
+
type TokenRefreshData = {
|
|
22
|
+
token: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
};
|
|
25
|
+
export declare abstract class AuthenticationClient {
|
|
26
|
+
private readonly clientId;
|
|
27
|
+
protected readonly stateService: StateService;
|
|
28
|
+
protected readonly userDatabaseService: UserDatabaseService<User>;
|
|
29
|
+
static AUTH_PATH: string;
|
|
30
|
+
private readonly path;
|
|
31
|
+
constructor(clientId: string, stateService: StateService, userDatabaseService: UserDatabaseService<User>);
|
|
32
|
+
abstract getAuthorizationUrl(userId: number): Promise<string>;
|
|
33
|
+
abstract getAuthenticatedUser(authToken: string): Promise<AuthenticatedUser>;
|
|
34
|
+
exchangeToken(code: string): Promise<AccessTokenData>;
|
|
35
|
+
refreshToken(refreshToken: string): Promise<AccessTokenData | undefined>;
|
|
36
|
+
protected authenticate(_data: AuthData): Promise<AccessTokenData>;
|
|
37
|
+
protected createAuthorizationUrl(userId: number, authorizationUrl: string, scope?: string): Promise<string>;
|
|
38
|
+
protected createRedirectUrl(): string;
|
|
39
|
+
getCurrentOrRefreshedToken(userId: number): Promise<TokenRefreshData | undefined>;
|
|
40
|
+
shouldVerifyUserIdMatch(): boolean;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthenticationClient = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const node_1 = require("@sentry/node");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
class AuthenticationClient {
|
|
17
|
+
constructor(clientId, stateService, userDatabaseService) {
|
|
18
|
+
this.clientId = clientId;
|
|
19
|
+
this.stateService = stateService;
|
|
20
|
+
this.userDatabaseService = userDatabaseService;
|
|
21
|
+
this.path = 'auth';
|
|
22
|
+
}
|
|
23
|
+
exchangeToken(code) {
|
|
24
|
+
const data = {
|
|
25
|
+
grant_type: 'authorization_code',
|
|
26
|
+
code,
|
|
27
|
+
redirect_uri: this.createRedirectUrl(),
|
|
28
|
+
};
|
|
29
|
+
return this.authenticate(data);
|
|
30
|
+
}
|
|
31
|
+
refreshToken(refreshToken) {
|
|
32
|
+
const data = {
|
|
33
|
+
grant_type: 'refresh_token',
|
|
34
|
+
refresh_token: refreshToken,
|
|
35
|
+
};
|
|
36
|
+
return this.authenticate(data);
|
|
37
|
+
}
|
|
38
|
+
authenticate(_data) {
|
|
39
|
+
throw new Error('Method not implemented.');
|
|
40
|
+
}
|
|
41
|
+
async createAuthorizationUrl(userId, authorizationUrl, scope) {
|
|
42
|
+
const authUrl = new URL(authorizationUrl);
|
|
43
|
+
const params = new URLSearchParams(authUrl.search);
|
|
44
|
+
const user = await this.userDatabaseService.getUser(userId);
|
|
45
|
+
const externalUserId = user === null || user === void 0 ? void 0 : user.externalUserId;
|
|
46
|
+
params.set('response_type', 'code');
|
|
47
|
+
params.set('redirect_uri', this.createRedirectUrl());
|
|
48
|
+
params.set('client_id', this.clientId);
|
|
49
|
+
params.set('state', await this.stateService.createState(userId, externalUserId));
|
|
50
|
+
if (scope) {
|
|
51
|
+
params.set('scope', scope);
|
|
52
|
+
}
|
|
53
|
+
authUrl.search = params.toString();
|
|
54
|
+
return Promise.resolve(authUrl.toString());
|
|
55
|
+
}
|
|
56
|
+
createRedirectUrl() {
|
|
57
|
+
const redirectUrl = new URL(this.path, (0, utils_1.getIntegrationBaseUrl)());
|
|
58
|
+
return redirectUrl.toString();
|
|
59
|
+
}
|
|
60
|
+
async getCurrentOrRefreshedToken(userId) {
|
|
61
|
+
const currentData = await this.userDatabaseService.getUser(userId);
|
|
62
|
+
if (!(currentData === null || currentData === void 0 ? void 0 : currentData.authToken)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!(0, utils_1.hasAuthTokenExpired)(currentData.tokenExpiresAt)) {
|
|
66
|
+
return { token: currentData.authToken, userId: currentData.externalUserId };
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
if (!currentData.refreshToken) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const refreshedData = await this.refreshToken(currentData.refreshToken);
|
|
73
|
+
if (!refreshedData) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
await this.userDatabaseService.setToken(userId, { tokenData: refreshedData });
|
|
77
|
+
return { token: refreshedData.accessToken, userId: currentData.externalUserId };
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
(0, node_1.captureException)(error);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
shouldVerifyUserIdMatch() {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.AuthenticationClient = AuthenticationClient;
|
|
89
|
+
AuthenticationClient.AUTH_PATH = 'AuthenticationClient.PATH';
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, common_1.Optional)(),
|
|
92
|
+
(0, common_1.Inject)(AuthenticationClient.AUTH_PATH),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], AuthenticationClient.prototype, "path", void 0);
|
|
95
|
+
//# sourceMappingURL=authentication-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-client.js","sourceRoot":"","sources":["../../src/services/authentication-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,uCAA+C;AAE/C,oCAAqE;AA8BrE,MAAsB,oBAAoB;IAKtC,YACqB,QAAgB,EACd,YAA0B,EAC1B,mBAA8C;QAFhD,aAAQ,GAAR,QAAQ,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAAc;QAC1B,wBAAmB,GAAnB,mBAAmB,CAA2B;QALA,SAAI,GAAG,MAAM,CAAA;IAM/E,CAAC;IAMJ,aAAa,CAAC,IAAY;QACtB,MAAM,IAAI,GAAa;YACnB,UAAU,EAAE,oBAAoB;YAChC,IAAI;YACJ,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE;SACzC,CAAA;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,YAAY,CAAC,YAAoB;QAC7B,MAAM,IAAI,GAAa;YACnB,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,YAAY;SAC9B,CAAA;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAES,YAAY,CAAC,KAAe;QAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC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OAAO,CAAC,MAAM,CAAC,CAAA;QAClE,IAAI,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,CAAA,EAAE,CAAC;YAC1B,OAAM;QACV,CAAC;QAED,IAAI,CAAC,IAAA,2BAAmB,EAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;YACnD,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,cAAc,EAAE,CAAA;QAC/E,CAAC;QAED,IAAI,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC5B,OAAM;YACV,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;YACvE,IAAI,CAAC,aAAa,EAAE,CAAC;gBACjB,OAAM;YACV,CAAC;YACD,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAA;YAE7E,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,cAAc,EAAE,CAAA;QACnF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,IAAA,uBAAgB,EAAC,KAAK,CAAC,CAAA;YAEvB,OAAO,SAAS,CAAA;QACpB,CAAC;IACL,CAAC;IAYD,uBAAuB;QACnB,OAAO,KAAK,CAAA;IAChB,CAAC;;AA/GL,oDAgHC;AA/GU,8BAAS,GAAG,2BAA2B,AAA9B,CAA8B;AAEuB;IAApE,IAAA,iBAAQ,GAAE;IAAE,IAAA,eAAM,EAAC,oBAAoB,CAAC,SAAS,CAAC;;kDAA+B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare abstract class ComposerAppendConfigurationService {
|
|
2
|
+
abstract getSignatureText(): string;
|
|
3
|
+
abstract canAddSignature(userId: number): Promise<boolean>;
|
|
4
|
+
}
|
|
5
|
+
export declare class ComposerAppendFormattingService {
|
|
6
|
+
private readonly configuration;
|
|
7
|
+
constructor(configuration: ComposerAppendConfigurationService);
|
|
8
|
+
formatForAppend(message: string, userId?: number): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ComposerAppendFormattingService = exports.ComposerAppendConfigurationService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
class ComposerAppendConfigurationService {
|
|
15
|
+
}
|
|
16
|
+
exports.ComposerAppendConfigurationService = ComposerAppendConfigurationService;
|
|
17
|
+
let ComposerAppendFormattingService = class ComposerAppendFormattingService {
|
|
18
|
+
constructor(configuration) {
|
|
19
|
+
this.configuration = configuration;
|
|
20
|
+
}
|
|
21
|
+
async formatForAppend(message, userId) {
|
|
22
|
+
const canAddSignature = userId
|
|
23
|
+
? await this.configuration.canAddSignature(userId)
|
|
24
|
+
: undefined;
|
|
25
|
+
if (!canAddSignature) {
|
|
26
|
+
return message;
|
|
27
|
+
}
|
|
28
|
+
const signature = this.configuration.getSignatureText();
|
|
29
|
+
return `${message}\n\n${signature}`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.ComposerAppendFormattingService = ComposerAppendFormattingService;
|
|
33
|
+
exports.ComposerAppendFormattingService = ComposerAppendFormattingService = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__metadata("design:paramtypes", [ComposerAppendConfigurationService])
|
|
36
|
+
], ComposerAppendFormattingService);
|
|
37
|
+
//# sourceMappingURL=composer-append-formatting.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer-append-formatting.service.js","sourceRoot":"","sources":["../../src/services/composer-append-formatting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAE3C,MAAsB,kCAAkC;CAGvD;AAHD,gFAGC;AAGM,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IACxC,YAA6B,aAAiD;QAAjD,kBAAa,GAAb,aAAa,CAAoC;IAAG,CAAC;IAElF,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,MAAe;QAClD,MAAM,eAAe,GAAG,MAAM;YAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC;YAClD,CAAC,CAAC,SAAS,CAAA;QAEf,IAAI,CAAC,eAAe,EAAE,CAAC;YACnB,OAAO,OAAO,CAAA;QAClB,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAA;QAEvD,OAAO,GAAG,OAAO,OAAO,SAAS,EAAE,CAAA;IACvC,CAAC;CACJ,CAAA;AAhBY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;qCAEmC,kCAAkC;GADrE,+BAA+B,CAgB3C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChoiceSetInput } from '@todoist/ui-extensions-core';
|
|
2
|
+
import { TranslationService } from './translation.service';
|
|
3
|
+
export declare class ComposerAppendSettingsService {
|
|
4
|
+
private readonly translationService;
|
|
5
|
+
constructor(translationService: TranslationService);
|
|
6
|
+
createSignatureToggleChoiceSetInput(id: string, signatureEnabled?: boolean): ChoiceSetInput;
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ComposerAppendSettingsService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const ui_extensions_core_1 = require("@todoist/ui-extensions-core");
|
|
15
|
+
const core_strings_1 = require("../constants/core-strings");
|
|
16
|
+
const translation_service_1 = require("./translation.service");
|
|
17
|
+
let ComposerAppendSettingsService = class ComposerAppendSettingsService {
|
|
18
|
+
constructor(translationService) {
|
|
19
|
+
this.translationService = translationService;
|
|
20
|
+
}
|
|
21
|
+
createSignatureToggleChoiceSetInput(id, signatureEnabled) {
|
|
22
|
+
const signatureChoicesInput = new ui_extensions_core_1.ChoiceSetInput();
|
|
23
|
+
signatureChoicesInput.id = id;
|
|
24
|
+
signatureChoicesInput.label = this.translationService.getTranslation(core_strings_1.Core.SIGNATURE_TITLE);
|
|
25
|
+
const signatureOnChoice = new ui_extensions_core_1.Choice(this.translationService.getTranslation(core_strings_1.Core.SIGNATURE_ON), true.toString());
|
|
26
|
+
const signatureOffChoice = new ui_extensions_core_1.Choice(this.translationService.getTranslation(core_strings_1.Core.SIGNATURE_OFF), false.toString());
|
|
27
|
+
signatureChoicesInput.choices = [signatureOnChoice, signatureOffChoice];
|
|
28
|
+
signatureChoicesInput.defaultValue =
|
|
29
|
+
(signatureEnabled !== null && signatureEnabled !== void 0 ? signatureEnabled : true) ? signatureOnChoice.value : signatureOffChoice.value;
|
|
30
|
+
signatureChoicesInput.spacing = 'medium';
|
|
31
|
+
return signatureChoicesInput;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.ComposerAppendSettingsService = ComposerAppendSettingsService;
|
|
35
|
+
exports.ComposerAppendSettingsService = ComposerAppendSettingsService = __decorate([
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
|
+
__metadata("design:paramtypes", [translation_service_1.TranslationService])
|
|
38
|
+
], ComposerAppendSettingsService);
|
|
39
|
+
//# sourceMappingURL=composer-append-settings.service.js.map
|