@navios/schedule 0.3.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.
Files changed (51) hide show
  1. package/README.md +370 -0
  2. package/dist/src/__tests__/schedule.spec.d.mts +2 -0
  3. package/dist/src/__tests__/schedule.spec.d.mts.map +1 -0
  4. package/dist/src/cron.constants.d.mts +17 -0
  5. package/dist/src/cron.constants.d.mts.map +1 -0
  6. package/dist/src/decorators/cron.decorator.d.mts +6 -0
  7. package/dist/src/decorators/cron.decorator.d.mts.map +1 -0
  8. package/dist/src/decorators/index.d.mts +3 -0
  9. package/dist/src/decorators/index.d.mts.map +1 -0
  10. package/dist/src/decorators/schedulable.decorator.d.mts +3 -0
  11. package/dist/src/decorators/schedulable.decorator.d.mts.map +1 -0
  12. package/dist/src/index.d.mts +5 -0
  13. package/dist/src/index.d.mts.map +1 -0
  14. package/dist/src/metadata/cron.metadata.d.mts +10 -0
  15. package/dist/src/metadata/cron.metadata.d.mts.map +1 -0
  16. package/dist/src/metadata/index.d.mts +3 -0
  17. package/dist/src/metadata/index.d.mts.map +1 -0
  18. package/dist/src/metadata/schedule.metadata.d.mts +11 -0
  19. package/dist/src/metadata/schedule.metadata.d.mts.map +1 -0
  20. package/dist/src/scheduler.service.d.mts +12 -0
  21. package/dist/src/scheduler.service.d.mts.map +1 -0
  22. package/dist/tsconfig.tsbuildinfo +1 -0
  23. package/dist/tsdown.config.d.mts +3 -0
  24. package/dist/tsdown.config.d.mts.map +1 -0
  25. package/dist/tsup.config.d.mts +3 -0
  26. package/dist/tsup.config.d.mts.map +1 -0
  27. package/dist/vitest.config.d.mts +3 -0
  28. package/dist/vitest.config.d.mts.map +1 -0
  29. package/lib/_tsup-dts-rollup.d.mts +105 -0
  30. package/lib/_tsup-dts-rollup.d.ts +105 -0
  31. package/lib/index.d.mts +14 -0
  32. package/lib/index.d.ts +14 -0
  33. package/lib/index.js +240 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/index.mjs +228 -0
  36. package/lib/index.mjs.map +1 -0
  37. package/package.json +41 -0
  38. package/project.json +53 -0
  39. package/src/__tests__/schedule.spec.mts +167 -0
  40. package/src/cron.constants.mts +16 -0
  41. package/src/decorators/cron.decorator.mts +30 -0
  42. package/src/decorators/index.mts +2 -0
  43. package/src/decorators/schedulable.decorator.mts +19 -0
  44. package/src/index.mts +4 -0
  45. package/src/metadata/cron.metadata.mts +52 -0
  46. package/src/metadata/index.mts +2 -0
  47. package/src/metadata/schedule.metadata.mts +55 -0
  48. package/src/scheduler.service.mts +93 -0
  49. package/tsconfig.json +13 -0
  50. package/tsup.config.mts +12 -0
  51. package/vitest.config.mts +12 -0
package/README.md ADDED
@@ -0,0 +1,370 @@
1
+ # Navios Schedule
2
+
3
+ `Navios Zod React` is a helper for a navios zod to use with Tanstack React Query.
4
+
5
+ ## Why?
6
+
7
+ - **Type Safety**: By using Zod schemas, you can ensure that the data you receive from your API matches the expected structure. This helps catch errors early in the development process.
8
+ - **Validation**: Zod provides powerful validation capabilities, allowing you to define complex validation rules for your data. This ensures that the data you work with is always valid and meets your requirements.
9
+ - **Integration with Navios**: Navios is a powerful HTTP client that simplifies API requests. By combining it with Zod, you can create a robust and type-safe API client.
10
+ - **React Query Support**: This package is designed to work seamlessly with Tanstack React Query, making it easy to manage API requests and responses in your React applications.
11
+ - **Declarative API**: The API is designed to be declarative, allowing you to define your API endpoints and their schemas in a clear and concise manner. This makes it easy to understand and maintain your API client.
12
+ - **Discriminated Union Support**: The package supports discriminated unions, allowing you to handle different response types based on a common property. This is useful for APIs that return different data structures based on the request.
13
+ - **Customizable**: The package allows you to customize the behavior of the API client, such as using a custom Navios client or enabling/disabling certain features like whole response validation.
14
+ - **Error Handling**: The package provides built-in error handling capabilities, allowing you to handle API errors gracefully and provide meaningful feedback to users.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install --save @navios/navios-zod @navios/navios-zod-react zod navios
20
+ ```
21
+
22
+ or
23
+
24
+ ```bash
25
+ yarn add @navios/navios-zod @navios/navios-zod-react zod navios
26
+ ```
27
+
28
+ ## Usage of Mutations
29
+
30
+ ```tsx
31
+ import { createAPI } from '@navios/navios-zod'
32
+ import { declareClient } from '@navios/navios-zod-react'
33
+
34
+ import { z } from 'zod'
35
+
36
+ const publicApi = createAPI({
37
+ baseURL: 'https://example.com/api/',
38
+ useDiscriminatorResponse: true,
39
+ })
40
+
41
+ const publicClient = declareClient({
42
+ api: publicApi,
43
+ })
44
+
45
+ const RequestSchema = z.object({
46
+ email: z.string().email(),
47
+ password: z.string().min(8).max(32),
48
+ })
49
+
50
+ const loginMutation = publicClient.mutation({
51
+ url: 'auth/login',
52
+ method: 'post',
53
+ // Navios Zod also validates the request body
54
+ requestSchema: RequestSchema,
55
+ responseSchema: z.discriminatedUnion('success', [
56
+ z.object({
57
+ success: z.literal(true),
58
+ data: z.object({
59
+ accessToken: z.string(),
60
+ refreshToken: z.string(),
61
+ }),
62
+ }),
63
+ z.object({
64
+ success: z.literal(false),
65
+ error: z.object({
66
+ message: z.string(),
67
+ }),
68
+ }),
69
+ ]),
70
+ processResponse: (response) => {
71
+ if (response.success) {
72
+ return response.data
73
+ } else {
74
+ throw new Error(response.error.message)
75
+ }
76
+ },
77
+ })
78
+
79
+ export function Login() {
80
+ const { mutateAsync: login, data, isSuccess, error } = loginMutation()
81
+
82
+ const form = useForm({
83
+ resolver: zodResolver(RequestSchema),
84
+ defaultValues: {
85
+ email: '',
86
+ password: '',
87
+ },
88
+ })
89
+
90
+ useEffect(() => {
91
+ if (isSuccess) {
92
+ console.log('Login successful:', data)
93
+ }
94
+ }, [isSuccess, data])
95
+
96
+ return (
97
+ <form onSubmit={form.handleSubmit(login)}>
98
+ {error && <p>{error.message}</p>}
99
+ <input {...form.register('email')} placeholder="Email" />
100
+ <input
101
+ {...form.register('password')}
102
+ type="password"
103
+ placeholder="Password"
104
+ />
105
+ <button type="submit">Login</button>
106
+ </form>
107
+ )
108
+ }
109
+ ```
110
+
111
+ ## Usage of Queries
112
+
113
+ ```tsx
114
+ import { createAPI } from '@navios/navios-zod'
115
+ import { declareClient } from '@navios/navios-zod-react'
116
+
117
+ import { z } from 'zod'
118
+
119
+ const publicApi = createAPI({
120
+ baseURL: 'https://example.com/api/',
121
+ useDiscriminatorResponse: true,
122
+ })
123
+
124
+ const publicClient = declareClient({
125
+ api: publicApi,
126
+ })
127
+
128
+ const usersList = publicClient.query({
129
+ url: 'users',
130
+ method: 'GET',
131
+ querySchema: z.object({
132
+ page: z.number().optional().default(1),
133
+ limit: z.number().optional().default(10),
134
+ }),
135
+ responseSchema: z.discriminatedUnion('success', [
136
+ z.object({
137
+ success: z.literal(true),
138
+ data: z.array(
139
+ z.object({
140
+ id: z.string(),
141
+ name: z.string(),
142
+ email: z.string().email(),
143
+ }),
144
+ ),
145
+ }),
146
+ z.object({
147
+ success: z.literal(false),
148
+ error: z.object({
149
+ message: z.string(),
150
+ }),
151
+ }),
152
+ ]),
153
+ processResponse: (response) => {
154
+ if (response.success) {
155
+ return response.data
156
+ } else {
157
+ throw new Error(response.error.message)
158
+ }
159
+ },
160
+ })
161
+
162
+ export function UsersList() {
163
+ const { page, limit } = routeApi.useSearch()
164
+ const navigate = routeApi.useNavigate()
165
+ const { data, isLoading, error } = usersList.use({
166
+ params: {
167
+ page,
168
+ limit,
169
+ },
170
+ })
171
+
172
+ if (isLoading) {
173
+ return <p>Loading...</p>
174
+ }
175
+
176
+ if (error) {
177
+ return <p>{error.message}</p>
178
+ }
179
+
180
+ return <ul>{data?.map((user) => <li key={user.id}>{user.name}</li>)}</ul>
181
+ }
182
+ ```
183
+
184
+ ## Usage of Infinite Queries
185
+
186
+ ```tsx
187
+ import { createAPI } from '@navios/navios-zod'
188
+ import { declareClient } from '@navios/navios-zod-react'
189
+
190
+ import { z } from 'zod'
191
+
192
+ const publicApi = createAPI({
193
+ baseURL: 'https://example.com/api/',
194
+ useDiscriminatorResponse: true,
195
+ })
196
+
197
+ const publicClient = declareClient({
198
+ api: publicApi,
199
+ })
200
+
201
+ const usersList = publicClient.infiniteQuery({
202
+ url: 'users',
203
+ method: 'GET',
204
+ querySchema: z.object({
205
+ page: z.number().optional().default(1),
206
+ limit: z.number().optional().default(10),
207
+ }),
208
+ responseSchema: z.discriminatedUnion('success', [
209
+ z.object({
210
+ success: z.literal(true),
211
+ data: z.array(
212
+ z.object({
213
+ id: z.string(),
214
+ name: z.string(),
215
+ email: z.string().email(),
216
+ }),
217
+ ),
218
+ meta: z.object({
219
+ total: z.number(),
220
+ totalPages: z.number(),
221
+ page: z.number(),
222
+ }),
223
+ }),
224
+ z.object({
225
+ success: z.literal(false),
226
+ error: z.object({
227
+ message: z.string(),
228
+ }),
229
+ }),
230
+ ]),
231
+ processResponse: (response) => {
232
+ if (response.success) {
233
+ return response.data
234
+ } else {
235
+ throw new Error(response.error.message)
236
+ }
237
+ },
238
+ getNextPageParam: (lastPage, pages) => {
239
+ if (lastPage.meta.page < lastPage.meta.totalPages) {
240
+ return lastPage.meta.page + 1
241
+ }
242
+ return undefined
243
+ },
244
+ select: (data) => {
245
+ return data.pages.flatMap((page) => page.data)
246
+ },
247
+ })
248
+
249
+ export function UsersList() {
250
+ const { page, limit } = routeApi.useSearch()
251
+ const { data, isLoading, error, fetchNextPage, hasNextPage } = usersList.use({
252
+ params: {
253
+ page,
254
+ limit,
255
+ },
256
+ })
257
+
258
+ if (isLoading) {
259
+ return <p>Loading...</p>
260
+ }
261
+
262
+ if (error) {
263
+ return <p>{error.message}</p>
264
+ }
265
+
266
+ return (
267
+ <div>
268
+ <ul>
269
+ {data?.map((page) =>
270
+ page.data.map((user) => <li key={user.id}>{user.name}</li>),
271
+ )}
272
+ </ul>
273
+ <button disabled={!hasNextPage} onClick={() => fetchNextPage()}>
274
+ Load more
275
+ </button>
276
+ </div>
277
+ )
278
+ }
279
+ ```
280
+
281
+ ## API
282
+
283
+ ### `declareClient`
284
+
285
+ This function is used to create a client for the API. It takes an object with the following properties:
286
+
287
+ - `api`: The API object created using `declareAPI` or `createAPI` from `@navios/navios-zod`.
288
+
289
+ The client object will have the following properties:
290
+
291
+ - `query`: A function that takes a configuration object and returns a query object.
292
+ - `mutation`: A function that takes a configuration object and returns a mutation object.
293
+ - `infiniteQuery`: A function that takes a configuration object and returns an infinite query object.
294
+
295
+ #### `query`
296
+
297
+ This function is used to create a query for the API. It takes a configuration object with the following properties:
298
+
299
+ - `url`: The URL of the API endpoint. For parameterized URLs, use the format `/users/$userId`.
300
+ - `method`: The HTTP method to use (GET, POST, PUT, DELETE, etc.).
301
+ - `querySchema`: A Zod schema for validating the query parameters. (optional)
302
+ - `responseSchema`: A Zod schema for validating the response data.
303
+ - `processResponse`: A function that takes the response data and returns the processed data. (optional, but recommended)
304
+
305
+ The result is a function that can be used to get query options. The function takes an object with the following properties:
306
+
307
+ - `params`: An object with the query parameters to send with the request. (required if `querySchema` is defined)
308
+ - `urlParams`: An object with the URL parameters to send with the request. (required if `url` contains URL parameters)
309
+
310
+ Function returns options for `useQuery` or `useSuspenseQuery` from `@tanstack/react-query`.
311
+
312
+ ##### `queryName.use`
313
+
314
+ This function is a helper hook which is a wrapper around `useQuery` from `@tanstack/react-query`. It takes the same parameters as the `query` result function and returns the query result.
315
+
316
+ ##### `queryName.useSuspense`
317
+
318
+ This function is a helper hook which is a wrapper around `useSuspenseQuery` from `@tanstack/react-query`. It takes the same parameters as the `query` result function and returns the query result.
319
+
320
+ ##### `queryName.invalidate`
321
+
322
+ This function is a helper function which is a wrapper around `invalidateQueries` from `@tanstack/react-query`. It takes parameters:
323
+
324
+ - `queryClient`: The query client to use. (optional, defaults to the query client from the context)
325
+ - `params`: An object with `urlParams` and `params` to invalidate the query. (required if `url` contains URL parameters or `querySchema` is defined)
326
+
327
+ This function is used to invalidate the query in the cache. It can be used to refetch the query data when the data changes or when the user navigates to a different page.
328
+
329
+ ##### `queryName.invalidateAll`
330
+
331
+ This function is a helper function which is a wrapper around `invalidateQueries` from `@tanstack/react-query`. It takes parameters:
332
+
333
+ - `queryClient`: The query client to use. (optional, defaults to the query client from the context)
334
+ - `params`: An object with `urlParams` to invalidate the query. (required if `url` contains URL parameters)
335
+
336
+ This function is used to invalidate query ignoring query params. It can be used to refetch all query data when the data changes or when the user navigates to a different page.
337
+
338
+ #### `mutation`
339
+
340
+ This function is used to create a mutation for the API. It takes a configuration object with the following properties:
341
+
342
+ - `url`: The URL of the API endpoint. For parameterized URLs, use the format `/users/$userId`.
343
+ - `method`: The HTTP method to use (PATCH, POST, PUT, DELETE, etc.).
344
+ - `requestSchema`: A Zod schema for validating the request body.
345
+ - `responseSchema`: A Zod schema for validating the response data.
346
+ - `processResponse`: A function that takes the response data and returns the processed data. (optional, but recommended)
347
+ - `useContext`: A function that is called before the mutation is executed. It can be used to set the context for the onSuccess and onError. (optional)
348
+ - `onSuccess`: A function that is called when the mutation is successful. (optional)
349
+ - `onError`: A function that is called when the mutation fails. (optional)
350
+ - `useKey`: If true, the mutation will have a mutation key which can be used to get the mutation status, limit parallel requests, etc. (optional, defaults to false)
351
+
352
+ The result is a function that can be used to get mutation in react query. When `useKey` is true, the function requires a `urlParams` argument.
353
+
354
+ The result is a react query mutation object
355
+
356
+ #### `infiniteQuery`
357
+
358
+ This function is used to create an infinite query for the API. It takes a configuration object with the following properties:
359
+
360
+ - `url`: The URL of the API endpoint. For parameterized URLs, use the format `/users/$userId`.
361
+ - `method`: The HTTP method to use (GET, POST, PUT, DELETE, etc.).
362
+ - `querySchema`: A Zod schema for validating the query parameters. (required)
363
+ - `responseSchema`: A Zod schema for validating the response data.
364
+ - `processResponse`: A function that takes the response data and returns the processed data. (optional, but recommended)
365
+ - `getNextPageParam`: A function that takes the last page and all pages and returns the next page param. (required)
366
+ - `initialPageData`: The initial data to use for the first page. (optional)
367
+ - `getPreviousPageParam`: A function that takes the first page and all pages and returns the previous page param. (optional)
368
+ - `select`: A function that takes the data and returns the selected data. (optional)
369
+
370
+ It works the same as `query`, but it returns an infinite query object. Please refer to the `query` section for more details.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schedule.spec.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.spec.d.mts","sourceRoot":"","sources":["../../../src/__tests__/schedule.spec.mts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ export declare enum Schedule {
2
+ EveryMinute = "*/1 * * * *",
3
+ EveryFiveMinutes = "*/5 * * * *",
4
+ EveryTenMinutes = "*/10 * * * *",
5
+ EveryFifteenMinutes = "*/15 * * * *",
6
+ EveryThirtyMinutes = "*/30 * * * *",
7
+ EveryHour = "0 * * * *",
8
+ EveryTwoHours = "0 */2 * * *",
9
+ EveryThreeHours = "0 */3 * * *",
10
+ EveryFourHours = "0 */4 * * *",
11
+ EverySixHours = "0 */6 * * *",
12
+ EveryTwelveHours = "0 */12 * * *",
13
+ EveryDay = "0 0 * * *",
14
+ EveryWeek = "0 0 * * 0",
15
+ EveryMonth = "0 0 1 * *"
16
+ }
17
+ //# sourceMappingURL=cron.constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.constants.d.mts","sourceRoot":"","sources":["../../src/cron.constants.mts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,gBAAgB,gBAAgB;IAChC,eAAe,iBAAiB;IAChC,mBAAmB,iBAAiB;IACpC,kBAAkB,iBAAiB;IACnC,SAAS,cAAc;IACvB,aAAa,gBAAgB;IAC7B,eAAe,gBAAgB;IAC/B,cAAc,gBAAgB;IAC9B,aAAa,gBAAgB;IAC7B,gBAAgB,iBAAiB;IACjC,QAAQ,cAAc;IACtB,SAAS,cAAc;IACvB,UAAU,cAAc;CACzB"}
@@ -0,0 +1,6 @@
1
+ import type { CronJobParams } from 'cron';
2
+ export interface CronOptions {
3
+ disabled?: boolean;
4
+ }
5
+ export declare function Cron(cronTime: CronJobParams['cronTime'], options?: CronOptions): (target: () => Promise<void>, context: ClassMethodDecoratorContext) => () => Promise<void>;
6
+ //# sourceMappingURL=cron.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/cron.decorator.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,IAAI,CAClB,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,EACnC,OAAO,CAAC,EAAE,WAAW,IAGnB,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC,EAC3B,SAAS,2BAA2B,WADtB,OAAO,CAAC,IAAI,CAAC,CAe9B"}
@@ -0,0 +1,3 @@
1
+ export * from './cron.decorator.mjs';
2
+ export * from './schedulable.decorator.mjs';
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/decorators/index.mts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ClassType } from '@navios/core';
2
+ export declare function Schedulable(): (target: ClassType, context: ClassDecoratorContext) => ClassType;
3
+ //# sourceMappingURL=schedulable.decorator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedulable.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/schedulable.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAM7C,wBAAgB,WAAW,KACjB,QAAQ,SAAS,EAAE,SAAS,qBAAqB,eAW1D"}
@@ -0,0 +1,5 @@
1
+ export * from './decorators/index.mjs';
2
+ export * from './metadata/index.mjs';
3
+ export * from './cron.constants.mjs';
4
+ export * from './scheduler.service.mjs';
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { CronJobParams } from 'cron';
2
+ export declare const CronMetadataKey: unique symbol;
3
+ export interface CronMetadata {
4
+ classMethod: string;
5
+ cronTime: CronJobParams['cronTime'] | null;
6
+ disabled: boolean;
7
+ }
8
+ export declare function getAllCronMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<CronMetadata>;
9
+ export declare function getCronMetadata(target: Function, context: ClassMethodDecoratorContext): CronMetadata;
10
+ //# sourceMappingURL=cron.metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/cron.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,eAAO,MAAM,eAAe,eAA4B,CAAA;AAExD,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IAC1C,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,2BAA2B,GAAG,qBAAqB,GAC3D,GAAG,CAAC,YAAY,CAAC,CAanB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,2BAA2B,GACnC,YAAY,CAqBd"}
@@ -0,0 +1,3 @@
1
+ export * from './cron.metadata.mjs';
2
+ export * from './schedule.metadata.mjs';
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/metadata/index.mts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { ClassType } from '@navios/core';
2
+ import type { CronMetadata } from './cron.metadata.mjs';
3
+ export declare const ScheduleMetadataKey: unique symbol;
4
+ export interface ScheduleMetadata {
5
+ name: string;
6
+ jobs: Set<CronMetadata>;
7
+ }
8
+ export declare function getScheduleMetadata(target: ClassType, context: ClassDecoratorContext): ScheduleMetadata;
9
+ export declare function extractScheduleMetadata(target: ClassType): ScheduleMetadata;
10
+ export declare function hasScheduleMetadata(target: ClassType): boolean;
11
+ //# sourceMappingURL=schedule.metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/schedule.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAIvD,eAAO,MAAM,mBAAmB,eAAkC,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;CACxB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,GAC7B,gBAAgB,CAoBlB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAS3E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAK9D"}
@@ -0,0 +1,12 @@
1
+ import type { ClassType } from '@navios/core';
2
+ import { CronJob } from 'cron';
3
+ export declare class SchedulerService {
4
+ private readonly logger;
5
+ private readonly jobs;
6
+ register(service: ClassType): void;
7
+ getJob<T extends ClassType>(service: T, method: keyof InstanceType<T>): CronJob | undefined;
8
+ private registerJobs;
9
+ startAll(): void;
10
+ stopAll(): void;
11
+ }
12
+ //# sourceMappingURL=scheduler.service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.service.d.mts","sourceRoot":"","sources":["../../src/scheduler.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAU7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAS9B,qBACa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAErB;IACF,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkC;IAEvD,QAAQ,CAAC,OAAO,EAAE,SAAS;IAW3B,MAAM,CAAC,CAAC,SAAS,SAAS,EACxB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,GAC5B,OAAO,GAAG,SAAS;IAMtB,OAAO,CAAC,YAAY;IA4BpB,QAAQ;IASR,OAAO;CAQR"}