@openstax/ts-utils 1.36.1 → 1.37.1
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/cjs/services/accountsGateway/index.d.ts +2 -2
- package/dist/cjs/services/queueProvider/index.d.ts +5 -0
- package/dist/cjs/services/queueProvider/index.js +2 -0
- package/dist/cjs/services/queueProvider/local.d.ts +10 -0
- package/dist/cjs/services/queueProvider/local.js +22 -0
- package/dist/cjs/services/queueProvider/sqs.d.ts +12 -0
- package/dist/cjs/services/queueProvider/sqs.js +26 -0
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/accountsGateway/index.d.ts +2 -2
- package/dist/esm/services/queueProvider/index.d.ts +5 -0
- package/dist/esm/services/queueProvider/index.js +1 -0
- package/dist/esm/services/queueProvider/local.d.ts +10 -0
- package/dist/esm/services/queueProvider/local.js +18 -0
- package/dist/esm/services/queueProvider/sqs.d.ts +12 -0
- package/dist/esm/services/queueProvider/sqs.js +22 -0
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/script/bin/.init-params-script.bash.swp +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigProviderForConfig } from '../../config';
|
|
2
2
|
import { GenericFetch } from '../../fetch';
|
|
3
3
|
import { JsonCompatibleStruct } from '../../routing';
|
|
4
|
-
import { ApiUser
|
|
4
|
+
import { ApiUser } from '../authProvider';
|
|
5
5
|
import { Logger } from '../logger';
|
|
6
6
|
export type Config = {
|
|
7
7
|
accountsBase: string;
|
|
@@ -60,7 +60,7 @@ export type SearchUsersResponse = {
|
|
|
60
60
|
} & JsonCompatibleStruct>;
|
|
61
61
|
total_count: number;
|
|
62
62
|
};
|
|
63
|
-
export type UpdateUserPayload =
|
|
63
|
+
export type UpdateUserPayload = Partial<ApiUser>;
|
|
64
64
|
export type MappedUserInfo<T> = {
|
|
65
65
|
data: T;
|
|
66
66
|
fullName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigProviderForConfig } from '../../config';
|
|
2
|
+
import { QueueProvider } from '.';
|
|
3
|
+
export type Config = {
|
|
4
|
+
handlerModulePath: string;
|
|
5
|
+
};
|
|
6
|
+
interface Initializer<C> {
|
|
7
|
+
configSpace?: C;
|
|
8
|
+
}
|
|
9
|
+
export declare const localQueueProvider: <C extends string = "local">(initializer?: Initializer<C>) => <T>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => QueueProvider<T>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { resolveConfigValue } from '../../config';
|
|
2
|
+
import { ifDefined } from '../../guards';
|
|
3
|
+
import { once } from '../../misc/helpers';
|
|
4
|
+
export const localQueueProvider = (initializer) => {
|
|
5
|
+
const init = ifDefined(initializer, {});
|
|
6
|
+
return () => (configProvider) => {
|
|
7
|
+
const config = configProvider[ifDefined(init.configSpace, 'local')];
|
|
8
|
+
const handlerModulePath = once(() => resolveConfigValue(config.handlerModulePath));
|
|
9
|
+
return {
|
|
10
|
+
enqueueMessage: async (payload, _options) => {
|
|
11
|
+
const modulePath = await handlerModulePath();
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
const module = require(modulePath);
|
|
14
|
+
await module.handler(payload);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SQS } from '@aws-sdk/client-sqs';
|
|
2
|
+
import { ConfigProviderForConfig } from '../../config';
|
|
3
|
+
import { QueueProvider } from '.';
|
|
4
|
+
export type Config = {
|
|
5
|
+
queueUrl: string;
|
|
6
|
+
};
|
|
7
|
+
interface Initializer<C> {
|
|
8
|
+
configSpace?: C;
|
|
9
|
+
sqsClient?: SQS;
|
|
10
|
+
}
|
|
11
|
+
export declare const sqsQueueProvider: <C extends string = "deployed">(initializer?: Initializer<C>) => <T>() => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => QueueProvider<T>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SendMessageCommand, SQS } from '@aws-sdk/client-sqs';
|
|
2
|
+
import { resolveConfigValue } from '../../config';
|
|
3
|
+
import { ifDefined } from '../../guards';
|
|
4
|
+
import { once } from '../../misc/helpers';
|
|
5
|
+
export const sqsQueueProvider = (initializer) => {
|
|
6
|
+
const init = ifDefined(initializer, {});
|
|
7
|
+
const sqs = once(() => { var _a; return (_a = init.sqsClient) !== null && _a !== void 0 ? _a : new SQS({ apiVersion: '2012-11-05' }); });
|
|
8
|
+
return () => (configProvider) => {
|
|
9
|
+
const config = configProvider[ifDefined(init.configSpace, 'deployed')];
|
|
10
|
+
const queueUrl = once(() => resolveConfigValue(config.queueUrl));
|
|
11
|
+
return {
|
|
12
|
+
enqueueMessage: async (payload, options) => {
|
|
13
|
+
const command = new SendMessageCommand({
|
|
14
|
+
QueueUrl: await queueUrl(),
|
|
15
|
+
MessageBody: JSON.stringify(payload),
|
|
16
|
+
DelaySeconds: options === null || options === void 0 ? void 0 : options.delaySeconds,
|
|
17
|
+
});
|
|
18
|
+
await sqs().send(command);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|