@driveflux/cms 1.4.7 → 1.4.8

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.
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ export declare const ConfigValidation: z.ZodObject<{
3
+ graphCms: z.ZodObject<{
4
+ devAuthToken: z.ZodString;
5
+ prodAuthToken: z.ZodString;
6
+ projectApi: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ devAuthToken: string;
9
+ prodAuthToken: string;
10
+ projectApi: string;
11
+ }, {
12
+ devAuthToken: string;
13
+ prodAuthToken: string;
14
+ projectApi: string;
15
+ }>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ graphCms: {
18
+ devAuthToken: string;
19
+ prodAuthToken: string;
20
+ projectApi: string;
21
+ };
22
+ }, {
23
+ graphCms: {
24
+ devAuthToken: string;
25
+ prodAuthToken: string;
26
+ projectApi: string;
27
+ };
28
+ }>;
29
+ export type Config = z.infer<typeof ConfigValidation>;
30
+ export declare const getConfig: () => Config;
31
+ export declare let config: Config;
32
+ export declare const setConfig: <Key extends keyof Config>(key: Key, value: Config[Key]) => void;
33
+ export declare const resetConfig: () => {
34
+ graphCms: {
35
+ devAuthToken: string;
36
+ prodAuthToken: string;
37
+ projectApi: string;
38
+ };
39
+ };
40
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;EAM3B,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAErD,eAAO,MAAM,SAAS,QAAO,MAO1B,CAAA;AAEH,eAAO,IAAI,MAAM,EAAE,MAA0D,CAAA;AAE7E,eAAO,MAAM,SAAS,GAAI,GAAG,SAAS,MAAM,MAAM,OAC5C,GAAG,SACD,MAAM,CAAC,GAAG,CAAC,SAGlB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;CAIvB,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,30 @@
1
+ import { initSingleton } from '@driveflux/singleton';
2
+ import { z } from 'zod';
3
+ export var ConfigValidation = z.object({
4
+ graphCms: z.object({
5
+ devAuthToken: z.string(),
6
+ prodAuthToken: z.string(),
7
+ projectApi: z.string()
8
+ })
9
+ });
10
+ export var getConfig = function() {
11
+ return ConfigValidation.parse({
12
+ graphCms: {
13
+ devAuthToken: process.env.GRAPHCMS_AUTH_TOKEN,
14
+ prodAuthToken: process.env.GRAPHCMS_AUTH_TOKEN,
15
+ projectApi: process.env.GRAPHCMS_PROJECT_API
16
+ }
17
+ });
18
+ };
19
+ export var config = initSingleton('backendConfig', function() {
20
+ return getConfig();
21
+ });
22
+ export var setConfig = function(key, value) {
23
+ config[key] = value;
24
+ };
25
+ export var resetConfig = function() {
26
+ config = initSingleton('backendConfig', function() {
27
+ return getConfig();
28
+ }, true);
29
+ return config;
30
+ };
@@ -1,4 +1,4 @@
1
- import { config } from '@driveflux/config/backend';
1
+ import { config } from '../config.js';
2
2
  import { GraphCMS } from './drivers/graphcms.js';
3
3
  // TODO dublicate code in index.ts in the same folder
4
4
  export var getHygraph = function(preview, locale) {
@@ -1,4 +1,4 @@
1
- import { config } from '@driveflux/config/backend';
1
+ import { config } from '../config.js';
2
2
  import { GraphCMS } from './drivers/graphcms.js';
3
3
  // TODO dublicate code in hygrpah.ts in the same folder
4
4
  export var getHygraph = function(preview, locale) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/cms",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -16,10 +16,11 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@driveflux/config": "1.6.2",
19
+ "@driveflux/singleton": "1.5.0",
20
20
  "@driveflux/utils": "3.3.1",
21
21
  "@graphcms/rich-text-types": "^0.5.1",
22
- "p-throttle": "^6.2.0"
22
+ "p-throttle": "^6.2.0",
23
+ "zod": "^3.23.8"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@driveflux/fab": "2.3.3",