@yolean/evidence-sdk 4.2.0 → 4.3.0
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @evidence-dev/sdk
|
|
2
2
|
|
|
3
|
+
## 4.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- db9c0e99d: DuckDB 2.0: sources run on @duckdb/node-api 2.0.0-r.1 and pages on @duckdb/duckdb-wasm 1.33.1-dev118.0, both DuckDB v2.0.0. Division by zero returns NULL and an untyped NULL is an INTEGER, as before. Other DuckDB 2.0 changes apply to source and page SQL, see https://duckdb.org/docs/2.0/operations_manual/migration: the `x -> x + 1` lambda syntax is an error, use `lambda x: x + 1`, and `~` matches part of a string. Browsers need WebAssembly exception handling, as duckdb-wasm no longer has a bundle without it.
|
|
8
|
+
|
|
9
|
+
Page queries run in a configured time zone instead of the browser's UTC offset: `deployment.timeZone`, UTC if not set, or for pages with a data scope the zone `deployment.timeZoneQuery` gives for it. In that zone current_date is its date, a string compared to a timestamptz, like a date range against to_timestamp(...), means its midnight, and timestamptz results show its wall-clock time. Prerendering and the browser use the same zone.
|
|
10
|
+
|
|
11
|
+
## 4.2.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 8b1f45215: Internal dependencies are published as ^ ranges instead of exact versions, so a release of one package no longer leaves its dependents pinned to the previous version.
|
|
16
|
+
|
|
3
17
|
## 4.2.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolean/evidence-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"evidence-sdk": "./src/cli.js"
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@clack/prompts": "^0.7.0",
|
|
90
90
|
"@evidence-dev/icons": "npm:@yolean/evidence-icons@^1.0.3",
|
|
91
91
|
"@evidence-dev/telemetry": "npm:@yolean/evidence-telemetry@^2.1.4",
|
|
92
|
-
"@evidence-dev/universal-sql": "npm:@yolean/evidence-universal-sql
|
|
92
|
+
"@evidence-dev/universal-sql": "npm:@yolean/evidence-universal-sql@^3.2.0",
|
|
93
93
|
"@steeze-ui/simple-icons": "^1.7.1",
|
|
94
94
|
"@steeze-ui/tabler-icons": "^2.1.1",
|
|
95
95
|
"@types/estree": "^1.0.5",
|
|
@@ -14,5 +14,11 @@ export const DeploymentConfigSchema = z.object({
|
|
|
14
14
|
.optional()
|
|
15
15
|
.refine((value) => !value || /^[A-Za-z_][A-Za-z0-9_]*$/.test(value), {
|
|
16
16
|
message: 'dataScope must be a route parameter name'
|
|
17
|
-
})
|
|
17
|
+
}),
|
|
18
|
+
// The IANA time zone page queries run in: current_date, timestamptz values and the strings
|
|
19
|
+
// compared to them; UTC if not set
|
|
20
|
+
timeZone: z.string().optional(),
|
|
21
|
+
// SQL giving a data scope's time zone in its first column, ${scope} being the scope as a
|
|
22
|
+
// string literal; pages whose scope it gives no zone for use timeZone
|
|
23
|
+
timeZoneQuery: z.string().optional()
|
|
18
24
|
});
|
|
@@ -72,3 +72,23 @@ export const addScopedBasePath = (path, scope, config) => {
|
|
|
72
72
|
config
|
|
73
73
|
);
|
|
74
74
|
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The SQL that gives a page's time zone: deployment.timeZoneQuery for the page's data scope, or null
|
|
78
|
+
* @param {string | null} scope
|
|
79
|
+
* @param {import("../../configuration/schemas/config.schema.js").EvidenceConfig} config
|
|
80
|
+
* @example getTimeZoneQuery('org1', config) // "select tz from orgs where slug = 'org1'"
|
|
81
|
+
* @returns {string | null}
|
|
82
|
+
*/
|
|
83
|
+
export const getTimeZoneQuery = (scope, config) => {
|
|
84
|
+
const sql = config.deployment.timeZoneQuery;
|
|
85
|
+
if (!sql || !scope) return null;
|
|
86
|
+
return sql.replaceAll('${scope}', `'${scope.replaceAll("'", "''")}'`);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* deployment.timeZone, the zone of pages without one from deployment.timeZoneQuery, or null for UTC
|
|
91
|
+
* @param {import("../../configuration/schemas/config.schema.js").EvidenceConfig} config
|
|
92
|
+
* @returns {string | null}
|
|
93
|
+
*/
|
|
94
|
+
export const getDefaultTimeZone = (config) => config.deployment.timeZone || null;
|
|
@@ -106,3 +106,26 @@ describe('data scope', () => {
|
|
|
106
106
|
expect(addScopedBasePath('/data/manifest.json', null, scoped)).toBe('/base/data/manifest.json');
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
+
|
|
110
|
+
import { getDefaultTimeZone, getTimeZoneQuery } from './addBasePath.js';
|
|
111
|
+
describe('time zone', () => {
|
|
112
|
+
const zoned = {
|
|
113
|
+
deployment: {
|
|
114
|
+
dataScope: 'orgslug',
|
|
115
|
+
timeZone: 'Europe/Stockholm',
|
|
116
|
+
timeZoneQuery: 'select tz from orgs where slug = ${scope}'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
it('queries the zone of a scope, with the scope as a string literal', () => {
|
|
120
|
+
expect(getTimeZoneQuery('org1', zoned)).toBe("select tz from orgs where slug = 'org1'");
|
|
121
|
+
expect(getTimeZoneQuery("o'1", zoned)).toBe("select tz from orgs where slug = 'o''1'");
|
|
122
|
+
});
|
|
123
|
+
it('has no query for pages without a scope, or without timeZoneQuery', () => {
|
|
124
|
+
expect(getTimeZoneQuery(null, zoned)).toBe(null);
|
|
125
|
+
expect(getTimeZoneQuery('org1', { deployment: {} })).toBe(null);
|
|
126
|
+
});
|
|
127
|
+
it('defaults to timeZone, or null for UTC', () => {
|
|
128
|
+
expect(getDefaultTimeZone(zoned)).toBe('Europe/Stockholm');
|
|
129
|
+
expect(getDefaultTimeZone({ deployment: {} })).toBe(null);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -2,7 +2,9 @@ export * from './inputs.js';
|
|
|
2
2
|
import {
|
|
3
3
|
addBasePath as _addBasePath,
|
|
4
4
|
addScopedBasePath as _addScopedBasePath,
|
|
5
|
-
getDataScope as _getDataScope
|
|
5
|
+
getDataScope as _getDataScope,
|
|
6
|
+
getDefaultTimeZone as _getDefaultTimeZone,
|
|
7
|
+
getTimeZoneQuery as _getTimeZoneQuery
|
|
6
8
|
} from './addBasePath.js';
|
|
7
9
|
import { config } from '$evidence/config';
|
|
8
10
|
/** @type {(path: string) => string} */
|
|
@@ -11,3 +13,7 @@ export const addBasePath = (path) => _addBasePath(path, config);
|
|
|
11
13
|
export const getDataScope = (params) => _getDataScope(params, config);
|
|
12
14
|
/** @type {(path: string, scope: string | null) => string} */
|
|
13
15
|
export const addScopedBasePath = (path, scope) => _addScopedBasePath(path, scope, config);
|
|
16
|
+
/** @type {(scope: string | null) => string | null} */
|
|
17
|
+
export const getTimeZoneQuery = (scope) => _getTimeZoneQuery(scope, config);
|
|
18
|
+
/** @type {() => string | null} */
|
|
19
|
+
export const getDefaultTimeZone = () => _getDefaultTimeZone(config);
|