@balena/pinejs 19.5.5-build-run-tests-on-utc-66ee275e8d32011a757507940a21747c2a7bdfca-1 → 19.6.0-build-experiment-generated-typings-4b8e0074867bf1874b190c1aaef9d8ac6aad9965-1
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/.pinejs-cache.json +1 -1
- package/.versionbot/CHANGELOG.yml +6 -6
- package/CHANGELOG.md +2 -2
- package/VERSION +1 -1
- package/docker-compose.npm-test.yml +0 -1
- package/out/tasks/index.d.ts +4 -1
- package/out/tasks/index.js.map +1 -1
- package/out/tasks/worker.d.ts +4 -4
- package/package.json +4 -4
- package/src/tasks/index.ts +18 -2
- package/src/tasks/worker.ts +4 -4
@@ -1,15 +1,15 @@
|
|
1
1
|
- commits:
|
2
|
-
- subject:
|
3
|
-
hash:
|
2
|
+
- subject: Infer async task fn callback arguments typing from schema
|
3
|
+
hash: 4b8e0074867bf1874b190c1aaef9d8ac6aad9965
|
4
4
|
body: ""
|
5
5
|
footer:
|
6
|
-
Change-type:
|
7
|
-
change-type:
|
6
|
+
Change-type: minor
|
7
|
+
change-type: minor
|
8
8
|
author: Otavio Jacobi
|
9
9
|
nested: []
|
10
|
-
version: 19.
|
10
|
+
version: 19.6.0
|
11
11
|
title: ""
|
12
|
-
date: 2024-11-
|
12
|
+
date: 2024-11-20T19:11:44.365Z
|
13
13
|
- commits:
|
14
14
|
- subject: Fix async tasks race condition for selecting task to be executed
|
15
15
|
hash: 97936ec9a2b3f5179a9088b6ae3fac14537ed378
|
package/CHANGELOG.md
CHANGED
@@ -4,10 +4,10 @@ All notable changes to this project will be documented in this file
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
-
# v19.
|
7
|
+
# v19.6.0
|
8
8
|
## (2024-11-20)
|
9
9
|
|
10
|
-
*
|
10
|
+
* Infer async task fn callback arguments typing from schema [Otavio Jacobi]
|
11
11
|
|
12
12
|
# v19.5.4
|
13
13
|
## (2024-10-28)
|
package/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
19.
|
1
|
+
19.6.0
|
package/out/tasks/index.d.ts
CHANGED
@@ -4,6 +4,8 @@ import { apiRoot } from './common';
|
|
4
4
|
import type { TaskHandler } from './worker';
|
5
5
|
import { Worker } from './worker';
|
6
6
|
import type TasksModel from './tasks';
|
7
|
+
import type { Task } from './tasks';
|
8
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
7
9
|
export type * from './tasks';
|
8
10
|
declare module '../sbvr-api/sbvr-utils' {
|
9
11
|
interface API {
|
@@ -13,4 +15,5 @@ declare module '../sbvr-api/sbvr-utils' {
|
|
13
15
|
export declare const config: ConfigLoader.Config;
|
14
16
|
export declare let worker: Worker | null;
|
15
17
|
export declare function setup(): Promise<void>;
|
16
|
-
export declare function addTaskHandler(name: string, fn: TaskHandler['fn'], schema?:
|
18
|
+
export declare function addTaskHandler(name: string, fn: TaskHandler<NonNullable<Task['Read']['is_executed_with__parameter_set']>>['fn'], schema?: undefined): void;
|
19
|
+
export declare function addTaskHandler<T extends Schema>(name: string, fn: TaskHandler<FromSchema<NonNullable<T>>>['fn'], schema: T): void;
|
package/out/tasks/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,sBAgFC;AAeD,wCAmBC;AA/JD,wDAA0C;AAC1C,8CAAyD;AACzD,6CAAgD;AAChD,kEAAoD;AAEpD,qCAAwC;AAExC,qCAAkC;AAQlC,MAAM,SAAS,GAAW,OAAO,CAAC,cAAc,CAAC,CAAC;AAGlD,MAAM,OAAO,GAAG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AAG,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CACnE,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAeD,SAAgB,cAAc,CAC7B,IAAY,EACZ,EAEO,EACP,MAAU;IAEV,IAAI,cAAM,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,cAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,sBAAsB,CAAC,CAAC;IACxE,CAAC;IACD,cAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;QACvB,IAAI;QACJ,EAAE;QACF,QAAQ,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,YAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KAC1D,CAAC;AACH,CAAC"}
|
package/out/tasks/worker.d.ts
CHANGED
@@ -3,17 +3,17 @@ import type { AnyObject } from 'pinejs-client-core';
|
|
3
3
|
import { PinejsClient } from '../sbvr-api/sbvr-utils';
|
4
4
|
import type { Task } from './tasks';
|
5
5
|
import type TasksModel from './tasks';
|
6
|
-
interface TaskArgs {
|
6
|
+
interface TaskArgs<T = AnyObject> {
|
7
7
|
api: PinejsClient;
|
8
|
-
params:
|
8
|
+
params: T;
|
9
9
|
}
|
10
10
|
type TaskResponse = Promise<{
|
11
11
|
status: Task['Read']['status'];
|
12
12
|
error?: string;
|
13
13
|
}>;
|
14
|
-
export interface TaskHandler {
|
14
|
+
export interface TaskHandler<T = AnyObject> {
|
15
15
|
name: string;
|
16
|
-
fn: (options: TaskArgs) => TaskResponse;
|
16
|
+
fn: (options: TaskArgs<T>) => TaskResponse;
|
17
17
|
validate?: ValidateFunction;
|
18
18
|
}
|
19
19
|
export declare class Worker {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@balena/pinejs",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.6.0-build-experiment-generated-typings-4b8e0074867bf1874b190c1aaef9d8ac6aad9965-1",
|
4
4
|
"main": "out/server-glue/module",
|
5
5
|
"type": "commonjs",
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"webpack-build": "npm run webpack-browser && npm run webpack-module && npm run webpack-server",
|
21
21
|
"lint": "balena-lint -t tsconfig.dev.json -e js -e ts src build typings Gruntfile.ts && npx tsc --project tsconfig.dev.json --noEmit",
|
22
22
|
"test": "npm run lint && npm run build && npm run webpack-build && npm run test:compose && npm run test:generated-types",
|
23
|
-
"test:compose": "trap 'docker compose -f docker-compose.npm-test.yml down ; echo Stopped ; exit 0' INT; docker compose -f docker-compose.npm-test.yml up -d && sleep 2 && DATABASE_URL=postgres://docker:docker@localhost:5431/postgres PINEJS_WEBRESOURCE_MAXFILESIZE=1000000000 S3_ENDPOINT=http://localhost:43680 S3_ACCESS_KEY=USERNAME S3_SECRET_KEY=PASSWORD S3_STORAGE_ADAPTER_BUCKET=balena-pine-web-resources S3_REGION=us-east-1 PINEJS_QUEUE_CONCURRENCY=1
|
23
|
+
"test:compose": "trap 'docker compose -f docker-compose.npm-test.yml down ; echo Stopped ; exit 0' INT; docker compose -f docker-compose.npm-test.yml up -d && sleep 2 && DATABASE_URL=postgres://docker:docker@localhost:5431/postgres PINEJS_WEBRESOURCE_MAXFILESIZE=1000000000 S3_ENDPOINT=http://localhost:43680 S3_ACCESS_KEY=USERNAME S3_SECRET_KEY=PASSWORD S3_STORAGE_ADAPTER_BUCKET=balena-pine-web-resources S3_REGION=us-east-1 PINEJS_QUEUE_CONCURRENCY=1 npm run mocha",
|
24
24
|
"test:generated-types": "npm run generate-types && git diff --exit-code ./src/sbvr-api/user.ts ./src/migrator/migrations.ts ./src/sbvr-api/dev.ts",
|
25
25
|
"mocha": "TS_NODE_FILES=true mocha",
|
26
26
|
"lint-fix": "balena-lint -t tsconfig.dev.json -e js -e ts --fix src test build typings Gruntfile.ts",
|
@@ -60,6 +60,7 @@
|
|
60
60
|
"deep-freeze": "^0.0.1",
|
61
61
|
"eventemitter3": "^5.0.1",
|
62
62
|
"express-session": "^1.18.1",
|
63
|
+
"json-schema-to-ts": "3.1.1",
|
63
64
|
"lodash": "^4.17.21",
|
64
65
|
"memoizee": "^0.4.17",
|
65
66
|
"pinejs-client-core": "^8.1.1",
|
@@ -91,7 +92,6 @@
|
|
91
92
|
"grunt-ts": "^6.0.0-beta.22",
|
92
93
|
"grunt-webpack": "^7.0.0",
|
93
94
|
"husky": "^9.1.6",
|
94
|
-
"json-schema-to-ts": "^3.1.1",
|
95
95
|
"lint-staged": "^15.2.10",
|
96
96
|
"load-grunt-tasks": "^5.1.0",
|
97
97
|
"mocha": "^10.7.3",
|
@@ -147,6 +147,6 @@
|
|
147
147
|
"recursive": true
|
148
148
|
},
|
149
149
|
"versionist": {
|
150
|
-
"publishedAt": "2024-11-
|
150
|
+
"publishedAt": "2024-11-20T19:11:45.270Z"
|
151
151
|
}
|
152
152
|
}
|
package/src/tasks/index.ts
CHANGED
@@ -8,6 +8,8 @@ import { ajv, apiRoot } from './common';
|
|
8
8
|
import type { TaskHandler } from './worker';
|
9
9
|
import { Worker } from './worker';
|
10
10
|
import type TasksModel from './tasks';
|
11
|
+
import type { Task } from './tasks';
|
12
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
11
13
|
|
12
14
|
export type * from './tasks';
|
13
15
|
|
@@ -127,8 +129,22 @@ export async function setup(): Promise<void> {
|
|
127
129
|
// Register a task handler
|
128
130
|
export function addTaskHandler(
|
129
131
|
name: string,
|
130
|
-
fn: TaskHandler
|
131
|
-
|
132
|
+
fn: TaskHandler<
|
133
|
+
NonNullable<Task['Read']['is_executed_with__parameter_set']>
|
134
|
+
>['fn'],
|
135
|
+
schema?: undefined,
|
136
|
+
): void;
|
137
|
+
export function addTaskHandler<T extends Schema>(
|
138
|
+
name: string,
|
139
|
+
fn: TaskHandler<FromSchema<NonNullable<T>>>['fn'],
|
140
|
+
schema: T,
|
141
|
+
): void;
|
142
|
+
export function addTaskHandler<T extends Schema>(
|
143
|
+
name: string,
|
144
|
+
fn: TaskHandler<
|
145
|
+
NonNullable<Task['Read']['is_executed_with__parameter_set']>
|
146
|
+
>['fn'],
|
147
|
+
schema?: T,
|
132
148
|
): void {
|
133
149
|
if (worker == null) {
|
134
150
|
throw new Error('Database does not support tasks');
|
package/src/tasks/worker.ts
CHANGED
@@ -10,9 +10,9 @@ import { ajv } from './common';
|
|
10
10
|
import type { Task } from './tasks';
|
11
11
|
import type TasksModel from './tasks';
|
12
12
|
|
13
|
-
interface TaskArgs {
|
13
|
+
interface TaskArgs<T = AnyObject> {
|
14
14
|
api: PinejsClient;
|
15
|
-
params:
|
15
|
+
params: T;
|
16
16
|
}
|
17
17
|
|
18
18
|
type TaskResponse = Promise<{
|
@@ -20,9 +20,9 @@ type TaskResponse = Promise<{
|
|
20
20
|
error?: string;
|
21
21
|
}>;
|
22
22
|
|
23
|
-
export interface TaskHandler {
|
23
|
+
export interface TaskHandler<T = AnyObject> {
|
24
24
|
name: string;
|
25
|
-
fn: (options: TaskArgs) => TaskResponse;
|
25
|
+
fn: (options: TaskArgs<T>) => TaskResponse;
|
26
26
|
validate?: ValidateFunction;
|
27
27
|
}
|
28
28
|
|