@candlerip/shared 0.0.147 → 0.0.149

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.
Files changed (37) hide show
  1. package/common/log/logger-worker/index.js +1 -1
  2. package/common/log/logger-worker/type.d.ts +6 -1
  3. package/common/type/index.d.ts +1 -0
  4. package/common/type/index.js +1 -0
  5. package/common/type/promise/domains.d.ts +1 -0
  6. package/common/type/promise/index.d.ts +1 -0
  7. package/common/type/promise/index.js +1 -0
  8. package/database/aggregate/index.d.ts +0 -1
  9. package/database/aggregate/index.js +0 -1
  10. package/database/mutation/candle-lighting-profile/get-candle-lighting-profile-db/compose-aggregates/index.d.ts +2 -0
  11. package/database/mutation/candle-lighting-profile/get-candle-lighting-profile-db/compose-aggregates/index.js +19 -0
  12. package/database/mutation/candle-lighting-profile/get-candle-lighting-profile-db/compose-aggregates/type.d.ts +3 -0
  13. package/database/mutation/candle-lighting-profile/get-candle-lighting-profile-db/index.js +23 -0
  14. package/database/mutation/candle-lighting-profile/get-candle-lighting-profile-db/type.d.ts +10 -0
  15. package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profiles-db → get-candle-lighting-profiles-db}/index.js +2 -2
  16. package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profiles-db → get-candle-lighting-profiles-db}/type.d.ts +1 -1
  17. package/database/mutation/candle-lighting-profile/get-candle-lighting-profiles-db/type.js +1 -0
  18. package/database/mutation/candle-lighting-profile/index.d.ts +2 -1
  19. package/database/mutation/candle-lighting-profile/index.js +2 -1
  20. package/database/mutation/country/utils/get-country-db/index.js +1 -1
  21. package/package.json +1 -1
  22. package/database/aggregate/candle-lighting-profile/index.d.ts +0 -1
  23. package/database/aggregate/candle-lighting-profile/index.js +0 -1
  24. package/database/aggregate/candle-lighting-profile/utils/compose-get-lighting-profile-aggregates/index.d.ts +0 -2
  25. package/database/aggregate/candle-lighting-profile/utils/compose-get-lighting-profile-aggregates/index.js +0 -10
  26. package/database/aggregate/candle-lighting-profile/utils/compose-get-lighting-profile-aggregates/type.d.ts +0 -2
  27. package/database/aggregate/candle-lighting-profile/utils/index.d.ts +0 -1
  28. package/database/aggregate/candle-lighting-profile/utils/index.js +0 -1
  29. package/database/mutation/candle-lighting-profile/utils/get-candle-lighting-profile-db/index.js +0 -22
  30. package/database/mutation/candle-lighting-profile/utils/get-candle-lighting-profile-db/type.d.ts +0 -6
  31. package/database/mutation/candle-lighting-profile/utils/index.d.ts +0 -2
  32. package/database/mutation/candle-lighting-profile/utils/index.js +0 -2
  33. /package/{database/aggregate/candle-lighting-profile/utils/compose-get-lighting-profile-aggregates/type.js → common/type/promise/domains.js} +0 -0
  34. /package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profile-db → get-candle-lighting-profile-db/compose-aggregates}/type.js +0 -0
  35. /package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profile-db → get-candle-lighting-profile-db}/index.d.ts +0 -0
  36. /package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profiles-db → get-candle-lighting-profile-db}/type.js +0 -0
  37. /package/database/mutation/candle-lighting-profile/{utils/get-candle-lighting-profiles-db → get-candle-lighting-profiles-db}/index.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import { sendToConsole } from './send-to-console/index.js';
2
2
  import { composeCustomError } from '../../custom-error/index.js';
3
3
  import { CloudWatchWorker } from '../../../aws/index.js';
4
- export const loggerWorker = async (awsRegion, logGroupName, isDevelopment) => {
4
+ export const loggerWorker = async (awsRegion, logGroupName, { isDevelopment }) => {
5
5
  const { createLogStream } = await CloudWatchWorker({ logGroupName, region: awsRegion });
6
6
  let _logStreamName;
7
7
  let _context;
@@ -1,5 +1,10 @@
1
1
  import { CustomError } from '../../custom-error/index.js';
2
- export type TLoggerWorker = (awsRegion: string, logGroupName: string, isDevelopment: string) => Promise<TLoggerWorkerReturn>;
2
+ export type TLoggerWorker = (awsRegion: string, logGroupName: string, options: {
3
+ isDevelopment: boolean;
4
+ }) => Promise<{
5
+ initLogStream: TInitLogStream;
6
+ log: TLog;
7
+ }>;
3
8
  export type TLoggerWorkerReturn = {
4
9
  initLogStream: TInitLogStream;
5
10
  log: TLog;
@@ -1,5 +1,6 @@
1
1
  export * from './array/index.js';
2
2
  export * from './boolean/index.js';
3
+ export * from './promise/index.js';
3
4
  export * from './number/index.js';
4
5
  export * from './null/index.js';
5
6
  export * from './object/index.js';
@@ -1,5 +1,6 @@
1
1
  export * from './array/index.js';
2
2
  export * from './boolean/index.js';
3
+ export * from './promise/index.js';
3
4
  export * from './number/index.js';
4
5
  export * from './null/index.js';
5
6
  export * from './object/index.js';
@@ -0,0 +1 @@
1
+ export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
@@ -0,0 +1 @@
1
+ export * from './domains.js';
@@ -0,0 +1 @@
1
+ export * from './domains.js';
@@ -1,5 +1,4 @@
1
1
  export * from './candle/index.js';
2
- export * from './candle-lighting-profile/index.js';
3
2
  export * from './country/index.js';
4
3
  export * from './country-translation/index.js';
5
4
  export * from './language-translation/index.js';
@@ -1,5 +1,4 @@
1
1
  export * from './candle/index.js';
2
- export * from './candle-lighting-profile/index.js';
3
2
  export * from './country/index.js';
4
3
  export * from './country-translation/index.js';
5
4
  export * from './language-translation/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposeAggregates } from './type.js';
2
+ export declare const composeAggregates: ComposeAggregates;
@@ -0,0 +1,19 @@
1
+ import { isBoolean } from '../../../../../common/index.js';
2
+ export const composeAggregates = ({ code, isDefault }) => {
3
+ const aggregates = [];
4
+ if (code) {
5
+ aggregates.push({
6
+ $match: {
7
+ code,
8
+ },
9
+ });
10
+ }
11
+ if (isBoolean(isDefault)) {
12
+ aggregates.push({
13
+ $match: {
14
+ isDefault,
15
+ },
16
+ });
17
+ }
18
+ return aggregates;
19
+ };
@@ -0,0 +1,3 @@
1
+ import { PipelineStage } from 'mongoose';
2
+ import { GetCandleLightingProfileDbProps } from '../type.js';
3
+ export type ComposeAggregates = (props: GetCandleLightingProfileDbProps) => PipelineStage[];
@@ -0,0 +1,23 @@
1
+ import { getCandleLightingProfileDbModel } from '../../../model/index.js';
2
+ import { composeAggregates } from './compose-aggregates/index.js';
3
+ import { composeCustomError } from '../../../../common/index.js';
4
+ export const getCandleLightingProfileDb = async (props) => {
5
+ let resp;
6
+ const aggregates = composeAggregates(props);
7
+ try {
8
+ resp = await getCandleLightingProfileDbModel().aggregate(aggregates);
9
+ }
10
+ catch (err) {
11
+ return {
12
+ customError: composeCustomError('Get candle lighting profile failed', { err, props }),
13
+ };
14
+ }
15
+ if (!resp || resp.length === 0) {
16
+ return {
17
+ data: null,
18
+ };
19
+ }
20
+ return {
21
+ data: resp[0],
22
+ };
23
+ };
@@ -0,0 +1,10 @@
1
+ import { CandleLightingProfile, CustomError } from '../../../../common/index.js';
2
+ export type GetCandleLightingProfileDb = (props: GetCandleLightingProfileDbProps) => Promise<{
3
+ data: CandleLightingProfile | null;
4
+ } | {
5
+ customError: CustomError;
6
+ }>;
7
+ export type GetCandleLightingProfileDbProps = {
8
+ code?: number;
9
+ isDefault?: boolean;
10
+ };
@@ -1,5 +1,5 @@
1
- import { CustomErrorWorker } from '../../../../../common/index.js';
2
- import { getCandleLightingProfileDbModel } from '../../../../model/index.js';
1
+ import { CustomErrorWorker } from '../../../../common/index.js';
2
+ import { getCandleLightingProfileDbModel } from '../../../model/index.js';
3
3
  export const getCandleLightingProfilesDb = async () => {
4
4
  const { composeCustomError } = CustomErrorWorker();
5
5
  let data;
@@ -1,4 +1,4 @@
1
- import { CandleLightingProfile, CustomError } from '../../../../../common/index.js';
1
+ import { CandleLightingProfile, CustomError } from '../../../../common/index.js';
2
2
  export type GetCandleLightingProfilesDb = () => Promise<{
3
3
  data: CandleLightingProfile[];
4
4
  } | {
@@ -1 +1,2 @@
1
- export * from './utils/index.js';
1
+ export * from './get-candle-lighting-profile-db/index.js';
2
+ export * from './get-candle-lighting-profiles-db/index.js';
@@ -1 +1,2 @@
1
- export * from './utils/index.js';
1
+ export * from './get-candle-lighting-profile-db/index.js';
2
+ export * from './get-candle-lighting-profiles-db/index.js';
@@ -10,7 +10,7 @@ export const getCountryDb = async (code, options) => {
10
10
  resp = await getCountryDbModel().aggregate(aggregates);
11
11
  }
12
12
  catch (err) {
13
- return { customError: composeCustomError('Get countries failed', { err }) };
13
+ return { customError: composeCustomError('Get country failed', { err }) };
14
14
  }
15
15
  if (!resp || resp.length === 0) {
16
16
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "=22.19.0"
@@ -1 +0,0 @@
1
- export * from './utils/index.js';
@@ -1 +0,0 @@
1
- export * from './utils/index.js';
@@ -1,2 +0,0 @@
1
- import { ComposeGetCandleLightingProfileAggregates } from './type.js';
2
- export declare const composeGetCandleLightingProfileAggregates: ComposeGetCandleLightingProfileAggregates;
@@ -1,10 +0,0 @@
1
- export const composeGetCandleLightingProfileAggregates = (code) => {
2
- const aggregates = [
3
- {
4
- $match: {
5
- code,
6
- },
7
- },
8
- ];
9
- return aggregates;
10
- };
@@ -1,2 +0,0 @@
1
- import { PipelineStage } from 'mongoose';
2
- export type ComposeGetCandleLightingProfileAggregates = (code: number) => PipelineStage[];
@@ -1 +0,0 @@
1
- export * from './compose-get-lighting-profile-aggregates/index.js';
@@ -1 +0,0 @@
1
- export * from './compose-get-lighting-profile-aggregates/index.js';
@@ -1,22 +0,0 @@
1
- import { composeGetCandleLightingProfileAggregates } from '../../../../aggregate/index.js';
2
- import { getCandleLightingProfileDbModel } from '../../../../model/index.js';
3
- import { CustomErrorWorker } from '../../../../../common/index.js';
4
- export const getCandleLightingProfileDb = async (code) => {
5
- let resp;
6
- const { composeCustomError } = CustomErrorWorker({ info: { code } });
7
- const aggregates = composeGetCandleLightingProfileAggregates(code);
8
- try {
9
- resp = await getCandleLightingProfileDbModel().aggregate(aggregates);
10
- }
11
- catch (err) {
12
- return { customError: composeCustomError('Get candle lighting profile failed', { err }) };
13
- }
14
- if (!resp || resp.length === 0) {
15
- return {
16
- data: null,
17
- };
18
- }
19
- return {
20
- data: resp[0],
21
- };
22
- };
@@ -1,6 +0,0 @@
1
- import { CandleLightingProfile, CustomError } from '../../../../../common/index.js';
2
- export type GetCandleLightingProfileDb = (code: number) => Promise<{
3
- data: CandleLightingProfile | null;
4
- } | {
5
- customError: CustomError;
6
- }>;
@@ -1,2 +0,0 @@
1
- export * from './get-candle-lighting-profile-db/index.js';
2
- export * from './get-candle-lighting-profiles-db/index.js';
@@ -1,2 +0,0 @@
1
- export * from './get-candle-lighting-profile-db/index.js';
2
- export * from './get-candle-lighting-profiles-db/index.js';