payload 3.0.0-beta.96 → 3.0.0-beta.97
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/admin/RichText.d.ts +2 -2
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Tab.d.ts +1 -1
- package/dist/admin/elements/Tab.d.ts.map +1 -1
- package/dist/admin/elements/Tab.js.map +1 -1
- package/dist/admin/forms/Description.d.ts +1 -1
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Error.d.ts +1 -1
- package/dist/admin/forms/Error.d.ts.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +1 -1
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +1 -1
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/types.d.ts +5 -5
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/types.d.ts +1 -1
- package/dist/admin/views/types.d.ts.map +1 -1
- package/dist/admin/views/types.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +1 -1
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/types.d.ts +5 -5
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
- package/dist/bin/generateTypes.js +1 -1
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/collections/config/client.d.ts +2 -2
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/types.d.ts +9 -9
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +1 -1
- package/dist/collections/operations/utils.d.ts.map +1 -1
- package/dist/collections/operations/utils.js.map +1 -1
- package/dist/config/client.d.ts +2 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/types.d.ts +49 -33
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/combineQueries.d.ts +1 -1
- package/dist/database/combineQueries.d.ts.map +1 -1
- package/dist/database/combineQueries.js.map +1 -1
- package/dist/database/types.d.ts +3 -3
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/fields/config/sanitize.js +1 -1
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/types.d.ts +56 -56
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +2 -2
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +2 -2
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -2
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +2 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/validations.d.ts +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/isReactComponent.d.ts +3 -3
- package/dist/utilities/isReactComponent.d.ts.map +1 -1
- package/dist/utilities/isReactComponent.js.map +1 -1
- package/dist/utilities/isValidID.d.ts +1 -1
- package/dist/utilities/isValidID.d.ts.map +1 -1
- package/dist/utilities/isValidID.js.map +1 -1
- package/dist/utilities/logger.d.ts +8 -3
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js +22 -14
- package/dist/utilities/logger.js.map +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/index.js +8 -8
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.js +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.js.map +1 -1
- package/dist/versions/types.d.ts +4 -4
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/isValidID.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\nexport const isValidID = (\n value: number | string,\n type: '
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/isValidID.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\nexport const isValidID = (\n value: number | string,\n type: 'number' | 'ObjectID' | 'text',\n): boolean => {\n if (type === 'text' && value) {\n if (['object', 'string'].includes(typeof value)) {\n const isObjectID = ObjectId.isValid(value as string)\n return typeof value === 'string' || isObjectID\n }\n return false\n }\n\n if (typeof value === 'number' && !Number.isNaN(value)) {\n return true\n }\n\n if (type === 'ObjectID') {\n return ObjectId.isValid(String(value))\n }\n}\n"],"names":["ObjectIdImport","ObjectId","default","isValidID","value","type","includes","isObjectID","isValid","Number","isNaN","String"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAE1C,MAAMC,WAAYD,eAAeE,OAAO,IACtCF;AAEF,OAAO,MAAMG,YAAY,CACvBC,OACAC;IAEA,IAAIA,SAAS,UAAUD,OAAO;QAC5B,IAAI;YAAC;YAAU;SAAS,CAACE,QAAQ,CAAC,OAAOF,QAAQ;YAC/C,MAAMG,aAAaN,SAASO,OAAO,CAACJ;YACpC,OAAO,OAAOA,UAAU,YAAYG;QACtC;QACA,OAAO;IACT;IAEA,IAAI,OAAOH,UAAU,YAAY,CAACK,OAAOC,KAAK,CAACN,QAAQ;QACrD,OAAO;IACT;IAEA,IAAIC,SAAS,YAAY;QACvB,OAAOJ,SAASO,OAAO,CAACG,OAAOP;IACjC;AACF,EAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Logger } from 'pino';
|
|
2
|
+
import type { Config } from '../config/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Payload internal logger. Uses Pino.
|
|
5
|
+
* This allows you to bring your own logger instance and let payload use it
|
|
6
|
+
*/
|
|
2
7
|
export type PayloadLogger = Logger;
|
|
3
|
-
export declare const defaultLoggerOptions: LoggerOptions;
|
|
4
8
|
export declare const prettySyncLoggerDestination: import("pino-pretty").default.PrettyStream;
|
|
5
|
-
export declare const
|
|
9
|
+
export declare const defaultLoggerOptions: import("pino-pretty").default.PrettyStream;
|
|
10
|
+
export declare const getLogger: (name?: string, logger?: Config["logger"]) => PayloadLogger;
|
|
6
11
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utilities/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utilities/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAA;AAQlC,eAAO,MAAM,2BAA2B,4CAItC,CAAA;AAEF,eAAO,MAAM,oBAAoB,4CAAuB,CAAA;AAExD,eAAO,MAAM,SAAS,2BAA+B,MAAM,CAAC,QAAQ,CAAC,KAAG,aA2BvE,CAAA"}
|
package/dist/utilities/logger.js
CHANGED
|
@@ -5,26 +5,34 @@ const prettyOptions = {
|
|
|
5
5
|
ignore: 'pid,hostname',
|
|
6
6
|
translateTime: 'SYS:HH:MM:ss'
|
|
7
7
|
};
|
|
8
|
-
export const defaultLoggerOptions = {
|
|
9
|
-
transport: {
|
|
10
|
-
options: prettyOptions,
|
|
11
|
-
target: 'pino-pretty'
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
8
|
export const prettySyncLoggerDestination = build({
|
|
15
9
|
...prettyOptions,
|
|
16
10
|
destination: 1,
|
|
17
11
|
sync: true
|
|
18
12
|
});
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
export const defaultLoggerOptions = build(prettyOptions);
|
|
14
|
+
export const getLogger = (name = 'payload', logger)=>{
|
|
15
|
+
if (!logger) {
|
|
16
|
+
return pino(defaultLoggerOptions);
|
|
17
|
+
}
|
|
18
|
+
// Synchronous logger used by bin scripts
|
|
19
|
+
if (logger === 'sync') {
|
|
20
|
+
return pino(prettySyncLoggerDestination);
|
|
21
|
+
}
|
|
22
|
+
// Check if logger is an object
|
|
23
|
+
if ('options' in logger) {
|
|
24
|
+
const { destination, options } = logger;
|
|
25
|
+
if (!options.name) {
|
|
26
|
+
options.name = name;
|
|
27
|
+
}
|
|
28
|
+
if (!options.enabled) {
|
|
29
|
+
options.enabled = process.env.DISABLE_LOGGING !== 'true';
|
|
30
|
+
}
|
|
31
|
+
return pino(options, destination);
|
|
32
|
+
} else {
|
|
33
|
+
// Instantiated logger
|
|
34
|
+
return logger;
|
|
26
35
|
}
|
|
27
|
-
return pino(prettySyncLoggerDestination);
|
|
28
36
|
};
|
|
29
37
|
|
|
30
38
|
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/logger.ts"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/logger.ts"],"sourcesContent":["import { type Logger, pino } from 'pino'\nimport { build, type PrettyOptions } from 'pino-pretty'\n\nimport type { Config } from '../config/types.js'\n\n/**\n * Payload internal logger. Uses Pino.\n * This allows you to bring your own logger instance and let payload use it\n */\nexport type PayloadLogger = Logger\n\nconst prettyOptions: PrettyOptions = {\n colorize: true,\n ignore: 'pid,hostname',\n translateTime: 'SYS:HH:MM:ss',\n}\n\nexport const prettySyncLoggerDestination = build({\n ...prettyOptions,\n destination: 1, // stdout\n sync: true,\n})\n\nexport const defaultLoggerOptions = build(prettyOptions)\n\nexport const getLogger = (name = 'payload', logger?: Config['logger']): PayloadLogger => {\n if (!logger) {\n return pino(defaultLoggerOptions)\n }\n\n // Synchronous logger used by bin scripts\n if (logger === 'sync') {\n return pino(prettySyncLoggerDestination)\n }\n\n // Check if logger is an object\n if ('options' in logger) {\n const { destination, options } = logger\n\n if (!options.name) {\n options.name = name\n }\n\n if (!options.enabled) {\n options.enabled = process.env.DISABLE_LOGGING !== 'true'\n }\n\n return pino(options, destination)\n } else {\n // Instantiated logger\n return logger\n }\n}\n"],"names":["pino","build","prettyOptions","colorize","ignore","translateTime","prettySyncLoggerDestination","destination","sync","defaultLoggerOptions","getLogger","name","logger","options","enabled","process","env","DISABLE_LOGGING"],"mappings":"AAAA,SAAsBA,IAAI,QAAQ,OAAM;AACxC,SAASC,KAAK,QAA4B,cAAa;AAUvD,MAAMC,gBAA+B;IACnCC,UAAU;IACVC,QAAQ;IACRC,eAAe;AACjB;AAEA,OAAO,MAAMC,8BAA8BL,MAAM;IAC/C,GAAGC,aAAa;IAChBK,aAAa;IACbC,MAAM;AACR,GAAE;AAEF,OAAO,MAAMC,uBAAuBR,MAAMC,eAAc;AAExD,OAAO,MAAMQ,YAAY,CAACC,OAAO,SAAS,EAAEC;IAC1C,IAAI,CAACA,QAAQ;QACX,OAAOZ,KAAKS;IACd;IAEA,yCAAyC;IACzC,IAAIG,WAAW,QAAQ;QACrB,OAAOZ,KAAKM;IACd;IAEA,+BAA+B;IAC/B,IAAI,aAAaM,QAAQ;QACvB,MAAM,EAAEL,WAAW,EAAEM,OAAO,EAAE,GAAGD;QAEjC,IAAI,CAACC,QAAQF,IAAI,EAAE;YACjBE,QAAQF,IAAI,GAAGA;QACjB;QAEA,IAAI,CAACE,QAAQC,OAAO,EAAE;YACpBD,QAAQC,OAAO,GAAGC,QAAQC,GAAG,CAACC,eAAe,KAAK;QACpD;QAEA,OAAOjB,KAAKa,SAASN;IACvB,OAAO;QACL,sBAAsB;QACtB,OAAOK;IACT;AACF,EAAC"}
|
|
@@ -20,7 +20,6 @@ export declare class Conf<T extends Record<string, any> = Record<string, unknown
|
|
|
20
20
|
constructor();
|
|
21
21
|
private _ensureDirectory;
|
|
22
22
|
private _write;
|
|
23
|
-
[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
|
|
24
23
|
/**
|
|
25
24
|
Delete an item.
|
|
26
25
|
|
|
@@ -40,6 +39,7 @@ export declare class Conf<T extends Record<string, any> = Record<string, unknown
|
|
|
40
39
|
@param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.
|
|
41
40
|
*/
|
|
42
41
|
set<Key extends keyof T>(key: string, value?: T[Key] | unknown): void;
|
|
42
|
+
[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
|
|
43
43
|
get size(): number;
|
|
44
44
|
get store(): T;
|
|
45
45
|
set store(value: T);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/conf/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsBH,qBAAa,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACvE,YAAW,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;IAG1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+C;IAC5E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkE;IAE7F,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAE5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;;IA6BrB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/conf/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsBH,qBAAa,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACvE,YAAW,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;IAG1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+C;IAC5E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkE;IAE7F,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAE5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;;IA6BrB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,MAAM;IAMd;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAOzB;;;;OAIG;IACH,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;IAK1C;;;;;OAKG;IACH,GAAG,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI;IA8BpE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAK7D,IAAI,IAAI,IAAI,MAAM,CAEjB;IACD,IAAI,KAAK,IAAI,CAAC,CAab;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,EAMjB;CACF;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAEhC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAA;AAC/C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,CAAA"}
|
|
@@ -66,14 +66,6 @@ export class Conf {
|
|
|
66
66
|
mode: this.#options.configFileMode
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
*[Symbol.iterator]() {
|
|
70
|
-
for (const [key, value] of Object.entries(this.store)){
|
|
71
|
-
yield [
|
|
72
|
-
key,
|
|
73
|
-
value
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
69
|
/**
|
|
78
70
|
Delete an item.
|
|
79
71
|
|
|
@@ -118,6 +110,14 @@ export class Conf {
|
|
|
118
110
|
}
|
|
119
111
|
this.store = store;
|
|
120
112
|
}
|
|
113
|
+
*[Symbol.iterator]() {
|
|
114
|
+
for (const [key, value] of Object.entries(this.store)){
|
|
115
|
+
yield [
|
|
116
|
+
key,
|
|
117
|
+
value
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
121
|
get size() {
|
|
122
122
|
return Object.keys(this.store).length;
|
|
123
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/telemetry/conf/index.ts"],"sourcesContent":["/**\n * Taken & simplified from https://github.com/sindresorhus/conf/blob/main/source/index.ts\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport assert from 'node:assert'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { envPaths } from './envPaths.js'\n\nconst createPlainObject = <T = Record<string, unknown>>(): T => Object.create(null)\n\nconst checkValueType = (key: string, value: unknown): void => {\n const nonJsonTypes = new Set(['undefined', 'symbol', 'function'])\n\n const type = typeof value\n\n if (nonJsonTypes.has(type)) {\n throw new TypeError(\n `Setting a value of type \\`${type}\\` for key \\`${key}\\` is not allowed as it's not supported by JSON`,\n )\n }\n}\n\nexport class Conf<T extends Record<string, any> = Record<string, unknown>>\n implements Iterable<[keyof T, T[keyof T]]>\n{\n readonly #options: Readonly<Partial<Options>>\n private readonly _deserialize: Deserialize<T> = (value) => JSON.parse(value)\n private readonly _serialize: Serialize<T> = (value) => JSON.stringify(value, undefined, '\\t')\n\n readonly events: EventTarget\n\n readonly path: string\n\n constructor() {\n const options: Partial<Options> = {\n configFileMode: 0o666,\n configName: 'config',\n fileExtension: 'json',\n projectSuffix: 'nodejs',\n }\n\n const cwd = envPaths('payload', { suffix: options.projectSuffix }).config\n\n this.#options = options\n\n this.events = new EventTarget()\n\n const fileExtension = options.fileExtension ? `.${options.fileExtension}` : ''\n this.path = path.resolve(cwd, `${options.configName ?? 'config'}${fileExtension}`)\n\n const fileStore = this.store\n const store = Object.assign(createPlainObject(), fileStore)\n\n try {\n assert.deepEqual(fileStore, store)\n } catch {\n this.store = store\n }\n }\n\n private _ensureDirectory(): void {\n // Ensure the directory exists as it could have been deleted in the meantime.\n fs.mkdirSync(path.dirname(this.path), { recursive: true })\n }\n\n private _write(value: T): void {\n const data: Uint8Array | string = this._serialize(value)\n\n fs.writeFileSync(this.path, data, { mode: this.#options.configFileMode })\n }\n\n *[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]> {\n for (const [key, value] of Object.entries(this.store)) {\n yield [key, value]\n }\n }\n\n /**\n Delete an item.\n\n @param key - The key of the item to delete.\n */\n delete(key: string): void {\n const { store } = this\n delete store[key]\n\n this.store = store\n }\n\n /**\n Get an item.\n\n @param key - The key of the item to get.\n */\n get<Key extends keyof T>(key: Key): T[Key] {\n const { store } = this\n return store[key]\n }\n\n /**\n Set an item or multiple items at once.\n\n @param key - You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or a hashmap of items to set at once.\n @param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.\n */\n set<Key extends keyof T>(key: string, value?: T[Key] | unknown): void {\n if (typeof key !== 'string' && typeof key !== 'object') {\n throw new TypeError(\n `Expected \\`key\\` to be of type \\`string\\` or \\`object\\`, got ${typeof key}`,\n )\n }\n\n if (typeof key !== 'object' && value === undefined) {\n throw new TypeError('Use `delete()` to clear values')\n }\n\n const { store } = this\n\n const set = (key: string, value?: T | T[Key] | unknown): void => {\n checkValueType(key, value)\n store[key as Key] = value as T[Key]\n }\n\n if (typeof key === 'object') {\n const object = key\n for (const [key, value] of Object.entries(object)) {\n set(key, value)\n }\n } else {\n set(key, value)\n }\n\n this.store = store\n }\n get size(): number {\n return Object.keys(this.store).length\n }\n get store(): T {\n try {\n const dataString = fs.readFileSync(this.path, 'utf8')\n const deserializedData = this._deserialize(dataString)\n return Object.assign(createPlainObject(), deserializedData)\n } catch (error: unknown) {\n if ((error as any)?.code === 'ENOENT') {\n this._ensureDirectory()\n return createPlainObject()\n }\n\n throw error\n }\n }\n\n set store(value: T) {\n this._ensureDirectory()\n\n this._write(value)\n\n this.events.dispatchEvent(new Event('change'))\n }\n}\n\nexport type Options = {\n /**\n The config is cleared if reading the config file causes a `SyntaxError`. This is a good behavior for unimportant data, as the config file is not intended to be hand-edited, so it usually means the config is corrupt and there's nothing the user can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be more useful to throw an error when the config is invalid instead of clearing.\n\n @default false\n */\n clearInvalidConfig?: boolean\n\n /**\n The [mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) that will be used for the config file.\n\n You would usually not need this, but it could be useful if you want to restrict the permissions of the config file. Setting a permission such as `0o600` would result in a config file that can only be accessed by the user running the program.\n\n Note that setting restrictive permissions can cause problems if different users need to read the file. A common problem is a user running your tool with and without `sudo` and then not being able to access the config the second time.\n\n @default 0o666\n */\n readonly configFileMode?: number\n\n /**\n Name of the config file (without extension).\n\n Useful if you need multiple config files for your app or module. For example, different config files between two major versions.\n\n @default 'config'\n */\n configName?: string\n\n /**\n Extension of the config file.\n\n You would usually not need this, but could be useful if you want to interact with a file with a custom file extension that can be associated with your app. These might be simple save/export/preference files that are intended to be shareable or saved outside of the app.\n\n @default 'json'\n */\n fileExtension?: string\n\n readonly projectSuffix?: string\n}\n\nexport type Serialize<T> = (value: T) => string\nexport type Deserialize<T> = (text: string) => T\n"],"names":["assert","fs","path","envPaths","createPlainObject","Object","create","checkValueType","key","value","nonJsonTypes","Set","type","has","TypeError","Conf","_deserialize","JSON","parse","_serialize","stringify","undefined","events","constructor","options","configFileMode","configName","fileExtension","projectSuffix","cwd","suffix","config","EventTarget","resolve","fileStore","store","assign","deepEqual","_ensureDirectory","mkdirSync","dirname","recursive","_write","data","writeFileSync","mode","Symbol","iterator","entries","delete","get","set","object","size","keys","length","dataString","readFileSync","deserializedData","error","code","dispatchEvent","Event"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,OAAOA,YAAY,cAAa;AAChC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAASC,QAAQ,QAAQ,gBAAe;AAExC,MAAMC,oBAAoB,IAAsCC,OAAOC,MAAM,CAAC;AAE9E,MAAMC,iBAAiB,CAACC,KAAaC;IACnC,MAAMC,eAAe,IAAIC,IAAI;QAAC;QAAa;QAAU;KAAW;IAEhE,MAAMC,OAAO,OAAOH;IAEpB,IAAIC,aAAaG,GAAG,CAACD,OAAO;QAC1B,MAAM,IAAIE,UACR,CAAC,0BAA0B,EAAEF,KAAK,aAAa,EAAEJ,IAAI,+CAA+C,CAAC;IAEzG;AACF;AAEA,OAAO,MAAMO;IAGF,CAAA,OAAQ,CAA4B;IAC5BC,eAA+B,CAACP,QAAUQ,KAAKC,KAAK,CAACT,OAAM;IAC3DU,aAA2B,CAACV,QAAUQ,KAAKG,SAA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qBAAqBsD;QAC5C,EAAE,OAAOC,OAAgB;YACvB,IAAI,AAACA,OAAeC,SAAS,UAAU;gBACrC,IAAI,CAACtB,gBAAgB;gBACrB,OAAOlC;YACT;YAEA,MAAMuD;QACR;IACF;IAEA,IAAIxB,MAAM1B,KAAQ,EAAE;QAClB,IAAI,CAAC6B,gBAAgB;QAErB,IAAI,CAACI,MAAM,CAACjC;QAEZ,IAAI,CAACa,MAAM,CAACuC,aAAa,CAAC,IAAIC,MAAM;IACtC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/telemetry/conf/index.ts"],"sourcesContent":["/**\n * Taken & simplified from https://github.com/sindresorhus/conf/blob/main/source/index.ts\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport assert from 'node:assert'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { envPaths } from './envPaths.js'\n\nconst createPlainObject = <T = Record<string, unknown>>(): T => Object.create(null)\n\nconst checkValueType = (key: string, value: unknown): void => {\n const nonJsonTypes = new Set(['undefined', 'symbol', 'function'])\n\n const type = typeof value\n\n if (nonJsonTypes.has(type)) {\n throw new TypeError(\n `Setting a value of type \\`${type}\\` for key \\`${key}\\` is not allowed as it's not supported by JSON`,\n )\n }\n}\n\nexport class Conf<T extends Record<string, any> = Record<string, unknown>>\n implements Iterable<[keyof T, T[keyof T]]>\n{\n readonly #options: Readonly<Partial<Options>>\n private readonly _deserialize: Deserialize<T> = (value) => JSON.parse(value)\n private readonly _serialize: Serialize<T> = (value) => JSON.stringify(value, undefined, '\\t')\n\n readonly events: EventTarget\n\n readonly path: string\n\n constructor() {\n const options: Partial<Options> = {\n configFileMode: 0o666,\n configName: 'config',\n fileExtension: 'json',\n projectSuffix: 'nodejs',\n }\n\n const cwd = envPaths('payload', { suffix: options.projectSuffix }).config\n\n this.#options = options\n\n this.events = new EventTarget()\n\n const fileExtension = options.fileExtension ? `.${options.fileExtension}` : ''\n this.path = path.resolve(cwd, `${options.configName ?? 'config'}${fileExtension}`)\n\n const fileStore = this.store\n const store = Object.assign(createPlainObject(), fileStore)\n\n try {\n assert.deepEqual(fileStore, store)\n } catch {\n this.store = store\n }\n }\n\n private _ensureDirectory(): void {\n // Ensure the directory exists as it could have been deleted in the meantime.\n fs.mkdirSync(path.dirname(this.path), { recursive: true })\n }\n\n private _write(value: T): void {\n const data: string | Uint8Array = this._serialize(value)\n\n fs.writeFileSync(this.path, data, { mode: this.#options.configFileMode })\n }\n\n /**\n Delete an item.\n\n @param key - The key of the item to delete.\n */\n delete(key: string): void {\n const { store } = this\n delete store[key]\n\n this.store = store\n }\n\n /**\n Get an item.\n\n @param key - The key of the item to get.\n */\n get<Key extends keyof T>(key: Key): T[Key] {\n const { store } = this\n return store[key]\n }\n\n /**\n Set an item or multiple items at once.\n\n @param key - You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or a hashmap of items to set at once.\n @param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.\n */\n set<Key extends keyof T>(key: string, value?: T[Key] | unknown): void {\n if (typeof key !== 'string' && typeof key !== 'object') {\n throw new TypeError(\n `Expected \\`key\\` to be of type \\`string\\` or \\`object\\`, got ${typeof key}`,\n )\n }\n\n if (typeof key !== 'object' && value === undefined) {\n throw new TypeError('Use `delete()` to clear values')\n }\n\n const { store } = this\n\n const set = (key: string, value?: T | T[Key] | unknown): void => {\n checkValueType(key, value)\n store[key as Key] = value as T[Key]\n }\n\n if (typeof key === 'object') {\n const object = key\n for (const [key, value] of Object.entries(object)) {\n set(key, value)\n }\n } else {\n set(key, value)\n }\n\n this.store = store\n }\n\n *[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]> {\n for (const [key, value] of Object.entries(this.store)) {\n yield [key, value]\n }\n }\n get size(): number {\n return Object.keys(this.store).length\n }\n get store(): T {\n try {\n const dataString = fs.readFileSync(this.path, 'utf8')\n const deserializedData = this._deserialize(dataString)\n return Object.assign(createPlainObject(), deserializedData)\n } catch (error: unknown) {\n if ((error as any)?.code === 'ENOENT') {\n this._ensureDirectory()\n return createPlainObject()\n }\n\n throw error\n }\n }\n\n set store(value: T) {\n this._ensureDirectory()\n\n this._write(value)\n\n this.events.dispatchEvent(new Event('change'))\n }\n}\n\nexport type Options = {\n /**\n The config is cleared if reading the config file causes a `SyntaxError`. This is a good behavior for unimportant data, as the config file is not intended to be hand-edited, so it usually means the config is corrupt and there's nothing the user can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be more useful to throw an error when the config is invalid instead of clearing.\n\n @default false\n */\n clearInvalidConfig?: boolean\n\n /**\n The [mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) that will be used for the config file.\n\n You would usually not need this, but it could be useful if you want to restrict the permissions of the config file. Setting a permission such as `0o600` would result in a config file that can only be accessed by the user running the program.\n\n Note that setting restrictive permissions can cause problems if different users need to read the file. A common problem is a user running your tool with and without `sudo` and then not being able to access the config the second time.\n\n @default 0o666\n */\n readonly configFileMode?: number\n\n /**\n Name of the config file (without extension).\n\n Useful if you need multiple config files for your app or module. For example, different config files between two major versions.\n\n @default 'config'\n */\n configName?: string\n\n /**\n Extension of the config file.\n\n You would usually not need this, but could be useful if you want to interact with a file with a custom file extension that can be associated with your app. These might be simple save/export/preference files that are intended to be shareable or saved outside of the app.\n\n @default 'json'\n */\n fileExtension?: string\n\n readonly projectSuffix?: string\n}\n\nexport type Serialize<T> = (value: T) => string\nexport type Deserialize<T> = (text: string) => T\n"],"names":["assert","fs","path","envPaths","createPlainObject","Object","create","checkValueType","key","value","nonJsonTypes","Set","type","has","TypeError","Conf","_deserialize","JSON","parse","_serialize","stringify","undefined","events","constructor","options","configFileMode","configName","fileExtension","projectSuffix","cwd","suffix","config","EventTarget","resolve","fileStore","store","assign","deepEqual","_ensureDirectory","mkdirSync","dirname","recursive","_write","data","writeFileSync","mode","delete","get","set","object","entries","Symbol","iterator","size","keys","length","dataString","readFileSync","deserializedData","error","code","dispatchEvent","Event"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,OAAOA,YAAY,cAAa;AAChC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAASC,QAAQ,QAAQ,gBAAe;AAExC,MAAMC,oBAAoB,IAAsCC,OAAOC,MAAM,CAAC;AAE9E,MAAMC,iBAAiB,CAACC,KAAaC;IACnC,MAAMC,eAAe,IAAIC,IAAI;QAAC;QAAa;QAAU;KAAW;IAEhE,MAAMC,OAAO,OAAOH;IAEpB,IAAIC,aAAaG,GAAG,CAACD,OAAO;QAC1B,MAAM,IAAIE,UACR,CAAC,0BAA0B,EAAEF,KAAK,aAAa,EAAEJ,IAAI,+CAA+C,CAAC;IAEzG;AACF;AAEA,OAAO,MAAMO;IAGF,CAAA,OAAQ,CAA4B;IAC5BC,eAA+B,CAACP,QAAUQ,KAAKC,KAAK,CAACT,OAAM;IAC3DU,aAA2B,CAACV,QAAUQ,KAAKG,SAAS,CAACX,OAAOY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,EAAE,OAAOC,OAAgB;YACvB,IAAI,AAACA,OAAeC,SAAS,UAAU;gBACrC,IAAI,CAACtB,gBAAgB;gBACrB,OAAOlC;YACT;YAEA,MAAMuD;QACR;IACF;IAEA,IAAIxB,MAAM1B,KAAQ,EAAE;QAClB,IAAI,CAAC6B,gBAAgB;QAErB,IAAI,CAACI,MAAM,CAACjC;QAEZ,IAAI,CAACa,MAAM,CAACuC,aAAa,CAAC,IAAIC,MAAM;IACtC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/versions/drafts/appendVersionToQueryKey.ts"],"sourcesContent":["import type { Where } from '../../types/index.js'\n\nexport const appendVersionToQueryKey = (query: Where): Where => {\n return Object.entries(query).reduce((res, [key, val]) => {\n if (['AND', '
|
|
1
|
+
{"version":3,"sources":["../../../src/versions/drafts/appendVersionToQueryKey.ts"],"sourcesContent":["import type { Where } from '../../types/index.js'\n\nexport const appendVersionToQueryKey = (query: Where): Where => {\n return Object.entries(query).reduce((res, [key, val]) => {\n if (['AND', 'and', 'OR', 'or'].includes(key) && Array.isArray(val)) {\n return {\n ...res,\n [key.toLowerCase()]: val.map((subQuery) => appendVersionToQueryKey(subQuery)),\n }\n }\n\n if (key !== 'id') {\n return {\n ...res,\n [`version.${key}`]: val,\n }\n }\n\n return {\n ...res,\n parent: val,\n }\n }, {})\n}\n"],"names":["appendVersionToQueryKey","query","Object","entries","reduce","res","key","val","includes","Array","isArray","toLowerCase","map","subQuery","parent"],"mappings":"AAEA,OAAO,MAAMA,0BAA0B,CAACC;IACtC,OAAOC,OAAOC,OAAO,CAACF,OAAOG,MAAM,CAAC,CAACC,KAAK,CAACC,KAAKC,IAAI;QAClD,IAAI;YAAC;YAAO;YAAO;YAAM;SAAK,CAACC,QAAQ,CAACF,QAAQG,MAAMC,OAAO,CAACH,MAAM;YAClE,OAAO;gBACL,GAAGF,GAAG;gBACN,CAACC,IAAIK,WAAW,GAAG,EAAEJ,IAAIK,GAAG,CAAC,CAACC,WAAab,wBAAwBa;YACrE;QACF;QAEA,IAAIP,QAAQ,MAAM;YAChB,OAAO;gBACL,GAAGD,GAAG;gBACN,CAAC,CAAC,QAAQ,EAAEC,IAAI,CAAC,CAAC,EAAEC;YACtB;QACF;QAEA,OAAO;YACL,GAAGF,GAAG;YACNS,QAAQP;QACV;IACF,GAAG,CAAC;AACN,EAAC"}
|
package/dist/versions/types.d.ts
CHANGED
|
@@ -10,19 +10,19 @@ export type SanitizedDrafts = {
|
|
|
10
10
|
validate: boolean;
|
|
11
11
|
};
|
|
12
12
|
export type IncomingCollectionVersions = {
|
|
13
|
-
drafts?:
|
|
13
|
+
drafts?: boolean | IncomingDrafts;
|
|
14
14
|
maxPerDoc?: number;
|
|
15
15
|
};
|
|
16
16
|
export interface SanitizedCollectionVersions extends Omit<IncomingCollectionVersions, 'drafts'> {
|
|
17
|
-
drafts:
|
|
17
|
+
drafts: false | SanitizedDrafts;
|
|
18
18
|
maxPerDoc?: number;
|
|
19
19
|
}
|
|
20
20
|
export type IncomingGlobalVersions = {
|
|
21
|
-
drafts?:
|
|
21
|
+
drafts?: boolean | IncomingDrafts;
|
|
22
22
|
max?: number;
|
|
23
23
|
};
|
|
24
24
|
export type SanitizedGlobalVersions = {
|
|
25
|
-
drafts:
|
|
25
|
+
drafts: false | SanitizedDrafts;
|
|
26
26
|
max: number;
|
|
27
27
|
};
|
|
28
28
|
export type TypeWithVersion<T> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/versions/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;I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SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,CAAC,CAAA;CACX,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/versions/types.ts"],"sourcesContent":["export type Autosave = {\n interval?: number\n}\n\nexport type IncomingDrafts = {\n autosave?: Autosave | boolean\n validate?: boolean\n}\n\nexport type SanitizedDrafts = {\n autosave: Autosave | false\n validate: boolean\n}\n\nexport type IncomingCollectionVersions = {\n drafts?:
|
|
1
|
+
{"version":3,"sources":["../../src/versions/types.ts"],"sourcesContent":["export type Autosave = {\n interval?: number\n}\n\nexport type IncomingDrafts = {\n autosave?: Autosave | boolean\n validate?: boolean\n}\n\nexport type SanitizedDrafts = {\n autosave: Autosave | false\n validate: boolean\n}\n\nexport type IncomingCollectionVersions = {\n drafts?: boolean | IncomingDrafts\n maxPerDoc?: number\n}\n\nexport interface SanitizedCollectionVersions extends Omit<IncomingCollectionVersions, 'drafts'> {\n drafts: false | SanitizedDrafts\n maxPerDoc?: number\n}\n\nexport type IncomingGlobalVersions = {\n drafts?: boolean | IncomingDrafts\n max?: number\n}\n\nexport type SanitizedGlobalVersions = {\n drafts: false | SanitizedDrafts\n max: number\n}\n\nexport type TypeWithVersion<T> = {\n createdAt: string\n id: string\n parent: number | string\n updatedAt: string\n version: T\n}\n"],"names":[],"mappings":"AAkCA,WAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.97",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"ts-essentials": "7.0.3",
|
|
97
97
|
"tsx": "4.17.0",
|
|
98
98
|
"uuid": "10.0.0",
|
|
99
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
99
|
+
"@payloadcms/translations": "3.0.0-beta.97"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|