wirejs-resources 0.1.169 → 0.1.171
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/overrides.d.ts +2 -0
- package/dist/resources/cron-job.d.ts +28 -0
- package/dist/resources/cron-job.js +29 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './types/index.js';
|
|
|
13
13
|
export * from './derived-types.js';
|
|
14
14
|
export * from './services/realtime.js';
|
|
15
15
|
export * from './resources/background-job.js';
|
|
16
|
+
export * from './resources/cron-job.js';
|
|
16
17
|
export * from './resources/key-value-store.js';
|
|
17
18
|
export * from './resources/endpoint.js';
|
|
18
19
|
export * from './resources/system-attribute.js';
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './types/index.js';
|
|
|
12
12
|
export * from './derived-types.js';
|
|
13
13
|
export * from './services/realtime.js';
|
|
14
14
|
export * from './resources/background-job.js';
|
|
15
|
+
export * from './resources/cron-job.js';
|
|
15
16
|
export * from './resources/key-value-store.js';
|
|
16
17
|
export * from './resources/endpoint.js';
|
|
17
18
|
export * from './resources/system-attribute.js';
|
package/dist/overrides.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AuthenticationService } from "./services/authentication";
|
|
2
2
|
import type { BackgroundJob } from "./resources/background-job";
|
|
3
|
+
import type { CronJob } from "./resources/cron-job";
|
|
3
4
|
import type { DistributedTable } from "./resources/distributed-table";
|
|
4
5
|
import type { Endpoint } from "./resources/endpoint";
|
|
5
6
|
import type { FileService } from "./services/file";
|
|
@@ -13,6 +14,7 @@ import type { Setting } from "./resources/setting";
|
|
|
13
14
|
export declare const overrides: {
|
|
14
15
|
AuthenticationService?: typeof AuthenticationService;
|
|
15
16
|
BackgroundJob?: typeof BackgroundJob;
|
|
17
|
+
CronJob?: typeof CronJob;
|
|
16
18
|
DistributedTable?: typeof DistributedTable;
|
|
17
19
|
Endpoint?: typeof Endpoint;
|
|
18
20
|
FileService?: typeof FileService;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Resource } from '../resource.js';
|
|
2
|
+
/**
|
|
3
|
+
* A function that will be executed in the background on a recurring schedule
|
|
4
|
+
* defined by a cron expression.
|
|
5
|
+
*
|
|
6
|
+
* These MUST be created at the top-level of your application. I.e., they cannot be created
|
|
7
|
+
* dynamically in response to an API request or other event.
|
|
8
|
+
*
|
|
9
|
+
* A `CronJob` can also invoke an existing {@link BackgroundJob} from its handler.
|
|
10
|
+
*
|
|
11
|
+
* ## WARNINGS
|
|
12
|
+
*
|
|
13
|
+
* 1. These jobs execute in a completely different environment that the one that defines it.
|
|
14
|
+
* DO NOT depend on global variables, closures, or other process state that is not lazily
|
|
15
|
+
* created or constructed in-place by the script.
|
|
16
|
+
* 2. In local development, **timeouts are not enforced.** (Yet.)
|
|
17
|
+
*/
|
|
18
|
+
export declare class CronJob extends Resource {
|
|
19
|
+
static registeredJobs: Map<string, {
|
|
20
|
+
schedule: string;
|
|
21
|
+
handler: () => Promise<void>;
|
|
22
|
+
}>;
|
|
23
|
+
readonly schedule: string;
|
|
24
|
+
constructor(scope: Resource | string, id: string, options: {
|
|
25
|
+
schedule: string;
|
|
26
|
+
handler: () => Promise<void>;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Resource } from '../resource.js';
|
|
2
|
+
/**
|
|
3
|
+
* A function that will be executed in the background on a recurring schedule
|
|
4
|
+
* defined by a cron expression.
|
|
5
|
+
*
|
|
6
|
+
* These MUST be created at the top-level of your application. I.e., they cannot be created
|
|
7
|
+
* dynamically in response to an API request or other event.
|
|
8
|
+
*
|
|
9
|
+
* A `CronJob` can also invoke an existing {@link BackgroundJob} from its handler.
|
|
10
|
+
*
|
|
11
|
+
* ## WARNINGS
|
|
12
|
+
*
|
|
13
|
+
* 1. These jobs execute in a completely different environment that the one that defines it.
|
|
14
|
+
* DO NOT depend on global variables, closures, or other process state that is not lazily
|
|
15
|
+
* created or constructed in-place by the script.
|
|
16
|
+
* 2. In local development, **timeouts are not enforced.** (Yet.)
|
|
17
|
+
*/
|
|
18
|
+
export class CronJob extends Resource {
|
|
19
|
+
static registeredJobs = new Map();
|
|
20
|
+
schedule;
|
|
21
|
+
constructor(scope, id, options) {
|
|
22
|
+
super(scope, id);
|
|
23
|
+
this.schedule = options.schedule;
|
|
24
|
+
CronJob.registeredJobs.set(this.absoluteId, {
|
|
25
|
+
schedule: options.schedule,
|
|
26
|
+
handler: options.handler,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|