@plitzi/sdk-actions 0.39.13 → 0.39.14
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 +10 -0
- package/dist/chunks/{grants-BsD-WlLE.mjs → grants-ZR79buug.mjs} +2 -14
- package/dist/chunks/{load-tw8iAgZy.mjs → load-dDkFegMP.mjs} +1 -1
- package/dist/chunks/{module-Baod2T6h.mjs → module-RTJHp4G8.mjs} +2 -7
- package/dist/chunks/{taskCatalog-J9hBMCsz.mjs → taskCatalog-D3vyVCWp.mjs} +1 -1
- package/dist/engine/runtime/kvStore.d.ts +3 -3
- package/dist/engine/runtime/redisKv.d.ts +3 -4
- package/dist/engine/types.d.ts +7 -4
- package/dist/functions/index.mjs +2 -2
- package/dist/index.mjs +17 -8
- package/dist/mongo/index.mjs +4 -9
- package/dist/mysql/index.mjs +8 -7
- package/dist/realtime/index.mjs +1 -1
- package/dist/sqlite/index.mjs +4 -9
- package/dist/types/config.d.ts +5 -5
- package/dist/worker/index.mjs +3 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @plitzi/sdk-actions
|
|
2
2
|
|
|
3
|
+
## 0.39.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1922cf: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [f1922cf]
|
|
10
|
+
- @plitzi/sdk-kernel@0.39.14
|
|
11
|
+
- @plitzi/sdk-shared@0.39.14
|
|
12
|
+
|
|
3
13
|
## 0.39.13
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -8,7 +8,6 @@ var KV_METHODS = {
|
|
|
8
8
|
set: true,
|
|
9
9
|
delete: true,
|
|
10
10
|
increment: true,
|
|
11
|
-
expire: true,
|
|
12
11
|
swap: true
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
@@ -67,27 +66,16 @@ var createMapKv = (entries, changed = () => void 0) => {
|
|
|
67
66
|
if (entries.delete(key)) changed();
|
|
68
67
|
return Promise.resolve();
|
|
69
68
|
},
|
|
70
|
-
increment: (key, amount) => {
|
|
69
|
+
increment: (key, amount, ttlSeconds) => {
|
|
71
70
|
const current = read(key);
|
|
72
71
|
const base = Number(current?.value ?? 0);
|
|
73
72
|
const next = (Number.isFinite(base) ? base : 0) + amount;
|
|
74
73
|
write(key, {
|
|
75
74
|
value: String(next),
|
|
76
|
-
expiresAt: current?.expiresAt
|
|
75
|
+
expiresAt: current?.expiresAt ?? expiry(ttlSeconds)
|
|
77
76
|
});
|
|
78
77
|
return Promise.resolve(next);
|
|
79
78
|
},
|
|
80
|
-
expire: (key, ttlSeconds) => {
|
|
81
|
-
const current = read(key);
|
|
82
|
-
if (current) {
|
|
83
|
-
entries.set(key, {
|
|
84
|
-
...current,
|
|
85
|
-
expiresAt: expiry(ttlSeconds)
|
|
86
|
-
});
|
|
87
|
-
changed();
|
|
88
|
-
}
|
|
89
|
-
return Promise.resolve();
|
|
90
|
-
},
|
|
91
79
|
swap: (key, expected, next, ttlSeconds) => {
|
|
92
80
|
if (read(key)?.value !== expected) return Promise.resolve(false);
|
|
93
81
|
write(key, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as buildFunctions } from "./module-
|
|
1
|
+
import { i as buildFunctions } from "./module-RTJHp4G8.mjs";
|
|
2
2
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
3
3
|
import { readFunctionsSource } from "@plitzi/sdk-shared/actions";
|
|
4
4
|
import { readFile, readdir } from "node:fs/promises";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as emptyState, o as queueOver, p as SET_ASIDE_WORDS, r as applyRule, s as queueRules } from "./queueRules-UGZNkho0.mjs";
|
|
2
2
|
import { a as triggerParams, i as findTriggerNode, n as RunLimitReached, r as limitOf, t as ActionRunError } from "./errors-bCBfIe7c.mjs";
|
|
3
|
-
import { i as KV_METHODS, n as MAX_GRANT_SECONDS, o as createMemoryKv, t as DEFAULT_GRANT_SECONDS } from "./grants-
|
|
3
|
+
import { i as KV_METHODS, n as MAX_GRANT_SECONDS, o as createMemoryKv, t as DEFAULT_GRANT_SECONDS } from "./grants-ZR79buug.mjs";
|
|
4
4
|
import { cappedResponse, fetchOutbound, isBlockedHost } from "@plitzi/sdk-kernel/outbound";
|
|
5
5
|
import { BODYLESS_METHODS, DEFAULT_READ_ENDPOINT, EMPTY_RESPONSE_METHODS } from "@plitzi/sdk-shared/connectors";
|
|
6
6
|
import { processTwig, processTwigParam, resolveStepParam } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
@@ -2019,12 +2019,7 @@ var createKvStore = (adapter, { prefix = "kv:" } = {}) => {
|
|
|
2019
2019
|
},
|
|
2020
2020
|
set: (key, value, ttlSeconds) => adapter.set(prefixed(key), JSON.stringify(value), ttlSeconds),
|
|
2021
2021
|
delete: (key) => adapter.delete(prefixed(key)),
|
|
2022
|
-
increment:
|
|
2023
|
-
const full = prefixed(key);
|
|
2024
|
-
const value = await adapter.increment(full, amount);
|
|
2025
|
-
if (ttlSeconds !== void 0 && value === amount) await adapter.expire(full, ttlSeconds);
|
|
2026
|
-
return value;
|
|
2027
|
-
},
|
|
2022
|
+
increment: (key, amount, ttlSeconds) => adapter.increment(prefixed(key), amount, ttlSeconds),
|
|
2028
2023
|
swap: (key, expected, next, ttlSeconds) => adapter.swap(prefixed(key), expected === void 0 ? void 0 : JSON.stringify(expected), JSON.stringify(next), ttlSeconds),
|
|
2029
2024
|
listPut: async (list, entry, options = {}) => {
|
|
2030
2025
|
const problem = listIdProblem(entry.id);
|
|
@@ -19,9 +19,9 @@ export type KvStoreConfig = {
|
|
|
19
19
|
* written by something else is answered as the string it is rather than failing.
|
|
20
20
|
* 2. **A counter's TTL is set once, by whoever created it, and never extended.** A window refreshed on every hit
|
|
21
21
|
* never closes while traffic keeps arriving — which is a rate limit that stops limiting exactly when it is
|
|
22
|
-
* being leant on. The
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* being leant on. The adapter's `increment` gives it in the same atomic step that creates the counter: set in a
|
|
23
|
+
* second step, a store that failed it (a Redis that timed out between `INCRBY` and `EXPIRE`) kept the counter
|
|
24
|
+
* for good, and a rate limit's window never opened again.
|
|
25
25
|
* 3. **Nothing is caught.** This is not a cache: a miss means the rate limit did not count and the idempotency key
|
|
26
26
|
* was not seen, so an adapter that cannot answer fails the run rather than being read as "no value".
|
|
27
27
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ActionKvAdapter } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* The commands this adapter sends, typed by shape rather than by a client library: ioredis answers them as they are,
|
|
4
|
-
* and any client that speaks them does. `eval` is for
|
|
4
|
+
* and any client that speaks them does. `eval` is for what Redis has no single command for: `swap`, and an increment
|
|
5
|
+
* that gives the counter its lifetime in the same step.
|
|
5
6
|
*/
|
|
6
7
|
export type RedisKvClient = {
|
|
7
8
|
get: (key: string) => Promise<string | null>;
|
|
@@ -10,8 +11,6 @@ export type RedisKvClient = {
|
|
|
10
11
|
(key: string, value: string, mode: 'EX', seconds: number): Promise<unknown>;
|
|
11
12
|
};
|
|
12
13
|
del: (key: string) => Promise<number>;
|
|
13
|
-
incrby: (key: string, amount: number) => Promise<number>;
|
|
14
|
-
expire: (key: string, seconds: number) => Promise<number>;
|
|
15
14
|
eval: (script: string, keys: number, ...args: (string | number)[]) => Promise<unknown>;
|
|
16
15
|
};
|
|
17
16
|
export type RedisKvOptions = {
|
|
@@ -19,7 +18,7 @@ export type RedisKvOptions = {
|
|
|
19
18
|
prefix?: string;
|
|
20
19
|
};
|
|
21
20
|
/**
|
|
22
|
-
* An {@link ActionKvAdapter} over Redis: each operation one command, and `swap` one script.
|
|
21
|
+
* An {@link ActionKvAdapter} over Redis: each operation one command, and `swap` and `increment` one script each.
|
|
23
22
|
*
|
|
24
23
|
* `client` may be a function, for a deployment whose connection comes and goes — it is asked on every call, and a
|
|
25
24
|
* client it cannot give is its to refuse (throwing), never this adapter's to read as "no value".
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -52,10 +52,13 @@ export type ActionKvAdapter = {
|
|
|
52
52
|
get: (key: string) => Promise<string | undefined>;
|
|
53
53
|
set: (key: string, value: string, ttlSeconds?: number) => Promise<void>;
|
|
54
54
|
delete: (key: string) => Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Adds to a counter and answers the NEW total, in ONE atomic step — this is what get-then-set cannot be. A counter
|
|
57
|
+
* it creates (absent, or past its lifetime) is given `ttlSeconds` in that same step, and a live one keeps its own —
|
|
58
|
+
* or, holding none, takes `ttlSeconds`. Never a separate step after: a store that failed the second one kept the
|
|
59
|
+
* counter for good (a Redis that timed out between `INCRBY` and `EXPIRE` did).
|
|
60
|
+
*/
|
|
61
|
+
increment: (key: string, amount: number, ttlSeconds?: number) => Promise<number>;
|
|
59
62
|
/**
|
|
60
63
|
* Writes `next` only if the key still holds `expected` — or, with `expected` undefined, only if it holds nothing (a
|
|
61
64
|
* key past its lifetime holds nothing). Answers whether it wrote. Must be atomic: it is what lets two writers
|
package/dist/functions/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as oauthCallbackUrlOn, d as DEFAULT_FUNCTION_LIMITS, i as buildFunctions, l as readManifest, n as functionsInHand, o as DEFAULT_FUNCTION_JOB_LIMITS, r as FunctionsBuildError, t as createActionsModule, u as DEFAULT_FUNCTION_CEILINGS } from "../chunks/module-
|
|
2
|
-
import { i as readFunctionsDir, n as loadFunctions, r as loadFunctionsSource } from "../chunks/load-
|
|
1
|
+
import { c as oauthCallbackUrlOn, d as DEFAULT_FUNCTION_LIMITS, i as buildFunctions, l as readManifest, n as functionsInHand, o as DEFAULT_FUNCTION_JOB_LIMITS, r as FunctionsBuildError, t as createActionsModule, u as DEFAULT_FUNCTION_CEILINGS } from "../chunks/module-RTJHp4G8.mjs";
|
|
2
|
+
import { i as readFunctionsDir, n as loadFunctions, r as loadFunctionsSource } from "../chunks/load-dDkFegMP.mjs";
|
|
3
3
|
import { t as credentialsFromEnv } from "../chunks/credentials-DwxZeAvH.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { FUNCTIONS_PROTOCOL, FunctionFailure, failedAnswerOf, readResponseMessage } from "@plitzi/sdk-shared/functions";
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as schedulesFor, C as fleetJobQueue, D as DEFAULT_MAX_ATTEMPTS, E as createScheduler, I as fetchConnectorRecords, L as rebaseMedia, M as KEPT_CALLS_PER_SPACE, N as KEPT_CALL_MS, O as scheduleFor, R as writeConnectorRecord, T as createJobWorker, _ as DEFAULT_LIMITS, a as createTaskRegistry, b as MAX_LIST_ENTRIES, f as taskName, g as spaceKvPatterns, j as createMemoryJobQueue, k as scheduleJobId, m as createSigning, p as MIN_SIGNING_SECRET_LENGTH, s as jobViewOf, t as createActionsModule, v as createKvStore, w as fleetKv, x as createActionJobs, y as MAX_LIST_BYTES } from "./chunks/module-
|
|
2
|
-
import { n as describeTask, r as createConnectorResolver, t as describeCatalog } from "./chunks/taskCatalog-
|
|
1
|
+
import { A as schedulesFor, C as fleetJobQueue, D as DEFAULT_MAX_ATTEMPTS, E as createScheduler, I as fetchConnectorRecords, L as rebaseMedia, M as KEPT_CALLS_PER_SPACE, N as KEPT_CALL_MS, O as scheduleFor, R as writeConnectorRecord, T as createJobWorker, _ as DEFAULT_LIMITS, a as createTaskRegistry, b as MAX_LIST_ENTRIES, f as taskName, g as spaceKvPatterns, j as createMemoryJobQueue, k as scheduleJobId, m as createSigning, p as MIN_SIGNING_SECRET_LENGTH, s as jobViewOf, t as createActionsModule, v as createKvStore, w as fleetKv, x as createActionJobs, y as MAX_LIST_BYTES } from "./chunks/module-RTJHp4G8.mjs";
|
|
2
|
+
import { n as describeTask, r as createConnectorResolver, t as describeCatalog } from "./chunks/taskCatalog-D3vyVCWp.mjs";
|
|
3
3
|
import { n as stateOf, t as documentOf } from "./chunks/queueDocument-DCBWcxe_.mjs";
|
|
4
4
|
import { a as emptyState, i as changedBy, l as statusCounts, o as queueOver, r as applyRule, s as queueRules } from "./chunks/queueRules-UGZNkho0.mjs";
|
|
5
5
|
import { a as triggerParams, t as ActionRunError } from "./chunks/errors-bCBfIe7c.mjs";
|
|
6
|
-
import { a as createMapKv, o as createMemoryKv } from "./chunks/grants-
|
|
6
|
+
import { a as createMapKv, o as createMemoryKv } from "./chunks/grants-ZR79buug.mjs";
|
|
7
7
|
import { createActionRealtime, n as publishJobView, r as createRealtimeHub, t as createRealtimeRetained } from "./realtime/index.mjs";
|
|
8
8
|
import { t as credentialsFromEnv } from "./chunks/credentials-DwxZeAvH.mjs";
|
|
9
9
|
import { hasValidToken } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
@@ -483,7 +483,19 @@ end
|
|
|
483
483
|
return 1
|
|
484
484
|
`;
|
|
485
485
|
/**
|
|
486
|
-
* An
|
|
486
|
+
* An increment and its lifetime as ONE step: `INCRBY`, then — when the counter holds no lifetime, which is what one it
|
|
487
|
+
* just created holds — `EXPIRE`, with nothing in between. Two commands left the key for good when Redis timed out on
|
|
488
|
+
* the second. A live counter keeps the lifetime it has, so a window never stretches on a hit.
|
|
489
|
+
*/
|
|
490
|
+
var INCREMENT = `
|
|
491
|
+
local total = redis.call('INCRBY', KEYS[1], ARGV[1])
|
|
492
|
+
if ARGV[2] ~= '' and redis.call('TTL', KEYS[1]) == -1 then
|
|
493
|
+
redis.call('EXPIRE', KEYS[1], tonumber(ARGV[2]))
|
|
494
|
+
end
|
|
495
|
+
return total
|
|
496
|
+
`;
|
|
497
|
+
/**
|
|
498
|
+
* An {@link ActionKvAdapter} over Redis: each operation one command, and `swap` and `increment` one script each.
|
|
487
499
|
*
|
|
488
500
|
* `client` may be a function, for a deployment whose connection comes and goes — it is asked on every call, and a
|
|
489
501
|
* client it cannot give is its to refuse (throwing), never this adapter's to read as "no value".
|
|
@@ -499,10 +511,7 @@ var createRedisKv = (client, { prefix = "" } = {}) => {
|
|
|
499
511
|
delete: async (name) => {
|
|
500
512
|
await redis().del(key(name));
|
|
501
513
|
},
|
|
502
|
-
increment: (name, amount) => redis().
|
|
503
|
-
expire: async (name, ttlSeconds) => {
|
|
504
|
-
await redis().expire(key(name), ttlSeconds);
|
|
505
|
-
},
|
|
514
|
+
increment: async (name, amount, ttlSeconds) => Number(await redis().eval(INCREMENT, 1, key(name), amount, ttlSeconds === void 0 ? "" : ttlSeconds)),
|
|
506
515
|
swap: async (name, expected, next, ttlSeconds) => await redis().eval(SWAP, 1, key(name), expected === void 0 ? "absent" : "equals", expected ?? "", next, ttlSeconds === void 0 ? "" : ttlSeconds) === 1
|
|
507
516
|
};
|
|
508
517
|
};
|
package/dist/mongo/index.mjs
CHANGED
|
@@ -840,8 +840,9 @@ var createMongoKv = ({ db, collection = "action_kv" }) => {
|
|
|
840
840
|
delete: async (key) => {
|
|
841
841
|
await (await store()).deleteOne({ _id: key });
|
|
842
842
|
},
|
|
843
|
-
increment: async (key, amount) => {
|
|
843
|
+
increment: async (key, amount, ttlSeconds) => {
|
|
844
844
|
const keysNow = await store();
|
|
845
|
+
const given = ttlSeconds === void 0 ? null : expiryIn(ttlSeconds);
|
|
845
846
|
const updated = await upserting(() => keysNow.findOneAndUpdate({ _id: key }, [
|
|
846
847
|
{ $set: { live: LIVE } },
|
|
847
848
|
{ $set: {
|
|
@@ -857,8 +858,8 @@ var createMongoKv = ({ db, collection = "action_kv" }) => {
|
|
|
857
858
|
] }, amount] } },
|
|
858
859
|
expiresAt: { $cond: [
|
|
859
860
|
"$live",
|
|
860
|
-
{ $ifNull: ["$expiresAt",
|
|
861
|
-
|
|
861
|
+
{ $ifNull: ["$expiresAt", given] },
|
|
862
|
+
given
|
|
862
863
|
] }
|
|
863
864
|
} },
|
|
864
865
|
{ $unset: "live" }
|
|
@@ -868,12 +869,6 @@ var createMongoKv = ({ db, collection = "action_kv" }) => {
|
|
|
868
869
|
}));
|
|
869
870
|
return Number(updated?.value ?? amount);
|
|
870
871
|
},
|
|
871
|
-
expire: async (key, ttlSeconds) => {
|
|
872
|
-
await (await store()).updateOne({
|
|
873
|
-
_id: key,
|
|
874
|
-
$expr: LIVE
|
|
875
|
-
}, [{ $set: { expiresAt: expiryIn(ttlSeconds) } }]);
|
|
876
|
-
},
|
|
877
872
|
/**
|
|
878
873
|
* Each branch is one update Mongo applies to the document atomically. Expecting a value, the filter names it.
|
|
879
874
|
* Expecting nothing is two cases: a lapsed document, taken over by a filter that matches only a lapsed one; and no
|
package/dist/mysql/index.mjs
CHANGED
|
@@ -891,21 +891,25 @@ var createMysqlKv = ({ pool, tablePrefix = "", createTables = true }) => {
|
|
|
891
891
|
delete: async (key) => {
|
|
892
892
|
await execute(await db(), `DELETE FROM ${kv} WHERE k = ?`, [key]);
|
|
893
893
|
},
|
|
894
|
-
increment: async (key, amount) => {
|
|
894
|
+
increment: async (key, amount, ttlSeconds) => {
|
|
895
895
|
const connection = await (await db()).getConnection();
|
|
896
896
|
try {
|
|
897
897
|
await connection.beginTransaction();
|
|
898
898
|
/**
|
|
899
899
|
* `v` FIRST: the assignments run left to right and each sees the ones before it, so the value has to be
|
|
900
900
|
* computed while `expires_at` still says whether the old one is alive. A lapsed counter starts again from
|
|
901
|
-
* zero,
|
|
901
|
+
* zero, with the lifetime it is given; a live one keeps its own, or takes the one given when it has none —
|
|
902
|
+
* in this statement, never one after it. `+ 0` reads the text as a number, as Redis reads its strings.
|
|
902
903
|
*/
|
|
903
|
-
|
|
904
|
+
const expiry = ttlSeconds === void 0 ? "NULL" : `${NOW_MS} + ?`;
|
|
905
|
+
const lifetime = ttlSeconds === void 0 ? [] : [ttlSeconds * 1e3];
|
|
906
|
+
await execute(connection, `INSERT INTO ${kv} (k, v, expires_at) VALUES (?, CAST(? AS CHAR), ${expiry})
|
|
904
907
|
ON DUPLICATE KEY UPDATE
|
|
905
908
|
v = CAST(IF(${LIVE}, (v + 0) + ?, ?) AS CHAR),
|
|
906
|
-
expires_at = IF(${LIVE}, expires_at,
|
|
909
|
+
expires_at = IF(${LIVE}, COALESCE(expires_at, VALUES(expires_at)), VALUES(expires_at))`, [
|
|
907
910
|
key,
|
|
908
911
|
amount,
|
|
912
|
+
...lifetime,
|
|
909
913
|
amount,
|
|
910
914
|
amount
|
|
911
915
|
]);
|
|
@@ -919,9 +923,6 @@ var createMysqlKv = ({ pool, tablePrefix = "", createTables = true }) => {
|
|
|
919
923
|
connection.release();
|
|
920
924
|
}
|
|
921
925
|
},
|
|
922
|
-
expire: async (key, ttlSeconds) => {
|
|
923
|
-
await execute(await db(), `UPDATE ${kv} SET expires_at = ${NOW_MS} + ? WHERE k = ? AND ${LIVE}`, [ttlSeconds * 1e3, key]);
|
|
924
|
-
},
|
|
925
926
|
/**
|
|
926
927
|
* Each branch is ONE statement MySQL applies under the row's lock, so two writers racing for the same key cannot
|
|
927
928
|
* both win. `affectedRows` counts the rows MATCHED because mysql2 connects with `FOUND_ROWS`: without it, writing
|
package/dist/realtime/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as KV_METHODS, o as createMemoryKv, r as createRealtimeGrants } from "../chunks/grants-
|
|
1
|
+
import { i as KV_METHODS, o as createMemoryKv, r as createRealtimeGrants } from "../chunks/grants-ZR79buug.mjs";
|
|
2
2
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
3
3
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
4
4
|
import { accessRefusal } from "@plitzi/sdk-shared/actions";
|
package/dist/sqlite/index.mjs
CHANGED
|
@@ -107,14 +107,13 @@ var createSqliteKv = (options) => {
|
|
|
107
107
|
set: db.prepare(`INSERT INTO ${table} (key, value, expires_at) VALUES (?, ?, ${expiresAt})
|
|
108
108
|
ON CONFLICT (key) DO UPDATE SET value = excluded.value, expires_at = excluded.expires_at`),
|
|
109
109
|
delete: db.prepare(`DELETE FROM ${table} WHERE key = ?`),
|
|
110
|
-
increment: db.prepare(`INSERT INTO ${table} (key, value, expires_at) VALUES (?, ?,
|
|
110
|
+
increment: db.prepare(`INSERT INTO ${table} (key, value, expires_at) VALUES (?, ?, ${expiresAt})
|
|
111
111
|
ON CONFLICT (key) DO UPDATE SET
|
|
112
112
|
value = CASE WHEN ${table}.expires_at IS NOT NULL AND ${table}.expires_at <= ${NOW_MS}
|
|
113
113
|
THEN excluded.value ELSE CAST(${table}.value + ? AS TEXT) END,
|
|
114
114
|
expires_at = CASE WHEN ${table}.expires_at IS NOT NULL AND ${table}.expires_at <= ${NOW_MS}
|
|
115
|
-
THEN
|
|
115
|
+
THEN excluded.expires_at ELSE COALESCE(${table}.expires_at, excluded.expires_at) END
|
|
116
116
|
RETURNING value`),
|
|
117
|
-
expire: db.prepare(`UPDATE ${table} SET expires_at = ${expiresAt} WHERE key = ? AND ${live}`),
|
|
118
117
|
claim: db.prepare(`INSERT INTO ${table} (key, value, expires_at) VALUES (?, ?, ${expiresAt})
|
|
119
118
|
ON CONFLICT (key) DO UPDATE SET value = excluded.value, expires_at = excluded.expires_at
|
|
120
119
|
WHERE ${table}.expires_at IS NOT NULL AND ${table}.expires_at <= ${NOW_MS}`),
|
|
@@ -140,16 +139,12 @@ var createSqliteKv = (options) => {
|
|
|
140
139
|
statements.delete.run(key);
|
|
141
140
|
return Promise.resolve();
|
|
142
141
|
},
|
|
143
|
-
increment: (key, amount) => {
|
|
142
|
+
increment: (key, amount, ttlSeconds) => {
|
|
144
143
|
const step = Number.isInteger(amount) ? BigInt(amount) : amount;
|
|
145
|
-
const value = text(statements.increment.get(key, String(amount), step));
|
|
144
|
+
const value = text(statements.increment.get(key, String(amount), expiry(ttlSeconds), expiry(ttlSeconds), step));
|
|
146
145
|
sweep();
|
|
147
146
|
return Promise.resolve(Number(value ?? amount));
|
|
148
147
|
},
|
|
149
|
-
expire: (key, ttlSeconds) => {
|
|
150
|
-
statements.expire.run(expiry(ttlSeconds), expiry(ttlSeconds), key);
|
|
151
|
-
return Promise.resolve();
|
|
152
|
-
},
|
|
153
148
|
swap: (key, expected, next, ttlSeconds) => {
|
|
154
149
|
const written = expected === void 0 ? statements.claim.run(key, next, expiry(ttlSeconds), expiry(ttlSeconds)) : statements.replace.run(next, expiry(ttlSeconds), expiry(ttlSeconds), key, expected);
|
|
155
150
|
sweep();
|
package/dist/types/config.d.ts
CHANGED
|
@@ -185,9 +185,9 @@ export type SSRActionConfig = {
|
|
|
185
185
|
/**
|
|
186
186
|
* Where the `kv` tasks keep things — shaped as `ActionKvAdapter` in `@plitzi/sdk-actions`.
|
|
187
187
|
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
188
|
+
* Five operations over strings: Redis, Memcached, a table, whatever this deployment already runs. How a counter
|
|
189
|
+
* BEHAVES — the key prefixing, the JSON round trip — belongs to the server; the one rule a store keeps is that an
|
|
190
|
+
* increment gives the counter it creates its lifetime in the same atomic step.
|
|
191
191
|
*
|
|
192
192
|
* Omitted leaves an in-process Map, which counts only its own replica. That is fine for one; for a cluster it is
|
|
193
193
|
* a rate limit that multiplies by the number of them, so a multi-replica deployment supplies a shared one.
|
|
@@ -196,8 +196,8 @@ export type SSRActionConfig = {
|
|
|
196
196
|
get: (key: string) => Promise<string | undefined>;
|
|
197
197
|
set: (key: string, value: string, ttlSeconds?: number) => Promise<void>;
|
|
198
198
|
delete: (key: string) => Promise<void>;
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
/** Adds, atomically; a counter it creates — or one holding no lifetime — is given `ttlSeconds` in the same step. */
|
|
200
|
+
increment: (key: string, amount: number, ttlSeconds?: number) => Promise<number>;
|
|
201
201
|
/** Writes `next` only if the key holds `expected` (nothing, when undefined); answers whether it wrote. Atomic. */
|
|
202
202
|
swap: (key: string, expected: string | undefined, next: string, ttlSeconds?: number) => Promise<boolean>;
|
|
203
203
|
};
|
package/dist/worker/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { handleRealtimePublish, handleRealtimeSocket, handleRealtimeSubscribe, realtimeModuleFor } from "../realtime/index.mjs";
|
|
2
2
|
import { a as createActionResolver, i as readRenderAsk, n as RENDER_PATH, t as createRemoteRenderResolver } from "../chunks/remote-DZSzOO01.mjs";
|
|
3
|
-
import { F as readKeptCall, P as keepCall, R as writeConnectorRecord, S as ACTIONS_FLEET_STORES, h as precheckRun, t as createActionsModule } from "../chunks/module-
|
|
3
|
+
import { F as readKeptCall, P as keepCall, R as writeConnectorRecord, S as ACTIONS_FLEET_STORES, h as precheckRun, t as createActionsModule } from "../chunks/module-RTJHp4G8.mjs";
|
|
4
4
|
import { a as triggerParams, i as findTriggerNode, t as ActionRunError } from "../chunks/errors-bCBfIe7c.mjs";
|
|
5
|
-
import { r as createConnectorResolver, t as describeCatalog } from "../chunks/taskCatalog-
|
|
6
|
-
import { t as isFunctionsDefinition } from "../chunks/load-
|
|
5
|
+
import { r as createConnectorResolver, t as describeCatalog } from "../chunks/taskCatalog-D3vyVCWp.mjs";
|
|
6
|
+
import { t as isFunctionsDefinition } from "../chunks/load-dDkFegMP.mjs";
|
|
7
7
|
import { privateOriginsOf } from "@plitzi/sdk-kernel/outbound";
|
|
8
8
|
import { isConnectorManifestDraft, validateConnectorManifest } from "@plitzi/sdk-shared/connectors";
|
|
9
9
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-actions",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.14",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"description": "The actions engine: server actions, a space's functions and runtimes as the platform holds them, the connectors, realtime, jobs, and the stock queues and stores. What a worker runs; what a page server is handed.",
|
|
6
6
|
"files": [
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"build:prod": "vite build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
41
|
-
"@plitzi/sdk-shared": "0.39.
|
|
40
|
+
"@plitzi/sdk-kernel": "0.39.14",
|
|
41
|
+
"@plitzi/sdk-shared": "0.39.14",
|
|
42
42
|
"nodemailer": "^10.6.0",
|
|
43
43
|
"ws": "^8.23.0"
|
|
44
44
|
},
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@plitzi/sdk-runtime": "0.39.
|
|
62
|
+
"@plitzi/sdk-runtime": "0.39.14",
|
|
63
63
|
"@types/node": "^26.6.6",
|
|
64
64
|
"@types/nodemailer": "^8.0.2",
|
|
65
65
|
"@types/ws": "^8.18.2",
|