@byline/core 1.12.1 → 1.12.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/dist/config/config.d.ts +11 -0
- package/dist/config/config.js +13 -3
- package/package.json +2 -2
package/dist/config/config.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { ClientConfig, CollectionAdminConfig, CollectionDefinition, ServerConfig } from '../@types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a collection definition by `path`. Returns `null` either when
|
|
4
|
+
* no config has been registered (e.g. unit tests, isolated tooling) or
|
|
5
|
+
* when a config is registered but doesn't carry a collection at that
|
|
6
|
+
* path. Matches the `T | null` return contract so callers can branch
|
|
7
|
+
* without try/catch.
|
|
8
|
+
*
|
|
9
|
+
* If a caller genuinely *requires* a registered config to proceed, it
|
|
10
|
+
* should reach for `getClientConfig()` / `getServerConfig()` — those
|
|
11
|
+
* still throw the loud "Byline has not been configured" error.
|
|
12
|
+
*/
|
|
2
13
|
export declare const getCollectionDefinition: (path: string) => CollectionDefinition | null;
|
|
3
14
|
export declare const getCollectionAdminConfig: (slug: string) => CollectionAdminConfig | null;
|
|
4
15
|
export declare function defineClientConfig(config: ClientConfig): void;
|
package/dist/config/config.js
CHANGED
|
@@ -31,11 +31,21 @@ function setBylineCoreInstance(core) {
|
|
|
31
31
|
;
|
|
32
32
|
globalThis[BYLINE_CORE] = core;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a collection definition by `path`. Returns `null` either when
|
|
36
|
+
* no config has been registered (e.g. unit tests, isolated tooling) or
|
|
37
|
+
* when a config is registered but doesn't carry a collection at that
|
|
38
|
+
* path. Matches the `T | null` return contract so callers can branch
|
|
39
|
+
* without try/catch.
|
|
40
|
+
*
|
|
41
|
+
* If a caller genuinely *requires* a registered config to proceed, it
|
|
42
|
+
* should reach for `getClientConfig()` / `getServerConfig()` — those
|
|
43
|
+
* still throw the loud "Byline has not been configured" error.
|
|
44
|
+
*/
|
|
34
45
|
export const getCollectionDefinition = (path) => {
|
|
35
46
|
const config = getClientConfigInstance() ?? getServerConfigInstance();
|
|
36
|
-
if (config == null)
|
|
37
|
-
|
|
38
|
-
}
|
|
47
|
+
if (config == null)
|
|
48
|
+
return null;
|
|
39
49
|
return config.collections.find((collection) => collection.path === path) ?? null;
|
|
40
50
|
};
|
|
41
51
|
export const getCollectionAdminConfig = (slug) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/core",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "1.12.
|
|
5
|
+
"version": "1.12.2",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"sharp": "^0.34.5",
|
|
80
80
|
"uuid": "^14.0.0",
|
|
81
81
|
"zod": "^4.4.3",
|
|
82
|
-
"@byline/auth": "1.12.
|
|
82
|
+
"@byline/auth": "1.12.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@biomejs/biome": "2.4.15",
|