@owlmeans/server-job 0.1.18-rc.32 → 0.1.18-rc.34
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/README.md +1 -1
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-job/SKILL.md +1 -1
- package/build/actions/cancel.d.ts +4 -3
- package/build/actions/cancel.d.ts.map +1 -1
- package/build/actions/cancel.js +14 -11
- package/build/actions/cancel.js.map +1 -1
- package/build/actions/get.d.ts +4 -3
- package/build/actions/get.d.ts.map +1 -1
- package/build/actions/get.js +10 -7
- package/build/actions/get.js.map +1 -1
- package/build/actions/list.d.ts +4 -3
- package/build/actions/list.d.ts.map +1 -1
- package/build/actions/list.js +16 -13
- package/build/actions/list.js.map +1 -1
- package/build/actions/watch.d.ts +3 -2
- package/build/actions/watch.d.ts.map +1 -1
- package/build/actions/watch.js +40 -37
- package/build/actions/watch.js.map +1 -1
- package/build/types.d.ts.map +1 -1
- package/build/utils/consts.local.d.ts +5 -0
- package/build/utils/consts.local.d.ts.map +1 -0
- package/build/utils/consts.local.js +5 -0
- package/build/utils/consts.local.js.map +1 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/policy/types.d.ts +11 -0
- package/build/utils/policy/types.d.ts.map +1 -0
- package/build/utils/policy/types.js +2 -0
- package/build/utils/policy/types.js.map +1 -0
- package/build/utils/policy.d.ts +2 -5
- package/build/utils/policy.d.ts.map +1 -1
- package/build/utils/policy.js +9 -7
- package/build/utils/policy.js.map +1 -1
- package/build/utils/types.d.ts +11 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils/view/types.d.ts +13 -0
- package/build/utils/view/types.d.ts.map +1 -0
- package/build/utils/view/types.js +2 -0
- package/build/utils/view/types.js.map +1 -0
- package/build/utils/view.d.ts +3 -17
- package/build/utils/view.d.ts.map +1 -1
- package/build/utils/view.js +86 -88
- package/build/utils/view.js.map +1 -1
- package/package.json +17 -17
- package/src/actions/cancel.ts +10 -5
- package/src/actions/get.ts +10 -5
- package/src/actions/list.ts +19 -13
- package/src/actions/watch.ts +40 -34
- package/src/types.ts +1 -0
- package/src/utils/consts.local.ts +7 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/policy/types.ts +11 -0
- package/src/utils/policy.ts +13 -13
- package/src/utils/types.ts +11 -0
- package/src/utils/view/types.ts +13 -0
- package/src/utils/view.ts +78 -89
- package/tests/view.spec.ts +5 -5
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
55
55
|
your project's skill store (`.agents/skills/`):
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
58
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.49
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/server-job",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.34",
|
|
5
|
+
"generatedAt": "2026-10-05T21:03:06.405Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/server-job
|
|
9
9
|
|
|
10
10
|
**Layer:** Server
|
|
11
|
-
**Install:** `"@owlmeans/server-job": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/server-job": "^0.1.18-rc.34"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
This package is the boundary between technical `@owlmeans/queue` records and the safe
|
|
14
14
|
`@owlmeans/job` contract. `serveJobEntrypoints` requires a `JobExposurePolicy`; there is no default
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { BoundEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
3
|
+
import type { JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Cancel a job and answer with what was cancelled.
|
|
5
6
|
*
|
|
@@ -10,5 +11,5 @@ import type { Context, JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
|
10
11
|
*
|
|
11
12
|
* @throws {UnknownJob}
|
|
12
13
|
*/
|
|
13
|
-
export declare const cancelJob: (protocol: JobEntrypoints['cancel'], opts: JobHandlerOptions) =>
|
|
14
|
+
export declare const cancelJob: (protocol: JobEntrypoints['cancel'], opts: JobHandlerOptions) => BoundEntrypointHandler<EntrypointProtocolDeclaration>;
|
|
14
15
|
//# sourceMappingURL=cancel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../src/actions/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../src/actions/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEzE,OAAO,KAAK,EAAW,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG7E;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,aACV,cAAc,CAAC,QAAQ,CAAC,QAC5B,iBAAiB,KACtB,sBAAsB,CAAC,6BAA6B,CAatD,CAAA"}
|
package/build/actions/cancel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handlers } from '@owlmeans/server-api';
|
|
2
2
|
import { UnknownJob } from '@owlmeans/queue';
|
|
3
|
-
import {
|
|
3
|
+
import { makeJobPolicyHelper } from '../utils/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Cancel a job and answer with what was cancelled.
|
|
6
6
|
*
|
|
@@ -11,14 +11,17 @@ import { jobsOf, readExposedJob } from '../utils/index.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @throws {UnknownJob}
|
|
13
13
|
*/
|
|
14
|
-
export const cancelJob = (protocol, opts) =>
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
export const cancelJob = (protocol, opts) => {
|
|
15
|
+
const policy = makeJobPolicyHelper(opts);
|
|
16
|
+
return handlers().params(protocol, async ({ id }, ctx, req) => {
|
|
17
|
+
const resource = policy.jobsOf(ctx);
|
|
18
|
+
const audience = await opts.policy.audience(req, ctx);
|
|
19
|
+
const record = await policy.readExposedJob(resource, id, audience);
|
|
20
|
+
if (opts.policy.cancel == null || !await opts.policy.cancel(record, audience)) {
|
|
21
|
+
throw new UnknownJob('job');
|
|
22
|
+
}
|
|
23
|
+
const removed = await resource.take(record.id);
|
|
24
|
+
return await opts.policy.map(removed, audience);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
24
27
|
//# sourceMappingURL=cancel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../src/actions/cancel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../src/actions/cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,QAAkC,EAClC,IAAuB,EACgC,EAAE;IACzD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAExC,OAAO,QAAQ,EAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAClE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC9E,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;QAC7B,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAY,CAAC,CAAA;QACxD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/build/actions/get.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { BoundEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
3
|
+
import type { JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* One job.
|
|
5
6
|
*
|
|
6
7
|
* @throws {UnknownJob} for an id that is absent AND for one that belongs to someone else.
|
|
7
8
|
*/
|
|
8
|
-
export declare const getJob: (protocol: JobEntrypoints['get'], opts: JobHandlerOptions) =>
|
|
9
|
+
export declare const getJob: (protocol: JobEntrypoints['get'], opts: JobHandlerOptions) => BoundEntrypointHandler<EntrypointProtocolDeclaration>;
|
|
9
10
|
//# sourceMappingURL=get.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/actions/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/actions/get.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAK,EAAW,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG7E;;;;GAIG;AACH,eAAO,MAAM,MAAM,aACP,cAAc,CAAC,KAAK,CAAC,QACzB,iBAAiB,KACtB,sBAAsB,CAAC,6BAA6B,CAStD,CAAA"}
|
package/build/actions/get.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { handlers } from '@owlmeans/server-api';
|
|
2
|
-
import {
|
|
2
|
+
import { makeJobPolicyHelper } from '../utils/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* One job.
|
|
5
5
|
*
|
|
6
6
|
* @throws {UnknownJob} for an id that is absent AND for one that belongs to someone else.
|
|
7
7
|
*/
|
|
8
|
-
export const getJob = (protocol, opts) =>
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export const getJob = (protocol, opts) => {
|
|
9
|
+
const policy = makeJobPolicyHelper(opts);
|
|
10
|
+
return handlers().params(protocol, async ({ id }, ctx, req) => {
|
|
11
|
+
const resource = policy.jobsOf(ctx);
|
|
12
|
+
const audience = await opts.policy.audience(req, ctx);
|
|
13
|
+
const record = await policy.readExposedJob(resource, id, audience);
|
|
14
|
+
return await opts.policy.map(record, audience);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
14
17
|
//# sourceMappingURL=get.js.map
|
package/build/actions/get.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/actions/get.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/actions/get.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,QAA+B,EAC/B,IAAuB,EACgC,EAAE;IACzD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAExC,OAAO,QAAQ,EAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAClE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/build/actions/list.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { BoundEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
3
|
+
import type { JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* The caller's jobs, newest first.
|
|
5
6
|
*
|
|
@@ -8,5 +9,5 @@ import type { Context, JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
|
8
9
|
* name filters go through the same criteria language as every other resource, so a filter written
|
|
9
10
|
* for this list means the same thing applied to the store the browser holds.
|
|
10
11
|
*/
|
|
11
|
-
export declare const listJobs: (protocol: JobEntrypoints['list'], opts: JobHandlerOptions) =>
|
|
12
|
+
export declare const listJobs: (protocol: JobEntrypoints['list'], opts: JobHandlerOptions) => BoundEntrypointHandler<EntrypointProtocolDeclaration>;
|
|
12
13
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAGzE,OAAO,KAAK,EAAW,cAAc,EAAE,iBAAiB,EAAgB,MAAM,aAAa,CAAA;AAG3F;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,aACT,cAAc,CAAC,MAAM,CAAC,QAC1B,iBAAiB,KACtB,sBAAsB,CAAC,6BAA6B,CAgBtD,CAAA"}
|
package/build/actions/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { handlers } from '@owlmeans/server-api';
|
|
2
|
-
import {
|
|
2
|
+
import { makeJobPolicyHelper } from '../utils/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* The caller's jobs, newest first.
|
|
5
5
|
*
|
|
@@ -8,17 +8,20 @@ import { jobsOf } from '../utils/index.js';
|
|
|
8
8
|
* name filters go through the same criteria language as every other resource, so a filter written
|
|
9
9
|
* for this list means the same thing applied to the store the browser holds.
|
|
10
10
|
*/
|
|
11
|
-
export const listJobs = (protocol, opts) =>
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export const listJobs = (protocol, opts) => {
|
|
12
|
+
const policy = makeJobPolicyHelper(opts);
|
|
13
|
+
return handlers().request(protocol, async (req, ctx) => {
|
|
14
|
+
const resource = policy.jobsOf(ctx);
|
|
15
|
+
const audience = await opts.policy.audience(req, ctx);
|
|
16
|
+
const query = (req.query ?? {});
|
|
17
|
+
const listed = await resource.list(opts.policy.where(audience, query), {
|
|
18
|
+
sort: [{ field: 'createdAt', order: 'desc' }],
|
|
19
|
+
...(query.size != null ? { size: query.size, page: query.page ?? 0 } : {}),
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
...listed,
|
|
23
|
+
items: await Promise.all(listed.items.map(record => opts.policy.map(record, audience))),
|
|
24
|
+
};
|
|
18
25
|
});
|
|
19
|
-
|
|
20
|
-
...listed,
|
|
21
|
-
items: await Promise.all(listed.items.map(record => opts.policy.map(record, audience))),
|
|
22
|
-
};
|
|
23
|
-
});
|
|
26
|
+
};
|
|
24
27
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/actions/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/actions/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAK/C,OAAO,EAAE,mBAAmB,EAAE,M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1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { BoundEntrypointHandler } from '@owlmeans/server-entrypoint';
|
|
2
3
|
import type { JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Push this caller's job lifecycle events down a socket.
|
|
@@ -12,5 +13,5 @@ import type { JobEntrypoints, JobHandlerOptions } from '../types.js';
|
|
|
12
13
|
* attributed by is gone by the time the event arrives, and an unattributable event is dropped
|
|
13
14
|
* rather than fanned out to everyone. Leave completed jobs in place on any queue that is watched.
|
|
14
15
|
*/
|
|
15
|
-
export declare const watchJobs: (protocol: JobEntrypoints['watch'], opts: JobHandlerOptions) =>
|
|
16
|
+
export declare const watchJobs: (protocol: JobEntrypoints['watch'], opts: JobHandlerOptions) => BoundEntrypointHandler<EntrypointProtocolDeclaration>;
|
|
16
17
|
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/actions/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/actions/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAQzE,OAAO,KAAK,EAAW,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAK7E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,aACV,cAAc,CAAC,OAAO,CAAC,QAC3B,iBAAiB,KACtB,sBAAsB,CAAC,6BAA6B,CA4CtD,CAAA"}
|
package/build/actions/watch.js
CHANGED
|
@@ -2,7 +2,7 @@ import { connection } from '@owlmeans/server-socket';
|
|
|
2
2
|
import { MessageType } from '@owlmeans/socket';
|
|
3
3
|
import { JOB_EVENT } from '@owlmeans/job';
|
|
4
4
|
import { logger } from '@owlmeans/log';
|
|
5
|
-
import {
|
|
5
|
+
import { makeJobPolicyHelper } from '../utils/index.js';
|
|
6
6
|
const log = logger('server-job:watch');
|
|
7
7
|
/**
|
|
8
8
|
* Push this caller's job lifecycle events down a socket.
|
|
@@ -16,45 +16,48 @@ const log = logger('server-job:watch');
|
|
|
16
16
|
* attributed by is gone by the time the event arrives, and an unattributable event is dropped
|
|
17
17
|
* rather than fanned out to everyone. Leave completed jobs in place on any queue that is watched.
|
|
18
18
|
*/
|
|
19
|
-
export const watchJobs = (protocol, opts) =>
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (projected != null)
|
|
39
|
-
await conn.notify(JOB_EVENT, projected);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
log.warn('Job watch notify failed', { id: event.id, queue: event.queue, error: e });
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
conn.listen(async (message) => {
|
|
46
|
-
if (typeof message !== 'object') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const msg = message;
|
|
50
|
-
if (msg.type === MessageType.System && msg.event === 'close') {
|
|
19
|
+
export const watchJobs = (protocol, opts) => {
|
|
20
|
+
const policy = makeJobPolicyHelper(opts);
|
|
21
|
+
return connection(protocol, async (conn, ctx, req) => {
|
|
22
|
+
const resource = policy.jobsOf(ctx);
|
|
23
|
+
const audience = await opts.policy.audience(req, ctx);
|
|
24
|
+
const publicIds = new Map();
|
|
25
|
+
const project = async (event) => {
|
|
26
|
+
const record = await resource.load({
|
|
27
|
+
$and: [{ id: event.id }, opts.policy.where(audience, {})],
|
|
28
|
+
});
|
|
29
|
+
if (record != null) {
|
|
30
|
+
const job = await opts.policy.map(record, audience);
|
|
31
|
+
publicIds.set(event.id, job.id);
|
|
32
|
+
return { type: 'upsert', job };
|
|
33
|
+
}
|
|
34
|
+
const id = publicIds.get(event.id);
|
|
35
|
+
return id == null ? null : { type: 'remove', id };
|
|
36
|
+
};
|
|
37
|
+
const unsubscribe = await resource.subscribe(async (event) => {
|
|
51
38
|
try {
|
|
52
|
-
await
|
|
39
|
+
const projected = await project(event);
|
|
40
|
+
if (projected != null)
|
|
41
|
+
await conn.notify(JOB_EVENT, projected);
|
|
53
42
|
}
|
|
54
43
|
catch (e) {
|
|
55
|
-
log.warn('Job watch
|
|
44
|
+
log.warn('Job watch notify failed', { id: event.id, queue: event.queue, error: e });
|
|
56
45
|
}
|
|
57
|
-
}
|
|
46
|
+
});
|
|
47
|
+
conn.listen(async (message) => {
|
|
48
|
+
if (typeof message !== 'object') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const msg = message;
|
|
52
|
+
if (msg.type === MessageType.System && msg.event === 'close') {
|
|
53
|
+
try {
|
|
54
|
+
await unsubscribe();
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
log.warn('Job watch unsubscribe failed', e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
58
61
|
});
|
|
59
|
-
}
|
|
62
|
+
};
|
|
60
63
|
//# sourceMappingURL=watch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/actions/watch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/actions/watch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,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
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE3E,MAAM,WAAW,MAAO,SAAQ,YAAY;IAC1C,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC,EAC1E,eAAe,EAAE,WAAW;CAAI;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB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AG,WAAW;IACpE,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;CAC7B;AAED,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../../src/utils/consts.local.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,eAAO,MAAM,eAAe,QAAS,CAAA;AAErC,eAAO,MAAM,cAAc,aAAqD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../../src/utils/consts.local.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAA;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AAErC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
|
+
import type { JobRecord, QueueResource } from '@owlmeans/queue';
|
|
3
|
+
import type { JobAudience } from '../../types.js';
|
|
4
|
+
/** The queue and the records one set of job handlers may reach, under its exposure policy. */
|
|
5
|
+
export interface JobPolicyHelper<A extends JobAudience = JobAudience> {
|
|
6
|
+
/** The queue these handlers read: the one the options name, else the context's sole queue. */
|
|
7
|
+
jobsOf: <D = unknown, R = unknown>(ctx: BasicContext<BasicConfig>) => QueueResource<D, R>;
|
|
8
|
+
/** Resolve an opaque id without revealing whether it exists outside the current audience. */
|
|
9
|
+
readExposedJob: (resource: QueueResource, id: string, audience: A) => Promise<JobRecord>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,8FAA8F;AAC9F,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAClE,8FAA8F;IAC9F,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,WAAW,CAAC,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACzF,6FAA6F;IAC7F,cAAc,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CACzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/policy/types.ts"],"names":[],"mappings":""}
|
package/build/utils/policy.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
|
-
import type { JobRecord, QueueResource } from '@owlmeans/queue';
|
|
3
1
|
import type { JobAudience, JobHandlerOptions } from '../types.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const readExposedJob: <A extends JobAudience>(resource: QueueResource, id: string, audience: A, opts: JobHandlerOptions<A>) => Promise<JobRecord>;
|
|
2
|
+
import type { JobPolicyHelper } from './policy/types.js';
|
|
3
|
+
export declare const makeJobPolicyHelper: <A extends JobAudience = JobAudience>(opts: JobHandlerOptions<A>) => JobPolicyHelper<A>;
|
|
7
4
|
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAW,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,QAC/D,iBAAiB,CAAC,CAAC,CAAC,KACzB,eAAe,CAAC,CAAC,CAWnB,CAAA"}
|
package/build/utils/policy.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { UnknownJob } from '@owlmeans/queue';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export const makeJobPolicyHelper = (opts) => {
|
|
3
|
+
const jobsOf = (ctx) => ctx.jobs(opts.queue);
|
|
4
|
+
const readExposedJob = async (resource, id, audience) => {
|
|
5
|
+
const record = await opts.policy.lookup(id, audience, resource);
|
|
6
|
+
if (record == null)
|
|
7
|
+
throw new UnknownJob('job');
|
|
8
|
+
return record;
|
|
9
|
+
};
|
|
10
|
+
return { jobsOf, readExposedJob };
|
|
9
11
|
};
|
|
10
12
|
//# sourceMappingURL=policy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/utils/policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAA0B,EACN,EAAE;IACtB,MAAM,MAAM,GAAG,CAA2B,GAA8B,EAAuB,EAAE,CAC9F,GAA0B,CAAC,IAAI,CAAO,IAAI,CAAC,KAAK,CAAC,CAAA;IAEpD,MAAM,cAAc,GAAG,KAAK,EAAE,QAAuB,EAAE,EAAU,EAAE,QAAW,EAAsB,EAAE;QACpG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC/D,IAAI,MAAM,IAAI,IAAI;YAAE,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;QAC/C,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;AACnC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JobJson, PublicJobError } from '@owlmeans/job';
|
|
2
|
+
export interface JobViewFields {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
summary?: string;
|
|
6
|
+
metadata?: Record<string, JobJson>;
|
|
7
|
+
result?: JobJson;
|
|
8
|
+
error?: PublicJobError;
|
|
9
|
+
cancellable?: boolean;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JobJson, JobView, PublicJobError } from '@owlmeans/job';
|
|
2
|
+
import type { JobRecord } from '@owlmeans/queue';
|
|
3
|
+
import type { JobViewFields } from '../types.js';
|
|
4
|
+
/** The public projection of a broker job: nothing crosses the boundary that was not allowlisted. */
|
|
5
|
+
export interface JobViewHelper {
|
|
6
|
+
/** Copy JSON through bounded, prototype-free containers and discard every non-JSON value. */
|
|
7
|
+
sanitizeJobJson: (value: unknown, depth?: number) => JobJson | undefined;
|
|
8
|
+
/** Build a public view from fields an application explicitly allowlisted. */
|
|
9
|
+
jobViewOf: (record: JobRecord, fields: JobViewFields) => JobView;
|
|
10
|
+
/** Safe default for a broker failure; raw reasons and stacks never cross the boundary. */
|
|
11
|
+
publicJobError: (type?: string) => PublicJobError;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/view/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,oGAAoG;AACpG,MAAM,WAAW,aAAa;IAC5B,6FAA6F;IAC7F,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAA;IACxE,6EAA6E;IAC7E,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAA;IAChE,0FAA0F;IAC1F,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,cAAc,CAAA;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/view/types.ts"],"names":[],"mappings":""}
|
package/build/utils/view.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
id: string;
|
|
5
|
-
kind: string;
|
|
6
|
-
summary?: string;
|
|
7
|
-
metadata?: Record<string, JobJson>;
|
|
8
|
-
result?: JobJson;
|
|
9
|
-
error?: PublicJobError;
|
|
10
|
-
cancellable?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/** Copy JSON through bounded, prototype-free containers and discard every non-JSON value. */
|
|
13
|
-
export declare const sanitizeJobJson: (value: unknown, depth?: number) => JobJson | undefined;
|
|
14
|
-
/** Build a public view from fields an application explicitly allowlisted. */
|
|
15
|
-
export declare const jobViewOf: (record: JobRecord, fields: JobViewFields) => JobView;
|
|
16
|
-
/** Safe default for a broker failure; raw reasons and stacks never cross the boundary. */
|
|
17
|
-
export declare const publicJobError: (type?: string) => PublicJobError;
|
|
1
|
+
import type { JobViewHelper } from './view/types.js';
|
|
2
|
+
export declare const createJobViewHelper: () => JobViewHelper;
|
|
3
|
+
export declare const jobViewHelper: JobViewHelper;
|
|
18
4
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/utils/view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/utils/view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,eAAO,MAAM,mBAAmB,QAAO,aAkFtC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA"}
|