@slack/bolt 3.12.1 → 4.0.0-nextGen.3
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/dist/App.d.ts +35 -6
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +132 -45
- package/dist/App.js.map +1 -1
- package/dist/Manifest.d.ts +5 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Manifest.js +16 -0
- package/dist/Manifest.js.map +1 -0
- package/dist/SlackFunction.d.ts +181 -0
- package/dist/SlackFunction.d.ts.map +1 -0
- package/dist/SlackFunction.js +418 -0
- package/dist/SlackFunction.js.map +1 -0
- package/dist/Subscription.d.ts +61 -0
- package/dist/Subscription.d.ts.map +1 -0
- package/dist/Subscription.js +169 -0
- package/dist/Subscription.js.map +1 -0
- package/dist/cli/get-hooks.d.ts +2 -0
- package/dist/cli/get-hooks.d.ts.map +1 -0
- package/dist/cli/get-hooks.js +18 -0
- package/dist/cli/get-hooks.js.map +1 -0
- package/dist/cli/get-manifest.d.ts +3 -0
- package/dist/cli/get-manifest.d.ts.map +1 -0
- package/dist/cli/get-manifest.js +16 -0
- package/dist/cli/get-manifest.js.map +1 -0
- package/dist/cli/hook-utils/manifest.d.ts +7 -0
- package/dist/cli/hook-utils/manifest.d.ts.map +1 -0
- package/dist/cli/hook-utils/manifest.js +104 -0
- package/dist/cli/hook-utils/manifest.js.map +1 -0
- package/dist/cli/hook-utils/manifest.spec.d.ts +2 -0
- package/dist/cli/hook-utils/manifest.spec.d.ts.map +1 -0
- package/dist/cli/hook-utils/manifest.spec.js +75 -0
- package/dist/cli/hook-utils/manifest.spec.js.map +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +37 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/start.d.ts +3 -0
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/start.js +40 -0
- package/dist/cli/start.js.map +1 -0
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +25 -1
- package/dist/errors.js.map +1 -1
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +8 -0
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware/builtin.d.ts.map +1 -1
- package/dist/middleware/builtin.js +0 -1
- package/dist/middleware/builtin.js.map +1 -1
- package/dist/middleware/process.d.ts.map +1 -1
- package/dist/middleware/process.js.map +1 -1
- package/dist/receivers/ExpressReceiver.d.ts +1 -1
- package/dist/receivers/ExpressReceiver.js +2 -1
- package/dist/receivers/ExpressReceiver.js.map +1 -1
- package/dist/receivers/HTTPModuleFunctions.js +1 -1
- package/dist/receivers/HTTPReceiver.js +4 -4
- package/dist/receivers/HTTPReceiver.js.map +1 -1
- package/dist/receivers/SocketModeFunctions.js +2 -1
- package/dist/receivers/SocketModeFunctions.js.map +1 -1
- package/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/dist/receivers/verify-request.d.ts +2 -2
- package/dist/receivers/verify-request.js +3 -3
- package/dist/types/actions/block-action.d.ts +4 -3
- package/dist/types/actions/block-action.d.ts.map +1 -1
- package/dist/types/actions/dialog-action.d.ts +4 -0
- package/dist/types/actions/dialog-action.d.ts.map +1 -1
- package/dist/types/events/base-events.d.ts +30 -1
- package/dist/types/events/base-events.d.ts.map +1 -1
- package/dist/types/events/base-events.js.map +1 -1
- package/dist/types/functions/index.d.ts +26 -0
- package/dist/types/functions/index.d.ts.map +1 -0
- package/dist/types/functions/index.js +3 -0
- package/dist/types/functions/index.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/middleware.d.ts +17 -1
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/middleware.js.map +1 -1
- package/dist/types/subscription/index.d.ts +80 -0
- package/dist/types/subscription/index.d.ts.map +1 -0
- package/dist/types/subscription/index.js +3 -0
- package/dist/types/subscription/index.js.map +1 -0
- package/dist/types/view/index.d.ts +6 -5
- package/dist/types/view/index.d.ts.map +1 -1
- package/package.json +16 -5
- package/src/cli/get-hooks.js +16 -0
- package/src/cli/get-manifest.js +16 -0
- package/src/cli/hook-utils/manifest.js +114 -0
- package/src/cli/start.js +43 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Middleware, AnyMiddlewareArgs, AllMiddlewareArgs } from './types';
|
|
2
|
+
import { SubscriptionOnCreateMiddleware, SubscriptionOnConfigureMiddleware, SubscriptionOnDeletedMiddleware, SlackSubscriptionMiddlewareArgs, SubConfigureFn } from './types/subscription';
|
|
3
|
+
export interface SubscriptionOptions {
|
|
4
|
+
onCreate: SubscriptionOnCreateMiddleware | SubscriptionOnCreateMiddleware[];
|
|
5
|
+
onConfigure: SubscriptionOnConfigureMiddleware | SubscriptionOnConfigureMiddleware[];
|
|
6
|
+
onDeleted?: SubscriptionOnDeletedMiddleware | SubscriptionOnDeletedMiddleware[];
|
|
7
|
+
}
|
|
8
|
+
declare type AllSubscriptionMiddlewareArgs<T extends SlackSubscriptionMiddlewareArgs = SlackSubscriptionMiddlewareArgs> = T & AllMiddlewareArgs;
|
|
9
|
+
export declare type SubscriptionMiddleware = SubscriptionOnCreateMiddleware[] | SubscriptionOnConfigureMiddleware[] | SubscriptionOnDeletedMiddleware[] | [];
|
|
10
|
+
export declare const VALID_NOTIFICATION_SUBSCRIPTION_INTERACTION_TYPES: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Subscription describes a collection of named middlewares
|
|
13
|
+
* for handling notification subscription related interaction
|
|
14
|
+
* payloads.
|
|
15
|
+
* */
|
|
16
|
+
export declare class Subscription {
|
|
17
|
+
/**
|
|
18
|
+
* @description The unique resource id for this Subscription.
|
|
19
|
+
* */
|
|
20
|
+
private id;
|
|
21
|
+
/** Middleware to process :: 'notification_subscription_create_requested'
|
|
22
|
+
* interaction payload
|
|
23
|
+
* */
|
|
24
|
+
private onCreate;
|
|
25
|
+
/** Middleware to process :: 'notification_subscription_configure_requested'
|
|
26
|
+
* interaction payload
|
|
27
|
+
* */
|
|
28
|
+
private onConfigure;
|
|
29
|
+
/** Middleware to process :: 'notification_subscription_deleted' interaction
|
|
30
|
+
* payload
|
|
31
|
+
* */
|
|
32
|
+
private onDeleted;
|
|
33
|
+
constructor(id: string, options: SubscriptionOptions);
|
|
34
|
+
getMiddleware(): Middleware<AnyMiddlewareArgs>;
|
|
35
|
+
/**
|
|
36
|
+
* `matchesConstraints()` implements any required constraints
|
|
37
|
+
* on notification subscription interaction payloads.
|
|
38
|
+
* */
|
|
39
|
+
private matchesConstraints;
|
|
40
|
+
private process;
|
|
41
|
+
private getSubMiddleware;
|
|
42
|
+
}
|
|
43
|
+
export declare function validate(id: string, options: SubscriptionOptions): void;
|
|
44
|
+
export declare function isSubscriptionInteraction(args: AnyMiddlewareArgs): args is AllSubscriptionMiddlewareArgs;
|
|
45
|
+
/**
|
|
46
|
+
* `processSubMiddleware()` processes subscription interaction payload with the
|
|
47
|
+
* middleware supplied by the user.
|
|
48
|
+
* */
|
|
49
|
+
export declare function processSubMiddleware(args: AllSubscriptionMiddlewareArgs, origMiddleware: SubscriptionMiddleware): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* `prepareSubArgs()` prepares the arguments for the specific middlewares
|
|
52
|
+
* adding specific arguments for utilities
|
|
53
|
+
* */
|
|
54
|
+
export declare function prepareSubArgs(args: AllMiddlewareArgs): AllSubscriptionMiddlewareArgs;
|
|
55
|
+
/**
|
|
56
|
+
* Utility which returns a fxn which can be used to
|
|
57
|
+
* open a configure view for configuring a Slack subscription
|
|
58
|
+
* */
|
|
59
|
+
export declare function createConfigure(args: any): SubConfigureFn;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=Subscription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,IAAI,CAkCvE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,IAAI,6BAA6B,CAGxG;AAED;;;KAGK;AACL,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,6BAA6B,EACnC,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,IAAI,CAAC,CAiBf;AACD;;;KAGK;AACL,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,6BAA6B,CAcrF;AAED;;;KAGK;AACL,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,cAAc,CAUzD"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConfigure = exports.prepareSubArgs = exports.processSubMiddleware = exports.isSubscriptionInteraction = exports.validate = exports.Subscription = exports.VALID_NOTIFICATION_SUBSCRIPTION_INTERACTION_TYPES = void 0;
|
|
4
|
+
/* Constants */
|
|
5
|
+
exports.VALID_NOTIFICATION_SUBSCRIPTION_INTERACTION_TYPES = [
|
|
6
|
+
'notification_subscription_create_requested',
|
|
7
|
+
'notification_subscription_configure_requested',
|
|
8
|
+
'notification_subscription_deleted',
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Subscription describes a collection of named middlewares
|
|
12
|
+
* for handling notification subscription related interaction
|
|
13
|
+
* payloads.
|
|
14
|
+
* */
|
|
15
|
+
class Subscription {
|
|
16
|
+
constructor(id, options) {
|
|
17
|
+
/** Middleware to process :: 'notification_subscription_deleted' interaction
|
|
18
|
+
* payload
|
|
19
|
+
* */
|
|
20
|
+
this.onDeleted = [];
|
|
21
|
+
this.process = async (args) => {
|
|
22
|
+
const { payload } = args;
|
|
23
|
+
const subArgs = prepareSubArgs(args);
|
|
24
|
+
const subMiddleware = this.getSubMiddleware(payload);
|
|
25
|
+
return processSubMiddleware(subArgs, subMiddleware);
|
|
26
|
+
};
|
|
27
|
+
this.getSubMiddleware = (payload) => {
|
|
28
|
+
switch (payload.type) {
|
|
29
|
+
case 'notification_subscription_create_requested':
|
|
30
|
+
return this.onCreate;
|
|
31
|
+
case 'notification_subscription_configure_requested':
|
|
32
|
+
return this.onConfigure;
|
|
33
|
+
case 'notification_subscription_deleted':
|
|
34
|
+
return this.onDeleted;
|
|
35
|
+
default:
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
validate(id, options);
|
|
40
|
+
const { onCreate, onConfigure, onDeleted } = options;
|
|
41
|
+
this.id = id;
|
|
42
|
+
this.onCreate = Array.isArray(onCreate) ? onCreate : [onCreate];
|
|
43
|
+
this.onConfigure = Array.isArray(onConfigure) ? onConfigure : [onConfigure];
|
|
44
|
+
if (onDeleted !== undefined) {
|
|
45
|
+
this.onDeleted = Array.isArray(onDeleted) ? onDeleted : [onDeleted];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/* Utilities */
|
|
49
|
+
getMiddleware() {
|
|
50
|
+
return async (args) => {
|
|
51
|
+
if (isSubscriptionInteraction(args) && this.matchesConstraints(args)) {
|
|
52
|
+
return this.process(args);
|
|
53
|
+
}
|
|
54
|
+
return args.next();
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* `matchesConstraints()` implements any required constraints
|
|
59
|
+
* on notification subscription interaction payloads.
|
|
60
|
+
* */
|
|
61
|
+
matchesConstraints(args) {
|
|
62
|
+
// TODO :: implement constraint matching against custom action_id
|
|
63
|
+
// when supported
|
|
64
|
+
// If a custom action_id is provided, it should match the id of the Subscription
|
|
65
|
+
// in order for proper middlewares to be invoked.
|
|
66
|
+
return typeof this.id === 'string' && typeof args.payload.action_id === 'string';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Subscription = Subscription;
|
|
70
|
+
/* Utilities */
|
|
71
|
+
function validate(id, options) {
|
|
72
|
+
// id must be a string
|
|
73
|
+
if (typeof id !== 'string') {
|
|
74
|
+
throw new Error('Subscription id must be a string');
|
|
75
|
+
}
|
|
76
|
+
// Check user has supplied minimal required middleware
|
|
77
|
+
const requiredKeys = ['onCreate', 'onConfigure'];
|
|
78
|
+
const missingKeys = requiredKeys.filter((key) => !(key in options));
|
|
79
|
+
if (missingKeys.length > 0) {
|
|
80
|
+
throw new Error(`Subscription handling options provided are missing required keys: ${missingKeys.join(', ')}`);
|
|
81
|
+
}
|
|
82
|
+
// Check user has supplied valid middleware
|
|
83
|
+
const currentKeys = Object.keys(options);
|
|
84
|
+
currentKeys.forEach((fnKey) => {
|
|
85
|
+
// must be non-falsy value
|
|
86
|
+
if (!options[fnKey]) {
|
|
87
|
+
throw new Error(`You must supply a middleware for ${fnKey}`);
|
|
88
|
+
}
|
|
89
|
+
// must be either a fn or array
|
|
90
|
+
if (typeof options[fnKey] !== 'function' && !Array.isArray(options[fnKey])) {
|
|
91
|
+
throw new Error(`Subscription handling option ${fnKey} must be a function or an array of functions`);
|
|
92
|
+
}
|
|
93
|
+
// arrays must contain middleware functions
|
|
94
|
+
if (Array.isArray(options[fnKey])) {
|
|
95
|
+
const array = options[fnKey];
|
|
96
|
+
array.forEach((middleware) => {
|
|
97
|
+
if (typeof middleware !== 'function') {
|
|
98
|
+
throw new Error('Subscription handling option(s) supplied as arrays must contain only functions');
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.validate = validate;
|
|
105
|
+
function isSubscriptionInteraction(args) {
|
|
106
|
+
return exports.VALID_NOTIFICATION_SUBSCRIPTION_INTERACTION_TYPES
|
|
107
|
+
.includes(args.payload.type);
|
|
108
|
+
}
|
|
109
|
+
exports.isSubscriptionInteraction = isSubscriptionInteraction;
|
|
110
|
+
/**
|
|
111
|
+
* `processSubMiddleware()` processes subscription interaction payload with the
|
|
112
|
+
* middleware supplied by the user.
|
|
113
|
+
* */
|
|
114
|
+
async function processSubMiddleware(args, origMiddleware) {
|
|
115
|
+
// Copy the array so modifications don't affect the original
|
|
116
|
+
const middlewares = [...origMiddleware];
|
|
117
|
+
// Don't process the last item in the array, it shouldn't get a next fn
|
|
118
|
+
let lastCalledMiddlewareIndex = -1;
|
|
119
|
+
// recursively call each middleware in array
|
|
120
|
+
const invokeMiddleware = async (toCallMiddlewareIndex) => {
|
|
121
|
+
if (lastCalledMiddlewareIndex < middlewares.length - 1) {
|
|
122
|
+
lastCalledMiddlewareIndex = toCallMiddlewareIndex;
|
|
123
|
+
// invoke middleware
|
|
124
|
+
await middlewares[toCallMiddlewareIndex]({
|
|
125
|
+
...args,
|
|
126
|
+
});
|
|
127
|
+
invokeMiddleware(toCallMiddlewareIndex + 1);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
invokeMiddleware(0);
|
|
131
|
+
}
|
|
132
|
+
exports.processSubMiddleware = processSubMiddleware;
|
|
133
|
+
/**
|
|
134
|
+
* `prepareSubArgs()` prepares the arguments for the specific middlewares
|
|
135
|
+
* adding specific arguments for utilities
|
|
136
|
+
* */
|
|
137
|
+
function prepareSubArgs(args) {
|
|
138
|
+
const { next: _next, ...subArgs } = args;
|
|
139
|
+
const preparedArgs = { ...subArgs };
|
|
140
|
+
switch (preparedArgs.payload.type) {
|
|
141
|
+
case 'notification_subscription_create_requested':
|
|
142
|
+
preparedArgs.configure = createConfigure(preparedArgs);
|
|
143
|
+
break;
|
|
144
|
+
case 'notification_subscription_configure_requested':
|
|
145
|
+
preparedArgs.configure = createConfigure(preparedArgs);
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
return preparedArgs;
|
|
151
|
+
}
|
|
152
|
+
exports.prepareSubArgs = prepareSubArgs;
|
|
153
|
+
/**
|
|
154
|
+
* Utility which returns a fxn which can be used to
|
|
155
|
+
* open a configure view for configuring a Slack subscription
|
|
156
|
+
* */
|
|
157
|
+
function createConfigure(args) {
|
|
158
|
+
const { payload } = args;
|
|
159
|
+
const trigger_id = payload.notification_subscription_action_trigger_id;
|
|
160
|
+
const { client, context } = args;
|
|
161
|
+
const token = context.botToken !== undefined ? context.botToken : context.userToken;
|
|
162
|
+
return (view) => client.views.open({
|
|
163
|
+
token,
|
|
164
|
+
trigger_id,
|
|
165
|
+
view,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
exports.createConfigure = createConfigure;
|
|
169
|
+
//# sourceMappingURL=Subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscription.js","sourceRoot":"","sources":["../src/Subscription.ts"],"names":[],"mappings":";;;AA+BA,eAAe;AACF,QAAA,iDAAiD,GAAG;IAC/D,4CAA4C;IAC5C,+CAA+C;IAC/C,mCAAmC;CACpC,CAAC;AACF;;;;KAIK;AACL,MAAa,YAAY;IAqBvB,YAAmB,EAAU,EAAE,OAA4B;QAL3D;;aAEK;QACG,cAAS,GAAsC,EAAE,CAAC;QAmClD,YAAO,GAAG,KAAK,EAAE,IAAmC,EAAiB,EAAE;YAC7E,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACzB,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACrD,OAAO,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACtD,CAAC,CAAC;QAEM,qBAAgB,GAAG,CAAC,OAAiD,EAA0B,EAAE;YACvG,QAAQ,OAAO,CAAC,IAAI,EAAE;gBACpB,KAAK,4CAA4C;oBAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC;gBACvB,KAAK,+CAA+C;oBAClD,OAAO,IAAI,CAAC,WAAW,CAAC;gBAC1B,KAAK,mCAAmC;oBACtC,OAAO,IAAI,CAAC,SAAS,CAAC;gBACxB;oBACE,OAAO,EAAE,CAAC;aACb;QACH,CAAC,CAAC;QAlDA,QAAQ,CAAC,EAA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OAAO,YAAY,CAAC;AACtB,CAAC;AAdD,wCAcC;AAED;;;KAGK;AACL,SAAgB,eAAe,CAAC,IAAS;IACvC,MAAM,EAAE,OAAO,EAAE,GAA8E,IAAI,CAAC;IACpG,MAAM,UAAU,GAAG,OAAO,CAAC,2CAA2C,CAAC;IACvE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IACpF,OAAO,CAAC,IAAU,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QACvC,KAAK;QACL,UAAU;QACV,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAVD,0CAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-hooks.d.ts","sourceRoot":"","sources":["../../src/cli/get-hooks.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
console.log(JSON.stringify({
|
|
4
|
+
hooks: {
|
|
5
|
+
'get-manifest': 'npx -q --no-install -p @slack/bolt slack-cli-get-manifest',
|
|
6
|
+
start: 'npx -q --no-install -p @slack/bolt slack-cli-start',
|
|
7
|
+
},
|
|
8
|
+
config: {
|
|
9
|
+
watch: {
|
|
10
|
+
'filter-regex': '^manifest\\.(ts|js|json)$',
|
|
11
|
+
paths: [
|
|
12
|
+
'.',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
'sdk-managed-connection-enabled': true,
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
//# sourceMappingURL=get-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-hooks.js","sourceRoot":"","sources":["../../src/cli/get-hooks.js"],"names":[],"mappings":";;AACA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;IACzB,KAAK,EAAE;QACL,cAAc,EAAE,2DAA2D;QAC3E,KAAK,EAAE,oDAAoD;KAC5D;IACD,MAAM,EAAE;QACN,KAAK,EAAE;YACL,cAAc,EAAE,2BAA2B;YAC3C,KAAK,EAAE;gBACL,GAAG;aACJ;SACF;QACD,gCAAgC,EAAE,IAAI;KACvC;CACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-manifest.d.ts","sourceRoot":"","sources":["../../src/cli/get-manifest.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const { getManifestData } = require('./hook-utils/manifest');
|
|
4
|
+
/**
|
|
5
|
+
* Implements the get-manifest script hook required by the Slack CLI
|
|
6
|
+
* Returns a manifest JSON string to stdout.
|
|
7
|
+
* Looks for a manifest.ts, .js and .json files. If multiple are found
|
|
8
|
+
* Then any manifest.ts (or missing that, manifest.js) defined
|
|
9
|
+
* properties will merge into any manifest.json
|
|
10
|
+
*/
|
|
11
|
+
(function _(cwd) {
|
|
12
|
+
let manifest = getManifestData(cwd);
|
|
13
|
+
// write manifest to stdout
|
|
14
|
+
console.log(JSON.stringify(manifest));
|
|
15
|
+
}(process.cwd()));
|
|
16
|
+
//# sourceMappingURL=get-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-manifest.js","sourceRoot":"","sources":["../../src/cli/get-manifest.js"],"names":[],"mappings":";;AACA,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAE7D;;;;;;EAME;AACF,CAAC,SAAS,CAAC,CAAC,GAAG;IACb,IAAI,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEpC,2BAA2B;IAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function getManifestData(searchDir: any): {};
|
|
2
|
+
export function unionMerge(array1: any, array2: any): any[];
|
|
3
|
+
export function readManifestJSONFile(searchDir: any, filename: any): any;
|
|
4
|
+
export function readImportedManifestFile(searchDir: any, filename: any): any;
|
|
5
|
+
export function hasManifest(...entries: any[]): boolean;
|
|
6
|
+
export function find(currentPath: any, targetFilename: any): any;
|
|
7
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.js"],"names":[],"mappings":"AAgFA,oDAwBC;AAnGD,4DAEC;AAGD,yEAWC;AAGD,6EAkBC;AAGD,wDAOC;AAOD,iEAmBC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const merge = require('deepmerge');
|
|
5
|
+
// helper array merge function
|
|
6
|
+
function unionMerge(array1, array2) {
|
|
7
|
+
return [...new Set(array1.concat(array2))];
|
|
8
|
+
}
|
|
9
|
+
// look for manifest.json in the current working directory
|
|
10
|
+
function readManifestJSONFile(searchDir, filename) {
|
|
11
|
+
let jsonFilePath, manifestJSON;
|
|
12
|
+
try {
|
|
13
|
+
jsonFilePath = find(searchDir, filename);
|
|
14
|
+
if (fs.existsSync(jsonFilePath)) {
|
|
15
|
+
manifestJSON = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8'));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
return manifestJSON;
|
|
22
|
+
}
|
|
23
|
+
// look for a manifest file in the current working directory
|
|
24
|
+
function readImportedManifestFile(searchDir, filename) {
|
|
25
|
+
let importedManifestFilePath, manifestImported;
|
|
26
|
+
try {
|
|
27
|
+
importedManifestFilePath = find(searchDir, filename);
|
|
28
|
+
if (fs.existsSync(importedManifestFilePath)) {
|
|
29
|
+
manifestImported = require(`${importedManifestFilePath}`);
|
|
30
|
+
// if a default key is provided, assumes default export contains manifest
|
|
31
|
+
if (manifestImported["default"]) {
|
|
32
|
+
manifestImported = manifestImported["default"];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.log(error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return manifestImported;
|
|
41
|
+
}
|
|
42
|
+
// true if any non empty manifest has been supplied
|
|
43
|
+
function hasManifest(...entries) {
|
|
44
|
+
for (let ent of entries) {
|
|
45
|
+
if (ent && (Object.keys(ent).length > 0)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// recursive search for provided path and return full path when filename is found
|
|
52
|
+
// TODO: Cache searched paths and check that they haven't been explored already
|
|
53
|
+
// This guards against rare edge case of a subdir in the file tree which is
|
|
54
|
+
// symlinked back to root or in such a way that creates a cycle. Can also implement
|
|
55
|
+
// max depth check.
|
|
56
|
+
function find(currentPath, targetFilename) {
|
|
57
|
+
if (currentPath.endsWith(`/${targetFilename}`)) {
|
|
58
|
+
return currentPath;
|
|
59
|
+
}
|
|
60
|
+
if (fs.existsSync(currentPath) && fs.lstatSync(currentPath).isDirectory()) {
|
|
61
|
+
let foundEntry;
|
|
62
|
+
let dirents = fs.readdirSync(currentPath);
|
|
63
|
+
for (let entry of dirents) {
|
|
64
|
+
if (entry !== 'node_modules') {
|
|
65
|
+
let newPath = path.resolve(currentPath, entry);
|
|
66
|
+
foundEntry = find(newPath, targetFilename);
|
|
67
|
+
if (foundEntry) {
|
|
68
|
+
return foundEntry;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getManifestData(searchDir) {
|
|
76
|
+
const file = 'manifest';
|
|
77
|
+
let manifest = {};
|
|
78
|
+
// look for a manifest JSON
|
|
79
|
+
const manifestJSON = readManifestJSONFile(searchDir, `${file}.json`);
|
|
80
|
+
// look for manifest.js
|
|
81
|
+
// stringify and parses the JSON in order to ensure that objects with .toJSON() functions
|
|
82
|
+
// resolve properly. This is a known behavior for CustomType
|
|
83
|
+
const manifestJS = JSON.parse(JSON.stringify(readImportedManifestFile(searchDir, `${file}.js`)));
|
|
84
|
+
if (!hasManifest(manifestJS, manifestJSON)) {
|
|
85
|
+
throw new Error('Unable to find a manifest file in this project');
|
|
86
|
+
}
|
|
87
|
+
// manage manifest merge
|
|
88
|
+
if (manifestJSON) {
|
|
89
|
+
manifest = merge(manifest, manifestJSON, { arrayMerge: unionMerge });
|
|
90
|
+
}
|
|
91
|
+
if (manifestJS) {
|
|
92
|
+
manifest = merge(manifest, manifestJS, { arrayMerge: unionMerge });
|
|
93
|
+
}
|
|
94
|
+
return manifest;
|
|
95
|
+
}
|
|
96
|
+
module.exports = {
|
|
97
|
+
getManifestData,
|
|
98
|
+
unionMerge,
|
|
99
|
+
readManifestJSONFile,
|
|
100
|
+
readImportedManifestFile,
|
|
101
|
+
hasManifest,
|
|
102
|
+
find,
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEnC,8BAA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,SAAS,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IAEjG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,wBAAwB;IACxB,IAAI,YAAY,EAAE;QAChB,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,UAAU,EAAC,CAAC,CAAC;KACrE;IACD,IAAI,UAAU,EAAE;QACd,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;KACpE;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,eAAe;IACf,UAAU;IACV,oBAAoB;IACpB,wBAAwB;IACxB,WAAW;IACX,IAAI;CACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.spec.d.ts","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('mocha');
|
|
3
|
+
const sinon = require('sinon');
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
const { fs } = require('memfs');
|
|
6
|
+
const mockfs = require('mock-fs');
|
|
7
|
+
const manifestUtils = require('./manifest');
|
|
8
|
+
const { unionMerge, hasManifest, find } = manifestUtils;
|
|
9
|
+
describe('Slack CLI Script Hooks: get-manifest utilities', () => {
|
|
10
|
+
describe('unionMerge', () => {
|
|
11
|
+
it('should return a union of two arrays', () => {
|
|
12
|
+
expect(unionMerge(["arwen"], ["strider"])).to.eql(["arwen", "strider"]);
|
|
13
|
+
expect(unionMerge(["gandalf", "gandalf"], [])).to.eql(["gandalf"]);
|
|
14
|
+
// setup
|
|
15
|
+
const fellowship = ["frodo", "samwise", "merry", "pippin", "gandalf"];
|
|
16
|
+
const hobbits = ["frodo", "samwise", "merry", "pippin"];
|
|
17
|
+
const actualUnion = ["frodo", "samwise", "merry", "pippin", "gandalf"];
|
|
18
|
+
const testUnion = unionMerge(fellowship, hobbits);
|
|
19
|
+
// test
|
|
20
|
+
expect(testUnion).to.eql(actualUnion);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('hasManifest', () => {
|
|
24
|
+
it('should return true if at least one non-empty object', () => {
|
|
25
|
+
expect(hasManifest({}, {}, { testKey: "testValue" })).to.be.true;
|
|
26
|
+
});
|
|
27
|
+
it('should return false if all empty objects', () => {
|
|
28
|
+
expect(hasManifest({}));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('find', () => {
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
mockfs({
|
|
34
|
+
'/middle-earth': {
|
|
35
|
+
'README.md': '1',
|
|
36
|
+
'mordor': {
|
|
37
|
+
'sauron.js': '1',
|
|
38
|
+
'orc.js': '1',
|
|
39
|
+
'nazgul.js': '1',
|
|
40
|
+
},
|
|
41
|
+
'node_modules': '1',
|
|
42
|
+
'eriador': {
|
|
43
|
+
'shire': {
|
|
44
|
+
'one-ring.js': '1',
|
|
45
|
+
'nazgul.js': '1',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
mockfs.restore();
|
|
53
|
+
});
|
|
54
|
+
it('should find the required file in any part of directory', () => {
|
|
55
|
+
const cwd = '/middle-earth';
|
|
56
|
+
//test
|
|
57
|
+
// when target exists
|
|
58
|
+
const result = find(cwd, 'one-ring.js');
|
|
59
|
+
expect(result).to.equal(`${cwd}/eriador/shire/one-ring.js`);
|
|
60
|
+
// when target doesn't exist
|
|
61
|
+
const result2 = find(cwd, 'hobbitses.js');
|
|
62
|
+
expect(result2).to.equal(null);
|
|
63
|
+
// when multiple similar files exist, it is greedy
|
|
64
|
+
const result3 = find(cwd, 'nazgul.js');
|
|
65
|
+
expect(result3).to.equal(`${cwd}/eriador/shire/nazgul.js`);
|
|
66
|
+
});
|
|
67
|
+
it('should not search within node_modules', () => {
|
|
68
|
+
const cwd = '/middle-earth';
|
|
69
|
+
//test
|
|
70
|
+
const result = find(cwd, 'node_modules');
|
|
71
|
+
expect(result).to.equal(null);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=manifest.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.spec.js","sourceRoot":"","sources":["../../../src/cli/hook-utils/manifest.spec.js"],"names":[],"mappings":";AAAA,OAAO,CAAC,OAAO,CAAC,CAAC;AACjB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAChC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAC5C,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;AAExD,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAE7C,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;YACvE,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC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.ts"],"names":[],"mappings":""}
|
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// Run script hook verifies that requirements for running an App in
|
|
9
|
+
// in developerMode (via Socket Mode) are met
|
|
10
|
+
(function _(cwd) {
|
|
11
|
+
// TODO - Format so that its less miss-able in output
|
|
12
|
+
process.stdout.write('Preparing local run in developer mode (Socket Mode)\n');
|
|
13
|
+
// Check required local run tokens
|
|
14
|
+
validate();
|
|
15
|
+
// Kick off a subprocess to run the app in development mode
|
|
16
|
+
const app = (0, child_process_1.spawn)('node', [`${path_1.default.resolve(cwd, 'app.js')}`]);
|
|
17
|
+
app.stdout.setEncoding('utf-8');
|
|
18
|
+
// TODO - Is there a way to configure this in spawn invocation
|
|
19
|
+
app.stdout.on('data', (data) => {
|
|
20
|
+
process.stdout.write(data);
|
|
21
|
+
});
|
|
22
|
+
app.stderr.on('data', (data) => {
|
|
23
|
+
process.stderr.write(data);
|
|
24
|
+
});
|
|
25
|
+
app.on('close', (code) => {
|
|
26
|
+
process.stdout.write(`bolt-app local run exited with code ${code}`);
|
|
27
|
+
});
|
|
28
|
+
}(process.cwd()));
|
|
29
|
+
function validate() {
|
|
30
|
+
if (!process.env.SLACK_CLI_XOXB) {
|
|
31
|
+
throw new Error('Missing local run bot token. Please see slack-cli maintainers to troubleshoot.');
|
|
32
|
+
}
|
|
33
|
+
if (!process.env.SLACK_CLI_XAPP) {
|
|
34
|
+
throw new Error('Missing local run app token. Please see slack-cli maintainers to troubleshoot');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -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CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;KAClG;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { main: pkgJSONMain } = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
|
7
|
+
// Run script hook verifies that requirements for running an App in
|
|
8
|
+
// in developerMode (via Socket Mode) are met
|
|
9
|
+
(function _(cwd, customPath) {
|
|
10
|
+
// TODO - Format so that its less miss-able in output
|
|
11
|
+
console.log('Preparing local run in developer mode (Socket Mode)');
|
|
12
|
+
// Check required local run tokens
|
|
13
|
+
validate();
|
|
14
|
+
// tries the provided path, then package.json main, then defaults to index.js in the current
|
|
15
|
+
// working directory
|
|
16
|
+
const pkgJSONDefault = 'index.js';
|
|
17
|
+
const fullPath = path.resolve(cwd, customPath ? customPath : pkgJSONMain ? pkgJSONMain : pkgJSONDefault);
|
|
18
|
+
console.log(fullPath);
|
|
19
|
+
// Kick off a subprocess to run the app in development mode
|
|
20
|
+
const app = spawn('node', [`${fullPath}`]);
|
|
21
|
+
app.stdout.setEncoding('utf-8');
|
|
22
|
+
app.stdout.on('data', (data) => {
|
|
23
|
+
process.stdout.write(data);
|
|
24
|
+
});
|
|
25
|
+
app.stderr.on('data', (data) => {
|
|
26
|
+
process.stderr.write(data);
|
|
27
|
+
});
|
|
28
|
+
app.on('close', (code) => {
|
|
29
|
+
console.log(`bolt-app local run exited with code ${code}`);
|
|
30
|
+
});
|
|
31
|
+
}(process.cwd(), process.env.SLACK_CLI_CUSTOM_FILE_PATH));
|
|
32
|
+
function validate() {
|
|
33
|
+
if (!process.env.SLACK_CLI_XOXB) {
|
|
34
|
+
throw new Error('Missing local run bot token. Please see slack-cli maintainers to troubleshoot.');
|
|
35
|
+
}
|
|
36
|
+
if (!process.env.SLACK_CLI_XAPP) {
|
|
37
|
+
throw new Error('Missing local run app token. Please see slack-cli maintainers to troubleshoot');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.js"],"names":[],"mappings":";;AACA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC;AAErF,mEAAmE;AACnE,6CAA6C;AAC7C,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,UAAU;IACzB,qDAAqD;IACrD,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACnE,kCAAkC;IAClC,QAAQ,EAAE,CAAC;IAEX,6FAA6F;IAC7F,oBAAoB;IACpB,MAAM,cAAc,GAAG,UAAU,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IACzG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEtB,2DAA2D;IAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,G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