@plitzi/sdk-server 0.37.1 → 0.37.2
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/CHANGELOG.md +146 -0
- package/README.md +26 -0
- package/dist/actions.d.ts +14 -6
- package/dist/actions.js +7 -3
- package/dist/core/server/baseServer.d.ts +4 -1
- package/dist/core/server/baseServer.js +2 -1
- package/dist/core/server/closeOnSignals.d.ts +28 -0
- package/dist/core/server/closeOnSignals.js +46 -0
- package/dist/core/server/pageServer.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/modules/actions/index.d.ts +12 -3
- package/dist/modules/actions/index.js +9 -3
- package/dist/modules/actions/jobs/index.d.ts +32 -0
- package/dist/modules/actions/jobs/index.js +57 -0
- package/dist/modules/actions/jobs/memoryQueue.d.ts +30 -0
- package/dist/modules/actions/jobs/memoryQueue.js +178 -0
- package/dist/modules/actions/jobs/memoryStores.test.d.ts +1 -0
- package/dist/modules/actions/jobs/scheduler.d.ts +62 -0
- package/dist/modules/actions/jobs/scheduler.js +125 -0
- package/dist/modules/actions/jobs/scheduler.test.d.ts +1 -0
- package/dist/modules/actions/jobs/schedules.d.ts +23 -0
- package/dist/modules/actions/jobs/schedules.js +47 -0
- package/dist/modules/actions/jobs/storeClock.d.ts +16 -0
- package/dist/modules/actions/jobs/storeClock.js +32 -0
- package/dist/modules/actions/jobs/testing/jobQueueContract.d.ts +25 -0
- package/dist/modules/actions/jobs/worker.d.ts +62 -0
- package/dist/modules/actions/jobs/worker.js +262 -0
- package/dist/modules/actions/jobs/worker.test.d.ts +1 -0
- package/dist/modules/actions/moduleFor.js +1 -0
- package/dist/modules/actions/runtime/precheck.js +1 -1
- package/dist/modules/actions/runtime/renderResolver.js +2 -2
- package/dist/modules/actions/transport/callHandler.js +1 -1
- package/dist/modules/actions/transport/webhookHandler.js +1 -1
- package/dist/modules/actions/types.d.ts +76 -1
- package/dist/modules/mongo/index.d.ts +4 -0
- package/dist/modules/mongo/jobQueue.d.ts +38 -0
- package/dist/modules/mongo/jobQueue.js +335 -0
- package/dist/modules/mongo/kv.d.ts +15 -0
- package/dist/modules/mongo/kv.js +98 -0
- package/dist/modules/mongo/stores.integration.test.d.ts +1 -0
- package/dist/modules/mysql/jobs/index.d.ts +5 -0
- package/dist/modules/mysql/jobs/jobQueue.d.ts +40 -0
- package/dist/modules/mysql/jobs/jobQueue.js +375 -0
- package/dist/modules/mysql/jobs/kv.d.ts +18 -0
- package/dist/modules/mysql/jobs/kv.js +78 -0
- package/dist/modules/mysql/jobs/schema.d.ts +24 -0
- package/dist/modules/mysql/jobs/schema.js +96 -0
- package/dist/modules/mysql/jobs/stores.integration.test.d.ts +1 -0
- package/dist/modules/ssr/Component.d.ts +2 -5
- package/dist/modules/ssr/Component.js +1 -2
- package/dist/modules/ssr/prepareRender.js +0 -3
- package/dist/mongo.d.ts +25 -0
- package/dist/mongo.js +3 -0
- package/dist/mysql.d.ts +11 -0
- package/dist/mysql.js +4 -1
- package/package.json +16 -6
- package/skills/plitzi-authoring/SKILL.md +73 -267
- package/skills/plitzi-authoring/reference/data-and-visibility.md +114 -0
- package/skills/plitzi-authoring/reference/elements-and-styles.md +107 -0
- package/skills/plitzi-authoring/reference/flows.md +80 -0
- package/skills/plitzi-authoring/reference/layouts.md +140 -0
- package/skills/plitzi-authoring/reference/review-checklist.md +50 -0
- package/skills/plitzi-authoring/reference/structure.md +83 -0
- package/skills/plitzi-authoring/reference/templates-and-export.md +54 -0
- package/skills/plitzi-authoring/reference/templates.md +69 -0
- package/skills/plitzi-authoring/reference/testing.md +52 -0
- package/dist/modules/actions/runtime/schedule.d.ts +0 -35
- package/dist/modules/actions/runtime/schedule.js +0 -76
- /package/dist/{modules/actions/runtime/schedule.test.d.ts → core/server/closeOnSignals.test.d.ts} +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ActionsModule } from '../index';
|
|
2
|
-
import { ActionLookups } from '../types';
|
|
3
|
-
import { Environment } from '@plitzi/sdk-shared';
|
|
4
|
-
export type ScheduleTick = {
|
|
5
|
-
spaceId: number;
|
|
6
|
-
environment?: Environment;
|
|
7
|
-
/** The minute being asked about. Passed in rather than read here so a tick is testable and a missed one can be
|
|
8
|
-
* replayed deliberately — never guessed at. */
|
|
9
|
-
at?: Date;
|
|
10
|
-
};
|
|
11
|
-
export type ScheduleResult = {
|
|
12
|
-
ran: {
|
|
13
|
-
actionId: string;
|
|
14
|
-
runId: string;
|
|
15
|
-
status: string;
|
|
16
|
-
}[];
|
|
17
|
-
skipped: {
|
|
18
|
-
actionId: string;
|
|
19
|
-
reason: string;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
export type ScheduleRunner = {
|
|
23
|
-
tick: (params: ScheduleTick) => Promise<ScheduleResult>;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Runs the actions a space has scheduled for this minute.
|
|
27
|
-
*
|
|
28
|
-
* It owns no timer, on purpose. What ticks it is the deployment's: a leader-locked interval in one role, a k8s
|
|
29
|
-
* CronJob hitting an endpoint, a queue consumer — all of which have to answer "which replica" and "what happens
|
|
30
|
-
* on restart", and none of which the SDK can answer for a deployment it cannot see.
|
|
31
|
-
*
|
|
32
|
-
* Missed ticks are NOT replayed. A scheduler that catches up fires an hour of digests at once after an outage,
|
|
33
|
-
* which is worse than the digest nobody got; the caller that wants a replay asks for that minute explicitly.
|
|
34
|
-
*/
|
|
35
|
-
export declare const createScheduleRunner: (lookups: ActionLookups, module: ActionsModule) => ScheduleRunner;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ActionRunError } from "./errors.js";
|
|
2
|
-
import { findTriggerNode, triggerParams } from "./triggers.js";
|
|
3
|
-
import { cronMatches } from "@plitzi/sdk-shared/actions";
|
|
4
|
-
//#region src/modules/actions/runtime/schedule.ts
|
|
5
|
-
/**
|
|
6
|
-
* Runs the actions a space has scheduled for this minute.
|
|
7
|
-
*
|
|
8
|
-
* It owns no timer, on purpose. What ticks it is the deployment's: a leader-locked interval in one role, a k8s
|
|
9
|
-
* CronJob hitting an endpoint, a queue consumer — all of which have to answer "which replica" and "what happens
|
|
10
|
-
* on restart", and none of which the SDK can answer for a deployment it cannot see.
|
|
11
|
-
*
|
|
12
|
-
* Missed ticks are NOT replayed. A scheduler that catches up fires an hour of digests at once after an outage,
|
|
13
|
-
* which is worse than the digest nobody got; the caller that wants a replay asks for that minute explicitly.
|
|
14
|
-
*/
|
|
15
|
-
var createScheduleRunner = (lookups, module) => {
|
|
16
|
-
const tick = async ({ spaceId, environment = "main", at = /* @__PURE__ */ new Date() }) => {
|
|
17
|
-
const result = {
|
|
18
|
-
ran: [],
|
|
19
|
-
skipped: []
|
|
20
|
-
};
|
|
21
|
-
const entries = await lookups.listActions?.(spaceId) ?? [];
|
|
22
|
-
for (const entry of entries) {
|
|
23
|
-
const schedule = findTriggerNode(entry.document.nodes, "schedule");
|
|
24
|
-
const params = schedule ? triggerParams(schedule) : void 0;
|
|
25
|
-
const cron = params?.cron;
|
|
26
|
-
if (!schedule?.enabled || !cron) continue;
|
|
27
|
-
if (!cronMatches(cron, at, typeof params.timezone === "string" ? params.timezone : void 0)) continue;
|
|
28
|
-
let run;
|
|
29
|
-
try {
|
|
30
|
-
run = await module.guards.begin({
|
|
31
|
-
spaceId,
|
|
32
|
-
actionId: entry.id,
|
|
33
|
-
callerId: "schedule",
|
|
34
|
-
input: {},
|
|
35
|
-
idempotencyKey: `schedule:${at.toISOString().slice(0, 16)}`,
|
|
36
|
-
sharedKey: true,
|
|
37
|
-
ttlMs: module.limitsFor(entry.document).timeoutMs
|
|
38
|
-
});
|
|
39
|
-
} catch (error) {
|
|
40
|
-
result.skipped.push({
|
|
41
|
-
actionId: entry.id,
|
|
42
|
-
reason: error instanceof ActionRunError ? error.reason : "failed"
|
|
43
|
-
});
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const run_ = await module.runAction({
|
|
48
|
-
entry,
|
|
49
|
-
input: {},
|
|
50
|
-
spaceId,
|
|
51
|
-
environment,
|
|
52
|
-
trigger: "schedule",
|
|
53
|
-
callerId: "schedule",
|
|
54
|
-
runId: run.runId,
|
|
55
|
-
signal: run.controller.signal
|
|
56
|
-
});
|
|
57
|
-
result.ran.push({
|
|
58
|
-
actionId: entry.id,
|
|
59
|
-
runId: run_.runId,
|
|
60
|
-
status: run_.status
|
|
61
|
-
});
|
|
62
|
-
} catch (error) {
|
|
63
|
-
result.skipped.push({
|
|
64
|
-
actionId: entry.id,
|
|
65
|
-
reason: error instanceof ActionRunError ? error.reason : "failed"
|
|
66
|
-
});
|
|
67
|
-
} finally {
|
|
68
|
-
await module.guards.end(run);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
};
|
|
73
|
-
return { tick };
|
|
74
|
-
};
|
|
75
|
-
//#endregion
|
|
76
|
-
export { createScheduleRunner };
|
/package/dist/{modules/actions/runtime/schedule.test.d.ts → core/server/closeOnSignals.test.d.ts}
RENAMED
|
File without changes
|